Dahua day/night switch utility - DahuaSunriseSunset

bp2008

Staff member
Mar 10, 2014
12,786
14,325
USA
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. On most cameras, 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:
Oh, what beautiful weather we are having this normal.
or
We're closed right now. Come back during the normal.

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.

For each camera you wish to do this with, you need to go to its web interface > Setting > Camera > Conditions > Profile Management. Set it to Full Time.

GitHub - bp2008/DahuaSunriseSunset: A Windows Service which changes the profile of dahua cameras between Night and Day at each sunset and sunrise.

Alternative using Blue Iris to set camera profiles:

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

For each camera you wish to do this with, you need to go to its web interface > Setting > Camera > Conditions > Profile Management. Set it to Full Time.

There are several ways to make Blue Iris change the camera's active profile. Here I will give instructions for the method I use. It is a little hacky because you can't simply schedule a custom HTTP request to occur. 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 which you do not intend to use for anything else.
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

pxd1SHZ.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:

BKPkuGU.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.

N5LuSFb.png
 
Last edited:
It's actually very easy to switch the profile with a script, I'm thinking about doing it with one of my cameras so I can give it a little bit of wdr during the day and turn it off at night, day profile and night profile

Sent from my Nexus 6P using Tapatalk
 
I also can´t understand, why this silly simple day/night switching together with ir-cut is possible, i can´t imagine that it would be difficult to program.:banghead:
 
I too was very puzzled by the profiles. I also concluded that whatever profile is chosen, it's in use 24/7. So there are 3 profiles, 2 of which are useless. Unless I write a script to brute-force a profile change by some non-NVR entity sending a command string.

If the profiles were switchable, maybe by scheduling "Day" and "Night", that would be a useful NVR feature, right out-of-the-box. For the varifocal Starlight Cams, it would be reaaly nice to have the cam's "Focus" parameter change as well. Right now, we can pick one focus value, and it's used 24/7. Even though the cam's image is clearest with a different focus setting for night and for day.

Maybe the same script that changes the profile could also change the focus setting?

Fastb
 
  • Like
Reactions: Flintstone61
@Fastb
i would like you to invite to a issue ticket for the focus day/night problem. I am very sad about this problem, and maybe we need to be more to get dahua working on it. I am glad about to find other users who agree this issue!
 
My 5231s let me schedule when I want the profiles to change between night and day?

Not a perfect solution, as when it gets dark changes daily, but it sounds like some Dahua cameras might not even have that option?
 
My 5231s let me schedule when I want the profiles to change between night and day?

Not a perfect solution, as when it gets dark changes daily, but it sounds like some Dahua cameras might not even have that option?
every camera has that option something must be wrong with the firmware......problem is you dont want to mess with it year round...
 
I just set this up today for an outdoor camera to give it a little bit of WDR during the day in domoticz, simple script:


HTML:
commandArray = {}

-- Switch cameras to day profile
if (timeofday['Daytime']) then
        commandArray['OpenURL']='http://user:pwd@10.0.0.125/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0'

-- Switch cameras to night profile
elseif (timeofday['Nighttime']) then
        commandArray['OpenURL']='http://user:pwd@10.0.0.125/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1'
end

return commandArray


All I have to do now is add URL's for any other cameras I want to change profiles with, and this will change based on sunrise and sunset. :)
 
IIRC BlueIris can switch between day/night profiles at Sunrise/Sunset
 
IR On - Night Profile / IR Off - Day Profile

Give it a shot, IR Auto I think is Normal Profile
 
  • Like
Reactions: hmjgriffon
IR controls don't work on my dahua turrets but it does work on the two hikvision cams I have. But other things do work like PTZ presets in BI change the PTZ presets I have created in the PTZ camera, heh.
 
Since IR control on Dahua's is really just switching profiles it requires you to setup your Day profile to Forced Color, Night Profile to Forced B&W and Normal Profile to Auto (default) directly on the cameras WebUI for that kind of behavior, out of the box all 3 profiles are Auto switch based off light sensor so that button dont seem to do anything unless you setup variation in the profiles.
 
  • Like
Reactions: hmjgriffon
Actually, it seems that IR On / Off commands from Blue Iris change just the Day & Night mode option, not the currently selected profile. I hate that Blue Iris even has an IR toggle button, because clicking it toggles between IR On and Off, and to get back to Auto mode which is what you want in 99.99% of cases, you have to dig back into the camera's web interface and set it there. Or I guess you could schedule an IR Auto command to happen in the near future. But there is no button that I know of that will simply issue this command.
 
Actually, it seems that IR On / Off commands from Blue Iris change just the Day & Night mode option, not the currently selected profile. I hate that Blue Iris even has an IR toggle button, because clicking it toggles between IR On and Off, and to get back to Auto mode which is what you want in 99.99% of cases, you have to dig back into the camera's web interface and set it there.
You can get back to auto by simply holding down the toggle button...this works on both the mobile app and server.
 
You can get back to auto by simply holding down the toggle button...this works on both the mobile app and server.

Aha, thanks for letting me know. Now that I know this I may consider implementing the button in UI2, except if I do it, it will be a toggle button with 3 toggle states... or a dropdown box or something. The most common option shouldn't be the one that is almost an easter egg.
 
If only there was some sort of manual or help file that could be used to document this stuff in; we could call it the.. ermm, BlueIris Bible?
 
If only there was some sort of manual or help file that could be used to document this stuff in; we could call it the.. ermm, BlueIris Bible?
To be fair, its not in the help file itself, its in a 2013 release note..
3.26.00 - May 30, 2013

  • Several new buttons have been added to the main UI in the PTZ area. These include focus near/far, IR lights, as well as Listen and Talk. Note that each of these functions are initially functional only for a small subset of cameras such as the Foscam 89xx (and its dozens of compatibles) as well as the Agasio 522/622 (and its dozens of compatibles). If your camera is not among these, yet supports these features, Blue Iris support may be in the works.

  • Clicking the IR button will toggle between on and off, while holding it down will switch to "auto" mode if the camera supports this functionality and Blue Iris knows the corresponding command to send to the camera.
 
Hah. I even searched the help file for that, but after the button wasn't mentioned in the "Camera Properties - PTZ" topic that contained a screenshot of the IR button (among others), I thought it was simply not documented.

In hindsight I should have scrolled through the What's New topic too because Ken often describes features in there and nowhere else.