NodeJS Module: node-dahua-api

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,346
Reaction score
5,261
Location
Denver, CO
sure, the API being: /cgi-bin/configManager.cgi?action=setConfig&VideoWidget[0].CustomTitle[1].Text=

I'll add this function to this project in the next version.
 

randyth

Young grasshopper
Joined
Aug 26, 2015
Messages
72
Reaction score
6
sure, the API being: /cgi-bin/configManager.cgi?action=setConfig&VideoWidget[0].CustomTitle[1].Text=

I'll add this function to this project in the next version.

Thank you! This can be very interesting to play with. Do you also know if it is possible to enable/disable a certain custom text-overlay by API?
I never knew these Dahua cams are so scriptable...

On a side-note: I seem to get less to none garbled snapshots after playing the the snapshot settings in the camera (I lowered the quality and set interval on 1 sec).
 
Last edited by a moderator:

KhurramF

n3wb
Joined
Aug 10, 2016
Messages
3
Reaction score
0
I finally got to nodejs on my ubuntu 16.04 system (I have been on a longish vacation). I have installed nodejs 4.2.6, npm, pm2 and node-dahua-api (last two globally). Runing "npm list -g --depth=0" gives:
/usr/local/lib
node-dahua-api@1.0.2
pm2@1.1.3
When I try to run "sudo node dahua.js", I get the following:
module.js:328
throw err;
^

Error: Cannot find module 'node-dahua-api'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/root/scripts/dahua/dahua.js:2:23)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
So what am I doing wrong here?
Thanks.
 
Joined
Nov 14, 2016
Messages
1
Reaction score
0
Here is what I get trying to install the API

sbrown@sbrown-virtual-machine:~$ sudo npm install node-dahua-api


> ref@1.3.2 install /home/sbrown/node_modules/net-keepalive/node_modules/ref

> node-gyp rebuild


/bin/sh: 1: node: not found

gyp: Call to 'node -e "require('nan')"' returned exit status 127 while in binding.gyp. while trying to load binding.gyp

gyp ERR! configure error

gyp ERR! stack Error: `gyp` failed with exit code: 1

gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:354:16)

gyp ERR! stack at emitTwo (events.js:87:13)

gyp ERR! stack at ChildProcess.emit (events.js:172:7)

gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)

gyp ERR! System Linux 4.4.0-45-generic

gyp ERR! command "/usr/bin/nodejs" "/usr/bin/node-gyp" "rebuild"

gyp ERR! cwd /home/sbrown/node_modules/net-keepalive/node_modules/ref

gyp ERR! node -v v4.2.6

gyp ERR! node-gyp -v v3.0.3

gyp ERR! not ok

/home/sbrown

└── (empty)


npm WARN enoent ENOENT: no such file or directory, open '/home/sbrown/package.json'

npm WARN sbrown No description

npm WARN sbrown No repository field.

npm WARN sbrown No README data

npm WARN sbrown No license field.

npm ERR! Linux 4.4.0-45-generic

npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "node-dahua-api"

npm ERR! node v4.2.6

npm ERR! npm v3.5.2

npm ERR! code ELIFECYCLE


npm ERR! ref@1.3.2 install: `node-gyp rebuild`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the ref@1.3.2 install script 'node-gyp rebuild'.

npm ERR! Make sure you have the latest version of node.js and npm installed.

npm ERR! If you do, this is most likely a problem with the ref package,

npm ERR! not with npm itself.

npm ERR! Tell the author that this fails on your system:

npm ERR! node-gyp rebuild

npm ERR! You can get information on how to open an issue for this project with:

npm ERR! npm bugs ref

npm ERR! Or if that isn't available, you can get their info via:

npm ERR! npm owner ls ref

npm ERR! There is likely additional logging output above.


npm ERR! Please include the following file with any support request:

npm ERR! /home/sbrown/npm-debug.log

npm ERR! code 1
 

uronito

n3wb
Joined
Oct 19, 2016
Messages
7
Reaction score
0
With the last firmware of dahua ip Cam (09/10/2016) Dahua Node Api cant connect to the cam, i think could be by autenthication method.

ipcc for domoticz cant connect to the cam at last firmware.

