I have an automation to turn on an office light when i walk in to the office after sunset but before 2am (I don’t want it to come on early in the morning)
It was my belief that the automation system for time knows the spanning of midnight, however, I ended up with this trace…
Result:
after:
__type: <class 'datetime.time'>
isoformat: '00:00:00'
now_time:
__type: <class 'datetime.time'>
isoformat: '16:28:47.378672'
before:
__type: <class 'datetime.time'>
isoformat: '02:00:00'
result: false```
...from this code...
alias: Office Light On/Off
description: “”
triggers:
- trigger: state
entity_id:- binary_sensor.office_presence_occupancy
from: “off”
to: “on”
id: detected
- binary_sensor.office_presence_occupancy
- trigger: state
entity_id:- binary_sensor.office_presence_occupancy
from: “on”
to: “off”
id: clear
conditions:
- binary_sensor.office_presence_occupancy
- condition: state
entity_id: sun.sun
state: below_horizon - condition: time
before: “02:00:00”
actions: - choose:
- conditions:
- condition: trigger
id:- detected
sequence:
- detected
- action: light.turn_on
metadata: {}
data:
brightness_pct: 16
target:
device_id: debdfcb9f64847d605aac81b91441be0
- condition: trigger
- conditions:
- condition: trigger
id:- clear
sequence:
- clear
- action: light.turn_off
metadata: {}
data: {}
target:
device_id: debdfcb9f64847d605aac81b91441be0
mode: single
- condition: trigger
- conditions:
It seems that my definition for below horizon is somehow returning midnight?