I want to automate that the front door light is on when the paperboy arrives.
Is this code the most logical?
-paperboy arrives between 6:00 and 7:00
-only turn on when its still dark (elevation below -3.5)
-don’t turn on when it is already on.
I think setting one of the conditions as trigger is not possible, or am I thinking wrong?
- alias: Front door light on
hide_entity: true
trigger:
platform: time
minutes: '/1'
seconds: 00
condition:
- condition: template
value_template: '{{ states.sun.sun.attributes.elevation < -3.5 }}'
- condition: time
after: '06:00:00'
before: '07:00:00'
- condition: state
entity_id: light.frontdoorlight
state: 'off'
action:
- service: light.turn_on
entity_id: light.frontdoorlight
I forgot the 2nd automation that should turn the light off (when elevation is above -3.5).
The way yaml works (new for me) confuses me a little.
Maybe this is better?
1st automation: If at 6:00 it is dark (elevation below -3.5) turn on the light.
2nd automation: When elevation becomes above -3.5 turn off the light
- alias: Front door light on
hide_entity: true
trigger:
platform: time
at: '06:00:00'
condition:
- condition: template
value_template: '{{ states.sun.sun.attributes.elevation < -3.5 }}'
- condition: state
entity_id: light.frontdoorlight
state: 'off'
action:
- service: light.turn_on
entity_id: light.frontdoorlight
- service: notify.pushetta
data:
message: front door light on
- alias: Front door light off
hide_entity: true
trigger:
platform: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.elevation }}'
above: -3.5
condition:
- condition: state
entity_id: light.frontdoorlight
state: 'on'
action:
- service: light.turn_off
entity_id: light.frontdoorlight
- service: notify.pushetta
data:
message: front door light off