RTSPtoWebRTC camera.frontend_stream_type reverts to 'hls' after HA startup
See original GitHub issueThe problem
The RTSPtoWebRTC integration successfully modifies the attribute frontend_stream_type of cameras to web_rtc whenever I reload the integration. However, when HA core restarts, all cameras revert to hls. To get WebRTC working again I need to reload the RTSPtoWebRTC integration. This also happened in v2022.04, before I upgraded to 2022.05 yesterday.
The cameras in question are working through the ONVIF integration. From looking through the logbook, I suspect a race condition between the ONVIF integration and the RTSPtoWebRTC integration.
To analyse this I added some template sensors like the following to track the value of the frontend_stream_type attribute of the cameras:
- name: driveway_stream_type
state: "{{ state_attr('camera.driveway_camera_mainstream', 'frontend_stream_type') }}"
Here’s what happens to that template sensor during and after a restart:

Here’s an abridged version of the Logbook showing relevant events during that restart:

I note from the “System Health” page that ONVIF had a 36s startup time.

RTSPtoWebRTC starts up faster than ONVIF, which makes it seem like a race condition to me.
In the meantime, I have automated reloading the integration with the following (where entry_id is the value in my .storage/core.config_entries file for the rtsp_to_webrtc entry):
alias: Reload RTSPtoWebRTC after restart
trigger:
- platform: homeassistant
event: start
condition: []
action:
- delay:
minutes: 1
- service: homeassistant.reload_config_entry
data:
entry_id: 5033d785b092d50d530138c64c1f20d9
mode: single
What version of Home Assistant Core has the issue?
2022.5.3
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
rtsp_to_webrtc
Link to integration documentation on our website
https://www.home-assistant.io/integrations/rtsp_to_webrtc/
Diagnostics information
config_entry-rtsp_to_webrtc-5033d785b092d50d530138c64c1f20d9.json.txt
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
Issue Analytics
- State:
- Created a year ago
- Comments:14 (6 by maintainers)

Top Related StackOverflow Question
OK I tagged onvif, but now will untag onvif and dig a little bit more assuming its an rtsp_to_webrtc bug.
Hi Allen, I’m happy to try it. My cameras are using the ONVIF integration via the DVR but that shouldn’t effect the test?