diff --git a/homeassistant/components/hue/switch.py b/homeassistant/components/hue/switch.py index d8d0d0fd05c..7f8e048d692 100644 --- a/homeassistant/components/hue/switch.py +++ b/homeassistant/components/hue/switch.py @@ -10,8 +10,8 @@ from aiohue.v2.models.resource import SensingService from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ENTITY_CATEGORY_CONFIG from homeassistant.core import HomeAssistant, callback +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from .bridge import HueBridge @@ -62,7 +62,7 @@ async def async_setup_entry( class HueSensingServiceEnabledEntity(HueBaseEntity, SwitchEntity): """Representation of a Switch entity from Hue SensingService.""" - _attr_entity_category = ENTITY_CATEGORY_CONFIG + _attr_entity_category = EntityCategory.CONFIG _attr_device_class = SwitchDeviceClass.SWITCH def __init__( diff --git a/homeassistant/components/hue/v1/sensor.py b/homeassistant/components/hue/v1/sensor.py index fc490ab1e4b..3a79f5f37f1 100644 --- a/homeassistant/components/hue/v1/sensor.py +++ b/homeassistant/components/hue/v1/sensor.py @@ -7,16 +7,12 @@ from aiohue.v1.sensors import ( ) from homeassistant.components.sensor import ( - STATE_CLASS_MEASUREMENT, SensorDeviceClass, SensorEntity, + SensorStateClass, ) -from homeassistant.const import ( - ENTITY_CATEGORY_DIAGNOSTIC, - LIGHT_LUX, - PERCENTAGE, - TEMP_CELSIUS, -) +from homeassistant.const import LIGHT_LUX, PERCENTAGE, TEMP_CELSIUS +from homeassistant.helpers.entity import EntityCategory from ..const import DOMAIN as HUE_DOMAIN from .sensor_base import SENSOR_CONFIG_MAP, GenericHueSensor, GenericZLLSensor @@ -79,7 +75,7 @@ class HueTemperature(GenericHueGaugeSensorEntity): """The temperature sensor entity for a Hue motion sensor device.""" _attr_device_class = SensorDeviceClass.TEMPERATURE - _attr_state_class = STATE_CLASS_MEASUREMENT + _attr_state_class = SensorStateClass.MEASUREMENT _attr_native_unit_of_measurement = TEMP_CELSIUS @property @@ -95,9 +91,9 @@ class HueBattery(GenericHueSensor, SensorEntity): """Battery class for when a batt-powered device is only represented as an event.""" _attr_device_class = SensorDeviceClass.BATTERY - _attr_state_class = STATE_CLASS_MEASUREMENT + _attr_state_class = SensorStateClass.MEASUREMENT _attr_native_unit_of_measurement = PERCENTAGE - _attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC + _attr_entity_category = EntityCategory.DIAGNOSTIC @property def unique_id(self): diff --git a/homeassistant/components/hue/v1/sensor_base.py b/homeassistant/components/hue/v1/sensor_base.py index 142941a1859..84921707f2a 100644 --- a/homeassistant/components/hue/v1/sensor_base.py +++ b/homeassistant/components/hue/v1/sensor_base.py @@ -9,7 +9,7 @@ from aiohue import AiohueException, Unauthorized from aiohue.v1.sensors import TYPE_ZLL_PRESENCE import async_timeout -from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT +from homeassistant.components.sensor import SensorStateClass from homeassistant.core import callback from homeassistant.helpers import debounce, entity from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed @@ -181,7 +181,7 @@ class GenericHueSensor(GenericHueDevice, entity.Entity): @property def state_class(self): """Return the state class of this entity, from STATE_CLASSES, if any.""" - return STATE_CLASS_MEASUREMENT + return SensorStateClass.MEASUREMENT async def async_added_to_hass(self): """When entity is added to hass.""" diff --git a/homeassistant/components/hue/v2/sensor.py b/homeassistant/components/hue/v2/sensor.py index daff7c8d6de..ff2b7b78e7d 100644 --- a/homeassistant/components/hue/v2/sensor.py +++ b/homeassistant/components/hue/v2/sensor.py @@ -19,18 +19,14 @@ from aiohue.v2.models.temperature import Temperature from homeassistant.components.binary_sensor import BinarySensorDeviceClass from homeassistant.components.sensor import ( - STATE_CLASS_MEASUREMENT, SensorDeviceClass, SensorEntity, + SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - ENTITY_CATEGORY_DIAGNOSTIC, - LIGHT_LUX, - PERCENTAGE, - TEMP_CELSIUS, -) +from homeassistant.const import LIGHT_LUX, PERCENTAGE, TEMP_CELSIUS from homeassistant.core import HomeAssistant, callback +from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback from ..bridge import HueBridge @@ -84,7 +80,7 @@ async def async_setup_entry( class HueSensorBase(HueBaseEntity, SensorEntity): """Representation of a Hue sensor.""" - _attr_state_class = STATE_CLASS_MEASUREMENT + _attr_state_class = SensorStateClass.MEASUREMENT def __init__( self, @@ -144,7 +140,7 @@ class HueBatterySensor(HueSensorBase): _attr_native_unit_of_measurement = PERCENTAGE _attr_device_class = SensorDeviceClass.BATTERY - _attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC + _attr_entity_category = EntityCategory.DIAGNOSTIC @property def native_value(self) -> int: @@ -161,7 +157,7 @@ class HueZigbeeConnectivitySensor(HueSensorBase): """Representation of a Hue ZigbeeConnectivity sensor.""" _attr_device_class = BinarySensorDeviceClass.CONNECTIVITY - _attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC + _attr_entity_category = EntityCategory.DIAGNOSTIC _attr_entity_registry_enabled_default = False @property