With the earlier firmware can connect.

In the new firmware, dahua uses digest autenthication, Can you implementing?

Thanks!!!!

Regards
 

nspinelli

n3wb
Joined
Dec 18, 2016
Messages
2
Reaction score
0
Hello - I am having some issues trying to get this working.
Camera: Dahua IPC-HFW4300S

Here is the error message that i am getting when i set trace to true:
ReferenceError: options is not defined
at handleConnection (/Users/Desktop/68/node_modules/node-dahua-api/dahua.js:176:43)
at Socket.<anonymous> (/Users/Desktop/68/node_modules/node-dahua-api/dahua.js:35:10)
at Socket.g (events.js:292:16)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1077:10)

When i have the trace set to false it connects but none of the triggers are firing. I am using the example that you have provided on github.

When i set the options in the Dahua.js file this is the message that i am receiving:
Connected to 10.3.3.201:80
Data: HTTP/1.0 200 OK
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Dec 2099 16:00:00 GMT
Connection: close
Content-Type: multipart/x-mixed-replace; boundary=myboundary

Any ideas on what I am doing wrong? Any insight would be much appreciated!!
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,346
Reaction score
5,261
Location
Denver, CO
it looks like your config might be malformed; it says options is not defined.

@uronito, what camera and firmware are you having trouble with?
 

uronito

n3wb
Joined
Oct 19, 2016
Messages
7
Reaction score
0
Hi @nayr ,

My cam is Dahua DH-SD29204T-GN-W,

with the firmware 2.400.0000.16.R.T4.484.9A.NR, build : 2016-05-17, dahua-node.js work correctly,

but with the last fimware DH_SD-Mao-Themis_Eng_P_Stream3_IVS_V2.422.0000.3.R.20161009 , dahua-nodejs connect but close connection at 1 second, response is 401.

i think that dahua changes method authentication.

i have had downgrade for dahua-nodejs works again.

Thanks!!!!!

Regards.
 

AlexV

n3wb
Joined
Jan 20, 2017
Messages
8
Reaction score
0
Hi! Is there some way to get a list of presets by this API?
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,346
Reaction score
5,261
Location
Denver, CO
what would that accomplish? the numerical ID should be adaquate.
 

AlexV

n3wb
Joined
Jan 20, 2017
Messages
8
Reaction score
0
Sorry, I don't understand you. I would like to get a list of user defined presets with corresponding IDs and captions. Is this possible?
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,346
Reaction score
5,261
Location
Denver, CO
you can dahua.ptzPreset(10), and it'll go to preset #10.. if that preset is not setup on the camera, then it wont do anything... I know of no way to extract any configurations you have for that preset.. just to use it.

If you can give me a valid use case; I may look into it.. but right now, I see absolutely no use in such a function..
 

AlexV

n3wb
Joined
Jan 20, 2017
Messages
8
Reaction score
0
Very simple... For instance, you want to make some custom UI where you want to display presets and allow user to click preset to go to it.
 

nayr

IPCT Contributor
Joined
Jul 16, 2014
Messages
9,346
Reaction score
5,261
Location
Denver, CO
most Camera UI's give you a numeical input, or selection box where you select 1-50 or something.. Not even Dahua's own apps do what your wanting so dont hold your breath.

You could always have them give names in your app, they dont nessicarly have to share names with the camera presets.. those preset names are only used if you enabled the status OSD text... like add preset, #1 - Yard, save.. now you have a button that says Yard and calls preset #1

If your wanting to make a camera app like you describe, you should look into using ONVIF so its not specific only to Dahua brand.. this module wont work with non-dahuas.. It was designed for those wanting to do some automation w/Dahuas and less for making a full featured Dahua client.. theres a ton of API calls I have not implemented, I only started with those most needed w/automation scripts.
 
Last edited:

AlexV

n3wb
Joined
Jan 20, 2017
Messages
8
Reaction score
0
It's sounds silly for me to expect that user will remember dozens of presets by numbers. And I were pretty sure that it's nor problem at all - as long as I can see the list via camera's web interface. If I can receive the list to show on web interface, so why I can't receive it via API?
 
Top