---
title: "Dahua Camera — Motion Sensor"
description: "Use any Dahua IP camera as a motion sensor in TapHome: HTTP polling of the eventManager CGI for VideoMotion. Set Anti-dither to 1–5 s for a short back-off."
url: "https://taphome.com/en/compatibility/dahua-camera-motion-sensor/"
language: en
lastmod: 2026-10-08
generator: hugo
ai:
  topics: ["iot-integration","sensor","motion-sensor","video-surveillance","ip-camera","dahua","http"]
  questions: ["How to use a Dahua IP camera as a motion sensor in TapHome?","What Dahua camera models are compatible with the TapHome motion sensor template?","Why does my Dahua camera always report motion in TapHome?","How to enable motion detection on a Dahua camera for TapHome?","Does the TapHome Dahua template support Smart Motion Detection (human/vehicle)?","How does TapHome authenticate against the Dahua HTTP API?"]
---

# Dahua Camera — Motion Sensor

Communication: Packet Parser → HTTP

- [Dahua HTTP API for IPC (v1.40)](https://wiki.dno-it.ru/wp-content/uploads/2023/06/dahua_http_api_for_ipcsd-v1.40.pdf)
- [Dahua Network Camera Web 3.0 Operation Manual](https://material.dahuasecurity.com/uploads/cpq/DOR/PUM0003428/Dahua-Network-Camera-Web-3.0_OperationManual_V2.1.5.pdf)
- [rroller/dahua — Home Assistant integration](https://github.com/rroller/dahua)

## Integration guide

Dahua Technology manufactures one of the largest ranges of IP surveillance cameras on the market. Every Dahua IPC, PTZ and thermal camera with motion detection exposes an HTTP CGI endpoint that reports the current motion state — TapHome uses this endpoint to turn any Dahua camera into a binary motion sensor that can drive scenes, recordings or notifications.

The template polls a single CGI endpoint every second and maps the response to a reed-contact device: motion active or no motion. No additional hardware, cloud account or RTSP stream is required — TapHome and the camera communicate directly on the local network over plain HTTP.

## Configuration

### Network

The template talks to the camera on **TCP port 80** using unencrypted HTTP. During template import in TapHome, enter the camera's IP address (a DHCP reservation or static IP is recommended — Dahua cameras do not publish a stable mDNS hostname).

| Parameter | Value |
|-----------|-------|
| Protocol | HTTP (port 80) |
| Poll interval | 1000 ms |
| Endpoint | `/cgi-bin/eventManager.cgi?action=getEventIndexes&code=VideoMotion` |
| Authentication | None (see note below) |

> [!WARNING]
> The template issues **unauthenticated** HTTP GETs. Newer Dahua firmware requires HTTP Basic or Digest authentication on every CGI call and returns a `401 Unauthorized` HTML page when credentials are missing. That HTML body does **not** contain the string `Error:No Events`, so the template would flip to permanent "motion active". You must either allow anonymous access to `eventManager.cgi` on the camera, or disable HTTP authentication in the camera's security settings. If your environment requires authenticated access, place a local reverse-proxy in front of the camera that injects the credentials.

> [!WARNING]
> The template has `UseHttps=False` hardcoded and uses port 80. HTTPS-only firmware is **not** supported. If your camera forces HTTPS, disable it under **Setting → Network → HTTPS** in the Web UI.

### Enabling motion detection on the camera

For `getEventIndexes&code=VideoMotion` to return an active state, motion detection must be explicitly enabled on the camera. Factory default on many Dahua models is **disabled**.

1. Log in to the camera Web UI at `http://<camera-ip>/`
2. Navigate to **Setting → Event → Video Detection → Motion Detection**
3. Tick **Enable** and click **Save**
4. Set the detection **Area** — paint the region(s) where motion should be tracked. The whole frame is active by default.
5. Tune **Sensitivity** (0–100, higher = easier to trigger) and **Threshold** (0–100, lower = easier to trigger) using the live waveform. Red = motion detected, green = no motion.
6. Configure **Period** (arming schedule) to cover the hours you want TapHome to react to motion (typically 24/7).
7. Set **Anti-dither** to 1–5 s if you want a short back-off between consecutive events.

The camera must also have a user account with **Operator** or higher permissions available (required for reading `eventManager.cgi` when authentication is enforced).

## Device capabilities

### Motion state

The template exposes a single reed-contact device that reflects the current motion state of the camera:

- **Motion** — the camera currently reports an active `VideoMotion` event
- **No motion** — the camera responds with `Error:No Events`

The state is derived from a one-second polling script:

```taphome
var VideoMotionEvent := SENDHTTPREQUEST("/cgi-bin/eventManager.cgi?action=getEventIndexes&code=VideoMotion");
return(INDEXOF(VideoMotionEvent.Content, "Error:No Events") = -1);
```

When motion ends, the camera holds the event active for `EventHandler.Delay` seconds (default **30 s**) before reporting `Error:No Events`. The TapHome sensor therefore stays triggered up to 30 seconds after the last motion, even if the camera's motion detection has already released. Lower the `Delay` value in the camera's event configuration for a shorter dwell time.

The TapHome sensor uses the standard i18n labels `Motion` (active) and `No motion` (idle), consistent with other binary motion sensors in the system.

### Compatible models

Any Dahua IP camera that exposes the standard HTTP API v1.40 (or later) with the `eventManager.cgi` endpoint — this covers the vast majority of IPC-H, IPC-K, IPC-E, PTZ and thermal series released from 2013 onward. The template is agnostic to resolution, codec and lens — it only reads the binary event flag.

## Troubleshooting

### Sensor is permanently ON (always shows motion)

This is the most common issue and has two typical root causes:

1. **HTTP authentication is enforced on the camera.** The template's unauthenticated request is answered with a `401 Unauthorized` HTML page. Because that page does not contain the literal string `Error:No Events`, the template reads it as "motion active". Fix: allow anonymous access to `eventManager.cgi` or disable authentication on the camera.
2. **Very old firmware returns an empty body instead of `Error:No Events` when idle.** An empty string does not contain the sentinel either, so the template reports motion continuously. Fix: update camera firmware to a version that returns the proper idle message.

Open `http://<camera-ip>/cgi-bin/eventManager.cgi?action=getEventIndexes&code=VideoMotion` in a browser and inspect the raw response. A healthy idle response is a plain-text body containing `Error:No Events`.

### Sensor is permanently OFF (never shows motion)

1. Motion detection is disabled on the camera — re-check **Setting → Event → Video Detection → Motion Detection → Enable**
2. The current time falls outside the configured **Period** (arming schedule)
3. The detection **Area** does not cover the part of the scene where motion occurs
4. **Sensitivity** is too low or **Threshold** is too high — re-tune using the live waveform in the Web UI
5. The camera is in its **Anti-dither** back-off window from the previous event

### No response / timeout

1. Verify the camera is reachable: `ping <camera-ip>` and open `http://<camera-ip>/` in a browser
2. Confirm HTTP on port 80 is enabled under **Setting → Network → Port**
3. Confirm HTTPS is disabled (or not forced) under **Setting → Network → HTTPS**
4. Check that the TapHome CCU and the camera are on the same subnet / VLAN

## Available devices 1

These devices appear in TapHome after import.

Dahua Camera Module

Motion Sensor Reed Contact Read-only

Binary motion state derived from the VideoMotion event stream — reports Motion when the camera has an active event, No motion when the endpoint returns 'Error:No Events'

boolean text\_contains

Read

```taphome
var VideoMotionEvent := SENDHTTPREQUEST("/cgi-bin/eventManager.cgi?action=getEventIndexes&code=VideoMotion");

return(INDEXOF(VideoMotionEvent.Content, "Error:No Events") = -1);
```

Possible improvements (10)

- Realtime motion push (Attach stream) — Long-lived multipart HTTP stream pushing Start/Stop events without polling. Would lower latency and bandwidth, but needs a streaming parser.
- Smart motion — human detection — AI-filtered event that only triggers on humans; reduces false positives from rain, insects, shadows.
- Smart motion — vehicle detection — AI-filtered event that only triggers on vehicles (cars, bikes, trucks).
- Tripwire (line crossing) — Triggers when an object crosses a user-defined line — useful for directional detection.
- Intrusion (region entry) — Triggers when an object enters or leaves a user-defined polygon region.
- Camera local alarm input — State of the camera's on-board alarm input terminal (dry contact). Not exposed by this template.
- Video loss — Useful as a diagnostic — indicates the camera sensor has lost the video signal.
- Snapshot capture — Returns a JPEG still image — could be wired to an action trigger, but out of scope for a binary sensor template.
- HTTP authentication — Template issues unauthenticated GETs. User must disable auth on the camera or allow anonymous access to eventManager.cgi — otherwise a 401 HTML body can be misread as permanent motion.
- HTTPS transport — Template has UseHttps=False hardcoded and uses port 80. HTTPS-only firmware is not supported.

## Sources

- Dahua HTTP API for IPC — Version 1.40
  
  [wiki.dno-it.ru](https://wiki.dno-it.ru/wp-content/uploads/2023/06/dahua_http_api_for_ipcsd-v1.40.pdf) 2026-04-15
  
  [PDF](https://taphome.com/compatibility/devices/dahua-camera-motion-sensor/manufacturer/dahua-http-api-v1.40.pdf)
- Dahua Network Camera Web 3.0 — Operation Manual V2.1.5
  
  [material.dahuasecurity.com](https://material.dahuasecurity.com/uploads/cpq/DOR/PUM0003428/Dahua-Network-Camera-Web-3.0_OperationManual_V2.1.5.pdf) 2026-04-15
  
  [PDF](https://taphome.com/compatibility/devices/dahua-camera-motion-sensor/manufacturer/network-camera-web-3.0-operation-manual.pdf)
- rroller/dahua — Home Assistant integration
  
  [github.com](https://github.com/rroller/dahua) 2026-04-15
- Dahua Technology — company overview (Wikipedia)
  
  [en.wikipedia.org](https://en.wikipedia.org/wiki/Dahua_Technology) 2026-04-15

Manufacturer documents are © their respective owners. They are provided as published by the manufacturer, for reference only.

## Related Documentation

- [Packet Parser Integration](https://taphome.com/en/compatibility/packet-parser-guide/)
- [Packet Parser (HTTP, TCP, UDP, FTP, MQTT)](https://taphome.com/en/docs/integration/packet-parser/)
- [Packet parser functions](https://taphome.com/en/docs/script/packet-parser/)
- [Parsing functions](https://taphome.com/en/docs/script/parsing-functions/)

