Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control light on the ASH26-W? #161

Open
poblabs opened this issue Sep 16, 2020 · 61 comments
Open

Control light on the ASH26-W? #161

poblabs opened this issue Sep 16, 2020 · 61 comments

Comments

@poblabs
Copy link

poblabs commented Sep 16, 2020

Is it possible to control the light on the new ASH26-W? That would be great if it could be added. Happy to help test anything, too

@DanPatten
Copy link

I am looking to do this too myself, still have not cracked it. Does anyone know the command to control the light?

@poblabs
Copy link
Author

poblabs commented Nov 2, 2020 via email

@DanPatten
Copy link

It looks like the config values do not sync with the smart home app but they do update when you query this point, I am unsure if this is right or not.

http://IP/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2

The value you are looking for is table.Lighting_V2[0][0][1].Mode=
Off = off
Manual = on

@poblabs
Copy link
Author

poblabs commented Nov 2, 2020

In my testing it seems that this only makes the light flash quickly, then turns off. Haven't been able to keep the lights on.

@DanPatten
Copy link

I have my Floodlight setting set to manual, so maybe set that and try it? I am on the latest firmware too.

@poblabs
Copy link
Author

poblabs commented Nov 2, 2020

I'm on the latest firmware too, and using this endpoint seemed to work to turn it on, but not off using Auto. I had to use the app to turn it off

http://ip/cgi-bin/configManager.cgi?action=setConfig&Lighting[0][0][0].Mode=Manual

@DanPatten
Copy link

DanPatten commented Nov 2, 2020

Use http://ip/cgi-bin/configManager.cgi?action=setConfig&Lighting[0][0][0].Mode=Off to turn it off. Maybe your light index is different than mine but mine is [0][0][1]

@poblabs
Copy link
Author

poblabs commented Nov 2, 2020

Now it's not working to turn it back on 😄 Neither the Lighting nor the Lighting_V2 endpoint. I wonder what's changed. I'll keep looking around. Where were you able to find the Lighting_V2 endpoint? Is there another one I wonder?

@DanPatten
Copy link

I did some crazy stuff with RDP since amcrest cameras are basically dahua cameras at their base and dug around there. You can view the entire config to see everything

http://IP/cgi-bin/configManager.cgi?action=getConfig&name=All

@poblabs
Copy link
Author

poblabs commented Nov 2, 2020

Yeah not much else to see I guess. I tried a wireshark capture, and can see my phone viewing the stream from AWS, but when I press the light button it's not an HTTP command (looks like TCP?) and there's not much else I can gain from that.

@poblabs
Copy link
Author

poblabs commented Nov 2, 2020

In the all config page, do you have this setting as false too?

table.All.LightGlobal[0].Enable=false

@DanPatten
Copy link

That setting is true for me

@poblabs
Copy link
Author

poblabs commented Nov 7, 2020

How did you set that to true? I wonder if that's why I'm not allowed to control the light?

@DanPatten
Copy link

Take a look at the supporting doc:
https://support.amcrest.com/hc/en-us/articles/360002007371-Amcrest-HTTP-API-SDK

I can't remember exactly but its setConfig I think

@poblabs
Copy link
Author

poblabs commented Nov 8, 2020

I was able to set it to true, but still can't get the light to turn on. Not sure what I'm missing.

@DanPatten
Copy link

This is my Lighting V2 Config (light is off atm)

table.Lighting_V2[0][0][0].Correction=50
table.Lighting_V2[0][0][0].LightType=InfraredLight
table.Lighting_V2[0][0][0].MiddleLight[0].Angle=50
table.Lighting_V2[0][0][0].MiddleLight[0].Light=50
table.Lighting_V2[0][0][0].Mode=Auto
table.Lighting_V2[0][0][0].Sensitive=3
table.Lighting_V2[0][0][1].Correction=50
table.Lighting_V2[0][0][1].LightType=WhiteLight
table.Lighting_V2[0][0][1].Mode=Off
table.Lighting_V2[0][0][1].NearLight[0].Angle=50
table.Lighting_V2[0][0][1].NearLight[0].Light=50
table.Lighting_V2[0][0][1].Sensitive=3
table.Lighting_V2[0][1][0].Correction=50
table.Lighting_V2[0][1][0].LightType=InfraredLight
table.Lighting_V2[0][1][0].MiddleLight[0].Angle=50
table.Lighting_V2[0][1][0].MiddleLight[0].Light=50
table.Lighting_V2[0][1][0].Mode=Auto
table.Lighting_V2[0][1][0].Sensitive=3
table.Lighting_V2[0][1][1].Correction=50
table.Lighting_V2[0][1][1].LightType=WhiteLight
table.Lighting_V2[0][1][1].Mode=Off
table.Lighting_V2[0][1][1].NearLight[0].Angle=50
table.Lighting_V2[0][1][1].NearLight[0].Light=50
table.Lighting_V2[0][1][1].Sensitive=3
table.Lighting_V2[0][2][0].Correction=50
table.Lighting_V2[0][2][0].LightType=InfraredLight
table.Lighting_V2[0][2][0].MiddleLight[0].Angle=50
table.Lighting_V2[0][2][0].MiddleLight[0].Light=50
table.Lighting_V2[0][2][0].Mode=Auto
table.Lighting_V2[0][2][0].Sensitive=3
table.Lighting_V2[0][2][1].Correction=50
table.Lighting_V2[0][2][1].LightType=WhiteLight
table.Lighting_V2[0][2][1].Mode=Off
table.Lighting_V2[0][2][1].NearLight[0].Angle=50
table.Lighting_V2[0][2][1].NearLight[0].Light=50
table.Lighting_V2[0][2][1].Sensitive=3

Also have:
table.All.LightGlobal[0].Enable=true

For floodlight settings I have the light set to manual

@poblabs
Copy link
Author

poblabs commented Nov 8, 2020

For floodlight settings I have the light set to manual

That did it. I had my floodlight setting in the app set to motion. Changing that to manual seems to have done it. Wish I could have motion controlled, and manual API override together

@mcowger
Copy link

mcowger commented Jan 6, 2021

For anyone that is searching for this too, here's an example I wrote for home assistant that might help:

  - platform: command_line
    switches:
      garage_floodlight:
        command_on:    '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][1].Mode=Manual" '
        command_off:   '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][1].Mode=Off" '
        command_state: '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2[0][0][1].Mode" | grep -oc "Manual" ||true'
        value_template: '{{ value == "1" }}'
        friendly_name: Garage Floodlight

@anonymous-one
Copy link

Thank you so much for posting this!

I was searching to see if the light could be turned on / off locally before I pulled the trigger and ordered one of these to replace the floodlight in our garden.

Looks like its a go!

THANKS!!!

@anonymous-one
Copy link

For floodlight settings I have the light set to manual

That did it. I had my floodlight setting in the app set to motion. Changing that to manual seems to have done it. Wish I could have motion controlled, and manual API override together

Just a thought... Since you are looking to locally flip the light on / off I am going to assume you are feeding the video into your own NVR instead of using their cloud (yuck...) or the sd card (double yuck...)...

Why not just have your NVR trigger on motion detect and flip the light accordingly.

That is how I am planning on doing it anyways.

@haydonryan
Copy link

haydonryan commented Sep 25, 2021

For anyone that is searching for this too, here's an example I wrote for home assistant that might help:

  - platform: command_line
    switches:
      garage_floodlight:
        command_on:    '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][1].Mode=Manual" '
        command_off:   '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][1].Mode=Off" '
        command_state: '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2[0][0][1].Mode" | grep -oc "Manual" ||true'
        value_template: '{{ value == "1" }}'
        friendly_name: Garage Floodlight

Thankyou so much for posting this. One question - do I paste this into a light section of the configuration.yaml?

@flacjacket
Copy link
Collaborator

It is a command line switch: https://www.home-assistant.io/integrations/switch.command_line/
This is something that we could look into adding upstream in home assistant as a light entity in the integration, as well.

@poblabs
Copy link
Author

poblabs commented Sep 25, 2021

Is this working reliably for you guys? I had mixed results and ended up not using it. Is there a new way now with these flood light cameras?

@haydonryan
Copy link

This is something that we could look into adding upstream in home assistant as a light entity in the integration, as well.

That would be amazing :) I would actually use the flood light quite a lot as a regular light as it's in the perfect place for lighting while putting the bins out.

@haydonryan
Copy link

haydonryan commented Nov 29, 2021

I tried this on the command line and had to escape the square brackets, plus escape all the special characters in my password (note creds and IPs are not real here).

Thanks all for your suggestions - this is now working.

PASSWORD= password?yes

switch:
  - platform: command_line
    switches:
      garage_floodlight:
        command_on:    '/usr/bin/curl -s --digest -u admin:password\?yes "http://192.168.1.1/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2\[0\]\[0\]\[1\].Mode=Manual" '
        command_off:   '/usr/bin/curl -s --digest -u admin:password\?yes "http://192.168.1.1/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2\[0\]\[0\]\[1\].Mode=Off" '
        command_state: '/usr/bin/curl -s --digest -u admin:password\?yes "http://192.168.1.1/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2\[0\]\[0\]\[1\].Mode" | grep -oc "Manual" ||true'
        value_template: '{{ value == "1" }}' 
        friendly_name: Garage Floodlight

@Darkside138
Copy link

Does anyone have this working? I can change the settings and they sometimes turn the lights on for a second but then they turn off immediately.

@al3x1337
Copy link

Does anyone have this working? I can change the settings and they sometimes turn the lights on for a second but then they turn off immediately.

As long as motion detection is turned off on the camera then the script to turn on and off the light is working for me just fine

@Darkside138
Copy link

Thanks for the quick response! That was it, need to turn off Flood Light motion detection and set the lights to manual in the Amcrest app.

@Darkside138
Copy link

