Day Night Switch Using HTTP - Camera Resets to Auto Exposure

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
449
Reaction score
657
Location
Alaska
Using a HFW-5849 bullet Dahua camera and NVR with the following HTTP URL's with a FireFox browser. The camera changes from day to night and back again maintaining its settings.

The Profile Management is listed as Full Time Night or Full Time Day when the URL is run which is what is expected.

Color to B/W - Camera 2 - Night
Code:
http://user:assword@192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[1].NightOptions.SwitchMode=3
B/W to color - Camera 2 -Day
Code:
http://user:asword@192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[1].NightOptions.SwitchMode=0
Format Defined
NightOptions.SwitchMode
0: NoSwitch, always use day options.
1: Switch depends on brightness.
2: Switch depends on time, switch to NightOptions
when time is after sunset time and before sunrise.
3: NoSwitch, always use NightOptions.
4: No switch, always use NormalOptions.

However, when used with a HFW-5242 Dahua camera the day night switch occurs but with an exposure issue. The night and day exposure Mode settings are both set for (Mode) Manual, (Shutter) Customized Range. When the HTTP URL is processed the Mode changes to Auto along with some other exposure settings.

The 5242 was reset to default using the UI five times. New settings were put in, but will not stay locked as expected.

Any suggestions on what to change so that all of the Exposure conditions remain as set?
 

wittaj

IPCT Contributor
Joined
Apr 28, 2019
Messages
25,124
Reaction score
48,970
Location
USA
I would try using Internet Explorer as some of the cameras are very quarky about using any other browser. One camera may be fine with Firefox and the next camera won't hold its settings.
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
449
Reaction score
657
Location
Alaska
The overall issue is that when the HTTP GET statement is run using the Hubitat Hub the same problem happens. The hub connects to the NVR on the LAN. No browser is used. The hub has a 'run action' button for testing.

Tried this last night and when sunup happened the 5849 camera switches correctly and retains it settings. ( i.e. went from B/W to color) While the other camera (5242) does not. (FW update - maybe?)

Just now tested with the hub by changing from day to night and back to day. The 5849 does not change settings. The 5242 changes from manual to auto. Mabe using a bigger baseball bat would be effective!!
 

jack7

Getting comfortable
Joined
Mar 21, 2019
Messages
323
Reaction score
250
Location
USA
To change all Day/Night Profile settings when the camera changes the IR/night vision on or off, try this.

In newer firmware that does not require a plug-in, use Web UI to set Profile Management to Day/Night.
For older firmware requiring a plug-in, the following command should do the same thing.
If you ever change any settings in the Profiles and Save using the Web UI, that will disable it and you have to use the URL again.
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
449
Reaction score
657
Location
Alaska
The SET statement did run. Bounced back an OK to the browser.

The goal is to switch between day and night without effecting any of the exposure settings. One camera does that well. The other camera resets exposure from manual to auto.

Also tried to SET the sunset and sunrise times into the camera as another possible workaround. That did work as the data can be read out with the GET statement. However, when the time in the statement matches time nothing happens. i.e. no change from day to night, etc.

Also did not notice any change in "Schedule" as the orange and black slider did not reflect the new sunset time. Perhaps not using the correct API.

This code below is being used as a test. It will set the times in the camera as indicated but no day to night action occurs.

Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[7].NightOptions.SunsetHour=17&VideoInOptions[7].NightOptions.SunsetMinute=28&VideoInOptions[7].NightOptions.SunsetSecond=00
This reads back the code from camera 7.

Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=getConfig&name=VideoInOptions[7].NightOptions.SunsetHour&name=VideoInOptions[7].NightOptions.SunsetMinute&name=VideoInOptions[7].NightOptions.SunsetSecond
If the original code worked in both cameras, then the issue would be solved. Not sure why one camera performs as it should and the other does not.
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
449
Reaction score
657
Location
Alaska
Yes, did look at that but the object is to run the sunset/sunup from the Hubitat Hub. Overall it works with one camera on Hubitat.

Now to figure out why it will not work with the other Dahua camera. Something strange going on with Night in manual mode that likes to switch back to auto. Even when using the API to set ExposureMode to manual it will not change the night mode. But it will now keep the Day in manual.

May have to check with Andy and see if there is a new FW update for that camera as it should play as well as the 5849. The the 5242 just does not like to play well with others!!
 

Serodgers

Getting the hang of it
Joined
Dec 17, 2018
Messages
74
Reaction score
51
Location
PC FL
I use a script from my Homeseer setup to change between day and night modes. I use the url from the util,posted and once iI figured out it was using digest authentication it works.

Have used it on two of my camera to have better event driven control using Homeseer. A IPC-HDW5442TM-AS and IPC-HDW2231R-ZS.


Sent from my iPad using Tapatalk
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
449
Reaction score
657
Location
Alaska
Please share your HTTP API that was used.

It appears that the Hubitat Hub is working fine in processing the HTTP GET request.

It is my opinion, is that the 5242 camera when switching to night from day (both manual settings) is auto switching to B/W from manual perhaps due to an illumination issue. At the moment that is the problem that requires addressing. This camera has IR.

