From 7c09cff3ad07e623e6ebb579fc3655130489abc9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 8 Dec 2021 22:15:15 +0100 Subject: [PATCH] Use new DeviceClass and EntityCategory enums in august (#61288) Co-authored-by: epenet --- .../components/august/binary_sensor.py | 17 +++++++---------- homeassistant/components/august/sensor.py | 16 ++++++---------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/august/binary_sensor.py b/homeassistant/components/august/binary_sensor.py index cf34952309b..d8c2117f4a3 100644 --- a/homeassistant/components/august/binary_sensor.py +++ b/homeassistant/components/august/binary_sensor.py @@ -19,15 +19,12 @@ from yalexs.util import update_lock_detail_from_activity from homeassistant.components.august import AugustData from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_CONNECTIVITY, - DEVICE_CLASS_DOOR, - DEVICE_CLASS_MOTION, - DEVICE_CLASS_OCCUPANCY, + BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription, ) -from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC from homeassistant.core import callback +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.event import async_call_later from .const import ACTIVITY_UPDATE_INTERVAL, DATA_AUGUST, DOMAIN @@ -115,22 +112,22 @@ SENSOR_TYPES_DOORBELL: tuple[AugustBinarySensorEntityDescription, ...] = ( AugustBinarySensorEntityDescription( key="doorbell_ding", name="Ding", - device_class=DEVICE_CLASS_OCCUPANCY, + device_class=BinarySensorDeviceClass.OCCUPANCY, value_fn=_retrieve_ding_state, is_time_based=True, ), AugustBinarySensorEntityDescription( key="doorbell_motion", name="Motion", - device_class=DEVICE_CLASS_MOTION, + device_class=BinarySensorDeviceClass.MOTION, value_fn=_retrieve_motion_state, is_time_based=True, ), AugustBinarySensorEntityDescription( key="doorbell_online", name="Online", - device_class=DEVICE_CLASS_CONNECTIVITY, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=BinarySensorDeviceClass.CONNECTIVITY, + entity_category=EntityCategory.DIAGNOSTIC, value_fn=_retrieve_online_state, is_time_based=False, ), @@ -169,7 +166,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): class AugustDoorBinarySensor(AugustEntityMixin, BinarySensorEntity): """Representation of an August Door binary sensor.""" - _attr_device_class = DEVICE_CLASS_DOOR + _attr_device_class = BinarySensorDeviceClass.DOOR def __init__(self, data, device, description: BinarySensorEntityDescription): """Initialize the sensor.""" diff --git a/homeassistant/components/august/sensor.py b/homeassistant/components/august/sensor.py index 744177cbef3..031e6fd9282 100644 --- a/homeassistant/components/august/sensor.py +++ b/homeassistant/components/august/sensor.py @@ -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__(