Seems like I can't use this light in automations? It needs an entity_id but I can't seem to configure one, says that's not a valid configuration?

@al3x1337
Copy link

al3x1337 commented Sep 8, 2022

Can anyone confirm if this still works?
Using doing http://192.168.x.x/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][1].Mode=Off brings up a "can not connect" message now. Camera is ping-able and RSTP stream still works so i know the IP is correct.

Noticed this just this past week.

@haydonryan
Copy link

Mine still works, and I update home assistant every morning via scheduled task

@al3x1337
Copy link

Mine still works, and I update home assistant every morning via scheduled task

Even after a factory reset and trying on a different VLAN I can not get it to work. Even http://IPADDRESS/cgi-bin/snapshot.cgi does not work.

I'm considering buying another unit to test with at this point...

@sts098
Copy link

sts098 commented Oct 16, 2022

Is there a way to toggle the floodlight mode from motion activated to manual with a command like these? If so, then I should be able to use node-red to run both commands.

Did you ever figure a way to toggle the flood light mode. Like you, I hope to control light locally, but also return it to automatic on when motion occurs.

@btehan
Copy link

btehan commented Oct 16, 2022

Is there a way to toggle the floodlight mode from motion activated to manual with a command like these? If so, then I should be able to use node-red to run both commands.

Did you ever figure a way to toggle the flood light mode. Like you, I hope to control light locally, but also return it to automatic on when motion occurs.

No. :⁠-⁠\

@mschingel
Copy link

Comparing when the Motion Activated is selected. With the lights off. TO when its set to manual with the lights On

C:>fc motion_activated_light_off.txt manual_light_on.txt
Comparing files motion_activated_light_off.txt and MANUAL_LIGHT_ON.TXT
***** motion_activated_light_off.txt
table.All.Alarm[0].EventHandler.LightingLink.FilckerLightType=WhiteLight
table.All.Alarm[0].EventHandler.LightingLink.LightDuration=300
table.All.Alarm[0].EventHandler.LightingLink.LightLinkType=KeepLighting
***** MANUAL_LIGHT_ON.TXT
table.All.Alarm[0].EventHandler.LightingLink.FilckerLightType=WhiteLight
table.All.Alarm[0].EventHandler.LightingLink.LightDuration=1800
table.All.Alarm[0].EventHandler.LightingLink.LightLinkType=KeepLighting


***** motion_activated_light_off.txt
table.All.Alarm[1].EventHandler.LightingLink.FilckerLightType=WhiteLight
table.All.Alarm[1].EventHandler.LightingLink.LightDuration=300
table.All.Alarm[1].EventHandler.LightingLink.LightLinkType=KeepLighting
***** MANUAL_LIGHT_ON.TXT
table.All.Alarm[1].EventHandler.LightingLink.FilckerLightType=WhiteLight
table.All.Alarm[1].EventHandler.LightingLink.LightDuration=1800
table.All.Alarm[1].EventHandler.LightingLink.LightLinkType=KeepLighting


***** motion_activated_light_off.txt
table.All.Alarm[2].EventHandler.LightingLink.FilckerLightType=WhiteLight
table.All.Alarm[2].EventHandler.LightingLink.LightDuration=300
table.All.Alarm[2].EventHandler.LightingLink.LightLinkType=KeepLighting
***** MANUAL_LIGHT_ON.TXT
table.All.Alarm[2].EventHandler.LightingLink.FilckerLightType=WhiteLight
table.All.Alarm[2].EventHandler.LightingLink.LightDuration=1800
table.All.Alarm[2].EventHandler.LightingLink.LightLinkType=KeepLighting


***** motion_activated_light_off.txt
table.All.AlarmLighting[0][0].Attribute.Brightness=100
table.All.AlarmLighting[0][0].Enable=true
table.All.AlarmLighting[0][0].LightCondition=ByVideoStatus
***** MANUAL_LIGHT_ON.TXT
table.All.AlarmLighting[0][0].Attribute.Brightness=100
table.All.AlarmLighting[0][0].Enable=false
table.All.AlarmLighting[0][0].LightCondition=ByVideoStatus


I Dont know why I dont see Lighting V2 when the lights is on? I can when I use the Dahua Integration to turn the light on.

I believe the "AlarmLighting[0][0].Enable=false" Turns the Motion Activated to Manual mode. To then allow the Lights from Lighting V2 to stay On.

I am unable to test if AlarmLighting00 changes to Manual mode or not BC i cannot get the curl to work

@audiophonicz
Copy link

In case this helps anyone else:

I used @mcowger 's yaml to make a switch in HA (awesome of you btw). Worked great for a few months. Then it stopped.
HA switch would only turn on the IR, not the floodlights. App said floodlight was on, but wasnt. Using the App to turn it off then back on did turn on the floodlights, but HA switch still only worked the IR.

To fix it, in the Amcrest mobile app I did:
Turn light off. Open settings.
Set floodlight from Manual to Scheduled.
Edit/Opened schedule.
Closed schedule.
Set floodlight from Scheduled back to Manual.
Set timeout to No Limit.
Exit settings.

