mirror of
https://github.com/home-assistant/core.git
synced 2025-08-09 23:55:07 +02:00
Simplify
This commit is contained in:
@@ -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 as ALARM_CONTROL_PANEL_DOMAIN,
|
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[ALARM_CONTROL_PANEL_DOMAIN] = set()
|
hub.entities[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 = ALARM_CONTROL_PANEL_DOMAIN
|
TYPE = DOMAIN
|
||||||
|
|
||||||
_attr_code_format = CodeFormat.NUMBER
|
_attr_code_format = CodeFormat.NUMBER
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
|
@@ -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 as BINARY_SENSOR_DOMAIN,
|
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[BINARY_SENSOR_DOMAIN] = set()
|
hub.entities[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 = BINARY_SENSOR_DOMAIN
|
TYPE = DOMAIN
|
||||||
entity_description: DeconzBinarySensorDescription
|
entity_description: DeconzBinarySensorDescription
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@@ -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 as COVER_DOMAIN,
|
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[COVER_DOMAIN] = set()
|
hub.entities[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 = COVER_DOMAIN
|
TYPE = 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."""
|
||||||
|
@@ -11,7 +11,7 @@ from homeassistant.components.cover import (
|
|||||||
ATTR_CURRENT_TILT_POSITION,
|
ATTR_CURRENT_TILT_POSITION,
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
ATTR_TILT_POSITION,
|
ATTR_TILT_POSITION,
|
||||||
DOMAIN as COVER_DOMAIN,
|
DOMAIN,
|
||||||
PLATFORM_SCHEMA as COVER_PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA as COVER_PLATFORM_SCHEMA,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
CoverEntityFeature,
|
CoverEntityFeature,
|
||||||
@@ -57,7 +57,7 @@ PARALLEL_UPDATES = 0
|
|||||||
|
|
||||||
PLATFORM_SCHEMA = COVER_PLATFORM_SCHEMA.extend(
|
PLATFORM_SCHEMA = COVER_PLATFORM_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_ENTITIES): cv.entities_domain(COVER_DOMAIN),
|
vol.Required(CONF_ENTITIES): cv.entities_domain(DOMAIN),
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Optional(CONF_UNIQUE_ID): cv.string,
|
vol.Optional(CONF_UNIQUE_ID): cv.string,
|
||||||
}
|
}
|
||||||
@@ -181,25 +181,21 @@ class CoverGroup(GroupEntity, CoverEntity):
|
|||||||
"""Move the covers up."""
|
"""Move the covers up."""
|
||||||
data = {ATTR_ENTITY_ID: self._covers[KEY_OPEN_CLOSE]}
|
data = {ATTR_ENTITY_ID: self._covers[KEY_OPEN_CLOSE]}
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
COVER_DOMAIN, SERVICE_OPEN_COVER, data, blocking=True, context=self._context
|
DOMAIN, SERVICE_OPEN_COVER, data, blocking=True, context=self._context
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_close_cover(self, **kwargs: Any) -> None:
|
async def async_close_cover(self, **kwargs: Any) -> None:
|
||||||
"""Move the covers down."""
|
"""Move the covers down."""
|
||||||
data = {ATTR_ENTITY_ID: self._covers[KEY_OPEN_CLOSE]}
|
data = {ATTR_ENTITY_ID: self._covers[KEY_OPEN_CLOSE]}
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
COVER_DOMAIN,
|
DOMAIN, SERVICE_CLOSE_COVER, data, blocking=True, context=self._context
|
||||||
SERVICE_CLOSE_COVER,
|
|
||||||
data,
|
|
||||||
blocking=True,
|
|
||||||
context=self._context,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_stop_cover(self, **kwargs: Any) -> None:
|
async def async_stop_cover(self, **kwargs: Any) -> None:
|
||||||
"""Fire the stop action."""
|
"""Fire the stop action."""
|
||||||
data = {ATTR_ENTITY_ID: self._covers[KEY_STOP]}
|
data = {ATTR_ENTITY_ID: self._covers[KEY_STOP]}
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
COVER_DOMAIN, SERVICE_STOP_COVER, data, blocking=True, context=self._context
|
DOMAIN, SERVICE_STOP_COVER, data, blocking=True, context=self._context
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||||
@@ -209,7 +205,7 @@ class CoverGroup(GroupEntity, CoverEntity):
|
|||||||
ATTR_POSITION: kwargs[ATTR_POSITION],
|
ATTR_POSITION: kwargs[ATTR_POSITION],
|
||||||
}
|
}
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
COVER_DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_SET_COVER_POSITION,
|
SERVICE_SET_COVER_POSITION,
|
||||||
data,
|
data,
|
||||||
blocking=True,
|
blocking=True,
|
||||||
@@ -220,33 +216,21 @@ class CoverGroup(GroupEntity, CoverEntity):
|
|||||||
"""Tilt covers open."""
|
"""Tilt covers open."""
|
||||||
data = {ATTR_ENTITY_ID: self._tilts[KEY_OPEN_CLOSE]}
|
data = {ATTR_ENTITY_ID: self._tilts[KEY_OPEN_CLOSE]}
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
COVER_DOMAIN,
|
DOMAIN, SERVICE_OPEN_COVER_TILT, data, blocking=True, context=self._context
|
||||||
SERVICE_OPEN_COVER_TILT,
|
|
||||||
data,
|
|
||||||
blocking=True,
|
|
||||||
context=self._context,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_close_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Tilt covers closed."""
|
"""Tilt covers closed."""
|
||||||
data = {ATTR_ENTITY_ID: self._tilts[KEY_OPEN_CLOSE]}
|
data = {ATTR_ENTITY_ID: self._tilts[KEY_OPEN_CLOSE]}
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
COVER_DOMAIN,
|
DOMAIN, SERVICE_CLOSE_COVER_TILT, data, blocking=True, context=self._context
|
||||||
SERVICE_CLOSE_COVER_TILT,
|
|
||||||
data,
|
|
||||||
blocking=True,
|
|
||||||
context=self._context,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Stop cover tilt."""
|
"""Stop cover tilt."""
|
||||||
data = {ATTR_ENTITY_ID: self._tilts[KEY_STOP]}
|
data = {ATTR_ENTITY_ID: self._tilts[KEY_STOP]}
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
COVER_DOMAIN,
|
DOMAIN, SERVICE_STOP_COVER_TILT, data, blocking=True, context=self._context
|
||||||
SERVICE_STOP_COVER_TILT,
|
|
||||||
data,
|
|
||||||
blocking=True,
|
|
||||||
context=self._context,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
|
async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
|
||||||
@@ -256,7 +240,7 @@ class CoverGroup(GroupEntity, CoverEntity):
|
|||||||
ATTR_TILT_POSITION: kwargs[ATTR_TILT_POSITION],
|
ATTR_TILT_POSITION: kwargs[ATTR_TILT_POSITION],
|
||||||
}
|
}
|
||||||
await self.hass.services.async_call(
|
await self.hass.services.async_call(
|
||||||
COVER_DOMAIN,
|
DOMAIN,
|
||||||
SERVICE_SET_COVER_TILT_POSITION,
|
SERVICE_SET_COVER_TILT_POSITION,
|
||||||
data,
|
data,
|
||||||
blocking=True,
|
blocking=True,
|
||||||
|
Reference in New Issue
Block a user