Python Script - Iterate within the entities of a group

I’m really a newby in pyhton writing but I’m trying to write a script that should read the state of every door or window and send a telegram with the name of the entities returning an on (open) state.

I’m stuck in the very first step, I’ve created a group with all entites that it should monitor and now I’m just trying to make a for loop that iterates within the entites of shuch group and logging some info with the following piece of code:

for entity_id in

It returns this error that does not help to find the error…

Error executing script: Not allowed to access