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

fix(device): don't passively listen for updates with 3.4 protocol

Protocol 3.4 devices seem to have problems eventually with passive listening without
sending anything. It is possibly an issue in the tinytuya library, where calling receive
is not just listening, but renegotiating the session key without any command being sent.

Such devices didn't seem to have issues with the 10x/second heartbeats before, so
revert to that for 3.4 devices.

Issue #5136
Jason Rumney 2 недель назад
Родитель
Сommit
dc51a499a8
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      custom_components/tuya_local/device.py

+ 5 - 1
custom_components/tuya_local/device.py

@@ -373,7 +373,11 @@ class TuyaLocalDevice(object):
                     self._last_full_poll = now
                     last_heartbeat = now  # reset heartbeat timer on full poll
                 elif persist:
-                    if now - last_heartbeat > self._HEARTBEAT_INTERVAL:
+                    if (
+                        now - last_heartbeat > self._HEARTBEAT_INTERVAL
+                        # 3.4 devices seem to require more frequent heartbeats to work reliably
+                        or self._api_protocol_version_index == 3
+                    ):
                         await self._hass.async_add_executor_job(
                             self._api.heartbeat,
                             True,