From a691abaa501e5b63c03561a11e327582cdd98c4c Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sun, 12 Dec 2021 15:27:20 +0100 Subject: [PATCH] Use new enums in gogogate2 (#61515) Co-authored-by: epenet --- homeassistant/components/gogogate2/cover.py | 5 ++-- homeassistant/components/gogogate2/sensor.py | 25 ++++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/gogogate2/cover.py b/homeassistant/components/gogogate2/cover.py index 16191304bb9..155c767eaea 100644 --- a/homeassistant/components/gogogate2/cover.py +++ b/homeassistant/components/gogogate2/cover.py @@ -9,10 +9,9 @@ from ismartgate.common import ( ) from homeassistant.components.cover import ( - DEVICE_CLASS_GARAGE, - DEVICE_CLASS_GATE, SUPPORT_CLOSE, SUPPORT_OPEN, + CoverDeviceClass, CoverEntity, ) from homeassistant.config_entries import ConfigEntry @@ -57,7 +56,7 @@ class DeviceCover(GoGoGate2Entity, CoverEntity): super().__init__(config_entry, data_update_coordinator, door, unique_id) self._attr_supported_features = SUPPORT_OPEN | SUPPORT_CLOSE self._attr_device_class = ( - DEVICE_CLASS_GATE if self.door.gate else DEVICE_CLASS_GARAGE + CoverDeviceClass.GATE if self.door.gate else CoverDeviceClass.GARAGE ) @property diff --git a/homeassistant/components/gogogate2/sensor.py b/homeassistant/components/gogogate2/sensor.py index 743c8e7efc7..29c8f360963 100644 --- a/homeassistant/components/gogogate2/sensor.py +++ b/homeassistant/components/gogogate2/sensor.py @@ -5,16 +5,15 @@ from itertools import chain from ismartgate.common import AbstractDoor, get_configured_doors -from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity -from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_TEMPERATURE, - ENTITY_CATEGORY_DIAGNOSTIC, - PERCENTAGE, - TEMP_CELSIUS, +from homeassistant.components.sensor import ( + SensorDeviceClass, + SensorEntity, + SensorStateClass, ) +from homeassistant.config_entries import ConfigEntry +from homeassistant.const import PERCENTAGE, TEMP_CELSIUS from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from .common import ( @@ -66,7 +65,7 @@ class DoorSensorEntity(GoGoGate2Entity, SensorEntity): class DoorSensorBattery(DoorSensorEntity): """Battery sensor entity for gogogate2 door sensor.""" - _attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC + _attr_entity_category = EntityCategory.DIAGNOSTIC def __init__( self, @@ -77,8 +76,8 @@ class DoorSensorBattery(DoorSensorEntity): """Initialize the object.""" unique_id = sensor_unique_id(config_entry, door, "battery") super().__init__(config_entry, data_update_coordinator, door, unique_id) - self._attr_device_class = DEVICE_CLASS_BATTERY - self._attr_state_class = STATE_CLASS_MEASUREMENT + self._attr_device_class = SensorDeviceClass.BATTERY + self._attr_state_class = SensorStateClass.MEASUREMENT self._attr_native_unit_of_measurement = PERCENTAGE @property @@ -104,8 +103,8 @@ class DoorSensorTemperature(DoorSensorEntity): """Initialize the object.""" unique_id = sensor_unique_id(config_entry, door, "temperature") super().__init__(config_entry, data_update_coordinator, door, unique_id) - self._attr_device_class = DEVICE_CLASS_TEMPERATURE - self._attr_state_class = STATE_CLASS_MEASUREMENT + self._attr_device_class = SensorDeviceClass.TEMPERATURE + self._attr_state_class = SensorStateClass.MEASUREMENT self._attr_native_unit_of_measurement = TEMP_CELSIUS @property