NodeJS Module: node-dahua-api

Discussion in 'Dahua' started by nayr, Feb 17, 2016.

Share This Page

  1. tangent

    tangent IPCT Contributor

    Joined:
    May 12, 2016
    Messages:
    3,837
    Likes Received:
    2,501
    @nayr hasn't been active on the forum in a while, but may respond to a pull request.
     
  2. Sitnalta

    Sitnalta Young grasshopper

    Joined:
    Apr 23, 2017
    Messages:
    38
    Likes Received:
    19
    Would be nice if somebody could make a Home Assistant component from the github code :love:
     
  3. tangent

    tangent IPCT Contributor

    Joined:
    May 12, 2016
    Messages:
    3,837
    Likes Received:
    2,501
    You can use the Amcrest component (dahua makes amcrest). It looks like the developer may have been working off an old version of the HTTP API.
    This is the most recent version of the API that's posted publicly that I'm aware of: https://s3.amazonaws.com/amcrest-files/Amcrest+HTTP+API+3.2017.pdf (v2.12)

    Consider contacting the developers of the amcrest component with feature requests and giving them a link to the newer documentation.
     
    mat200 likes this.
  4. Carver

    Carver n3wb

    Joined:
    Dec 11, 2017
    Messages:
    17
    Likes Received:
    4
    I'd like to trigger a "Lens Init". The API (V1.67) doesn't include a suitable CGI command.
    Is it possible with node.js?

    Best regards, Carver
     
  5. tangent

    tangent IPCT Contributor

    Joined:
    May 12, 2016
    Messages:
    3,837
    Likes Received:
    2,501
  6. Carver

    Carver n3wb

    Joined:
    Dec 11, 2017
    Messages:
    17
    Likes Received:
    4
    @tangent: Thanks, but there's also no Lens Init available. And to do that with node-dahua-api (if possible), I don't know the command.
     
  7. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    148
    Likes Received:
    18
    Location:
    Wellington, New Zealand
    Anyone used this on later nvrs, specially a DHI-NVR5216 and noticed any of the functions not working?
     
  8. tangent

    tangent IPCT Contributor

    Joined:
    May 12, 2016
    Messages:
    3,837
    Likes Received:
    2,501
    What sort of problems are you having?
     
  9. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    148
    Likes Received:
    18
    Location:
    Wellington, New Zealand
    Things like snapshot (which uses the following url: http://<ip>/cgi-bin/snapshot.cgi?channel=1) now gets a

    Error
    ErrorID=5, Detail=Server internal error!
     
  10. tangent

    tangent IPCT Contributor

    Joined:
    May 12, 2016
    Messages:
    3,837
    Likes Received:
    2,501
    I'd go back to the Dahua HTTP API documentation (amcrest version linked above) and test the basic functions in your web browser.

    I'm not sure if the nodejs code has been updated to use digest authentication which newer cameras and nvrs are using. You may have to manually make some changes.
     
  11. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    148
    Likes Received:
    18
    Location:
    Wellington, New Zealand
    Yeah did that...a lot of those functions don't work any more. Like snapshot.cgi, getConfig?action=ChannelTitle, the odd one does though.

    Looks like in this device, and others? they've changed the api. Using fiddler I think i managed to figure out they've gone to a RPC2 call where json is posted. ie I see now that I can call the RPC2 with a json string containing "method":"configManager.getConfig","params":{"name":"ChannelTitle"} (and a few more and it seems to replicate that function that used to be in the http api call for configManger?action=getConfig&name=ChannelTitle.

    So people using this api may start encountering issues on different hardware
     
  12. tangent

    tangent IPCT Contributor

    Joined:
    May 12, 2016
    Messages:
    3,837
    Likes Received:
    2,501
    What firmware version are you running? Unfortunately Dahua doesn't make the API publicly available anymore and only provides it to people who sign an NDA.
    This combined with their disregard for the license terms of open source software are a bit irritating.
     
  13. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    148
    Likes Received:
    18
    Location:
    Wellington, New Zealand
    I think this lists the fw I’m running DHI-NVR5216-16P-4KS2 - HTPP API (web fw 3.2.3.1829) - Different
     
  14. eengineer

    eengineer n3wb

    Joined:
    Jul 17, 2018
    Messages:
    14
    Likes Received:
    7
    Location:
    Europe
    Did Nayr leave the forum? :(

    I'm looking into getting both motion and IVS into MQTT messages for some of my cameras...
     
  15. psycik

    psycik Getting the hang of it

    Joined:
    Dec 9, 2015
    Messages:
    148
    Likes Received:
    18
    Location:
    Wellington, New Zealand
    I have a service that does it (docker/python service to mqtt - psyciknz/CameraEvents ), which can also send image content for notifications. But the snapshot function is not working for my particular unit.

    And the only other issue it might have is getting the channel list for an nvr. But it still sends motion alerts out.
     
    trollmar and eengineer like this.
  16. eengineer

    eengineer n3wb

    Joined:
    Jul 17, 2018
    Messages:
    14
    Likes Received:
    7
    Location:
    Europe
    I will test that tomorrow, buddy. Nice! We just installed a Dahua A46 as a baby monitor and it replaced a hacked Xiaomi Dafang running Dafang Hacks with the MQTT motion detection alerts... so I need something similar.
     
  17. tangent

    tangent IPCT Contributor

    Joined:
    May 12, 2016
    Messages:
    3,837
    Likes Received:
    2,501
    He hasn't been active here in quite a while. He had a lot of more important things going on in his life.
     
    Last edited: Feb 14, 2019
  18. wrybread

    wrybread Getting the hang of it

    Joined:
    Sep 12, 2018
    Messages:
    117
    Likes Received:
    49
    Location:
    San Francisco
    Yup!

    http://<IP>/cgi-bin/ptz.cgi?action=getPresets&channel=0

    My Dahua SD49225T-HN returns:

    Code:
    presets[0].Index=1
    presets[0].Name=Whatever
    presets[0].Type=0
    presets[1].Index=2
    presets[1].Name=Whatever Else
    presets[1].Type=0
    presets[2].Index=3
    presets[2].Name=Whatever Else Again
    presets[2].Type=0
    
    etc
    
    And I agree with you, very very useful.

    Incidentally I found it in the Amcrest API, not the Dahua API, even though I'm using a Dahua camera...

    https://s3.amazonaws.com/amcrest-files/Amcrest+HTTP+API+3.2017.pdf
     
    Last edited: Feb 15, 2019
    tangent likes this.
  19. trollmar

    trollmar n3wb

    Joined:
    Feb 9, 2017
    Messages:
    20
    Likes Received:
    0
    Hi cool!
    Thx for sharing.

    Maybe a stupid question but how do I install it on ..lets say ubuntu?
    Gitclone it ..and then? ;-)