I only was able to workout a partial workaround solution.
In this example flow it is injected:
msg.payload = foo
msg.topic = alarm
The change node uses a jsonata expression to create the object {alarm : msg.payload}
and have it stored in flow.sta
The function node will read to the object msg
the object flow.sta
Flow:
[{"id":"35baa7cd.9b2f08","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"5ae8597e.4bdc08","type":"debug","z":"35baa7cd.9b2f08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":690,"y":120,"wires":[]},{"id":"42343f37.f095a","type":"inject","z":"35baa7cd.9b2f08","name":"","topic":"alarm","payload":"foo","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":120,"wires":[["df81e676.991df8"]]},{"id":"df81e676.991df8","type":"change","z":"35baa7cd.9b2f08","name":"","rules":[{"t":"set","p":"#:(memoryOnly)::sta","pt":"flow","to":"$.{topic : payload}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":120,"wires":[["f7335a43.eb7498"]]},{"id":"f7335a43.eb7498","type":"function","z":"35baa7cd.9b2f08","name":"read flow.sta","func":"\nmsg = flow.get(\"sta\",\"memoryOnly\");\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":120,"wires":[["5ae8597e.4bdc08"]]}]