While there is an incredibly useful integration for Dahua cameras available through HACS, its trigger options are limited to any zone being activated. For true control over your smart home security, it’s essential to implement zone-specific automations. This granular approach provides significant benefits, such as:
Customizable Alerts: Gain the flexibility to disable notifications for high-traffic zones while maintaining crucial alerts for others.
Targeted Responses: Design your smart home to react differently depending on the scenario—for example, automatically opening the garage door when a vehicle is detected, versus immediately triggering an alarm if someone attempts to climb your fence.
Of course, this method only works if your specific camera model supports webhooks.
Home Assistant configuration
Since installing my Dahua camera, I’ve been trying to get webhooks to work—initially with zero success. The frustrating part? There were no errors in the Home Assistant logs, and a tcpdump confirmed the camera was hitting the HA socket perfectly. After struggling for half a day, I finally uncovered the root cause. It turns out the Dahua camera sends request headers with specific attributes that HA was silently rejecting:
CONNECTION: Keep-Alive
Content-Encoding: deflate
Content-Type: application/json
Host: xx.xx.xx.xx
CONTENT-LENGTH: 0 HA uses aiohttp as its web server. When aiohttp sees Content-Encoding: deflate, it tries to decompress the body. But the body is empty — 0 bytes. The decompression fails, aiohttp rejects the request internally before it ever reaches the webhook handler, and nothing gets logged.
Unfortunately, the camera doesn’t offer any internal settings to modify these headers, so we’ll need to use a proxy server to “clean” them before they reach Home Assistant. Let’s dive in and get our Nginx proxy ready.
NGINX reverse-proxy
I already use an Nginx proxy to manage my Home Assistant access: SSL is enabled for my mobile companion apps, while a non-SSL path remains open for integrations like webhooks that don’t support encryption. Since I run a Home Assistant Docker setup, I use a standalone Nginx service on the same host. I’m not entirely sure if the HAOS Reverse Proxy add-on supports this specific header-stripping functionality, but it works perfectly in a standalone environment.
Note: If you don’t have a proxy set up yet, follow this guide to install an Nginx reverse proxy from scratch.
First, we’ll need to create a new configuration file. Let’s create and open it using your preferred text editor (such as mcedit or nano):
sudo touch /etc/nginx/sites-available/dahua_proxy
sudo mcedit /etc/nginx/sites-available/dahua_proxy Add the following configuration if your HA is accessible WITHOUT SSL:
server {
listen 8121;
location /api/webhook/ {
proxy_pass http://YOUR_HA_IP:PORT;
proxy_set_header Host $host:PORT;
proxy_set_header Content-Encoding "";
}
} Add the following configuration if your HA is accessible WITH SSL:
server {
listen 8121;
location /api/webhook/ {
proxy_pass https://YOUR_HA_IP:PORT;
proxy_ssl_verify off;
proxy_set_header Host $host:PORT;
proxy_set_header Content-Encoding "";
}
} ⚠️ Explanation:
Check if 8121 port is available with the following command, and choose any other available port if 8121 alredy used.
ss -nlp | grep 8121 Replace YOUR_HA_IP:PORT with your actual HA IP address and HTTP or HTTPS port.
Pay your attention to using PORT in two config directives!
Save your config, activate it, and restart your nginx server:
sudo ln -s /etc/nginx/sites-available/dahua_proxy /etc/nginx/sites-enabled/dahua_proxy
sudo systemctl restart nginx Create HA Automation
⚠️ HACS Dahua integration must be configured for the following steps!
Next, let’s create the automation and its corresponding webhook:
Navigate to Settings → Automations & Scenes, and click Create Automation.
Click Add Trigger and select Webhook from the list.
Home Assistant will then provide you with an auto-generated Webhook ID.
- Click “+ Add Action” and choose “Take Camera snapshot”.
- Add your camera main stream as a target.
- Define a file name for a snapshot.
- Check if “/config/www/” is accessible for HA using the fileeditor plugin or run the following command, replacing “ha” with your Home Assistant container name:
sudo docker exec ha ls -la /config/www/ - Click “+ Add Action” and choose “Wait for time to pass (delay)” and set a 1-second delay to be sure that a snapshot is saved before the next step.
- Click “+ Add Action” and choose “Send a notification via YOUR MOBILE PHONE NAME” to send a notification.
- Define a title and a message of your notification and add your snapshot as a data.
Camera configuration
The last step is your camera configuration:
- Open your camera’s web-inteface, navigate to “Server config” section, and add your nginx proxy server IP and port:
- Navigate to AI section, activate “AcuPick” and “IVS” functions, click “next” button.
- Add your new rule e.g. “Intrusion” and configure it with your webhook command:
Nowadays, Dahua cameras have a pretty complicated interface, so let’s check with HA integration if “Smart Motion Detection” is activated:
- Navigate to Settings → Devices & Services, find your Dahua integration, and click on it.
- Click on your camera and check the service:
Now, step in front of your camera to trigger the zone and verify that your webhook integration is working!


