Skip to content

Commit

Permalink
fix: unifiprotect prevent RTSP repair for third-party cameras (#132212)
Browse files Browse the repository at this point in the history
Co-authored-by: J. Nick Koston <nick@koston.org>
  • Loading branch information
2 people authored and frenck committed Dec 4, 2024
1 parent d40a9bd commit f285793
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion homeassistant/components/unifiprotect/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _get_camera_channels(
is_default = False

# 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)
yield camera, camera.channels[0], True
else:
Expand Down
27 changes: 27 additions & 0 deletions tests/components/unifiprotect/test_repairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,30 @@ async def test_rtsp_writable_fix_when_not_setup(
ufp.api.update_device.assert_called_with(
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"]

0 comments on commit f285793

Please sign in to comment.