diff --git a/.coveragerc b/.coveragerc index ce11e4822a8..b892dd1f25d 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1478,6 +1478,7 @@ omit = homeassistant/components/zwave_me/lock.py homeassistant/components/zwave_me/number.py homeassistant/components/zwave_me/sensor.py + homeassistant/components/zwave_me/siren.py homeassistant/components/zwave_me/switch.py [report] diff --git a/homeassistant/components/zwave_me/const.py b/homeassistant/components/zwave_me/const.py index ccbf6989f07..87d740f1ece 100644 --- a/homeassistant/components/zwave_me/const.py +++ b/homeassistant/components/zwave_me/const.py @@ -16,6 +16,7 @@ class ZWaveMePlatform(StrEnum): NUMBER = "switchMultilevel" SWITCH = "switchBinary" SENSOR = "sensorMultilevel" + SIREN = "siren" RGBW_LIGHT = "switchRGBW" RGB_LIGHT = "switchRGB" @@ -28,5 +29,6 @@ PLATFORMS = [ Platform.LOCK, Platform.NUMBER, Platform.SENSOR, + Platform.SIREN, Platform.SWITCH, ] diff --git a/homeassistant/components/zwave_me/manifest.json b/homeassistant/components/zwave_me/manifest.json index 8863cd6ebf7..2e6efd9576b 100644 --- a/homeassistant/components/zwave_me/manifest.json +++ b/homeassistant/components/zwave_me/manifest.json @@ -4,7 +4,7 @@ "documentation": "https://www.home-assistant.io/integrations/zwave_me", "iot_class": "local_push", "requirements": [ - "zwave_me_ws==0.2.1", + "zwave_me_ws==0.2.2", "url-normalize==1.4.1" ], "after_dependencies": ["zeroconf"], diff --git a/homeassistant/components/zwave_me/siren.py b/homeassistant/components/zwave_me/siren.py new file mode 100644 index 00000000000..c528f610132 --- /dev/null +++ b/homeassistant/components/zwave_me/siren.py @@ -0,0 +1,49 @@ +"""Representation of a sirenBinary.""" +from typing import Any + +from homeassistant.components.siren import SirenEntity +from homeassistant.core import callback +from homeassistant.helpers.dispatcher import async_dispatcher_connect + +from . import ZWaveMeEntity +from .const import DOMAIN, ZWaveMePlatform + +DEVICE_NAME = ZWaveMePlatform.SIREN + + +async def async_setup_entry(hass, config_entry, async_add_entities): + """Set up the siren platform.""" + + @callback + def add_new_device(new_device): + controller = hass.data[DOMAIN][config_entry.entry_id] + siren = ZWaveMeSiren(controller, new_device) + + async_add_entities( + [ + siren, + ] + ) + + config_entry.async_on_unload( + async_dispatcher_connect( + hass, f"ZWAVE_ME_NEW_{DEVICE_NAME.upper()}", add_new_device + ) + ) + + +class ZWaveMeSiren(ZWaveMeEntity, SirenEntity): + """Representation of a ZWaveMe siren.""" + + @property + def is_on(self) -> bool: + """Return the state of the siren.""" + return self.device.level == "on" + + def turn_on(self, **kwargs: Any) -> None: + """Turn the entity on.""" + self.controller.zwave_api.send_command(self.device.id, "on") + + def turn_off(self, **kwargs: Any) -> None: + """Turn the entity off.""" + self.controller.zwave_api.send_command(self.device.id, "off") diff --git a/requirements_all.txt b/requirements_all.txt index e318f61ccfe..01b81d8fabc 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2506,4 +2506,4 @@ zm-py==0.5.2 zwave-js-server-python==0.35.2 # homeassistant.components.zwave_me -zwave_me_ws==0.2.1 +zwave_me_ws==0.2.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index f1aa2224391..fdde0853f51 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1599,4 +1599,4 @@ zigpy==0.43.0 zwave-js-server-python==0.35.2 # homeassistant.components.zwave_me -zwave_me_ws==0.2.1 +zwave_me_ws==0.2.2