Move reset request to thermostat control menu

We don't get auto reconnect anymore
This commit is contained in:
atse 2024-08-27 16:50:16 +08:00
parent 5a09c026fa
commit a8d7986c82
2 changed files with 8 additions and 15 deletions

View File

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

View File

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