From fde4e42069147b332faf62140603d68b350b3262 Mon Sep 17 00:00:00 2001 From: atse Date: Fri, 4 Aug 2023 11:00:33 +0800 Subject: [PATCH] Set status first in _on_connection_changed --- pytec/tec_qt.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index bff5198..cb034ba 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -474,8 +474,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.port_set_spin.setEnabled(not result) self.connect_btn.setText("Disconnect" if result else "Connect") if result: + self.hw_rev_data = await self.client.hw_rev() + self._status(self.hw_rev_data) self.client_watcher.start_watching() - self._status(await self.client.hw_rev()) self.fan_update(await self.client.fan()) else: self.status_lbl.setText("Disconnected") @@ -485,6 +486,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.report_box.setChecked(False) await self.stop_report_mode() self.client_watcher.stop_watching() + self.status_lbl.setText("Disconnected") def _set_fan_pwm_warning(self): if self.fan_power_slider.value() != 100: @@ -498,7 +500,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): def _status(self, hw_rev_d: dict): logging.debug(hw_rev_d) - self.hw_rev_data = hw_rev_d self.status_lbl.setText(f"Connected to Thermostat v{hw_rev_d['rev']['major']}.{hw_rev_d['rev']['minor']}") self.fan_group.setEnabled(hw_rev_d["settings"]["fan_available"])