You want to pass msg if payload matches valid state
Here is an example of setting a ui-switch. one switch is set on/off with short and long press. The other example switch is set on/off with just a short press toggle.
e.g.
[{"id":"5f7026fc9858803a","type":"group","z":"65617ffeb779f51c","name":"simulate short and long press on i3 channel 0","style":{"label":true,"color":"#000000"},"nodes":["1122b2f9fb54dbc2","5058ff5e2e6e7ffc","fd1bb44399d97fc3","e6dc0c1d6b81bad2","c3f7d4242c4d0405","c6da279ffb9f23e3"],"x":294,"y":2519,"w":892,"h":122},{"id":"1122b2f9fb54dbc2","type":"mqtt out","z":"65617ffeb779f51c","g":"5f7026fc9858803a","name":"","topic":"shellies/shellyix3-123/input_event/0","qos":"","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"e8ba3ef5.22f4a8","x":1010,"y":2600,"wires":[]},{"id":"5058ff5e2e6e7ffc","type":"inject","z":"65617ffeb779f51c","g":"5f7026fc9858803a","name":"shortpush","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":2560,"wires":[["fd1bb44399d97fc3"]]},{"id":"fd1bb44399d97fc3","type":"ui_button","z":"65617ffeb779f51c","g":"5f7026fc9858803a","name":"","group":"99a91e75281341f5","order":6,"width":0,"height":0,"passthru":true,"label":"shortpush","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"Shortpush","payloadType":"str","topic":"topic","topicType":"msg","x":540,"y":2560,"wires":[["e6dc0c1d6b81bad2"]]},{"id":"e6dc0c1d6b81bad2","type":"change","z":"65617ffeb779f51c","g":"5f7026fc9858803a","name":"","rules":[{"t":"set","p":"event_cnt","pt":"flow","to":"$sum([$flowContext(\"event_cnt\")]) + 1","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"{\"event\":$$.payload,\"event_cnt\": $flowContext(\"event_cnt\")}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":2560,"wires":[["1122b2f9fb54dbc2"]]},{"id":"c3f7d4242c4d0405","type":"inject","z":"65617ffeb779f51c","g":"5f7026fc9858803a","name":"longpush","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":2600,"wires":[["c6da279ffb9f23e3"]]},{"id":"c6da279ffb9f23e3","type":"ui_button","z":"65617ffeb779f51c","g":"5f7026fc9858803a","name":"","group":"99a91e75281341f5","order":7,"width":0,"height":0,"passthru":true,"label":"Longpush","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"Longpush","payloadType":"str","topic":"topic","topicType":"msg","x":540,"y":2600,"wires":[["e6dc0c1d6b81bad2"]]},{"id":"e8ba3ef5.22f4a8","type":"mqtt-broker","name":"testb","broker":"192.168.1.25","port":"1883","clientid":"node-red-test","autoConnect":true,"usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"99a91e75281341f5","type":"ui_group","name":"Default","tab":"8cf419bfa3bb0c6c","order":1,"disp":true,"width":8,"collapse":false,"className":""},{"id":"8cf419bfa3bb0c6c","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false},{"id":"6cb591661703fea6","type":"group","z":"65617ffeb779f51c","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["2024a3ba142464b0","c2791862dcd04abc","03b13b16fd280246","4ecfb6cf8347717e","a51318ea5486bc01","43ef3c3a32a0b448","9b57d3b28506f8c1","a04b853dc47232ad","8cea4afcb192a274","28096b2abd1a5945","0772f169b5ccba23","65e1167954596393","c048ed6637afb65f","9511c562dd45545e"],"x":334,"y":2679,"w":772,"h":242},{"id":"2024a3ba142464b0","type":"ui_led","z":"65617ffeb779f51c","g":"6cb591661703fea6","order":3,"group":"99a91e75281341f5","width":2,"height":1,"label":"short long","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"#ff0000","value":"false","valueType":"bool"},{"color":"#008000","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"circle","showGlow":true,"name":"short long","x":980,"y":2780,"wires":[]},{"id":"c2791862dcd04abc","type":"ui_switch","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"","label":"short long","tooltip":"","group":"99a91e75281341f5","order":5,"width":4,"height":1,"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":820,"y":2780,"wires":[["2024a3ba142464b0"]]},{"id":"03b13b16fd280246","type":"mqtt in","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"","topic":"shellies/shellyix3-123/input_event/0","qos":"2","datatype":"auto-detect","broker":"e8ba3ef5.22f4a8","nl":false,"rap":true,"rh":0,"inputs":0,"x":500,"y":2720,"wires":[["43ef3c3a32a0b448"]]},{"id":"4ecfb6cf8347717e","type":"switch","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"","property":"payload.event","propertyType":"msg","rules":[{"t":"eq","v":"Shortpush","vt":"str"},{"t":"eq","v":"Longpush","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":2780,"wires":[["a51318ea5486bc01"],["9b57d3b28506f8c1"]]},{"id":"a51318ea5486bc01","type":"change","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":2780,"wires":[["c2791862dcd04abc"]]},{"id":"43ef3c3a32a0b448","type":"rbe","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload.event_cnt","topi":"topic","x":710,"y":2720,"wires":[["4ecfb6cf8347717e","a04b853dc47232ad"]]},{"id":"9b57d3b28506f8c1","type":"change","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":2820,"wires":[["c2791862dcd04abc"]]},{"id":"a04b853dc47232ad","type":"switch","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"","property":"payload.event","propertyType":"msg","rules":[{"t":"eq","v":"Shortpush","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":410,"y":2880,"wires":[["8cea4afcb192a274"]]},{"id":"8cea4afcb192a274","type":"change","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$flowContext(\"short\") = true ? false : true","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":2880,"wires":[["0772f169b5ccba23"]]},{"id":"28096b2abd1a5945","type":"change","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"","rules":[{"t":"set","p":"short","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":2880,"wires":[["65e1167954596393"]]},{"id":"0772f169b5ccba23","type":"ui_switch","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"","label":"short","tooltip":"","group":"99a91e75281341f5","order":4,"width":4,"height":1,"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":710,"y":2880,"wires":[["28096b2abd1a5945"]]},{"id":"65e1167954596393","type":"ui_led","z":"65617ffeb779f51c","g":"6cb591661703fea6","order":1,"group":"99a91e75281341f5","width":2,"height":1,"label":"short","labelPlacement":"left","labelAlignment":"left","colorForValue":[{"color":"#ff0000","value":"false","valueType":"bool"},{"color":"#008000","value":"true","valueType":"bool"}],"allowColorForValueInMessage":false,"shape":"circle","showGlow":true,"name":"short","x":1030,"y":2880,"wires":[]},{"id":"c048ed6637afb65f","type":"comment","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"short on long off","info":"","x":920,"y":2740,"wires":[]},{"id":"9511c562dd45545e","type":"comment","z":"65617ffeb779f51c","g":"6cb591661703fea6","name":"short on short off","info":"","x":920,"y":2840,"wires":[]}]