Use new DeviceClass and EntityCategory enums in august (#61288)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet
2021-12-08 22:15:15 +01:00
committed by GitHub
parent b2ae018837
commit 7c09cff3ad
2 changed files with 13 additions and 20 deletions

View File

@@ -12,17 +12,13 @@ from yalexs.lock import LockDetail
from homeassistant.components.august import AugustData
from homeassistant.components.sensor import (
DEVICE_CLASS_BATTERY,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.const import (
ATTR_ENTITY_PICTURE,
ENTITY_CATEGORY_DIAGNOSTIC,
PERCENTAGE,
STATE_UNAVAILABLE,
)
from homeassistant.const import ATTR_ENTITY_PICTURE, PERCENTAGE, STATE_UNAVAILABLE
from homeassistant.core import callback
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_registry import async_get_registry
from homeassistant.helpers.restore_state import RestoreEntity
@@ -73,14 +69,14 @@ class AugustSensorEntityDescription(
SENSOR_TYPE_DEVICE_BATTERY = AugustSensorEntityDescription[LockDetail](
key="device_battery",
name="Battery",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=_retrieve_device_battery_state,
)
SENSOR_TYPE_KEYPAD_BATTERY = AugustSensorEntityDescription[KeypadDetail](
key="linked_keypad_battery",
name="Battery",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=_retrieve_linked_keypad_battery_state,
)
@@ -254,7 +250,7 @@ class AugustBatterySensor(AugustEntityMixin, SensorEntity, Generic[T]):
"""Representation of an August sensor."""
entity_description: AugustSensorEntityDescription[T]
_attr_device_class = DEVICE_CLASS_BATTERY
_attr_device_class = SensorDeviceClass.BATTERY
_attr_native_unit_of_measurement = PERCENTAGE
def __init__(