mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add state class to emonitor sensors (#64934)
This commit is contained in:
parent
50cc5e10b9
commit
09982afd2e
@ -1,7 +1,11 @@
|
||||
"""Support for a Emonitor channel sensor."""
|
||||
from aioemonitor.monitor import EmonitorChannel
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import POWER_WATT
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -45,16 +49,13 @@ class EmonitorPowerSensor(CoordinatorEntity, SensorEntity):
|
||||
|
||||
_attr_device_class = SensorDeviceClass.POWER
|
||||
_attr_native_unit_of_measurement = POWER_WATT
|
||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||
|
||||
def __init__(self, coordinator: DataUpdateCoordinator, channel_number: int) -> None:
|
||||
"""Initialize the channel sensor."""
|
||||
self.channel_number = channel_number
|
||||
super().__init__(coordinator)
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Channel unique id."""
|
||||
return f"{self.mac_address}_{self.channel_number}"
|
||||
self._attr_unique_id = f"{self.mac_address}_{channel_number}"
|
||||
|
||||
@property
|
||||
def channel_data(self) -> EmonitorChannel:
|
||||
|
Loading…
x
Reference in New Issue
Block a user