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
Switch statistics config to require either/both 'max_age' and 'sampling_size' #80999
Switch statistics config to require either/both 'max_age' and 'sampling_size' #80999
Conversation
Hey there @fabaff, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
@emontnemery ready for review. Thanks! |
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.
Thanks, @ThomDietrich 👍
Breaking change
The configuration of
statistics
sensors has changed:state_characteristic
configuration setting is now mandatory.sampling_size
configuration setting is now optional and no longer defaults to the arbitrary value 20. Depending on your use case, you can now definesampling_size
,max_age
, or both. Existing sensors won't behave differently by the change. However, you might want to check whether your currently defined sensors have a meaningfulsampling_size
configured, or whether you want to remove this setting completely.Proposed change
This change needs to go into Home Assistant version 2022.12.0.
So far, the statistics component had an implicit configuration of
sampling_size: 20
. This did (1) confuse users which didn't set any other often more meaningful and higher value for their use case, and did (2) require a user to decide on and configure a reasonable buffer size limit, which is rather tedious for use cases focused on time-bounds rather than sample-size-bounds. Users would work around this issue by e.g.sampling_size: 9999
, which is not an acceptable situation.This PR removes the default sampling_size. Users can now configure max_age OR sampling_size OR both options in the settings of a statistics sensor. If both limits are given, they will be applied equally.
This PR removes the deprecation warnings for
sampling_size
andstate_characteristic
. They served their purpose.All test cases were adapted to the new configuration needs. No new test cases are necessary, as existing ones already check the correct workings of both sampling bounds.
Type of change
Additional information
binary_sensor
entities #50837Checklist
black --fast 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
..coveragerc
.To help with the load of incoming pull requests: