Dahua day/night switch utility - DahuaSunriseSunset

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
280
Reaction score
357
Location
Alaska
I have only gotten that error when either the user name or password were incorrect...
Good call.

Started over and uninstalled, even though that now appears that it was an unnecessary step.

Added a few cameras at a time and then ran the utility "Simulate Sunset" etc and no errors in the log. Looks like one camera was in the utility, but not connected to the network switch. Thus one of the errors.

The other camera still has an error even with the correct user and password. Not sure what is happening there. Just left it out of the utility as it can switch on its own using the camera Day/Night setting.

Did notice if a camera would send an error that the utility would lock up. Had to stop and restart the utility. i.e. red X in upper right corner of the pop up plus the yellow hour glass symbol.

Also, when editing an entry sometimes it would not edit and would remain unchanged. Had to make the change in the cfg file. Perhaps not using the utility correctly as all should be done without messing with the internal utility files.

With all of the errors gone, the utility calculated time switch when compared to the actual time switch is exact!!! Calculated at 10:52:43 PM and switched at 10:52:43 PM. Success!

Appreciate all of your kind assistance.....
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
280
Reaction score
357
Location
Alaska
If you're seeing a ton of web requests are you sure the problem isn't with your internet connections stability?

I have to wonder if your connection is dropping thus generating the repeated requests.
Yes, it is possible with the one remaining camera. Will be changing out the wiring on that camera in the next day or two. There should be no "internet connection connections stability" IMO as the BI system is on a dual NIC machine with no internet available on that sub net.

Appreciate the suggestion.
 

samplenhold

Known around here
Joined
Aug 8, 2018
Messages
5,737
Reaction score
18,858
Location
Spring, Texas
The other camera still has an error even with the correct user and password.
I vaguely remember that there is more than one password in the Dahua cams. If you changed the password in one place, it may have not changed it in the other. I think that was one problem I had with that utility in the beginning, but my mind is foggy. I think it was that I had changed the password to something different than the one I set it up with during initialization. I think you have to modify the password for both the Account and the Onvif User. And when I changed it I had only modified it for the Admin account.


1659068674675.png
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
280
Reaction score
357
Location
Alaska
Thanks.... That will be a good place to look.

Did notice, when looking at the camera setup screen in BI that the camera port number at 80 had changed to an incorrect port number. Have not had the time to check, but that could perhaps also have created an error with the utility. i.e. wrong port and it crashed. Most likely happened when the camera was powered down earlier that day. The camera's are just trying to be creative and go off to never, never land!

Did change it back, but have not yet added that cam to the utility lineup. Hopefully that was the issue. If not, then more troubleshooting.
 

eeeeesh

BIT Beta Team
Joined
Jan 5, 2017
Messages
391
Reaction score
655
I recently switched over from the standalone utility to the integrated Blue Iris commands using the PZT work around

Everything is working fine for my (2) 5231 Cams and my (1) 5241 LPR Cam, but I can't get it to work on some of my other 'Andy Cams'.
(2) IPC-E3541F-AS-M
(1) IPC-HDBW5441F-AS-E2 v2 Boobie cam
(1) HDBW4231F-E2-M v1 Boobie cam

When I try the command in a web browser, I get a '404 not found 'error' instead of an 'ok' if it works properly

Anyone know what the proper syntax would be with these other commands?
 

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
16,489
Reaction score
30,649
Location
USA
Sounds like an issue with the ONVIF password as mentioned in post #523
 

eeeeesh

BIT Beta Team
Joined
Jan 5, 2017
Messages
391
Reaction score
655
Sounds like an issue with the ONVIF password as mentioned in post #523
Thanks, but I am pretty sure it's not password related

The reason why I say that is if I enter the command without the username password in chrome for a camera I know it will work on, I will get a popup asking for username/password. On these other cameras, it goes directly to the '404 not found' error page

Also, if I deliberately screw up the password on a working camera I get a page with "Error Invalid Authority!"
 

jmhmcse

