Access different nodes values in function to Enable different Outputs


I want to read different nodes values in the function to enable different outputs.

How can I do that?


Welcome to the forum @obi1987

I am afraid your description of the problem is not sufficient to provide an answer. Please provide a lot more information about what you are trying to do.

Thanks for the reply :slight_smile:

Well.I want to use on tag from PLC as a decision Tag.

On the basis of I would like to log values continuous and stop values.

For Example

PLC Tag Value can be PLC_Tag = 1, 2 ,3

When value PLC_Tag=1.I want to send some values to database only once.

When value PLC_Tag=2.I want to send some tags values every second.

When value PLC_Taq=3.I want to stop the storage.

Sorry, I don't know what a decision tag is or a plc tag.

Are you fetching data from a PLC? If so have you got that bit working?

You say you want to write to a database, have you got the basic database operation working?

Yes decision tag is just a plc Tag reading over the OPC UA.

Yes reading from PLC and writing to influx DB is working fine.

OK, so you want to stop/start the database write based on the value of something you fetch from the PLC. Have a look at node-red-contrib-simple-gate. That can be used to block messages. You could put that in the path to the database and stop the message flow when required. That will cope with states 2 and 3.

Thanks alot.I will look into it.

One more thing. Is there any way I can read values in function.
Let say INJECT has a value (Payload).Is there any way I can read that pay value in function?

It is working good with gate.

I use inject to stop the value. Can you please tell how I can use PLC value as an Input. I want to define Topic as gate topic ,so it will take it as a value to stop the gate.

I guess you are a beginner with node-red so I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

Yes, I am beginner.Thank for sharing .

I think you are misunderstanding how Node-red works.
Consider this snippet of a flow
Untitled 4
There are four inputs: two Injects, an MQTT and an Email node.

These nodes do not "have a value" that you can read in the function node.
Instead, when an email arrives or an inject is triggered, the data flows as a message down the wire to the function node and then it is gone.
When a message arrives, the function node has no knowledge of previous messages.

If you want to use the data from more than one input you must either

  • Arrange for all the data you want to arrive in a single message - with a Join node OR
  • Save data from one message so that it is still available when a different message arrives - with context variables.

I think I was not explaining my issue well. Here is snapshot.

Here everything working fine and OPC UA payload updated every second and moving out.

There one Inject with topic Control to stop the flow and it is working fine when I pressed it. Now rather than that I need a value from PLC here but the problem is that I need to specify Topic Control otherwise gate will not work.

In the gate node you can specify what topic you want to use, and what payload values should open and close the gate. So connect the message containing the plc tag in the payload into the gate and configure the gate to use the topic and payload values that are there. If it hasn't got a topic then use a Change node to set it.

This is all basic stuff, have you watched the videos I suggested?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.