This seemed to reset whatever was confused and now the HA switch controls the floodlights again.

@mschingel
Copy link

Yes, I was hoping to change to manual and increase timeout without the use of the amcrest app

@audiophonicz
Copy link

I made it less than 3 months before my ASH26 started not turning the light on again, but this time my above fiddling didnt work. I started cataloging each button in the mobile app and then discovered the "ForceOn" flag when setting NightVision to static ON. I tried setting Lighting_V2 to "ForceOn" instead of "Manual" and it actually returned OK. Expanding on that, the API documentation I can find only mentioned Lighting[][] where the first [] is for video channel (always 0) and the second is for "configNo" 0, 1, or 2 which sets "normal", "day", and "night". I figure this is the first two values of Lighting_V2[][][], the 3rd being [0] for InfraredLight and [1] for WhiteLight. I believe InfraredLight maps to "Night Vision On|Off" in the mobile app. On mine, this value seemed to force the WhiteLight aka floodlight on as well. So I started setting all of the V2[][][].Mode to ForcedOn or Off, which in turn seems to set all of the Lighting[][].Mode to ForceOn and Off with V2. I have updated mcowger's switch commands to set everything on or everything off in one swing just in case my issue is setting the default configNo but it somehow deciding to use another. (I still only query the one address, though) We will see if this method is more reliable.

TL;DR

I stopped messing with single values and just shotgun ForceOn and Off with the below commands in place of Manual in mcowger's code:

        command_on:    '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][0].Mode=ForceOn&Lighting_V2[0][0][1].Mode=ForceOn&Lighting_V2[0][1][0].Mode=ForceOn&Lighting_V2[0][1][1].Mode=ForceOn&Lighting_V2[0][2][0].Mode=ForceOn&Lighting_V2[0][2][1].Mode=ForceOn" '
        command_off:   '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][0].Mode=Off&Lighting_V2[0][0][1].Mode=Off&Lighting_V2[0][1][0].Mode=Off&Lighting_V2[0][1][1].Mode=Off&Lighting_V2[0][2][0].Mode=Off&Lighting_V2[0][2][1].Mode=Off" '
        command_state: '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2[0][0][1].Mode" | grep -oc "ForceOn" ||true'

@mschingel
Copy link

mschingel commented Feb 5, 2023

What is floodlight mode setting? I just turned mine to manual mode in the app. Then setup automations and use Dahua HA integration.

But would try this if I could keep my setting to Motion Active and have the switch work. I prefer the near instant on when motion is detected from the camera. The HA automation has a very tiny delay.

@itkfilelor
Copy link

Comparing when the Motion Activated is selected. With the lights off. TO when its set to manual with the lights On

C:>fc motion_activated_light_off.txt manual_light_on.txt Comparing files motion_activated_light_off.txt and MANUAL_LIGHT_ON.TXT ***** motion_activated_light_off.txt table.All.Alarm[0].EventHandler.LightingLink.FilckerLightType=WhiteLight table.All.Alarm[0].EventHandler.LightingLink.LightDuration=300 table.All.Alarm[0].EventHandler.LightingLink.LightLinkType=KeepLighting ***** MANUAL_LIGHT_ON.TXT table.All.Alarm[0].EventHandler.LightingLink.FilckerLightType=WhiteLight table.All.Alarm[0].EventHandler.LightingLink.LightDuration=1800 table.All.Alarm[0].EventHandler.LightingLink.LightLinkType=KeepLighting

***** motion_activated_light_off.txt table.All.Alarm[1].EventHandler.LightingLink.FilckerLightType=WhiteLight table.All.Alarm[1].EventHandler.LightingLink.LightDuration=300 table.All.Alarm[1].EventHandler.LightingLink.LightLinkType=KeepLighting ***** MANUAL_LIGHT_ON.TXT table.All.Alarm[1].EventHandler.LightingLink.FilckerLightType=WhiteLight table.All.Alarm[1].EventHandler.LightingLink.LightDuration=1800 table.All.Alarm[1].EventHandler.LightingLink.LightLinkType=KeepLighting

***** motion_activated_light_off.txt table.All.Alarm[2].EventHandler.LightingLink.FilckerLightType=WhiteLight table.All.Alarm[2].EventHandler.LightingLink.LightDuration=300 table.All.Alarm[2].EventHandler.LightingLink.LightLinkType=KeepLighting ***** MANUAL_LIGHT_ON.TXT table.All.Alarm[2].EventHandler.LightingLink.FilckerLightType=WhiteLight table.All.Alarm[2].EventHandler.LightingLink.LightDuration=1800 table.All.Alarm[2].EventHandler.LightingLink.LightLinkType=KeepLighting

***** motion_activated_light_off.txt table.All.AlarmLighting[0][0].Attribute.Brightness=100 table.All.AlarmLighting[0][0].Enable=true table.All.AlarmLighting[0][0].LightCondition=ByVideoStatus ***** MANUAL_LIGHT_ON.TXT table.All.AlarmLighting[0][0].Attribute.Brightness=100 table.All.AlarmLighting[0][0].Enable=false table.All.AlarmLighting[0][0].LightCondition=ByVideoStatus

I Dont know why I dont see Lighting V2 when the lights is on? I can when I use the Dahua Integration to turn the light on.

I believe the "AlarmLighting[0][0].Enable=false" Turns the Motion Activated to Manual mode. To then allow the Lights from Lighting V2 to stay On.

I am unable to test if AlarmLighting00 changes to Manual mode or not BC i cannot get the curl to work

As for the cURL command did you try escaping the brackets?
instead of
AlarmLighting[0][0].LightCondition=ByVideoStatus
try
AlarmLighting\[0\]\[0\].LightCondition=ByVideoStatus

Also I am testing a way to toggle smart and manual. I never noticed the AlarmLighting table before, and I checked mine and it says ByForce as opposed to your ByVideoStatus I am wondering if that will affect the change?
Looking at the app, when I change

table.All.AlarmLighting[0][0].Enable=false
table.All.AlarmLighting[0][0].LightCondition=ByForce

to

table.All.AlarmLighting[0][0].Enable=true
table.All.AlarmLighting[0][0].LightCondition=ByVideoStatus

My app actually shows motion activated and the light sensor, which it did not before when only changing the settings in V2

@mschingel
Copy link

I think this is the way. I know from the other post you’re testing it. But having this feature we be really nice.
The ability to toggle between the modes will be nice especially to run automations to control the light directly at certain times of the day or simply let the camera to do it.

@itkfilelor
Copy link

LightCondition toggles whether or not the camera will test the amount of light in the field and determine if the flood light is neccesary.

@mschingel
Copy link

So when it’s by force it’s considered manual mode in the Amcrest app?

anyway to add a switch within integration or a curl that I can use to test in ha?

@itkfilelor
Copy link

So when it’s by force it’s considered manual mode in the Amcrest app?

anyway to add a switch within integration or a curl that I can use to test in ha?

As for the LightCondition it just means when the light is motion activated, it will always come on regardless of light levels. the cURLs would be:
Light sense:

curl -s --digest USER:PASS "http://CAM-ADDRESS/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting\[0\]\[0\].LightCondition=ByVideoStatus"

Always turn on:

curl -s --digest USER:PASS "http://CAM-ADDRESS/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting\[0\]\[0\].LightCondition=ByForce"

state:

curl -s --digest USER:PASS "http://CAM-ADDRESS/cgi-bin/configManager.cgi?action=getConfig&name=AlarmLighting\[0\]\[0\].LightCondition"

just swap Enable for LightCondition if you want to toggle motion activated with valid values of true/false

Everything is case sensitive as well.

@d0u8l3m
Copy link

d0u8l3m commented Mar 6, 2023

TL;DR

I stopped messing with single values and just shotgun ForceOn and Off with the below commands in place of Manual in mcowger's code:

        command_on:    '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][0].Mode=ForceOn&Lighting_V2[0][0][1].Mode=ForceOn&Lighting_V2[0][1][0].Mode=ForceOn&Lighting_V2[0][1][1].Mode=ForceOn&Lighting_V2[0][2][0].Mode=ForceOn&Lighting_V2[0][2][1].Mode=ForceOn" '
        command_off:   '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][0].Mode=Off&Lighting_V2[0][0][1].Mode=Off&Lighting_V2[0][1][0].Mode=Off&Lighting_V2[0][1][1].Mode=Off&Lighting_V2[0][2][0].Mode=Off&Lighting_V2[0][2][1].Mode=Off" '
        command_state: '/usr/bin/curl -s --digest -u admin:password "http://IP/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2[0][0][1].Mode" | grep -oc "ForceOn" ||true'

I recently just got 2 of these floodlights and used this configuration on both, thank you btw! They seem to work fine in motion detected mode other than being unable to turn the light back off on their own, but I have yet to fully test it, I think the default was set to 5 minutes and I didn't wait that long.

Could a command be added to switch it back to motion mode after it turns off manually? Or would it be better to just use the motion sensor entity in HA and configure it that way?

@mschingel
Copy link

mschingel commented Mar 6, 2023 via email

@drsweb
Copy link

drsweb commented May 2, 2023

From my experience in working with the ASH26, turning the light on manually definitely requires that motion detection for the floodlight be turned off first before trying to turn the light on. And, it seems those need to be done as separate sequential steps. I originally had the flashing light issue others have experienced...but this now works 100% of the time for me:

Turn off motion detection for floodlight, turn light on:

http://CAMERA-IP/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting[0][0].Enable=false&Alarm[2].EventHandler.LightingLink.LightDuration=1800

http://CAMERA-IP/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][0].Mode=Auto&Lighting_V2[0][0][1].Mode=Manual

Turn Light Off, turn motion detection for floodlight back on (5 minutes):

http://CAMERA-IP/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][1].Mode=Off&Lighting_V2[0][0][0].Mode=Auto

