Forked from Knuspel/switches_on_at_sunset.yaml
Last active
December 12, 2021 12:06
-
-
Save albertzak/2b540703f9fda0d148a81d13fe52e2bd to your computer and use it in GitHub Desktop.
Home Assistant Blueprint for Turning Switches Off At Sunrise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Switch Off At Sunrise | |
description: Turn off the following switches at sunset | |
domain: automation | |
input: | |
# Create a variable for identifying the light to act upon | |
target_switch: | |
name: Switches | |
description: This is the switch (or switches) that will be turned off at sunset | |
# Use a selector, to pick the light(s) | |
selector: | |
target: | |
entity: | |
domain: switch | |
# Create a variable for capturing the desired offset for shifting the trigger | |
elevation_shift: | |
name: Elevation Shift | |
description: Using an elevation offset (height of sun relative to the horizon) to shift the sunset trigger, either earlier or later. Positive values bring the automation start time forward, whilst negative values delay the start time. | |
default: 0.0 | |
# Use a selector, to set the time shift or offset | |
selector: | |
number: | |
min: -10.0 | |
max: 10.0 | |
mode: slider | |
step: 1.0 | |
# Prevent the automation from running concurrently | |
mode: single | |
# Define the variables used in the action section | |
variables: | |
target_switch: !input target_switch | |
# Define the trigger for the automation | |
trigger: | |
# Using the state of the sun to act as the trigger | |
platform: numeric_state | |
entity_id: sun.sun | |
attribute: elevation | |
# Can be a positive or negative number | |
above: !input elevation_shift | |
# Add a condition to ensure that this only triggers near sunrise, in the morning | |
condition: | |
# Check that it is after sunrise | |
condition: sun | |
after: sunset | |
# Add a buffer to be sure | |
after_offset: "01:00:00" | |
# This section will take action on the lights, and turn them off | |
action: | |
# A very simple structure of turning on the selected light(s) | |
- service: switch.turn_off | |
target: !input target_switch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment