Add circular mean statistics and sensor state class MEASUREMENT_ANGLE
Breaking change
Proposed change
Add support for circular mean statistics in the recorder for angles in °.
A new field mean_type is added to the StatisticMetadata, which specifies whether the mean is arithmetic or circular.
The boolean field has_mean is deprecated and should not be used anymore. It will be removed in 2026.4 to avoid a breaking change for custom components.
To use the new circular_mean, the new sensor state class MEASUREMENT_ANGLE was added. It should be used similar to the MEASUREMENT for angles like the wind direction. Currently, only degrees (°) are supported.
Type of change
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [x] New feature (which adds functionality to an existing integration)
- [ ] Deprecation (breaking change to happen in the future)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
Additional information
- This PR fixes or closes issue: fixes #
- This PR is related to issue:
- Link to documentation pull request:
- Link to developer documentation pull request:
- Link to frontend pull request: https://github.com/home-assistant/frontend/pull/24758
Checklist
- [ ] The code change is tested and works locally.
- [ ] Local tests pass. Your PR cannot be merged unless tests pass
- [ ] There is no commented out code in this PR.
- [ ] I have followed the development checklist
- [ ] I have followed the perfect PR recommendations
- [ ] The code has been formatted using Ruff (
ruff format homeassistant tests) - [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for www.home-assistant.io
If the code communicates with devices, web services, or third-party tools:
- [ ] The manifest file has all fields filled out correctly.
Updated and included derived files by running:python3 -m script.hassfest. - [ ] New or updated dependencies have been added to
requirements_all.txt.
Updated by runningpython3 -m script.gen_requirements_all. - [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
To help with the load of incoming pull requests:
- [ ] I have reviewed two other open pull requests in this repository.
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (recorder) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of recorder can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign recorderRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (sensor) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of sensor can trigger bot actions by commenting:
@home-assistant closeCloses the pull request.@home-assistant rename Awesome new titleRenames the pull request.@home-assistant reopenReopen the pull request.@home-assistant unassign sensorRemoves the current integration label and assignees on the pull request, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.
@edenhaus, hello! Do I understand correctly that the changes you are proposing have not yet been implemented? And do I understand correctly that after the implementation, all wind direction entities contained in the core (in particular, in the EcoWitt integration) will automatically receive the correct state class (which one, by the way?) and it will be possible to use Long Term Statistics for these entities?
@edenhaus, hello! Do I understand correctly that the changes you are proposing have not yet been implemented? And do I understand correctly that after the implementation, all wind direction entities contained in the core (in particular, in the EcoWitt integration) will automatically receive the correct state class (which one, by the way?) and it will be possible to use Long Term Statistics for these entities?
This PR will add long-term statistical support for circular states like the wind direction. As this PR has not yet been merged, this feature is not yet available. This PR adds a new state class. After this PR got merged, all wind direction entities need to set the new state class to make LTS available (For some, I will set it in a follow-up PR)
@edenhaus, I see, thank you for your work and for your reply. So we'll be waiting...
Discussed with @bramkragten that the core PR can be merged upfront the frontend one