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

cleanup(device): rename CACHE_TIMEOUT to POLLING_INTERVAL

_CACHE_TIMEOUT is a confusing name, as there is no cache, and it is easily confused
with _FAKE_IT_TIMEOUT for the interim values used after sending to avoid lag in the UI.

Instead name it _POLLING_INTERVAL to link it with _HEARTBEAT_INTERVAL and full_poll
Jason Rumney 17 часов назад
Родитель
Сommit
aa513d7a65
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      custom_components/tuya_local/device.py

+ 3 - 3
custom_components/tuya_local/device.py

@@ -156,7 +156,7 @@ class TuyaLocalDevice(object):
         # we can overlay onto the state while we wait for the board to update
         # its switches.
         self._FAKE_IT_TIMEOUT = 5
-        self._CACHE_TIMEOUT = 30
+        self._POLLING_INTERVAL = 30
         self._HEARTBEAT_INTERVAL = 5
         # More attempts are needed in auto mode so we can cycle through all
         # the possibilities a couple of times
@@ -364,8 +364,8 @@ class TuyaLocalDevice(object):
                         self._api.parent.set_socketPersistent(persist)
                     self._last_full_poll = 0  # ensure we start with a full poll
 
-                needs_full_poll = now - self._last_full_poll > self._CACHE_TIMEOUT
-                if now - last_cache > self._CACHE_TIMEOUT or (
+                needs_full_poll = now - self._last_full_poll > self._POLLING_INTERVAL
+                if now - last_cache > self._POLLING_INTERVAL or (
                     persist and needs_full_poll
                 ):
                     if (