Parcourir la source

Don't try touse updatedps before the protocol is working.

The addition of updatedps seems to be interfering with api protocol detection.
Don't use it until the protocol has been detected.
Jason Rumney il y a 3 ans
Parent
commit
33141b8815
1 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 5 1
      custom_components/tuya_local/device.py

+ 5 - 1
custom_components/tuya_local/device.py

@@ -232,7 +232,11 @@ class TuyaLocalDevice(object):
                     self._api.set_socketPersistent(persist)
                     self._api.set_socketPersistent(persist)
 
 
                 if now - last_cache > self._CACHE_TIMEOUT:
                 if now - last_cache > self._CACHE_TIMEOUT:
-                    if self._force_dps and not dps_updated:
+                    if (
+                        self._force_dps
+                        and not dps_updated
+                        and self._api_protocol_working
+                    ):
                         poll = await self._retry_on_failed_connection(
                         poll = await self._retry_on_failed_connection(
                             lambda: self._api.updatedps(self._force_dps),
                             lambda: self._api.updatedps(self._force_dps),
                             f"Failed to refresh device state for {self.name}",
                             f"Failed to refresh device state for {self.name}",