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?
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.
You setup all the configuration in the config node (ip address, username, password, ...).
At startup the config node auto-connects to the IP camera, and as soon as it is connected you can start sending Onvif events.
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).
The config node status will change based on Onvif results that it has receveived from the IP camera.
My Onvif nodes will listen to status changes in the config node, and update their node status likewise.
What you want to achieve is:
Send all the configuration via the input message.
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...
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).
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 ...
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?
@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.
@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
I have made tests to configure the USER / PASSWORD of the HTTP Request nodes (These do not allow dynamic modifications)
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.
I made some modifications to the onvif-media and onvif-config nodes, so that they adjusted to receive the information through msg.payload, and call the initialize(msg.payload.deviceConfig) when the node is invoked, initially the node begins unconfigured, after receiving an IP to connect, it returns the connection of the camera with that IP, if another action with the same IP is sent to the same node, I re-use the connection and only executed the actions.
Another modification I made was to add some events to receive when it was "connected " to the camera and creating the event name 'camera_conn+_msgid', in this way I can use different onvif-media nodes without interfering with each other(putting only one node of onvif-media in the tab), I can still use it in a unique way and for each _msgid, it triggers the events corresponding to every IP sent in the msg.deviceConfig.xaddress, this way I did it and it worked for me for what I needed.