Add Siren to Z-Wave.Me integration (#67200)

* Siren integration

* Clean up

Co-authored-by: Dmitry Vlasov <kerbalspacema@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
pull/67900/head
Poltorak Serguei 2022-03-09 11:09:29 +03:00 committed by GitHub
parent 36385396b0
commit c6952a0ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 3 deletions

View File

@ -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]

View File

@ -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,
]

View File

@ -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"],

View File

@ -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")

View File

@ -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

View File

@ -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