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