I am trying to convert this to a momentary switch. I want the animated icon to run while the igniter runs and reset when the message comes back from the igniter circuit the delay substitutes.
I can't seem to inject the reset logic correctly to make it momentary.
Any help would be greatly appreciated.
[{"id":"9c27e8ba.02c398","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"711c541c.7108ac","type":"function","z":"9c27e8ba.02c398","name":"Push Button","func":"var state = context.get(\"STATE\")||0;\n\n// Look for a !X message to get values.\nif (msg.payload != \"X\") //Do this if the message is NOT \"X\"\n{\n //\n // Background colours first.\n //\n context.set(\"ABGC\", msg.colourA);\n context.set(\"BBGC\", msg.colourB);\n //\n // Now do text.\n //\n context.set(\"Atxt\", msg.txtA);\n context.set(\"Btxt\", msg.txtB);\n //\n // Font colours.\n //\n context.set(\"AFC\",msg.txtclrA);\n context.set(\"BFC\",msg.txtclrB);\n //\n // Payloads.\n //\n context.set(\"PayloadA\", msg.payloadA);\n context.set(\"PayloadB\", msg.payloadB);\n //\n // Icons.\n //\n context.set(\"icon_on\", msg.icon_on);\n context.set(\"icon_off\", msg.icon_off);\n //\n // Topic.\n //\n if (msg.topicSET !== null)\n {\n context.set(\"Topic\",msg.topicSET);\n } else\n {\n context.set(\"Topic\",\"~\");\n }\n return;\n}\n// Now on to the real stuff.\nif (msg.payload == \"X\")\n{\n state = (state + 1)% 2;\n //node.warn(state);\n context.set(\"STATE\",state);\n} else if (msg.payload == \"Y\") {\n state = 0;\n context.set(\"STATE\",state);\n}\nif (state === 0)\n{\n // Condition A\n msg.payload = context.get(\"PayloadA\");\n msg.colour = context.get(\"ABGC\");\n msg.txt = context.get(\"icon_off\")+context.get(\"Atxt\");\n msg.fontclr = context.get(\"AFC\");\n msg.icon = context.get(\"icon_off\");\n} else\n{\n // Condition B\n msg.payload = context.get(\"PayloadB\");\n msg.colour = context.get(\"BBGC\");\n msg.txt = context.get(\"icon_on\")+context.get(\"Btxt\");\n msg.fontclr = context.get(\"BFC\");\n msg.icon = context.get(\"icon_on\");\n}\nif (context.get(\"Topic\") == \"~\")\n{\n msg.topic = \"\";\n} else\n{\n msg.topic = context.get(\"Topic\");\n}\nreturn msg;\n","outputs":1,"noerr":0,"x":580,"y":280,"wires":[["66b52f17.b7153","160a1fd1.09f1f","e57debbf.de80a8"]]},{"id":"66b52f17.b7153","type":"ui_button","z":"9c27e8ba.02c398","name":"Ignitor","group":"559f6812.e7fd18","order":4,"width":3,"height":2,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"{{msg.fontclr}}","bgcolor":"{{msg.colour}}","icon":"","payload":"X","payloadType":"str","topic":"","x":560,"y":230,"wires":[["711c541c.7108ac"]]},{"id":"6354d2ea.97ef7c","type":"function","z":"9c27e8ba.02c398","name":"Setup","func":"msg = {\n \"colourA\": \"red\",\n \"colourB\": \"green\",\n \"txtA\": \"Off\",\n \"txtB\": \"On\",\n \"txtclrA\": \"black\",\n \"txtclrB\": \"white\",\n \"payloadA\": \"0\",\n \"payloadB\": \"1\",\n \"icon_off\": '<i class=\"fa fa-2x fa-bomb\"></i> ',\n \"icon_on\": '<i class=\"fa fa-spinner fa-pulse fa-3x fa-fw\"></i> ',\n \"topicSET\": \"channel_6\"\n}\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":280,"wires":[["711c541c.7108ac"]]},{"id":"f7f727e4.35bab8","type":"link in","z":"9c27e8ba.02c398","name":"","links":["b83a013.f422","9f2b93b.9819f7"],"x":445,"y":340,"wires":[["711c541c.7108ac"]]},{"id":"9f2b93b.9819f7","type":"link out","z":"9c27e8ba.02c398","name":"","links":["6e70941f.08214c","f7f727e4.35bab8"],"x":855,"y":280,"wires":[]},{"id":"160a1fd1.09f1f","type":"delay","z":"9c27e8ba.02c398","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":760,"y":280,"wires":[["9f2b93b.9819f7"]]},{"id":"2c961667.b0e8ca","type":"inject","z":"9c27e8ba.02c398","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":280,"wires":[["6354d2ea.97ef7c"]]},{"id":"e57debbf.de80a8","type":"debug","z":"9c27e8ba.02c398","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":340,"wires":[]},{"id":"559f6812.e7fd18","type":"ui_group","z":"","name":"Ignitor","tab":"91b245b1.b4ed7","order":4,"disp":true,"width":5,"collapse":false},{"id":"91b245b1.b4ed7","type":"ui_tab","z":"","name":"Pump Control Dashboard","icon":"dashboard","order":3,"disabled":false,"hidden":false}]