Преглед изворни кода

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 пре 1 дан
родитељ
комит
899a4eb85d
1 измењених фајлова са 3 додато и 1 уклоњено
  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)
                 now = time()
                 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
                     # has been established.  Until then, we need to rotate
                     # the protocol version, which seems to require a fresh