Add state class to hunterdouglas_powerview (#64936)

This commit is contained in:
J. Nick Koston 2022-01-25 18:36:22 -10:00 committed by GitHub
parent 8593d07883
commit 5cc5813bd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,11 @@
"""Support for hunterdouglass_powerview sensors."""
from aiopvapi.resources.shade import factory as PvShade
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 PERCENTAGE
from homeassistant.core import HomeAssistant, callback
@ -55,22 +59,15 @@ class PowerViewShadeBatterySensor(ShadeEntity, SensorEntity):
"""Representation of an shade battery charge sensor."""
_attr_entity_category = EntityCategory.DIAGNOSTIC
@property
def native_unit_of_measurement(self):
"""Return the unit of measurement."""
return PERCENTAGE
_attr_native_unit_of_measurement = PERCENTAGE
_attr_device_class = SensorDeviceClass.BATTERY
_attr_state_class = SensorStateClass.MEASUREMENT
@property
def name(self):
"""Name of the shade battery."""
return f"{self._shade_name} Battery"
@property
def device_class(self):
"""Shade battery Class."""
return SensorDeviceClass.BATTERY
@property
def unique_id(self):
"""Shade battery Uniqueid."""