Dahua day/night switch utility - DahuaSunriseSunset

biggen

Known around here
Joined
May 6, 2018
Messages
2,560
Reaction score
2,832
I am trying to us an Arduino Uno with an ambient light sensor to change the cameras into night mode when it gets too dark due clouds during the day. The problem I am having that Dahua cameras use Digest Authentication. I have not been able to get that type of authentication to work from the Arduino, there is not much documention out there for this type of authentication in regards to the Arduino.

Being able to control your utility remotely would be awesome.
You can use just plan authentication with wget or curl if you are on the local network of the cameras. I use this command to flip my 5442 to night:


wget -O - --user admin --password pass "10.200.200.6/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1" >/dev/null 2>&1


And this to flip back to day:

wget -O - --user admin --password pass "10.200.200.6/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0" >/dev/null 2>&1
 

Fubduck

Getting the hang of it
Joined
Jul 10, 2018
Messages
109
Reaction score
72
Location
colorado
You can use just plan authentication with wget or curl if you are on the local network of the cameras. I use this command to flip my 5442 to night:


wget -O - --user admin --password pass "10.200.200.6/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1" >/dev/null 2>&1


And this to flip back to day:

wget -O - --user admin --password pass "10.200.200.6/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0" >/dev/null 2>&1
Unfortunately neither wget or curl are available on the Arduino.
 

Fubduck

Getting the hang of it
Joined
Jul 10, 2018
Messages
109
Reaction score
72
Location
colorado
You can’t install wget?
No it's not a traditional linux type device. I may have found a work-around though. I've turned it into a webserver that spits out a webpage with the lux value from the light sensor. I can read that webpage using cron from another server and then use wget from there to trigger the change.
 
Joined
Dec 27, 2017
Messages
8
Reaction score
10
I wanted to use stronger noise reduction at night and weaker during the day, but Dahua seems to have made a mess of the profile management. There doesn't seem to be a way to have the camera switch automatically between Day and Night profiles when the camera changes between "Color" and "Black & White" mode.

The Profile Management tab has a "Normal" mode which is evidently supposed to do this (IPC/Camera Configuration - Dahua Wiki). But I just tried it. It doesn't do that at all. Choosing "Normal" just makes the camera use a third profile, which is neither "Day" or "Night" but a separate third profile called "Normal", which stores settings independently of the "Day" and "Night" profiles.

Dahua engineers must live in a world where it is perfectly acceptable to say:

or


Now I know why Nayr has his profile management scripted externally, but even that seems to be a mess: Switch Dahua Day/Night Profile via IPC HTTP API

Update

I've written Windows software to take care of this.

GitHub - bp2008/DahuaSunriseSunset: A Windows Service which changes the profile of dahua cameras between Night and Day at each sunset and sunrise.
Hi, i am new to this forum, I have a dahua 5216-16p-i NVR and few 5442TM camera, in the camera setting, i have four Profile Management"--general, full time, schedule, day/night. How to use your DahuaSunriseSunset application? do i need to have a PC to be ON all the time or sleep mode to enable sunrise/sunset function? or just need a PC to install it. Thank you BP2008
 

Sphinxicus

Getting comfortable
Joined
Aug 30, 2017
Messages
174
Reaction score
341
Location
Ireland
Hi, i am new to this forum, I have a dahua 5216-16p-i NVR and few 5442TM camera, in the camera setting, i have four Profile Management"--general, full time, schedule, day/night. How to use your DahuaSunriseSunset application? do i need to have a PC to be ON all the time or sleep mode to enable sunrise/sunset function? or just need a PC to install it. Thank you BP2008
you need a device running Windows OS to run the utility. The device needs to be on and the utilities windows service running at the time you wish for your cameras to switch profiles for it to fire the command to the camera.

I personally run this on my Blue Iris PC as its obviously always on and has access to the network that the cameras reside on. Its a great utility and much kudos to @bp2008 for creating it
 

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
24,831
Reaction score
48,420
Location
USA
In addition to what @Sphinxicus said, it is a little harder to run this utility with an NVR as well as the cameras are probably connected to POE ports on the NVR, so they are given a different IP address and you probably cannot reach them from a Windows computer for this tool to work.

