diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 176cba8ae8b..781388f12d6 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -55,6 +55,7 @@ from homeassistant.helpers.deprecation import ( DeprecatedConstantEnum, all_with_deprecated_constants, check_if_deprecated_constant, + deprecated_function, dir_with_deprecated_constants, ) 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: 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: _LOGGER.error("Error handling WebRTC offer: %s", ex) send_message( diff --git a/tests/components/camera/test_webrtc.py b/tests/components/camera/test_webrtc.py index 04cafbf4ae5..ba90788bdc3 100644 --- a/tests/components/camera/test_webrtc.py +++ b/tests/components/camera/test_webrtc.py @@ -65,7 +65,6 @@ class MockCamera(Camera): _attr_name = "Test" _attr_supported_features: CameraEntityFeature = CameraEntityFeature.STREAM - _attr_frontend_stream_type: StreamType = StreamType.WEB_RTC def __init__(self) -> None: """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( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, - init_test_integration: MockCamera, + caplog: pytest.LogCaptureFixture, ) -> None: """Test sync WebRTC stream offer.""" client = await hass_ws_client(hass) - init_test_integration.set_sync_answer(WEBRTC_ANSWER) await client.send_json_auto_id( { "type": "camera/webrtc/offer", - "entity_id": "camera.test", + "entity_id": "camera.sync", "offer": WEBRTC_OFFER, } ) 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["success"] subscription_id = response["id"]