
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) |
The template issues unauthenticated HTTP GETs. Newer Dahua firmware requires HTTP Basic or Digest authentication on every CGI call and returns a
401 UnauthorizedHTML page when credentials are missing. That HTML body does not contain the stringError:No Events, so the template would flip to permanent “motion active”. You must either allow anonymous access toeventManager.cgion 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.
The template has
UseHttps=Falsehardcoded 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.
- Log in to the camera Web UI at
http://<camera-ip>/ - Navigate to Setting → Event → Video Detection → Motion Detection
- Tick Enable and click Save
- Set the detection Area — paint the region(s) where motion should be tracked. The whole frame is active by default.
- 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.
- Configure Period (arming schedule) to cover the hours you want TapHome to react to motion (typically 24/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
VideoMotionevent - No motion — the camera responds with
Error:No Events
The state is derived from a one-second polling script:
| |
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 PIR logic 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:
- HTTP authentication is enforced on the camera. The template’s unauthenticated request is answered with a
401 UnauthorizedHTML page. Because that page does not contain the literal stringError:No Events, the template reads it as “motion active”. Fix: allow anonymous access toeventManager.cgior disable authentication on the camera. - Very old firmware returns an empty body instead of
Error:No Eventswhen 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)
- Motion detection is disabled on the camera — re-check Setting → Event → Video Detection → Motion Detection → Enable
- The current time falls outside the configured Period (arming schedule)
- The detection Area does not cover the part of the scene where motion occurs
- Sensitivity is too low or Threshold is too high — re-tune using the live waveform in the Web UI
- The camera is in its Anti-dither back-off window from the previous event
No response / timeout
- Verify the camera is reachable:
ping <camera-ip>and openhttp://<camera-ip>/in a browser - Confirm HTTP on port 80 is enabled under Setting → Network → Port
- Confirm HTTPS is disabled (or not forced) under Setting → Network → HTTPS
- Check that the TapHome CCU and the camera are on the same subnet / VLAN