Add alias to DOMAIN import in deconz (#125568)

This commit is contained in:
epenet 2024-09-09 19:27:06 +02:00 committed by GitHub
parent c5453835c2
commit e0a221ba1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 50 additions and 46 deletions

View File

@ -10,7 +10,7 @@ from pydeconz.models.sensor.ancillary_control import (
) )
from homeassistant.components.alarm_control_panel import ( from homeassistant.components.alarm_control_panel import (
DOMAIN, DOMAIN as ALARM_CONTROl_PANEL_DOMAIN,
AlarmControlPanelEntity, AlarmControlPanelEntity,
AlarmControlPanelEntityFeature, AlarmControlPanelEntityFeature,
CodeFormat, CodeFormat,
@ -60,7 +60,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up the deCONZ alarm control panel devices.""" """Set up the deCONZ alarm control panel devices."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[ALARM_CONTROl_PANEL_DOMAIN] = set()
@callback @callback
def async_add_sensor(_: EventType, sensor_id: str) -> None: def async_add_sensor(_: EventType, sensor_id: str) -> None:
@ -79,7 +79,7 @@ class DeconzAlarmControlPanel(DeconzDevice[AncillaryControl], AlarmControlPanelE
"""Representation of a deCONZ alarm control panel.""" """Representation of a deCONZ alarm control panel."""
_update_key = "panel" _update_key = "panel"
TYPE = DOMAIN TYPE = ALARM_CONTROl_PANEL_DOMAIN
_attr_code_format = CodeFormat.NUMBER _attr_code_format = CodeFormat.NUMBER
_attr_supported_features = ( _attr_supported_features = (

View File

@ -18,7 +18,7 @@ from pydeconz.models.sensor.vibration import Vibration
from pydeconz.models.sensor.water import Water from pydeconz.models.sensor.water import Water
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DOMAIN, DOMAIN as BINARY_SENSOR_DOMAIN,
BinarySensorDeviceClass, BinarySensorDeviceClass,
BinarySensorEntity, BinarySensorEntity,
BinarySensorEntityDescription, BinarySensorEntityDescription,
@ -165,7 +165,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up the deCONZ binary sensor.""" """Set up the deCONZ binary sensor."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[BINARY_SENSOR_DOMAIN] = set()
@callback @callback
def async_add_sensor(_: EventType, sensor_id: str) -> None: def async_add_sensor(_: EventType, sensor_id: str) -> None:
@ -189,7 +189,7 @@ async def async_setup_entry(
class DeconzBinarySensor(DeconzDevice[SensorResources], BinarySensorEntity): class DeconzBinarySensor(DeconzDevice[SensorResources], BinarySensorEntity):
"""Representation of a deCONZ binary sensor.""" """Representation of a deCONZ binary sensor."""
TYPE = DOMAIN TYPE = BINARY_SENSOR_DOMAIN
entity_description: DeconzBinarySensorDescription entity_description: DeconzBinarySensorDescription
def __init__( def __init__(

View File

@ -9,7 +9,7 @@ from pydeconz.models.scene import Scene as PydeconzScene
from pydeconz.models.sensor.presence import Presence from pydeconz.models.sensor.presence import Presence
from homeassistant.components.button import ( from homeassistant.components.button import (
DOMAIN, DOMAIN as BUTTON_DOMAIN,
ButtonDeviceClass, ButtonDeviceClass,
ButtonEntity, ButtonEntity,
ButtonEntityDescription, ButtonEntityDescription,
@ -51,7 +51,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up the deCONZ button entity.""" """Set up the deCONZ button entity."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[BUTTON_DOMAIN] = set()
@callback @callback
def async_add_scene(_: EventType, scene_id: str) -> None: def async_add_scene(_: EventType, scene_id: str) -> None:
@ -83,7 +83,7 @@ async def async_setup_entry(
class DeconzSceneButton(DeconzSceneMixin, ButtonEntity): class DeconzSceneButton(DeconzSceneMixin, ButtonEntity):
"""Representation of a deCONZ button entity.""" """Representation of a deCONZ button entity."""
TYPE = DOMAIN TYPE = BUTTON_DOMAIN
def __init__( def __init__(
self, self,
@ -119,7 +119,7 @@ class DeconzPresenceResetButton(DeconzDevice[Presence], ButtonEntity):
_attr_entity_category = EntityCategory.CONFIG _attr_entity_category = EntityCategory.CONFIG
_attr_device_class = ButtonDeviceClass.RESTART _attr_device_class = ButtonDeviceClass.RESTART
TYPE = DOMAIN TYPE = BUTTON_DOMAIN
async def async_press(self) -> None: async def async_press(self) -> None:
"""Store reset presence state.""" """Store reset presence state."""

View File

@ -13,7 +13,7 @@ from pydeconz.models.sensor.thermostat import (
) )
from homeassistant.components.climate import ( from homeassistant.components.climate import (
DOMAIN, DOMAIN as CLIMATE_DOMAIN,
FAN_AUTO, FAN_AUTO,
FAN_HIGH, FAN_HIGH,
FAN_LOW, FAN_LOW,
@ -81,7 +81,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up the deCONZ climate devices.""" """Set up the deCONZ climate devices."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[CLIMATE_DOMAIN] = set()
@callback @callback
def async_add_climate(_: EventType, climate_id: str) -> None: def async_add_climate(_: EventType, climate_id: str) -> None:
@ -98,7 +98,7 @@ async def async_setup_entry(
class DeconzThermostat(DeconzDevice[Thermostat], ClimateEntity): class DeconzThermostat(DeconzDevice[Thermostat], ClimateEntity):
"""Representation of a deCONZ thermostat.""" """Representation of a deCONZ thermostat."""
TYPE = DOMAIN TYPE = CLIMATE_DOMAIN
_attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
_enable_turn_on_off_backwards_compatibility = False _enable_turn_on_off_backwards_compatibility = False

View File

@ -12,7 +12,7 @@ from pydeconz.models.light.cover import Cover
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
ATTR_TILT_POSITION, ATTR_TILT_POSITION,
DOMAIN, DOMAIN as COVER_DOMAIN,
CoverDeviceClass, CoverDeviceClass,
CoverEntity, CoverEntity,
CoverEntityFeature, CoverEntityFeature,
@ -38,7 +38,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up covers for deCONZ component.""" """Set up covers for deCONZ component."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[COVER_DOMAIN] = set()
@callback @callback
def async_add_cover(_: EventType, cover_id: str) -> None: def async_add_cover(_: EventType, cover_id: str) -> None:
@ -54,7 +54,7 @@ async def async_setup_entry(
class DeconzCover(DeconzDevice[Cover], CoverEntity): class DeconzCover(DeconzDevice[Cover], CoverEntity):
"""Representation of a deCONZ cover.""" """Representation of a deCONZ cover."""
TYPE = DOMAIN TYPE = COVER_DOMAIN
def __init__(self, cover_id: str, hub: DeconzHub) -> None: def __init__(self, cover_id: str, hub: DeconzHub) -> None:
"""Set up cover device.""" """Set up cover device."""

View File

@ -7,7 +7,11 @@ from typing import Any
from pydeconz.models.event import EventType from pydeconz.models.event import EventType
from pydeconz.models.light.light import Light, LightFanSpeed from pydeconz.models.light.light import Light, LightFanSpeed
from homeassistant.components.fan import DOMAIN, FanEntity, FanEntityFeature from homeassistant.components.fan import (
DOMAIN as FAN_DOMAIN,
FanEntity,
FanEntityFeature,
)
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -34,7 +38,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up fans for deCONZ component.""" """Set up fans for deCONZ component."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[FAN_DOMAIN] = set()
@callback @callback
def async_add_fan(_: EventType, fan_id: str) -> None: def async_add_fan(_: EventType, fan_id: str) -> None:
@ -53,7 +57,7 @@ async def async_setup_entry(
class DeconzFan(DeconzDevice[Light], FanEntity): class DeconzFan(DeconzDevice[Light], FanEntity):
"""Representation of a deCONZ fan.""" """Representation of a deCONZ fan."""
TYPE = DOMAIN TYPE = FAN_DOMAIN
_default_on_speed = LightFanSpeed.PERCENT_50 _default_on_speed = LightFanSpeed.PERCENT_50
_attr_supported_features = ( _attr_supported_features = (

View File

@ -18,7 +18,7 @@ from homeassistant.components.light import (
ATTR_HS_COLOR, ATTR_HS_COLOR,
ATTR_TRANSITION, ATTR_TRANSITION,
ATTR_XY_COLOR, ATTR_XY_COLOR,
DOMAIN, DOMAIN as LIGHT_DOMAIN,
EFFECT_COLORLOOP, EFFECT_COLORLOOP,
FLASH_LONG, FLASH_LONG,
FLASH_SHORT, FLASH_SHORT,
@ -125,7 +125,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up the deCONZ lights and groups from a config entry.""" """Set up the deCONZ lights and groups from a config entry."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[LIGHT_DOMAIN] = set()
@callback @callback
def async_add_light(_: EventType, light_id: str) -> None: def async_add_light(_: EventType, light_id: str) -> None:
@ -170,7 +170,7 @@ class DeconzBaseLight[_LightDeviceT: Group | Light](
): ):
"""Representation of a deCONZ light.""" """Representation of a deCONZ light."""
TYPE = DOMAIN TYPE = LIGHT_DOMAIN
_attr_color_mode = ColorMode.UNKNOWN _attr_color_mode = ColorMode.UNKNOWN
def __init__(self, device: _LightDeviceT, hub: DeconzHub) -> None: def __init__(self, device: _LightDeviceT, hub: DeconzHub) -> None:

View File

@ -8,7 +8,7 @@ from pydeconz.models.event import EventType
from pydeconz.models.light.lock import Lock from pydeconz.models.light.lock import Lock
from pydeconz.models.sensor.door_lock import DoorLock from pydeconz.models.sensor.door_lock import DoorLock
from homeassistant.components.lock import DOMAIN, LockEntity from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN, LockEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -24,7 +24,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up locks for deCONZ component.""" """Set up locks for deCONZ component."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[LOCK_DOMAIN] = set()
@callback @callback
def async_add_lock_from_light(_: EventType, lock_id: str) -> None: def async_add_lock_from_light(_: EventType, lock_id: str) -> None:
@ -53,7 +53,7 @@ async def async_setup_entry(
class DeconzLock(DeconzDevice[DoorLock | Lock], LockEntity): class DeconzLock(DeconzDevice[DoorLock | Lock], LockEntity):
"""Representation of a deCONZ lock.""" """Representation of a deCONZ lock."""
TYPE = DOMAIN TYPE = LOCK_DOMAIN
@property @property
def is_locked(self) -> bool: def is_locked(self) -> bool:

View File

@ -13,7 +13,7 @@ from pydeconz.models.sensor import SensorBase as PydeconzSensorBase
from pydeconz.models.sensor.presence import Presence from pydeconz.models.sensor.presence import Presence
from homeassistant.components.number import ( from homeassistant.components.number import (
DOMAIN, DOMAIN as NUMBER_DOMAIN,
NumberEntity, NumberEntity,
NumberEntityDescription, NumberEntityDescription,
) )
@ -74,7 +74,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up the deCONZ number entity.""" """Set up the deCONZ number entity."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[NUMBER_DOMAIN] = set()
@callback @callback
def async_add_sensor(_: EventType, sensor_id: str) -> None: def async_add_sensor(_: EventType, sensor_id: str) -> None:
@ -99,7 +99,7 @@ async def async_setup_entry(
class DeconzNumber(DeconzDevice[SensorResources], NumberEntity): class DeconzNumber(DeconzDevice[SensorResources], NumberEntity):
"""Representation of a deCONZ number entity.""" """Representation of a deCONZ number entity."""
TYPE = DOMAIN TYPE = NUMBER_DOMAIN
entity_description: DeconzNumberDescription entity_description: DeconzNumberDescription
def __init__( def __init__(

View File

@ -6,7 +6,7 @@ from typing import Any
from pydeconz.models.event import EventType from pydeconz.models.event import EventType
from homeassistant.components.scene import DOMAIN, Scene from homeassistant.components.scene import DOMAIN as SCENE_DOMAIN, Scene
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -22,7 +22,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up scenes for deCONZ integration.""" """Set up scenes for deCONZ integration."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[SCENE_DOMAIN] = set()
@callback @callback
def async_add_scene(_: EventType, scene_id: str) -> None: def async_add_scene(_: EventType, scene_id: str) -> None:
@ -39,7 +39,7 @@ async def async_setup_entry(
class DeconzScene(DeconzSceneMixin, Scene): class DeconzScene(DeconzSceneMixin, Scene):
"""Representation of a deCONZ scene.""" """Representation of a deCONZ scene."""
TYPE = DOMAIN TYPE = SCENE_DOMAIN
async def async_activate(self, **kwargs: Any) -> None: async def async_activate(self, **kwargs: Any) -> None:
"""Activate the scene.""" """Activate the scene."""

View File

@ -11,7 +11,7 @@ from pydeconz.models.sensor.presence import (
PresenceConfigTriggerDistance, PresenceConfigTriggerDistance,
) )
from homeassistant.components.select import DOMAIN, SelectEntity from homeassistant.components.select import DOMAIN as SELECT_DOMAIN, SelectEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EntityCategory from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -35,7 +35,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up the deCONZ button entity.""" """Set up the deCONZ button entity."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[SELECT_DOMAIN] = set()
@callback @callback
def async_add_air_purifier_sensor(_: EventType, sensor_id: str) -> None: def async_add_air_purifier_sensor(_: EventType, sensor_id: str) -> None:
@ -85,7 +85,7 @@ class DeconzAirPurifierFanMode(DeconzDevice[AirPurifier], SelectEntity):
AirPurifierFanMode.SPEED_5.value, AirPurifierFanMode.SPEED_5.value,
] ]
TYPE = DOMAIN TYPE = SELECT_DOMAIN
@property @property
def current_option(self) -> str: def current_option(self) -> str:
@ -113,7 +113,7 @@ class DeconzPresenceDeviceModeSelect(DeconzDevice[Presence], SelectEntity):
PresenceConfigDeviceMode.UNDIRECTED.value, PresenceConfigDeviceMode.UNDIRECTED.value,
] ]
TYPE = DOMAIN TYPE = SELECT_DOMAIN
@property @property
def current_option(self) -> str | None: def current_option(self) -> str | None:
@ -140,7 +140,7 @@ class DeconzPresenceSensitivitySelect(DeconzDevice[Presence], SelectEntity):
_attr_entity_category = EntityCategory.CONFIG _attr_entity_category = EntityCategory.CONFIG
_attr_options = list(SENSITIVITY_TO_DECONZ) _attr_options = list(SENSITIVITY_TO_DECONZ)
TYPE = DOMAIN TYPE = SELECT_DOMAIN
@property @property
def current_option(self) -> str | None: def current_option(self) -> str | None:
@ -171,7 +171,7 @@ class DeconzPresenceTriggerDistanceSelect(DeconzDevice[Presence], SelectEntity):
PresenceConfigTriggerDistance.NEAR.value, PresenceConfigTriggerDistance.NEAR.value,
] ]
TYPE = DOMAIN TYPE = SELECT_DOMAIN
@property @property
def current_option(self) -> str | None: def current_option(self) -> str | None:

View File

@ -28,7 +28,7 @@ from pydeconz.models.sensor.temperature import Temperature
from pydeconz.models.sensor.time import Time from pydeconz.models.sensor.time import Time
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
DOMAIN, DOMAIN as SENSOR_DOMAIN,
SensorDeviceClass, SensorDeviceClass,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
@ -336,7 +336,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up the deCONZ sensors.""" """Set up the deCONZ sensors."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[SENSOR_DOMAIN] = set()
known_device_entities: dict[str, set[str]] = { known_device_entities: dict[str, set[str]] = {
description.key: set() description.key: set()
@ -393,7 +393,7 @@ async def async_setup_entry(
class DeconzSensor(DeconzDevice[SensorResources], SensorEntity): class DeconzSensor(DeconzDevice[SensorResources], SensorEntity):
"""Representation of a deCONZ sensor.""" """Representation of a deCONZ sensor."""
TYPE = DOMAIN TYPE = SENSOR_DOMAIN
entity_description: DeconzSensorDescription entity_description: DeconzSensorDescription
def __init__( def __init__(

View File

@ -9,7 +9,7 @@ from pydeconz.models.light.siren import Siren
from homeassistant.components.siren import ( from homeassistant.components.siren import (
ATTR_DURATION, ATTR_DURATION,
DOMAIN, DOMAIN as SIREN_DOMAIN,
SirenEntity, SirenEntity,
SirenEntityFeature, SirenEntityFeature,
) )
@ -28,7 +28,7 @@ async def async_setup_entry(
) -> None: ) -> None:
"""Set up sirens for deCONZ component.""" """Set up sirens for deCONZ component."""
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[SIREN_DOMAIN] = set()
@callback @callback
def async_add_siren(_: EventType, siren_id: str) -> None: def async_add_siren(_: EventType, siren_id: str) -> None:
@ -45,7 +45,7 @@ async def async_setup_entry(
class DeconzSiren(DeconzDevice[Siren], SirenEntity): class DeconzSiren(DeconzDevice[Siren], SirenEntity):
"""Representation of a deCONZ siren.""" """Representation of a deCONZ siren."""
TYPE = DOMAIN TYPE = SIREN_DOMAIN
_attr_supported_features = ( _attr_supported_features = (
SirenEntityFeature.TURN_ON SirenEntityFeature.TURN_ON
| SirenEntityFeature.TURN_OFF | SirenEntityFeature.TURN_OFF

View File

@ -7,7 +7,7 @@ from typing import Any
from pydeconz.models.event import EventType from pydeconz.models.event import EventType
from pydeconz.models.light.light import Light from pydeconz.models.light.light import Light
from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN, SwitchEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -27,7 +27,7 @@ async def async_setup_entry(
Switches are based on the same device class as lights in deCONZ. Switches are based on the same device class as lights in deCONZ.
""" """
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[SWITCH_DOMAIN] = set()
@callback @callback
def async_add_switch(_: EventType, switch_id: str) -> None: def async_add_switch(_: EventType, switch_id: str) -> None:
@ -46,7 +46,7 @@ async def async_setup_entry(
class DeconzPowerPlug(DeconzDevice[Light], SwitchEntity): class DeconzPowerPlug(DeconzDevice[Light], SwitchEntity):
"""Representation of a deCONZ power plug.""" """Representation of a deCONZ power plug."""
TYPE = DOMAIN TYPE = SWITCH_DOMAIN
@property @property
def is_on(self) -> bool: def is_on(self) -> bool: