Dahua day/night switch utility - DahuaSunriseSunset

The new Web 5.0 GUI cameras will respond correctly to the old CGI calls if and only if one first sets them to Self-Adaptive working mode in the web GUI.
That leaves them in a state that will accept the old CGI commands issued by software written to control the older cameras via....

cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0 <-- day profile
cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1 <-- night profile

This seems to be related to the cameras being left in VideoInMode[0].Mode=0 which is the mode that accepts the old profile switches via Config[0].
If one forgets and leaves the Web 5.0 cameras in Customized Scene working mode (VideoInMode[0].Mode=3), the web 5.0 cameras refuse the old Config[0] settings.

VideoInMode[0].Mode=3 <-- camera is in scheduled customized scene mode and won't accept Config[0] settings
VideoInMode[0].Mode=0 <-- camera is in constant profile mode and WILL accept Config[0] settings

If camera is already in VideoInMode[0].Mode=0, I can freely change VideoInMode[0].Mode back and forth via API calls between VideoInMode[0].Mode=3 and VideoInMode[0].Mode=0

Unfortunately, I can't seem to force VideoInMode[0].Mode=0 if camera was left in VideoInMode[0].Mode=3 via the GUI.
That means I can't write a universal API call sequence to force the web 5.0 cameras into the needed VideoInMode[0].Mode=0 before issuing VideoInMode[0].Config[0]=0 or VideoInMode[0].Config[0]=0 commands.

Still poking away at it. There seems to be some setting that the GUI can adjust but we don't have via CGI.

Interestingly, when in that "locked" state after GUI set VideoInMode[0].Mode=3, the CGI does accept VideoInMode[0].Mode=3, but not other values. So, the command is recognized.
 
Last edited:
As a might as well try it measure, I did this to a PTZ5A4M-25X

Night

In the 5.0 web GUI, set camera to Customized Scene, and DEFAULTED the schedule so it was always day profile.

After doing that, VideoInMode[0].Mode behavior changed...

cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Mode=3 <--- set Web 5.0 camera to day profile
cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Mode=4 <--- set Web 5.0 camera to night profile

This might be a way forward on Web 5.0 cameras that one wishes to control via CGI, but not needing to always remember to set camera in Self-Adaptive working mode. Doesn't help with the old utilities, but might be useful for new apps and CGI calls to the web 5.0 cameras.

Addition --- Even with the schedule cleared, this seems to work.
Also, works with camera left in self-adaptive working mode.

--------------

Tried on another web 5.0 camera IPC-T54IR-ZE-S3. It didn’t seem to initially work. It changed profiles, but not to what was desired.
I remembered I had also done some other commands on the first camera before defaulting the schedule. That would be these two....

Night

I think those two commands set up the Night profile to be selected when VideoInMode[0].Mode=4

Doing those two commands seems essential to allow defaulting the schedule set the other camera up for the new commands to select the desired day or night profile.
However, on IPC-T54IR-ZE-S3, there is a weird 30 second delay before camera switches to day profile.

BTW VideoInMode[0].Mode=2 is the day/night operating mode in the IPC-T54IR-ZE-S3
 
Last edited:
Hello... I have been trying to setup the automated Day Profile\Night Profile using the PTZ control. The instructions are clear. My first test failed because I had %$ in my password. I got a 404 error. Someone previously stated they had a @ in their password and had to remove it before it would work. So, I changed my password to remove the %$. Voila! I was then able to select the Day Profile of Night Profile using the test button. I then started setting up my other cameras and noticed the first camera went offline, with a message to check the password. I had changed the Blue Iris password to match the camera password already so now I'm confused? I then went into the camera and Blue Iris and set the passwords back to the old password that has the %$ in it. The camera came back online and all seems good, except now I can't change the Day\Night profiles using the PTZ control. I also went into the camera and tried to change the Onvif to match but kept getting a password error. I don't believe I have changed the Onvif password on any of my cameras and I'm not sure if it has any relevance at all. Any ideas on what I'm missing?
 
I was able to use this guide to get the day/night profiles rolling with a set of IPC-T54IR-AS. It was a little hairy and it needed to be in 2nd option for "working mode".
 
I think I may have solved the issue I was having on my IPC-T5442T-ZE cameras. I found the post below by wittaj and so I tried changing the ONVIF password again and this time it worked. I'm running a test tonight on the one camera and if it works I will do the rest. I also have an IPC-T54IR-ZE so I will deal with that when my other cameras are all working.


wittaj March 16, 2024
"You may think the password is correct but it isn't LOL.

So it didn't find the camera properly.

For some reason these devices keep users and ONVIF users as separate and if the password doesn't match in the ONVIF manager list (which happens frequently when people start changing passwords), then the cameras cannot be "seen". Or sometimes the firmware just goes wonky.

Log into the Camera GUI and under users you will see a tab called ONVIF User or ONVIF Manager or something like that.

Select it and then change the admin password for the ONVIF user to match your new password.

Or simply create a new user and password in ONVIF user and use that in BI and hit the find/inspect again."
 
