In addition to previous post I would add that you do not even need to iterate through the entire group of windows or lights.
If I understand correct eg. if 1 of x windows will be open, you only want to send a message for this specific window.
For this usecase you can use “when a member of the group changes” as rule trigger and within the rule you can use the contextual info (what will give you the name of the window that was opened).
If multiple windows will be opened at the same time, the contextual info will get overwritten, and therefore you need to pass the event to the Timer (otherweise the timer will always only know the window that was opened / closed latest).
Simply use the timer in this library (instead of the ootb timer in blockly) what will solve the issue with the context (as I’m doing exactly the same).
Removing your loop would make your rule faster and more easy to read, as there is no need to always check all windows and OH will tell you which window was opened / closed.
For the light you can do the same or, if you always want to turn off the light after a specific time, e.g. 10 minutes, simple use the expiration timer metadata and you do not need to have a rule at all.