Skip to content

Commit aa9491b

Browse files
committed
Also use last changed for integral
1 parent 8cb464d commit aa9491b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

custom_components/sat/pid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,14 @@ def _update_integral(self, state: TemperatureState) -> None:
192192
return
193193

194194
if self._last_integral_updated is None:
195-
self._last_integral_updated = state.last_reported.timestamp()
195+
self._last_integral_updated = state.last_changed.timestamp()
196196
return
197197

198-
delta_time = state.last_reported.timestamp() - self._last_integral_updated
198+
delta_time = state.last_changed.timestamp() - self._last_integral_updated
199199

200200
# Ignore non-forward timestamps.
201201
if delta_time <= 0:
202-
self._last_integral_updated = state.last_reported.timestamp()
202+
self._last_integral_updated = state.last_changed.timestamp()
203203
return
204204

205205
# Skip integration when integral gain is disabled.
@@ -210,7 +210,7 @@ def _update_integral(self, state: TemperatureState) -> None:
210210
self._integral = clamp_to_range(self._integral, self._heating_curve.value)
211211

212212
# Record the timestamp used for this integration step.
213-
self._last_integral_updated = state.last_reported.timestamp()
213+
self._last_integral_updated = state.last_changed.timestamp()
214214

215215
def _update_derivative(self, state: TemperatureState) -> None:
216216
"""Update the derivative term of the PID controller based on temperature slope."""

0 commit comments

Comments
 (0)