Created
May 12, 2022 10:40
-
-
Save erkr/7abf78d6ce9a1edc904124b1e1ee512c to your computer and use it in GitHub Desktop.
Revisions
-
erkr created this gist
May 12, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ # Author Eric Kreuwels, Copyright 2022, publiced under the free MIT license conditions blueprint: name: Actions at Sunrise Offset description: Persistant offset based actions around sunrise. These actions can be any sequence including checking additional conditions if you like domain: automation input: time_shift: name: Time Shift description: Using time shift around Sunrise. A negative value is earlier, a positive value is later. default: "-00:01:00" selector: text: {} 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' # Define the trigger for the automation trigger: - platform: sun event: sunrise offset: !input time_shift - platform: homeassistant event: start condition: # check if the sun is rising (between midnight and noon only) - condition: state entity_id: sun.sun attribute: rising state: true # check is it is after the defined offset - condition: sun after: sunrise after_offset: !input time_shift # check if persistency state actions are needed - condition: template value_template: '{{ trigger.platform!="homeassistant" or trigger_at_startup }}' # now() >= as_datetime(state_attr("sun.sun", "next_rising")) + timedelta( hours = day_shift, minutes = time_shift) }}' # now() > today_at("10:15") action: !input sunrise_actions