From 1f03c140f577f898a8e806e36519492023460a67 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Tue, 29 Oct 2024 10:45:00 +0100 Subject: [PATCH] Bump go2rtc-client to 0.0.1b2 (#129395) --- homeassistant/components/go2rtc/__init__.py | 8 ++-- homeassistant/components/go2rtc/manifest.json | 2 +- homeassistant/package_constraints.txt | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/go2rtc/test_init.py | 48 ++++++++++--------- 6 files changed, 33 insertions(+), 31 deletions(-) diff --git a/homeassistant/components/go2rtc/__init__.py b/homeassistant/components/go2rtc/__init__.py index 77743d971bd..007cf825e7c 100644 --- a/homeassistant/components/go2rtc/__init__.py +++ b/homeassistant/components/go2rtc/__init__.py @@ -163,17 +163,15 @@ class WebRTCProvider(CameraWebRTCProvider): case WebRTCCandidate(): value = HAWebRTCCandidate(message.candidate) case WebRTCAnswer(): - value = HAWebRTCAnswer(message.answer) + value = HAWebRTCAnswer(message.sdp) case WsError(): value = WebRTCError("go2rtc_webrtc_offer_failed", message.error) - case _: - _LOGGER.warning("Unknown message %s", message) - return send_message(value) ws_client.subscribe(on_messages) - await ws_client.send(WebRTCOffer(offer_sdp)) + config = camera.async_get_webrtc_client_configuration() + await ws_client.send(WebRTCOffer(offer_sdp, config.configuration.ice_servers)) async def async_on_webrtc_candidate(self, session_id: str, candidate: str) -> None: """Handle the WebRTC candidate.""" diff --git a/homeassistant/components/go2rtc/manifest.json b/homeassistant/components/go2rtc/manifest.json index 025b26317bb..a9e0fc1209a 100644 --- a/homeassistant/components/go2rtc/manifest.json +++ b/homeassistant/components/go2rtc/manifest.json @@ -7,5 +7,5 @@ "documentation": "https://www.home-assistant.io/integrations/go2rtc", "integration_type": "system", "iot_class": "local_polling", - "requirements": ["go2rtc-client==0.0.1b1"] + "requirements": ["go2rtc-client==0.0.1b2"] } diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index f9d104f299f..52c6fc4bf0e 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -26,7 +26,7 @@ ciso8601==2.3.1 cryptography==43.0.1 dbus-fast==2.24.3 fnv-hash-fast==1.0.2 -go2rtc-client==0.0.1b1 +go2rtc-client==0.0.1b2 ha-av==10.1.1 ha-ffmpeg==3.2.1 habluetooth==3.6.0 diff --git a/requirements_all.txt b/requirements_all.txt index 98554d2069c..5cc70915bcf 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -986,7 +986,7 @@ gitterpy==0.1.7 glances-api==0.8.0 # homeassistant.components.go2rtc -go2rtc-client==0.0.1b1 +go2rtc-client==0.0.1b2 # homeassistant.components.goalzero goalzero==0.2.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 06c6f3cab7a..b43aa82a912 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -836,7 +836,7 @@ gios==5.0.0 glances-api==0.8.0 # homeassistant.components.go2rtc -go2rtc-client==0.0.1b1 +go2rtc-client==0.0.1b2 # homeassistant.components.goalzero goalzero==0.2.2 diff --git a/tests/components/go2rtc/test_init.py b/tests/components/go2rtc/test_init.py index 9c7d34060ef..fddb315479f 100644 --- a/tests/components/go2rtc/test_init.py +++ b/tests/components/go2rtc/test_init.py @@ -196,7 +196,12 @@ async def _test_setup_and_signaling( await camera.async_handle_async_webrtc_offer( OFFER_SDP, "session_id", receive_message_callback ) - ws_client.send.assert_called_once_with(WebRTCOffer(OFFER_SDP)) + ws_client.send.assert_called_once_with( + WebRTCOffer( + OFFER_SDP, + camera.async_get_webrtc_client_configuration().configuration.ice_servers, + ) + ) ws_client.subscribe.assert_called_once() # Simulate the answer from the go2rtc server @@ -303,11 +308,17 @@ async def message_callbacks( ) -> Callbacks: """Prepare and return receive message callback.""" receive_callback = Mock(spec_set=WebRTCSendMessage) + camera = init_test_integration - await init_test_integration.async_handle_async_webrtc_offer( + await camera.async_handle_async_webrtc_offer( OFFER_SDP, "session_id", receive_callback ) - ws_client.send.assert_called_once_with(WebRTCOffer(OFFER_SDP)) + ws_client.send.assert_called_once_with( + WebRTCOffer( + OFFER_SDP, + camera.async_get_webrtc_client_configuration().configuration.ice_servers, + ) + ) ws_client.subscribe.assert_called_once() # Simulate messages from the go2rtc server @@ -346,23 +357,6 @@ async def test_receiving_messages_from_go2rtc_server( on_message.assert_called_once_with(expected_message) -@pytest.mark.usefixtures("init_integration") -async def test_receiving_unknown_message_from_go2rtc_server( - message_callbacks: Callbacks, - caplog: pytest.LogCaptureFixture, -) -> None: - """Test receiving unknown message from go2rtc server.""" - on_message, send_message = message_callbacks - - send_message({"type": "unknown"}) - on_message.assert_not_called() - assert ( - "homeassistant.components.go2rtc", - logging.WARNING, - "Unknown message {'type': 'unknown'}", - ) in caplog.record_tuples - - @pytest.mark.usefixtures("init_integration") async def test_on_candidate( ws_client: Mock, @@ -386,7 +380,12 @@ async def test_on_candidate( await init_test_integration.async_handle_async_webrtc_offer( OFFER_SDP, session_id, Mock() ) - ws_client.send.assert_called_once_with(WebRTCOffer(OFFER_SDP)) + ws_client.send.assert_called_once_with( + WebRTCOffer( + OFFER_SDP, + camera.async_get_webrtc_client_configuration().configuration.ice_servers, + ) + ) ws_client.reset_mock() await camera.async_on_webrtc_candidate(session_id, "candidate") @@ -412,7 +411,12 @@ async def test_close_session( await init_test_integration.async_handle_async_webrtc_offer( OFFER_SDP, session_id, Mock() ) - ws_client.send.assert_called_once_with(WebRTCOffer(OFFER_SDP)) + ws_client.send.assert_called_once_with( + WebRTCOffer( + OFFER_SDP, + camera.async_get_webrtc_client_configuration().configuration.ice_servers, + ) + ) # Close session camera.close_webrtc_session(session_id)