http://CAMERA-IP/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting[0][0].Enable=true&Alarm[2].EventHandler.LightingLink.LightDuration=300

Works great for me, like I said the trick is to make each endpoint request separately as combining them doesn't work. I run a bash script with these calls being done via curl in home assistant as a command line switch.

@jckickflip
Copy link

jckickflip commented Dec 2, 2023

@drsweb Can you share config/code for this as I am struggling to get it working. Im trying to make a switch to turn it on and off but so for the switch is just stuck off.

@haydonryan
Copy link

haydonryan commented Dec 2, 2023

I have this at the end of my configuration.yaml (redacted user/ password) and IP. It doesn't go under any other yaml keys. (running latest version of homeassistant)

command_line:    
    - switch:
        name: Garage Floodlight        
        command_on:    '/usr/bin/curl -s --digest -u username:password "http://<ip_of_camera>/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2\[0\]\[0\]\[1\].Mode=Manual" '        
        command_off:   '/usr/bin/curl -s --digest -u username:password "http://<ip_of_camera>/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2\[0\]\[0\]\[1\].Mode=Off" '        
        command_state: '/usr/bin/curl -s --digest -u username:password "http://<ip_of_camera>/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2\[0\]\[0\]\[1\].Mode" | grep -oc "Manual" ||true'        
        value_template: '{{ value == "1" }}'   

@drsweb
Copy link

drsweb commented Dec 2, 2023

@drsweb Can you share config/code for this as I am struggling to get it working. Im trying to make a switch to turn it on and off but so for the switch is just stuck off.

Here's what I use for my floodlight switches on Home Assistant, this runs on a Raspberry Pi with Raspian OS:

At end of my HA configuration.yaml:

- platform: command_line
    switches:
      back_door_floodlight:
        command_on:    '/config/scripts/floodon.sh "<IP ADDRESS OF CAMERA>"'
        command_off:    '/config/scripts/floodoff.sh "<IP ADDRESS OF CAMERA>"'
        command_state: '/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://<IP ADDRESS OF CAMERA>/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2\[0\]\[0\]\[1\].Mode" | grep -oc "Manual" || true'
        value_template: '{{ value == "1" }}'
        friendly_name: Back Door Floodlight
      garage_floodlight:
        command_on:    '/config/scripts/floodon.sh "<IP ADDRESS OF CAMERA>"'
        command_off:    '/config/scripts/floodoff.sh "<IP ADDRESS OF CAMERA>"'
        command_state: '/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://<IP ADDRESS OF CAMERA>/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2\[0\]\[0\]\[1\].Mode" | grep -oc "Manual" || true'
        value_template: '{{ value == "1" }}'
        friendly_name: Garage Floodlight

/config/scripts/floodon.sh:

#!/usr/bin/bash

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting%5B0%5D%5B0%5D.Enable=false&Alarm%5B2%5D.EventHandler.LightingLink.LightDuration=1800"

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2%5B0%5D%5B0%5D%5B0%5D.Mode=Auto&Lighting_V2%5B0%5D%5B0%5D%5B1%5D.Mode=Manual"

/config/scripts/floodoff.sh:

#!/usr/bin/bash

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2%5B0%5D%5B0%5D%5B1%5D.Mode=Off&Lighting_V2%5B0%5D%5B0%5D%5B0%5D.Mode=Auto"

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting%5B0%5D%5B0%5D.Enable=true&Alarm%5B2%5D.EventHandler.LightingLink.LightDuration=300"

@jckickflip
Copy link

jckickflip commented Dec 3, 2023

@drsweb Can you share config/code for this as I am struggling to get it working. Im trying to make a switch to turn it on and off but so for the switch is just stuck off.

Here's what I use for my floodlight switches on Home Assistant, this runs on a Raspberry Pi with Raspian OS:

At end of my HA configuration.yaml:

- platform: command_line
    switches:
      back_door_floodlight:
        command_on:    '/config/scripts/floodon.sh "<IP ADDRESS OF CAMERA>"'
        command_off:    '/config/scripts/floodoff.sh "<IP ADDRESS OF CAMERA>"'
        command_state: '/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://<IP ADDRESS OF CAMERA>/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2\[0\]\[0\]\[1\].Mode" | grep -oc "Manual" || true'
        value_template: '{{ value == "1" }}'
        friendly_name: Back Door Floodlight
      garage_floodlight:
        command_on:    '/config/scripts/floodon.sh "<IP ADDRESS OF CAMERA>"'
        command_off:    '/config/scripts/floodoff.sh "<IP ADDRESS OF CAMERA>"'
        command_state: '/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://<IP ADDRESS OF CAMERA>/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2\[0\]\[0\]\[1\].Mode" | grep -oc "Manual" || true'
        value_template: '{{ value == "1" }}'
        friendly_name: Garage Floodlight

/config/scripts/floodon.sh:

