Onvif camera control

That is good news. Now I'm going to sleep, before you guys start registering new bugs :joy:

You can just do npm install node-red-contrib-onvif-nodes@0.0.1-beta.4 in your Node-RED folder.
See you tomorrow !!

Hey, great work @BartButenaers it works (it helps if I put the right password in, which the catch node told me was wrong).

How do I find what to put in the Profile field for the ptz node?

[Edit] I just put 1 in the profile and it seems to work (though my camera only does Zoom). Would be nice to know what I am supposed to do though.

Hey @Colin,
Back from a lovely day at work :lying_face:

I assume you are busy now testing Node-RED version 0.20.0, so hopefully you have some time left for Onvif :wink:

Very good question! I have added some explanation of media profiles on the readme page. Hopefully it becomes clear now...

Onvif media-related SOAP requests require to specify the profile token. However most of the time these tokens are very weird looking. Reason is that - when creating a new profile - often no (human readable) token is specified, so the Onvif will automatically create a new token. To avoid that people have to work with these weird tokens, my Media-node was implemented like this:

  1. Users can specify the profile name (instead of the profile token).
  2. Then the node automatically determines the profile token belonging to the profile name.
  3. At the end, the node call the SOAP action with the profile token as input.

Moreover the Media-node's config screen offers a search box, to load automatically all available media profile names...

I have now published a new node-red-contrib-onvif-nodes@0.0.1-beta.5 version, that offers the same way of working in the PTZ-node:

onvif_ptz_profiles

So you just need to specify one of the profile names in your PTZ node from now on ...

Ah, right, I have just realised what the profiles are. Thanks.
My camera doesn't seem to do exactly what the onvif spec says, but since it doesn't claim to be onvif compliant I was surprised when it found it, and the most important thing I wanted to do was to be able to Zoom without having to boot into Windows and run a horrible ActiveX control, and zoom does work :slight_smile: The camera doesn't do PT, just Zoom.
So even if I can't make it do anything else I am happy and grateful for you hard work.

@Colin: Same here. Found out that one of my Panasonic camera's supported Onvif, only after I used my Discovery node for the first time. :joy:

Does it work only with the horrible ActiveX control, or have you also been able to zoom with my hopefully-bit-less-horrible PTZ node?? If not, please let me know what the issue is !!

I noticed beta.5 now shows up in "Manage Pallet" Hopefully the remaining updates will be upgradable from there as well. Nice work.

I missed your documentation page initially, reading it now and will give it another try after diner tonight.

Heuh, do you see it in your pallet???? Not for me. I see only the Onvif node from the other author:

image

I especially eliminated the "node-red" keyword from my package.json file, to make sure these beta versions don't appear in the pallet:

"keywords": [ "onvif", "ip", "camera", "snapshot", "ptz", "rtsp", "stream", "surveillance" ],

I don't want everybody to install these beta versions, because most of the time they are not backwards compatible...

Have a nice diner !! My time is up for today ...

1 Like

I had stopped and restarted node-red for the dashboard update, right after I upgraded to beta.5
Here is a screen shot:

I'm having trouble getting anything useful to happen, its less than clear what the "tokens" are and where they come from. to put in the node properties boxes.

It also looks like some of the examples from your documentation page are out of sync with beta.5

The first tabsheet are the nodes that you have installed, so normal that it appears them. Second tab are all available nodes, so there it should not appear...

I appreciate that you are helping to test my nodes, but that isn't really constructive feedback. Cannot solve it, or cannot add it...

I will replace the "token name everywhere by "profile name". Isn't the information on the reame about "media profiles" clear enough, or what do you mean. I need to use profiles everywhere, because that is how Onvif works...

That could be. Will have a look at that tonight. Will also review whether the information on all "Info" panels is still correct.

Specifically your example to grab a snapshot:

