Use new enums in hue (#61772)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/61791/head
parent
bcc9251517
commit
36da11e924
homeassistant/components/hue
|
@ -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__(
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue