*Solved* OR (before Sunrise AND after Sunset) stopped working

Updated to Home Assistant 0.114.0b0 and this automation condition has stopped working in my automatons:

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

sun below_horizon is still working but I would prefer to use the above with offsets…

Are you sure that this worked before? The docs state explicitly that you need to have two separate conditions. It will never be after sunset and before sunrise, because after sunset is only from aftdr sunset till midnight and before sunrise is from midnight until sunrise.

Also, this is an issue with a beta version and should be posted on github, not in the forum.

Agreed. That would never have worked.

This part:

  - after: sunset
    before: sunrise
    condition: sun

Will only be true when it’s both between sunset & midnight and between midnight & sunrise, which it will never be.

This part:

condition: or
conditions:

does absolutely nothing, since you’re trying to “OR” one condition with no other condition.

Duh! Shouldn’t be tinkering at 3:00am! I do know about the midnight deal. It was at some point working. I’m not sure how/when I messed it up. This is the code I had been using…

condition: not
conditions:
  - condition: sun
    before: sunset
    after: sunrise
    before_offset: '-00:20:00'
    after_offset: '+00:20:00'

Alternatively, my ‘or’ (as pointed out) should have been…

condition: or
conditions:
  - condition: sun
    before: sunrise
    before_offset: '+00:20:00'
  - condition: sun
    after: sunset
    after_offset: '-00:20:00'

Thanks and my apologies…

1 Like