Try this flow as an example of restoring the switch state after a reboot;
[{"id":"fcacdc7d.c798a","type":"ui_switch","z":"31e18edc.98bdc2","name":"","label":"switch","tooltip":"","group":"61d2dced.3db8f4","order":4,"width":"5","height":"3","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":590,"y":500,"wires":[["d0d80b69.b06ad8"]]},{"id":"d0d80b69.b06ad8","type":"change","z":"31e18edc.98bdc2","name":"","rules":[{"t":"set","p":"test","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":500,"wires":[[]]},{"id":"dc02a5a1.560988","type":"inject","z":"31e18edc.98bdc2","name":"","topic":"","payload":"test","payloadType":"global","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":410,"y":500,"wires":[["fcacdc7d.c798a"]]},{"id":"61d2dced.3db8f4","type":"ui_group","z":"","name":"flowtest","tab":"3c94630c.13381c","disp":true,"width":"12","collapse":false},{"id":"3c94630c.13381c","type":"ui_tab","z":0,"name":"Test","icon":"dashboard","order":6}]