4
0
Эх сурвалжийг харах

fix(device): revert last 2 "fixes" for protocol 3.4 devices

- increase of retry limit from 1 to 2: seems to have made the problem worse for some devices,
  even though the logs show that with a limit of 1 most cases of null response were able to
  recover, and only when there were 2 in a row the problems emerged. Now trying no retries,
  to eliminate any extra actions tinytuya is doing as part of retrying failed commands.

- sending heartbeats every time around the loop: not sending heartbeats was the main change
  in 3.3->4.0 timeframe that was suspected to cause the issue, but reverting this for 3.4
  devices has only made the problem worse, so this does not seem to be the root cause.
  This makes sense, since heartbeats every 0.1s are likely to overload devices, which is the
  reason this change was made in the first place, and review of tinytuya code shows that
  calling receive should not send anything to the device, so it should just be getting any
  unsolicited messages the device has sent in between heartbeats.

Issue #5347
Jason Rumney 2 долоо хоног өмнө
parent
commit
aa8913166e

+ 3 - 10
custom_components/tuya_local/device.py

@@ -127,13 +127,10 @@ class TuyaLocalDevice(object):
             raise e
             raise e
 
 
         # we handle retries at a higher level so we can rotate protocol version
         # we handle retries at a higher level so we can rotate protocol version
-        # on the other hand, protocol 3.4 devices send encrypted null ACKs that
-        # often get mixed in, so we need to retry a couple of times before resorting
-        # to recovery measures that seem to make things worse.
-        self._api.set_socketRetryLimit(2)
+        self._api.set_socketRetryLimit(0)
         if self._api.parent:
         if self._api.parent:
             # Retries cause problems for other children of the parent device
             # Retries cause problems for other children of the parent device
-            self._api.parent.set_socketRetryLimit(1)
+            self._api.parent.set_socketRetryLimit(0)
 
 
         self._refresh_task = None
         self._refresh_task = None
         self._protocol_configured = protocol_version
         self._protocol_configured = protocol_version
@@ -373,11 +370,7 @@ class TuyaLocalDevice(object):
                     self._last_full_poll = now
                     self._last_full_poll = now
                     last_heartbeat = now  # reset heartbeat timer on full poll
                     last_heartbeat = now  # reset heartbeat timer on full poll
                 elif persist:
                 elif persist:
-                    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
-                    ):
+                    if now - last_heartbeat > self._HEARTBEAT_INTERVAL:
                         await self._hass.async_add_executor_job(
                         await self._hass.async_add_executor_job(
                             self._api.heartbeat,
                             self._api.heartbeat,
                             True,
                             True,