State engine as a subflow

Hi.
Is it possible to build a state engine as a subflow?
I want to be able to pass a numeric value (1-10) and based on that there is 3 different status variables that can change. 1 of the variables is dependant of the 2 other, so the subflow must be able to read it's own variables to set the correct output values.
I'm kinda new to node red, so please be gentle with me :slight_smile:

Yes it is possible, each instant of the subflow will have its own variables and should not interfere with the other instances.

thanks for the quick response. How would I access the variables from a subflow instance?
image
Here I have 2 instances of my subflow. can I add the instanse number as part of the address?
something like this:
var sts1 = flow.get("Pump01.OperationState")

You would set a subflow property in the template, then when you use a subflow you would give the property a value. This value can be accessed using env.get("property_name") in a function node.

Sorry for being a Noob here, but how do I set the subflow property value? i used the flow.set inside the subflow to hold the values, and expose these in the msg object. If I were to use the env.get() do I have to specify the name of the subflow instance as well?

THe docs will tell you setting subflow property

You may benefit form viewing the essentials videos

Thanks for the links. I've been trying to do some research but had trouble finding relevant topics.
Thanks for all the help so far :smiley:

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