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

Device: don't delay updates if the connection is persistent

We currently insert a 1 second delay if commands are coming too frequently,
to avoid overloading devices with connections. But since we started using
persistent connections, this probably isn't necessary.

Issue #2410
Jason Rumney 1 год назад
Родитель
Сommit
c186dae362
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      custom_components/tuya_local/device.py

+ 2 - 2
custom_components/tuya_local/device.py

@@ -254,7 +254,7 @@ class TuyaLocalDevice(object):
 
     def pause(self):
         self._temporary_poll = True
-        self._api.setSocketPersistent(False)
+        self._api.setSocketPersistent(false)
         if self._api.parent:
             self._api.parent.setSocketPersistent(False)
 
@@ -506,7 +506,7 @@ class TuyaLocalDevice(object):
         # Only delay a second if there was recently another command.
         # Otherwise delay 1ms, to keep things simple by reusing the
         # same send mechanism.
-        waittime = 1 if since < 1.1 else 0.001
+        waittime = 1 if since < 1.1 and self.should_poll else 0.001
 
         await asyncio.sleep(waittime)
         await self._send_pending_updates()