Fix hwrev getting

This commit is contained in:
atse 2024-08-28 16:32:31 +08:00
parent 6e9ded532b
commit d6f86c3435
2 changed files with 5 additions and 4 deletions

View File

@ -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())

View File

@ -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: