Просмотр исходного кода

Diagnostics: handle API version not yet negotiated.

When API version is not yet negotiated, the index is set to None, which is
not a valid index to the versions array.  Diagnostics was blindly
using it as an index, but this case needs an exception.

From issue #907 log result
Jason Rumney 2 лет назад
Родитель
Сommit
cf8fefc02b
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      custom_components/tuya_local/diagnostics.py

+ 5 - 1
custom_components/tuya_local/diagnostics.py

@@ -75,7 +75,11 @@ def _async_device_as_dict(
     data = {
         "name": device.name,
         "api_version_set": device._api.version,
-        "api_version_used": API_PROTOCOL_VERSIONS[device._api_protocol_version_index],
+        "api_version_used": (
+            "none"
+            if device._api_protocol_version_index is None
+            else API_PROTOCOL_VERSIONS[device._api_protocol_version_index]
+        ),
         "api_working": device._api_protocol_working,
         "status": device._api.dps_cache,
         "cached_state": device._cached_state,