Retreiving object data with variable

I am relatively new to Node Red. I am using it within Home Assistant. This is my first request for help.

I am building a flow to manage multiples doors (opening) with contact sensor.
First portion, I am defining flow variables. Currently 2 but more to come,

 [{"id":"5153ed25.2db83c","type":"change","z":"144c9bef.2833a4","name":"","rules":[{"t":"set","p":"S4","pt":"flow","to":"S4","tot":"msg"},{"t":"set","p":"S1","pt":"flow","to":"S1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":3780,"wires":[[]]},{"id":"423605f2.fd2cd4","type":"inject","z":"144c9bef.2833a4","name":"Set Flow Wariable for Sensors","props":[{"p":"S4","v":"{\"opening\":\"Front Door\",\"waitFor\":10}","vt":"json"},{"p":"S1","v":"{\"opening\":\"Patio Cuisine\",\"waitFor\":5}","vt":"json"}],"repeat":"","crontab":"00 12 * * *","once":false,"onceDelay":0.1,"topic":"","x":270,"y":3780,"wires":[["5153ed25.2db83c"]]}]

In the second portion, I am retrieving values from my "flow" object using S4.'variable name'.

I would like to retrieve the data using the content of the topic as an index for the object. This would be something like flow.get("??? topic ???.door") . This would make my flow more flexible for multiple Sensor. Currently I have ro make on function node for each door. Thank you for any help. Hopefully I did include my nodes in a usable format.

I forgot to include my second portion, here it is.

[{"id":"fcaff2cf.b0f7e","type":"inject","z":"144c9bef.2833a4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"S4","payload":"on","payloadType":"str","x":200,"y":3840,"wires":[["d141d94c.0c7eb8"]]},{"id":"d0f10cdf.a08af8","type":"debug","z":"144c9bef.2833a4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":3920,"wires":[]},{"id":"d141d94c.0c7eb8","type":"function","z":"144c9bef.2833a4","name":"","func":"{\n    msg.waitFor = flow.get(\"S4.waitFor\");\n    msg.door = flow.get(\"S4.opening\")\n}\n\nif(msg.payload == \"on\")\n{\n    msg.payload = \"opened\";\n    msg.delay = msg.waitFor * 60\n}\nelse\n{\n    msg.payload = \"closed\";\n    msg.reset = \"true\"\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":3860,"wires":[["d0f10cdf.a08af8"]]},{"id":"263ca025.3dceb","type":"inject","z":"144c9bef.2833a4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"S4","payload":"off","payloadType":"str","x":210,"y":3920,"wires":[["d141d94c.0c7eb8"]]}]

Try

msg.waitFor = flow.get(msg.topic+".waitFor")

Thank you very much for a quick solution.
It works great!