-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Time Simple Moving Average shows wrong state when the input sensor doesn't change state #57337
Comments
filter documentation |
Hey there @dgomes, mind taking a look at this issue as it has been labeled with an integration ( |
I think it works as intended. |
@Danielhiversen is absolutely right, hope he can finish that PR 😉 |
EDIT: Please disregard my answer below. I see that #53053 addresses this issue. However I think IMO this should not be a new feature but a bugfix. If it works as intended depends on the intention😉. As I understand the referenced paper the time-SMA is the average of values during a certain period weighting each observation value by the amount of time it remained unchanged. This amount changes over time for the first and last observation and observations fall out of this period over time as well. If the observed value does not change anymore the average will approach the last observation more and more. If the observed value has not changed for longer than the observation period, the average si identical to the last value. Therefor the time SMA filter must not only change when there is a new observation but continuously (or periodically) over time. |
The big difference is what triggers an update: a new event from the source, or a time event (clock). #53053 is the right direction (new filter) as the current implementation already reflects many users needs. |
I agree that it might be unfortunate for users already using this filter. I suggest that the documentation is updated to indicate the he existing filter is somewhat a mixture between the rolling average (based on observation events) end the time-SMA (based on state duration). The new filter would then be a proper implementation of the algorithm described in the referenced Eckner paper. |
The problem
If a sensor doesn't change its state for a longer time (e.g. power produced by a solar panel during the night) the moving average filter remains at the state it had the last time the sensor changed. Only when a new change happens from the sensor the filtered state jumps to the value of the sensor during the 'static period'.
What is version of Home Assistant Core has the issue?
core-2021.9.7
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
Filter Sensor
Link to integration documentation on our website
https://www.home-assistant.io/integrations/filter/#time-simple-moving-average
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
the filtered state should be updated after some time if there is no change of input state.
The text was updated successfully, but these errors were encountered: