Hello Paolo,
Looks like there are some syntax issues on your code (missing quotes and unbalanced curly braces).
See if below code achieves what you want.
I moved part of the code to a function node (personal preference). The other nodes were added to test the flow with different values of flag, text and led.
´´´
[{"id":"4117ffc1.b817","type":"ui_template","z":"44cc2866.39c908","group":"89b6c636.3f1818","name":"","order":0,"width":0,"height":0,"format":"<svg>\n\n<circle cx=\"10\" cy=\"10\" r=\"10\" style=\"stroke: none; fill: {{msg.led_color}};\"/>\n<text x=\"30\" y=\"15\" fill=\"{{msg.text_color}}\"> {{msg.txt}}</text>\n\n</svg>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":654.1000556945801,"y":202.00000190734863,"wires":[[]]},{"id":"d0140866.baf4f8","type":"function","z":"44cc2866.39c908","name":"Test","func":"msg.txt = global.get(\"txt\") || 0;\nmsg.led = global.get(\"led\") || 0;\nmsg.flag = global.get(\"flag\") || 0;\n\n\nmsg.led_color = (msg.led === 0) ? \"red\" : \"green\";\n\nif (msg.flag === 0) {\n msg.led_color = \"gray\";\n msg.text_color = \"gray\";\n} else {\n msg.text_color = \"black\";\n}\nreturn msg;\n","outputs":1,"noerr":0,"x":509.0000057220459,"y":202.4000015258789,"wires":[["4117ffc1.b817"]]},{"id":"29eeed59.9b5102","type":"inject","z":"44cc2866.39c908","name":"LED 0","topic":"","payload":"Testing","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":148.00000381469727,"y":230.00000524520874,"wires":[["b9caf343.452d5"]]},{"id":"b9caf343.452d5","type":"change","z":"44cc2866.39c908","name":"","rules":[{"t":"set","p":"led","pt":"global","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":293.1000099182129,"y":230.60000371932983,"wires":[["d0140866.baf4f8"]]},{"id":"3706258d.17255a","type":"inject","z":"44cc2866.39c908","name":"LED 1","topic":"","payload":"Testing","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":146.00000381469727,"y":276.00000524520874,"wires":[["6fa6de1d.1de44"]]},{"id":"6fa6de1d.1de44","type":"change","z":"44cc2866.39c908","name":"","rules":[{"t":"set","p":"led","pt":"global","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":291.1000099182129,"y":276.60000371932983,"wires":[["d0140866.baf4f8"]]},{"id":"937a6d4f.21ec1","type":"inject","z":"44cc2866.39c908","name":"FLAG 0","topic":"","payload":"Testing","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":148.00000524520874,"y":129.00000381469727,"wires":[["fe3dcfba.20445"]]},{"id":"fe3dcfba.20445","type":"change","z":"44cc2866.39c908","name":"","rules":[{"t":"set","p":"flag","pt":"global","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":303.10001134872437,"y":129.60000228881836,"wires":[["d0140866.baf4f8"]]},{"id":"c3970f4a.b4918","type":"inject","z":"44cc2866.39c908","name":"FLAG 1","topic":"","payload":"Testing","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":150.00000524520874,"y":176.00000381469727,"wires":[["e2ea84b8.83abb8"]]},{"id":"e2ea84b8.83abb8","type":"change","z":"44cc2866.39c908","name":"","rules":[{"t":"set","p":"flag","pt":"global","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":305.10001134872437,"y":176.60000228881836,"wires":[["d0140866.baf4f8"]]},{"id":"89b6c636.3f1818","type":"ui_group","z":"","name":"SVG LED","tab":"99b36f6.7a6d29","disp":true,"width":"6","collapse":false},{"id":"99b36f6.7a6d29","type":"ui_tab","z":"","name":"SVG LED","icon":"dashboard"}]
´´´