Dahua config via scripts

remlemasi

n3wb
Joined
Jan 17, 2023
Messages
18
Reaction score
5
Location
US
Just set up an Amcrest AD410 with scrypted and HomeKit and used this for configuration:


This got me thinking about using scripted URLs to enable and disable the white LEDs on my HDW5442TM-AS-LED full color. Thinking of doing it on a schedule and also when motion is detected by whatever trigger.

I tried to search but was not successful… are there any guides on how to achieve this? A list of Dahua parameters that can be configured this way?
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
450
Reaction score
657
Location
Alaska
Some have posted the Dahus HTTP API on this site that lists the code required to perform a number of camera functions. However, it may or may not contain the information you requested.

As an example, the below would switch a camera from color to B/W.

Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[5].NightOptions.SwitchMode=2&VideoInOptions[5].NightOptions.Profile=3
 

remlemasi

n3wb
Joined
Jan 17, 2023
Messages
18
Reaction score
5
Location
US
Some have posted the Dahus HTTP API on this site that lists the code required to perform a number of camera functions. However, it may or may not contain the information you requested.

As an example, the below would switch a camera from color to B/W.

Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[5].NightOptions.SwitchMode=2&VideoInOptions[5].NightOptions.Profile=3
Thats a great start! I’ll probably start with a whole bunch of getConfigs before I start using setConfig so I understand what’s available. VideoInOptions sounds like it might lead to the LED parameter so I’ll try that first. Any other categories you know of? I have “Encode” and “VideoInOptions”…

Maybe a nice sticky for this topic is in order!
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
450
Reaction score
657
Location
Alaska
Found this 'flashlight' setting. It may or may not work for your needs. Some API's work for some cameras and not others. But it is fun trying to see what can be done.

See attached PDF.
 

Attachments

remlemasi

n3wb
Joined
Jan 17, 2023
Messages
18
Reaction score
5
Location
US
Ah very interesting. I’ll run a getConfig in that when I get home.

Doing getConfig on VideoInOptions there seems to be three settings: No prefix, NightOptions, and NormalOptions.

Based on what I’ve already set, I’m guessing no prefix is “Day,” NightOptions is “Night,” and NormalOptions is “General.” Can you confirm?

Additonally, even on my full color LED model, I have an InfraRed and InfraRedLevel parameters. Perhaps those refer to whatever LEDs are populated on those pins and it might work?

I’ll find out soon enough as I’ll enable the LEDs and then re-run getConfig on VideoInOptions and see if anything has changed.

Follow up question, does the camera re-request the username and password after a period of time or does it remember if you do it often enough?
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
450
Reaction score
657
Location
Alaska
This list should assist in defining the terms.

NightOptions.SwitchMode
0: NoSwitch, always use day options.
1: Switch depends on brightness.
2: Switch depends on time, switch to NightOptions
when time is after sunset time and before sunrise.
3: NoSwitch, always use NightOptions.
4: No switch, always use NormalOptions.

NightOptions.Profile
0: use temporary day options.
1: use temporary NightOptions.
2: use temporary NormalOptions.
3: depends on head.NightOptions.SwitchMode

NightOptions.ExposureMode
0: AutoExposure
1: Gain first
2: Exposure first
4: Manual

NightOptions.DayNightColor
0: always multicolor
1: autoswitch along with brightness
2: always monochrome

When using a browser, with no user name or password as part of the statement, then a form field will be displayed asking for user and password. The SET statement modifies the camera data, while the GET is used to read the data out of the camera.

The user and password can be included as part of the statement as follows:

Code:
http://admin:password@192.168.1.108:80/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[1].NightOptions.SwitchMode=3
The term 'flashlight', I assume, is in reference to the white light LED but can not be 100% sure. The setup for IR would be a different set of parameters.
 

remlemasi

n3wb
Joined
Jan 17, 2023
Messages
18
Reaction score
5
Location
US
Thank you, super helpful yet again...

Changing the LED from Off to Auto to Manual in the web server GUI yielded no changes to any parameters in VideoInOptions (InfraRed did not work) and no changes to FlashLight. Here is the getConfig. I haven't tried enabling it yet via setConfig and will try that next... but kind of scared to brick it...

Code:
table.FlashLight.Brightness=50
table.FlashLight.Enable=false
table.FlashLight.TimeSection[0][0]=1 00:00:00-23:59:59
table.FlashLight.TimeSection[0][1]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[0][2]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[0][3]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[0][4]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[0][5]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[1][0]=1 00:00:00-23:59:59
table.FlashLight.TimeSection[1][1]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[1][2]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[1][3]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[1][4]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[1][5]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[2][0]=1 00:00:00-23:59:59
table.FlashLight.TimeSection[2][1]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[2][2]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[2][3]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[2][4]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[2][5]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[3][0]=1 00:00:00-23:59:59
table.FlashLight.TimeSection[3][1]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[3][2]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[3][3]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[3][4]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[3][5]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[4][0]=1 00:00:00-23:59:59
table.FlashLight.TimeSection[4][1]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[4][2]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[4][3]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[4][4]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[4][5]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[5][0]=1 00:00:00-23:59:59
table.FlashLight.TimeSection[5][1]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[5][2]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[5][3]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[5][4]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[5][5]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[6][0]=1 00:00:00-23:59:59
table.FlashLight.TimeSection[6][1]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[6][2]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[6][3]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[6][4]=0 00:00:00-23:59:59
table.FlashLight.TimeSection[6][5]=0 00:00:00-23:59:59
 

remlemasi

n3wb
Joined
Jan 17, 2023
Messages
18
Reaction score
5
Location
US
Ok, the document didn't result in any progress... but I found this:


It's for AD cameras, but the commands for illuminator works!!! I'm unable to set the brightness level under manual mode... but oh well... good enough :)

Here is the getConfig for "Lighting":

Code:
table.Lighting[0][0].Correction=50
table.Lighting[0][0].MiddleLight[0].Angle=50
table.Lighting[0][0].MiddleLight[0].Light=50
table.Lighting[0][0].Mode=Auto
table.Lighting[0][0].Sensitive=3
table.Lighting[0][1].Correction=50
table.Lighting[0][1].MiddleLight[0].Angle=50
table.Lighting[0][1].MiddleLight[0].Light=50
table.Lighting[0][1].Mode=Manual
table.Lighting[0][1].Sensitive=3
table.Lighting[0][2].Correction=50
table.Lighting[0][2].MiddleLight[0].Angle=50
table.Lighting[0][2].MiddleLight[0].Light=50
table.Lighting[0][2].Mode=Off
table.Lighting[0][2].Sensitive=3
table.Lighting[0][3].Correction=50
table.Lighting[0][3].MiddleLight[0].Angle=50
table.Lighting[0][3].MiddleLight[0].Light=50
table.Lighting[0][3].Mode=Off
table.Lighting[0][3].Sensitive=3
[0][1] is Day
[0][2] is Night
[0][3] is General

Not sure what [0][0] is... maybe the default baseline...

Also not sure what the parameters other than "Mode" are. Changing the brightness level in the web server GUI doesn't yield any changes to these values.
 

remlemasi

n3wb
Joined
Jan 17, 2023
Messages
18
Reaction score
5
Location
US
SUCCESS!!! I am now able to turn the LEDs on and off from HomeKit on my iPhone via the HomeBridge HTTP Switch plugin. For posterity's sake, in case anyone needs, see this thread for how I figured everything out. Hint... the cameras use digest authentication...



Here's the plugin:


and here is the code to make it work (on night mode [0][2]):

Code:
{
    "accessory": "HTTP-SWITCH",
    "name": "Camera LEDs",
    "switchType": "toggle",
    "onUrl": {
        "url": "http://<IP-ADDRESS>/cgi-bin/configManager.cgi?action=setConfig&Lighting[0][2].Mode=Manual",
        "method": "GET",
        "auth": {
            "username": "admin",
            "password": "<PASSWORD>",
            "sendImmediately": false
        }
    },
    "offUrl": {
        "url": "http://<IP-ADDRESS>/cgi-bin/configManager.cgi?action=setConfig&Lighting[0][2].Mode=Off",
        "method": "GET",
        "auth": {
            "username": "admin",
            "password": "<PASSWORD>",
            "sendImmediately": false
        }
    }
}
If anyone found this useful, please let me know so I can feel good :)
 

remlemasi

n3wb
Joined
Jan 17, 2023
Messages
18
Reaction score
5
Location
US
BTW, I'm also going to use this method to create a sunrise and sunset automation to trigger day and night modes. HomeKit makes that very easy. Just another alternative to BI and that windows script that others use. If anyone needs the exact code (like above), let me know...
 
Top