Use new enums in deconz (#61343)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
2e99fbc1f3
commit
fa38a2d0bf
4 changed files with 34 additions and 47 deletions
|
@ -17,21 +17,16 @@ from pydeconz.sensor import (
|
|||
)
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_GAS,
|
||||
DEVICE_CLASS_MOISTURE,
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OPENING,
|
||||
DEVICE_CLASS_SMOKE,
|
||||
DEVICE_CLASS_TAMPER,
|
||||
DEVICE_CLASS_VIBRATION,
|
||||
DOMAIN,
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
BinarySensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC
|
||||
from homeassistant.const import ATTR_TEMPERATURE
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import ATTR_DARK, ATTR_ON
|
||||
|
@ -56,27 +51,27 @@ ATTR_VIBRATIONSTRENGTH = "vibrationstrength"
|
|||
ENTITY_DESCRIPTIONS = {
|
||||
CarbonMonoxide: BinarySensorEntityDescription(
|
||||
key="carbonmonoxide",
|
||||
device_class=DEVICE_CLASS_GAS,
|
||||
device_class=BinarySensorDeviceClass.GAS,
|
||||
),
|
||||
Fire: BinarySensorEntityDescription(
|
||||
key="fire",
|
||||
device_class=DEVICE_CLASS_SMOKE,
|
||||
device_class=BinarySensorDeviceClass.SMOKE,
|
||||
),
|
||||
OpenClose: BinarySensorEntityDescription(
|
||||
key="openclose",
|
||||
device_class=DEVICE_CLASS_OPENING,
|
||||
device_class=BinarySensorDeviceClass.OPENING,
|
||||
),
|
||||
Presence: BinarySensorEntityDescription(
|
||||
key="presence",
|
||||
device_class=DEVICE_CLASS_MOTION,
|
||||
device_class=BinarySensorDeviceClass.MOTION,
|
||||
),
|
||||
Vibration: BinarySensorEntityDescription(
|
||||
key="vibration",
|
||||
device_class=DEVICE_CLASS_VIBRATION,
|
||||
device_class=BinarySensorDeviceClass.VIBRATION,
|
||||
),
|
||||
Water: BinarySensorEntityDescription(
|
||||
key="water",
|
||||
device_class=DEVICE_CLASS_MOISTURE,
|
||||
device_class=BinarySensorDeviceClass.MOISTURE,
|
||||
),
|
||||
}
|
||||
|
||||
|
@ -186,8 +181,8 @@ class DeconzTampering(DeconzDevice, BinarySensorEntity):
|
|||
TYPE = DOMAIN
|
||||
_device: PydeconzSensor
|
||||
|
||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||
_attr_device_class = DEVICE_CLASS_TAMPER
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
_attr_device_class = BinarySensorDeviceClass.TAMPER
|
||||
|
||||
def __init__(self, device: PydeconzSensor, gateway: DeconzGateway) -> None:
|
||||
"""Initialize deCONZ binary sensor."""
|
||||
|
|
|
@ -10,8 +10,6 @@ from pydeconz.light import Cover
|
|||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
ATTR_TILT_POSITION,
|
||||
DEVICE_CLASS_DAMPER,
|
||||
DEVICE_CLASS_SHADE,
|
||||
DOMAIN,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_CLOSE_TILT,
|
||||
|
@ -21,6 +19,7 @@ from homeassistant.components.cover import (
|
|||
SUPPORT_SET_TILT_POSITION,
|
||||
SUPPORT_STOP,
|
||||
SUPPORT_STOP_TILT,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -32,9 +31,9 @@ from .deconz_device import DeconzDevice
|
|||
from .gateway import DeconzGateway, get_gateway_from_config_entry
|
||||
|
||||
DEVICE_CLASS = {
|
||||
"Level controllable output": DEVICE_CLASS_DAMPER,
|
||||
"Window covering controller": DEVICE_CLASS_SHADE,
|
||||
"Window covering device": DEVICE_CLASS_SHADE,
|
||||
"Level controllable output": CoverDeviceClass.DAMPER,
|
||||
"Window covering controller": CoverDeviceClass.SHADE,
|
||||
"Window covering device": CoverDeviceClass.SHADE,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ from homeassistant.components.number import (
|
|||
NumberEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENTITY_CATEGORY_CONFIG
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .deconz_device import DeconzDevice
|
||||
|
@ -37,7 +37,7 @@ class DeconzNumberEntityDescription(
|
|||
):
|
||||
"""Class describing deCONZ number entities."""
|
||||
|
||||
entity_category = ENTITY_CATEGORY_CONFIG
|
||||
entity_category = EntityCategory.CONFIG
|
||||
|
||||
|
||||
ENTITY_DESCRIPTIONS = {
|
||||
|
|
|
@ -22,24 +22,16 @@ from pydeconz.sensor import (
|
|||
|
||||
from homeassistant.components.sensor import (
|
||||
DOMAIN,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
STATE_CLASS_TOTAL_INCREASING,
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
ATTR_VOLTAGE,
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
|
@ -51,6 +43,7 @@ from homeassistant.helpers.dispatcher import (
|
|||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
)
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
|
@ -79,15 +72,15 @@ ATTR_EVENT_ID = "event_id"
|
|||
ENTITY_DESCRIPTIONS = {
|
||||
Battery: SensorEntityDescription(
|
||||
key="battery",
|
||||
device_class=DEVICE_CLASS_BATTERY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.BATTERY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
),
|
||||
Consumption: SensorEntityDescription(
|
||||
key="consumption",
|
||||
device_class=DEVICE_CLASS_ENERGY,
|
||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
),
|
||||
Daylight: SensorEntityDescription(
|
||||
|
@ -97,31 +90,31 @@ ENTITY_DESCRIPTIONS = {
|
|||
),
|
||||
Humidity: SensorEntityDescription(
|
||||
key="humidity",
|
||||
device_class=DEVICE_CLASS_HUMIDITY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.HUMIDITY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
),
|
||||
LightLevel: SensorEntityDescription(
|
||||
key="lightlevel",
|
||||
device_class=DEVICE_CLASS_ILLUMINANCE,
|
||||
device_class=SensorDeviceClass.ILLUMINANCE,
|
||||
native_unit_of_measurement=LIGHT_LUX,
|
||||
),
|
||||
Power: SensorEntityDescription(
|
||||
key="power",
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
),
|
||||
Pressure: SensorEntityDescription(
|
||||
key="pressure",
|
||||
device_class=DEVICE_CLASS_PRESSURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=PRESSURE_HPA,
|
||||
),
|
||||
Temperature: SensorEntityDescription(
|
||||
key="temperature",
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
),
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue