Not sure if this is the right title for my question, but what I’m trying to acomplish is:
-
Base Automation (blueprint) that adapts the lights from X brightness & color to Y brightness & color, starting at time A, ending at time B, stops the change when a manual change is made
Multiple automations will be based on this blueprint with different start/end times and light values.
This blueprint is finished and working -
Actionable Notification Automation/script that if in the Base Automation a manual change is made, I receive an actionable notification on my phone after X minutes that asks me to continue the light change. If I reply “Yes” it will continue from the light settings at that moment
This is not yet finished, but I’m working on it. -
Time Home Automation that when I get home, it turns on the lights with values based on the time I get home (either bright and cool lights in daytime or dimmed and warm at night), then it calculates how long from that point until the next Base Automation will start and after X amount of minutes, it gradually dims the lights until the desired start values from the next automation based on Base Automation are reached.
Now that I’ve finally finished my first blueprint Base Automation, I want to amplify the automation by the functions 2 and 3. I’m looking for tips and ideas to use these automations efficiently and have them work together (Time Home knows when next script from Base Automation is running).
What actions should be combined into 1 automation and which shouldn’t?
What actions should be run in a script and which in an automation?
In case this makes my idea a bit more clear, below is the blueprint Base Automation (currently in script form, because I haven’t tested the automation version yet)
blueprint:
name: AL ES Adaptive Lights
description: Change lights based on time of day
domain: script
input:
target_light:
name: Lights
description: The light(s) with kelvin
selector:
entity:
filter:
- domain:
- light
multiple: true
start_time:
name: Start Time
description: Time to start the automation
selector:
time: {}
default: null
end_time:
name: End Time
description: Time the script should end
selector:
time: {}
start_template:
name: Start Template
description: Start based on a template
selector:
template:
default: false
steps_per_minute:
name: Steps per minute for all runs
description: Used for configuring percentage of each step for brightness and color temperature
default: 5
selector:
number:
min: 1
max: 12
start_kelvin:
description: Start Kelvin value
selector:
color_temp:
unit: kelvin
default: ""
name: Starting Kelvin
end_kelvin:
description: >-
Target Kelvin value
selector:
color_temp:
unit: kelvin
name: Target Kelvin
start_bright:
name: Start brightness
description: Start brightess percent
selector:
number:
min: 1
max: 100
default: ""
end_bright:
name: Maximum Brightness
description: End brightness percent
selector:
number:
min: 1
max: 100
default: ""
manual_override:
name: Input boolean for manual changes
description: Stop change of lights when manual change is made
selector:
entity:
filter:
- domain:
- input_boolean
reminder_continue_change:
name: Reminder to continue light change
description: >-
Send an actionable notification after time has passed to continue the light change
selector:
time: {}
default: "00:30:00"
mode: single
variables:
start_time: !input start_time
end_time: !input end_time
steps_per_minute: !input steps_per_minute
start_kelvin: !input start_kelvin
end_kelvin: !input end_kelvin
start_bright: !input start_bright
end_bright: !input end_bright
manual_override: !input manual_override
duration: >
{% set start = strptime(start_time, '%H:%M:%S') %}
{% set end = strptime(end_time, '%H:%M:%S') %}
{% if start > end %}
{% set end = end + timedelta(days=1) %}
{% endif %}
{{ (end - start).total_seconds() / 60 }}
intervals: "{{ duration * steps_per_minute | int }}"
step_kelvin: "{{ ((end_kelvin - start_kelvin) / intervals) }}"
step_bright: "{{ ((end_bright - start_bright) / intervals) }}"
sequence:
- variables:
step_kelvin: >
{% if start_kelvin < end_kelvin %}
{{ (end_kelvin - start_kelvin) / intervals }}
{% else %}
{{ (start_kelvin - end_kelvin) / intervals * -1 }}
{% endif %}
step_bright: >
{% if start_bright < end_bright %}
{{ (end_bright - start_bright) / intervals }}
{% else %}
{{ (start_bright - end_bright) / intervals * -1 }}
{% endif %}
- service: light.turn_on
target:
entity_id: !input target_light
data:
brightness_pct: "{{ start_bright }}"
color_temp_kelvin: "{{ start_kelvin }}"
- delay:
seconds: 2
- repeat:
until:
- condition: or
conditions:
- condition: state
entity_id: !input manual_override
state: "on"
- condition: template
value_template: "{{ repeat.index == intervals | int }}"
sequence:
- service: light.turn_on
target:
entity_id: !input target_light
data:
brightness_pct: "{{ (start_bright + (step_bright * repeat.index)) | int }}"
color_temp_kelvin: "{{ (start_kelvin + (step_kelvin * repeat.index)) | int }}"
- delay:
seconds: 2