I'm no longer using this flow, but this is from my archive -
[{"id":"393b4f1.83476b","type":"mqtt out","z":"6eb37a1d.ee8f34","name":"request status","topic":"relayboard","qos":"2","retain":"false","broker":"3ecd7f11.4d3dd","x":850,"y":210,"wires":[]},{"id":"be1306ae.f74358","type":"mqtt in","z":"6eb37a1d.ee8f34","name":"","topic":"relayboard/status","qos":"2","broker":"3ecd7f11.4d3dd","x":100,"y":270,"wires":[["ac77d09d.c76a4"]]},{"id":"e99b35c.756f9c8","type":"change","z":"6eb37a1d.ee8f34","name":"Write to flow context","rules":[{"t":"set","p":"relayStat","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":270,"wires":[[]]},{"id":"ac77d09d.c76a4","type":"json","z":"6eb37a1d.ee8f34","name":"","property":"payload","action":"","pretty":false,"x":330,"y":270,"wires":[["e99b35c.756f9c8","542cbed8.7c85c"]]},{"id":"4cc56b37.5a7994","type":"inject","z":"6eb37a1d.ee8f34","name":"Restore","topic":"","payload":"relayStat","payloadType":"flow","repeat":"","crontab":"","once":true,"onceDelay":"1","x":160,"y":90,"wires":[["542cbed8.7c85c"]]},{"id":"83a4cac0.49afd8","type":"ui_switch","z":"6eb37a1d.ee8f34","name":"","label":"Relay 1","tooltip":"","group":"78c14ac3.283354","order":1,"width":"4","height":"2","passthru":false,"decouple":"true","topic":"relayboard/relay1","style":"","onvalue":"on","onvalueType":"str","onicon":"fa-bolt fa-5x","oncolor":"red","offvalue":"off","offvalueType":"str","officon":"fa-power-off fa-5x","offcolor":"green","x":343,"y":100,"wires":[["5e0ca9b6.073418"]]},{"id":"5fdfe712.58fed8","type":"ui_switch","z":"6eb37a1d.ee8f34","name":"","label":"Relay 2","tooltip":"","group":"78c14ac3.283354","order":2,"width":"4","height":"2","passthru":false,"decouple":"true","topic":"relayboard/relay2","style":"","onvalue":"on","onvalueType":"str","onicon":"fa-bolt fa-5x","oncolor":"red","offvalue":"off","offvalueType":"str","officon":"fa-power-off fa-5x","offcolor":"green","x":343,"y":154,"wires":[["da3680c4.fad65"]]},{"id":"542cbed8.7c85c","type":"function","z":"6eb37a1d.ee8f34","name":"Parse state json","func":"// Restore status after a re-deploy/reboot and\n// update switch status\nvar relay1 = {payload: (msg.payload.status.relay1 ? \"on\" : \"off\")};\nvar relay2 = {payload: (msg.payload.status.relay2 ? \"on\" : \"off\")};\nvar relay3 = {payload: (msg.payload.status.relay3 ? \"on\" : \"off\")};\nreturn [relay1, relay2, relay3];","outputs":3,"noerr":0,"x":170,"y":154,"wires":[["83a4cac0.49afd8"],["5fdfe712.58fed8"],["453a7cec.97d4d4"]]},{"id":"453a7cec.97d4d4","type":"ui_switch","z":"6eb37a1d.ee8f34","name":"","label":"Relay 3","tooltip":"","group":"78c14ac3.283354","order":3,"width":"4","height":"2","passthru":false,"decouple":"true","topic":"relayboard/relay3","style":"","onvalue":"on","onvalueType":"str","onicon":"fa-bolt fa-5x","oncolor":"red","offvalue":"off","offvalueType":"str","officon":"fa-power-off fa-5x","offcolor":"green","x":343,"y":210,"wires":[["632257e3.b18908","d020f8d6.e4d478"]]},{"id":"632257e3.b18908","type":"change","z":"6eb37a1d.ee8f34","name":"Change Status","rules":[{"t":"set","p":"payload","pt":"msg","to":"status","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":210,"wires":[["faf4d333.d7a3f"]]},{"id":"faf4d333.d7a3f","type":"delay","z":"6eb37a1d.ee8f34","name":"Delay","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":700,"y":210,"wires":[["393b4f1.83476b"]]},{"id":"d020f8d6.e4d478","type":"mqtt out","z":"6eb37a1d.ee8f34","name":"control relay","topic":"","qos":"2","retain":"false","broker":"3ecd7f11.4d3dd","x":570,"y":100,"wires":[]},{"id":"dc135f34.a3d11","type":"comment","z":"6eb37a1d.ee8f34","name":"RELAYBOARD","info":"","x":160,"y":40,"wires":[]},{"id":"47663be9.340164","type":"ui_button","z":"6eb37a1d.ee8f34","name":"All Off","group":"78c14ac3.283354","order":5,"width":"2","height":"1","passthru":false,"label":"All Off","tooltip":"","color":"green","bgcolor":"#2A2A2A","icon":"","payload":"off","payloadType":"str","topic":"relayboard/all","x":750,"y":100,"wires":[["8a8dcfde.be33f"]]},{"id":"cc64eb9c.5a7088","type":"ui_button","z":"6eb37a1d.ee8f34","name":"All On","group":"78c14ac3.283354","order":4,"width":"2","height":"1","passthru":false,"label":"All On","color":"red","bgcolor":"#2A2A2A","icon":"","payload":"on","payloadType":"str","topic":"relayboard/all","x":750,"y":150,"wires":[["e338452.1c565b8"]]},{"id":"da3680c4.fad65","type":"link out","z":"6eb37a1d.ee8f34","name":"","links":["4f6ad260.ba944c"],"x":448,"y":155,"wires":[]},{"id":"4f6ad260.ba944c","type":"link in","z":"6eb37a1d.ee8f34","name":"","links":["da3680c4.fad65","8a8dcfde.be33f","e338452.1c565b8","5e0ca9b6.073418","915ca260.894b9","95c25ab1.ef0458"],"x":515,"y":160,"wires":[["d020f8d6.e4d478","632257e3.b18908"]]},{"id":"8a8dcfde.be33f","type":"link out","z":"6eb37a1d.ee8f34","name":"","links":["4f6ad260.ba944c"],"x":845,"y":100,"wires":[]},{"id":"e338452.1c565b8","type":"link out","z":"6eb37a1d.ee8f34","name":"","links":["4f6ad260.ba944c"],"x":845,"y":150,"wires":[]},{"id":"5e0ca9b6.073418","type":"link out","z":"6eb37a1d.ee8f34","name":"","links":["4f6ad260.ba944c"],"x":448,"y":100,"wires":[]},{"id":"3ecd7f11.4d3dd","type":"mqtt-broker","z":"","name":"paul_broker","broker":"192.168.1.8","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"78c14ac3.283354","type":"ui_group","z":"","name":"Remote relay","tab":"225049e7.1f19a6","disp":true,"width":"4","collapse":false},{"id":"225049e7.1f19a6","type":"ui_tab","z":"","name":"ESP devices","icon":"dashboard","order":10}]