forked from M-Labs/thermostat
Stop polling drift
Just waiting for the update_s doesn't take into account the time to execute update_params, and causes time drift.
This commit is contained in:
parent
ed2f5a690f
commit
e5a8f8b1f8
@ -46,9 +46,11 @@ class ClientWatcher(QObject):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
async def run(self):
|
async def run(self):
|
||||||
|
loop = asyncio.get_running_loop()
|
||||||
while self.running:
|
while self.running:
|
||||||
|
time = loop.time()
|
||||||
await self.update_params()
|
await self.update_params()
|
||||||
await asyncio.sleep(self.update_s)
|
await asyncio.sleep(self.update_s - (loop.time() - time))
|
||||||
|
|
||||||
async def update_params(self):
|
async def update_params(self):
|
||||||
self.fan_update.emit(await self._client.get_fan())
|
self.fan_update.emit(await self._client.get_fan())
|
||||||
|
Loading…
Reference in New Issue
Block a user