# Subflows within subflows - just asking

**URL:** <https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147>\
**Category:** General\
**Created:** [25 January 2023 02:32 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147 "2023-01-25T02:32:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 January 2023 02:32 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147/1 "2023-01-25T02:32:14Z")

</div>

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`?

---

<div class="post-metadata">

**Author:** ![tve](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tve/32/59475_2.png) [@tve](https://discourse.nodered.org/u/tve)\
**Post date:** [25 January 2023 02:34 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147/2 "2023-01-25T02:34:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 January 2023 02:44 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147/3 "2023-01-25T02:44:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 January 2023 07:16 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147/4 "2023-01-25T07:16:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 January 2023 07:40 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147/5 "2023-01-25T07:40:09Z")

</div>

Yeah, agreed.

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

 ![Screenshot from 2023-01-25 18-30-33](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/e/2e1e0916d36898c0d8ce72b78ee254809eb51219.png)

(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.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 January 2023 08:00 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147/6 "2023-01-25T08:00:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 January 2023 08:02 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147/7 "2023-01-25T08:02:28Z")

</div>

I agree.

But my curiosity just doesn't know how to stop. 🙂😕

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [25 January 2023 09:56 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147/8 "2023-01-25T09:56:01Z")

</div>

This is where "collapsible groups" would be nice 😁

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 👍

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [25 January 2023 10:10 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147/9 "2023-01-25T10:10:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 March 2023 10:10 UTC](https://discourse.nodered.org/t/subflows-within-subflows-just-asking/74147/10 "2023-03-26T10:10:49Z")

</div>

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