User programmed commands

Hello,
Dont know if something as simplistic as this could work:

[{"id":"8f66fca2.30a2c","type":"ui_button","z":"8dcb5519.97c368","name":"","group":"f2b3b649.3a0428","order":2,"width":0,"height":0,"passthru":false,"label":"forwards","tooltip":"","color":"","bgcolor":"","icon":"","payload":"forward","payloadType":"str","topic":"","x":220,"y":360,"wires":[["74feed45.2c380c"]]},{"id":"6e440910.6bb2c8","type":"ui_button","z":"8dcb5519.97c368","name":"","group":"f2b3b649.3a0428","order":1,"width":0,"height":0,"passthru":false,"label":"backwards","tooltip":"","color":"","bgcolor":"","icon":"","payload":"backwards","payloadType":"str","topic":"","x":230,"y":420,"wires":[["74feed45.2c380c"]]},{"id":"748ce9d1.9924f8","type":"ui_button","z":"8dcb5519.97c368","name":"","group":"f2b3b649.3a0428","order":3,"width":0,"height":0,"passthru":false,"label":"turn left","tooltip":"","color":"","bgcolor":"","icon":"","payload":"left","payloadType":"str","topic":"","x":220,"y":480,"wires":[["74feed45.2c380c"]]},{"id":"2fd0ce4b.ccbf5a","type":"ui_button","z":"8dcb5519.97c368","name":"","group":"f2b3b649.3a0428","order":4,"width":0,"height":0,"passthru":false,"label":"turn right","tooltip":"","color":"","bgcolor":"","icon":"","payload":"right","payloadType":"str","topic":"","x":220,"y":540,"wires":[["74feed45.2c380c"]]},{"id":"a84a1d4f.fc84a","type":"ui_text","z":"8dcb5519.97c368","group":"89538443.9a52d8","order":5,"width":"0","height":"0","name":"","label":"command queue:","format":"{{msg.payload}}","layout":"col-center","x":850,"y":480,"wires":[]},{"id":"adf22118.84a4c8","type":"ui_button","z":"8dcb5519.97c368","name":"","group":"89538443.9a52d8","order":7,"width":0,"height":0,"passthru":false,"label":"execute queue","tooltip":"","color":"","bgcolor":"","icon":"","payload":"clear","payloadType":"str","topic":"","x":240,"y":600,"wires":[["b3358875.cac53"]]},{"id":"74feed45.2c380c","type":"function","z":"8dcb5519.97c368","name":"make queue","func":"let queue = flow.get(\"queue\") || [];\nqueue.push(msg.payload);\nmsg.payload = queue.toString();\nflow.set(\"queue\", queue);\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":460,"wires":[["a84a1d4f.fc84a"]]},{"id":"b3358875.cac53","type":"function","z":"8dcb5519.97c368","name":"empty queue","func":"let queue = flow.get(\"queue\");\nconst times = queue.length;\nfor(i=0; i<times; i++){\n    let command = queue.shift();\n    node.send([{payload:queue.toString()},{payload:command}]);\n}\nreturn [{payload:\"queue done\"},{payload:\"\"}];","outputs":2,"noerr":0,"x":440,"y":600,"wires":[["59e27146.f7a68"],["950607ee.231ca8"]]},{"id":"59e27146.f7a68","type":"delay","z":"8dcb5519.97c368","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":540,"wires":[["a84a1d4f.fc84a"]]},{"id":"950607ee.231ca8","type":"delay","z":"8dcb5519.97c368","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":630,"y":620,"wires":[["1bec9616.f7999a"]]},{"id":"1bec9616.f7999a","type":"ui_text","z":"8dcb5519.97c368","group":"89538443.9a52d8","order":6,"width":0,"height":0,"name":"","label":"command beeing executed:","format":"{{msg.payload}}","layout":"row-spread","x":930,"y":620,"wires":[]},{"id":"f2b3b649.3a0428","type":"ui_group","z":"","name":"commands","tab":"3408b43d.f3fcac","order":1,"disp":true,"width":"6","collapse":false},{"id":"89538443.9a52d8","type":"ui_group","z":"","name":"queue","tab":"3408b43d.f3fcac","order":2,"disp":true,"width":"6","collapse":false},{"id":"3408b43d.f3fcac","type":"ui_tab","name":"Tab 6","icon":"dashboard","order":6}]

Where you have the commands and can add them to a queue which you can than execute on the push of another button.
This is of course just a basic proof of concept i threw together but maybe its and idea for a starting point. (disclaimer: i tested this for about 30 seconds, so it might have errors)

Johannes

3 Likes