Just another reason to run Blue Iris over an NVR lol.
 

d5775927

Pulling my weight
Joined
Dec 11, 2019
Messages
287
Reaction score
221
Location
Israel
In addition to what @Sphinxicus said, it is a little harder to run this utility with an NVR as well as the cameras are probably connected to POE ports on the NVR, so they are given a different IP address and you probably cannot reach them from a Windows computer for this tool to work.

Just another reason to run Blue Iris over an NVR lol.
When you open the Managment-> Camera menu (in the NVR), the NVR forwards HTTP request to the the IP cameras (this allows you to access the IPC cameras via the browser, even when you are browsing from other subnet).
Assuming that if you login to the NVR (using curl/wget) and trigger this behavior (of forwarding requests to the IPCs), the utility may work as well.
However, need to use the NVR IP and the camera port, I didn't try yet (since I usually have enough street light after sunset).
 

SpacemanSpiff

Known around here
Joined
Apr 15, 2021
Messages
1,467
Reaction score
2,470
Location
USA
When you open the Managment-> Camera menu (in the NVR), the NVR forwards HTTP request to the the IP cameras (this allows you to access the IPC cameras via the browser, even when you are browsing from other subnet).
Assuming that if you login to the NVR (using curl/wget) and trigger this behavior (of forwarding requests to the IPCs), the utility may work as well.
However, need to use the NVR IP and the camera port, I didn't try yet (since I usually have enough street light after sunset).
Despite the NVR being the sole recorder in this scenario, the trigger is still initiated from a PC, correct?
 

Mike A.

Known around here
Joined
May 6, 2017
Messages
3,828
Reaction score
6,384
I must be a dummy. I'm having problems getting this simple thing to work properly.

Camera switches but not at the right times.

I have defined my longitude/latitude. Double checked that's correct. Entered the offset at -5 for US East Coast as I normally would for other things. IP is correct, service is running, etc., since camera does switch. My time is correct on the machine where running. It's the time server for the rest of my network and cam is using that and it's correct there too. I've tried the cam profile in multiple ways, full-time, scheduled, normal. Seems to make no difference. Simulate Sunrise/Sunset does work.

WTH am I doing wrong?

Oh, wait.. what is the offset from? The calculated sunrise/sunset or UTC?
 
Last edited:

Sphinxicus

Getting comfortable
Joined
Aug 30, 2017
Messages
174
Reaction score
341
Location
Ireland
from memory, the offset value isn't timezone offset from GMT as far as i'm aware. Its offsetting the time you want to fire the sunrise or sunset in relation to your local timezone. I have my values set to 0.5 and -0.5 if i remember right. So my cams will switch to day profile 30mins after sunrise and will switch to night profile 30mins before sunset.

post the error log, that will give a better idea. Also, the profile should be set to full time i think
 

Mike A.

Known around here
Joined
May 6, 2017
Messages
3,828
Reaction score
6,384
OK, that's probably it. Not sure how I got in my head that it was from UTC.

Log was a mess because I've been starting and stopping and triggering sunrise/sunset at different times over the last few days. Deleted so that I'll get a clean one now. I'll post if the offset change doesn't do it. Likely so though.
 

handinpalm

Getting comfortable
Joined
Sep 21, 2016
Messages
679
Reaction score
1,433
Location
Tampa Bay FL
I recently got 4 new Dahua 5442 cameras that have FW dated 7/16/21, and none of them can be controlled with the Sunrise/Sunset utility (Ver 1.8) . I configured Profile Management to Full Time, and camera Day & Night set to Color/B/W. just like all the other Dahua cameras, that are still working. I have rebooted BI server and checked that service is running. Has anyone else run into this problem with Dahua FW version 7/6/21?
 

bp2008

Staff member
Joined
Mar 10, 2014
Messages
12,672
Reaction score
14,015
Location
USA
I am running a cam with firmware from 2021-07-09 and its API for setting sunrise and sunset is working fine.

1638125074802.png

