Просмотр исходного кода

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 лет назад
Родитель
Сommit
30c2cee351
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      custom_components/tuya_local/device.py

+ 1 - 1
custom_components/tuya_local/device.py

@@ -81,7 +81,7 @@ class TuyaLocalDevice(object):
         self._CACHE_TIMEOUT = 120
         # More attempts are needed in auto mode so we can cycle through all
         # 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._lock = Lock()