فهرست منبع

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 سال پیش
والد
کامیت
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
         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()