This guide will show you how to get almost lag free video from several security cameras directly in the Home Assistant dashboard without having to open up any streams. The video is automatically played using WebRTC whenever you open the corresponding dashboard, and there is no need for any other actions. This is a perfect solution for those using wall-mounted tablets, as you can interact with the dashboard, for example turning on lights and media players, while viewing a live feed from one of your security cameras.
As good as this sounds, there is (currently) one rather large caveat to the Home Assistant project I am guiding you through today: compatibility. There is a list of tested and confirmed to be working cameras, and it currently isn't all too extensive. What will please many though is the fact that many cheaper cameras, such as the Sonoff GK-200MP2-B, the (hacked) Xiaomi Dafang, the Wyze Cam v2, and many Dahua models are supports. An extensive an up-to-date list can be found in the project's repository.
WebRTC for Home Assistant
Surveillance in Home Assistant has come a long way thanks to open standards such as ONVIF and protocols such as the RTSP. The WebRTC Camera custom component brings yet another exciting technology to Home Assistant: Web Real-Time Communication.
WebRTC works in any modern browser, including mobile versions, has a minimal delay, does not labour the CPU with transcoding, and supports audio. Sounds almost too good to be true, doesn't it? Thanks to an old Xiaomi Dafang camera I have lying around, I can unequivocally confirm that it is precisely what it promises to be.
How to install WebRTC Camera in Home Assistant
As a custom component, it should come as no surprise that WebRTC Camera is installed using the Home Assistant Community Store, or HACS for short. If you haven't done so yet, I suggest you set up using the official instructions on the project's website. Once installed, search for
WebRTC Camera in the existing repositories. There should be no need for adding it manually. You will be prompted to restart Home Assistant after the installation has been completed. Do so before continuing.
With the restart complete, enter the Home Assistant integrations, and search for WebRTC Camera. There are no further inputs needed and once the integration has been added, it is ready for action.
Setting up a camera using WebRTC in Home Assistant
Cameras aren't added using the WebRTC Camera custom component, it instead uses cameras that have already been added to Home Assistant or an available RTSP stream. In my case, I have set up a hacked Xiaomi Dafang security camera using the ffmpeg integration.
- platform: ffmpeg
input: -rtsp_transport tcp -i rtsp://192.168.1.69:8554/unicast
This camera can now be added to the Home Assistant dashboard using a manual card and the following lines of YAML:
Configuring WebRTC Camera
There are further parameters you can configure using the WebRTC Camera custom component for Home Assistant. In my case, the Xiaomi Dafang camera supports PT
Z (pan, tilt, and zoom) movement. The card can be set up to display those controls as an overlay, giving it a cleaner look than adding several buttons below the card.
Another thing you will notice is that the camera will take a couple of seconds to load with the basic setup above. This is due to the connection being severed whenever you switch to a different tab or window. This can be disabled, but it does mean that the camera will constantly be streamed in the background.
Verdict: This should be an official Home Assistant feature
In my opinion, the WebRTC Camera custom component should be an official feature of Home Assistant. In my non-scientific testing, the lag is never more than a second, and it makes viewing security cameras in the Home Assistant dashboard much easier. I would definitely recommend those using wall-mounted tablets to test this component. And even if your walls are free of screens, the functionality might well be beneficial.
As already mentioned, a full list of supported cameras can be found in the WebRTC Camera repository. A few community favourites include the Sonoff GK-200MP2-B, the Hikvision DS-2CD2T47G1-L, DS-2CD1321-I, and DS-2CD2143G0-IS, the Dahua DH-IPC-HDPW1431FP-AS-0280B, the Wyze Cam v2, Xiaomi Dafang, and the Reolink E1 Pro.