From a8d7986c82ad1c8167535be9c1d8e53c541b464f Mon Sep 17 00:00:00 2001 From: atse Date: Tue, 27 Aug 2024 16:50:16 +0800 Subject: [PATCH] Move reset request to thermostat control menu We don't get auto reconnect anymore --- pytec/pytec/gui/view/thermostat_ctrl_menu.py | 11 ++++++++--- pytec/tec_qt.py | 12 ------------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/pytec/pytec/gui/view/thermostat_ctrl_menu.py b/pytec/pytec/gui/view/thermostat_ctrl_menu.py index 4201e77..c3493af 100644 --- a/pytec/pytec/gui/view/thermostat_ctrl_menu.py +++ b/pytec/pytec/gui/view/thermostat_ctrl_menu.py @@ -6,8 +6,6 @@ from pytec.gui.view.net_settings_input_diag import NetSettingsInputDiag class ThermostatCtrlMenu(QtWidgets.QMenu): - reset_act = pyqtSignal(bool) - def __init__(self, thermostat, style): super().__init__() self._thermostat = thermostat @@ -56,7 +54,7 @@ class ThermostatCtrlMenu(QtWidgets.QMenu): self.fan = fan self.actionReset = QtGui.QAction("Reset Thermostat", self) - self.actionReset.triggered.connect(self.reset_act) + self.actionReset.triggered.connect(self.reset_request) self.addAction(self.actionReset) self.actionEnter_DFU_Mode = QtGui.QAction("Enter DFU Mode", self) @@ -177,6 +175,13 @@ class ThermostatCtrlMenu(QtWidgets.QMenu): self.fan_power_slider.value() ) + @asyncSlot(bool) + async def reset_request(self, _): + assert self._thermostat.connected() + + await self._thermostat.reset() + await self._thermostat.end_session() + @asyncSlot(bool) async def dfu_request(self, _): assert self._thermostat.connected() diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index d206d20..f95a3c1 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -119,8 +119,6 @@ class MainWindow(QtWidgets.QMainWindow): self.connect_btn.setMenu(self.conn_menu) self.thermostat_ctrl_menu = ThermostatCtrlMenu(self.thermostat, self.style()) - self.thermostat_ctrl_menu.reset_act.connect(self.reset_request) - self.thermostat_settings.setMenu(self.thermostat_ctrl_menu) self.loading_spinner.hide() @@ -259,16 +257,6 @@ class MainWindow(QtWidgets.QMainWindow): self.loading_spinner.start() self.loading_spinner.show() - @asyncSlot(bool) - async def reset_request(self, _): - assert self.thermostat.connected() - - await self.thermostat.reset() - await self.thermostat.end_session() - await asyncio.sleep(0.1) # Wait for the reset to start - - self.connect_btn.click() # Reconnect - async def coro_main(): args = get_argparser().parse_args()