I think this works
[{"id":"521a8221d629d6e9","type":"ui_switch","z":"4b211f23c08b43f4","name":"","label":"switch","tooltip":"","group":"bd5694e58bd4943e","order":7,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":370,"y":100,"wires":[["954eef0c78c00eaf","7c6bb2e9aac46b6b"]]},{"id":"7e8e32f10acdba8d","type":"inject","z":"4b211f23c08b43f4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"lastvalue","payloadType":"flow","x":180,"y":100,"wires":[["521a8221d629d6e9"]]},{"id":"954eef0c78c00eaf","type":"change","z":"4b211f23c08b43f4","name":"","rules":[{"t":"set","p":"lastvalue","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":100,"wires":[[]]},{"id":"7c6bb2e9aac46b6b","type":"debug","z":"4b211f23c08b43f4","name":"debug 2461","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":160,"wires":[]},{"id":"bd5694e58bd4943e","type":"ui_group","name":"This Pi","tab":"9611f8e5805241b9","order":2,"disp":true,"width":"6","collapse":false,"className":""},{"id":"9611f8e5805241b9","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
My settings.js has
contextStorage: {
default: {
module:"localfilesystem"
},
},
Note that the switch node will only accept the value from msg.payload if it's set to pass through a payload which is a valid state. So if the last value was eg true, if Node-red restarts, true will be sent to your timer once more as well as showing on the dashboard. I'm not sure if this is desirable behaviour.
There is an alternative setup if pass-through is not selected, for the switch to "show the state of the input". Maybe this could be used to sync the dashboard without re-sending the last message to the timer.