Sfoglia il codice sorgente

Don't set api version on startup.

Setting the api version seems to involve a sleep in the latest tinytuya library.
This causes warnings in the HA log like:

```
Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for tuya_local doing blocking calls at custom_components/tuya_local/device.py, line 297: self._api.set_version(new_version)
```

This may be a contributor to #311.
Jason Rumney 3 anni fa
parent
commit
50fa1686d4
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 3 1
      custom_components/tuya_local/device.py

+ 3 - 1
custom_components/tuya_local/device.py

@@ -50,7 +50,6 @@ class TuyaLocalDevice(object):
         self._api = tinytuya.Device(dev_id, address, local_key)
         self._refresh_task = None
         self._protocol_configured = protocol_version
-        self._rotate_api_protocol_version()
 
         self._reset_cached_state()
 
@@ -246,6 +245,9 @@ class TuyaLocalDevice(object):
             self._lock.release()
 
     def _retry_on_failed_connection(self, func, error_message):
+        if self._api_protocol_version_index is None:
+            self._rotate_api_protocol_version()
+
         for i in range(self._CONNECTION_ATTEMPTS):
             try:
                 func()