Dahua day/night switch utility - DahuaSunriseSunset

Discussion in 'Dahua' started by bp2008, Mar 29, 2017.

Share This Page

  1. OnePunch

    OnePunch n3wb

    Joined:
    Mar 31, 2018
    Messages:
    18
    Likes Received:
    3
    In any case, your app now allows me to use the WDR backlight setting as switching between "night" and "normal" now actually works and can be used as an alternate settings scheme for anyone else.

    Thanks again!
     
    bp2008 likes this.
  2. patrocle

    patrocle Getting the hang of it

    Joined:
    Jun 5, 2015
    Messages:
    437
    Likes Received:
    55
    Location:
    California
    For some reason i can't get this to work on my Dahua IPC-HFW5231E-Z12E

    I have it setup as "Full" time, and all the info entered into the "Dahua Utility app". I can see that something is happening when i click "simulate sunrise or sunset" as the camera image goes darker or lights up" , but will not go to the zoom & focus where it's suppose to go!

    Been trying this for quite sometime and i can not get it to work. If i move in cam settings the day and night profiles at zoom and focus where suppose to be, they go back all way zoom 1020 and focus 1800 in to max.

    I am doing something wrong or the utility may not send the right commands to the camera?

    Thanks!
    P.
     
  3. EMPIRETECANDY

    EMPIRETECANDY IPCT Vendor

    Joined:
    Nov 8, 2016
    Messages:
    2,357
    Likes Received:
    4,323
    Location:
    HONGKONG
    try to update to the newest firmware i posted, the new firmware has an update for the day/night switch delay.
     
    patrocle likes this.
  4. patrocle

    patrocle Getting the hang of it

    Joined:
    Jun 5, 2015
    Messages:
    437
    Likes Received:
    55
    Location:
    California
    Andy, Thank you for that info. Will have a look.
    Regards,
    P.
     
    EMPIRETECANDY likes this.
  5. Burton_Flooring

    Burton_Flooring Pulling my weight

    Joined:
    Apr 20, 2018
    Messages:
    125
    Likes Received:
    154
    Thank you, Thank you , Thank you @bp2008 ! Using this to switch between general overview of an area during day, to license plate reading at night. Works!
     
  6. bigrob444

    bigrob444 n3wb

    Joined:
    Apr 8, 2017
    Messages:
    11
    Likes Received:
    7
    Really great utility, thank you for this!
     
  7. Carver

    Carver n3wb

    Joined:
    Dec 11, 2017
    Messages:
    17
    Likes Received:
    4
    Thank you for this great utility :) However, there are some minor glitches.
    Running Version 1.3.1 on Windows 10, the input fields doesn't take care of floating point
    numbers. E.g. a sunrise offset of -0.5 becomes -5 and same issue with longitude and latitude.
    Configuring values directly in DahuaSunriseSunsetConfig.cfg works flawlessly.

    Suggestions: Why not name the DahuaSunriseSunsetErrors.txt as DahuaSunriseSunsetLog.txt
    since there are also normal service activities logged? - I was a litte confused after entering the
    necessary data because there are no OK/Cancel buttons. Why not add? They're already paid ;)

    Best regards, Carver
     
    vidmo likes this.
  8. HoosierD

    HoosierD n3wb

    Joined:
    May 29, 2018
    Messages:
    23
    Likes Received:
    15
    Location:
    Ventura, California
    Thank you @bp2008. I was wondering how to do this and stumbled on the tread in the Cliff Notes. Love it!
     
  9. Dseg42

    Dseg42 Getting the hang of it

    Joined:
    Apr 17, 2016
    Messages:
    107
    Likes Received:
    1
  10. WSCam

    WSCam n3wb

    Joined:
    Sep 24, 2018
    Messages:
    4
    Likes Received:
    1
    Location:
    Tacoma, WA
    By the way, if you have a spiffy Dahua with 2 cameras in a single body, this program will only adjust the first one (channel zero).

    You can manually switch profiles on the 2nd camera (channel one) with URLs like:
    http://user:password@hostname/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[<channel>].Config[0]=<0 for day, 1 for night>

    (the "VideoInMode" is where you switch between the channels... [0] for camera 1, [1] for camera 2)

    e.g. if I wanted to switch the 2nd camera to night profile, I'd request:
    http://user:pass@host/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[1].Config[0]=1

    I don't know if that's something that could be added... some configuration per camera to set it to channel 0 (the default) or channel 1 (if you do happen to have something like the IPC-HDBW4231FP-E2-M)
     
  11. bp2008

    bp2008 Staff Member

    Joined:
    Mar 10, 2014
    Messages:
    8,064
    Likes Received:
    4,896
    I don't know when I'll have time again to update this app again, but it shouldn't be a big deal making it configurable which channel is specified. Then you'd just treat it as two separate cameras in this app.
     
    fenderman likes this.
  12. WSCam

    WSCam n3wb

    Joined:
    Sep 24, 2018
    Messages:
    4
    Likes Received:
    1
    Location:
    Tacoma, WA
    I mangled together some code changes to include a box for channel # and included that in the URL passed to the camera. As you mentioned, I just had to add each camera with channel 0 and 1. Since the dual cam doesn't have focus or zoom there were no changes to those features. It's just a handful of changes and maybe when I've tested it out more I can see if you're interested in merging the changes. It tested okay but I haven't actually used it in the real world and I'd want to see how it performs before I called it good.

    EDIT: I did have to make a few adjustments:
    1) I added logging so that it logs the IP:port for each camera it's adjusting, just so I could track the specific actions (e.g. "Setting camera 10.1.1.255:80 channel 0 to Day")
    2) The parallelism seems to cause trouble when trying to set both channels at the same time. I ended up disabling the parallelism (set it to a max of 1 thread) and added a 1-second delay between commands for the day/night request. Without those changes, it was trying to set both at once and typically only one channel or the other actually accepted it and the other didn't make the change.

    Removing the parallelism isn't a big deal for me... I'm only doing it on the one camera body for now and even if I add in my other Dahuas that's only 3 more total. I can live with having 5 cameras set in a 5 second span rather than all at once.

    Overall I'm pleased with how it's working now and I do appreciate the effort you put into it. My other option was to setup a script to send the requests with curl, but I'd still have to figure out a way to do it at dynamic times based on the sunrise/sunset. My home automation system does that but I didn't want to try tying into that unless nothing else came along. Having this run as a service on the same computer running BI is very workable.
     
    Last edited: Oct 20, 2018
  13. WSCam

    WSCam n3wb

    Joined:
    Sep 24, 2018
    Messages:
    4
    Likes Received:
    1
    Location:
    Tacoma, WA
    By the way, at least if you're just changing day/night (not sure about focus/zoom), the only permissions the user apparently needs is "AV Parameter". So if you want to create a user just for this service (and I recommend it), that's the only one it needs to have.
     
    Rhodesy likes this.
  14. mlapaglia

    mlapaglia Pulling my weight

    Joined:
    Apr 6, 2016
    Messages:
    328
    Likes Received:
    139
    I've created a fork of this project to support Hikvision cameras. I can help implement features if anybody needs something mlapaglia/IpCameraSunriseSunset
     
  15. PeskyPete

    PeskyPete Getting the hang of it

    Joined:
    Nov 14, 2018
    Messages:
    28
    Likes Received:
    28
    Location:
    Canada
    Wanted to say thanks so much to the op for sharing this program.
    Works great! I haven't read the entire thread, but 'fetching' the zoom & focus numbers worked well, as I originally took the values from the slider bars within the Dahua app. which was incorrect, of course!
     
    bp2008 likes this.
  16. jaydeel

    jaydeel BIT Beta Team

    Joined:
    Nov 9, 2016
    Messages:
    105
    Likes Received:
    80
    Location:
    SF Bay Area
    @bp2008 Can the ‘Simulate Sunrise’ and ‘Simulate Sunset’ functions be executed from the command line?

    I ask because I’d like to assign these actions to two camera presets.

    The reason why is that I’ve errantly sent Dahua’s autofocus api http autofocus command at night with horrible results (this is on a 5231; Dahua’s algorithm seems unable to focus in low light). Clicking the ‘Simulate Sunset’ button always fixes the focus, but I must access my BI machine to accomplish this.
     
    Last edited: Feb 6, 2019
  17. bp2008

    bp2008 Staff Member

    Joined:
    Mar 10, 2014
    Messages:
    8,064
    Likes Received:
    4,896
    @jaydeel

    No, they can't. You should be able to modify some BI camera presets to make them send an appropriate API request directly to the camera, without the need for an external program.

    These are all the commands which the DahuaSunriseSunset app is able to send:

    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
    Set zoom and focus (enter numbers for zoom and focus):
    Code:
    /cgi-bin/devVideoInput.cgi?action=adjustFocus&focus=0&zoom=0
    Get current zoom and focus numbers from camera (use this to find out which focus and zoom values will work well when adjusting camera zoom/focus):
    Code:
    /cgi-bin/devVideoInput.cgi?action=getFocusStatus
    Just instruct the camera to autofocus:
    Code:
    /cgi-bin/devVideoInput.cgi?action=autoFocus
     
    Last edited: Feb 6, 2019
    NetHunter likes this.
  18. jaydeel

    jaydeel BIT Beta Team

    Joined:
    Nov 9, 2016
    Messages:
    105
    Likes Received:
    80
    Location:
    SF Bay Area
    Thanks. I have experimented with a script to do this, but i’ve not succeeded yet in reproducing your perfect result. You send a sequence of repeat zoom/focus commands if I recall correctly. I may have the timing or sequence wrong. I’ll do more testing.
     
  19. bp2008

    bp2008 Staff Member

    Joined:
    Mar 10, 2014
    Messages:
    8,064
    Likes Received:
    4,896
    Well the adjustFocus command is pretty buggy in my experience, and must be sent multiple times in order to achieve the desired result. It made me a little bit crazy trying to figure out the most reliable number of repeats.
     
  20. jaydeel

    jaydeel BIT Beta Team

    Joined:
    Nov 9, 2016
    Messages:
    105
    Likes Received:
    80
    Location:
    SF Bay Area
    Exactly what I was hoping to avoid :)

    Did you settle on a single value for the repeats, or is it programmatically determined?