Well, it appears that all my IPC-B5442E-Z4E, IPC-T5442T-ZE and IPC-T5442TM cameras can now be be switched to the day or night profile using the BI sunrise\sunset schedule. I had one issue where I could not change the ONVIF admin password so I added a new admin ONVIF account and pointed BI to use that account. Fixed my problem. So, having all these automatically follow the sunrise\sunset schedule is a big bonus.

I still have a problem with my IPC-T54IR-ZE camera. If I manually put the Working Mode of the camera into self-adaptive mode I can set the profile to day or night, but only once because whenever I make the change the Working Mode is switched to Customized Scene. When the camera is in Customized Scene Working Mode the commands sent to the camera using the automated PTZ method does not work. I don't know if this can be resolved so for now this one camera is going back into Customized Scene working mode and I will have to manually update the schedule periodically so the switching of Day\Night profiles can happen reasonably close to the actual sunrise and sunset.
 
  • Like
Reactions: CCTVThomas
All roads lead to wittaj... Using the API calls below I was able to use the PTZ method to change the day\night profile on my IPC-T54IR-ZE. Thank you!

wittaj Oct 20, 2022
DRUM ROLL.........

With help from above, I have figured out the APIs to change profiles for this camera!!!!!

Here is the API to go to Night profile :


Here is the API to go to Day profile :



This code will overwrite the schedules in the GUI - when you run the night API, it will change all the times and months to NIGHT and when you run the day profile, it will change all the schedules in the GUI to DAY.

So we cannot use the standalone sunrise/sunset utility, but fortunately @bp2008 provided updated instructions in that thread on how to make it happen in BI, we just need to change the API in his instructions to this one.
 
  • Like
Reactions: guykuo
I did make one small change tonight. The API calls above set the Day\Night Mode to color. For my setup color at night is not ideal. I set it to Auto so it is B&W most of the night but if there is sufficient light it will turn to color.

Night API call for auto color mode
http://USER:PW@IPADDRESS/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[].NightOptions.SwitchMode=3&VideoInOptions[].NightOptions.DayNightColor=1

See this thread for more parameter options
 
  • Like
Reactions: mteky2 and CanCuba
I have one old style camera that is returning a 404 error when running the url admin:w@192.168.1.10/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1
I've changed the ONVIF password to be sure it was not the culprit. No odd characters int the pw. The url works fine on my other cameras. Any ideas why one camera returns a 404 error?

UPDATE: I found the problem to be the CGI service was not enabled.
 

Attachments

  • screenshot (1).jpeg
    screenshot (1).jpeg
    112.6 KB · Views: 40
Last edited:
  • Like
Reactions: MarkusAgustus
Those cameras are running the old Gui. I have one IPC-T54IR-ZE that is running the new Gui. I did manage to get it working, too.
How'd you get the 54IR to work with the utility. I have a couple of 54IRs that don't change to Night automatically sometimes.
 
  • Like
Reactions: Oneup
I have been able to switch from Day to Night and vice versa (using URL as shown above) but those are the only profiles I seem to be able to select using the API. How does one select one of the other profiles (i.e. Custom1 or Custom2)??
 
  • Like
Reactions: MarkusAgustus
I have been able to switch from Day to Night and vice versa (using URL as shown above) but those are the only profiles I seem to be able to select using the API. How does one select one of the other profiles (i.e. Custom1 or Custom2)??
I'm not sure? I looked into this for the first time today. First, I'm assuming the API, version 3.26, from Andy's web site is the correct reference. If not, perhaps someone could point us in the correct direction.

API 3.26 Here

Using this API I can see the parameter names and values that enable setting the camera for the examples above...

1714516937296.png
1714517048179.png

Maybe it's not possible because I would expect that the NightOptions.SwitchMode method on page 256 would have more parameters to match the options in the camera itself? Maybe it is set somewhere else?

1714517742860.png
 
I'm not sure? I looked into this for the first time today. First, I'm assuming the API, version 3.26, from Andy's web site is the correct reference. If not, perhaps someone could point us in the correct direction.

API 3.26 Here

Using this API I can see the parameter names and values that enable setting the camera for the examples above...

View attachment 193713
View attachment 193715

Maybe it's not possible because I would expect that the NightOptions.SwitchMode method on page 256 would have more parameters to match the options in the camera itself? Maybe it is set somewhere else?

View attachment 193718

I have been able to switch from Day to Night and vice versa (using URL as shown above) but those are the only profiles I seem to be able to select using the API. How does one select one of the other profiles (i.e. Custom1 or Custom2)??


Unfortunately the API document has not been updated to reflect the new GUI and as such nobody has gone to the effort (or if they have, they haven't posted it here) to try to figure out how to use the other profiles with the API.
 
So we cannot use the standalone sunrise/sunset utility, but fortunately @bp2008 provided updated instructions
Okay, I'm done. I can't get this new GUI to reliably switch Day/Night. Can someone please link the post by @bp2008 that explains how to get BI to do the API calls? Thanks!
 
Okay, I'm done. I can't get this new GUI to reliably switch Day/Night. Can someone please link the post by @bp2008 that explains how to get BI to do the API calls? Thanks!

It is the edit in the first post to this thread, but you will have to use the APIs above for the new GUI.
 
  • Like
Reactions: 105437