Open bradsjm opened 3 years ago
I started trying this out and I got as far as setting my power sensors to have the proper state_class but I don't seem to be able to set it up with the energy settings in home assistant. Maybe someone knows what I'm missing or doing wrong?
In .storage/core.entity_registry
:
{
"entity_id": "sensor.game_room_lights_power",
"config_entry_id": "abcdef0123456789abcdef0123456789",
"device_id": "def0123456789abcdef0123456789abc",
"area_id": null,
"unique_id": "abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789::167::sensor::power",
"platform": "hubitat",
"name": null,
"icon": null,
"disabled_by": null,
"capabilities": {
"state_class": "measurement"
},
"supported_features": 0,
"device_class": "power",
"unit_of_measurement": "W",
"original_name": "Game Room Lights Power",
"original_icon": null
},
If someone has an entity that works with the energy settings I'd love to see the equivalent json
I would also like to get this working. I've tried to add the state_class too, but can't get it to work properly.
Someone in the forums mentioned a solution using entity customization.
I added this to the configuration file.
homeassistant:
customize_glob:
sensor.*_power:
state_class: measurement
sensor.*_energy:
state_class: total_increasing
last_reset: '1970-01-01T00:00:00+00:00'
The energy sensors appears now, but the power sensors are still not available for tracking long term statistics.
Home Assistant has support for long term statistics and a new power dashboard but requires entities to support it, see https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics
A requirement to opt-in for statistics is that the sensor has state_class set to measurement. That means that the current value represents the current value.
My understanding from the documentation I think would be as simple as updating the sensor.py file when defining energy devices by adding the state_class property set to "measurement" to the appropriate classes (HubitatPowerSensor, HubitatVoltageSensor etc.) https://developers.home-assistant.io/docs/core/entity/sensor/. It may be worth also adding it to other measurement sensor classes that can then have long term statistics tracked.