Skip to content

Commit

Permalink
Diagnostics: handle API version not yet negotiated.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
make-all committed Aug 13, 2023
1 parent cc051de commit cf8fefc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/tuya_local/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit cf8fefc

Please sign in to comment.