Automation trace says conditions not met when all conditions are met

Hi, I’m trying to figure out why the following automation isn’t working and could use some help.

here’s the automation code

id: '1705475658593'
alias: Dining off no presence
description: Between sunset and 7 am
trigger:
  - type: not_occupied
    platform: device
    device_id: ea397d9d58fdef3cd8536be113282c66
    entity_id: 29f3a18fc5170be80d0b826be32fb5c3
    domain: binary_sensor
    for:
      hours: 0
      minutes: 10
      seconds: 0
condition:
  - condition: sun
    after: sunset
  - condition: time
    before: '07:00:00'
action:
  - service: light.turn_off
    data: {}
    target:
      device_id:
        - 42b4bbcabfbfad8256a4aa4ba333dc3c
        - 1c0c67bc3dc0d6669ef54a373e2ffa5c
mode: single

Here’s the result (the trigger was triggered and the conditions were met - 11:37 PM so after sunset and before 7 AM)

The second condition doesn’t work the way you think it does.

This means between midnight and 07:00:00.

  - condition: time
    before: '07:00:00'

11:37 PM (23:37:00) fails that condition between it’s not between those two hours.

From the Time Condition’s documentation:

To fix it, simply logically OR the two conditions.

condition:
  - or:
      - condition: sun
        after: sunset
      - condition: time
        before: '07:00:00'

By logically ORing them, only one of the two conditions needs to report true in order to continue. So 23:37:00 will pass the first condition, fail the second condition, but only one out two is all that’s needed so it will continue on to execute the actions.

Oh wow! Thank you! I will try this tonight. Really appreciate the help