forked from M-Labs/thermostat
Use asserts to check for connectivity
This commit is contained in:
parent
9c0977262c
commit
c3d7804898
@ -359,8 +359,8 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
@asyncSlot(int)
|
||||
async def fan_set_request(self, value):
|
||||
if not self.client.connected():
|
||||
return
|
||||
assert self.client.connected()
|
||||
|
||||
if self.thermostat_ctrl_menu.fan_auto_box.isChecked():
|
||||
with QSignalBlocker(self.thermostat_ctrl_menu.fan_auto_box):
|
||||
self.thermostat_ctrl_menu.fan_auto_box.setChecked(False)
|
||||
@ -370,8 +370,8 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
@asyncSlot(int)
|
||||
async def fan_auto_set_request(self, enabled):
|
||||
if not self.client.connected():
|
||||
return
|
||||
assert self.client.connected()
|
||||
|
||||
if enabled:
|
||||
await self.client.set_fan("auto")
|
||||
self.fan_update(await self.client.get_fan())
|
||||
@ -382,19 +382,27 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
@asyncSlot(int)
|
||||
async def save_cfg_request(self, ch):
|
||||
assert self.thermostat.connected()
|
||||
|
||||
await self.thermostat.save_cfg(str(ch))
|
||||
|
||||
@asyncSlot(int)
|
||||
async def load_cfg_request(self, ch):
|
||||
assert self.thermostat.connected()
|
||||
|
||||
await self.thermostat.load_cfg(str(ch))
|
||||
|
||||
@asyncSlot(bool)
|
||||
async def dfu_request(self, _):
|
||||
assert self.thermostat.connected()
|
||||
|
||||
await self._on_connection_changed(False)
|
||||
await self.thermostat.dfu()
|
||||
|
||||
@asyncSlot(bool)
|
||||
async def reset_request(self, _):
|
||||
assert self.thermostat.connected()
|
||||
|
||||
await self._on_connection_changed(False)
|
||||
await self.thermostat.reset()
|
||||
await asyncio.sleep(0.1) # Wait for the reset to start
|
||||
@ -403,12 +411,16 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
@asyncSlot(bool)
|
||||
async def net_settings_request(self, _):
|
||||
assert self.thermostat.connected()
|
||||
|
||||
ipv4 = await self.thermostat.get_ipv4()
|
||||
self.net_settings_input_diag = NetSettingsInputDiag(ipv4["addr"])
|
||||
self.net_settings_input_diag.set_ipv4_act.connect(self.set_net_settings_request)
|
||||
|
||||
@asyncSlot(str)
|
||||
async def set_net_settings_request(self, ipv4_settings):
|
||||
assert self.thermostat.connected()
|
||||
|
||||
await self.thermostat.set_ipv4(ipv4_settings)
|
||||
await self.thermostat._client.end_session()
|
||||
await self._on_connection_changed(False)
|
||||
|
Loading…
Reference in New Issue
Block a user