How to get lag-free video in the Home Assistant dashboard

Disclosure: This post contains affiliate links. If you click through and make a purchase, I will earn a commission, at no additional cost to you. Read my full disclosure here.

An illustration of people being watched by security cameras.

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.

  • How to install WebRTC Camera in Home Assistant
  • Setting up a camera using WebRTC in Home Assistant
  • Configuring WebRTC Camera
  • Verdict: This should be an official Home Assistant feature
  • Supported cameras
  • 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.

    The WebRTC Camera integration for lag-free video in Home Assistant

    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.

    camera:
      - platform: ffmpeg
        name: DaFang3
        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:

    type: custom:webrtc-camera
    entity: camera.dafang3

    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 PTZ (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.

    type: custom:webrtc-camera
    entity: camera.dafang3
    background: true
    ptz:
      service: mqtt.publish
      data_left:
        topic: camera/bedroom/camera/motors/horizontal/set
        payload: left
      data_right:
        topic: camera/bedroom/camera/motors/horizontal/set
        payload: right
      data_up:
        topic: camera/bedroom/camera/motors/vertical/set
        payload: up
      data_down:
        topic: camera/bedroom/camera/motors/vertical/set
        payload: down

    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.

    Supported cameras

    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.

    A portrait photo oif Liam Alexander Colman, the author, creator, and owner of Home Assistant Guide wearing a suit.

    About Liam Alexander Colman

    is an experienced Home Assistant user who has been utilizing the platform for a variety of projects over an extended period. His journey began with a Raspberry Pi, which quickly grew to three Raspberry Pis and eventually a full-fledged server. Liam's current operating system of choice is Unraid, with Home Assistant comfortably running in a Docker container.
    With a deep understanding of the intricacies of Home Assistant, Liam has an impressive setup, consisting of various Zigbee devices, and seamless integrations with existing products such as his Android TV box. For those interested in learning more about Liam's experience with Home Assistant, he shares his insights on how he first started using the platform and his subsequent journey.

    Comments

    1. I wish there was a way to cast eufy cameras to chromecast though, it runs fine with webrtc in ha, but once I dashcast it to chromecast I get unsupported codec.

      Reply
    2. Unfortunately I dont think webrtc is a valid solution unless you only want local access. If you want to be able to access it remotely from a variety of devices, you will have issues.

      Reply

    Leave a comment

    Share to...