params update concurrently

This commit is contained in:
atse 2024-08-23 13:36:46 +08:00
parent 067ab925dd
commit f93e76eaa0

View File

@ -64,16 +64,23 @@ class Thermostat(QObject, metaclass=PropertyMeta):
return self.hw_rev return self.hw_rev
async def update_params(self): async def update_params(self):
self.fan = await self._client.get_fan() fan_task = asyncio.create_task(self._client.get_fan())
self.pwm = await self._client.get_pwm() pwm_task = asyncio.create_task(self._client.get_pwm())
pid_task = asyncio.create_task(self._client.get_pid())
report_task = asyncio.create_task(self._client.report())
thermistor_task = asyncio.create_task(self._client.get_steinhart_hart())
postfilter_task = asyncio.create_task(self._client.get_postfilter())
self.fan = await fan_task
self.pwm = await pwm_task
if self._poll_for_report: if self._poll_for_report:
self.report = await self._client.report() self.report = await report_task
self.interval = [ self.interval = [
self.report[i]["interval"] for i in range(len(self.report)) self.report[i]["interval"] for i in range(len(self.report))
] ]
self.pid = await self._client.get_pid() self.pid = await pid_task
self.thermistor = await self._client.get_steinhart_hart() self.thermistor = await thermistor_task
self.postfilter = await self._client.get_postfilter() self.postfilter = await postfilter_task
def connected(self): def connected(self):
return self._client.connected() return self._client.connected()