Dahua day/night switch utility - DahuaSunriseSunset

In any case, your app now allows me to use the WDR backlight setting as switching between "night" and "normal" now actually works and can be used as an alternate settings scheme for anyone else.

Thanks again!
 
  • Like
Reactions: bp2008
For some reason i can't get this to work on my Dahua IPC-HFW5231E-Z12E

I have it setup as "Full" time, and all the info entered into the "Dahua Utility app". I can see that something is happening when i click "simulate sunrise or sunset" as the camera image goes darker or lights up" , but will not go to the zoom & focus where it's suppose to go!

Been trying this for quite sometime and i can not get it to work. If i move in cam settings the day and night profiles at zoom and focus where suppose to be, they go back all way zoom 1020 and focus 1800 in to max.

I am doing something wrong or the utility may not send the right commands to the camera?

Thanks!
P.
 
For some reason i can't get this to work on my Dahua IPC-HFW5231E-Z12E

I have it setup as "Full" time, and all the info entered into the "Dahua Utility app". I can see that something is happening when i click "simulate sunrise or sunset" as the camera image goes darker or lights up" , but will not go to the zoom & focus where it's suppose to go!

Been trying this for quite sometime and i can not get it to work. If i move in cam settings the day and night profiles at zoom and focus where suppose to be, they go back all way zoom 1020 and focus 1800 in to max.

I am doing something wrong or the utility may not send the right commands to the camera?

Thanks!
P.
try to update to the newest firmware i posted, the new firmware has an update for the day/night switch delay.
 
  • Like
Reactions: patrocle
Thank you, Thank you , Thank you @bp2008 ! Using this to switch between general overview of an area during day, to license plate reading at night. Works!
 
Thank you for this great utility :) However, there are some minor glitches.
Running Version 1.3.1 on Windows 10, the input fields doesn't take care of floating point
numbers. E.g. a sunrise offset of -0.5 becomes -5 and same issue with longitude and latitude.
Configuring values directly in DahuaSunriseSunsetConfig.cfg works flawlessly.

Suggestions: Why not name the DahuaSunriseSunsetErrors.txt as DahuaSunriseSunsetLog.txt
since there are also normal service activities logged? - I was a litte confused after entering the
necessary data because there are no OK/Cancel buttons. Why not add? They're already paid ;)

Best regards, Carver
 
  • Like
Reactions: vidmo
By the way, if you have a spiffy Dahua with 2 cameras in a single body, this program will only adjust the first one (channel zero).

You can manually switch profiles on the 2nd camera (channel one) with URLs like:
http://user:password@hostname/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[<channel>].Config[0]=<0 for day, 1 for night>

(the "VideoInMode" is where you switch between the channels... [0] for camera 1, [1] for camera 2)

e.g. if I wanted to switch the 2nd camera to night profile, I'd request:
http://user:pass@host/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[1].Config[0]=1

I don't know if that's something that could be added... some configuration per camera to set it to channel 0 (the default) or channel 1 (if you do happen to have something like the IPC-HDBW4231FP-E2-M)
 
I don't know when I'll have time again to update this app again, but it shouldn't be a big deal making it configurable which channel is specified. Then you'd just treat it as two separate cameras in this app.
 
  • Like
Reactions: fenderman
I mangled together some code changes to include a box for channel # and included that in the URL passed to the camera. As you mentioned, I just had to add each camera with channel 0 and 1. Since the dual cam doesn't have focus or zoom there were no changes to those features. It's just a handful of changes and maybe when I've tested it out more I can see if you're interested in merging the changes. It tested okay but I haven't actually used it in the real world and I'd want to see how it performs before I called it good.

EDIT: I did have to make a few adjustments:
1) I added logging so that it logs the IP:Port for each camera it's adjusting, just so I could track the specific actions (e.g. "Setting camera 10.1.1.255:80 channel 0 to Day")
2) The parallelism seems to cause trouble when trying to set both channels at the same time. I ended up disabling the parallelism (set it to a max of 1 thread) and added a 1-second delay between commands for the day/night request. Without those changes, it was trying to set both at once and typically only one channel or the other actually accepted it and the other didn't make the change.

Removing the parallelism isn't a big deal for me... I'm only doing it on the one camera body for now and even if I add in my other Dahuas that's only 3 more total. I can live with having 5 cameras set in a 5 second span rather than all at once.

Overall I'm pleased with how it's working now and I do appreciate the effort you put into it. My other option was to setup a script to send the requests with curl, but I'd still have to figure out a way to do it at dynamic times based on the sunrise/sunset. My home automation system does that but I didn't want to try tying into that unless nothing else came along. Having this run as a service on the same computer running BI is very workable.
 
Last edited:
By the way, at least if you're just changing day/night (not sure about focus/zoom), the only permissions the user apparently needs is "AV Parameter". So if you want to create a user just for this service (and I recommend it), that's the only one it needs to have.
 
  • Like
Reactions: Rhodesy
Wanted to say thanks so much to the op for sharing this program.
Works great! I haven't read the entire thread, but 'fetching' the zoom & focus numbers worked well, as I originally took the values from the slider bars within the Dahua app. which was incorrect, of course!
 
  • Like
Reactions: bp2008
@bp2008 Can the ‘Simulate Sunrise’ and ‘Simulate Sunset’ functions be executed from the command line?

I ask because I’d like to assign these actions to two camera presets.

The reason why is that I’ve errantly sent Dahua’s autofocus api http autofocus command at night with horrible results (this is on a 5231; Dahua’s algorithm seems unable to focus in low light). Clicking the ‘Simulate Sunset’ button always fixes the focus, but I must access my BI machine to accomplish this.
 
Last edited:
@jaydeel

No, they can't. You should be able to modify some BI camera presets to make them send an appropriate API request directly to the camera, without the need for an external program.

These are all the commands which the DahuaSunriseSunset app is able to send:

Set "Day" profile:
Code:
/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0

Set "Night" profile:
Code:
/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1

Set "Normal" profile:
Code:
/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=2

Set zoom and focus (enter numbers for zoom and focus):
Code:
/cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=0&zoom=0

Get current zoom and focus numbers from camera (use this to find out which focus and zoom values will work well when adjusting camera zoom/focus):
Code:
/cgi-bin/devVideoInput.cgi?action=getFocusStatus

Just instruct the camera to autofocus:
Code:
/cgi-bin/devVideoInput.cgi?action=autoFocus
 
Last edited:
  • Like
Reactions: NetHunter
You should be able to modify some BI camera presets to make them send an appropriate API request directly to the camera, without the need for an external program.

Thanks. I have experimented with a script to do this, but i’ve not succeeded yet in reproducing your perfect result. You send a sequence of repeat zoom/focus commands if I recall correctly. I may have the timing or sequence wrong. I’ll do more testing.
 
Well the adjustFocus command is pretty buggy in my experience, and must be sent multiple times in order to achieve the desired result. It made me a little bit crazy trying to figure out the most reliable number of repeats.