fix: unifiprotect prevent RTSP repair for third-party cameras (#132212)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Raphael Hehl 2024-12-04 06:03:31 +01:00 committed by GitHub
parent 1fe2a928a2
commit cb36184511
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 1 deletions

View File

@ -90,7 +90,7 @@ def _get_camera_channels(
is_default = False is_default = False
# no RTSP enabled use first channel with no stream # no RTSP enabled use first channel with no stream
if is_default: if is_default and not camera.is_third_party_camera:
_create_rtsp_repair(hass, entry, data, camera) _create_rtsp_repair(hass, entry, data, camera)
yield camera, camera.channels[0], True yield camera, camera.channels[0], True
else: else:

View File

@ -363,3 +363,30 @@ async def test_rtsp_writable_fix_when_not_setup(
ufp.api.update_device.assert_called_with( ufp.api.update_device.assert_called_with(
ModelType.CAMERA, doorbell.id, {"channels": channels} ModelType.CAMERA, doorbell.id, {"channels": channels}
) )
async def test_rtsp_no_fix_if_third_party(
hass: HomeAssistant,
ufp: MockUFPFixture,
doorbell: Camera,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test no RTSP disabled warning if camera is third-party."""
for channel in doorbell.channels:
channel.is_rtsp_enabled = False
for user in ufp.api.bootstrap.users.values():
user.all_permissions = []
ufp.api.get_camera = AsyncMock(return_value=doorbell)
doorbell.is_third_party_camera = True
await init_entry(hass, ufp, [doorbell])
await async_process_repairs_platforms(hass)
ws_client = await hass_ws_client(hass)
await ws_client.send_json({"id": 1, "type": "repairs/list_issues"})
msg = await ws_client.receive_json()
assert msg["success"]
assert not msg["result"]["issues"]