Last active
July 8, 2024 20:30
-
-
Save erkr/27bb347ab107c4a9231046e75667356b to your computer and use it in GitHub Desktop.
Home Assistant Blueprint for 'persistent' Sunrise elevation triggered actions
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
# Author Eric Kreuwels, Copyright 2022, publiced under the free MIT license conditions | |
blueprint: | |
name: Actions at Sunrise elevation | |
description: Persistant elevation based actions around sunrise. These actions can be any sequence including checking additional conditions if you like | |
domain: automation | |
input: | |
elevation_shift: | |
name: Elevation Shift | |
description: Using an elevation angle of the sun relative to the horizon; a positive angle is above the horizon. Angles between 0 and -3 degrees are in the twilight zone | |
default: 0.0 | |
selector: | |
number: | |
min: -6.0 | |
max: 6.0 | |
mode: slider | |
step: 0.5 | |
unit_of_measurement : degrees | |
trigger_at_startup: | |
name: Trigger at Home Assistant startup | |
description: Trigger the target state check and enforcement at Home Assistant. This check is only effective between Solar Midnight and Solar Noon. | |
default: true | |
selector: | |
boolean: {} | |
sunrise_actions: | |
name: Sunrise Actions | |
description: Action to run at the defined elevations around sunrise | |
default: [] | |
selector: | |
action: {} | |
# Prevent the automation from running concurrently | |
mode: single | |
# Define the variables used in the action section | |
variables: | |
trigger_at_startup: !input 'trigger_at_startup' | |
elevation_shift: !input 'elevation_shift' | |
# Define the trigger for the automation | |
trigger: | |
- platform: numeric_state | |
entity_id: sun.sun | |
attribute: elevation | |
above: !input elevation_shift | |
- platform: homeassistant | |
event: start | |
condition: | |
# check if the sun is settling (between noon and midnight only) | |
- condition: state | |
entity_id: sun.sun | |
attribute: rising | |
state: true | |
# check if persistency state actions are needed | |
- condition: template | |
value_template: '{{ trigger.platform!="homeassistant" or (trigger_at_startup and state_attr("sun.sun", "elevation") >= elevation_shift and state_attr("sun.sun", "elevation") <= elevation_shift + 2) }}' | |
action: !input sunrise_actions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment