Skip to content

Commit e10c1eb

Browse files
authored
Fix UniFi Protect RTSP repair warnings when globally disabled (home-assistant#157516)
1 parent 0174bad commit e10c1eb

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

homeassistant/components/unifiprotect/camera.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ def _get_camera_channels(
9292

9393
# no RTSP enabled use first channel with no stream
9494
if is_default and not camera.is_third_party_camera:
95-
_create_rtsp_repair(hass, entry, data, camera)
95+
# Only create repair issue if RTSP is not disabled globally
96+
if not data.disable_stream:
97+
_create_rtsp_repair(hass, entry, data, camera)
98+
else:
99+
ir.async_delete_issue(hass, DOMAIN, f"rtsp_disabled_{camera.id}")
96100
yield camera, camera.channels[0], True
97101
else:
98102
ir.async_delete_issue(hass, DOMAIN, f"rtsp_disabled_{camera.id}")

tests/components/unifiprotect/test_repairs.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
from uiprotect.data import Camera, CloudAccount, Version
99

10-
from homeassistant.components.unifiprotect.const import DOMAIN
10+
from homeassistant.components.unifiprotect.const import CONF_DISABLE_RTSP, DOMAIN
1111
from homeassistant.config_entries import SOURCE_REAUTH
1212
from homeassistant.core import HomeAssistant
13+
from homeassistant.helpers import issue_registry as ir
1314

1415
from .utils import MockUFPFixture, init_entry
1516

@@ -282,3 +283,26 @@ async def test_rtsp_no_fix_if_third_party(
282283

283284
assert msg["success"]
284285
assert not msg["result"]["issues"]
286+
287+
288+
async def test_rtsp_no_fix_if_globally_disabled(
289+
hass: HomeAssistant,
290+
ufp: MockUFPFixture,
291+
doorbell: Camera,
292+
issue_registry: ir.IssueRegistry,
293+
) -> None:
294+
"""Test no RTSP disabled warning if RTSP is globally disabled on integration."""
295+
296+
for channel in doorbell.channels:
297+
channel.is_rtsp_enabled = False
298+
299+
# Set RTSP globally disabled in config entry options
300+
hass.config_entries.async_update_entry(
301+
ufp.entry,
302+
options={**ufp.entry.options, CONF_DISABLE_RTSP: True},
303+
)
304+
305+
await init_entry(hass, ufp, [doorbell])
306+
await async_process_repairs_platforms(hass)
307+
308+
assert len(issue_registry.issues) == 0

0 commit comments

Comments
 (0)