forked from M-Labs/thermostat
Move reset request to thermostat control menu
We don't get auto reconnect anymore
This commit is contained in:
parent
3aeef04330
commit
72ca1f16a9
|
@ -6,8 +6,6 @@ from pytec.gui.view.net_settings_input_diag import NetSettingsInputDiag
|
||||||
|
|
||||||
|
|
||||||
class ThermostatCtrlMenu(QtWidgets.QMenu):
|
class ThermostatCtrlMenu(QtWidgets.QMenu):
|
||||||
reset_act = pyqtSignal(bool)
|
|
||||||
|
|
||||||
def __init__(self, thermostat, style):
|
def __init__(self, thermostat, style):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._thermostat = thermostat
|
self._thermostat = thermostat
|
||||||
|
@ -56,7 +54,7 @@ class ThermostatCtrlMenu(QtWidgets.QMenu):
|
||||||
self.fan = fan
|
self.fan = fan
|
||||||
|
|
||||||
self.actionReset = QtGui.QAction("Reset Thermostat", self)
|
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.addAction(self.actionReset)
|
||||||
|
|
||||||
self.actionEnter_DFU_Mode = QtGui.QAction("Enter DFU Mode", self)
|
self.actionEnter_DFU_Mode = QtGui.QAction("Enter DFU Mode", self)
|
||||||
|
@ -177,6 +175,13 @@ class ThermostatCtrlMenu(QtWidgets.QMenu):
|
||||||
self.fan_power_slider.value()
|
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)
|
@asyncSlot(bool)
|
||||||
async def dfu_request(self, _):
|
async def dfu_request(self, _):
|
||||||
assert self._thermostat.connected()
|
assert self._thermostat.connected()
|
||||||
|
|
|
@ -117,8 +117,6 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.connect_btn.setMenu(self.conn_menu)
|
self.connect_btn.setMenu(self.conn_menu)
|
||||||
|
|
||||||
self.thermostat_ctrl_menu = ThermostatCtrlMenu(self.thermostat, self.style())
|
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.thermostat_settings.setMenu(self.thermostat_ctrl_menu)
|
||||||
|
|
||||||
self.loading_spinner.hide()
|
self.loading_spinner.hide()
|
||||||
|
@ -250,16 +248,6 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.loading_spinner.start()
|
self.loading_spinner.start()
|
||||||
self.loading_spinner.show()
|
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():
|
async def coro_main():
|
||||||
args = get_argparser().parse_args()
|
args = get_argparser().parse_args()
|
||||||
|
|
Loading…
Reference in New Issue