mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Use new enums in hue (#61772)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
bcc9251517
commit
36da11e924
@ -10,8 +10,8 @@ from aiohue.v2.models.resource import SensingService
|
|||||||
|
|
||||||
from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity
|
from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ENTITY_CATEGORY_CONFIG
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .bridge import HueBridge
|
from .bridge import HueBridge
|
||||||
@ -62,7 +62,7 @@ async def async_setup_entry(
|
|||||||
class HueSensingServiceEnabledEntity(HueBaseEntity, SwitchEntity):
|
class HueSensingServiceEnabledEntity(HueBaseEntity, SwitchEntity):
|
||||||
"""Representation of a Switch entity from Hue SensingService."""
|
"""Representation of a Switch entity from Hue SensingService."""
|
||||||
|
|
||||||
_attr_entity_category = ENTITY_CATEGORY_CONFIG
|
_attr_entity_category = EntityCategory.CONFIG
|
||||||
_attr_device_class = SwitchDeviceClass.SWITCH
|
_attr_device_class = SwitchDeviceClass.SWITCH
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -7,16 +7,12 @@ from aiohue.v1.sensors import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
STATE_CLASS_MEASUREMENT,
|
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import LIGHT_LUX, PERCENTAGE, TEMP_CELSIUS
|
||||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
LIGHT_LUX,
|
|
||||||
PERCENTAGE,
|
|
||||||
TEMP_CELSIUS,
|
|
||||||
)
|
|
||||||
|
|
||||||
from ..const import DOMAIN as HUE_DOMAIN
|
from ..const import DOMAIN as HUE_DOMAIN
|
||||||
from .sensor_base import SENSOR_CONFIG_MAP, GenericHueSensor, GenericZLLSensor
|
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."""
|
"""The temperature sensor entity for a Hue motion sensor device."""
|
||||||
|
|
||||||
_attr_device_class = SensorDeviceClass.TEMPERATURE
|
_attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
_attr_native_unit_of_measurement = TEMP_CELSIUS
|
_attr_native_unit_of_measurement = TEMP_CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -95,9 +91,9 @@ class HueBattery(GenericHueSensor, SensorEntity):
|
|||||||
"""Battery class for when a batt-powered device is only represented as an event."""
|
"""Battery class for when a batt-powered device is only represented as an event."""
|
||||||
|
|
||||||
_attr_device_class = SensorDeviceClass.BATTERY
|
_attr_device_class = SensorDeviceClass.BATTERY
|
||||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
_attr_native_unit_of_measurement = PERCENTAGE
|
_attr_native_unit_of_measurement = PERCENTAGE
|
||||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
|
@ -9,7 +9,7 @@ from aiohue import AiohueException, Unauthorized
|
|||||||
from aiohue.v1.sensors import TYPE_ZLL_PRESENCE
|
from aiohue.v1.sensors import TYPE_ZLL_PRESENCE
|
||||||
import async_timeout
|
import async_timeout
|
||||||
|
|
||||||
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT
|
from homeassistant.components.sensor import SensorStateClass
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import debounce, entity
|
from homeassistant.helpers import debounce, entity
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
@ -181,7 +181,7 @@ class GenericHueSensor(GenericHueDevice, entity.Entity):
|
|||||||
@property
|
@property
|
||||||
def state_class(self):
|
def state_class(self):
|
||||||
"""Return the state class of this entity, from STATE_CLASSES, if any."""
|
"""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):
|
async def async_added_to_hass(self):
|
||||||
"""When entity is added to hass."""
|
"""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.binary_sensor import BinarySensorDeviceClass
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
STATE_CLASS_MEASUREMENT,
|
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import LIGHT_LUX, PERCENTAGE, TEMP_CELSIUS
|
||||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
|
||||||
LIGHT_LUX,
|
|
||||||
PERCENTAGE,
|
|
||||||
TEMP_CELSIUS,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity import EntityCategory
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from ..bridge import HueBridge
|
from ..bridge import HueBridge
|
||||||
@ -84,7 +80,7 @@ async def async_setup_entry(
|
|||||||
class HueSensorBase(HueBaseEntity, SensorEntity):
|
class HueSensorBase(HueBaseEntity, SensorEntity):
|
||||||
"""Representation of a Hue sensor."""
|
"""Representation of a Hue sensor."""
|
||||||
|
|
||||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -144,7 +140,7 @@ class HueBatterySensor(HueSensorBase):
|
|||||||
|
|
||||||
_attr_native_unit_of_measurement = PERCENTAGE
|
_attr_native_unit_of_measurement = PERCENTAGE
|
||||||
_attr_device_class = SensorDeviceClass.BATTERY
|
_attr_device_class = SensorDeviceClass.BATTERY
|
||||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> int:
|
def native_value(self) -> int:
|
||||||
@ -161,7 +157,7 @@ class HueZigbeeConnectivitySensor(HueSensorBase):
|
|||||||
"""Representation of a Hue ZigbeeConnectivity sensor."""
|
"""Representation of a Hue ZigbeeConnectivity sensor."""
|
||||||
|
|
||||||
_attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
|
_attr_device_class = BinarySensorDeviceClass.CONNECTIVITY
|
||||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||||
_attr_entity_registry_enabled_default = False
|
_attr_entity_registry_enabled_default = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user