diff --git a/homeassistant/components/reolink/binary_sensor.py b/homeassistant/components/reolink/binary_sensor.py index 2d08e42a6c8..5664bba25a3 100644 --- a/homeassistant/components/reolink/binary_sensor.py +++ b/homeassistant/components/reolink/binary_sensor.py @@ -63,6 +63,7 @@ BINARY_PUSH_SENSORS = ( cmd_id=33, device_class=BinarySensorDeviceClass.MOTION, value=lambda api, ch: api.motion_detected(ch), + supported=lambda api, ch: api.supported(ch, "motion_detection"), ), ReolinkBinarySensorEntityDescription( key=FACE_DETECTION_TYPE, diff --git a/homeassistant/components/reolink/camera.py b/homeassistant/components/reolink/camera.py index 329ef9028de..119fb625349 100644 --- a/homeassistant/components/reolink/camera.py +++ b/homeassistant/components/reolink/camera.py @@ -37,23 +37,27 @@ CAMERA_ENTITIES = ( key="sub", stream="sub", translation_key="sub", + supported=lambda api, ch: api.supported(ch, "stream"), ), ReolinkCameraEntityDescription( key="main", stream="main", translation_key="main", + supported=lambda api, ch: api.supported(ch, "stream"), entity_registry_enabled_default=False, ), ReolinkCameraEntityDescription( key="snapshots_sub", stream="snapshots_sub", translation_key="snapshots_sub", + supported=lambda api, ch: api.supported(ch, "snapshot"), entity_registry_enabled_default=False, ), ReolinkCameraEntityDescription( key="snapshots", stream="snapshots_main", translation_key="snapshots_main", + supported=lambda api, ch: api.supported(ch, "snapshot"), entity_registry_enabled_default=False, ), ReolinkCameraEntityDescription( diff --git a/tests/components/reolink/test_media_source.py b/tests/components/reolink/test_media_source.py index 126d445ca01..7e4a0cfb7a7 100644 --- a/tests/components/reolink/test_media_source.py +++ b/tests/components/reolink/test_media_source.py @@ -333,7 +333,14 @@ async def test_browsing_rec_playback_unsupported( config_entry: MockConfigEntry, ) -> None: """Test browsing a Reolink camera which does not support playback of recordings.""" - reolink_connect.supported.return_value = 0 + + def test_supported(ch, key): + """Test supported function.""" + if key == "replay": + return False + return True + + reolink_connect.supported = test_supported with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]): assert await hass.config_entries.async_setup(config_entry.entry_id) @@ -347,6 +354,8 @@ async def test_browsing_rec_playback_unsupported( assert browse.identifier is None assert browse.children == [] + reolink_connect.supported = lambda ch, key: True # Reset supported function + async def test_browsing_errors( hass: HomeAssistant, @@ -354,8 +363,6 @@ async def test_browsing_errors( config_entry: MockConfigEntry, ) -> None: """Test browsing a Reolink camera errors.""" - reolink_connect.supported.return_value = 1 - with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]): assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done() @@ -373,8 +380,6 @@ async def test_browsing_not_loaded( config_entry: MockConfigEntry, ) -> None: """Test browsing a Reolink camera integration which is not loaded.""" - reolink_connect.supported.return_value = 1 - with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]): assert await hass.config_entries.async_setup(config_entry.entry_id) await hass.async_block_till_done()