Hi and welcoome.
You can set the switch to react on input.
Here is an example, copy it, press ctrl in editor and paste the example and press import.
[{"id":"29c91446b812e54e","type":"inject","z":"da8a6ef0b3c9a5c8","name":"mqtt true","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"a/topic","payload":"true","payloadType":"bool","x":200,"y":420,"wires":[["d43e6a72a6fb31d6"]]},{"id":"d43e6a72a6fb31d6","type":"change","z":"da8a6ef0b3c9a5c8","name":"","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":405,"y":460,"wires":[["6dee0b3683ed12f7","80358c1d54a72b8a"]],"l":false},{"id":"6dee0b3683ed12f7","type":"ui_switch","z":"da8a6ef0b3c9a5c8","name":"","label":"switch","tooltip":"","group":"2d4fe667.28f8ba","order":17,"width":0,"height":0,"passthru":false,"decouple":"true","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":530,"y":460,"wires":[["d43e6a72a6fb31d6"]]},{"id":"5514bb6c2134ef26","type":"inject","z":"da8a6ef0b3c9a5c8","name":"mqtt false","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"a/topic","payload":"false","payloadType":"bool","x":200,"y":480,"wires":[["d43e6a72a6fb31d6"]]},{"id":"80358c1d54a72b8a","type":"debug","z":"da8a6ef0b3c9a5c8","name":"debug 115","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":400,"wires":[]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"demo","tab":"1caa8458.b17814","order":2,"disp":true,"width":"12","collapse":false},{"id":"1caa8458.b17814","type":"ui_tab","name":"Demo","icon":"dashboard","order":1,"disabled":false,"hidden":false}]