Reference env variable in property name

Hi everyone, I am trying to generalize a subflow so that I can use it in multiple rooms of my place.

Some of my global scope properties look something like global.currentscene.livingroom or global.currentscene.bedroom.

What I am now doing is that I am setting an env variable $room in my subflow in the attempt to be able to set global properties dynamically from inside the subflow. In other words, I am trying to then do something like:

Change Node -> Property -> global.currentscene.$room -> Assign value

I have read the docs but it is still unclear to me whether I can achieve something like this. This page mentions not being able to reference partial stuff, but does that mean that I should instead assign a value such as global.currentscene.livingroom to my env, rather than livingroom, and then just use $room ?

Thanks

You could set the env var to a message then reference that var.
e.g.

[{"id":"62b0db36.5664cc","type":"subflow","name":"Subflow 1","info":"","category":"","in":[{"x":160,"y":120,"wires":[{"id":"18db26f9.bc2c09"}]}],"out":[{"x":440,"y":140,"wires":[{"id":"18db26f9.bc2c09","port":0}]}],"env":[{"name":"room","type":"str","value":"","ui":{"type":"input","opts":{"types":["str"]}}}],"meta":{},"color":"#DDAA99"},{"id":"18db26f9.bc2c09","type":"change","z":"62b0db36.5664cc","name":"","rules":[{"t":"set","p":"global_name","pt":"msg","to":"room","tot":"env"},{"t":"set","p":"test[msg.global_name]","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":180,"wires":[[]]},{"id":"13c60667.bee79a","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":1880,"wires":[["1e3ddcce.248b13"]]},{"id":"1e3ddcce.248b13","type":"subflow:62b0db36.5664cc","z":"bf9e1e33.030598","name":"","env":[{"name":"room","value":"tester","type":"str"}],"x":340,"y":1880,"wires":[[]]}]

When I try and import your code I get the error Error: TypeError: o is undefined

Not sure what happened there, as imports fine for me. Its a simple flow.

The sub flow just contains a change node.

[{"id":"18db26f9.bc2c09","type":"change","z":"62b0db36.5664cc","name":"","rules":[{"t":"set","p":"global_name","pt":"msg","to":"room","tot":"env"},{"t":"set","p":"test[msg.global_name]","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":180,"wires":[[]]}]

The subflow enviroment variable is set like this


The injected payload is saved to global.test.[$room]