Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate RTSPtoWebRTC #131467

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions homeassistant/components/rtsp_to_webrtc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady, HomeAssistantError
from homeassistant.helpers import issue_registry as ir
from homeassistant.helpers.aiohttp_client import async_get_clientsession

_LOGGER = logging.getLogger(__name__)
Expand All @@ -40,10 +41,24 @@
TIMEOUT = 10
CONF_STUN_SERVER = "stun_server"

_DEPRECATED = "deprecated"


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up RTSPtoWebRTC from a config entry."""
hass.data.setdefault(DOMAIN, {})
ir.async_create_issue(
hass,
DOMAIN,
_DEPRECATED,
breaks_in_ha_version="2025.6.0",
is_fixable=False,
severity=ir.IssueSeverity.WARNING,
translation_key=_DEPRECATED,
translation_placeholders={
"go2rtc": "[go2rtc](https://www.home-assistant.io/integrations/go2rtc/)",
},
)

client: WebRTCClientInterface
try:
Expand Down Expand Up @@ -98,6 +113,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
if DOMAIN in hass.data:
del hass.data[DOMAIN]
ir.async_delete_issue(hass, DOMAIN, _DEPRECATED)
return True


Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/rtsp_to_webrtc/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"server_unreachable": "[%key:component::rtsp_to_webrtc::config::error::server_unreachable%]"
}
},
"issues": {
"deprecated": {
"title": "The RTSPtoWebRTC integration is deprecated",
"description": "The RTSPtoWebRTC integration is deprecated and will be removed. Please use the {go2rtc} integration instead, which is enabled by default and provides a better experience. You only need to remove the RTSPtoWebRTC config entry."
}
},
"options": {
"step": {
"init": {
Expand Down
19 changes: 17 additions & 2 deletions tests/components/rtsp_to_webrtc/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
from homeassistant.components.websocket_api import TYPE_RESULT
from homeassistant.config_entries import ConfigEntryState
from homeassistant.core import HomeAssistant
from homeassistant.helpers import issue_registry as ir
from homeassistant.setup import async_setup_component

from .conftest import SERVER_URL, STREAM_SOURCE, ComponentSetup

from tests.common import MockConfigEntry
from tests.test_util.aiohttp import AiohttpClientMocker
from tests.typing import WebSocketGenerator

Expand All @@ -33,15 +35,28 @@ async def setup_homeassistant(hass: HomeAssistant):
await async_setup_component(hass, "homeassistant", {})


@pytest.mark.usefixtures("rtsp_to_webrtc_client")
async def test_setup_success(
hass: HomeAssistant, rtsp_to_webrtc_client: Any, setup_integration: ComponentSetup
hass: HomeAssistant,
config_entry: MockConfigEntry,
issue_registry: ir.IssueRegistry,
) -> None:
"""Test successful setup and unload."""
await setup_integration()
config_entry.add_to_hass(hass)

assert await async_setup_component(hass, DOMAIN, {})
await hass.async_block_till_done()
assert issue_registry.async_get_issue(DOMAIN, "deprecated")

entries = hass.config_entries.async_entries(DOMAIN)
assert len(entries) == 1
assert entries[0].state is ConfigEntryState.LOADED
await hass.config_entries.async_unload(entries[0].entry_id)
await hass.async_block_till_done()

assert not hass.data.get(DOMAIN)
assert entries[0].state is ConfigEntryState.NOT_LOADED
assert not issue_registry.async_get_issue(DOMAIN, "deprecated")


@pytest.mark.parametrize("config_entry_data", [{}])
Expand Down