Hey everyone! I wanted to share a fun automation setup I’ve been working on. I’ve always loved how the outdoor lights in my garden come on at sunset, but I wanted to make sure they only activate between 17:00 and 21:00. I’ve been a bit puzzled about how to set this up without the lights turning on too early or too late. After some research, I found that using the sun’s elevation as a trigger works perfectly! Here’s how I set it up:
yaml
alias: ‘Turn outside lights when sun is dim’
trigger:
platform: numeric_state
entity_id: sun.sun
value_template: ‘{{ state.attributes.elevation }}’
below: 4.0
condition:
condition: time
after: ‘17:00:00’
before: ‘21:00:00’
action:
- service: light.turn_on
entity_id: light.outside - service: switch.turn_on
entity_id: switch.switch_outside_light_west
This setup ensures the lights come on when the sun is low enough, but not before 5 PM or after 9 PM. It’s been working beautifully! The garden looks stunning at sunset, and I love how it creates a warm atmosphere. If anyone has tips on fine-tuning this further, I’d love to hear them! ![]()
![]()