Set status first in _on_connection_changed

This commit is contained in:
atse 2023-08-04 11:00:33 +08:00
parent 3c9541fea2
commit fde4e42069
1 changed files with 3 additions and 2 deletions

View File

@ -474,8 +474,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.port_set_spin.setEnabled(not result) self.port_set_spin.setEnabled(not result)
self.connect_btn.setText("Disconnect" if result else "Connect") self.connect_btn.setText("Disconnect" if result else "Connect")
if result: if result:
self.hw_rev_data = await self.client.hw_rev()
self._status(self.hw_rev_data)
self.client_watcher.start_watching() self.client_watcher.start_watching()
self._status(await self.client.hw_rev())
self.fan_update(await self.client.fan()) self.fan_update(await self.client.fan())
else: else:
self.status_lbl.setText("Disconnected") self.status_lbl.setText("Disconnected")
@ -485,6 +486,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.report_box.setChecked(False) self.report_box.setChecked(False)
await self.stop_report_mode() await self.stop_report_mode()
self.client_watcher.stop_watching() self.client_watcher.stop_watching()
self.status_lbl.setText("Disconnected")
def _set_fan_pwm_warning(self): def _set_fan_pwm_warning(self):
if self.fan_power_slider.value() != 100: if self.fan_power_slider.value() != 100:
@ -498,7 +500,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def _status(self, hw_rev_d: dict): def _status(self, hw_rev_d: dict):
logging.debug(hw_rev_d) 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.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"]) self.fan_group.setEnabled(hw_rev_d["settings"]["fan_available"])