Add device_class, and state_class support to compensation integration (e.g., for battery percentage)

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 :grinning:

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 :grinning:

Valid request, but what you can do in the meantime is to add it via your customize.yaml.

Thanks for the tip :+1:

1 Like

No promises this goes through.

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

@petro

Awesome to see this added, thanks Petro for making it happen!

Blacky :grinning: