Start/stop

2,189 views
Skip to first unread message

Professor Hantzen

unread,
Oct 20, 2016, 3:16:45 PM10/20/16
to Node-RED
Hi there,

I just discovered node-red a few days ago.  I'm a Ripple developer and found node-red through the announcement that Interledger (a Ripple Labs project) has joined JS Foundation.  I love what I've discovered here in node-red - being able to program node visually in a flow-based way is exactly what I've been yearning to do for years.

When I first used it, and started my first flow (which ran on a 5 minute timer), I tried for some time to figure out how to stop it again.  I did notice that in the console output, when starting a flow, the flow is first stopped by node-red.  Would it be possible to include this same "stop" functionality in a button on the node-red interface?  Being able to stop flows easily as starting them would be great.

Thanks for your help!

Mike Blackstock

unread,
Oct 20, 2016, 9:43:59 PM10/20/16
to Node-RED
I recall this suggestion coming up before more than once in different forms perhaps...


Currently the only way to stop all of your flows is to stop node-red.  You cannot deploy or save your flows to the runtime or storage without starting them (that is, if they haven't already started).

There is a case where you may have a flow that is using a node that is not installed.  In that case the UI looks like the flow has been deployed, but it hasn't.  (https://github.com/node-red/node-red/issues/832)

I recall having trouble with this when I started using node-red a few years ago, but came to appreciate the simplicity of one button deploy and the fact that my flows are just always running.  I can disable parts by unwiring the input and hit deploy again.  That said,  I agree - it would be nice to stop or disable a flow on a tab, or even stop all flows without stopping node-red.  I think Nick mentioned that is on the backlog somewhere, but I can't seem to find the relevant issue/card.   If it is something we want, I think it will be really important to get the interface right, maintaining the simplicity we have today.

Mike

Mike Biddell

unread,
Oct 21, 2016, 3:06:36 AM10/21/16
to Node-RED
Cant we just have an Enable/Disable node which you wire into your flows. Click it to disable and it puts out zero payload. This is a simple solution which doesn't involve Nick or Dave doing any work and keeps all the nice to haves.

Dave C-J

unread,
Oct 21, 2016, 4:14:19 AM10/21/16
to node...@googlegroups.com
the switch node will do it ...

[{"id":"7bbbdc70.f17b34","type":"inject","z":"896b28a8.437658","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":138,"y":1731,"wires":[["375b726b.60baee"]]},{"id":"378df000.62bc4","type":"inject","z":"896b28a8.437658","name":"enable","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"x":134,"y":1815,"wires":[["bc5f0155.bf5f2"]]},{"id":"375b726b.60baee","type":"switch","z":"896b28a8.437658","name":"gate","property":"gate","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","outputs":1,"x":331.5,"y":1731,"wires":[["e2a6c3fa.d247f"]]},{"id":"247aef8d.8cb4f","type":"inject","z":"896b28a8.437658","name":"disable","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"x":139,"y":1862,"wires":[["bc5f0155.bf5f2"]]},{"id":"bc5f0155.bf5f2","type":"change","z":"896b28a8.437658","name":"set gate","rules":[{"t":"move","p":"payload","pt":"msg","to":"gate","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":291.5,"y":1813,"wires":[[]]},{"id":"e2a6c3fa.d247f","type":"debug","z":"896b28a8.437658","name":"","active":true,"console":"true","complete":"payload","x":532,"y":1731,"wires":[]}]

Julian Knight

unread,
Oct 21, 2016, 4:50:15 AM10/21/16
to Node-RED
It would be sooooo convenient to have the ability to disable nodes without removing them from the flow.

I know there are arguments about the simplicity and potential confusion about leaving nodes turned off and then forgetting but I suspect that is an edge case for most of us and would easily be dealt with for more complex deployments by having a settings option to disable the feature. There could also be a warning note on deployment similar to the one for unused config nodes.

It isn't that this is a necessity, there are workarounds but they aren't convenient by any means. There are also cases where the workarounds aren't suitable. The main case there being nodes that talk to hardware such as serial ports. If, for some reason, the port is unavailable or erroring, being able to temporarily disable the appropriate nodes would save some sanity.

Mike Biddell

unread,
Oct 21, 2016, 6:25:46 AM10/21/16
to Node-RED
I haven't tried the switch node.... will give it a go. If we do have an enable/disable node, it should also have an input so enable and disable could be performed programmatically !!!! i.e. send the node a string of enable or disable. Obviously a click button also, which should maybe turn red and put the current state under the node. Actually, such a node would enable quite reasonable state machines e.g. Home or Away etc.

Nicholas O'Leary

unread,
Oct 21, 2016, 6:31:08 AM10/21/16
to Node-RED Mailing List
Mike,

 If we do have an enable/disable node....

The Switch node can be used for exactly this scenario - it can block a flow based on a value of either the message or of a flow/global context value . State machines etc are all absolutely possible to create using the Switch node. There is no benefit of having another node to do this task.

On the wider discussion of enabling/disabling flows, as Mike said, the discussion has been had many times and I'm not inclined to rehearse it again when a quick search of the google group will find said discussions.

tldr; enable/disable individual nodes: no. enable/disable a flow (tab): at some point, just not bubbled up the priority list.


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/2b72c1cd-f435-4f0e-8cd6-60d341b08e73%40googlegroups.com.

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

Mike Biddell

unread,
Oct 21, 2016, 6:33:02 AM10/21/16
to Node-RED
Dave

Looked at the switch node and although it works as advertised, it's just a bit complicated. If you don't mind, Dave, I'll ask my son to knock us up a single node to do it ????

I want a state machine for home or away and the proposed new node would give me exactly what I want.

It'll probably cost me several beers !!!!

Mike

Nicholas O'Leary

unread,
Oct 21, 2016, 6:38:56 AM10/21/16
to Node-RED Mailing List
Mike,

assuming our emails are cross in flight.

I would strongly urge you not to create another node for this purpose. You have all the nodes you need.

I would like to understand what about the Switch node you find complicated.

Here is a Switch node with two outputs and messages will get routed to the appropriate output based on the current value of 'flow.state'. If flow.state does not equal either 'home' or 'away', the messages will not pass through.
Inline images 1


You can then use a Change node wherever you want to modify flow.state

Inline images 2



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

Dave C-J

unread,
Oct 21, 2016, 7:44:38 AM10/21/16
to node...@googlegroups.com
...and remember ... the editor is NOT meant to be the UI... use the dashboard of your choice for that.

Mike Blackstock

unread,
Oct 21, 2016, 12:56:09 PM10/21/16
to Node-RED
Hi Nick,

Is this issue 'enable/disable a flow (tab)' tracked on the github issues list or elsewhere?  Sorry - I couldn't find it.

Just confirming - longer term node-red ideas/roadmap is still tracked on trello? https://trello.com/b/R0O3CSrI/node-red-whiteboard

Mike Blackstock
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.

Nicholas O'Leary

unread,
Oct 21, 2016, 1:05:16 PM10/21/16
to Node-RED

Hi Mike,

looks like I hadn't created an item for it. Will do.

The trello board tries to be a general view of items and the general sense of our prioritisation. The 'current' 'next' columns are guides rather than firm commitments as we try to be flexible and responsive to the unexpected. I will admit to not being rigourous in adding items there... something I know we need to improve on.

Nick


Mike Blackstock

unread,
Oct 21, 2016, 1:12:18 PM10/21/16
to node...@googlegroups.com
No problem - thanks Nick.  Just want to make sure good ideas don't get lost and that we don't add duplicate issues.

I am glad to help with this as much I can.

Mike

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/804168ee-7b1e-4048-b6bd-7a7ecd0eb1de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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



--
Mike Blackstock
Chief Technical Officer
Sense Tecnic Systems, Inc.
308 East 5th Avenue, Vancouver, BC, V5T1H4
www.sensetecnic.com

Mike Bell

unread,
Oct 21, 2016, 3:59:03 PM10/21/16
to Node-RED
Nick and Dave,

I can see that creating new nodes for every special purpose is not good for the NR ecosystem. On the other hand, using the switch node is only a partial solution in this case for a couple of reasons. First, it does not scale very well. If you want to deploy more than a few of these gates, each needs its own flow variable. Every additional gate has to be edited separately, and you need a naming convention for nodes and variables that helps keep track of things. Initializing the nodes requires either setting one of the inject nodes for the corresponding change node to inject once at start or creating a change node to set all the flow variables at once. Second, there is something of a ui/debugging issue, because the state of a gate is not visible in the editor, and connecting it to the dashboard for display and control takes some fiddling. (See my suggestion below.) 

The solution I use is a function node that transmits the input message when in the "on" state and blocks it when "off". Messages with a particular topic are treated as control rather than traffic, and their payloads are used to set the state of the gate. The function saves its state as a context variable and displays it as node.status. The node can be duplicated as many times as needed, without any modification. It is easily linked to the dashboard. An example flow is below. The javascript is beginner-level and strange in places because the function was cut down from one that included a "toggle" control option that would invert the state of the gate. I hope someone finds this useful. Suggestions for improvement are welcome.

Mike 

[{"id":"9d7517f8.ebb5e8","type":"function","z":"b1ce0795.f0efc","name":"on/off","func":"var switch_state = context.get('switch_state') || 1;\nswitch (msg.topic){\n    case 'on_off':\n        switch (msg.payload){\n            case true:\n                node.status({fill:\"green\",shape:\"dot\",text:\"enabled\"});\n                switch_state = 1;\n                break;\n            case false:\n                node.status({fill:\"red\",shape:\"dot\",text:\"disabled\"});\n                switch_state = 0;\n                break;\n        }\n        context.set('switch_state',switch_state);\n        return null;\n    default:\n        switch (switch_state){\n            case 0:\n                return null;\n            default:\n                return msg;\n        }}\n","outputs":1,"noerr":0,"x":550,"y":100,"wires":[["9d8b7fd9.69fda","b279caa6.9b108"]]},{"id":"294d0eae.af0962","type":"ui_switch","z":"b1ce0795.f0efc","name":"log","label":"Event Log","group":"d457819d.2ba88","order":1,"width":0,"height":0,"topic":"on_off","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":430,"y":100,"wires":[["9d7517f8.ebb5e8"]]},{"id":"9891e913.4b0a68","type":"inject","z":"b1ce0795.f0efc","name":"on","topic":"on/off","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":true,"x":290,"y":80,"wires":[["294d0eae.af0962"]]},{"id":"18249915.8099ef","type":"inject","z":"b1ce0795.f0efc","name":"off","topic":"on/off","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"x":290,"y":120,"wires":[["294d0eae.af0962"]]},{"id":"6c52a09e.46d54","type":"link in","z":"b1ce0795.f0efc","name":"write log","links":["1c5fa7c1.e3a058"],"x":475,"y":140,"wires":[["9d7517f8.ebb5e8"]]},{"id":"9d8b7fd9.69fda","type":"file","z":"b1ce0795.f0efc","name":"write log","filename":"/home/pi/.node-red/log","appendNewline":true,"createDir":false,"overwriteFile":"false","x":680,"y":100,"wires":[]},{"id":"b279caa6.9b108","type":"debug","z":"b1ce0795.f0efc","name":"log message","active":true,"console":"false","complete":"payload","x":690,"y":140,"wires":[]},{"id":"27729360.de675c","type":"comment","z":"b1ce0795.f0efc","name":"log","info":"","x":410,"y":140,"wires":[]},{"id":"d457819d.2ba88","type":"ui_group","z":"","name":"Notifications","tab":"2ddaedbc.d22512","order":3,"disp":true,"width":"6"},{"id":"2ddaedbc.d22512","type":"ui_tab","z":"","name":"UPS1","icon":"dashboard","order":2}]

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

Dave C-J

unread,
Oct 21, 2016, 5:22:02 PM10/21/16
to node...@googlegroups.com
Mike

indeed - a perfectly valid way to do it.
Must admit I usually use a function for this sort of thing also but used a switch as it may be simpler for others to understand.

Mike Biddell

unread,
Oct 22, 2016, 4:39:46 AM10/22/16
to Node-RED
Mike

You are describing precisely the node I had in mind. The status appearing as a red or green box under the node and configurable payload for enabled or disabled.
When I said it was complicated, I didn't mean I couldn't understand it. I meant it was messy, hard to track, not intuitive, not visual and proliferated nodes.

However, if I was the creator of node-red, I would reserve the right to recommend whether a node should exist or not and as such Dave and Nick obviously should have the final say !!! You could end up with a tower of Babel situation if you are not careful. 

Mike

Professor Hantzen

unread,
Oct 22, 2016, 10:49:38 AM10/22/16
to Node-RED
Thank you all for the responses.  I'm glad to have discovered such an enthusiastic community here.  

From what I understand, it is on the roadmap to enable/disable particular flows (tabs) - and this will be implemented at some point.  That's great!  As others have remarked, one important reason it's useful is for "panic" situations. We all make mistakes, and when a flow is deployed with a bug this can end up causing annoyance, for example, by maxing out the Twitter API by mistake.  Or it could conceivably have an even potentially dangerous real-world effect, like mistakenly setting off a real-world alarm.

Being able to "un-deploy" a particular flow without affecting other deployed flows will be great, but I can be patient and will try some of the workarounds here. Thanks again! :)
Message has been deleted

Julian Knight

unread,
Oct 24, 2016, 8:27:02 AM10/24/16
to Node-RED
And Nick/Dave are ... usually ... fairly patient with us all ;-)

But this is open source so we are all free to create stuff that works in the ecosystem like contributed nodes if we feel strongly enough. So there is nothing stopping people from creating a contributed node with a simply on/off switch and a status if that was what they needed. Even if you then retired it should the core capabilities catch up in the future. I did that with one of my contributed nodes.

Matha Goram

unread,
Apr 6, 2017, 9:28:52 AM4/6/17
to Node-RED
"... maxing out the Twitter API by mistake..."

Just did it with my very first flow (without obeying the command - Read The Manual) and panicked for "a" button!

Regards.
Reply all
Reply to author
Forward
0 new messages