Trouble with and/or conditions in scripts

Hey guys,

Struggling with script conditions.

if one or the both sensors are not closed, repeat TTS (script.close_doors) till they meet the condition and then turn on the aircon.

The issue is, if they are already closed it does not meet the conditions and wont run.

But If I use the GUI to add another condition if they are closed to run the actions, it doesn’t look right?

I know I need another condition to bypass the repeat if they are already closed, but I have no idea how that should look?

Any help would be great :slight_smile:

alias: Aircon
sequence:
  - repeat:
      until:
        - type: is_not_open
          condition: device
          device_id: 
          entity_id: binary_sensor.balcony_door_contact
          domain: binary_sensor
        - type: is_not_open
          condition: device
          device_id: 
          entity_id: binary_sensor.bedroom_window_contact
          domain: binary_sensor
      sequence:
        - service: script.close_doors
          data: {}
        - delay:
            hours: 0
            minutes: 0
            seconds: 30
            milliseconds: 0
  - type: turn_on
    device_id: 
    entity_id: switch.air_conditioner
    domain: switch
  - delay:
      hours: 1
      minutes: 0
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 
    entity_id: switch.air_conditioner
    domain: switch
mode: single

So it is working as the above as long as one/ both sensors are open.

But if I add a “or” condition for if the sensors are closed, it just breaks the whole thing.

And I cant seem to find a “else”

What am I missing?

alias: Aircon
sequence:
  - type: is_open
    condition: device
    device_id: 4b11bceb2fb6a35ed6af545274801dc8
    entity_id: binary_sensor.balcony_door_contact
    domain: binary_sensor
  - type: is_open
    condition: device
    device_id: f5fee151eb7f9f644e85f356b8fa686b
    entity_id: binary_sensor.bedroom_window_contact
    domain: binary_sensor
  - repeat:
      until:
        - type: is_not_open
          condition: device
          device_id: 4b11bceb2fb6a35ed6af545274801dc8
          entity_id: binary_sensor.balcony_door_contact
          domain: binary_sensor
        - type: is_not_open
          condition: device
          device_id: f5fee151eb7f9f644e85f356b8fa686b
          entity_id: binary_sensor.bedroom_window_contact
          domain: binary_sensor
      sequence:
        - service: script.close_doors
          data: {}
        - delay:
            hours: 0
            minutes: 1
            seconds: 0
            milliseconds: 0
  - condition: or
    conditions:
      - type: is_not_open
        condition: device
        device_id: 4b11bceb2fb6a35ed6af545274801dc8
        entity_id: binary_sensor.balcony_door_contact
        domain: binary_sensor
      - type: is_not_open
        condition: device
        device_id: f5fee151eb7f9f644e85f356b8fa686b
        entity_id: binary_sensor.bedroom_window_contact
        domain: binary_sensor
  - type: turn_on
    device_id: 4ac6fe48877f4761acb7bdac08e8c6d7
    entity_id: switch.air_conditioner
    domain: switch
  - delay:
      hours: 1
      minutes: 30
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 4ac6fe48877f4761acb7bdac08e8c6d7
    entity_id: switch.air_conditioner
    domain: switch
mode: single

Ok I think I got it LOL!

This worked with one window open.

Next I have to try with everything shut

alias: Aircon
sequence:
  - condition: or
    conditions:
      - type: is_open
        condition: device
        device_id: 4b11bceb2fb6a35ed6af545274801dc8
        entity_id: binary_sensor.balcony_door_contact
        domain: binary_sensor
      - type: is_open
        condition: device
        device_id: f5fee151eb7f9f644e85f356b8fa686b
        entity_id: binary_sensor.bedroom_window_contact
        domain: binary_sensor
  - repeat:
      until:
        - type: is_not_open
          condition: device
          device_id: 4b11bceb2fb6a35ed6af545274801dc8
          entity_id: binary_sensor.balcony_door_contact
          domain: binary_sensor
        - type: is_not_open
          condition: device
          device_id: f5fee151eb7f9f644e85f356b8fa686b
          entity_id: binary_sensor.bedroom_window_contact
          domain: binary_sensor
      sequence:
        - service: script.close_doors
          data: {}
        - delay:
            hours: 0
            minutes: 1
            seconds: 0
            milliseconds: 0
  - condition: or
    conditions:
      - type: is_not_open
        condition: device
        device_id: 4b11bceb2fb6a35ed6af545274801dc8
        entity_id: binary_sensor.balcony_door_contact
        domain: binary_sensor
      - type: is_not_open
        condition: device
        device_id: f5fee151eb7f9f644e85f356b8fa686b
        entity_id: binary_sensor.bedroom_window_contact
        domain: binary_sensor
  - type: turn_on
    device_id: 4ac6fe48877f4761acb7bdac08e8c6d7
    entity_id: switch.air_conditioner
    domain: switch
  - delay:
      hours: 1
      minutes: 30
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 4ac6fe48877f4761acb7bdac08e8c6d7
    entity_id: switch.air_conditioner
    domain: switch
mode: single