Fix UniFi Protect RTSP repair warnings when globally disabled (#157516)

This commit is contained in:
Raphael Hehl
2025-11-29 22:53:34 +02:00
committed by GitHub
parent 0174bad182
commit e10c1ebcf6
2 changed files with 30 additions and 2 deletions
@@ -92,7 +92,11 @@ def _get_camera_channels(
# no RTSP enabled use first channel with no stream
if is_default and not camera.is_third_party_camera:
_create_rtsp_repair(hass, entry, data, camera)
# Only create repair issue if RTSP is not disabled globally
if not data.disable_stream:
_create_rtsp_repair(hass, entry, data, camera)
else:
ir.async_delete_issue(hass, DOMAIN, f"rtsp_disabled_{camera.id}")
yield camera, camera.channels[0], True
else:
ir.async_delete_issue(hass, DOMAIN, f"rtsp_disabled_{camera.id}")
+25 -1
View File
@@ -7,9 +7,10 @@ from unittest.mock import AsyncMock
from uiprotect.data import Camera, CloudAccount, Version
from homeassistant.components.unifiprotect.const import DOMAIN
from homeassistant.components.unifiprotect.const import CONF_DISABLE_RTSP, DOMAIN
from homeassistant.config_entries import SOURCE_REAUTH
from homeassistant.core import HomeAssistant
from homeassistant.helpers import issue_registry as ir
from .utils import MockUFPFixture, init_entry
@@ -282,3 +283,26 @@ async def test_rtsp_no_fix_if_third_party(
assert msg["success"]
assert not msg["result"]["issues"]
async def test_rtsp_no_fix_if_globally_disabled(
hass: HomeAssistant,
ufp: MockUFPFixture,
doorbell: Camera,
issue_registry: ir.IssueRegistry,
) -> None:
"""Test no RTSP disabled warning if RTSP is globally disabled on integration."""
for channel in doorbell.channels:
channel.is_rtsp_enabled = False
# Set RTSP globally disabled in config entry options
hass.config_entries.async_update_entry(
ufp.entry,
options={**ufp.entry.options, CONF_DISABLE_RTSP: True},
)
await init_entry(hass, ufp, [doorbell])
await async_process_repairs_platforms(hass)
assert len(issue_registry.issues) == 0