ScratMan / HASmartThermostat

Smart Thermostat with PID controller for HomeAssistant
338 stars 49 forks source link

Output is set to 0 when temperature sensor is stable more then 3 hours #48

Closed bamnoru closed 2 years ago

bamnoru commented 2 years ago

Hi @ScratMan

Unfortunately, I've got temperature sensors that send an update only when the value changes. This night, when the PID values were stable (P:0, I:7, D:0), and the temperature also, the output suddenly cames to 0, and, cut off the heaters until the temperature drops.

This is due to these lines (#731) :

            if time.time() - self._last_sensor_update > 10800:
                # sensor not updated for more than 3 hours, considered as stall, set to 0 for safety
                self._control_output = 0

Maybe this value of "10800" should be a parameter, and, if the value is "0", this safety rule will be disabled

ScratMan commented 2 years ago

This was expected, I didn't know if it could occur, but you proved that yes, it can. I added the sensor_stall and output_safety settings to the thermostat. The first one allows adjusting the threshold or disable the feature (setting to 0), while the second adjusts the output level that the thermostat will use in case the temperature sensor becomes unresponsive, so that the heating remains on for a minimum of time vs PWM.