Just to show what I've been doing lately with `subflows` and stuff

I am sorry for all the recent stupid questions I've been asking.

I was writing some code to do some graphical animations when devices need to be charged.
This is the flow - you will have to set some flow.context stuff, sorry.

And I haven't configured the two text nodes for the GUI side.

I have put two sets of buttons for the two (of three) devices for testing and it all works.

Concept:
Batteries go flat eventually.
When the battery has 2 levels: VERY LOW and LOW.
When either of them are detected a message is sent.

I plug them in and CHARGE them.

When it is full, it tells me and turns the power off to stop charging the device.

Then when I unplug the device the notification is wiped.
(As I'm typing this, I see a problem with what I've done. But it isn't the end of the world.)

But you may enjoy looking at it.

So, to use:

There are some inject nodes.
REQEUEST2
REQUEST
DETECTED
FULL
GONE

The two REQUEST are to show the two different low battery warnings.
DETECTED means it is charging.
FULL - speaks for itself.
GONE - when I remove the power.

The GUI is quite fun to watch.

[{"id":"ca5e1e7f2227fa14","type":"subflow","name":"Blinker","info":"2021 12 7  \nA subflow to send pulsing messages at a given interval to make something *flash*.\n\nConfigurable by setting `environment` variables in the node's settings.\n\n\n# **Output toggle node to send alternating messages at a specified frequency.**\n# \n\n## 3 things need to be set to configure this subflow\n1 - `delay`:  milliseconds between toggles (override with msg.delay)\n\n2 - `msg1`:   text message for state 1  \n\n3 - `msg2`:   text message for state 2 \n\n`msg.topic` is output and alternates between `msg1` and `msg2` to indicate which message is being sent.\n\n## Optional:\n`offmsg` - sent when it is reset.\n\nMay be handy to make sure things are *off*.\n\n## Input message\nTo start send `msg` (anything)\n\nTo stop, send `msg.reset`","category":"","in":[{"x":50,"y":80,"wires":[{"id":"3a95f6976aee6fd0"}]}],"out":[{"x":920,"y":70,"wires":[{"id":"f3b2b2634e2662cd","port":1},{"id":"a655faf0bc379507","port":0},{"id":"ee7989afdda9f61c","port":0}]},{"x":920,"y":120,"wires":[{"id":"ee7989afdda9f61c","port":1}]}],"env":[{"name":"delay","type":"num","value":""},{"name":"msg1","type":"str","value":""},{"name":"msg2","type":"str","value":""},{"name":"offmsg","type":"str","value":""}],"meta":{"module":"Toggler","version":"0.1.1","desc":"Toggles output between `msg1` and `msg2` set in node config"},"color":"#A6BBCF","icon":"node-red-contrib-bool-gate/switch.png","status":{"x":920,"y":170,"wires":[{"id":"502c279ae9a6f385","port":0}]}},{"id":"c53ebcc9e62a7552","type":"trigger","z":"ca5e1e7f2227fa14","name":"resend every x","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-1","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":430,"y":80,"wires":[["f3b2b2634e2662cd","ee7989afdda9f61c"]]},{"id":"f3b2b2634e2662cd","type":"function","z":"ca5e1e7f2227fa14","d":true,"name":"toggle","func":"delete msg.delay;\nconst msg1 = {};\nlet c = context.get(\"counter\") ||0;\n\nif (c == 0) {\n    //  0\n    msg.payload = env.get(\"msg1\");\n    msg.topic = \"msg1\";\n} else if (c == 1) {\n    //  1\n    msg.payload = env.get(\"msg2\");\n    msg.topic = \"msg2\";\n};\n\nmsg1.payload = c;\nc = (c + 1) % 2;\ncontext.set(\"counter\",c);\nreturn [msg1,msg];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":600,"y":290,"wires":[["502c279ae9a6f385"],[]]},{"id":"c183245c1a6a7fac","type":"switch","z":"ca5e1e7f2227fa14","name":"is reset?","property":"reset","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":410,"y":170,"wires":[["a9be61803cd67654","6e3a0cdb44f6a994"]]},{"id":"a9be61803cd67654","type":"switch","z":"ca5e1e7f2227fa14","name":"off msg?","property":"offmsg","propertyType":"env","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":610,"y":130,"wires":[["a655faf0bc379507"]]},{"id":"a655faf0bc379507","type":"change","z":"ca5e1e7f2227fa14","name":"set off message","rules":[{"t":"set","p":"payload","pt":"msg","to":"offmsg","tot":"env"},{"t":"delete","p":"reset","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":130,"wires":[[]]},{"id":"502c279ae9a6f385","type":"function","z":"ca5e1e7f2227fa14","name":"status","func":"const c = msg.payload;\n\nif (c == 0) {\n    msg.payload = ({text: \"msg1\"});\n} else if (c == 1) {\n    msg.payload = ({text: \"msg2\"});\n} else {\n    msg.payload = ({text:\"\"});\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":170,"wires":[[]]},{"id":"6e3a0cdb44f6a994","type":"change","z":"ca5e1e7f2227fa14","name":"reset","rules":[{"t":"set","p":"payload","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":170,"wires":[["502c279ae9a6f385"]]},{"id":"3a95f6976aee6fd0","type":"function","z":"ca5e1e7f2227fa14","name":"set msg.delay","func":"msg.delay = msg.delay || env.get(\"delay\") || 1000;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":80,"wires":[["c53ebcc9e62a7552","c183245c1a6a7fac"]]},{"id":"ee7989afdda9f61c","type":"function","z":"ca5e1e7f2227fa14","name":"2022 02 26 *","func":"delete msg.delay;\nconst msgnull = null;\nconst msgS = {};\nlet c = context.get(\"counter\") ||0;\ncontext.set(\"counter\",((c + 1) % 2));\n\nif (c == 0) {\n    //  0\n    msg.payload = env.get(\"msg1\");\n    msg.topic = \"msg1\";\n    //\n    msgS.payload =c;\n    return[msg,msgnull,msgS];\n    //\n} else if (c == 1) {\n    //  1\n    msg.payload = env.get(\"msg2\");\n    msg.topic = \"msg2\";\n    //\n    msgS.payload =c;\n    return[msgnull,msg,msgS];\n    //\n};\n\n//msgS.payload = c;\n//return [msg,msgS];\n","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":80,"wires":[[],[],["502c279ae9a6f385"]],"outputLabels":["msgA","msgB","which message"],"info":"This has 2 outputs to allow message modification straight out of subflowl\n`msg.stop` is sent to only the first output"},{"id":"57abdb6a81108b5e","type":"subflow","name":"Charging animation","info":"# 2022 01 22\n#\nUsed to show battery charging animation\nin `text` node.\n`delay` variable adjustable for speed.\n\nStop with `msg.payload` set to `STOP`\nStart with any other message.\n","category":"","in":[{"x":70,"y":90,"wires":[{"id":"2ede7a21936f7648"}]}],"out":[{"x":680,"y":290,"wires":[{"id":"13f371dc65ce64c2","port":0},{"id":"68a52078c46c883c","port":0},{"id":"0ab56842292fb9d3","port":0},{"id":"0726957e9177a1df","port":0},{"id":"67114f6ac6d2b992","port":0},{"id":"ece03e225293b162","port":0}]}],"env":[{"name":"Delay","type":"num","value":"","ui":{"label":{"en-US":"delay"},"type":"input","opts":{"types":["num"]}}}],"meta":{"type":"BatteryChargingAnimation","version":"0.0.1","desc":"Shows battery charging animation"},"color":"#DDAA99"},{"id":"735de64a63a01964","type":"change","z":"57abdb6a81108b5e","name":"","rules":[{"t":"move","p":"count","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":160,"wires":[["99d7f4e8957e5146"]]},{"id":"eae4805a3ab61cc5","type":"counter","z":"57abdb6a81108b5e","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":"1","x":270,"y":160,"wires":[["735de64a63a01964"]]},{"id":"99d7f4e8957e5146","type":"switch","z":"57abdb6a81108b5e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"}],"checkall":"true","repair":false,"outputs":5,"x":340,"y":290,"wires":[["13f371dc65ce64c2"],["68a52078c46c883c"],["0ab56842292fb9d3"],["0726957e9177a1df"],["67114f6ac6d2b992","303ab05667ee32d1"]]},{"id":"085ec0363af843e6","type":"trigger","z":"57abdb6a81108b5e","name":"Clock","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-600","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":120,"wires":[["eae4805a3ab61cc5"]]},{"id":"6d2f7066155fd9f4","type":"change","z":"57abdb6a81108b5e","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":120,"wires":[["eae4805a3ab61cc5"]]},{"id":"13f371dc65ce64c2","type":"change","z":"57abdb6a81108b5e","name":"Battery 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"<font color = \"red\"><i class=\"fa fa-battery-empty fa-2x fa-bold fa-rotate-270\"></i></font>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":210,"wires":[[]]},{"id":"68a52078c46c883c","type":"change","z":"57abdb6a81108b5e","name":"Battery 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"<font color = \"orange\"><i class=\"fa fa-battery-1 fa-2x fa-bold fa-rotate-270\"></i></font>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":250,"wires":[[]]},{"id":"0ab56842292fb9d3","type":"change","z":"57abdb6a81108b5e","name":"Battery 2","rules":[{"t":"set","p":"payload","pt":"msg","to":"<font color = \"yellow\"><i class=\"fa fa-battery-2 fa-2x fa-bold fa-rotate-270\"></i></font>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":290,"wires":[[]]},{"id":"0726957e9177a1df","type":"change","z":"57abdb6a81108b5e","name":"Battery 3","rules":[{"t":"set","p":"payload","pt":"msg","to":"<font color = \"green\"><i class=\"fa fa-battery-3 fa-2x fa-bold fa-rotate-270\"></i></font>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":330,"wires":[[]]},{"id":"67114f6ac6d2b992","type":"change","z":"57abdb6a81108b5e","name":"Battery 4","rules":[{"t":"set","p":"payload","pt":"msg","to":"<font color = \"lime\"><i class=\"fa fa-battery-4 fa-2x fa-bold fa-rotate-270\"></i></font>","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":370,"wires":[[]]},{"id":"4839d9f4ddbd4d0b","type":"change","z":"57abdb6a81108b5e","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":80,"wires":[["085ec0363af843e6"]]},{"id":"2ede7a21936f7648","type":"switch","z":"57abdb6a81108b5e","name":"STOP?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"STOP","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":135,"y":90,"wires":[["9119ee83213bf78a"],["1b6d1a9471f69cf2"]],"l":false},{"id":"adf27c84eef84d24","type":"link out","z":"57abdb6a81108b5e","name":"link out 1","mode":"link","links":["b0893e6e81d70d33"],"x":685,"y":410,"wires":[]},{"id":"b0893e6e81d70d33","type":"link in","z":"57abdb6a81108b5e","name":"link in 1","links":["adf27c84eef84d24"],"x":395,"y":120,"wires":[["6d2f7066155fd9f4"]]},{"id":"1b6d1a9471f69cf2","type":"function","z":"57abdb6a81108b5e","name":"Set delay","func":"let delay = env.get(\"delay\") || 500;\nmsg.delay = delay;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":195,"y":120,"wires":[["085ec0363af843e6"]],"l":false},{"id":"303ab05667ee32d1","type":"function","z":"57abdb6a81108b5e","name":"Set delay","func":"let delay = env.get(\"delay\") || 500;\nmsg.delay = delay;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":435,"y":410,"wires":[["4ef1cc367f19376d"]],"l":false},{"id":"4ef1cc367f19376d","type":"trigger","z":"57abdb6a81108b5e","name":"Delay","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"600","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":550,"y":410,"wires":[["adf27c84eef84d24"]]},{"id":"ece03e225293b162","type":"change","z":"57abdb6a81108b5e","name":"Wipe","rules":[{"t":"set","p":"payload","pt":"msg","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":40,"wires":[[]]},{"id":"02965c74b997a840","type":"delay","z":"57abdb6a81108b5e","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":455,"y":40,"wires":[["ece03e225293b162"]],"l":false},{"id":"9119ee83213bf78a","type":"junction","z":"57abdb6a81108b5e","x":320,"y":80,"wires":[["4839d9f4ddbd4d0b","6d2f7066155fd9f4","02965c74b997a840"]]},{"id":"d1c713d69197aa7a","type":"subflow","name":"Mobile Device Power Management","info":"","category":"","in":[{"x":100,"y":250,"wires":[{"id":"9d25c4f6686c5d0f"}]}],"out":[{"x":1440,"y":120,"wires":[{"id":"9d25c4f6686c5d0f","port":0}]},{"x":1420,"y":280,"wires":[{"id":"818fa6da349f8ef1","port":0},{"id":"c6bc8295f4565cc2","port":0},{"id":"f6b8461c9ffcb055","port":0},{"id":"368666bc076f5aa0","port":0},{"id":"bcd36f8705a0696d","port":0},{"id":"818fa6da349f8ef1","port":1},{"id":"368666bc076f5aa0","port":1},{"id":"c6bc8295f4565cc2","port":1}]},{"x":1470,"y":410,"wires":[{"id":"849faa042ace856e","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","outputLabels":["LED output","Icon","240 power control"]},{"id":"9d25c4f6686c5d0f","type":"function","z":"d1c713d69197aa7a","name":"WiFi device power status message constructor","func":"//  OUTPUTS:\n//  1 - To LED\n//  2 - Animation\n//  3 - Power control\n\n//node.warn(\"Device = \" + msg.device);\n\n//  Get variables.\nlet type = msg.payload.power;\nlet who = msg.payload.who;\nlet request = flow.get(msg.payload.power);\nlet device = msg.device;\nlet led = msg[msg.payload.who];\nlet colour = msg[msg.payload.power];\n\n\n//  Create extra messages\nlet msg1 = {};\nlet msg2 = {};\n\n//node.warn(\"=============\");\n//node.warn(\"Type \" + type);\n//node.warn(\"Who \" + who);\n//node.warn(\"Device \" + device);\n//node.warn(\"Power Request \"+ request);\n//node.warn(\"Removed \" + removed);\n//node.warn(\"Full \" + full);\n//node.warn(\"Detected \" + detected);\n//node.warn(\"Request \" + request);\n//node.warn(\"Request2 \" + request2);\n//node.warn(\"Device LED (led) \" + led);\n//node.warn(\"Colour scheme (colour) \" + colour);\n//node.warn(`LED ${msg[msg.payload.who]}`);\n//node.warn(\"=============\");\n\n//  Depending on `type`.\nif (type == \"REQUEST2\") {\n    //  REQUEST\n    node.status({ fill: \"red\", shape: \"dot\", text: who + \" \" + type });\n    //  msg is `rgb,(device),request2`\n//    msg.payload = { \"device\": who, \"payload\": \"REQUEST2\", \"level\": 20 };\n    msg.payload = \"rgb,\" + led + \",\" + colour;\n    msg1.payload = type;\n    msg1.who = who;\n    return [msg, msg1, null];\n}\nelse\nif (type == \"REQUEST\") {\n    //  REQUEST\n    //    context.set(device,type);\n    node.status({ fill: \"red\", shape: \"dot\", text: who + \" \" + type });\n//    msg.payload = { \"device\": who, \"payload\": \"REQUEST\", \"level\": 20 };\n    msg.payload = \"rgb,\" + led + \",\" + colour;\n    msg1.payload = type;\n    msg1.who = who;\n    return [msg, msg1, null];\n}\nelse\nif (type == \"DETECTED\") {\n    //  DETECTED\n    node.status({ fill: \"blue\", shape: \"dot\", text: who + \" \" + type });\n//    msg.payload = { \"device\": who, \"payload\": \"DETECTED\", \"level\": 20 };\n    msg.payload = \"rgb,\" + led + \",\" + colour;\n    msg1.payload = type;\n    msg1.who = who;\n    return [msg, msg1, null];\n}\nelse\nif (type == \"FULL\") {\n    //  FULL\n    node.status({ fill: \"green\", shape: \"dot\", text: who + \" \" + type });\n//    msg.payload = { \"device\": who, \"payload\": \"FULL\", \"level\": 100 };\n    msg.payload = \"rgb,\" + led + \",\" + colour;\n    msg1.payload = type;\n    msg1.who = who;\n    msg2.payload = \"off\";\n    msg2.device = device;\n    return [msg, msg1, msg2]\n}\nelse\nif (type == \"CLEAR\") {\n    //  CLEAR\n    node.status({});\n//    msg.payload = { \"device\": who, \"payload\": \"REMOVED\", \"level\": 20 };\n    msg.payload = \"rgb,\" + led + \",\" + colour;\n    msg1.payload = type;\n    msg1.who = who;\n    return [msg, msg1, null];\n}\n","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":250,"wires":[[],["c55e245951717ef8"],["849faa042ace856e"]],"outputLabels":["LED message","ICON message","POWER message"]},{"id":"849faa042ace856e","type":"template","z":"d1c713d69197aa7a","name":"","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{device}}/cmnd/power1","output":"str","x":1080,"y":410,"wires":[[]]},{"id":"c55e245951717ef8","type":"switch","z":"d1c713d69197aa7a","name":"Condition","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"REQUEST2","vt":"str"},{"t":"eq","v":"REQUEST","vt":"str"},{"t":"eq","v":"DETECTED","vt":"str"},{"t":"eq","v":"FULL","vt":"str"},{"t":"eq","v":"CLEAR","vt":"str"}],"checkall":"true","repair":false,"outputs":5,"x":640,"y":250,"wires":[["5407299ccbc6db82","423a895aa0fb855a","b5eee13c4b37fc36","818fa6da349f8ef1"],["280b8ed8b340838f","423a895aa0fb855a","b5eee13c4b37fc36","c6bc8295f4565cc2"],["f6b8461c9ffcb055","280b8ed8b340838f","5407299ccbc6db82","423a895aa0fb855a"],["280b8ed8b340838f","5407299ccbc6db82","b5eee13c4b37fc36","368666bc076f5aa0"],["bcd36f8705a0696d","280b8ed8b340838f","5407299ccbc6db82","423a895aa0fb855a","b5eee13c4b37fc36"]]},{"id":"f6b8461c9ffcb055","type":"subflow:57abdb6a81108b5e","z":"d1c713d69197aa7a","name":"","env":[{"name":"Delay","value":"400","type":"num"}],"x":1110,"y":280,"wires":[[]]},{"id":"bcd36f8705a0696d","type":"change","z":"d1c713d69197aa7a","name":"Wipe","rules":[{"t":"set","p":"payload","pt":"msg","to":" ","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1070,"y":360,"wires":[[]]},{"id":"280b8ed8b340838f","type":"change","z":"d1c713d69197aa7a","name":"Stop","rules":[{"t":"set","p":"reset","pt":"msg","to":"foo","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":915,"y":200,"wires":[["818fa6da349f8ef1"]],"l":false},{"id":"5407299ccbc6db82","type":"change","z":"d1c713d69197aa7a","name":"Stop","rules":[{"t":"set","p":"reset","pt":"msg","to":"foo","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":915,"y":240,"wires":[["c6bc8295f4565cc2"]],"l":false},{"id":"423a895aa0fb855a","type":"change","z":"d1c713d69197aa7a","name":"Stop","rules":[{"t":"set","p":"reset","pt":"msg","to":"foo","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":915,"y":320,"wires":[["368666bc076f5aa0"]],"l":false},{"id":"b5eee13c4b37fc36","type":"change","z":"d1c713d69197aa7a","name":"Stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":915,"y":280,"wires":[["f6b8461c9ffcb055"]],"l":false},{"id":"818fa6da349f8ef1","type":"subflow:ca5e1e7f2227fa14","z":"d1c713d69197aa7a","name":"Request2","env":[{"name":"delay","value":"800","type":"num"},{"name":"msg1","value":"<font color = \"red\"><i class=\"fa fa-battery-empty fa-2x fa-bold fa-rotate-270\"></i></font>","type":"str"},{"name":"offmsg","value":" ","type":"str"}],"x":1080,"y":200,"wires":[[],[]]},{"id":"c6bc8295f4565cc2","type":"subflow:ca5e1e7f2227fa14","z":"d1c713d69197aa7a","name":"Request","env":[{"name":"delay","value":"800","type":"num"},{"name":"msg1","value":"<font color = \"red\"><i class=\"fa fa-battery-1 fa-2x fa-bold fa-rotate-270\"></i></font>","type":"str"},{"name":"msg2","value":"<font color = \"black\"><i class=\"fa fa-battery-1 fa-2x fa-bold fa-rotate-270\"></i></font>","type":"str"},{"name":"offmsg","value":" ","type":"str"}],"x":1080,"y":240,"wires":[[],[]]},{"id":"368666bc076f5aa0","type":"subflow:ca5e1e7f2227fa14","z":"d1c713d69197aa7a","name":"Full","env":[{"name":"delay","value":"800","type":"num"},{"name":"msg1","value":"<font color = \"green\"><i class=\"fa fa-battery-full fa-2x fa-bold fa-rotate-270\"></i></font>","type":"str"},{"name":"msg2","value":"<font color = \"lime\"><i class=\"fa fa-battery-full fa-2x fa-bold fa-rotate-270\"></i></font>","type":"str"},{"name":"offmsg","value":" ","type":"str"}],"x":1070,"y":320,"wires":[[],[]]},{"id":"b48744b374aa9aaa","type":"subflow","name":"MacroPowerMonitor","info":"","category":"","in":[{"x":70,"y":170,"wires":[{"id":"067e8406bce08cc8"}]}],"out":[{"x":760,"y":60,"wires":[{"id":"0a0c6d8cb2dba896","port":0}]},{"x":760,"y":110,"wires":[{"id":"28020e95a20ff685","port":1}]},{"x":750,"y":170,"wires":[{"id":"099d5c2d7b54e54c","port":1}]},{"x":760,"y":230,"wires":[{"id":"a6914bafe029f580","port":1}]},{"x":800,"y":280,"wires":[{"id":"abfed1f07e5ef343","port":0}]}],"env":[],"meta":{},"color":"#0F0DFF","outputLabels":["LED","S21","S5","other","240V power control"],"icon":"font-awesome/fa-bolt"},{"id":"067e8406bce08cc8","type":"switch","z":"b48744b374aa9aaa","name":"","property":"payload.who","propertyType":"msg","rules":[{"t":"eq","v":"S21","vt":"str"},{"t":"eq","v":"S5","vt":"str"},{"t":"eq","v":"other","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":200,"y":170,"wires":[["28020e95a20ff685"],["099d5c2d7b54e54c"],["a6914bafe029f580"]]},{"id":"099d5c2d7b54e54c","type":"subflow:d1c713d69197aa7a","z":"b48744b374aa9aaa","name":"","x":450,"y":170,"wires":[["0a0c6d8cb2dba896"],[],["abfed1f07e5ef343"]],"outputLabels":["LED output","Icon","240 power control"]},{"id":"a6914bafe029f580","type":"subflow:d1c713d69197aa7a","z":"b48744b374aa9aaa","name":"","x":450,"y":230,"wires":[["0a0c6d8cb2dba896"],[],["abfed1f07e5ef343"]],"outputLabels":["LED output","Icon","240 power control"]},{"id":"28020e95a20ff685","type":"subflow:d1c713d69197aa7a","z":"b48744b374aa9aaa","name":"","x":450,"y":110,"wires":[["0a0c6d8cb2dba896"],[],["abfed1f07e5ef343"]],"outputLabels":["LED output","Icon","240 power control"]},{"id":"0a0c6d8cb2dba896","type":"junction","z":"b48744b374aa9aaa","x":650,"y":60,"wires":[[]]},{"id":"abfed1f07e5ef343","type":"junction","z":"b48744b374aa9aaa","x":660,"y":280,"wires":[[]]},{"id":"cbce6faf1a990d00","type":"inject","z":"a1911aa3.c45be8","name":"Request 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"request","payloadType":"str","x":1680,"y":3140,"wires":[["aa56b0127f924373"]]},{"id":"aa56b0127f924373","type":"change","z":"a1911aa3.c45be8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"who\":\"S21\",\"power\":\"REQUEST2\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1795,"y":3140,"wires":[["5cb9d1e4615b4047"]],"l":false},{"id":"9ed2ee5308840f71","type":"inject","z":"a1911aa3.c45be8","name":"Request","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"request","payloadType":"str","x":1680,"y":3180,"wires":[["ca9c273d65c0b6d6"]]},{"id":"ca9c273d65c0b6d6","type":"change","z":"a1911aa3.c45be8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"who\":\"S21\",\"power\":\"REQUEST\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1795,"y":3180,"wires":[["5cb9d1e4615b4047"]],"l":false},{"id":"f8eb7f72d2db9352","type":"inject","z":"a1911aa3.c45be8","name":"Detected","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"detected","payloadType":"str","x":1680,"y":3220,"wires":[["13b38e1a51893c55"]]},{"id":"13b38e1a51893c55","type":"change","z":"a1911aa3.c45be8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"who\":\"S21\",\"power\":\"DETECTED\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1795,"y":3220,"wires":[["5cb9d1e4615b4047"]],"l":false},{"id":"6f727b03cd407da7","type":"inject","z":"a1911aa3.c45be8","name":"Full","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"full","payloadType":"str","x":1670,"y":3260,"wires":[["da8d871163ea8251"]]},{"id":"da8d871163ea8251","type":"change","z":"a1911aa3.c45be8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"who\":\"S21\",\"power\":\"FULL\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1795,"y":3260,"wires":[["5cb9d1e4615b4047"]],"l":false},{"id":"4ad5cb398c761a70","type":"inject","z":"a1911aa3.c45be8","name":"Gone","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"clear","payloadType":"str","x":1670,"y":3300,"wires":[["d66fe87c19f42af4"]]},{"id":"d66fe87c19f42af4","type":"change","z":"a1911aa3.c45be8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"who\":\"S21\",\"power\":\"CLEAR\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1795,"y":3300,"wires":[["5cb9d1e4615b4047"]],"l":false},{"id":"8de09ccd742e1816","type":"comment","z":"a1911aa3.c45be8","name":"S5","info":"","x":1990,"y":3100,"wires":[]},{"id":"f7244d148347f9b9","type":"inject","z":"a1911aa3.c45be8","name":"Request 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"request","payloadType":"str","x":2000,"y":3140,"wires":[["0eaba2a0a75c87d5"]]},{"id":"b53cae17af9c7c49","type":"inject","z":"a1911aa3.c45be8","name":"Request","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"request","payloadType":"str","x":2000,"y":3180,"wires":[["4690734070a0b4f9"]]},{"id":"b144d46688d56ded","type":"inject","z":"a1911aa3.c45be8","name":"Detected","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"detected","payloadType":"str","x":2000,"y":3220,"wires":[["97cf552179ef4762"]]},{"id":"41b5e31bd089b739","type":"inject","z":"a1911aa3.c45be8","name":"Full","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"full","payloadType":"str","x":1990,"y":3260,"wires":[["df9a8b410f82870e"]]},{"id":"f5b7d70b2dcfeb18","type":"inject","z":"a1911aa3.c45be8","name":"Gone","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"clear","payloadType":"str","x":1990,"y":3300,"wires":[["f3b5717678871b90"]]},{"id":"0eaba2a0a75c87d5","type":"change","z":"a1911aa3.c45be8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"who\":\"S5\",\"power\":\"REQUEST2\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":2115,"y":3140,"wires":[["5cb9d1e4615b4047"]],"l":false},{"id":"4690734070a0b4f9","type":"change","z":"a1911aa3.c45be8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"who\":\"S5\",\"power\":\"REQUEST\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":2115,"y":3180,"wires":[["5cb9d1e4615b4047"]],"l":false},{"id":"97cf552179ef4762","type":"change","z":"a1911aa3.c45be8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"who\":\"S5\",\"power\":\"DETECTED\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":2115,"y":3220,"wires":[["5cb9d1e4615b4047"]],"l":false},{"id":"df9a8b410f82870e","type":"change","z":"a1911aa3.c45be8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"who\":\"S5\",\"power\":\"FULL\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":2115,"y":3260,"wires":[["5cb9d1e4615b4047"]],"l":false},{"id":"f3b5717678871b90","type":"change","z":"a1911aa3.c45be8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"who\":\"S5\",\"power\":\"CLEAR\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":2115,"y":3300,"wires":[["5cb9d1e4615b4047"]],"l":false},{"id":"297962f437269932","type":"comment","z":"a1911aa3.c45be8","name":"S21","info":"","x":1670,"y":3100,"wires":[]},{"id":"1e572d1f83e02970","type":"subflow:b48744b374aa9aaa","z":"a1911aa3.c45be8","x":2120,"y":3450,"wires":[[],["d68749a9c83d09cb"],["accdddcb63e41688"],[],[]]},{"id":"1544e9373ec2a5e6","type":"change","z":"a1911aa3.c45be8","name":"Add extra parts to message","rules":[{"t":"set","p":"REQUEST","pt":"msg","to":"REQUEST","tot":"flow"},{"t":"set","p":"REQUEST2","pt":"msg","to":"REQUEST2","tot":"flow"},{"t":"set","p":"DETECTED","pt":"msg","to":"DETECTED","tot":"flow"},{"t":"set","p":"FULL","pt":"msg","to":"FULL","tot":"flow"},{"t":"set","p":"REMOVED","pt":"msg","to":"REMOVED","tot":"flow"},{"t":"set","p":"S21","pt":"msg","to":"2","tot":"num"},{"t":"set","p":"S5","pt":"msg","to":"3","tot":"num"},{"t":"set","p":"other","pt":"msg","to":"4","tot":"num"},{"t":"set","p":"device","pt":"msg","to":"power_device","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1870,"y":3450,"wires":[["1e572d1f83e02970"]]},{"id":"d68749a9c83d09cb","type":"ui_text","z":"a1911aa3.c45be8","order":0,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","x":2340,"y":3420,"wires":[]},{"id":"accdddcb63e41688","type":"ui_text","z":"a1911aa3.c45be8","order":0,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","x":2340,"y":3460,"wires":[]},{"id":"5cb9d1e4615b4047","type":"junction","z":"a1911aa3.c45be8","x":1720,"y":3450,"wires":[["16ab972d5d9e0d59","1544e9373ec2a5e6"]]}]

No foreign nodes used.
Need NR 3.x as I have used the joint thingy.

context needed:
flow.REQUEST 100,014,000
flow.REQUET2 100,000,000
flow.DETECTED 010,010,000
flow.FULL 000,010,000
flow.REMOVED 0,0,0
flow.power_device A1
None of them are really needed to get the animation working.
They are used to control the RGB LED colour.
But are needed to have the code working.

Yeah, it may be annoying.
But the animation/s (GUI notifications) is are cute. IMO.

3 Likes