Repository navigation
Conversation
- Move the WebRTC stream methods from RingDoorBell into RingWebRtcMixin and use it on RingOther too. Ring Intercoms (intercom_handset_video and intercom_handset_audio) use the same live_view signalling as cameras; verified two-way audio on both kinds. - When Ring ends a session, RingWebRtcStream._close() runs inside the reader task and awaited read_task, i.e. itself, raising 'Task cannot await on itself' and never delivering the close reason to on_message_callback. Skip the await when read_task is the current task, and make the device-level close callback only forget the stream instead of re-entering close().
This was referenced Nov 8, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related changes to WebRTC streams.
1. WebRTC live view for
RingOther(intercoms)Ring Intercoms use the same
live_viewsignalling as cameras, but the WebRTC methods lived only onRingDoorBell, soRingOthercouldn't start a stream. This moves them, unchanged, into aRingWebRtcMixin(ring_doorbell/webrtcdevice.py) used by bothRingDoorBellandRingOther. The public API ofRingDoorBelldoesn't change.Tested in the field via ring-intercom-video, which has been monkey-patching these methods onto
RingOther:intercom_handset_video: live video plus two-way audio.intercom_handset_audio: two-way audio confirmed at the door station by two users (traces). The stockstream_options(video_enabled: true) works with an audio-only offer, so no per-kind change is needed.2.
RuntimeError: Task cannot await on itselfwhen Ring ends a sessionWhen Ring sends a
closemessage,handle_close_message()runs inside the reader task and calls_close(), which ends withawait read_task. That's the current task, so it raises, the exception is never retrieved, andon_message_callbacknever gets the close reason. In Home Assistant, the frontend then never learns that the session ended. The device-level_close_callbackalso re-enteredclose_webrtc_stream()→stream.close()and hit the same path (report with traceback)._close()skips awaitingread_taskwhen it is the current task. The reader exits on its own once the websocket is closed._close_callbackonly removes the stream from_webrtc_streams, because the stream is already closing itself.Tests
tests/test_webrtc.py: checks that both classes expose the WebRTC methods, and simulates a server close inside a reader task. That test fails onmasterwith theRuntimeErrorand passes here. Full suite, ruff on the changed files and mypy all pass. (ruff checkreports two existing errors in__init__.py/auth.pythat this PR doesn't touch.)🤖 Generated with Claude Code