Onvif camera control

Once you got the Xaddr you can do getCurrentProfile and from the json extract the snapshot URL and/or the stream (rtsp) URL I realize we made different choices as to which javaScript onvif library to use, which can further confuse things. As I said I'll try to test, your onvif nodes once you've "released" them. I have four brands of allegedly onvif compatible cameras here and access to some higher end models.

There is one thing I'm fuzzy on, that is if the camera actually needs a password to answer the onvif probe or not. If its needed and different from the admin:adnim that seems to be the usual default, it'll break automatic discovery. None of the Onvif cameras I've had access to have failed to respond using the default admin:admin for the getCurrentProfile

Some reply with an "embedded password" as part of the URL, others don't, these often require user:passwd@IPaddress for access, for which admin:admin has worked for all the cameras I'be been able to try.

@Bart No worries, there is no hurry, and indeed, I must have missed your post, my mistake :expressionless: ... I'll wait for the new release.
Maybe some constructive feedback. I don't mind all the info from the discovery node, in my opinion it's best to provide all the info you can have. Everyone has different needs, and if the info is available, its not a big deal to extract just what you need.
Maybe (don't know it its possible) it would be convenient if, after the discovery node has run, to have a drop down list in the other nodes, where you just select the camera you want to attach. And if the discovery nodes can include profiles etc, this could be added as a drop down list also.

Thank you all for the support and good work.

@prutspapa,
That is indeed something I have been considering. Think there are two major ways to implement this:

  • I have used the node-red way: create a Discovery-node. As soon as I get an input message, I send a broadcast on the network, and I create an output message containing the devices.
  • It could perhaps be more user-friendly to show a dropdown box in the config node, so you can just select an ip address from it. But then you might have to wait a couple of seconds until the discovery has finished...
    Not sure which of both is best. Or perhaps I should offer both ways of working ...

P.S. I already do something similar in the Media node, for the automatic loading of profiles (from the camera) from which you can easily choose:

onvif_search_tokens

Hi everybody (a.o. @davidcgu, @wb666greene, @Klangen82 , @prutspapa, @krambriw),

To avoid that this becomes a never-ending-story, I have released a beta version on NPM:

npm install node-red-contrib-onvif-nodes@0.0.1-beta.3

Then at least we have something to discuss...
But remember that this is only a beta version, so some stuff doesn't work yet correctly!!!
I have added all my TODO's and KNOWN ISSUES on my readme page. When I have time left, I will create Github issues for those...

All 'constructive' feedback is welcome! The config screens of my nodes should become MUCH more user friendly!! Perhaps we can copy some useful stuff from other tools, like the Onvif device manager. So I you have a better suggestion, please let the screenshots come...

Keep in mind that I will be absent from the Node-RED forum from 17 to 27 March !!
Won't be able to answer questions or do any fixes in that period...

Thanks in advance for all testing and ideas!!!!
Bart

A minor point but I think it might be worth increasing the default timeout on the discovery node. Mine took rather longer than 5 secs the first time. Unfortunately I don't know how long it took as on subsequent tries it came straight back. I will leave it a while and then see how long it takes.
If I have 'multiple messages' enabled does it send each one immediately it gets an answer or does it wait for the timeout and send them all?

Actually I am wondering if there is a bug in the timeout on the discovery. I realised that I know the answer to my multiple messages timeout question, as with multiple enabled my camera comes straight back (after the first try). However, with multiple disabled it seems to come back after 5 seconds even if I have 20 set in the timeout.

A question. In the onvif-config node should I put exactly the address that I get from XAddrs from the discovery node? In my case this is an array with one element http://192.168.x.xxx/onvif/device_service
I ask because it doesn't connect. Of course this could be a problem with the camera.

When I try the onvif-config node with the china cameras I have, I get a typical XAddrs like
http://192.168.1.93:80/onvif/device_service

But this does not work for streaming. Instead, if I use ONVIF device manager, I get
rtsp://192.168.1.93:2600/stream0

This works for streaming as well as stream1 when providing user:password

I have just looked back through the thread and saw one that suggests I should only put the IP address of the camera in the config node, not the full url returned by discovery. I tried that and it seems better in that it sat for several seconds saying initialising, but then dropped back to disconnected. A Catch node didn't give me any indication of what went wrong.

I tried:

npm install node-red-contrib-onvif-nodes@0.0.1-beta.3

And got:

npm WARN saveError ENOENT: no such file or directory, open '/home/wally/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/wally/package.json'
npm WARN wally No description
npm WARN wally No repository field.
npm WARN wally No README data
npm WARN wally No license field.

+ node-red-contrib-onvif-nodes@0.0.1-beta.3
updated 1 package and audited 93 packages in 0.855s
found 0 vulnerabilities



   โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
   โ”‚                                                               โ”‚
   โ”‚       New minor version of npm available! 6.4.1 โ†’ 6.9.0       โ”‚
   โ”‚   Changelog: https://github.com/npm/cli/releases/tag/v6.9.0   โ”‚
   โ”‚               Run npm install -g npm to update!               โ”‚
   โ”‚                                                               โ”‚
   โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

But after stopping and restarting no onvif nodes were in my pallet. Looking in the .node-red/node_modules directory I don't see your onvif nodes.

I don't know what has gone wrong. Any ideas?

Hey Colin (@Colin), it waits for the timeout and then send them all. That's how the Onvif library works ... I have added your feedback to the readme file now:

image

Congratulations, you have found the first bug ... I have fixed it on Github (not on NPM).
For clarity, I have also added a 'seconds' label after the timeout input field:

image

The disadvantage is that everybody would have to wait longer. In my case the cameras respond quickly, so then I would have to wait longer ... Would have been better if the output messages would be send as soon as a device responds...

No just the IP address...
In the Onvif Device Manager they call it 'Address':

image

Since you are not the only one with doubts about it, I have renamed it to 'IP address':

image

Walter (@krambriw), the Media node delivers the stream URL's (see here). Isn't that sufficient enough?

No idea. Will have a look whether I can get and show more error information.

Unfortunately not ...

I am not seeing that in multiple message mode (this is on Ubuntu if it makes a difference). Now that my camera has been probed once it appears to be responding immediately and when I click the inject to the discovery node I see the response immediately and then the node status stays on discovering for the 5 seconds. However, if I set it to single message mode then it waits till the end of the discovery then sends the message.

@colin,
This is the code snippet where the Onvif library calls my callback handler (which sets the node status to 'connected' or 'disconnected'):

this.cam = new onvif.Cam(options, function(err) { 
        if (err) {
             setOnvifStatus(node, "disconnected");
        }
        else {  
             setOnvifStatus(node, "connected"); 
        }
});

As you can see they also pass me 'err', but I don't do anything with that error at the moment.
When I for example change the user name in my config node:

image

Then I see this error in the debugger:

Is it ok if I just write this error to the console log???

@Colin:
I wasn't able to test this decently, since only 1 of my camera's support Onvif ...
But the behaviour you describe is perfect for me. Will put your summary on the readme page.

Signal it as an error so a Catch node can pick it up?

@wb666greene you should run the install from your .node-red folder.
[Edit] and then restart node-red.

Thanks, that sees to have solved it. I'll stop and restart node-red as soon as I finish a test that is running now. I wasn't aware of that little tidbit.

At the moment, it should find six Onvif cameras on my subnet.

Haven't thought about that, since I have never used the Catch node myself :roll_eyes:
From Nick's explanation it seems that I should do it like this:

node.error( err, {} );

Fingers crossed now ...

Have published version node-red-contrib-onvif-nodes@0.0.1-beta.4 with following changes:

  • Log node error in case of status "disconnected"
  • In Config-node the 'xAddress' label is changed to 'IP address'
  • On readme page the output messages for broadcast are better explained
  • The timeout value is now used in the Discovery-node

It found all six. Here is what the OnVif Discovery returns to a debug node for my XM POE "straight from china" camera:

3/11/2019, 5:30:58 PMnode: 76f82216.b5717c
msg : Object
object
payload: object
endpointReference: object
address: "urn:uuid:ef35b696-5566-7788-99aa-001217dcedd4"
types: array[1]
0: "dn:NetworkVideoTransmitter"
scopes: array[6]
0: "onvif://www.onvif.org/type/video_encoder"
1: "onvif://www.onvif.org/type/audio_encoder"
2: "onvif://www.onvif.org/hardware/IPC-model"
3: "onvif://www.onvif.org/location/country/china"
4: "onvif://www.onvif.org/name/NVT"
5: "onvif://www.onvif.org/Profile/Streaming"
XAddrs: array[1]
0: "http://192.168.2.155:8899/onvif/device_service"
metadataVersion: 10
_msgid: "b499663c.702fd8"

I'm going to try beta.4
Will an npm update work or do I need to uninstall beta.3 before installing beta.4?