Ver Fonte

fix(device): ensure persistent connection is reestablished after error

When the persistent connection has been closed due to an error, ensure that
this is detected and the persistent connection reestablished next time
around the receive loop.

Issue #6112, originally #6054 which was reverted in the last commit.
Jason Rumney há 1 mês atrás
pai
commit
899a4eb85d
1 ficheiros alterados com 3 adições e 1 exclusões
  1. 3 1
      custom_components/tuya_local/device.py

+ 3 - 1
custom_components/tuya_local/device.py

@@ -350,7 +350,9 @@ class TuyaLocalDevice(object):
                 last_cache = self._cached_state.get("updated_at", 0)
                 last_cache = self._cached_state.get("updated_at", 0)
                 now = time()
                 now = time()
                 full_poll = False
                 full_poll = False
-                if persist == self.should_poll:
+                if (persist == self.should_poll) or (
+                    persist and (self._api.socket is None)
+                ):
                     # use persistent connections after initial communication
                     # use persistent connections after initial communication
                     # has been established.  Until then, we need to rotate
                     # has been established.  Until then, we need to rotate
                     # the protocol version, which seems to require a fresh
                     # the protocol version, which seems to require a fresh