Automation with covers and door/window sensors

Hi, I’m struggling with an automation…
I’ve covers and door/window sensors already in HA. Now I’d like to set up an automation, which checks prior shutting down each cover the open/closed status of the door/window. Only if the specific door/window is closed, the cover should shut down. Problem so far is the specific… Any help is appreciated! Thanks

Can we see what you’ve got so far?

If it were me, I’d write a separate automation for each of two or three windows to test the principle, then think about combining them. If there were only a few I might not bother - particularly as the light levels on different sides of the house vary considerably. It depends on your use case and what the triggers are.

Not really that far…

alias: Close
description: ""
trigger:
  - platform: state
    entity_id:
      - input_button.close
    from: null
condition:
  - condition: state
    entity_id: binary_sensor.windows_a
    state: "off"
  - condition: state
    entity_id: binary_sensor.window_b
    state: "off"
action:
  - service: cover.close_cover
    data: {}
    target:
      entity_id:
        - cover.a
        - cover.b
mode: single

And here’s the problem: the automation won’t close cover B even only sensor A is showing “open”.
I’ve to fit 22 windows/doors and specific covers in this automation…

I think the easiest would just be a series of if-then actions checking each window and acting accordingly.

I see what you mean. :astonished: Still, it might be worth splitting it up a bit, just for sanity’s sake - maybe by floors or something. If you put them all in the same automation, when there’s an error none of them will be closed.

Your existing automation won’t run unless all the windows are closed - which may be what you want. If you want them to close individually, then @brooksben11’s suggestion would be a good place to start, but without the existing condition section.

Done this way. Works…