Subflows within subflows - just asking

I am just thinking and this question came up:

Ok, a subflow is a specific grouping of nodes that do something and have been put into a subflow because it is used a lot of times in different places.

So is it good practice to put subflow nodes within other subflows?

If it makes sense to you from an organizational perspective then yes, you can definitely nest subflows.

1 Like

Are there problems with doing that?

Are there advantages?

I'm wanting to check if there are/n't any traps with doing it.
Or benefits.

As always, use the KISS principle. If it makes your life simpler then do it, otherwise don't.

1 Like

Yeah, agreed.

But - as an example - this is what I have:

(All the lines are blurred where to draw them for subflow definition)

I am making a routine for my mobile devices and their power levels.
(Nothing worse than a flat battery when you want to use a device)

So the devices send messages so I can see if they are needing power/to be charged.

Each green box (you can't see the entire bottom one) is for each device.

Each has 1 input and 3 outputs.

So the idea is that each (green) box can be made into a subfow.
But (OCD kicking in) I could put all 3 of those subflows into a subflow - which: yes would only be used once, but would not / does not need to be sprawled out on the screen all the time.

I would have to move that switch node into the bigger subflow, but that isn't too difficult.

(Curiosity sucks) and it is just wondering if that is a good idea.
Given the bigger one would only have 3 subflows in it (and a switch node) there is little chance of anything going wrong.

Oh, and as you also may notice/see those green boxes already have a subflow in them.
So it will be a 3 layer deep nest in the subflow.
(I also have to stop using that word: subflow)

I'll shut up here. I think I am not getting any more information imparted.

Normally I would not use a subflow unless I was going to use it more than once.

1 Like

I agree.

But my curiosity just doesn't know how to stop. :slight_smile: :confused:

This is where "collapsible groups" would be nice :grin:

I can see why you might want to put those flows into sub-flows - I wouldn't wrap them in another sub-group myself because I'd find it more annoying than helpful to have to dig 2-levels deep to see what they do. I'd simply put the calls to the 3 sub-flows in a group.

But then I've not found a need/desire to use sub-flows for a long time - pretty much since groups were introduced in fact. If I have a section of flow that I want to "hide", I treat a group as kind of a function, wrap it in a group and use a link-in as the input. Then I can put it somewhere more out of the way.

As always, Node-RED provides lots of options :+1:

1 Like

Thanks.

In the mean time I have done a great job of shooting myself in the foot.

Now I'm sitting here trying to rewrite the messages.