I am not using the DahuaSunriseSunset service. Instead I am having Blue Iris send the http requests using its own scheduler.

It is a little hacky to set up in Blue Iris because you can't simply schedule a custom HTTP request. But you can modify PTZ presets in Blue Iris to send custom HTTP requests, and you can schedule calls to those presets to happen at times relative to sunrise and sunset.

The procedure is:

1. In Blue Iris, go to Camera Properties > PTZ/Control tab.
2. Enable PTZ control (if your cam doesn't have motorized pan/tilt/zoom then just pick "Dahua New V5" from the dropdown).
3. Click Edit presets.
4. Type Day Profile into the description of one of the presets.
5. Click "On call" button, then add a "Web request or MQTT" action.
6. Configure the URL as user:password@192.168.0.1/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0, replacing user, password, and 192.168.0.1 with your own camera credentials and address.
7. Repeat steps 4-6 on a different preset, but with the description Night Profile and change the 0 at the end of the URL to 1 like this: user:password@192.168.0.1/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1

1638125662725.png

Finally you can proceed to scheduling calls to your presets:

8. Go to camera properties > Schedule tab > Events schedule.

Add each event at the desired time:

1638126063161.png

In this example, I configured it so the camera goes to Day mode 1 hour before sunrise. I configured this weeks ago and Blue Iris has automatically adjusted the exact scheduled time as the sunrise time changes daily.

1638126075887.png
 
Last edited:

handinpalm

Getting comfortable
Joined
Sep 21, 2016
Messages
679
Reaction score
1,433
Location
Tampa Bay FL
Thanks for the response Brian, but I like to keep things as simple as possible. I will use the "General" profile and let the camera photosensor change the modes. I always liked using your utility to change all the cameras at once. I had problems with older versions of cameras constantly switching back and forth between day/night, due to the poor hysteresis. Hopefully the newer cameras will not have that problem, and I will play around with the sensitivity.
 
Last edited:

gwminor48

Known around here
Joined
Jul 16, 2015
Messages
3,641
Reaction score
6,959
Location
Texas
I am running a cam with firmware from 2021-07-09 and its API for setting sunrise and sunset is working fine.

View attachment 110032

I am not using the DahuaSunriseSunset service. Instead I am having Blue Iris send the http requests using its own scheduler.

It is a little hacky to set up in Blue Iris because you can't simply schedule a custom HTTP request. But you can modify PTZ presets in Blue Iris to send custom HTTP requests, and you can schedule calls to those presets to happen at times relative to sunrise and sunset.

The procedure is:

1. In Blue Iris, go to Camera Properties > PTZ/Control tab.
2. Enable PTZ control (if your cam doesn't have motorized pan/tilt/zoom then just pick "Dahua New V5" from the dropdown).
3. Click Edit presets.
4. Type Day Profile into the description of one of the presets.
5. Click "On call" button, then add a "Web request or MQTT" action.
6. Configure the URL as user:password@192.168.0.1/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0, replacing user, password, and 192.168.0.1 with your own camera credentials and address.
7. Repeat steps 4-6 on a different preset, but with the description Night Profile and change the 0 at the end of the URL to 1 like this: user:password@192.168.0.1/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1

View attachment 110037

Finally you can proceed to scheduling calls to your presets:

8. Go to camera properties > Schedule tab > Events schedule.

Add each event at the desired time:

View attachment 110038

In this example, I configured it so the camera goes to Day mode 1 hour before sunrise. I configured this weeks ago and Blue Iris has automatically adjusted the exact scheduled time as the sunrise time changes daily.

View attachment 110039
Thanks! I'll try this on an older Dahua PTZ I have. Will it matter if the camera is set on Normal, Full Time, or Schedule?
 

bradner

Getting comfortable
Joined
Aug 15, 2019
Messages
426
Reaction score
757
Location
PNW
Hi Brian,

I bought a 4 channel Dahua cam (PSDW5631-B360) from Andy's sale and was wondering if I needed a special parameter to get the utility to work with each channel. It doesn't seem to work by just plugging in the IP address of the camera. Thanks
 
Top