Hi There, I'm trying to create a dimmer value into a JSON line. This dimmer value needs to be controlled by a pushbutton. When you press once, the light goes on. When you keep the button pressed, the dimmer value goes down , and when it's zero it goes up until you release the button. This is what I got at the moment, but that's without that variable value.
[{"id":"06afa4f2be886b2e","type":"tab","label":"Flow 7","disabled":false,"info":"","env":},{"id":"c220c40b2dc0a40b","type":"group","z":"06afa4f2be886b2e","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["28fd8aaed4e403c8","c5304477870a5d1c","70afc3b684eac84e","1c60f127b5c56e99","110f56d66c768df9"],"x":134,"y":219,"w":772,"h":142},{"id":"c5304477870a5d1c","type":"inject","z":"06afa4f2be886b2e","g":"c220c40b2dc0a40b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":230,"y":260,"wires":[["70afc3b684eac84e"]]},{"id":"70afc3b684eac84e","type":"change","z":"06afa4f2be886b2e","g":"c220c40b2dc0a40b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"switch_toggle","tot":"flow"},{"t":"set","p":"payload","pt":"msg","to":"$$.payload = 1 ? 0 : 1","tot":"jsonata"},{"t":"set","p":"switch_toggle","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":260,"wires":[["1c60f127b5c56e99"]]},{"id":"1c60f127b5c56e99","type":"function","z":"06afa4f2be886b2e","g":"c220c40b2dc0a40b","name":"","func":"var x = context.get("counter") || 0;\nif (msg.payload == 0)\n{\n context.set("counter",0);\n msg.payload = {"channel":5, "value":0};\n return msg;\n}\nif (msg.payload == 1)\n{\n context.set("counter",1);\n msg.payload = {"channel":5, "value":100};\n return msg;\n}\n\nif (x === 0)\n{\n msg.payload = {"channel":5, "value":100};\n} else\nif (x === 1)\n{\n msg.payload = {"channel":5, "value":0};\n}\n\nx = (x + 1) % 2;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":,"x":600,"y":260,"wires":[["110f56d66c768df9","28fd8aaed4e403c8"]]},{"id":"110f56d66c768df9","type":"debug","z":"06afa4f2be886b2e","g":"c220c40b2dc0a40b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":790,"y":260,"wires":},{"id":"28fd8aaed4e403c8","type":"artnet-command","z":"06afa4f2be886b2e","g":"c220c40b2dc0a40b","name":"DMX Controller","artnetnode":"d4e9c1034ff581f7","x":800,"y":320,"wires":,"inputLabels":["switch"]},{"id":"d4e9c1034ff581f7","type":"artnet-node","host":"192.168.2.37","port":"6454","universe":"0"}]