#!/usr/bin/bash

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting%5B0%5D%5B0%5D.Enable=false&Alarm%5B2%5D.EventHandler.LightingLink.LightDuration=1800"

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2%5B0%5D%5B0%5D%5B0%5D.Mode=Auto&Lighting_V2%5B0%5D%5B0%5D%5B1%5D.Mode=Manual"

/config/scripts/floodoff.sh:

#!/usr/bin/bash

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2%5B0%5D%5B0%5D%5B1%5D.Mode=Off&Lighting_V2%5B0%5D%5B0%5D%5B0%5D.Mode=Auto"

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting%5B0%5D%5B0%5D.Enable=true&Alarm%5B2%5D.EventHandler.LightingLink.LightDuration=300"

So how do the scripts know which of the lights you are turning on and off if the one script runs for either camera? also when I copy your code I get an error end of the stream or a document separator is expected (165:1)

@drsweb
Copy link

drsweb commented Dec 3, 2023

@drsweb Can you share config/code for this as I am struggling to get it working. Im trying to make a switch to turn it on and off but so for the switch is just stuck off.

Here's what I use for my floodlight switches on Home Assistant, this runs on a Raspberry Pi with Raspian OS:
At end of my HA configuration.yaml:

- platform: command_line
    switches:
      back_door_floodlight:
        command_on:    '/config/scripts/floodon.sh "<IP ADDRESS OF CAMERA>"'
        command_off:    '/config/scripts/floodoff.sh "<IP ADDRESS OF CAMERA>"'
        command_state: '/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://<IP ADDRESS OF CAMERA>/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2\[0\]\[0\]\[1\].Mode" | grep -oc "Manual" || true'
        value_template: '{{ value == "1" }}'
        friendly_name: Back Door Floodlight
      garage_floodlight:
        command_on:    '/config/scripts/floodon.sh "<IP ADDRESS OF CAMERA>"'
        command_off:    '/config/scripts/floodoff.sh "<IP ADDRESS OF CAMERA>"'
        command_state: '/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://<IP ADDRESS OF CAMERA>/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2\[0\]\[0\]\[1\].Mode" | grep -oc "Manual" || true'
        value_template: '{{ value == "1" }}'
        friendly_name: Garage Floodlight

/config/scripts/floodon.sh:

#!/usr/bin/bash

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting%5B0%5D%5B0%5D.Enable=false&Alarm%5B2%5D.EventHandler.LightingLink.LightDuration=1800"

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2%5B0%5D%5B0%5D%5B0%5D.Mode=Auto&Lighting_V2%5B0%5D%5B0%5D%5B1%5D.Mode=Manual"

/config/scripts/floodoff.sh:

#!/usr/bin/bash

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2%5B0%5D%5B0%5D%5B1%5D.Mode=Off&Lighting_V2%5B0%5D%5B0%5D%5B0%5D.Mode=Auto"

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting%5B0%5D%5B0%5D.Enable=true&Alarm%5B2%5D.EventHandler.LightingLink.LightDuration=300"

So how do the scripts know which of the lights you are turning on and off if the one script runs for either camera? also when I copy your code I get an error end of the stream or a document separator is expected (165:1)

The IP address of the camera is passed as a parameter to the scripts. For example in the HA config:

command_on: '/config/scripts/floodon.sh "<IP ADDRESS OF CAMERA>"'

