فهرست منبع

Device: when stopping or pausing, force non-persistent connection

This is done for the side-effect that underlying library will call close()
on the socket when setting persistent connection to false, in the hope that
it might solve some reconfiguration problems when devices are not responding.

Issue #1804, #1013, Discussion #2354 among others.
Jason Rumney 1 سال پیش
والد
کامیت
3fafb5fee2
1فایلهای تغییر یافته به همراه6 افزوده شده و 0 حذف شده
  1. 6 0
      custom_components/tuya_local/device.py

+ 6 - 0
custom_components/tuya_local/device.py

@@ -178,6 +178,9 @@ class TuyaLocalDevice(object):
         self._children.clear()
         self._force_dps.clear()
         if self._refresh_task:
+            self._api.set_socketPersistent(False)
+            if self._api.parent:
+                self._api.parent.set_socketPersistent(False)
             await self._refresh_task
         _LOGGER.debug("Monitor loop for %s stopped", self.name)
         self._refresh_task = None
@@ -251,6 +254,9 @@ class TuyaLocalDevice(object):
 
     def pause(self):
         self._temporary_poll = True
+        self._api.setSocketPersistent(false)
+        if self._api.parent:
+            self._api.parent.setSocketPersistent(false)
 
     def resume(self):
         self._temporary_poll = False