From b53a959a52ebd867ec8901cf78f376fbca970e6a Mon Sep 17 00:00:00 2001 From: Lukas Klass Date: Sun, 22 Oct 2023 09:27:27 +0200 Subject: [PATCH] Update PID controller on every entity change This updates the PID controller whenever any entity state change occurs. To stabilize this, sample_time must be set. This approach only works, when enough entity changes occur in home-assistant but the approach is still better than the current implementation. --- custom_components/pid_controller/sensor.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/custom_components/pid_controller/sensor.py b/custom_components/pid_controller/sensor.py index a9c0139..f4aa36b 100644 --- a/custom_components/pid_controller/sensor.py +++ b/custom_components/pid_controller/sensor.py @@ -797,8 +797,7 @@ def _update_sensor(self, entity=None) -> None: self.reset_pid() self._pid.set_point = set_point - if entity == self._source: - self._pid.update(source) + self._pid.update(source) output = float(self._pid.output)