The compensation integration currently lacks support for assigning a device_class, or state_class.
Request: Please enhance the compensation integration by allowing the following optional configuration fields:
device_class
state_class
This would improve usability, reduce configuration complexity, and help sensors better integrate into the Home Assistant UI and ecosystem.
Thanks for considering!
Blacky
I think I put an issue in for something like this once…
Yea this is a no brainier and HA should do it, it is throughout HA and maybe they just missed this one.
BUUUTTTT someone has to do it.
Blacky
Valid request, but what you can do in the meantime is to add it via your customize.yaml
.
petro
(Petro)
June 3, 2025, 1:11pm
6
No promises this goes through.
dev
← Petro31:update-compensation
opened 01:10PM - 03 Jun 25 UTC
## Breaking change
## Proposed change
Update the compensation integration t… o account for device_class and state_class. In turn this also accounts for source entity states like unknown and unavailable.
## Type of change
- [ ] Dependency upgrade
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New integration (thank you!)
- [ ] 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 # https://github.com/home-assistant/core/issues/145928 https://github.com/home-assistant/core/issues/132734
- This PR is related to issue:
- Link to documentation pull request:
- Link to developer documentation pull request:
- Link to frontend pull request:
## Checklist
- [x] The code change is tested and works locally.
- [x] Local tests pass. **Your PR cannot be merged unless tests pass**
- [x] There is no commented out code in this PR.
- [x] I have followed the [development checklist][dev-checklist]
- [x] I have followed the [perfect PR recommendations][perfect-pr]
- [x] The code has been formatted using Ruff (`ruff format homeassistant tests`)
- [x] 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][docs-repository]
If the code communicates with devices, web services, or third-party tools:
- [ ] The [manifest file][manifest-docs] 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 running `python3 -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][prs] in this repository.
[prs]: https://github.com/home-assistant/core/pulls?q=is%3Aopen+is%3Apr+-author%3A%40me+-draft%3Atrue+-label%3Awaiting-for-upstream+sort%3Acreated-desc+review%3Anone+-status%3Afailure
[dev-checklist]: https://developers.home-assistant.io/docs/development_checklist/
[manifest-docs]: https://developers.home-assistant.io/docs/creating_integration_manifest/
[quality-scale]: https://developers.home-assistant.io/docs/integration_quality_scale_index/
[docs-repository]: https://github.com/home-assistant/home-assistant.io
[perfect-pr]: https://developers.home-assistant.io/docs/review-process/#creating-the-perfect-pr
2 Likes
Tried the customize.yaml
workaround and it did the trick!
Here are a few details for those interested, seems it can be applied to almost any Home Assistant entity. It makes use of the core homeassistant
integration . (Manual customization examples .)
An example configuration.yaml
:
homeassistant:
customize:
sensor.compensation_sensor_front_door_open_sensor_battery:
device_class: battery
Or, to keep your config more modular, create a customize.yaml
file:
sensor.compensation_sensor_front_door_open_sensor_battery:
device_class: battery
and include it in your configuration.yaml
:
homeassistant:
customize: !include customize.yaml
Important! Note that the compensation integration generates its own entity ID, so you’ll need to create the compensation, restart HA, get the compensation entity ID, then customize the device class followed by a final HA restart.
1 Like
Wow, thanks for the fast turnaround! Hope it gets merged!
1 Like
Blacky
June 4, 2025, 12:20am
9
@petro
Awesome to see this added, thanks Petro for making it happen!
Blacky