Hi
use case 1: at night I want turn lights on at dusk and turn them off at certain time, but before turn lights on, check if it is not later than “time to turn lights off”.
use case 2: in the morning, I want to turn lights on at certain time and turn them off at dawn, but before turn lights on, check if it is not later than dawn
for use case 1: automation looks like:
alias: lights on/off night
description: ""
trigger:
- platform: numeric_state
entity_id: sun.sun
value_template: "{{ state.attributes.elevation }}"
below: -5.9
alias: lights on night
id: lights.on.nig
- platform: time
at: input_datetime.outdoor_lights_off
alias: Lights off night
id: lights.off.nig
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: lights.on.nig
alias: at dawn
- condition: time
before: input_datetime.outdoor_lights_off
alias: and before lights off time
after: "00:00:00"
sequence:
- service: light.turn_on
data: {}
target:
device_id: xxx
- conditions:
- condition: trigger
id: lights.off.nig
alias: when lights off time
sequence:
- service: light.turn_off
data: {}
target:
device_id: xxx
mode: single
for use case 2: I know it’s wrong but…
alias: lights on/off morning
description: ""
trigger:
- platform: time
at: input_datetime.outdoor_lights_on
alias: lights.on.morning
id: lights.on.mor
- platform: numeric_state
entity_id: sun.sun
value_template: "{{ state.attributes.elevation }}"
above: -5.9
id: lights.off.mor
alias: lights.off.morning
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: lights.on.mor
- condition: sun
before: sunrise --> this is not right. it should be before dawn or before sun.sun elevation below - 6
sequence:
- service: light.turn_on
data: {}
target:
device_id: xxx
- conditions:
- condition: trigger
id: lights.off.mor
sequence:
- service: light.turn_off
data: {}
target:
device_id: xxx
mode: single
Any idea how to add condition only turn the lights on if before dawn?
Thanks