1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-26 14:08:21 +00:00

Add Reolink siren state (#153169)

This commit is contained in:
starkillerOG
2025-09-29 08:42:38 +02:00
committed by GitHub
parent 7eb0f2993f
commit f833b56122
3 changed files with 9 additions and 1 deletions

View File

@@ -43,6 +43,7 @@ class ReolinkHostSirenEntityDescription(
SIREN_ENTITIES = (
ReolinkSirenEntityDescription(
key="siren",
cmd_id=547,
translation_key="siren",
supported=lambda api, ch: api.supported(ch, "siren_play"),
),
@@ -100,6 +101,11 @@ class ReolinkSirenEntity(ReolinkChannelCoordinatorEntity, SirenEntity):
self.entity_description = entity_description
super().__init__(reolink_data, channel)
@property
def is_on(self) -> bool | None:
"""State of the siren."""
return self._host.api.baichuan.siren_state(self._channel)
@raise_translated_error
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn on the siren."""

View File

@@ -171,6 +171,7 @@ def _init_host_mock(host_mock: MagicMock) -> None:
host_mock.baichuan.mac_address.return_value = TEST_MAC_CAM
host_mock.baichuan.privacy_mode.return_value = False
host_mock.baichuan.day_night_state.return_value = "day"
host_mock.baichuan.siren_state.return_value = True
host_mock.baichuan.subscribe_events.side_effect = ReolinkError("Test error")
host_mock.baichuan.active_scene = "off"
host_mock.baichuan.scene_names = ["off", "home"]

View File

@@ -16,6 +16,7 @@ from homeassistant.const import (
ATTR_ENTITY_ID,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
STATE_ON,
STATE_UNKNOWN,
Platform,
)
@@ -39,7 +40,7 @@ async def test_siren(
assert config_entry.state is ConfigEntryState.LOADED
entity_id = f"{Platform.SIREN}.{TEST_CAM_NAME}_siren"
assert hass.states.get(entity_id).state == STATE_UNKNOWN
assert hass.states.get(entity_id).state == STATE_ON
# test siren turn on
await hass.services.async_call(