Converting flow as node

547 views
Skip to first unread message

sudhakar bhooramoorthy

unread,
Sep 23, 2015, 5:58:22 PM9/23/15
to Node-RED
Is there any way to convert flow into a Node, so that I can drag and drop into my new flows without exposing all the details of how it works in the background once it is tested; 

Thanks
B.Sudhakar

Nicholas O'Leary

unread,
Sep 23, 2015, 6:02:06 PM9/23/15
to Node-RED Mailing LIst
Hi,

not quite.

You can package a flow as a 'subflow', which appears as a single node in the palette. (Select the nodes in your flow, the select "Subflows"->"Selection to Subflow" in the sidebar menu.)

We don't currently have a way for you to easily redistribute such a subflow in a way that completely hides the implementation from the user.

Nick

--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Scargill

unread,
Sep 24, 2015, 8:47:48 AM9/24/15
to Node-RED
Help me out here. I'd not taken any notice of subflows until now.

So I can see how you would select a group of flows and inputs etc.. and make a new block which you can rename. Lovely.

So I have a timestamp - a flow which generates a command and an output that goes to a LED - the led flashes back and forth - and I can manually change the flash by clicking on the timestamp mode. Lovely.

So I can see how you select the three - make a new subnode, save it. That part is easy.

What I don't understand are the input and output options. How does an input option relate to the fact that my flow has an input you can press....... I'm just not seeing this at all??  Don't suppose you have simple video example anywhere?

Pete.

Peter Scargill

unread,
Sep 24, 2015, 8:54:22 AM9/24/15
to Node-RED
Ok, got another question.. I was playing with this subflow idea, deleted it.. and when I came to DEPLOY I noted a message saying that some nodes are not configured properly - everything works and I can't see any page items with dotted lines or anything - any way to tell what is supposedly not configured properly (it would be really good if you got a hint - that's a bit like a compiler saying "there's a problem somewhere"...

Pete.




On Wednesday, 23 September 2015 23:58:22 UTC+2, sudhakar bhooramoorthy wrote:

Nicholas O'Leary

unread,
Sep 24, 2015, 8:59:28 AM9/24/15
to Node-RED Mailing LIst
Peter,

the 'input' and 'output's of a subflow relate to the input/output ports you can wire into your flow.
They are not related to whether any of the nodes inside of the subflow have a button (as the Inject and Debug nodes do).

In their current incarnation, think of a subflow as a template. You drag individual instances of the subflow into the workspace and the runtime creates an embodiment of the template inline to the flow. If you drag two instances in, they are independent instances - they do not share any internal state.

When you open up the subflow to edit it, you are editing the template, not a specific instance. This means any buttons on nodes within the template don't have a one-to-one mapping to a node running in the runtime. This is why the buttons are disabled within the subflow view.

I wrote a while ago about our roadmap for subflows (search the mailing list for 'subflow v2'). This will introduce inline subflows where they are not intended as reusable components, rather a way to help organise your flows. In this instance, there would be a one-to-one mapping of the nodes in the subflow view and what's in the runtime - so the buttons will be enabled. But that's a little way off in the future at the moment.


On your follow-up question, when you say you deleted the subflow, did you just delete the subflow instance node in your workspace, or did you also delete the subflow template itself from the palette? MY guess is you did the former and the misconfigured node is inside the subflow template. Double click on it in the palette to open it up and you can then delete the subflow using the button in the toolbar. If you'd already done that, then there must be something somewhere misconfigured.. Have made a note for us to make that dialog more helpful...

Nick

--

Peter Scargill

unread,
Sep 24, 2015, 9:13:46 AM9/24/15
to node...@googlegroups.com

Sorry to be thick Nicholas…

 

Last things first – the subflow..

 

I kind of know what you’re talking about as I’ve seen config info left lying around from nodes – but I cant’ see anything… “double click on It in the palate”?  Double click on what? I deleted the subflow….  (just one delete) and I can’t see any reference to it anywhere… in SUBFLOWS menu there is nothing.. in WORKSPACES there are just the ones that should be there.. I’m not seeing anything else I can click…

 

On the FIRST item, I must’ve read what you’ve said there 3 times.. and I still don’t see the point of being able to add inputs and outputs if you can’t attach them to anything? I know it’s just me .. but have you an example anywhere? I can’t think of an actual use for a subflow if I can’t attach it to something. I’m sure it will all click shortly….

--
http://nodered.org
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/nNFjDjMtN9A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

Peter Scargill

unread,
Sep 24, 2015, 9:23:15 AM9/24/15
to node...@googlegroups.com

Forget the subflow issue – sorted thanks … any tips to help me understand the inputs and outputs on those subflows would be great.

 

Pete.

 

From: node...@googlegroups.com [mailto:node...@googlegroups.com] On Behalf Of Nicholas O'Leary
Sent: 24 September 2015 14:59
To: Node-RED Mailing LIst <node...@googlegroups.com>
Subject: Re: [node-red] Re: Converting flow as node

 

Peter,

--
http://nodered.org
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/nNFjDjMtN9A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.

Nicholas O'Leary

unread,
Sep 24, 2015, 9:33:08 AM9/24/15
to Node-RED Mailing LIst
When you create subflow, it gets added to the palette in a 'subflows' section that appears at the top. That lets you drag on new instances of the subflow as you would any other node in your palette. If you double click on that node it will open up the subflow in a new tab that lets you edit it.

I didn't say you can't attach inputs/outputs to anything. I said the exact opposite: the inputs/outputs of a subflow relate to the input/ouput ports of a subflow instance you wire into your flow.

Here I am editing a subflow called 'My First Subflow'. I have added a single Input and an Output to the subflow and wired a Function node into them. 

Inline images 3

You can see this subflow node has been added to my palette and I have dragged on an instance of this subflow and wired in an Inject/Debug pair of nodes either side.

Inline images 2

I now go back into the subflow node and add a second output.

Inline images 4

Going back to the main sheet, you can see the subflow instance now has a second output I can wire up.


Inline images 5


This is equivalent to:

Inline images 6




Going back into the subflow, if I add an Inject node:

Inline images 7

note the button on the inject node is disabled - because we're editing a template, not a live running set of nodes.



Peter Scargill

unread,
Sep 24, 2015, 11:28:08 AM9/24/15
to node...@googlegroups.com

AHAH!!!  And I was just about to ask what happens if my function has multiple outputs (one of mine has 6) and I see you can just add outputs – LOVE IT!!!

 

Right, thank you for that –marvellous… now it is clear. Between this and getting to grips with script files I’m having a good week.

 

Pete.

image002.jpg
image004.jpg
image006.jpg
image008.jpg
image010.jpg
image012.jpg
Reply all
Reply to author
Forward
0 new messages