Exporting nodes - extra stuff included and not wanted

Recently I helped someone and wrote some code to do what they wanted.

But when I exported the nodes I took a few configuration nodes as well.

But there weren't any of them used in the code.
It was simple nodes.

I hope this is the code.
I know I posted it, but I know the gremlins will be playing with things.

[{"id":"402169a8.8a791","type":"subflow","name":"B Toggle 2","info":"Toggle output at receipt of message.\nConfigurable output and message to send back to button node.\n(2022 02 18)\n\nIf `msg.payload == 0` (number) the output is forced to the OFF condition.\n\nIf `msg.payload == 1` (number) the output is forced to the ON condition.\n\nAny other input toggles the output.\n\n## ENV variables:\n```\nOnCLR - the colour when ON condition active.\nOnTXT - the text when ON condition active.\nOffCLR - the colour when OFF condition active.\nOffTXT - the text when OFF conditin active.\nON - payload when ON condition active.\nOFF - payload when OFF condition active.\nCTOPIC - the topic of the output message.\n```\n\nOutputs:\n - 1 $OFF for OFF and $ON for ON.\n - 2 $ON for OFF and $OFF for ON.  (Opposite of 1)\n - 3 to be sent back to button with `msg.colour` to set buttons colour and `msg.txt` for the text to be displayed.\n","category":"","in":[{"x":80,"y":120,"wires":[{"id":"69ae694095adea75"}]}],"out":[{"x":680,"y":110,"wires":[{"id":"5a9848b4303ef8d2","port":0},{"id":"8c41e6c213bcdefe","port":0}]},{"x":680,"y":210,"wires":[{"id":"3a564786d2308bdd","port":0},{"id":"a2ec504194f78107","port":0}]},{"x":680,"y":310,"wires":[{"id":"f14d0daf4ad33691","port":0},{"id":"aff48be4199bcfab","port":0}]}],"env":[{"name":"OffTXT","type":"str","value":""},{"name":"OffCLR","type":"str","value":""},{"name":"OnTXT","type":"str","value":""},{"name":"OnCLR","type":"str","value":""},{"name":"OFF","type":"str","value":""},{"name":"ON","type":"str","value":""},{"name":"CTOPIC","type":"str","value":""}],"meta":{},"color":"#D8BFD8","outputLabels":["Normal output","Inverted output","To button"],"icon":"node-red-dashboard/ui_switch.png"},{"id":"69ae694095adea75","type":"function","z":"402169a8.8a791","name":"toggle","func":"var x = context.get(\"counter\") || 0;\nif (msg.payload == 0)\n{\n    context.set(\"counter\",0);\n    msg.payload = 0;\n    return msg;\n}\nif (msg.payload == 1)\n{\n    context.set(\"counter\",1);\n    msg.payload = 1;\n    return msg;\n}\n\nif (x === 0)\n{\n    msg.payload = 1;\n} else\nif (x === 1)\n{\n    msg.payload = 0;\n}\n\nx = (x + 1) % 2;\n\ncontext.set(\"counter\",x);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":210,"y":120,"wires":[["63da8f2c6a34b348","0db7c2da3958ea2c"]],"info":"##  Outputs `1` or `0` for ON/OFF and `msg.colour` to send to button."},{"id":"63da8f2c6a34b348","type":"switch","z":"402169a8.8a791","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":310,"wires":[["f14d0daf4ad33691"],["aff48be4199bcfab"]]},{"id":"f14d0daf4ad33691","type":"change","z":"402169a8.8a791","name":"OFF","rules":[{"t":"set","p":"colour","pt":"msg","to":"OffCLR","tot":"env"},{"t":"set","p":"txt","pt":"msg","to":"OffTXT","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":280,"wires":[[]]},{"id":"aff48be4199bcfab","type":"change","z":"402169a8.8a791","name":"ON","rules":[{"t":"set","p":"colour","pt":"msg","to":"OnCLR","tot":"env"},{"t":"set","p":"txt","pt":"msg","to":"OnTXT","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":340,"wires":[[]]},{"id":"0db7c2da3958ea2c","type":"switch","z":"402169a8.8a791","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":120,"wires":[["5a9848b4303ef8d2","3a564786d2308bdd"],["8c41e6c213bcdefe","a2ec504194f78107"]]},{"id":"5a9848b4303ef8d2","type":"change","z":"402169a8.8a791","name":"OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"env"},{"t":"set","p":"topic","pt":"msg","to":"CTOPIC","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":90,"wires":[[]]},{"id":"8c41e6c213bcdefe","type":"change","z":"402169a8.8a791","name":"ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"env"},{"t":"set","p":"topic","pt":"msg","to":"CTOPIC","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":140,"wires":[[]]},{"id":"a2ec504194f78107","type":"change","z":"402169a8.8a791","name":"OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"env"},{"t":"set","p":"topic","pt":"msg","to":"CTOPIC","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":230,"wires":[[]]},{"id":"3a564786d2308bdd","type":"change","z":"402169a8.8a791","name":"ON","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"env"},{"t":"set","p":"topic","pt":"msg","to":"CTOPIC","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":180,"wires":[[]]},{"id":"c0d3891213382315","type":"function","z":"0918ee609bf69fc7","name":"Your existing flow -->","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3750,"y":1680,"wires":[["6de2e57d21f70489","cffe8f3ad2cdbd3a"]]},{"id":"24d5e3906d93e8ca","type":"subflow:402169a8.8a791","z":"0918ee609bf69fc7","name":"","env":[{"name":"OffTXT","value":"STOP","type":"str"},{"name":"OffCLR","value":"red","type":"str"},{"name":"OnTXT","value":"GO","type":"str"},{"name":"OnCLR","value":"lime","type":"str"},{"name":"OFF","value":"STOP","type":"str"},{"name":"ON","value":"GO","type":"str"},{"name":"CTOPIC","value":"control","type":"str"}],"x":3980,"y":1610,"wires":[["6de2e57d21f70489","cffe8f3ad2cdbd3a"],[],["efaa09e9779c383d"]]},{"id":"efaa09e9779c383d","type":"ui_button","z":"0918ee609bf69fc7","name":"","group":"fe65c87a.f14ca8","order":36,"width":0,"height":0,"passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"","bgcolor":"{{msg.colour}}","className":"","icon":"","payload":"X","payloadType":"str","topic":"topic","topicType":"msg","x":3980,"y":1540,"wires":[["24d5e3906d93e8ca"]]},{"id":"6de2e57d21f70489","type":"function","z":"0918ee609bf69fc7","name":"Option 1","func":"if (msg.topic ==  \"control\")\n{\n    if (msg.payload == \"STOP\")\n    {\n        context.set(\"flow\",\"STOP\");\n        return;\n    }\n    if (msg.payload == \"GO\")\n    {\n        context.est(\"flow\",\"GO\");\n        return;\n    }\n}\nvar condition = context.get(\"flow\");\nif (condition == \"STOP\")\n{\n    return;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3970,"y":1680,"wires":[["5cf4fc64e6746595"]]},{"id":"cffe8f3ad2cdbd3a","type":"gate","z":"0918ee609bf69fc7","name":"Option 2","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memory","x":3980,"y":1730,"wires":[["5cf4fc64e6746595"]]},{"id":"5cf4fc64e6746595","type":"function","z":"0918ee609bf69fc7","name":"Your existing flow -->","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":4220,"y":1680,"wires":[[]]},{"id":"fe65c87a.f14ca8","type":"ui_group","name":"Group 1","tab":"d70f1990.9bd528","order":1,"disp":true,"width":6},{"id":"d70f1990.9bd528","type":"ui_tab","name":"Test Tab","icon":"dashboard","order":36,"disabled":false,"hidden":false}]

Does this contain a couple of context nodes?
If you don't mind checking.

And it begs the question - for me if they are there - how did they (the context nodes) get involved in this bit of code?

Sorry for the dumb question.
I'm asking a lot of them recently.

Yeah!

Ok, maybe I didn't need to post the code, but proof of my question:

(See picture)

Oh.... Ok. Hind sight just set in.
They are for the Dashboard where the button is - yes?

Sorry.

But if someone could confirm that theory it would be appreciated.

Yes, they are the config nodes related to the dashboard button.

1 Like

Thanks @knolleary

I should have known better.
But now I hope I remember this.

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