ok, I get the idea of using jsonata as an itermediate step.
Example on how this would work om my exact case:
example flow with 2 subflows, different deviceId for each:
[{"id":"282de603a3e98524","type":"subflow","name":"Subflow 2","info":"","category":"","in":[{"x":50,"y":30,"wires":[{"id":"73173a06beaebc00"}]}],"out":[],"env":[{"name":"deviceId","type":"str","value":""}],"meta":{},"color":"#DDAA99"},{"id":"73173a06beaebc00","type":"change","z":"282de603a3e98524","name":"","rules":[{"t":"set","p":"deviceId","pt":"msg","to":"$env(\"deviceId\")","tot":"jsonata"},{"t":"set","p":"status.devices[msg.deviceId]","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":80,"wires":[[]]},{"id":"41263f249259654e","type":"subflow:282de603a3e98524","z":"8617b96f8c8e93ed","name":"deviceA","env":[{"name":"deviceId","value":"deviceA","type":"str"}],"x":470,"y":100,"wires":[]},{"id":"a181053111630f15","type":"inject","z":"8617b96f8c8e93ed","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ok","payloadType":"str","x":210,"y":180,"wires":[["4418dafc915d302c"]]},{"id":"4418dafc915d302c","type":"subflow:282de603a3e98524","z":"8617b96f8c8e93ed","name":"deviceB","env":[{"name":"deviceId","value":"deviceB","type":"str"}],"x":470,"y":140,"wires":[]},{"id":"9ad689075a9cce3b","type":"inject","z":"8617b96f8c8e93ed","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"nok","payloadType":"str","x":200,"y":220,"wires":[["4418dafc915d302c"]]},{"id":"2be500a165e57375","type":"inject","z":"8617b96f8c8e93ed","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ok","payloadType":"str","x":210,"y":100,"wires":[["41263f249259654e"]]},{"id":"c1ad625858cd8838","type":"inject","z":"8617b96f8c8e93ed","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"nok","payloadType":"str","x":200,"y":140,"wires":[["41263f249259654e"]]}]