From d6f86c3435f1385883f41f54da9a841f89702e14 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 61eb27f..6b97cab 100644 --- a/pytec/pytec/gui/model/thermostat.py +++ b/pytec/pytec/gui/model/thermostat.py @@ -39,6 +39,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() @@ -63,8 +64,7 @@ class Thermostat(QObject, metaclass=PropertyMeta): self.connection_errored = True 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 f827838..41a03ae 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -133,9 +133,10 @@ class MainWindow(QtWidgets.QMainWindow): self.conn_menu.host_set_line.setEnabled(False) self.conn_menu.port_set_spin.setEnabled(False) 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: