Skip to content

Commit f833b56

Browse files
authored
Add Reolink siren state (home-assistant#153169)
1 parent 7eb0f29 commit f833b56

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

homeassistant/components/reolink/siren.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ReolinkHostSirenEntityDescription(
4343
SIREN_ENTITIES = (
4444
ReolinkSirenEntityDescription(
4545
key="siren",
46+
cmd_id=547,
4647
translation_key="siren",
4748
supported=lambda api, ch: api.supported(ch, "siren_play"),
4849
),
@@ -100,6 +101,11 @@ def __init__(
100101
self.entity_description = entity_description
101102
super().__init__(reolink_data, channel)
102103

104+
@property
105+
def is_on(self) -> bool | None:
106+
"""State of the siren."""
107+
return self._host.api.baichuan.siren_state(self._channel)
108+
103109
@raise_translated_error
104110
async def async_turn_on(self, **kwargs: Any) -> None:
105111
"""Turn on the siren."""

tests/components/reolink/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ def _init_host_mock(host_mock: MagicMock) -> None:
171171
host_mock.baichuan.mac_address.return_value = TEST_MAC_CAM
172172
host_mock.baichuan.privacy_mode.return_value = False
173173
host_mock.baichuan.day_night_state.return_value = "day"
174+
host_mock.baichuan.siren_state.return_value = True
174175
host_mock.baichuan.subscribe_events.side_effect = ReolinkError("Test error")
175176
host_mock.baichuan.active_scene = "off"
176177
host_mock.baichuan.scene_names = ["off", "home"]

tests/components/reolink/test_siren.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
ATTR_ENTITY_ID,
1717
SERVICE_TURN_OFF,
1818
SERVICE_TURN_ON,
19+
STATE_ON,
1920
STATE_UNKNOWN,
2021
Platform,
2122
)
@@ -39,7 +40,7 @@ async def test_siren(
3940
assert config_entry.state is ConfigEntryState.LOADED
4041

4142
entity_id = f"{Platform.SIREN}.{TEST_CAM_NAME}_siren"
42-
assert hass.states.get(entity_id).state == STATE_UNKNOWN
43+
assert hass.states.get(entity_id).state == STATE_ON
4344

4445
# test siren turn on
4546
await hass.services.async_call(

0 commit comments

Comments
 (0)