Challenge: Why did this automation fire last night?

I’m trying to figure out why an automation was triggered last night just after 1 am. Below are the conditions, which I THOUGHT were correct.

input_boolean.vacation_mode_boolean was definitely off. Thoughts?

  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.vacation_mode_boolean
        state: 'off'

      - condition: or
        conditions:
          - condition: sun
            after: sunrise
          - condition: time 
            before: '22:00:00'
  • Does Logbook show the automation triggered at 01:00?
  • In Configuration > Automations does the automation’s “Last_triggered” indicate 01:00?

It’s a trick!
That’s not an automation, that’s a condition block, it can not do anything.

Did I win?

1 Like

at 1:00 am.
your first condition is true. ( this is the and condition )
your second condition is false, ( this is the or condition )

We need to know what triggers the automation, please show the full automation.

1 AM passes your conditions just fine.

Your conditions are:
HVAC off AND (after sunrise OR before 22:00)
HVAV off true AND (after sunrise false OR before 22:00 true)

No the second condition (OR condition) is true.

After sunrise -> false
Before 22:00 -> true
True OR false -> true

1 Like

I think you want to logically AND the three conditions:

Vacation Mode is off
AND
Time is after sunrise
AND
Time is before 22:00

It will constrain the time portion to be between sunrise and 22:00.

  condition:
    - condition: state
      entity_id: input_boolean.vacation_mode_boolean
      state: 'off'
    - condition: sun
      after: sunrise
    - condition: time 
      before: '22:00:00'

i could be wrong, but i thought, when not all conditions or met, the condition is false.

No the second condition (OR condition) is true.

After sunrise -> false
Before 22:00 -> true
True OR false -> true

Yes, that’s true for an AND condition, but definitely not for an OR condition.

1 Like

@123 I think this is correct. 1 am is before 10 pm, so it would evaluate to true. I’m not sure why I was thinking that needed to be an OR. I just needed someone to point out my stupidity. Thank you!!!

What you might have been thinking of is when you want to constrain the time to be within sunrise and sunset. In that case, you do use a logical OR as shown in the documentation’s example for Sunrise-Sunset Condition:

condition:
  condition: or
  conditions:
    - condition: sun
      after: sunset
    - condition: sun
      before: sunrise

However, that’s because of the implicit ‘midnight boundary’ (explained in the docs).

@123 Yes, I think that is exactly when I was thinking. Thanks again!