Send msg to onvif Media

Hi guys, I'm here again

I have been trying to use an array of information to send it to the onvif-media node, but apparently, the node needs a default IP to be able to connect, someone knows somehow that I can send the configuration that the node needs through the msg for the node to take that information?

Js function to send information (that array should come from the onvif-discovery node)

Onvif media node
Selection_999(050)

Use a default config to allow the deploy without error

thanks!

Hi @jamessantoya26,
What do you mean by "the node need a default ip"? I assume you mean the ip address in the config node...

I have build those nodes with the idea of having 1 config node per IP camera. When you have multiple IP addresses, then you create multiple config nodes, and 1 media node per config node...

Did it like that to make sure the overhead if connecting would be done once, at startup.

Bart

1 Like

Hi @BartButenaers
I understand, but my question is more related to how to send configuration information to the nodes through the payload

example:

I have a Configuration array

info = [{
            name: "cam",
            xaddress: "http://127.0.0.0",
            credentials: {
                user: "username",
                password: "password"  
            }
        },
        {
            name: "cam2",
            xaddress: "http://127.1.1.1",
            credentials: {
                user: "username",
                password: "password"  
            }
        }];

and I iterate over them and for each iteration I want to send it to the media node for its configuration and get its response, but what I see is that the node has to have an IP configured in its properties before being called.

thanks for answering

maybe here is an example of it
To get the snapshot, the information required by the node is passed into the payload if we do not want to configure it in the same

but maybe in the onvif-media node, I am not sure if we were receiving the information through the payload, if the node is not configured

Yes but currently it works like this:

  1. You setup all the configuration in the config node (ip address, username, password, ...).
  2. At startup the config node auto-connects to the IP camera, and as soon as it is connected you can start sending Onvif events.
  3. Every node calls passes the incoming msg requests to the config node, and the config node handles all the onvif requests (based on the configuration that it already has).
  4. The config node status will change based on Onvif results that it has receveived from the IP camera.
  5. My Onvif nodes will listen to status changes in the config node, and update their node status likewise.

What you want to achieve is:

  1. Send all the configuration via the input message.
  2. Since there is no config node, the node will have to do it now by himself. Unless the node creates a config node dynamically on the fly...
  3. For every request that arrives, there should be a connection started first to the Onvif camera. Unless there is some kind of dynamic cache where all the connections are being maintained, to be able to reuse the connections (and avoid the overhead of creating new connections all the time).
  4. There should be new status texts, because "connected" doesn't say much anymore in your use case.

Unless you see a much simpler solution, then please share it!!!!

Otherwise this would be a complete rework of my Onvif nodes, and - since I already don't have enough time to finish those nodes in order to publish them on NPM- that is not something that will happen unfortunately ...

1 Like

Perhaps you can explain your use case. Can't you simply create a config node for every IP camera (containing the config of that camera), and then create a media node for every config node? Or are you dealing with an enormous amount of camera's or something like that?

1 Like

@BartButenaers thanks for your answers, I am looking for a way in which I can adapt the nodes according to what comes through the msg.payload, I am dealing with the amount of IPs that are discovered in the node-discovery.

thanks for your help

1 Like

Perhaps you can create a Map:

  • key = ip address
  • value = Cam instance

When an unknown ip address arrives (i.e. not in the map), then you create a new Cam instance to which you connect.
When a known ip address arrives, the you get the existing Cam instance from the map.

1 Like

Hi all!

@jamessantoya26 months ago, I was looking for something similar, so that the ONVIF-CONFIG configurations could be made dynamically to implement a configuration section in the UI board, I have been looking and seeing the way to do it, I followed the advice of @BartButenaers to try to use the NODE-RED API to dynamically perform the configurations in all the nodes that require configuration, such as the HTTP request.

I will tell you about my experience and see if we can achieve it :slight_smile:
I have made tests to configure the USER / PASSWORD of the HTTP Request nodes (These do not allow dynamic modifications)

To do this, you must access the NODE-RED API (Admin API Methods : Node-RED):

1. Request the current TOKEN, you can make a GET request:
curl http://localhost:1880/auth/token --data 'client_id=node-red-admin&grant_type=password&scope=*&username=admin&password=password'

You will get a Bearer type token (A_SECRET_TOKEN)

2. You have to obtain the configuration of the flow that contains the HTTP request which you want to modify the data [GET], to later send a PUT to send the desired configuration
2.1 [GET]. curl -H "Authorization: Bearer A_SECRET_TOKEN" http://localhost:1880/admin/flow/(id of your flow that contains the HTTP request)

2.2 [PUT]. finally you make a PUT request and inject the JSON with the modified information, such as the user / password you need and you can put them from a variable

I have tried to do the same with the OnVif device node, but it points to another node that is the ONVIF-CONFIG which does not allow me to make info requests and publish them again as I did with the HTTP request node.

Achraf B.