mikakaraila / node-red-contrib-opcua

A Node-RED node to communicate OPC UA. Uses node-opcua library.
Other
211 stars 196 forks source link

[Feature Request] Make client endpoint dynamically configurable #469

Closed pascalporedda closed 2 years ago

pascalporedda commented 2 years ago

Today I ran into the problem that I need the OPC client's node endpoint to be configurable, either via selecting an env variable, or setting the endpoint to an incoming messages property. Like, it is possible with many other nodes in NodeRED.

Would it be possible for you to add this feature?

mikakaraila commented 2 years ago

It is already existing, look OPCUA-TEST-NODES.json

Tab: reconnect image

I will extend actions to support disconnect & connect. Current implementation uses action "reconnect".

mikakaraila commented 2 years ago

I extended actions: image

pascalporedda commented 2 years ago

Yeah I can verify that this is working as expected. Though I would still prefer being able to select end endpoint url from an ENV variable for example, because now I have to set the UaEndpoint everytime I call a method as well for example. Having the option to refer to an env variable inside the UA config node would make things easier.

mikakaraila commented 2 years ago

Did you look older example? It will use msg that contains endpoint information...

pascalporedda commented 2 years ago

Yes I've seen that, using a msg works fine but I would like to have this:

Screenshot 2022-08-24 at 11 17 09

Instead of in a change node that sends a message to the OPC client rather here:

Screenshot 2022-08-24 at 11 17 23

So that I could simply refer to an Env variable inside the config node or use a JSONata expression there.

mikakaraila commented 2 years ago

Argh, can you change environment variable value during runtime?

Or use function node to build value and then inject msg. image

mikakaraila commented 2 years ago

Do you have example where this feature has been used? I found example from core nodes (inject). I will take a look next week.

pascalporedda commented 2 years ago

Perfect, thank you. Yeah the Inject Node covers this feature.

tedkim13 commented 2 years ago

Hi all, I believe it's already possible to use an environment variable for configuring the OpcUa-Endpoint node, we do something similar for our use case:

image

One thing to note is that the environment variable must be the full endpoint. Unfortunately cannot substitute just a part of the property. e.g. opc.tcp://{ENDPOINT}:48030 image

Hope this helps.

pascalporedda commented 2 years ago

Hi @tedkim13 this looks promising, I'll try this 👍🏻 and leave you guys feedback once I know if this works or not.

pascalporedda commented 2 years ago

Works perfectly fine. Thank you!

offrok commented 1 year ago

@pascalporedda could you please explain how you set the environment variable at runtime in this context? I thought you could only set them at startup

afagundesm commented 1 year ago

Hi, using the example OPCUA-TEST-NODES.json (tab reconnect) I am able to use the action "reconnect" in a function node but then when I try to use the action "browse" it will not browse on the new endpoint address space (after reconnecting). Instead, it will try to browse on the endpoint initially configured for the OPC UA Client node. There is a way of giving the msg.OpcUaEndpoint on the action "browse" like we do in "reconnect"?