Amcrest ASH26-W Floodlight Camera Light and Siren Control

I purchased and installed several Amcrest ASH26-W Floodlight Cameras and successfully incorporated into Home Assistant with generic camera and the Dahua integration in HACS. The issue I’m having is that when the light control is set to motion activated, the switch just briefly flashes the light on. There is also no option to control the siren.

After a lot of poking around I discovered a option that allow me to use a url to access these features: (https://github.com/rroller/dahua/issues/341#issuecomment-1999004949)

I set these up in my rest commands file (user id, pw and IP changed here). I can call these in a script but I get an error:

Scipt:

side_floodlight_on:
  sequence:
    - service: rest_command.side_floodlight_on

rest_commands.yaml code:

side_floodlight_on:
    url: "http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"
  side_floodlight_off:
    url: "http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=0"

  side_floodlight_siren_on:
    url: "http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=2&info[0].IO=1"
  side_floodlight_siren_off:
    url: "http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=2&info[0].IO=2"

If I put the url directly into chrome, I get an ok response and the desired action occurs. It seems like the user id and pw is not being passed along when included in the url. I tried to play around with other rest options with the same result:

  side_floodlight_on_test:
    username: "user"
    password: "password"
    url: "http://192.168.1.xxx/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"
    method: POST
    verify_ssl: false

It seems like since the url works, I’m having an issue with how to set up the rest command. I’m posing this to hopefully get this resolved but also to help others using this same unit out. I like to be able to control everything in Home Assistant and not having to go into a bunch of other apps.

You have method as POST but the GitHub link says they are GET

1 Like

Good point but still I get the same error with GET or POST. I’d also think that since I’m sending data and not retreiving data POST would be correct. 401 Error makes me think there is something wrong with the authentication when using REST even though the url works directly.

Not sure. sometimes api is an endpoint that does action on connection

try below

side_floodlight_on:
    url: "http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"
    method: GET
    username: "[user]"
    password: "[password]"

EDIT
I forgot your tried above with post. did you also test it with get? do you get same error with both?

I tried both GET and POST and get the exact same error 401 with both.

You’re trying to use Basic Auth and the API does not support that. You want to use Digest Auth which is slightly more involved but it looks like Home Assistant makes it easy.

This getstatus API is not working for me. Getting 400 / Bad Request.
/cgi-bin/coaxialControlIO.cgi?action=getstatus

But these seem to work
Light on:
/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1
Light off:
/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=0

Siren on:
/cgi-bin/coaxialControlIO.cgiaction=control&channel=1&info[0].Type=2&info[0].IO=1
Siren off:
/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=2&info[0].IO=2
(IO=2 is the correct string to turn off the siren.)

EDIT: The method is GET btw for all API requests. Not POST

I started writing this and forgot to hit post 2 weeks ago:

Ok, after a bunch of github searching, I finally got something that works. I ended up having to use a shell command, which is not ideal as it requires restarts after each change to test. Maybe there’s a way to get this to work in REST?

Working:

shell_command:
  tahoe_side_floodlight_on: /usr/bin/curl  --globoff -s --digest -u user:password "http://192.168.1.xxx/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"
  tahoe_side_floodlight_off: /usr/bin/curl  --globoff -s --digest -u user:password "http://192.168.1.xxx/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=0"
  tahoe_side_siren_on: /usr/bin/curl  --globoff -s --digest -u user:password "http://192.168.1.xxx/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=2&info[0].IO=1"
  tahoe_side_siren_off: /usr/bin/curl  --globoff -s --digest -u user:password "http://192.168.1.xxx/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=2&info[0].IO=2"

Next step will be to get the user id and password into secrets but I didn’t want to have too many variables going at this point.

Also, here are some things I tried that DIDN’T work in case it helps others:

Returned Code 3: “curl: (3) bad range in URL position 102” which is the first bracket. &info**[0]**

tahoe_side_floodlight_test1: /usr/bin/curl -s --digest user:password "http://192.168.1.xxx/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"
tahoe_side_floodlight_test2: /usr/bin/curl -s --digest -u user:password "http://192.168.1.xxx/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"
tahoe_side_floodlight_test4: /usr/bin/curl -X POST "http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"
tahoe_side_floodlight_test5: /usr/bin/curl -k "http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"
tahoe_side_floodlight_test7: /usr/bin/curl -X GET "http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"

This gave curl: (2) no URL specified:

tahoe_side_floodlight_test6: /usr/bin/curl -u  "http://user:[email protected]/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1"

Yes, there is. You don’t have to use a shell script. Did you look at the link I posted earlier?

EDIT

Here are some examples

rest_command:
  front_door_light_on:
    url: !secret amcrest_front_door_light_on_url
    method: get
    authentication: digest
    username: !secret amcrest_front_door_username
    password: !secret amcrest_front_door_password
  front_door_light_off:
    url: !secret amcrest_front_door_light_off_url
    method: get
    authentication: digest
    username: !secret amcrest_front_door_username
    password: !secret amcrest_front_door_password
  front_door_siren_on:
    url: !secret amcrest_front_door_siren_on_url
    method: get
    authentication: digest
    username: !secret amcrest_front_door_username
    password: !secret amcrest_front_door_password
  front_door_siren_off:
    url: !secret amcrest_front_door_siren_off_url
    method: get
    authentication: digest
    username: !secret amcrest_front_door_username
    password: !secret amcrest_front_door_password

In my secrets.yaml I have

amcrest_front_door_light_on_url: http://x.x.x.x/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=1
amcrest_front_door_light_off_url: http://x.x.x.x/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=1&info[0].IO=0
amcrest_front_door_siren_on_url: http://x.x.x.x/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=2&info[0].IO=1
amcrest_front_door_siren_off_url: http://x.x.x.x/cgi-bin/coaxialControlIO.cgi?action=control&channel=1&info[0].Type=2&info[0].IO=2
amcrest_front_door_username: admin
amcrest_front_door_password: MySuperS3cretPassw0rd