Conditional action with OR

I can’t figure out the below, seems silly…

I built an integration between UniFi Cameras that when a person or car is sensed on driveway it sends a command to turn on certain house lights.

This is only supposed to happen after dark, then I put in a 10 minute timer and if it’s after 10pm I want those same lights to turn off.

Then I added what I thought was an OR branch rush if it’s after 1201AM the next day (cause the motion can happen any time after midnight too) to also turn off… But they are not… I’m clearly misinterpreting the branching:

Blockquote
alias: Doorbell Camera Detected Person at Night
description: “”
triggers:

  • type: turned_on
    device_id: 40543053751b6ac81de96b3bbe9a94b2
    entity_id: 76a46c26a754c234b460e4ad684817ca
    domain: binary_sensor
    trigger: device
    conditions:
  • condition: sun
    before: sunrise
    before_offset: “-900”
    after: sunset
    after_offset: “1860”
    actions:
  • type: turn_on
    device_id: a993afffc869ebd12ca823972923daec
    entity_id: cd2da8f7f3e2bcae34efea207470a238
    domain: switch
  • type: turn_on
    device_id: 0b844b0a7729a1e558f04a7de9dee01e
    entity_id: 7ae4af596b97c41da6adc6a4d943a93f
    domain: switch
  • type: turn_on
    device_id: 77435b7615646a71d33cae6ce22c1f01
    entity_id: bf58957b8db4b2b5028eec16e5e71e88
    domain: switch
  • type: turn_on
    device_id: 98d8314400c713d483817f5ea4e9f4d5
    entity_id: 9329c28b53d76d67f872f26ec0a78cee
    domain: switch
  • delay:
    hours: 0
    minutes: 10
    seconds: 0
    milliseconds: 0
  • choose:
    • conditions:
      • condition: time
        after: “22:00:00”
        weekday:
        • sun
        • mon
        • tue
        • wed
        • thu
        • fri
        • sat
      • condition: or
        conditions:
        • condition: time
          after: “00:00:00”
          weekday:
          • sun
          • mon
          • tue
          • wed
          • fri
          • thu
          • sat
            sequence:
      • type: turn_off
        device_id: 0b844b0a7729a1e558f04a7de9dee01e
        entity_id: 7ae4af596b97c41da6adc6a4d943a93f
        domain: switch
      • type: turn_off
        device_id: a993afffc869ebd12ca823972923daec
        entity_id: cd2da8f7f3e2bcae34efea207470a238
        domain: switch
        enabled: true
      • type: turn_off
        device_id: 77435b7615646a71d33cae6ce22c1f01
        entity_id: bf58957b8db4b2b5028eec16e5e71e88
        domain: switch
      • type: turn_off
        device_id: 98d8314400c713d483817f5ea4e9f4d5
        entity_id: 9329c28b53d76d67f872f26ec0a78cee

Please could you post your yaml as preformatted text (</> in the toolbar) - it’s quite difficult to read otherwise and the leading spaces are important.

It should look something like…

triggers:
  - entity_id:
      - binary_sensor.bathroom_motion_sensor_motion
    to: "on"
    trigger: state
  - entity_id:
      - binary_sensor.bathroom_motion_sensor_motion
    to: "off"
    for:
      hours: 0
      minutes: 10
      seconds: 0
    trigger: state
conditions:
  - condition: state
    state: "off"
    entity_id: input_boolean.bathroom_motion_sensor_override
  - condition: state
    entity_id: input_boolean.override_all
    state: "off"

and so on...

Agree on the formatting.

But, at a quick glance, I think you are using the ‘or’ wrong. It does not go between two conditions. It is a condition on its own with two conditions (the or’d conditions) inside it.

The time condition will span midnight if you populate both the before & after fields. Read here.

PS - your current conditions don’t do anything they will run all day because it’s always after 00:00

1 Like

I’ve reset it to this and will see how it works tonight.
Sorry all for the formatting, I did not know how to do this, will get better!
Thanks!

Use this button for formatting.
image