mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Reolink check if camera and motion supported (#146666)
This commit is contained in:
parent
c78b66d5d5
commit
89ae68c5af
@ -63,6 +63,7 @@ BINARY_PUSH_SENSORS = (
|
|||||||
cmd_id=33,
|
cmd_id=33,
|
||||||
device_class=BinarySensorDeviceClass.MOTION,
|
device_class=BinarySensorDeviceClass.MOTION,
|
||||||
value=lambda api, ch: api.motion_detected(ch),
|
value=lambda api, ch: api.motion_detected(ch),
|
||||||
|
supported=lambda api, ch: api.supported(ch, "motion_detection"),
|
||||||
),
|
),
|
||||||
ReolinkBinarySensorEntityDescription(
|
ReolinkBinarySensorEntityDescription(
|
||||||
key=FACE_DETECTION_TYPE,
|
key=FACE_DETECTION_TYPE,
|
||||||
|
@ -37,23 +37,27 @@ CAMERA_ENTITIES = (
|
|||||||
key="sub",
|
key="sub",
|
||||||
stream="sub",
|
stream="sub",
|
||||||
translation_key="sub",
|
translation_key="sub",
|
||||||
|
supported=lambda api, ch: api.supported(ch, "stream"),
|
||||||
),
|
),
|
||||||
ReolinkCameraEntityDescription(
|
ReolinkCameraEntityDescription(
|
||||||
key="main",
|
key="main",
|
||||||
stream="main",
|
stream="main",
|
||||||
translation_key="main",
|
translation_key="main",
|
||||||
|
supported=lambda api, ch: api.supported(ch, "stream"),
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
ReolinkCameraEntityDescription(
|
ReolinkCameraEntityDescription(
|
||||||
key="snapshots_sub",
|
key="snapshots_sub",
|
||||||
stream="snapshots_sub",
|
stream="snapshots_sub",
|
||||||
translation_key="snapshots_sub",
|
translation_key="snapshots_sub",
|
||||||
|
supported=lambda api, ch: api.supported(ch, "snapshot"),
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
ReolinkCameraEntityDescription(
|
ReolinkCameraEntityDescription(
|
||||||
key="snapshots",
|
key="snapshots",
|
||||||
stream="snapshots_main",
|
stream="snapshots_main",
|
||||||
translation_key="snapshots_main",
|
translation_key="snapshots_main",
|
||||||
|
supported=lambda api, ch: api.supported(ch, "snapshot"),
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
ReolinkCameraEntityDescription(
|
ReolinkCameraEntityDescription(
|
||||||
|
@ -333,7 +333,14 @@ async def test_browsing_rec_playback_unsupported(
|
|||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test browsing a Reolink camera which does not support playback of recordings."""
|
"""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]):
|
with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]):
|
||||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
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.identifier is None
|
||||||
assert browse.children == []
|
assert browse.children == []
|
||||||
|
|
||||||
|
reolink_connect.supported = lambda ch, key: True # Reset supported function
|
||||||
|
|
||||||
|
|
||||||
async def test_browsing_errors(
|
async def test_browsing_errors(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -354,8 +363,6 @@ async def test_browsing_errors(
|
|||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test browsing a Reolink camera errors."""
|
"""Test browsing a Reolink camera errors."""
|
||||||
reolink_connect.supported.return_value = 1
|
|
||||||
|
|
||||||
with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]):
|
with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]):
|
||||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -373,8 +380,6 @@ async def test_browsing_not_loaded(
|
|||||||
config_entry: MockConfigEntry,
|
config_entry: MockConfigEntry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test browsing a Reolink camera integration which is not loaded."""
|
"""Test browsing a Reolink camera integration which is not loaded."""
|
||||||
reolink_connect.supported.return_value = 1
|
|
||||||
|
|
||||||
with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]):
|
with patch("homeassistant.components.reolink.PLATFORMS", [Platform.CAMERA]):
|
||||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user