Disable blind while door open

Hi. I use Ikea blinds. One of them is mounted over my patio door.
I have an automation for closing all blinds at sunset (or at 20:00 if sunset later).
I want to modify the automation to not close the blind over the door, if the door is open.
When the door is closed, the blind should also close. I have a door sensor at the door.
So any idea how to configure this?
I’m not sure if the automation is the right place to put the code in, sine I think the automation will only be triggered once. So maybe it won’t close the blind when door closes.

The automation code right now:

- alias: 'Fyrtur sunset'
  trigger:
    - platform: sun
      event: sunset
      offset: '+00:10:00'
    - platform: time
      at: '20:00:00'    
  action:
    service: cover.close_cover
    entity_id: group.covers_fyrtur

That’s easy enough. Just add a condition:

- alias: 'Fyrtur sunset'
  trigger:
    - platform: sun
      event: sunset
      offset: '+00:10:00'
    - platform: time
      at: '20:00:00'    
  condition:
    condition: state # door must be closed
    entity_id: binary_sensor.your_door_sensor_here
    state: 'off'
  action:
    service: cover.close_cover
    entity_id: group.covers_fyrtur

You can use a second automation for this.

- alias: 'Fyrtur sunset door close'
  trigger:
    platform: state # when door closes
    entity_id: binary_sensor.your_door_sensor_here
    to: 'off'
  condition:
    condition: or # only after 8pm or 10 minutes after sunset
    conditions: 
      - condition: time 
        after: '19:59:59'  
      - condition: sun
        after: sunset
        after_offset: '+00:10:00'
  action:
    service: cover.close_cover
    entity_id: group.covers_fyrtur

Or you can combine them all in the one automation:

- alias: 'Fyrtur sunset and door close'
  trigger:
    - platform: sun
      event: sunset
      offset: '+00:10:00'
    - platform: time
      at: '20:00:00'    
    - platform: state 
      entity_id: binary_sensor.your_door_sensor_here
      to: 'off'
  condition:
    - condition: state 
      entity_id: binary_sensor.your_door_sensor_here
      state: 'off'
    - condition: or 
      conditions: 
        - condition: time 
          after: '19:59:59'  
        - condition: sun
          after: sunset
          after_offset: '+00:10:00'
  action:
    service: cover.close_cover
    entity_id: group.covers_fyrtur

Offcourse, you can still close it manually now when the door is still open.
I think a template cover might be a better way to accomplish this ?

The combined automation doesnt seems to work. Blinds goes down even if door is open.

That’s not possible if you used your sensor here:

  condition:
    - condition: state 
      entity_id: binary_sensor.your_door_sensor_here
      state: 'off'

Post your code.

- alias: 'Fyrtur sunset'
  trigger:
    - platform: sun
      event: sunset
      offset: '+00:10:00'
    - platform: time
      at: '20:00:00'    
    - platform: state
      entity_id: binary_sensor.aeon_labs_zw112_door_window_sensor_6_sensor
      to: 'off'
  condition:
    - condition: state
      entity_id: binary_sensor.aeon_labs_zw112_door_window_sensor_6_sensor
      state: 'off'
    - condition: or 
      conditions: 
        - condition: time 
          after: '19:59:59'  
        - condition: sun
          after: sunset
          after_offset: '+00:10:00'
  action:
    service: cover.close_cover
    entity_id: group.covers_fyrtur

Think the or might be wrong.
The blinds should go down after sunset or 20:00 if sunset is later.
BUT if the door is open at sunset or after 20:00 the blinds should not go down
until the door is shut.

The way I have written it, the automation will be triggered by any of the following:

  1. the door closing,
  2. sunset + 10 minutes,
  3. and at 8pm

but to perform the actions all the following conditions must be met.

The conditions work like this, always. No matter which of the three triggers start the automation.

  1. The door must be closed. If it’s not the automation wont run.

AND

  1. It must be 8pm or later, OR after sunset + 10minutes.

Which should do what you want.

I believe you when you say it is not working that way. I just don’t see how. Can you check the developer tools states menu and make sure the door sensor is off when the door is closed, and on when the door is open.

Hm, was pretty sure the sensor was off when closed and on when open.
I have to check when I get home.

The automation run even if the door is open.
Sensor say “off” when closed.
Not sure why its not working.

Do you have the correct door sensor here:

  condition:
    - condition: state
      entity_id: binary_sensor.aeon_labs_zw112_door_window_sensor_6_sensor
      state: 'off'

Do you have another automation that could be closing the blinds?

Did you restart or reload automations after making the edits?

the sensor is correct. I have no other automation closing the blinds.
I have reloaded the automation.
Automation closes the blinds at 20:00 as supposed (sunset is later than 20 for now),
but it closes blinds even if the door is open (the state on sensor is on)

One thought, the trigger as written now shouldn’t the blind close if

  1. sunset or
  2. 20:00 or
  3. door close ?

So it would close blinds when door changes state to off even if its not 20:00 or sunset?

If you are sure you have exactly this condition including lack of capitalisation of the state ‘off’, correct spelling of everything including sensor and the same indentation then I’m sorry, I don’t know how to help you. You seem to have a very special install of home assistant, unlike any other, that ignores simple conditions like:

  condition:
    - condition: state
      entity_id: binary_sensor.aeon_labs_zw112_door_window_sensor_6_sensor
      state: 'off'

No, because of these conditions:

    - condition: or 
      conditions: 
        - condition: time 
          after: '19:59:59'  
        - condition: sun
          after: sunset
          after_offset: '+00:10:00'

it must be after sunset + 10 minutes or after 8pm when the door closes for the actions to be performed.

yeah, its goofy, can’t see any obvious fault.
Ill have to dig deeper to find out whats misssing…

Just a thought, is this door sensor battery powered?

Does it’s state go ‘unavailable’ when it goes to sleep?

Never mind that’s still not ‘off’ which it should have to be for the automation to run. If the above were true it might never close the blinds, opposite to what you are seeing (always closing the blinds).

yeh its a battery one.
Have not seen it unavailable, according to states in devops its either off or on

Yeah that’s not the problem, see my edit.

I will try an automation that trigger something else from the sensor.
just to see pinpoint the problem.

the condition:

- condition: or 
      conditions: 
        - condition: time 
          after: '19:59:59'  
        - condition: sun
          after: sunset
          after_offset: '+00:10:00'

it shouldn’t be - condition: and ?