The 5849 camera that works is color and B/W with no IR. It uses white light LEDs for night illumination and will not respond to IR illumination.

As a side note, the Homeseer products look a bit on the high side. For z Wave switches check out "The Smartest House".
 

Serodgers

Getting the hang of it
Joined
Dec 17, 2018
Messages
74
Reaction score
51
Location
PC FL
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
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
449
Reaction score
657
Location
Alaska
Appreciate the code posting.

Gave it a try in FF and IE and the browsers returns OK for all three examples. Thus it ran, but no change from color to B/W, etc. Will test again when the sun is out.

Set it up for camera 6 as follows:

Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[5].Config[0]=0
Thanks again
 

biggen

Known around here
Joined
May 6, 2018
Messages
2,590
Reaction score
2,895
To go to night mode try: ipaddress/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1

And to go to day mode try: ipaddress/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=0
 

Serodgers

Getting the hang of it
Joined
Dec 17, 2018
Messages
74
Reaction score
51
Location
PC FL
Appreciate the code posting.

Gave it a try in FF and IE and the browsers returns OK for all three examples. Thus it ran, but no change from color to B/W, etc. Will test again when the sun is out.

Set it up for camera 6 as follows:

Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[5].Config[0]=0
Thanks again
It just changes the profile in use not color or b/w. Manually switch to day and setup how you want it to operate. Then switch to night and do the same. Either profile can be set to Color, b/w or auto.

Execute command to switch day profile. Look at camera page to see it is in proper mode. Switch to night with url and check again. All my Dauha’s switch correctly with those urls. I use them from Homeseer events to change two of mine.


Sent from my iPad using Tapatalk
 

Alaska Country

Getting comfortable
Joined
Jun 10, 2021
Messages
449
Reaction score
657
Location
Alaska
Tried a number of suggestions (thank you to those that responded) for changing Dahua cameras from "Day" to "Night" mode and back again when using a Dahua NVR5-216-16P-I/L. In this approach, the change is made to the "Full Time Day" or "Full Time Night" mode. Tested using a Dahua NVR with Dahua bullet cameras 5849, 5242, 2831 and 7442. Result: all switched at the correct time.

The HTTP API code, when entered into the URL bar of IE or FF, will pop up a screen with a request for the user and password of the camera selected. Note that each camera is numbered, for logic purposes, stating with 0. For a camera on POE port 6, the logic number entered into the URL bar would be 5. (i.e. N-1)

Camera 6 - POE Port 6 - Sets Color to B/W - Deck (Logic 5)
Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[5].NightOptions.SwitchMode=3&
VideoInOptions[5].NightOptions.DayNightColor=2
Camera 6 - POE Port 6 - Sets B/W to Color - Deck (Logic 5)
Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[5].NightOptions.SwitchMode=0&
VideoInOptions[5].NightOptions.DayNightColor=0
Terms added for reference

NightOptions.SwitchMode
0: NoSwitch, always use day options.
1: Switch depends on brightness.
2: Switch depends on time, switch to NightOptions
when time is after sunset time and before sunrise.
3: NoSwitch, always use NightOptions.
4: No switch, always use NormalOptions.

NightOptions.DayNightColor
0: always multicolor
1: autoswitch along with brightness
2: always monochrome

Dahua cameras (one or all) can be checked to determine if the data sent to the camera is actually in the camera using the "GET" function of the API. i.e. this retrieves data and posts the results to your browser. While the "SET" function changes camera data and if successful responds with an "OK", or "Error" for a failure or other message.

The below will retrieve the status of "Switch Mode" and "Day Night Color" for camera 6 - POE Port 6 - logic 5.

Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=getConfig&name=VideoInOptions[5].NightOptions.SwitchMode&
name=VideoInOptions[5].NightOptions.DayNightColor
For Night settings the response would be:

table.VideoInOptions[5].NightOptions.SwitchMode=3
table.VideoInOptions[5].NightOptions.DayNightColor=2

For Day settings the response would be:

table.VideoInOptions[5].NightOptions.SwitchMode=0
table.VideoInOptions[5].NightOptions.DayNightColor=0


To retrieve all "Video In Options" for this same camera use:
Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=getConfig&name=VideoInOptions[5]
For all cameras (0-15). Same code as above but with the brackets and 5 removed.
Code:
http://192.168.1.108/cgi-bin/configManager.cgi?action=getConfig&name=VideoInOptions
Switching for eight cameras is being controlled using a Hubitat C7 Hub. This device generates the sunrise/sunset time for your location plus a time offset if desired. The "Rules Machine" allows for HTTP GET requests and thus works to change Dahua cameras from Day to Night and back again depending on local sunup/sundown times.

To utilize, rules were made, one for each camera for sunup and sundown including a time offset. (Sundown minus 45 mins - Sunup plus 45 mins) Each HTTP GET also requires the addition of user, password and HTTP port number as part of the URL.

It was also necessary to add a short delay between each of the "actions" as the Hub processed at a speed that the NVR would not accept. Once a two second delay was added between each sent "action" all eight cameras successfully switched.
 
Top