Enable/Disable Dahua Motion Detect via API using Shell_Command

Tags: #<Tag:0x00007f73ad1255c0>

I have a Dahua SD22204T which has a certain ONVIF support from HA. Unfortunately the ‘camera.enable_motion_detection’ and ‘camera.dusable_motion_detection’ are not working, running Home Assistant 0.110.4. This is a pity since the Dahua firmware does not support sunset triggers for enabling and disabling motion detect and when it gets dark it is too unreliable in the daylight settings.

So… I found this API reference and was happy to see that the calls below work perfectly fine. So I’ve put them in a shell command for now.

dahua_motion_enable: curl -g --anyauth –u <uid>:<pwd> 'http://<ip/dns>/cgi-bin/configManager.cgi?action=setConfig&MotionDetect[0].Enable=true'
dahua_motion_enable: curl -g --anyauth –u <uid>:<pwd> 'http://<ip/dns>/cgi-bin/configManager.cgi?action=setConfig&MotionDetect[0].Enable=false

My reason for share this is to help others.

P.s. Of course it would be create to have this “fixed” and maybe additional functionality was added, but I just don’t have the tools, time and knowledge to do this by myself. So this is my solution for now and maybe it inspires others to solve issues using Shell_Command

edit: fixed the API reference link

By the way, if someone has a (nice) way of getting the result (when successful an OK) back to HA, then I’d be interested. Perhaps not specifically for these commands, but in general.

You might consider using the amcrest integration. I’m told it works with Dahua cameras as well (and implements the services for enabling & disabling motion detection.)

I can confirm. Thanks for the tip! I’ll switch from ONVIF to amcrest cause it offers more features than ONVIF for my cam. It however doesn’t offer a full enable/disable motion detection, which by itself is fine.
It offers the option to Disable/Enable recording on motion detect, but lacks the option to enable/disable snapshots or email on motion.
amcrest
So I am afraid I still need my API commands, but will make it handle the missing options instead of fully enable/disable motion detect.

Those services are already defined in the camera domain & are supported by the amcrest integration: camera.enable_motion_detection & camera.disable_motion_detection. The services in the amcrest domain are above & beyond what the camera component defines.

They didn’t work when I first tried them, so I thought they where incompatible with my cam.
I did a check just yet and can confirm it works. Looking back, the problem of not working probably lay in the ONVIF only account I created for Home Assistant. That account probably didn’t had the correct privileges to disable and enable motion detect.

Thanks a lot!