I use PID controller with input that is quite small and quite often drops below zero. When input drops below zero, the PID integration does not work. Saturation prevents decrementing the integral value i_term when input is less than zero.
# Calculate I and avoids Sturation
if self._last_output is None or (
self._last_output > 0 and self._last_output < 100
):
self._i_term += self._ki * error * delta_time
self._i_term = self.clamp_value(self._i_term, self._windup)
I use PID controller with input that is quite small and quite often drops below zero. When input drops below zero, the PID integration does not work. Saturation prevents decrementing the integral value
i_termwhen input is less than zero.I fixed mine by setting the comparison
self._last_output > -100 and self._last_output < 100https://github.com/soloam/ha-pid-controller/blob/60052392bdaa114dc9296fcf7d3b58db48129993/custom_components/pid_controller/pidcontroller.py#L88C1-L90C11