Example flow for 'comment'

Following on from my previous post,here is a sample flow that I have put together that comprises of a couple of text boxes and a button with a bit of validation.

Be gentle with me!

As I am still getting to grips with Node Red (its only been few days), I have found that there are some 13 nodes involved in this simple exercise. Basically each drop down needs to have had a selection made before pressing the button otherwise throw out an error.

Am I on the right track here? - it does work but there is 'working' and 'working' ....!
Maybe I am missing a few shortcuts that I need to learn and perhaps I have made this a bit too long winded..! It's all a learning process and I want to be sure I am on the right track,

[{"id":"b63250fb.860ad8","type":"ui_dropdown","z":"a8343255.189ef","name":"","label":"Plug Type","tooltip":"","place":"Select option","group":"5c6086d3.9b1118","order":1,"width":0,"height":0,"passthru":true,"multiple":false,"options":[],"payload":"","topic":"","x":500,"y":820,"wires":[["a26c5c76.7e0fb8"]]},{"id":"a26c5c76.7e0fb8","type":"switch","z":"a8343255.189ef","name":"Plug Type","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"A","vt":"str"},{"t":"eq","v":"B","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":680,"y":820,"wires":[["6c2aaa83.a5d364"],["6c2aaa83.a5d364"]]},{"id":"6c2f1b16.fb9c7c","type":"inject","z":"a8343255.189ef","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":820,"wires":[["88926d49.c4b8f8","24d60f2a.117c28"]]},{"id":"88926d49.c4b8f8","type":"change","z":"a8343255.189ef","name":"Set Plug type","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\"A\",\"B\"]","tot":"json"},{"t":"set","p":"options","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":820,"wires":[["b63250fb.860ad8"]]},{"id":"b02b0f60.b8bc28","type":"ui_dropdown","z":"a8343255.189ef","name":"","label":"Location ","tooltip":"","place":"Select option","group":"5c6086d3.9b1118","order":2,"width":0,"height":0,"passthru":true,"multiple":false,"options":[],"payload":"","topic":"","x":500,"y":900,"wires":[["6d9ea8e4.97b11"]]},{"id":"8284a54c.b08ca8","type":"ui_button","z":"a8343255.189ef","name":"","group":"5c6086d3.9b1118","order":3,"width":0,"height":0,"passthru":false,"label":"Configure","tooltip":"","color":"","bgcolor":"","icon":"","payload":"smartplug","payloadType":"flow","topic":"","x":280,"y":980,"wires":[["3789ab59.8f78fc"]]},{"id":"24d60f2a.117c28","type":"change","z":"a8343255.189ef","name":"Set plug location ","rules":[{"t":"set","p":"payload","pt":"msg","to":"[\"Local 1\",\"Local 2\",\"Local 3\",\"Local 4\"]","tot":"json"},{"t":"set","p":"options","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":900,"wires":[["b02b0f60.b8bc28"]]},{"id":"3789ab59.8f78fc","type":"function","z":"a8343255.189ef","name":"","func":"if (flow.get('typepresent') === true && flow.get('locationpresent') === true) {\n        msg.enabled = true;\n        flow.set('typepresent', undefined);\n        flow.set('locationpresent',undefined);\n        return [msg, null];\n} \nelse {\n    msg.payload = 'Error';\n    return [null,msg];\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":500,"y":980,"wires":[["84c0616a.283ea8"],["c16309e3.a3aae"]]},{"id":"6d9ea8e4.97b11","type":"switch","z":"a8343255.189ef","name":"Location ","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Local 1","vt":"str"},{"t":"eq","v":"Local 2","vt":"str"},{"t":"eq","v":"Local 3","vt":"str"},{"t":"eq","v":"Local 4","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":680,"y":900,"wires":[["7232ee93.47cf7"],["7232ee93.47cf7"],["7232ee93.47cf7"],["7232ee93.47cf7"]]},{"id":"6c2aaa83.a5d364","type":"function","z":"a8343255.189ef","name":"","func":"flow.set('smartplug.type',msg.payload);\nflow.set('typepresent',true);\n//node.warn('hallo ' + msg.payload);return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":860,"y":820,"wires":[[]]},{"id":"7232ee93.47cf7","type":"function","z":"a8343255.189ef","name":"","func":"flow.set('smartplug.location',msg.payload);\nflow.set('locationpresent',true);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":860,"y":900,"wires":[[]]},{"id":"c16309e3.a3aae","type":"ui_toast","z":"a8343255.189ef","position":"prompt","displayTime":"3","highlight":"","sendall":true,"outputs":1,"ok":"OK","cancel":"","raw":false,"topic":"","name":"","x":690,"y":1060,"wires":[[]]},{"id":"84c0616a.283ea8","type":"debug","z":"a8343255.189ef","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":980,"wires":[]},{"id":"5c6086d3.9b1118","type":"ui_group","z":"","name":"Smart Plugs","tab":"b44b7bd3.3905e8","order":1,"disp":true,"width":"6","collapse":false},{"id":"b44b7bd3.3905e8","type":"ui_tab","z":"","name":"System","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

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