Deprecate RTSPtoWebRTC (#131467)

* Deprecate RTSPtoWebRTC

* Update homeassistant/components/rtsp_to_webrtc/strings.json

Co-authored-by: Allen Porter <allen@thebends.org>

* Updated text

---------

Co-authored-by: Allen Porter <allen@thebends.org>
This commit is contained in:
Robert Resch 2024-11-25 21:17:19 +01:00 committed by GitHub
parent 7aa30758f9
commit 1b62e12261
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 39 additions and 2 deletions

View File

@ -30,6 +30,7 @@ from homeassistant.components import camera
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__)
@ -40,10 +41,24 @@ DATA_UNSUB = "unsub"
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:
@ -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

View File

@ -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": {

View File

@ -14,10 +14,12 @@ from homeassistant.components.rtsp_to_webrtc import DOMAIN
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
@ -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", [{}])