Make an entity depend on another entity

I have a few shutters and I want to to automate that when it is getting warm outside it should close. And I also want to be able to control them manually in HA.
But every window can also be opened, so I added sensors so HA can check whether or not the window is opened.
Is there a way to make the shutter always check the window state so it can never go down when the window beneath it is opened? I know I could make automation rules, but then for each scenario I first have to check the window state and it really makes my automation rules ugly.
Any ideas how to make the shutter entity automatically dependent on the window state?

If the entity for the window and shutter are the same you could just template it and when you close a shutter it should check the corresponding window.

I’m sorry, but can you elaborate or give an example ?
btw the shutter is a shutter and the window is a switch within HA. Don’t know if that is what you meant by ‘are the same’

Do you mean the shutter is a cover within HA?

Which cover platform are you using to control the shutters? Is it MQTT Cover?

entity names… ie if you have a window sensor called sensor.front_window and a cover/shutter called shutter.front_window then you could call a close service on the shutter and have it check the appropriate sensor since the ‘names’ are the same. front_window

you could even use a group and loop through the group using the same kind of logic… quick flowchart like as follows

for x in group.shutters
   if sensor.cover[x] == 'Up' then
       don't close the shutter
   else
       close the shutter
   endif

ideally you’d just check the window ‘associated’ with that shutter.

I’m sure there are easier ways to do it but I’m just throwing this out as food for thought.