4
0
Эх сурвалжийг харах

Calculate AUTO_CONNECTION_ATTEMPTS from API_PROTOCOL_VERSIONS length

To reduce the number of changes required if this is expanded again in
future, and avoid forgetting to bump it, calculate instead of using a fixed
number.  Tests will still need updating.
Jason Rumney 3 жил өмнө
parent
commit
30c2cee351

+ 1 - 1
custom_components/tuya_local/device.py

@@ -81,7 +81,7 @@ class TuyaLocalDevice(object):
         self._CACHE_TIMEOUT = 120
         self._CACHE_TIMEOUT = 120
         # More attempts are needed in auto mode so we can cycle through all
         # More attempts are needed in auto mode so we can cycle through all
         # the possibilities a couple of times
         # the possibilities a couple of times
-        self._AUTO_CONNECTION_ATTEMPTS = 11
+        self._AUTO_CONNECTION_ATTEMPTS = len(API_PROTOCOL_VERSIONS) * 2 + 1
         self._SINGLE_PROTO_CONNECTION_ATTEMPTS = 3
         self._SINGLE_PROTO_CONNECTION_ATTEMPTS = 3
         self._lock = Lock()
         self._lock = Lock()