Or condition within automation not working

I have used two conditions for my Garage door. If it’s open for more than 5 mins then send notification
However, when I add another condition with Or, it’s failing. Is it because all conditions need to be true ?
How to get this working then ?

alias: 'Notify: Garage door open'
description: ''
trigger:
  - platform: state
    entity_id:
      - binary_sensor.zone_9
    for:
      hours: 0
      minutes: 5
      seconds: 0
    to: 'on'
condition:
  - condition: time
    before: '08:00:00'
    after: '18:00:00'
    weekday:
      - sun
      - sat
      - fri
      - thu
      - wed
      - tue
      - mon
  - condition: or
    conditions:
      - condition: time
        before: '17:00:00'
        after: '09:00:00'
        weekday:
          - fri
          - thu
          - wed
          - tue
          - mon
action:
  - service: notify.mobile_app_pixel_4_xl
    data:
      title: Warning!
      message: Garage door is open
mode: single

You’re not using the “or” correctly. :slight_smile: What you do, is to give a second condition that can have “or” conditions within. It has nothing to do with your first condition. :slight_smile:

What you do is:
condition1 (true or false) AND (condition2 (true or false) OR here would be another condition for or)

what you want to do is:
(condition1 OR condition2)

condition:
  - or:
    - condition: time
      before: '08:00:00'
      after: '18:00:00'
      weekday:
        - sun
        - sat
        - fri
        - thu
        - wed
        - tue
        - mon
    - condition: time
      before: '17:00:00'
      after: '09:00:00'
      weekday:
        - fri
        - thu
        - wed
        - tue
        - mon
1 Like

Ah ha, great works perfectly! :hugs:

1 Like