Deprecate camera async_handle_web_rtc_offer (#131285)

This commit is contained in:
Robert Resch 2024-11-22 17:37:56 +01:00 committed by GitHub
parent 97f574a86a
commit 754cf1fdb4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 5 deletions

View File

@ -55,6 +55,7 @@ from homeassistant.helpers.deprecation import (
DeprecatedConstantEnum, DeprecatedConstantEnum,
all_with_deprecated_constants, all_with_deprecated_constants,
check_if_deprecated_constant, check_if_deprecated_constant,
deprecated_function,
dir_with_deprecated_constants, dir_with_deprecated_constants,
) )
from homeassistant.helpers.entity import Entity, EntityDescription from homeassistant.helpers.entity import Entity, EntityDescription
@ -665,7 +666,10 @@ class Camera(Entity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_):
""" """
if self._supports_native_sync_webrtc: if self._supports_native_sync_webrtc:
try: try:
answer = await self.async_handle_web_rtc_offer(offer_sdp) answer = await deprecated_function(
"async_handle_async_webrtc_offer",
breaks_in_ha_version="2025.6",
)(self.async_handle_web_rtc_offer)(offer_sdp)
except ValueError as ex: except ValueError as ex:
_LOGGER.error("Error handling WebRTC offer: %s", ex) _LOGGER.error("Error handling WebRTC offer: %s", ex)
send_message( send_message(

View File

@ -65,7 +65,6 @@ class MockCamera(Camera):
_attr_name = "Test" _attr_name = "Test"
_attr_supported_features: CameraEntityFeature = CameraEntityFeature.STREAM _attr_supported_features: CameraEntityFeature = CameraEntityFeature.STREAM
_attr_frontend_stream_type: StreamType = StreamType.WEB_RTC
def __init__(self) -> None: def __init__(self) -> None:
"""Initialize the mock entity.""" """Initialize the mock entity."""
@ -684,24 +683,33 @@ async def test_websocket_webrtc_offer_failure(
} }
@pytest.mark.usefixtures("mock_test_webrtc_cameras")
async def test_websocket_webrtc_offer_sync( async def test_websocket_webrtc_offer_sync(
hass: HomeAssistant, hass: HomeAssistant,
hass_ws_client: WebSocketGenerator, hass_ws_client: WebSocketGenerator,
init_test_integration: MockCamera, caplog: pytest.LogCaptureFixture,
) -> None: ) -> None:
"""Test sync WebRTC stream offer.""" """Test sync WebRTC stream offer."""
client = await hass_ws_client(hass) client = await hass_ws_client(hass)
init_test_integration.set_sync_answer(WEBRTC_ANSWER)
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "camera/webrtc/offer", "type": "camera/webrtc/offer",
"entity_id": "camera.test", "entity_id": "camera.sync",
"offer": WEBRTC_OFFER, "offer": WEBRTC_OFFER,
} }
) )
response = await client.receive_json() response = await client.receive_json()
assert (
"tests.components.camera.conftest",
logging.WARNING,
(
"async_handle_web_rtc_offer was called from camera, this is a deprecated "
"function which will be removed in HA Core 2025.6. Use "
"async_handle_async_webrtc_offer instead"
),
) in caplog.record_tuples
assert response["type"] == TYPE_RESULT assert response["type"] == TYPE_RESULT
assert response["success"] assert response["success"]
subscription_id = response["id"] subscription_id = response["id"]