Sunset and Time Condition

Hello all,

I’m looking to have in a condition, after sunset, but before 3 am.

This code is not working, what am I doing wrong?

conditions:
  - condition: sun
    after: sunset
  - condition: time
    before: '03:00:00'

Say the sun sets at 20:00 so you want after that but you are anding it with before 03:00

They don’t overlap, so its always false

If that’s the complete condition section, the first line should be condition: not conditions:. If it’s not the complete section, please always post the complete code.

Note it’ll only work from 00:00 to 03:00 as e.g. 23:00 is not before 03:00.

No, not even then

@MontyRisk you need an ‘or’ condition

You’re right, as often the case :wink: . The docs are clear that after: sunset is only True from sunset to midnight.

Perhaps use the sun state condition instead, checking for below_horizon?

No, I get stuff wrong too, another coat of looking at with a fresh pair of eyes is always useful :+1:

1 Like