diff --git a/custom_components/tahoma/siren.py b/custom_components/tahoma/siren.py index 518c33e0..8f9d2d61 100644 --- a/custom_components/tahoma/siren.py +++ b/custom_components/tahoma/siren.py @@ -1,4 +1,6 @@ """Support for Overkiz sirens.""" +from typing import Any + from pyoverkiz.enums import OverkizState from pyoverkiz.enums.command import OverkizCommand, OverkizCommandParam @@ -23,55 +25,47 @@ async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback, -): +) -> None: """Set up the Overkiz sirens from a config entry.""" data: HomeAssistantOverkizData = hass.data[DOMAIN][entry.entry_id] - entities = [ + async_add_entities( OverkizSiren(device.device_url, data.coordinator) for device in data.platforms[Platform.SIREN] - ] - - async_add_entities(entities) + ) class OverkizSiren(OverkizEntity, SirenEntity): - """Representation an Overkiz Switch.""" + """Representation an Overkiz Siren.""" _attr_supported_features = SUPPORT_TURN_OFF | SUPPORT_TURN_ON | SUPPORT_DURATION @property - def is_on(self): + def is_on(self) -> bool: """Get whether the siren is in on state.""" return ( self.executor.select_state(OverkizState.CORE_ON_OFF) == OverkizCommandParam.ON ) - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Send the on command.""" - if kwargs.get(ATTR_DURATION): - duration = kwargs.get(ATTR_DURATION) + duration = kwargs[ATTR_DURATION] else: duration = 2 * 60 # 2 minutes duration_in_ms = duration * 1000 await self.executor.async_execute_command( - OverkizCommand.RING_WITH_SINGLE_SIMPLE_SEQUENCE, # https://www.tahomalink.com/enduser-mobile-web/steer-html5-client/vendor/somfy/io/siren/const.js + # https://www.tahomalink.com/enduser-mobile-web/steer-html5-client/vendor/somfy/io/siren/const.js + OverkizCommand.RING_WITH_SINGLE_SIMPLE_SEQUENCE, duration_in_ms, # duration 75, # 90 seconds bip, 30 seconds silence 2, # repeat 3 times OverkizCommandParam.MEMORIZED_VOLUME, ) - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Send the off command.""" - await self.executor.async_cancel_command( - [OverkizCommand.RING_WITH_SINGLE_SIMPLE_SEQUENCE] - ) - - await self.executor.async_execute_command( - OverkizCommand.ADVANCED_REFRESH, OverkizCommandParam.NORMAL - ) + await self.executor.async_execute_command(OverkizCommand.OFF)