From c761f9fe942f2f108e911436ff4b4f6cad92805d Mon Sep 17 00:00:00 2001 From: atse Date: Wed, 28 Aug 2024 16:32:31 +0800 Subject: [PATCH] Fix hwrev getting --- pytec/pytec/gui/model/thermostat.py | 4 ++-- pytec/tec_qt.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pytec/pytec/gui/model/thermostat.py b/pytec/pytec/gui/model/thermostat.py index f125fdc..3d6b7b9 100644 --- a/pytec/pytec/gui/model/thermostat.py +++ b/pytec/pytec/gui/model/thermostat.py @@ -38,6 +38,7 @@ class Thermostat(QObject, metaclass=PropertyMeta): async def start_session(self, host, port): self.connection_state_changed.emit(ThermostatConnectionState.CONNECTING) await self._client.connect(host, port) + self.hw_rev = await self.get_hw_rev() self.connection_state_changed.emit(ThermostatConnectionState.CONNECTED) self.start_watching() @@ -58,8 +59,7 @@ class Thermostat(QObject, metaclass=PropertyMeta): await asyncio.sleep(self._update_s) async def get_hw_rev(self): - self.hw_rev = await self._client.hw_rev() - return self.hw_rev + return await self._client.hw_rev() async def update_params(self): fan_task = asyncio.create_task(self._client.get_fan()) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index b395f52..463abf4 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -141,9 +141,10 @@ class MainWindow(QtWidgets.QMainWindow): match state: case ThermostatConnectionState.CONNECTED: self.connect_btn.setText("Disconnect") - hw_rev_d = await self.thermostat.get_hw_rev() self.status_lbl.setText( - f"Connected to Thermostat v{hw_rev_d['rev']['major']}.{hw_rev_d['rev']['minor']}" + "Connected to Thermostat v" + f"{self.thermostat.hw_rev['rev']['major']}." + f"{self.thermostat.hw_rev['rev']['minor']}" ) case ThermostatConnectionState.CONNECTING: