From 3118bfdfab685be4c57d69401c8c8a647a5b54c7 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 13 Dec 2021 15:06:19 +0100 Subject: [PATCH] Use new enums in guardian (#61660) Co-authored-by: epenet --- .../components/guardian/binary_sensor.py | 16 ++++++------- homeassistant/components/guardian/sensor.py | 23 ++++++++----------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/homeassistant/components/guardian/binary_sensor.py b/homeassistant/components/guardian/binary_sensor.py index 6ac07274501..1d7195a8f17 100644 --- a/homeassistant/components/guardian/binary_sensor.py +++ b/homeassistant/components/guardian/binary_sensor.py @@ -2,16 +2,14 @@ from __future__ import annotations from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_CONNECTIVITY, - DEVICE_CLASS_MOISTURE, - DEVICE_CLASS_MOVING, + BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import DataUpdateCoordinator @@ -35,19 +33,19 @@ SENSOR_KIND_MOVED = "moved" SENSOR_DESCRIPTION_AP_ENABLED = BinarySensorEntityDescription( key=SENSOR_KIND_AP_INFO, name="Onboard AP Enabled", - device_class=DEVICE_CLASS_CONNECTIVITY, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=BinarySensorDeviceClass.CONNECTIVITY, + entity_category=EntityCategory.DIAGNOSTIC, ) SENSOR_DESCRIPTION_LEAK_DETECTED = BinarySensorEntityDescription( key=SENSOR_KIND_LEAK_DETECTED, name="Leak Detected", - device_class=DEVICE_CLASS_MOISTURE, + device_class=BinarySensorDeviceClass.MOISTURE, ) SENSOR_DESCRIPTION_MOVED = BinarySensorEntityDescription( key=SENSOR_KIND_MOVED, name="Recently Moved", - device_class=DEVICE_CLASS_MOVING, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=BinarySensorDeviceClass.MOVING, + entity_category=EntityCategory.DIAGNOSTIC, ) PAIRED_SENSOR_DESCRIPTIONS = ( diff --git a/homeassistant/components/guardian/sensor.py b/homeassistant/components/guardian/sensor.py index 9a88805baaf..895452e0fda 100644 --- a/homeassistant/components/guardian/sensor.py +++ b/homeassistant/components/guardian/sensor.py @@ -2,21 +2,16 @@ from __future__ import annotations from homeassistant.components.sensor import ( - STATE_CLASS_MEASUREMENT, + SensorDeviceClass, SensorEntity, SensorEntityDescription, + SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_TEMPERATURE, - ENTITY_CATEGORY_DIAGNOSTIC, - PERCENTAGE, - TEMP_FAHRENHEIT, - TIME_MINUTES, -) +from homeassistant.const import PERCENTAGE, TEMP_FAHRENHEIT, TIME_MINUTES from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from . import PairedSensorEntity, ValveControllerEntity @@ -37,22 +32,22 @@ SENSOR_KIND_UPTIME = "uptime" SENSOR_DESCRIPTION_BATTERY = SensorEntityDescription( key=SENSOR_KIND_BATTERY, name="Battery", - device_class=DEVICE_CLASS_BATTERY, - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=SensorDeviceClass.BATTERY, + entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=PERCENTAGE, ) SENSOR_DESCRIPTION_TEMPERATURE = SensorEntityDescription( key=SENSOR_KIND_TEMPERATURE, name="Temperature", - device_class=DEVICE_CLASS_TEMPERATURE, + device_class=SensorDeviceClass.TEMPERATURE, native_unit_of_measurement=TEMP_FAHRENHEIT, - state_class=STATE_CLASS_MEASUREMENT, + state_class=SensorStateClass.MEASUREMENT, ) SENSOR_DESCRIPTION_UPTIME = SensorEntityDescription( key=SENSOR_KIND_UPTIME, name="Uptime", icon="mdi:timer", - entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=TIME_MINUTES, )