diff --git a/pytec/pytec/gui/view/thermostat_ctrl_menu.py b/pytec/pytec/gui/view/thermostat_ctrl_menu.py index 2fe2047..6a14597 100644 --- a/pytec/pytec/gui/view/thermostat_ctrl_menu.py +++ b/pytec/pytec/gui/view/thermostat_ctrl_menu.py @@ -1,3 +1,4 @@ +import logging from PyQt6 import QtWidgets, QtGui, QtCore from PyQt6.QtCore import pyqtSignal, pyqtSlot, QSignalBlocker from qasync import asyncSlot @@ -45,6 +46,7 @@ class ThermostatCtrlMenu(QtWidgets.QMenu): self.fan_power_slider.valueChanged.connect(self.fan_set_request) self.fan_auto_box.stateChanged.connect(self.fan_auto_set_request) + self._thermostat.fan_update.connect(self.fan_update) self.fan_lbl.setToolTip("Adjust the fan") self.fan_lbl.setText("Fan:") @@ -125,6 +127,20 @@ class ThermostatCtrlMenu(QtWidgets.QMenu): self.actionAbout_Thermostat.triggered.connect(about_thermostat) self.addAction(self.actionAbout_Thermostat) + @pyqtSlot("QVariantMap") + def fan_update(self, fan_settings): + logging.debug(fan_settings) + if fan_settings is None: + return + with QSignalBlocker(self.fan_power_slider): + self.fan_power_slider.setValue( + fan_settings["fan_pwm"] or 100 # 0 = PWM off = full strength + ) + with QSignalBlocker(self.fan_auto_box): + self.fan_auto_box.setChecked(fan_settings["auto_mode"]) + if not self.hw_rev_data["settings"]["fan_pwm_recommended"]: + self.set_fan_pwm_warning() + def set_fan_pwm_warning(self): if self.fan_power_slider.value() != 100: pixmapi = getattr(QtWidgets.QStyle.StandardPixmap, "SP_MessageBoxWarning") diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index f5c77d7..1c52d0e 100755 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -110,7 +110,6 @@ class MainWindow(QtWidgets.QMainWindow): self.zero_limits_warning.set_limits_warning ) - self.thermostat.fan_update.connect(self.fan_update) self.thermostat.report_update.connect(self.autotuners.tick) self.thermostat.report_update.connect(self.pid_autotune_handler) self.thermostat.interval_update.connect( @@ -209,20 +208,6 @@ class MainWindow(QtWidgets.QMainWindow): f"Connected to Thermostat v{hw_rev_d['rev']['major']}.{hw_rev_d['rev']['minor']}" ) - @pyqtSlot("QVariantMap") - def fan_update(self, fan_settings): - logging.debug(fan_settings) - if fan_settings is None: - return - with QSignalBlocker(self.thermostat_ctrl_menu.fan_power_slider): - self.thermostat_ctrl_menu.fan_power_slider.setValue( - fan_settings["fan_pwm"] or 100 # 0 = PWM off = full strength - ) - with QSignalBlocker(self.thermostat_ctrl_menu.fan_auto_box): - self.thermostat_ctrl_menu.fan_auto_box.setChecked(fan_settings["auto_mode"]) - if not self.hw_rev_data["settings"]["fan_pwm_recommended"]: - self.thermostat_ctrl_menu.set_fan_pwm_warning() - @asyncSlot(int) async def on_report_box_stateChanged(self, enabled): await self.thermostat.set_report_mode(enabled)