[{"id":"bd25387b.516598","type":"inject","z":"6925873a.fe0858","name":"Get HTTP stream URL","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":215,"y":635,"wires":[["52cd8a88.28cbc4"]]},{"id":"52cd8a88.28cbc4","type":"change","z":"6925873a.fe0858","name":"","rules":[{"t":"set","p":"action","pt":"msg","to":"getStreamUri","tot":"str"},{"t":"set","p":"protocol","pt":"msg","to":"HTTP","tot":"str"},{"t":"set","p":"profileToken","pt":"msg","to":"1_def_profile3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":544,"y":635,"wires":[["2cc38daa.80b192"]]},{"id":"2cc38daa.80b192","type":"onvif-media","z":"6925873a.fe0858","name":"","deviceConfig":"8de17a72.47e668","profileToken":"","profileName":"media_profile1","videoEncoderConfigToken":"","videoEncoderConfigName":"","videoEncoderConfigEncoding":"","action":"getSnapshot","protocol":"","stream":"","x":765,"y":595,"wires":[["d87139ef.61df88","f0683b93.ecba48"]]},{"id":"29ff0902.c906e6","type":"catch","z":"6925873a.fe0858","name":"","scope":null,"x":755,"y":670,"wires":[["d87139ef.61df88"]]},{"id":"d87139ef.61df88","type":"debug","z":"6925873a.fe0858","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":960,"y":680,"wires":[]},{"id":"f0683b93.ecba48","type":"image","z":"6925873a.fe0858","name":"","width":"1280","x":975,"y":595,"wires":[]},{"id":"8de17a72.47e668","type":"onvif-config","z":"","xaddress":"192.168.2.219","name":""}]

Crashes node-red when I press the Get HTTP Stream URL:

13 Mar 02:06:15 - [info] Started flows
13 Mar 02:06:15 - [info] [mqtt-broker:localhost:1883] Connected to broker: mqtt://localhost:1883
13 Mar 02:06:15 - [info] [mqtt-broker:localhost:1883] Connected to broker: mqtt://localhost:1883
13 Mar 02:06:15 - [info] [mqtt-broker:localhost:1883] Connected to broker: mqtt://localhost:1883
13 Mar 02:06:43 - [red] Uncaught Exception:
13 Mar 02:06:43 - TypeError: Cannot read property '0' of undefined
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Unit entered failed state.
nodered.service: Failed with result 'exit-code'.
nodered.service: Service hold-off time over, scheduling restart.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
13 Mar 02:06:43 - [info]
Welcome to Node-RED
===================
13 Mar 02:06:43 - [info] Node-RED version: v0.19.5
13 Mar 02:06:43 - [info] Node.js  version: v8.15.1
13 Mar 02:06:43 - [info] Linux 4.4.0-142-generic x64 LE
13 Mar 02:06:43 - [info] Loading palette nodes
13 Mar 02:06:44 - [info] Dashboard version 2.14.0 started at /ui
(node:31261) ExperimentalWarning: The fs.promises API is experimental
13 Mar 02:06:44 - [info] Settings file  : /home/wally/.node-red/settings.js
13 Mar 02:06:44 - [info] Context store  : 'default' [module=memory]
13 Mar 02:06:44 - [info] User directory : /home/wally/.node-red
13 Mar 02:06:44 - [warn] Projects disabled : editorTheme.projects.enabled=false
13 Mar 02:06:44 - [info] Flows file     : /home/wally/.node-red/flows_kahuna.json
13 Mar 02:06:44 - [info] Server now running at http://127.0.0.1:1880/
13 Mar 02:06:44 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
13 Mar 02:06:44 - [info] Starting flows
13 Mar 02:06:44 - [info] Started flows
13 Mar 02:06:44 - [info] [mqtt-broker:localhost:1883] Connected to broker: mqtt://localhost:1883
13 Mar 02:06:44 - [info] [mqtt-broker:localhost:1883] Connected to broker: mqtt://localhost:1883
13 Mar 02:06:44 - [info] [mqtt-broker:localhost:1883] Connected to broker: mqtt://localhost:1883

Nothing appeared to be happening until I noticed a flow in another tab was restarting, then I checked the log. Catch node did nothing.

I had hoped for more clarification of the properties figuring I didn't have the dropdown selections set correctly. Your example flow from the github had two more inject nodes which I didn't cut and paste above, and pressing any of them crashes. I had no further information until I discovered it was crashing instead of nothing happening.

I do hope that eventually you can get the "update" button to appear in Manage Pallet.

If I can get the "Get snapshot image" action to work, this could be the basis for a great front-end to my Python AI code by making the inject node be periodic. Right now I can use node-red as an input source by having the camera/DVR ftp the snapshots to node-red-contrib-ftp-server, but grabbing the snapshots directly in the python is more efficient than using ftp but generally much harder to setup.

Yes, it does zoom with your ptz node, that's what I said, I thought. That is why I am happy.
I haven't managed to get incremental zoom to do anything useful. If I tell it to zoom 1 or -1 it goes to full in or out and it doesn't seem to like fractional values, but I am not sure what it should do. Similarly continuous zoom with a time, which I assume should zoom for that time and then stop, does not stop, but I have achieved what I want by using continuous zoom and then zoom stop after a short time.
Lots of other stuff doesn't work, Go Home for example, but since the camera is not advertised as onvif compliant it may well be that the camera just doesn't support it. I guess what has been happening is the the manufacturers have been developing the support and including it in the product even though it is not all there yet.

One point, I have a flow with lots of onvif nodes and inject nodes on to try things out, and on restart I am seeing

(node:11140) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 onvif_status listeners added. Use emitter.setMaxListeners() to increase limit

Whether that is anything you can (or need to) do anything about or whether it is inherent in the system I don't know. Once it is up and running I likely won't have that many anyway, and I could suppress the warning as it suggests anyway, so it isn't a big deal.

I may be have found an issue why some people have problems with the nodes keeping disconnected...
With the beta 5, I saw in the log messages an error when adding the port to the ipadress :

"Error: getaddrinfo ENOTFOUND
192.168.1.5:8899
192.168.1.5:8899:80"

From the last line, it seems to me that the node is always looking for access on port 80? Or am I wrong ?

Hey guys,
Will continue tomorrow evening with these issues. Some of them are not easy to troubleshoot ...
Thanks for testing and reporting!

Hey @Colin,
The config node can change status (unconfigured - connected - disconnected). All Onvif nodes that use such a config node, will add a status listener on that node. But as soon as a node is closed, I remove the status listener. Since my listeners 'should' be cleaned up nicely, no listeners should be leaking (and causing the maxlistenersexceededwarning).

However, I see in the error description that there are 11 listeners added. If my theory is correct, you should have 11 Onvif nodes using the SAME config node. Is that true?

Seems that the default maximum number of listeners is 10, which you have exceeded. If that is the root cause, I could workaround this in two ways:

  • Set a higher amount of allowed listeners in the config node, e.g. emitter.setMaxListeners(20). However not sure what the maximum should need to be...
  • Set an infinite number of allowed listeners in the config node emitter.setMaxListeners(0): But that might perhaps introduce issues, when I ever introduce a bug (i.e. not removing all listeners correctly). In that case my bug would never be visualized, while my code is leaking listeners.

Perhaps better to set a large number, like 50 listeners ...

Yes, I have around that number. Whether that is what will happen in practice I don't know, it depends how people are going to use the nodes I suppose.

It's just a warning - it is often the case that people forget to clean them up properly - or just add another one on each connection - or in our case often on deploy - so in this case as long as you have 11 cameras (ie you are expecting 11 listeners) then all is OK and you can probably set it to 0 (infinite). If you have 5 and deploy twice or 3 times and then it happens then you have problem.

1 Like

Actually it is not the number of cameras, it is the number of nodes accessing that camera.

node-red-contrib-onvif-nodes@0.0.1-beta.5 version

I find my camera "http://192.168.0.28:10080/onvif/device_service"
I build the config using just the ip address 192.168.0.28 and add user, password and device name.
However when I deploy I get message: "Error: connect ECONNREFUSED 192.168.0.28:80" from the catch node, shouldn't it be using port 10080 not port 80 ? & how would I tell it which port to use ?

Yeah... indeed... the point being is the number what you expect, and stay that way, or does it go up whenever they reconnect - or you redeploy etc... first is ok (so setting it to 0 would be ok) , second means you have leak you need to fix before you set it to something. (again maybe 0)

To make sure my beloved testers don't feel neglected, I have published node-red-contrib-onvif-nodes@0.0.1-beta.6 with following changes:

  • @prutspapa & @Dave: There is now an extra "port" field on the Onvif config node, which is 80 by default:

    image

    When your Onvif Discovery shows another port number, you can copy that port number to your config node. WARNING: SINCE ONLY A FEW PEOPLE ARE TESTING THIS NODE, I HAVEN'T ADDED MIGRATION CODE. SO YOU WILL HAVE TO ADD VALUE 80 MANUALLY IN THIS FIELD FOR EXISTING ONVIF-CONFIG NODES.

  • As you can see in the above screenshot, the 'xAddress' field is renamed to 'IP address'.

  • @wb666greene: The both snapshot flows on the readme have been updated, and some extra explanation has been added (e.g. that you should copy the Onvif credentials should also be specified in the httpRequest node)! But the second flow to get a snapshot (without the httprequest node is much simpler to use!!).

  • @colin: MaxListenersExceededWarning should not occur anymore...

  • @wb666greene: Have updated some explanations on the Info panels (e.g. about tokens) and readme page.

Well then it becomes difficult. For my Panasonic ip camera's, it works correctly. Will have a look at the flows on the readme page. Perhaps they are out of sync with my latest software versions. But yes there will be lots of incorrect/incomplete Onvif implementations available...