The Dahua Home Assistant integration allows you to integrate your Dahua cameras in Home Assistant.
Supports motion events, alarm events (and others), enabling/disabling motion detection, switches for infrared, illuminator (white light), security lights (red/blue flashers), and sirens.
NOTE: Using the switch to turn on/off the infrared light will disable the "auto" mode. Use the service to enable auto mode again (or the camera UI).
If you want live streaming, make usre to add the following to your config.yaml:
ffmpeg:
stream:
To install with HACS:
- Click on HACS in the Home Assistant menu
- Click on
Integrations - Click the
EXPLORE & ADD REPOSITORIESbutton - Search for
Dahua - Click the
INSTALL THIS REPOSITORY IN HACSbutton - Restart Home Assistant
- Configure the camera by going to
Configurations->Integrations->ADD INTERATIONSbutton, search forDahuaand configure the camera.
To manually install:
# Download a copy of this repository
$ wget https://github.com/rroller/dahua/archive/dahua-main.zip
# Unzip the archive
$ unzip dahua-main.zip
# Move the dahua directory into your custom_components directory in your Home Assistant install
$ mv dahua-main/custom_components/dahua <home-assistant-install-directory>/config/custom_components/
⚠️ After executing one of the above installation methods, restart Home Assistant. Also clear your browser cache before proceeding to the next step, as the integration may not be visible otherwise.
- Now the integration is added to HACS and available in the normal HA integration installation, so...
- In the HA left menu, click
Configuration - Click
Integrations - Click
ADD INTEGRATION - Type
Dahuaand select it - Enter the details:
- Username: Your camera's username
- Password: Your camera's password
- Address: Your camera's address, typically just the IP address
- Port: Your camera's HTTP port. Default is
80 - RTSP Port: Your camera's RTSP port, default is
554. Used to live stream your camera in HA - RTSP Streams: The RTSP stream you want to use (Main, Sub, or Both). If both, two camera entities will be created
- Events: The integration will keep a connection open to the camera to capture motion events, alarm events, etc. You can select which events you want to monitor and report in HA. If no events are selected then the connection will no be created. If you want a specific event that's not listed here open an issue and I'll add it.
This integration should word with most Dahua cameras. It has been tested with very old and very new Dahua cameras. The following are confirmed to work:
- IPC-HDW5831R-ZE
- IPC-T5442T-ZE
- IPC-HDW2831T-ZS-S2
- IPC-HDW3849HP-AS-PV
- IPC-HFW1435S-W
- IPC-HFW1435S-W-S2
- IPC-A26
- IPC-HDW4233C-A
- Please let me know if you've tested with additional cameras
| Service | Parameters | Description |
|---|---|---|
camera.enable_motion_detection |
Enables motion detection | |
camera.disable_motion_detection |
Disabled motion detection | |
dahua.set_infrared_mode |
entity_id: camera.cam13_main mode: Auto, On, Off brightness: 0 - 100 inclusive |
Sets the infrared mode. Useful to set the mode back to Auto |
dahua.set_video_profile_mode |
entity_id: camera.cam13_main mode: Day, Night |
Sets the video profile mode to day or night |
This will provide a normal HA camera entity (can take snapshots, etc)
| Switch | Description |
|---|---|
| Motion | Enables or disables motion detection on the camera |
| Siren | If the camera has a siren, will turn on the siren. Note, it seems sirens only stay on for 10 to 15 seconds before switching off |
| Disarming Linkage | Newer firmwares have a "disarming" feature (not sure what it is, but some people use it). This allows one to turn it on/off. This is found in the UI by going to Event -> Disarming |
| Light | Description |
|---|---|
| Infrared | Turns on/off the infrared light. Using this switch will disable the "auto" mode. If you want to enable auto mode again then use the service to enable auto. When in auto, this switch will not report the on/off state. |
| Illuminator | If the camera has one, turns on/off the illuminator light (white light). Using this switch will disable the "auto" mode. If you want to enable auto mode again then use the service to enable auto. When in auto, this switch will not report the on/off state. |
| Security | If the camera has one, turns on/off the security light (red/blue flashing light). This light stays on for 10 to 15 seconds before the camera auto turns it off. |
| Sensor | Description |
|---|---|
| Motion | A sensor that turns on when the camera detects motion |
If you wish to work on this component, the easiest way is to follow HACS Dev Container README. In short:
- Install Docker
- Install Visual Studio Code
- Install the devcontainer Visual Code plugin
- Clone this repo and open it in Visual Studio Code
- View -> Command Palette. Type
Tasks: Run Taskand select it, then clickRun Home Assistant on port 9123 - Open Home Assistant at http://localhost:9123
Add to your configuration.yaml:
logger:
default: info
logs:
custom_components.dahua: debug