diff --git a/pytec/pytec/aioclient.py b/pytec/pytec/aioclient.py index 6248dac..d07ebce 100644 --- a/pytec/pytec/aioclient.py +++ b/pytec/pytec/aioclient.py @@ -223,3 +223,14 @@ class Client: async def fan(self): """Get Thermostat current fan settings""" return await self._command("fan") + + async def reset(self): + """Reset the Thermostat + + The client is disconnected as the TCP session is terminated. + """ + async with self._command_lock: + self._writer.write("reset\n".encode('utf-8')) + await self._writer.drain() + + await self.disconnect() diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 5bd1b00..ed3d189 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -304,6 +304,17 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): self.menu.addAction(fan) self.menu.fan = fan + @asyncSlot(bool) + async def reset_thermostat(_): + await self._on_connection_changed(False) + await self.tec_client.reset() + await asyncio.sleep(0.1) # Wait for the reset to start + + self.connect_btn.click() # Reconnect + + self.actionReset.triggered.connect(reset_thermostat) + self.menu.addAction(self.actionReset) + self.thermostat_settings.setMenu(self.menu) self.plot_menu = QtWidgets.QMenu() diff --git a/pytec/tec_qt.ui b/pytec/tec_qt.ui index a9e45be..aa28348 100644 --- a/pytec/tec_qt.ui +++ b/pytec/tec_qt.ui @@ -449,6 +449,17 @@ + + + Reset + + + Reset the Thermostat + + + QAction::NoRole + + diff --git a/pytec/ui_tec_qt.py b/pytec/ui_tec_qt.py index 8c5a61d..a6b44b9 100644 --- a/pytec/ui_tec_qt.py +++ b/pytec/ui_tec_qt.py @@ -195,6 +195,9 @@ class Ui_MainWindow(object): self.main_layout.addWidget(self.bottom_settings_group) self.gridLayout_2.addLayout(self.main_layout, 0, 1, 1, 1) MainWindow.setCentralWidget(self.main_widget) + self.actionReset = QtGui.QAction(parent=MainWindow) + self.actionReset.setMenuRole(QtGui.QAction.MenuRole.NoRole) + self.actionReset.setObjectName("actionReset") self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) @@ -213,6 +216,8 @@ class Ui_MainWindow(object): self.report_refresh_spin.setSuffix(_translate("MainWindow", " s")) self.report_box.setText(_translate("MainWindow", "Report")) self.report_apply_btn.setText(_translate("MainWindow", "Apply")) + self.actionReset.setText(_translate("MainWindow", "Reset")) + self.actionReset.setToolTip(_translate("MainWindow", "Reset the Thermostat")) from pglive.sources.live_plot_widget import LivePlotWidget from pyqtgraph.parametertree import ParameterTree