Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - alias: plants_light
- trigger:
- - platform: sun
- event: sunset
- actions:
- - service: light.turn_on
- data:
- entity_id: light.plants
- - delay: >-
- {% set current_night_length = as_timestamp(state_attr('sun.sun', 'next_setting')) - as_timestamp(state_attr('sun.sun', 'next_rising')) %}
- {% set min_night_length = 7*3600 + 47*60 + 43 %}
- {% set max_night_length = 16*3600 + 46*60 + 39 %}
- {% set scale = 1 - (current_night_length - min_night_length) / (max_night_length - min_night_length) %}
- {% set delay = (scale * min_night_length / 4) | int %}
- {{ delay }}
- - service: light.turn_off
- data:
- entity_id: light.plants
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement