Repository navigation
Replies: 1 comment
|
Done in release 2026.11.0, thanks for suggestion |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Context
The PID is recalculated on state_changed events from the target sensor. Many sensors (e.g. Zigbee2MQTT devices such as the Aqara air monitor) only produce a state change when the value changes, so with a stable temperature the gap between two calculations can be long (55 min in my case).
Current behaviour (pid_controller/init.py)
The new error is applied to the whole elapsed interval, although during that interval the measured temperature was the previous one.
Real example (v2026.10.2, ki = 0.007)
Temperature stable at 19.96 °C (setpoint 20) for ~55 min.
An oven raises the room to 20.57 °C, so the next sensor update arrives with error = −0.57.
Integral update: 0.007 × (−0.57) × 3292 s ≈ −13.1. Observed: 7.9 → −5.3.
With the previous error applied to that interval, the change would have been about +0.9, followed by normal integration of the overshoot.
Result: the integral loses hours of accumulated heating demand, and the heater restarts late once the extra heat source is gone. It is especially visible with high-inertia systems (electric underfloor heating).
Proposal
Integrate using the trapezoidal rule (or the previous error):
with _last_error stored at the end of each calculation (and reset when the integral is cleared or the setpoint changes). This is a small change, and it makes the integral independent of how often the sensor reports.
All reactions