[node-red] get flow id in a dynamic way

736 views
Skip to first unread message

Aly Saleh

unread,
Feb 7, 2017, 8:51:28 AM2/7/17
to Node-RED
Hey,

I am kind of new to node-red but thanks for the awesome work.

I have a use case where I need to input the flow itself as a json into a subflow. Is there any way to get the flow itself or at least the id of it so that I can request Get/flows/flowid ? 

I know if I exported the flow from the ui, I could get it then use it into the subflow, however that would require some manual work, which I would like to avoid.

any ideas?

Thank you 

Julian Knight

unread,
Feb 8, 2017, 8:08:46 AM2/8/17
to Node-RED
Do you just want the TEXT of the flow or are you trying to create a new flow from the existing?

The former is easy since the flow file is JSON so you can simply read it as a file and then parse it. The latter would seem to be recursive so I'm not sure if it would be possible or even safe.

Aly Saleh

unread,
Feb 8, 2017, 8:16:31 AM2/8/17
to Node-RED
I want to create a sub flow that takes a flow JSON as an input and send it somehow, the problem of your proposed solution as I understand, is that it assumes I already know the flow id so then I could go and parse the flows file searching for my flow, however, the one developing the flow does not have its id 

yes, i have also thought it would be recursive, but isn't it also the same idea of creating an export node ?

Thanks for your reply 

Nick O'Leary

unread,
Feb 8, 2017, 8:23:01 AM2/8/17
to Node-RED Mailing List
It still isn't very clear to me what you are trying to do.

>Is there any way to get the flow itself or at least the id of it so that I can request Get/flows/flowid ? 

Which flow do you mean? The complete flow config can be obtained by a get request to /flows. But I think you mean you want to get an individual flow config? If you search through the complete config for 'tab' nodes, that will give you the list of flow ids present. How you then pick which of those flows is the one you want will depend on what you're trying to do.

Nick



--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
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+unsubscribe@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/c4d6e929-055f-426e-931b-401beae500e0%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Aly Saleh

unread,
Feb 8, 2017, 8:40:32 AM2/8/17
to Node-RED
Hey, 


- yes I want to get an individual flow.

which flow? 
 
  -The flow that I am currently developing, as if I am just adding an export node to my flow that just prints the flow config.

- I didn't quite get what you mean, do you mean is to  parse the whole config searching for my individual flow ?

- The idea behind what I am trying to do, is to make the someone develop a flow then send it somehow to some other machine which also has a node-red instance that would import it. So then to send this flow, i need to get it as an input, without that "someone" needing to export and copy paste it because I am developing a sub flow for sending the flow text.

I hope I was clear, its a bit complicated to explain.

On Wednesday, February 8, 2017 at 2:23:01 PM UTC+1, Nick O'Leary wrote:
It still isn't very clear to me what you are trying to do.

>Is there any way to get the flow itself or at least the id of it so that I can request Get/flows/flowid ? 

Which flow do you mean? The complete flow config can be obtained by a get request to /flows. But I think you mean you want to get an individual flow config? If you search through the complete config for 'tab' nodes, that will give you the list of flow ids present. How you then pick which of those flows is the one you want will depend on what you're trying to do.

Nick


On 8 February 2017 at 13:16, Aly Saleh <aly.mo...@gmail.com> wrote:
I want to create a sub flow that takes a flow JSON as an input and send it somehow, the problem of your proposed solution as I understand, is that it assumes I already know the flow id so then I could go and parse the flows file searching for my flow, however, the one developing the flow does not have its id 

yes, i have also thought it would be recursive, but isn't it also the same idea of creating an export node ?

Thanks for your reply 


On Wednesday, February 8, 2017 at 2:08:46 PM UTC+1, Julian Knight wrote:
Do you just want the TEXT of the flow or are you trying to create a new flow from the existing?

The former is easy since the flow file is JSON so you can simply read it as a file and then parse it. The latter would seem to be recursive so I'm not sure if it would be possible or even safe.

On Tuesday, 7 February 2017 13:51:28 UTC, Aly Saleh wrote:
Hey,

I am kind of new to node-red but thanks for the awesome work.

I have a use case where I need to input the flow itself as a json into a subflow. Is there any way to get the flow itself or at least the id of it so that I can request Get/flows/flowid ? 

I know if I exported the flow from the ui, I could get it then use it into the subflow, however that would require some manual work, which I would like to avoid.

any ideas?

Thank you 

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
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.

To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.

Sebastian Barwe

unread,
Feb 8, 2017, 4:34:20 PM2/8/17
to Node-RED
Not used it for myself and was just grabbed from my heap.
thought that "flow cloning" was the idea of http://flows.nodered.org/node/node-red-contrib-flow-dispatcher
Maybe this helps?

Aly Saleh

unread,
Feb 9, 2017, 6:18:31 AM2/9/17
to Node-RED
Hey Sebastian,

Thanks for your reply,

Seems from the documentation that it should do the job since the url does not include the id of the flow it is reading in the node "flowreader", but I haven't tested it yet, will test it and get back to you

Aly

Aly Saleh

unread,
Feb 13, 2017, 11:43:25 AM2/13/17
to Node-RED
Hey Sebastian, 

Hey Sebastian,

I would say that this solution is exactly like inputing the Id of the flow and then executing the Get /flow/:id, 
But I think it is sufficient at the moment. The idea was to have a dynamic export node but as I can see there isn't a lot of use cases for it anyways.

Thanks for your help.
Reply all
Reply to author
Forward
0 new messages