Can I place a switch between two nodes in order to 1) in one position allow the flow, and 2) in another position stop the flow of information between them?
So I am tinkering with this example, and the switch provides true or false, which permits the function to pass on the time stamp to the output. But if I try anything other than a time stamp, such as a node that injects a number, it doesn't work for me. What am I not understanding?
[{"id":"53df21e9.a21a3","type":"ui_switch","z":"b94485da.7ea138","name":"","label":"Message over ride switch","group":"609a4324.b967cc","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"gate","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":153,"y":1016,"wires":[["334615e1.4220ca"]]},{"id":"334615e1.4220ca","type":"function","z":"b94485da.7ea138","name":"control","func":"if (msg.topic === \"gate\") {\n context.pass = (msg.payload === true) ? true : false;\n return null; // exit out early as it's just the control\n}\nif (context.pass) {\n return msg; // if enabled pass msg\n}\nreturn null; // or drop it","outputs":1,"noerr":0,"x":328,"y":1058,"wires":[["10d243f.a851cbc"]]},{"id":"d2316b66.880828","type":"inject","z":"b94485da.7ea138","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":"","x":162.5,"y":1100,"wires":[["334615e1.4220ca"]]},{"id":"10d243f.a851cbc","type":"ui_text","z":"b94485da.7ea138","group":"609a4324.b967cc","order":0,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","x":533.5,"y":1111.3499755859375,"wires":[]},{"id":"609a4324.b967cc","type":"ui_group","z":"","name":"Column two","tab":"2b7805f9.7f5ada","disp":true,"width":"6","collapse":false},{"id":"2b7805f9.7f5ada","type":"ui_tab","z":"b94485da.7ea138","name":"Home","icon":"dashboard"}]
On Friday, April 20, 2018 at 2:36:04 PM UTC-5, timothym...@gmail.com wrote:Found this in the Node Red Library:which gives an example of using a switch to inject a value into a function, that stops that function from passing through messages from another node. I will see if I can modify it for my purposes.Can I place a switch between two nodes in order to 1) in one position allow the flow, and 2) in another position stop the flow of information between them? 3) Can I load the switch with a value that it will then send to the second node instead of what was previously going to pass through the switch?
--
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/66702f20-6297-4a5b-b888-9e0074a8dd24%40googlegroups.com.
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.
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/8150081a-d2a3-4740-b2ee-0bd9936cd545%40googlegroups.com.
Can you take a look at this flow? For some reason, I can't get any output from the last control that the message override switch controls. The debug feeding into it shows there is input of 90 when triggered, but the debug on the output shows nothing. Maybe its the naming of the message (gate : msg.payload : number) ?[{"id":"77f298e7.40cb18","type":"function","z":"fe166526.3bb3b8","name":"+ Check Deviation","func":"if (msg.payload > 30)\n{\nvar temp = \"Warning! \";\nmsg.payload = temp.concat(msg.payload);\nvar tag = \" Zero Distance\";\nmsg.payload = msg.payload.concat(tag);\nmsg.topic = 'check3';\nreturn msg;\n}","outputs":1,"noerr":0,"x":520.9000244140625,"y":2342.800048828125,"wires":[["9bffa656.ee9ed8"]]},{"id":"ebdbbb15.2db2c8","type":"function","z":"fe166526.3bb3b8","name":"control","func":"if (msg.topic === \"gate\") {\n context.pass = (msg.payload === true) ? true : false;\n return null; // exit out early as it's just the control\n}\nif (context.pass) {\n return msg; // if enabled pass msg\n}\nreturn null; // or drop it","outputs":1,"noerr":0,"x":335.8999938964844,"y":2345.800048828125,"wires":[["77f298e7.40cb18"]]},{"id":"8533b0e7.234a9","type":"function","z":"fe166526.3bb3b8","name":"send reset","func":"if (msg.payload === true)\n{\n return null;\n}\nelse if (msg.payload === false)\n{\n msg.payload = 'Distance OK';\n return msg;\n}\n","outputs":1,"noerr":0,"x":317.8999938964844,"y":2397.800048828125,"wires":[["9bffa656.ee9ed8"]]},{"id":"9bffa656.ee9ed8","type":"trigger","z":"fe166526.3bb3b8","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-5","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":529.9000244140625,"y":2398.800048828125,"wires":[["87fb84a5.83cdb8"]]},{"id":"87fb84a5.83cdb8","type":"ui_text","z":"fe166526.3bb3b8","group":"df51a64f.b86e98","order":0,"width":0,"height":0,"name":"Dist Warn","label":"","format":"{{msg.payload}}","layout":"row-spread","x":635.4000244140625,"y":2456,"wires":[]},{"id":"86431c0c.ebaf7","type":"arduino in","z":"fe166526.3bb3b8","name":"Sharp Distance Sensor Front","pin":"7","state":"ANALOG","arduino":"5204a4b7.37058c","x":135.89999389648437,"y":2263.800048828125,"wires":[["f7958914.8d6dd8"]]},{"id":"995de55f.f29c88","type":"ui_text","z":"fe166526.3bb3b8","group":"df51a64f.b86e98","order":7,"width":0,"height":0,"name":"","label":"IR dist frt (cm)","format":"{{40-msg.payload}}","layout":"row-spread","x":516.9000244140625,"y":2261.2001953125,"wires":[]},{"id":"f7958914.8d6dd8","type":"range","z":"fe166526.3bb3b8","minin":"100","maxin":"450","minout":"0","maxout":"40","action":"clamp","round":true,"property":"payload","name":"","x":342.9000549316406,"y":2260.60009765625,"wires":[["995de55f.f29c88","ebdbbb15.2db2c8","c35b473.964a6b8"]]},{"id":"c35b473.964a6b8","type":"function","z":"fe166526.3bb3b8","name":"threshold distance","func":" msg.topic = 'gate';\nif (msg.payload > 30)\n{\n msg.payload = true;\n return msg;\n}\nelse if (msg.payload < 29)\n{\n msg.payload = false;\n return msg;\n}\n","outputs":1,"noerr":0,"x":113,"y":2346,"wires":[["ebdbbb15.2db2c8","8533b0e7.234a9","f637a7a3.7237f8"]]},{"id":"f637a7a3.7237f8","type":"function","z":"fe166526.3bb3b8","name":"threshold distance","func":" msg.topic = 'gate';\nif (msg.payload === true)\n{\n msg.payload = 90;\n return msg;\n}\nelse if (msg.payload === false)\n{\n }\n","outputs":1,"noerr":0,"x":127,"y":2440,"wires":[["83f50445.ad3958","206520d.bf860e","966a157b.86eab8"]]},{"id":"83f50445.ad3958","type":"arduino out","z":"fe166526.3bb3b8","name":"Throttle Servo","pin":"24","state":"SERVO","arduino":"5204a4b7.37058c","x":631,"y":2554,"wires":[]},{"id":"206520d.bf860e","type":"debug","z":"fe166526.3bb3b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":452.5,"y":2482.2999877929687,"wires":[]},{"id":"a3168d0f.09a74","type":"ui_switch","z":"fe166526.3bb3b8","name":"","label":"Message over ride switch","group":"df51a64f.b86e98","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"gate","style":"","onvalue":"false","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"true","offvalueType":"bool","officon":"","offcolor":"","x":135,"y":2607,"wires":[["966a157b.86eab8"]]},{"id":"966a157b.86eab8","type":"function","z":"fe166526.3bb3b8","name":"control","func":"if (msg.topic === \"gate\") {\n context.pass = (msg.payload === true) ? true : false;\n return null; // exit out early as it's just the control\n}\nif (context.pass !== false) {\n return msg; // if enabled pass msg\n}\nreturn null; // or drop it","outputs":1,"noerr":0,"x":341,"y":2609,"wires":[["770df7e9.ca0498","b5610c38.a34f7"]]},{"id":"770df7e9.ca0498","type":"ui_text","z":"fe166526.3bb3b8","group":"df51a64f.b86e98","order":0,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","x":528.5,"y":2631.35009765625,"wires":[]},{"id":"b5610c38.a34f7","type":"debug","z":"fe166526.3bb3b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":574.5,"y":2716.300048828125,"wires":[]},{"id":"df51a64f.b86e98","type":"ui_group","z":"","name":"Column 3","tab":"4a3b55c0.22eccc","order":4,"disp":false,"width":"3","collapse":false},{"id":"5204a4b7.37058c","type":"arduino-board","z":"","device":"/dev/ttyACM0"},{"id":"4a3b55c0.22eccc","type":"ui_tab","z":"","name":"Robot Dashboard","icon":"dashboard"}]
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/8150081a-d2a3-4740-b2ee-0bd9936cd545%40googlegroups.com.
--
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/8f8c3f31-036b-4d39-88fa-fb18eb09994a%40googlegroups.com.
Examine the first line of your Threshold Distance function node.
Colin
Yes, it took me until 1:00 am last night to figure that out. I should not have left the topic as gate, as that is the topic that is rejected. I changed the topic name, and it worked. I didn't realize that a topic assigned to a message, continues that characteristic after it leaves the node.
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/25e33a6b-7881-4ad9-aeee-7f7fc4fec86f%40googlegroups.com.