You would replace the <IP ADDRESS OF CAMERA> with you camera's IP address, and that is passed in the script when it is run by HA as the switch is flipped. Then in the .sh script, it makes the http call to that camera's IP address by using the $1 parameter (in the ...http://$1/cgi-bin/... part), which will be the IP address that was passed to the script:

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting%5B0%5D%5B0%5D.Enable=false&Alarm%5B2%5D.EventHandler.LightingLink.LightDuration=1800"

@jckickflip
Copy link

jckickflip commented Dec 3, 2023

@drsweb Can you share config/code for this as I am struggling to get it working. Im trying to make a switch to turn it on and off but so for the switch is just stuck off.

Here's what I use for my floodlight switches on Home Assistant, this runs on a Raspberry Pi with Raspian OS:

At end of my HA configuration.yaml:

- platform: command_line
    switches:
      back_door_floodlight:
        command_on:    '/config/scripts/floodon.sh "192.168.68.XXX"'
        command_off:    '/config/scripts/floodoff.sh "192.168.68.XXX"'
        command_state: '/usr/bin/curl -s --digest -u admin:password "http://192.168.68.XXX/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2\[0\]\[0\]\[1\].Mode" | grep -oc "Manual" || true'
        value_template: '{{ value == "1" }}'
        friendly_name: Back Door Floodlight
      garage_floodlight:
        command_on:    '/config/scripts/floodon.sh "192.168.68.XX"'
        command_off:    '/config/scripts/floodoff.sh "192.168.68.XX"'
        command_state: '/usr/bin/curl -s --digest -u admin2:password2 "http://192.168.68.XX/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2\[0\]\[0\]\[1\].Mode" | grep -oc "Manual" || true'
        value_template: '{{ value == "1" }}'
        friendly_name: Garage Floodlight

/config/scripts/floodon.sh:

#!/usr/bin/bash

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting%5B0%5D%5B0%5D.Enable=false&Alarm%5B2%5D.EventHandler.LightingLink.LightDuration=1800"

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2%5B0%5D%5B0%5D%5B0%5D.Mode=Auto&Lighting_V2%5B0%5D%5B0%5D%5B1%5D.Mode=Manual"

/config/scripts/floodoff.sh:

#!/usr/bin/bash

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2%5B0%5D%5B0%5D%5B1%5D.Mode=Off&Lighting_V2%5B0%5D%5B0%5D%5B0%5D.Mode=Auto"

/usr/bin/curl -s --digest -u <CAMERA USER NAME>:<CAMERA PASSWORD> "http://$1/cgi-bin/configManager.cgi?action=setConfig&AlarmLighting%5B0%5D%5B0%5D.Enable=true&Alarm%5B2%5D.EventHandler.LightingLink.LightDuration=300"

so in the end it should look like this ? I get were it is getting the IP address now just not sure were it gets the username and password from, or do you just use the same user name and password on both cameras? also when I copy your code I get an error end of the stream or a document separator is expected (165:1)

@drsweb
Copy link

drsweb commented Dec 3, 2023

so in the end it should look like this ? I get were it is getting the IP address now just not sure were it gets the username and password from, or do you just use the same user name and password on both cameras? also when I copy your code I get an error end of the stream or a document separator is expected (165:1)

Oh yes, sorry. My cameras have the same username/password. You could create more parameters to make that variable for each camera if you want/need to.

I'm not sure, but it's possible you could be getting some sort of formatting code or something else if you are copy/pasting. Maybe look it over closely and if worse comes to worse maybe type things by hand to make sure that's not happening? The error does kind of make it sound like there is some sort formatting/characters that it's not expecting.

@audiophonicz
Copy link

Hello frens, me again.

I just updated HA to 2024.1.2 (And I know I had this issue in Dec with one of the 2023.12.x builds) and my command line switch was throwing errors. They changed the way this was written in the configuration.yaml, as well as how the name and id function. For anyone having issues, the new way to write @mcowger's example commands is:

command_line:
  - switch:
      name: Garage Floodlight
      unique_id: garage_floodlight
      command_on: "/usr/bin/curl  --globoff -s --digest -u admin:pass 'http://<ip>/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][0].Mode=ForceOn&Lighting_V2[0][0][1].Mode=ForceOn&Lighting_V2[0][1][0].Mode=ForceOn&Lighting_V2[0][1][1].Mode=ForceOn&Lighting_V2[0][2][0].Mode=ForceOn&Lighting_V2[0][2][1].Mode=ForceOn'"
      command_off: "/usr/bin/curl  --globoff -s --digest -u admin:pass 'http://<ip>/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2[0][0][0].Mode=Off&Lighting_V2[0][0][1].Mode=Off&Lighting_V2[0][1][0].Mode=Off&Lighting_V2[0][1][1].Mode=Off&Lighting_V2[0][2][0].Mode=Off&Lighting_V2[0][2][1].Mode=Off'"
      command_state: "/usr/bin/curl --globoff -s --digest -u admin:pass 'http://<ip>/cgi-bin/configManager.cgi?action=getConfig&name=Lighting_V2[0][0][1].Mode' | grep -oc 'ForceOn' ||true"
      value_template: "{{ value == '1' }}"

@cdavis289
Copy link

cdavis289 commented Jan 29, 2024

I was able to implement @drsweb bash scripts and HA config. Thanks! I ran into a few issues so I thought I would document it for others since it took me a while to find an answer:

  • Those scripts used #!/usr/bin/bash as the first line however you should check your systems bash location (ie from HA container type which bash) and update accordingly. Mine used #!/bin/bash. Not sure if this stopped the scripts from working since I also had the issue below.
  • I copied the text from this github page and pasted into a file through configurator in HA. I didn't realize that it pasted a CRLF (\r\n) at the end of each line which is a newline character in windows, but not Linux. I had to replace the CRLF (\r\n) with a LF (\n) which is a newline character in Linux. After that everything started working.

@nabahr
Copy link

nabahr commented Dec 4, 2024

This is a very curious observation that I have discovered....I have been using the "Manual/off" method for a couple years and it worked mostly fine. During the cold winter months though the light would turn on dimly or not turn on at all, but during the warm weather it worked fine. I figured it was just the hardware.

This year, the light has been performing very poorly and wouldn't even turn on in 20F weather....but then I discovered that turning the light on/off via the app worked fine.
Turns out, after switching to the "ForceOn" method to turn the light on/off, now it works fine in the cold as well, just like on the app.

The status of the light between HA and the amcrest app do not agree at all though, but for me that's fine, I never use the app.
If I turn on via HA, then turn on via app, then turn off via HA, the light stays on. Same going the other way, app on->HA on->app off->light stays on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests