-
-
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
Add Update by time filter #131745
base: dev
Are you sure you want to change the base?
Add Update by time filter #131745
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dbrand666
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
Hey there @dgomes, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
b59c587
to
f754417
Compare
Based on deleted branch by Daniel Hjelseth Høyer <[email protected]>
Based on deleted branch by Daniel Hjelseth Høyer <[email protected]>
c71bbc8
to
b5fa0b0
Compare
Note: Since we can't set SCAN_INTERVAL per filter, I'm just letting it default.
b5fa0b0
to
925a4f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if update by time should be considered a filter
I'm not sure what you mean. Are you thinking that I should create a new filter for this rather than adding the flag to TimeSMAFilter? What would I call it? TimeSMAFilterV2? TimedTimeSMAFilter? Just TimedSMAFilter? My own preference would be to treat this as a bugfix and get rid of the update_by_time flag - I really can't see anyone actually expecting the current behavior. |
Filter is something that processes the output of a source sensor, this is more like a sampler (therefore the need to update by time which is not commanded by the source) That's also the reason I created https://github.com/dgomes/ha_sampler to keep it separate. But lets listen to other folks |
Proposed change
As currently implemented, the Time Simple Moving Average filter only gets updated when it receives a new value. This is counter to most people's expectations. See, for example, #57337 "the Time Simple Moving Average shows wrong state when the input sensor doesn't change state".
This is an old issue and Daniel Hjelseth Høyer had created and then abandoned #53053 as an enhancement to let the user ask HA to update the state periodically. That was about 3 years ago.
I rebased that deleted branch, fixed it a bit, and added a test. I think it's time we get this merged.
I followed his lead and left the old behavior intact and added a new flag
update_by_time
to the existing SMA filter that tells it to update as the time changes - not just on new data.Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: