Skip to content

Commit

Permalink
Merge pull request #20 from flowent59/main
Browse files Browse the repository at this point in the history
feat(sensor.py): add state_class to EnergyUsageSensor for Energy dashboard integration
  • Loading branch information
juanillo62gm authored Jan 29, 2025
2 parents a4ca433 + bb761a1 commit 761b020
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions custom_components/panda_pwr/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from homeassistant.components.sensor import SensorEntity
from homeassistant.components.sensor.const import SensorDeviceClass
from homeassistant.components.sensor import SensorStateClass
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
UnitOfElectricCurrent,
Expand Down Expand Up @@ -57,6 +58,7 @@ def __init__(
"native_unit_of_measurement"
)
self._attr_device_class = sensor_info.get("device_class")
self._attr_state_class = sensor_info.get("state_class")
self._device_id = device_id

async def async_update(self) -> None:
Expand Down Expand Up @@ -193,6 +195,7 @@ def __init__(self, api: Any, entry: ConfigEntry, device_id: str) -> None:
"unique_id_suffix": "energy_usage",
"native_unit_of_measurement": UnitOfEnergy.KILO_WATT_HOUR,
"device_class": SensorDeviceClass.ENERGY,
"state_class": SensorStateClass.TOTAL_INCREASING,
}
super().__init__(api, entry, device_id, sensor_info)

Expand Down

0 comments on commit 761b020

Please sign in to comment.