berijan

Subflowsample

Feb 15th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. [{"id":"c86a224a6af0f379","type":"subflow","name":"Subflow 1","info":"","category":"","in":[{"x":120,"y":120,"wires":[{"id":"be7a1b56ee2a7ee2"}]}],"out":[{"x":1340,"y":120,"wires":[{"id":"151c4ff947b1e0f8","port":0}]},{"x":1340,"y":200,"wires":[{"id":"a26ddd55096dc297","port":0}]}],"env":[{"name":"color_temp","type":"num","value":"177"},{"name":"brightness","type":"num","value":"255"},{"name":"white_value","type":"num","value":"255"}],"meta":{},"color":"#DDAA99"},{"id":"758c17d5cf3e2524","type":"change","z":"c86a224a6af0f379","name":"default light data","rules":[{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"payload.color_temp","pt":"msg","to":"color_temp","tot":"env"},{"t":"set","p":"payload.brightness","pt":"msg","to":"brightness","tot":"env"},{"t":"set","p":"payload.white_value","pt":"msg","to":"white_value","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":280,"wires":[[]]},{"id":"d67049ce6efa10e0","type":"function","z":"c86a224a6af0f379","name":"set light data as payload","func":"msg.payload = {};\n\nif (!msg.subInputMsg.color_temp)\n msg.payload.color_temp = env.get(\"color_temp\");\nelse\n //Use color temp from input\n msg.payload.color_temp = msg.subInputMsg.color_temp; \n\n\nif (!msg.subInputMsg.brightness)\n msg.payload.brightness = env.get(\"brightness\");\nelse\n //Data from input msg\n msg.payload.brightness = msg.subInputMsg.brightness; \n\n\nif (!msg.subInputMsg.white_value)\n msg.payload.white_value = env.get(\"white_value\");\nelse\n //Data from input msg\n msg.payload.white_value = msg.subInputMsg.white_value; \n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":670,"y":120,"wires":[["a26ddd55096dc297","151c4ff947b1e0f8","bccd491b38e40a89"]]},{"id":"be7a1b56ee2a7ee2","type":"function","z":"c86a224a6af0f379","name":"Save original input msg","func":"let newMsg = {};\nnewMsg.payload = {};\n\n//store original input message for later use if neccesary\nnewMsg.subInputMsg = msg;\n\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":120,"wires":[["d67049ce6efa10e0"]]},{"id":"bccd491b38e40a89","type":"debug","z":"c86a224a6af0f379","name":"dbg1 in sub","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":220,"wires":[]},{"id":"a26ddd55096dc297","type":"function","z":"c86a224a6af0f379","name":"lightData as payload + sub input data","func":"let newMsg = {};\nnewMsg.payload = msg.payload;\nnewMsg.subInputMsg = msg.subInputMsg;\n\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1090,"y":200,"wires":[[]]},{"id":"151c4ff947b1e0f8","type":"function","z":"c86a224a6af0f379","name":"lightData as payload","func":"let newMsg = {};\nnewMsg.payload = msg.payload;\nreturn newMsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1040,"y":120,"wires":[[]]},{"id":"b8bb3360ea432406","type":"comment","z":"c86a224a6af0f379","name":"Other way to use sub parameter","info":"","x":270,"y":240,"wires":[]},{"id":"746a0141e06ba991","type":"tab","label":"SubflowTest","disabled":false,"info":"","env":[]},{"id":"810ac48f6c2606fe","type":"subflow:c86a224a6af0f379","z":"746a0141e06ba991","name":"","env":[{"name":"white_value","value":"256","type":"num"}],"x":460,"y":180,"wires":[["4a9a61279938513e"],["15e1808ca1801952"]]},{"id":"90d33c66d3fdf6e4","type":"inject","z":"746a0141e06ba991","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":140,"wires":[["810ac48f6c2606fe"]]},{"id":"4a9a61279938513e","type":"debug","z":"746a0141e06ba991","name":"dbg sub out1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":160,"wires":[]},{"id":"bc678738c83417db","type":"inject","z":"746a0141e06ba991","name":"Brightness","props":[{"p":"brightness","v":"10","vt":"num"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"This could be the remote data","payloadType":"str","x":160,"y":200,"wires":[["810ac48f6c2606fe"]]},{"id":"5b8f6b7c93632da9","type":"inject","z":"746a0141e06ba991","name":"color_temp & white_value","props":[{"p":"color_temp","v":"45","vt":"num"},{"p":"white_value","v":"127","vt":"num"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"This could be the remote data","payloadType":"str","x":210,"y":260,"wires":[["810ac48f6c2606fe"]]},{"id":"15e1808ca1801952","type":"debug","z":"746a0141e06ba991","name":"dbg sub out2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":200,"wires":[]}]
Advertisement
Add Comment
Please, Sign In to add comment