Pulling my weight
Joined
Dec 30, 2018
Messages
188
Reaction score
121
Location
usa
Thanks, but I am pretty sure it's not password related
I'm running into the same issue... I have a new:

Device Type IPC-T5442TM-AS-LED-2.8mm-S2 (Loryta from Andy via his Amazon store)​
System Version V2.840.15OG00A.0.R, Build Date: 2022-01-10​
WEB Version V3.2.1.1174274​
ONVIF Version 20.12(V3.1.0.1064635)​

Tried the "old" method using the EXE and received...

Code:
Exception thrown attempting web request ([URL unfurl="true"]http://192.168.1.99:199/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0[/URL]): The remote server returned an error: (404) Not Found.

(and yes I do have a non-standard port defined for the camera's HTTP)

Then went in and added the PTZ method and received...
CamName2 Web: error: No Stream: 404​

This is a newly installed camera with only one username/password combination set during the install for both the Account User and Onvif User.
 
Last edited:

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
280
Reaction score
357
Location
Alaska
Looked at the CFG file for the sunrise/sunset Windows 10/11 utility. Tested with the Dahua camera that will not play nice and compared to those cameras that work. There was no difference in the CFG file data.

My conclusion, like others, is that that issue appears to be with the camera. Did input the fields for the ONVIF password. However, it does ask for the previous password and that would not be known if the camera went off to never, never land. Did input the old password data and it appears that the ONVIF password was not changed. When tested, with the utility, the same no go scenario.

May try a camera reset, however other have installed a new camera with negitave results. Have three of the same model (HFW-5242H-Z6E-MF). Two switch fine, one does not.
 

jmhmcse

Pulling my weight
Joined
Dec 30, 2018
Messages
188
Reaction score
121
Location
usa
Device Type IPC-T5442TM-AS-LED-2.8mm-S2 (Loryta from Andy via his Amazon store)
System Version V2.840.15OG00A.0.R,
Build Date: 2022-01-10
WEB Version V3.2.1.1174274
ONVIF Version 20.12(V3.1.0.1064635)

This camera's internal workings appear to be a MUCH different than what the two http commands describe in note #1.
user:password@192.168.0.1/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0​
and​
user:password@192.168.0.1/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1​

No cgi-bin directory; much more javascript with functions and sub-functions. To modify settings it seems you first need to retrieve the current configuration (ConfigManager.getConfig), make adjustments, and then update the configuration (ConfigManager.setConfig).

Probing the camera, the following structure is uncovered. There may be more hidden, but here's what I found:
192.168.1.99:199/jsBase/lib/jquery.js?version=@WebVersion​
192.168.1.99:199/jsBase/widget/js/jquery.ui.core.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/jquery.ui.widget.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.password.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/jquery.base64.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/jquery.powertip.min.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/jquery.pubsub.js?version=@WebVersion@​
192.168.1.99:199/jsBase/common/extend.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/md5.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/base64.js?version=@WebVersion@​
192.168.1.99:199/jsCore/common.js?version=@WebVersion@​
192.168.1.99:199/js/publicFunc.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/sea.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/seajs-text.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.tab.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.table.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.pagination.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.textfield.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.numberfield.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.datepicker.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.timefield.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.tip.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.dialog.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.ipfield.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.validator.js?version=@WebVersion@​
192.168.1.99:199/js/timeZoneExcel.js?version=@WebVersion@​

===========

Hoping in a future firmware update that a built-in sunrise/sunset feature will be added to the camera.
 
Last edited:

biggen

Known around here
Joined
May 6, 2018
Messages
2,210
Reaction score
2,172
This camera's internal workings appear to be a MUCH different than what the two http commands describe in note #1.
user:password@192.168.0.1/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0​
and​
user:password@192.168.0.1/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1​

No cgi-bin directory; much more javascript with functions and sub-functions. To modify settings it seems you first need to retrieve the current configuration (ConfigManager.getConfig), make adjustments, and then update the configuration (ConfigManager.setConfig).

Probing the camera, the following structure is uncovered. There may be more hidden, but here's what I found:
192.168.1.99:199/jsBase/lib/jquery.js?version=@WebVersion​
192.168.1.99:199/jsBase/widget/js/jquery.ui.core.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/jquery.ui.widget.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.password.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/jquery.base64.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/jquery.powertip.min.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/jquery.pubsub.js?version=@WebVersion@​
192.168.1.99:199/jsBase/common/extend.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/md5.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/base64.js?version=@WebVersion@​
192.168.1.99:199/jsCore/common.js?version=@WebVersion@​
192.168.1.99:199/js/publicFunc.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/sea.js?version=@WebVersion@​
192.168.1.99:199/jsBase/lib/seajs-text.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.tab.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.table.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.pagination.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.textfield.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.numberfield.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.datepicker.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.timefield.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.tip.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.dialog.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.ipfield.js?version=@WebVersion@​
192.168.1.99:199/jsBase/widget/js/dui.validator.js?version=@WebVersion@​
192.168.1.99:199/js/timeZoneExcel.js?version=@WebVersion@​

===========

Hoping in a future firmware update that a built-in sunrise/sunset feature will be added to the camera.
I just bought two 5442s from Andy and the two commands you posted above to switch to Day/Night still work fine for me.

I use a Linux cronjob with Sunwait to execute those two commands at sunrise and sunset. Works fine.
 

jaydeel

BIT Beta Team
Joined
Nov 9, 2016
Messages
794
Reaction score
787
Location
SF Bay Area
I also use Sunwait, but with with Task Scheduler.
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
280
Reaction score
357
Location
Alaska
Have been using the sunrise/sunset Windows utility with Dahua HFW5242H-Z6E cameras on a BI machine. Purchased two of the cameras at the same time and both have the same FW, etc. One would switch using the utility and the other would not.

The IP address of both cameras would PING. Plus both are accessible using BI for setting camera functions.

As a test, used the HTTP GET time function, as below, on both cameras with the HTTP string being used in the browser URL bar on the BI computer.

Code:
http://192.168.1.108/cgi-bin/global.cgi?action=getCurrentTime
One camera would display the time, while the second would produce a 404 Not Found error.

The problem camera was removed from the switch and powered down. When reconnected the same issue was present.

Next, using the camera GUI, initiated a "Factory Reset". IP address changed to default and then was changed back to the camera sub net on the BI machine. (Note: dual NIC system)

Tested and the issue is RESOLVED!!

For an unknown reason, the camera would not accept HTTP GET or SET statements sent either by using the browser URL or the sunset/sunrise Windows utility on the BI machine.
 

prsmith777

Pulling my weight
Joined
Dec 23, 2019
Messages
106
Reaction score
182
Location
Colorado
Late to the party, but just started fooling around with this.

I followed the Blue Iris integration on the first post and I have it working, I think. Ran into some difficulty with one camera not accepting username and password. What got it working was to try accessing cam using same http control url on IE...it asked for password and if I wanted to save the credentials... then it worked in BI. I'm not sure that is going to "stick" on reboots, etc.

Was wondering if there is a simple way to check to make sure the profiles are correct from the web interface. Perhaps there is a way to add a "D" or "N" on the image layout next to the time ?

I guess it should be obvious if I have the correct profile by looking at the images but I'm fairly new to this so it's not too clear to me.
 

looney2ns

IPCT Contributor
Joined
Sep 25, 2016
Messages
14,165
Reaction score
19,465
Location
Evansville, In. USA
Late to the party, but just started fooling around with this.

I followed the Blue Iris integration on the first post and I have it working, I think. Ran into some difficulty with one camera not accepting username and password. What got it working was to try accessing cam using same http control url on IE...it asked for password and if I wanted to save the credentials... then it worked in BI. I'm not sure that is going to "stick" on reboots, etc.

Was wondering if there is a simple way to check to make sure the profiles are correct from the web interface. Perhaps there is a way to add a "D" or "N" on the image layout next to the time ?

I guess it should be obvious if I have the correct profile by looking at the images but I'm fairly new to this so it's not too clear to me.
If you have the cams setting setup for day and night, it will be obvious if its working or not.
You can also access the Cams web gui and see if it changed there.
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
280
Reaction score
357
Location
Alaska
One can also check the Errors Log in the Sunrise Sunset Utility. On my system it is located in

Code:
c:> Program Files> DahuaSunriseSunsetUtility>DahuaSunriseSunsetErrors.txt
Your file location may be different.

Open the txt file and check for errors. If all is working, there will be no error messages. Only data as follows:

Utility_Log.PNG

Also, if the file gets too big, just delete as the utility will generate a new errors log.

As previously stated, check the UI to see when the cameras switched from night to day, etc. Often there will be a timeline marker when this occurs but sometimes not.
 

looney2ns

IPCT Contributor
Joined
Sep 25, 2016
Messages
14,165
Reaction score
19,465
Location
Evansville, In. USA
One can also check the Errors Log in the Sunrise Sunset Utility. On my system it is located in

Code:
c:> Program Files> DahuaSunriseSunsetUtility>DahuaSunriseSunsetErrors.txt
Your file location may be different.

Open the txt file and check for errors. If all is working, there will be no error messages. Only data as follows:

View attachment 138219

Also, if the file gets too big, just delete as the utility will generate a new errors log.

As previously stated, check the UI to see when the cameras switched from night to day, etc. Often there will be a timeline marker when this occurs but sometimes not.
He's not using the utility, he's using commands directly from Blue iris.
 
Joined
Aug 3, 2022
Messages
19
Reaction score
2
Location
La,ca
trying to autoupdate dahua camera day/night with this script on synology like someone had posted earlier in this thread but its not working...

!/bin/sh
location="LAX"
# we get all the web page
allfile=$( wget -qO- '
Transportation Security Administration | Transportation Security Administration');
# we get the original sunrise/sunset time values
sunrise_str=$(echo $allfile | sed -ne '/Sunrise/{s/.<Sunrise>\(.\)<\/Sunrise>.*/\1/p;q;}')
sunset_str=$(echo $allfile | sed -ne '/Sunset/{s/.<Sunset>\(.\)<\/Sunset>.*/\1/p;q;}')
# we convert time values to Time in 24-hour format
sunset=$(date --date="$sunset_str +20 minutes" +%T)
sunrise=$(date --date="$sunrise_str -20 minutes" +%T)
sunsetsec=$(date --date="$sunset_str +19 minutes" +%s)
/usr/bin/curl -s -g --digest -u admin:pw "
$
{sunrise}-${sunset}" >> timechange.log
now=$(date)
nowsec=$(date +%s)
sleeptime=$(( sunsetsec - nowsec ))
echo "$now Setting sunrise $sunrise, sunset $sunset in $sleeptime seconds" >> timechange.log
sleep $sleeptime
# insert code here to run at sunset +19 minutes


on output i'm getting the following errors

/bin/bash: !/bin/sh: No such file or directory
/bin/bash: line 5: $'\342\200\213': command not found
date: invalid date '\342\200\213 +20 minutes'
date: invalid date '\342\200\213 -20 minutes'
date: invalid date '\342\200\213 +19 minutes'
/bin/bash: line 18: : syntax error: operand expected (error token is "")
/bin/bash: line 19: $'\342\200\213': command not found
sleep: invalid time interval '\342\200\213'
Try 'sleep --help' for more information.

can anyone help with what needs to be changed please?
 

pbc

Pulling my weight
Joined
Jul 11, 2014
Messages
955
Reaction score
147
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



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:



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.

Hmmm...got this working fine yesterday, but then today it didn't change the camera to night mode.

In the actualy camera, does it matter if this setting is set to always enable day or night? I.e., as long as it says "Full time" shouldn't it work?

1663468305158.png
 
Top