diff --git a/homeassistant/components/deconz/siren.py b/homeassistant/components/deconz/siren.py index 17ce8528f18..18121d989a8 100644 --- a/homeassistant/components/deconz/siren.py +++ b/homeassistant/components/deconz/siren.py @@ -1,5 +1,4 @@ """Support for deCONZ siren.""" - from __future__ import annotations from typing import Any @@ -9,10 +8,8 @@ from pydeconz.light import Siren from homeassistant.components.siren import ( ATTR_DURATION, DOMAIN, - SUPPORT_DURATION, - SUPPORT_TURN_OFF, - SUPPORT_TURN_ON, SirenEntity, + SirenEntityFeature, ) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback @@ -20,7 +17,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback from .deconz_device import DeconzDevice -from .gateway import DeconzGateway, get_gateway_from_config_entry +from .gateway import get_gateway_from_config_entry async def async_setup_entry( @@ -66,16 +63,13 @@ class DeconzSiren(DeconzDevice, SirenEntity): """Representation of a deCONZ siren.""" TYPE = DOMAIN + _attr_supported_features = ( + SirenEntityFeature.TURN_ON + | SirenEntityFeature.TURN_OFF + | SirenEntityFeature.DURATION + ) _device: Siren - def __init__(self, device: Siren, gateway: DeconzGateway) -> None: - """Set up siren.""" - super().__init__(device, gateway) - - self._attr_supported_features = ( - SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_DURATION - ) - @property def is_on(self) -> bool: """Return true if siren is on.""" diff --git a/homeassistant/components/devolo_home_control/siren.py b/homeassistant/components/devolo_home_control/siren.py index ab86dc78032..20318f87a6d 100644 --- a/homeassistant/components/devolo_home_control/siren.py +++ b/homeassistant/components/devolo_home_control/siren.py @@ -4,13 +4,7 @@ from typing import Any from devolo_home_control_api.devices.zwave import Zwave from devolo_home_control_api.homecontrol import HomeControl -from homeassistant.components.siren import ( - ATTR_TONE, - SUPPORT_TONES, - SUPPORT_TURN_OFF, - SUPPORT_TURN_ON, - SirenEntity, -) +from homeassistant.components.siren import ATTR_TONE, SirenEntity, SirenEntityFeature from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -43,6 +37,12 @@ async def async_setup_entry( class DevoloSirenDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, SirenEntity): """Representation of a cover device within devolo Home Control.""" + _attr_supported_features = ( + SirenEntityFeature.TURN_OFF + | SirenEntityFeature.TURN_ON + | SirenEntityFeature.TONES + ) + def __init__( self, homecontrol: HomeControl, device_instance: Zwave, element_uid: str ) -> None: @@ -58,9 +58,6 @@ class DevoloSirenDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, SirenEntity): self._multi_level_switch_property.max + 1, ) ] - self._attr_supported_features = ( - SUPPORT_TURN_OFF | SUPPORT_TURN_ON | SUPPORT_TONES - ) self._default_tone = device_instance.settings_property["tone"].tone @property diff --git a/homeassistant/components/overkiz/siren.py b/homeassistant/components/overkiz/siren.py index 8f9d2d6167f..02736f6f50a 100644 --- a/homeassistant/components/overkiz/siren.py +++ b/homeassistant/components/overkiz/siren.py @@ -4,13 +4,8 @@ from typing import Any from pyoverkiz.enums import OverkizState from pyoverkiz.enums.command import OverkizCommand, OverkizCommandParam -from homeassistant.components.siren import SirenEntity -from homeassistant.components.siren.const import ( - ATTR_DURATION, - SUPPORT_DURATION, - SUPPORT_TURN_OFF, - SUPPORT_TURN_ON, -) +from homeassistant.components.siren import SirenEntity, SirenEntityFeature +from homeassistant.components.siren.const import ATTR_DURATION from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant @@ -38,7 +33,11 @@ async def async_setup_entry( class OverkizSiren(OverkizEntity, SirenEntity): """Representation an Overkiz Siren.""" - _attr_supported_features = SUPPORT_TURN_OFF | SUPPORT_TURN_ON | SUPPORT_DURATION + _attr_supported_features = ( + SirenEntityFeature.TURN_OFF + | SirenEntityFeature.TURN_ON + | SirenEntityFeature.DURATION + ) @property def is_on(self) -> bool: diff --git a/homeassistant/components/rfxtrx/siren.py b/homeassistant/components/rfxtrx/siren.py index 9a4a475998d..282933f7f85 100644 --- a/homeassistant/components/rfxtrx/siren.py +++ b/homeassistant/components/rfxtrx/siren.py @@ -5,12 +5,7 @@ from typing import Any import RFXtrx as rfxtrxmod -from homeassistant.components.siren import ( - SUPPORT_TONES, - SUPPORT_TURN_OFF, - SUPPORT_TURN_ON, - SirenEntity, -) +from homeassistant.components.siren import SirenEntity, SirenEntityFeature from homeassistant.components.siren.const import ATTR_TONE from homeassistant.config_entries import ConfigEntry from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback @@ -26,8 +21,6 @@ from . import ( ) from .const import CONF_OFF_DELAY -SUPPORT_RFXTRX = SUPPORT_TURN_ON | SUPPORT_TONES - SECURITY_PANIC_ON = "Panic" SECURITY_PANIC_OFF = "End Panic" SECURITY_PANIC_ALL = {SECURITY_PANIC_ON, SECURITY_PANIC_OFF} @@ -129,13 +122,13 @@ class RfxtrxOffDelayMixin(Entity): class RfxtrxChime(RfxtrxCommandEntity, SirenEntity, RfxtrxOffDelayMixin): """Representation of a RFXtrx chime.""" + _attr_supported_features = SirenEntityFeature.TURN_ON | SirenEntityFeature.TONES _device: rfxtrxmod.ChimeDevice def __init__(self, device, device_id, off_delay=None, event=None): """Initialize the entity.""" super().__init__(device, device_id, event) self._attr_available_tones = list(self._device.COMMANDS.values()) - self._attr_supported_features = SUPPORT_TURN_ON | SUPPORT_TONES self._default_tone = next(iter(self._device.COMMANDS)) self._off_delay = off_delay @@ -180,12 +173,12 @@ class RfxtrxChime(RfxtrxCommandEntity, SirenEntity, RfxtrxOffDelayMixin): class RfxtrxSecurityPanic(RfxtrxCommandEntity, SirenEntity, RfxtrxOffDelayMixin): """Representation of a security device.""" + _attr_supported_features = SirenEntityFeature.TURN_ON | SirenEntityFeature.TURN_OFF _device: rfxtrxmod.SecurityDevice def __init__(self, device, device_id, off_delay=None, event=None): """Initialize the entity.""" super().__init__(device, device_id, event) - self._attr_supported_features = SUPPORT_TURN_ON | SUPPORT_TURN_OFF self._on_value = get_first_key(self._device.STATUS, SECURITY_PANIC_ON) self._off_value = get_first_key(self._device.STATUS, SECURITY_PANIC_OFF) self._off_delay = off_delay diff --git a/homeassistant/components/switch_as_x/siren.py b/homeassistant/components/switch_as_x/siren.py index 752f7fd76ad..591546cd20a 100644 --- a/homeassistant/components/switch_as_x/siren.py +++ b/homeassistant/components/switch_as_x/siren.py @@ -1,8 +1,7 @@ """Siren support for switch entities.""" from __future__ import annotations -from homeassistant.components.siren import SirenEntity -from homeassistant.components.siren.const import SUPPORT_TURN_OFF, SUPPORT_TURN_ON +from homeassistant.components.siren import SirenEntity, SirenEntityFeature from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_ENTITY_ID from homeassistant.core import HomeAssistant @@ -40,4 +39,4 @@ async def async_setup_entry( class SirenSwitch(BaseToggleEntity, SirenEntity): """Represents a Switch as a Siren.""" - _attr_supported_features = SUPPORT_TURN_ON | SUPPORT_TURN_OFF + _attr_supported_features = SirenEntityFeature.TURN_ON | SirenEntityFeature.TURN_OFF diff --git a/homeassistant/components/tuya/siren.py b/homeassistant/components/tuya/siren.py index ae38149da2b..dcb26871bb2 100644 --- a/homeassistant/components/tuya/siren.py +++ b/homeassistant/components/tuya/siren.py @@ -5,8 +5,11 @@ from typing import Any from tuya_iot import TuyaDevice, TuyaDeviceManager -from homeassistant.components.siren import SirenEntity, SirenEntityDescription -from homeassistant.components.siren.const import SUPPORT_TURN_OFF, SUPPORT_TURN_ON +from homeassistant.components.siren import ( + SirenEntity, + SirenEntityDescription, + SirenEntityFeature, +) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -71,6 +74,8 @@ async def async_setup_entry( class TuyaSirenEntity(TuyaEntity, SirenEntity): """Tuya Siren Entity.""" + _attr_supported_features = SirenEntityFeature.TURN_ON | SirenEntityFeature.TURN_OFF + def __init__( self, device: TuyaDevice, @@ -81,7 +86,6 @@ class TuyaSirenEntity(TuyaEntity, SirenEntity): super().__init__(device, device_manager) self.entity_description = description self._attr_unique_id = f"{super().unique_id}{description.key}" - self._attr_supported_features = SUPPORT_TURN_ON | SUPPORT_TURN_OFF @property def is_on(self) -> bool: diff --git a/homeassistant/components/zha/siren.py b/homeassistant/components/zha/siren.py index 5ba83dbef12..587efc49c9c 100644 --- a/homeassistant/components/zha/siren.py +++ b/homeassistant/components/zha/siren.py @@ -1,5 +1,4 @@ """Support for ZHA sirens.""" - from __future__ import annotations import functools @@ -9,17 +8,10 @@ from zigpy.zcl.clusters.security import IasWd as WD from homeassistant.components.siren import ( ATTR_DURATION, - SUPPORT_DURATION, - SUPPORT_TURN_OFF, - SUPPORT_TURN_ON, SirenEntity, + SirenEntityFeature, ) -from homeassistant.components.siren.const import ( - ATTR_TONE, - ATTR_VOLUME_LEVEL, - SUPPORT_TONES, - SUPPORT_VOLUME_SET, -) +from homeassistant.components.siren.const import ATTR_TONE, ATTR_VOLUME_LEVEL from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant, callback @@ -87,11 +79,11 @@ class ZHASiren(ZhaEntity, SirenEntity): ) -> None: """Init this siren.""" self._attr_supported_features = ( - SUPPORT_TURN_ON - | SUPPORT_TURN_OFF - | SUPPORT_DURATION - | SUPPORT_VOLUME_SET - | SUPPORT_TONES + SirenEntityFeature.TURN_ON + | SirenEntityFeature.TURN_OFF + | SirenEntityFeature.DURATION + | SirenEntityFeature.VOLUME_SET + | SirenEntityFeature.TONES ) self._attr_available_tones: list[int | str] | dict[int, str] | None = { WARNING_DEVICE_MODE_BURGLAR: "Burglar", diff --git a/homeassistant/components/zwave_js/siren.py b/homeassistant/components/zwave_js/siren.py index a3fe3dfd595..e7443f33dae 100644 --- a/homeassistant/components/zwave_js/siren.py +++ b/homeassistant/components/zwave_js/siren.py @@ -6,15 +6,12 @@ from typing import Any from zwave_js_server.client import Client as ZwaveClient from zwave_js_server.const.command_class.sound_switch import ToneID -from homeassistant.components.siren import DOMAIN as SIREN_DOMAIN, SirenEntity -from homeassistant.components.siren.const import ( - ATTR_TONE, - ATTR_VOLUME_LEVEL, - SUPPORT_TONES, - SUPPORT_TURN_OFF, - SUPPORT_TURN_ON, - SUPPORT_VOLUME_SET, +from homeassistant.components.siren import ( + DOMAIN as SIREN_DOMAIN, + SirenEntity, + SirenEntityFeature, ) +from homeassistant.components.siren.const import ATTR_TONE, ATTR_VOLUME_LEVEL from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.dispatcher import async_dispatcher_connect @@ -62,10 +59,12 @@ class ZwaveSirenEntity(ZWaveBaseEntity, SirenEntity): int(id): val for id, val in self.info.primary_value.metadata.states.items() } self._attr_supported_features = ( - SUPPORT_TURN_ON | SUPPORT_TURN_OFF | SUPPORT_VOLUME_SET + SirenEntityFeature.TURN_ON + | SirenEntityFeature.TURN_OFF + | SirenEntityFeature.VOLUME_SET ) if self._attr_available_tones: - self._attr_supported_features |= SUPPORT_TONES + self._attr_supported_features |= SirenEntityFeature.TONES @property def is_on(self) -> bool | None: