logo smart home family kruse

Kruse Smart Home

Easy living in our smart home & Garden

Home Assistant Dahua webcam dashboard including PTZ presets

Home Assistant Dahua webcam dashboard including PTZ presets

30 January 2023


1. Introduction

A Home Assistant Dahua webcam dashboard card is created to show the life stream of our backyard camera within Home Assistant. We use the Dahua webcam to monitor our fish ponds so we can see which animals steal our fish and how, so we can bring counter measures in place. So far a blue heron, magpie and cats have managed in the past years to grab some fish from our pond. It turned out that the blue heron was the hungriest and smartest thief.

Our Dahua webcam is a so called PTZ camera (Dahua DH-SD22204T-GN-W) which makes it possible to move and zoom the lens. By creating PTZ presets in the camera it is possible to switch to predefined views via the web or mobile apps. Our Dahua webcam dashboard card includes buttons to switch the PTZ presets.

The next sections explain how to setup this Dahua webcam dashboard card for our situation, but can easily be adapted to suit your own webcam & situation (even if your webcam brand is not Dahua as most webcams use similar commands to switch the presets).

Note: We are still finetuning our dashboard card and will update this article accordingly.

2. Requirements

The following is required to reproduce the Dahua webcam dashboard card:


  • Philips Hue lights
    We use these around our pond and when dark can be used to put the pond in bright light.

2. Configure the Dahua webcam

Before setting up the dashboard the webcam itself is configured.

  1. Login into the Dahua Webcam and create PTZ presets via settings > PTZ.
  2. Setup a user to be used from Home Assistant with only the rights needed. In our case a user HomeAssistant & password was created.

3. Integrate the Dahua webcam within Home Assistant

To make the life feed from the Dahua webcam available within Home Assistant we use the Dahua integration. This integration needs to be used for every Dahua webcam you want to add to Home Assistant.

  1. Within Home Assistant go to Settings and click the “Add integration” button. In the search field enter dahua.
  2. Enter the webcam connection details and click the submit button.
  3. The Dahua integration will show the added webcam(s).

    For our camera 3 entities have been added for the live feeds; the main stream and 2 substreams.Additionally several other entities for the camera have been added depending on the selected and supported options such as motion detection, video loss, cross line alarm etc.Note: Achtertuin is Dutch for backyard.

4. Create the Dahua webcam dashboard card

Creating the Home Assistant dashboard card involves adding the webcam commands for the PZT presets switch to the configuration.yaml so these become available as a Home Assistant entity which can be executed from a button, which will be part of the custom button card.

4.1 Update configuration.yaml

  1. Open configuration.yaml in the Home Assistant file editor.
  2. For our situation the following is added:

    Syntax of the PTZ preset command:
    SHELL_COMMAND_NAME: ‘curl –digest -u “USERNAME:PASSWORD” -g “http://IP_ADDRESS:PORT/cgi-bin/ptz.cgi?action=start&channel=1&code=GotoPreset&arg1=0&arg2=PTZ_PRESET_NR&arg3=0″‘

4.2 Configure the Dahua webcam dashboard card

The Dahua webcam card is based on the Lovelace vertical stack card which contains the Dahua camera stream in a picture entity and a Lovelace grid containing custom button cards for each button setting a specific PTZ camera preset. The whole configuration of the Dahua webcam dashboard card is shown below. Adapt the yaml code to your situation.

Note:  In a later state detailed instruction will be posted how to create the dashboard card for people just starting with Home Assistant.

The custom button cards make use of the template “buttonnav”, which is as follows:

To add this template to Home Assistant select edit dashboard and select again from the menu “raw configuration editor”.  Add the template script at the top.

5. Finally

The Dahua webcam dashboard card should now look similar as shown in the introduction of this article. We are not finished with fine tuning our card, so more updates to come.

Article by <a href="https://smarthome.familykruse.eu/author/iamjwk/" target="_self">Jan-Willem</a>

Article by Jan-Willem


Writen by the website owner


Submit a Comment

Your email address will not be published. Required fields are marked *