Use new enums in guardian (#61660)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-13 15:06:19 +01:00 committed by GitHub
parent 2462d4cdf6
commit 3118bfdfab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 23 deletions

View File

@ -2,16 +2,14 @@
from __future__ import annotations from __future__ import annotations
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASS_CONNECTIVITY, BinarySensorDeviceClass,
DEVICE_CLASS_MOISTURE,
DEVICE_CLASS_MOVING,
BinarySensorEntity, BinarySensorEntity,
BinarySensorEntityDescription, BinarySensorEntityDescription,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -35,19 +33,19 @@ SENSOR_KIND_MOVED = "moved"
SENSOR_DESCRIPTION_AP_ENABLED = BinarySensorEntityDescription( SENSOR_DESCRIPTION_AP_ENABLED = BinarySensorEntityDescription(
key=SENSOR_KIND_AP_INFO, key=SENSOR_KIND_AP_INFO,
name="Onboard AP Enabled", name="Onboard AP Enabled",
device_class=DEVICE_CLASS_CONNECTIVITY, device_class=BinarySensorDeviceClass.CONNECTIVITY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
) )
SENSOR_DESCRIPTION_LEAK_DETECTED = BinarySensorEntityDescription( SENSOR_DESCRIPTION_LEAK_DETECTED = BinarySensorEntityDescription(
key=SENSOR_KIND_LEAK_DETECTED, key=SENSOR_KIND_LEAK_DETECTED,
name="Leak Detected", name="Leak Detected",
device_class=DEVICE_CLASS_MOISTURE, device_class=BinarySensorDeviceClass.MOISTURE,
) )
SENSOR_DESCRIPTION_MOVED = BinarySensorEntityDescription( SENSOR_DESCRIPTION_MOVED = BinarySensorEntityDescription(
key=SENSOR_KIND_MOVED, key=SENSOR_KIND_MOVED,
name="Recently Moved", name="Recently Moved",
device_class=DEVICE_CLASS_MOVING, device_class=BinarySensorDeviceClass.MOVING,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
) )
PAIRED_SENSOR_DESCRIPTIONS = ( PAIRED_SENSOR_DESCRIPTIONS = (

View File

@ -2,21 +2,16 @@
from __future__ import annotations from __future__ import annotations
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT, SensorDeviceClass,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import PERCENTAGE, TEMP_FAHRENHEIT, TIME_MINUTES
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_TEMPERATURE,
ENTITY_CATEGORY_DIAGNOSTIC,
PERCENTAGE,
TEMP_FAHRENHEIT,
TIME_MINUTES,
)
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import PairedSensorEntity, ValveControllerEntity from . import PairedSensorEntity, ValveControllerEntity
@ -37,22 +32,22 @@ SENSOR_KIND_UPTIME = "uptime"
SENSOR_DESCRIPTION_BATTERY = SensorEntityDescription( SENSOR_DESCRIPTION_BATTERY = SensorEntityDescription(
key=SENSOR_KIND_BATTERY, key=SENSOR_KIND_BATTERY,
name="Battery", name="Battery",
device_class=DEVICE_CLASS_BATTERY, device_class=SensorDeviceClass.BATTERY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
) )
SENSOR_DESCRIPTION_TEMPERATURE = SensorEntityDescription( SENSOR_DESCRIPTION_TEMPERATURE = SensorEntityDescription(
key=SENSOR_KIND_TEMPERATURE, key=SENSOR_KIND_TEMPERATURE,
name="Temperature", name="Temperature",
device_class=DEVICE_CLASS_TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=TEMP_FAHRENHEIT, native_unit_of_measurement=TEMP_FAHRENHEIT,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
) )
SENSOR_DESCRIPTION_UPTIME = SensorEntityDescription( SENSOR_DESCRIPTION_UPTIME = SensorEntityDescription(
key=SENSOR_KIND_UPTIME, key=SENSOR_KIND_UPTIME,
name="Uptime", name="Uptime",
icon="mdi:timer", icon="mdi:timer",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=TIME_MINUTES, native_unit_of_measurement=TIME_MINUTES,
) )