forked from M-Labs/thermostat
Reset button
This commit is contained in:
parent
998d999b59
commit
8f31380d52
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -449,6 +449,17 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<action name="actionReset">
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset the Thermostat</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user