ScratMan / HASmartThermostat

Smart Thermostat with PID controller for HomeAssistant
353 stars 50 forks source link

Integral component keeps constant in some cases #74

Closed enredador closed 2 years ago

enredador commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

Integral component does not reduce when temperature is over setpoint. It keeps constant.

To Reproduce Steps to reproduce the behavior: Change setpoint under actual temperature

Expected behavior It should reduce itself to 0 smoothly.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context The problem can be solved changing this line in pid_controller/init.py:

if self._out_min < self._last_output < self._out_max and \ to: if self._out_min <= self._last_output <= self._out_max and \

As it is now, when output falls to 0 and do not change, the integral component do not vary.

gasman1844 commented 2 years ago

I have reproduced this issue. I've set up a test temperature sensor (using an input number) and so can simulate a number of scenarios. I also see the behaviour described above and I also tried the fix which saw the integral component start to vary above set-point.

ScratMan commented 2 years ago

This is not an issue, integral will only update if the heating is modulated, that means if the PWM output is not 0 and not 100%, to avoid windup and to make sure any external heating source (like sun through window) won't make the integral go down to 0. Otherwise, once external heating source disappear, your heating system will restart from scratch requiring to converge again to the optimal integral value

TippyLion28 commented 1 year ago

As a workaround, I've created an automation which calls the reset integral gain service if the heater is not powered up for 30 minutes.