Change Day Schedule on Dahua IP Camera via Dahua API

Does this in the first post work... and what's the hiccup with it (written back in 2017)?


That is what I mentioned in post #15 but it only works for the old GUI (orange/black/grey interface) and not the new GUI (white/blue interface).

Excerpts of it work with the new GUI, but not the whole thing.
 
If I knew how to do it, I would certainly be happy to do it. I don't understand it all, hence my willingness to PAY someone to do it. :)

I'm willing to be the guinea pig for testing it... lol.

I've written a few step-by-step guides before, for things I know ... check this one out: miniDSP C-DSP 8x12 DL Tuning Step by Step Guide

As you can see... I like pictures.

But the API stuff is above my noggin.

I'm actually in the middle of writing a review and setup guide for the StormAudio MK3 Processor. This is stuff I know and have been around since they started, so I understand it. Cameras and networking are a new learning curve for me.
 
Last edited:
One way to think of the API calls is that the URL is nothing more then a container that is used to send information (commands) to the camera. In many cases, the difficult part is finding the correct code (URL) to activate the needed camera function. The HTTP API from Dahua is one tool that can assist.

The API for day/night mode change is already done as the desired URL can be placed into a browser, sent to the camera and that function activated.

The Hubitat Hub is nothing more than a microcomputer that provides the following functions:

1) Uses an HTTP GET command and sends a command to the camera
2) Built in local sunset/rise times with adjustable time offset
3) A Rules Machine to setup a time schedule to activate a rule
4) A simplified system to construct a lighting on/off rule
5) A way to edit and update apps and code
6) Ability to import and export code (apps)
7) Is functional without the need for internet connectivity

In order to be successful with the HUB, if would be good if that individual has some prior experience with the device. Otherwise, there would be a substantial issue with frustration as a first time user.

Other alternatives for these API functions could be the Raspberry PI, Windows Power Shell, Task Scheduler, etc.

Perhaps the current Web 4 Dahua Sunrise/Sunset Service Manager could be updated to include Web 5 cameras, as it is no longer supported.

As an alternative, consider engaging a developer in India as an idea. Most likely more bang for the buck.

 
I've hired freelancers to do things, so that might be a viable option.

I also have Home Assistant. I haven't used it because I haven't found a real use for it yet. We have our lights and shades automated with Lutron for the ones we want to be automated.

But even HA might be more than I want to learn, as it appears to need shell commands and such for the HTTP GET. Of course, may as well just use Windows Power Shell on the computer with the cameras, so hiring a freelancer to help with that might be an idea.
 
It looks like HA may process HTTP GET calls. However, can not check as do not run HA.

Here is a video that may help.



Keep in mind that HA most likely has to be on the same network at the Dahua cameras. In my case, one HUB is used for home automation requirements (192.168.1.xxx) and then a 2nd HUB on the camera network (192.168.55.xxx) for those day/night mode change activities. i.e. the BI computer has zero internet connectivity.

Perhaps you have found a solution that will work for you needs......
 
  • Like
Reactions: CanCuba
I watched it. He's using a push button to make the call. I guess I'll have to train our cat... lol.

I need to look at it and see, surely there is an time scheduler I can set to make the call.
 
What is needed in Home Assistant is support for local sunrise and set times plus a positive or negative time offset.

When setting up HA did it require your actual lat/long as one of the input fields? If yes, then it most likely will have local sunset and sunrise as an option for rule making. If not available as part of HA, then perhaps someone in the HA community has written an APP to provide that function that can be added to HA.

Then it is a matter of creating a rule in HA to fire the HTTP GET say 30 minutes before local sunset to change the camera from day to night mode. And for night about 30 minutes after sunrise for the day camera mode. Two different rules in this case.

Also check with the folks in the HA community as they often have good advice on solutions.

Here is a sample Hubitat log for my local camera mode changes based on LUX.

sample_log.PNG
 
  • Like
Reactions: CanCuba
Nice comparison of Hubitat vs Home Assistant.

 
For the URLs to get, confirming these are the two I will use with my password and camera IP address:

Day Switch for Sunrise Trigger

Code:
http://admin:password@192.168.55.156/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].TimeSectionV2[0][0]=00:00:00-24:00:00 Day


Night Switch for Sunset Trigger

Code:
http://admin:password@192.168.55.156/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].TimeSectionV2[0][0]=00:00:00-24:00:00 Night

And I'll have to setup this automation for each camera.
 
So there is only one configuration.yaml file that can be edited for the HTTP GET command. He says add it here, but there are two triggers, one for sunrise and one for sunset. They are going to call this file up to process the HTTP call.

I'll post in the HA forum to see if anyone can suggest the commands to have sunrise and sunset trigger the right one needed. I'm sure there is command code for it, but I have no clue what it is.

1722307507932.png
 
lol.... too much information and too much to try to comprehend for me... sorry.

I posted in the HA forum. Let's see if I get some dumbed-down responses. Too much is taken for granted in a lot of these responses, with steps missing for the hillbilly.
 
Yes, for each camera as the code is specific to that camera's IP address. Thus the same code but only change the IP address.

Then you will need the same listing, but this time for night. They could be integrated into one rule, but keeping one rule for day and another for night makes thing simpler. One could also use a variable to change the word "Day" to "Night" based on the time of day. Something to consider for any future revisions.

There is no need to set the time. As listed 00:00 to 24:00 need not change.

However, Dahua uses a month code in the date. Did look for a wildcard or another way to eliminate that function, but no go. Thus that number will have to be changed once a month or the next month will not change.

In the code, this part MUST be changed to reflect the current month.

TimeSectionV2[0]

In Dahua speak, January is month 0, while July is month 6. For July change the [0] to [6] and for August [7]. The month update code APP is run every day at 1 minute after midnight local time or it could be run just a few seconds after midnight.

The key, is to get the month to change from all orange to all purple at your local sunset plus a time offset. The the other part for the month change can be added as needed. Or, just update the code for that one number once per month.

On my end, placed a variable that is updated once per day based on the name of the month that is extracted from a date string. Thus it does a comparison. If the month is "Jul" and if TRUE, then set the global variable to 6, etc.

Once this all works, then all of your Web 4 cameras can be added using a different API to have all camera day/night mode switching done in HA.
 
Some ideal for the HA community...


 
Can both of the commands run at the same time each day... or do I need to trigger the Day URL at sunrise and Night URL at sunset?
To work the command must be run when you desire to change camera modes. One command prior to sunset. The other command after sunrise. Thus two rules one for day to night mode and then the reverse to night to day mode.
 
Yeah... this is way above my skill set. This is just way too much information to absorb and figure out. I thought maybe it would be something simple, but it ain't for me.

The freelancer will have to do for this, or I'll have to live with setting the time plan for each camera and live with it being off a good bit from beginning of the month to end.

Gotta have a month code app to change the month... whew... just when you think you might have a grip on it... boom... add another "gotcha". lol
 
TimeSectionV2[0]

In Dahua speak, January is month 0, while July is month 6. For July change the [0] to [6] and for August [7]. The month update code APP is run every day at 1 minute after midnight local time or it could be run just a few seconds after midnight.
Where would I find this "month update code APP" that has to run at 12:01 or actually 00:01 each day?

Feeding this info to a freelancer.