add script blueprint
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
# ha-sunrise-alarm
|
# ha-sunrise-alarm
|
||||||
|
|
||||||
A HomeAssistant blueprint that turns your smart lights into a natural alarm clock.
|
A HomeAssistant blueprint that turns your smart lights into a natural alarm clock.
|
||||||
|
|
||||||
|
<a href="https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https://git.jaroszew.ski/patrick/ha-sunrise-alarm/src/branch/main/sunrise-alarm.yaml">
|
||||||
|
<img src="https://my.home-assistant.io/badges/blueprint_import.svg" alt="Open your Home Assistant instance and show the blueprint import dialog">
|
||||||
|
</a>
|
||||||
140
sunrise-alarm.yaml
Normal file
140
sunrise-alarm.yaml
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
blueprint:
|
||||||
|
name: "Simulated Sunrise Alarm"
|
||||||
|
description: "Smoothly increase light brightness with configurable steps"
|
||||||
|
domain: script
|
||||||
|
|
||||||
|
input:
|
||||||
|
target_lights:
|
||||||
|
name: Target Light(s)
|
||||||
|
description: Light(s) to control
|
||||||
|
selector:
|
||||||
|
target:
|
||||||
|
entity:
|
||||||
|
domain: light
|
||||||
|
reversed:
|
||||||
|
name: "Simulate sunset instead of sunrise"
|
||||||
|
description: If true, reverses the direction (simulates sunset instead of sunrise)
|
||||||
|
selector:
|
||||||
|
boolean:
|
||||||
|
default: false
|
||||||
|
|
||||||
|
steps:
|
||||||
|
name: Number of Steps
|
||||||
|
description: How many brightness steps in the curve
|
||||||
|
default: 20
|
||||||
|
selector:
|
||||||
|
number:
|
||||||
|
min: 5
|
||||||
|
max: 100
|
||||||
|
step: 1
|
||||||
|
|
||||||
|
total_duration:
|
||||||
|
name: Total Duration
|
||||||
|
description: Total time to complete the brightness ramp
|
||||||
|
default: 30
|
||||||
|
selector:
|
||||||
|
number:
|
||||||
|
min: 1
|
||||||
|
max: 120
|
||||||
|
unit_of_measurement: minutes
|
||||||
|
|
||||||
|
start_brightness:
|
||||||
|
name: Starting Brightness
|
||||||
|
description: Initial brightness percentage (0-100)
|
||||||
|
default: 1
|
||||||
|
selector:
|
||||||
|
number:
|
||||||
|
min: 0
|
||||||
|
max: 100
|
||||||
|
step: 1
|
||||||
|
|
||||||
|
end_brightness:
|
||||||
|
name: Ending Brightness
|
||||||
|
description: Final brightness percentage (0-100)
|
||||||
|
default: 100
|
||||||
|
selector:
|
||||||
|
number:
|
||||||
|
min: 1
|
||||||
|
max: 100
|
||||||
|
step: 1
|
||||||
|
|
||||||
|
start_temp:
|
||||||
|
name: Starting Color Temperature
|
||||||
|
description: Final color temperature in Kelvin
|
||||||
|
default: 2000
|
||||||
|
selector:
|
||||||
|
color_temp:
|
||||||
|
min: 2000
|
||||||
|
unit: kelvin
|
||||||
|
|
||||||
|
end_temp:
|
||||||
|
name: Ending Color Temperature
|
||||||
|
description: Final color temperature in Kelvin
|
||||||
|
default: 5500
|
||||||
|
selector:
|
||||||
|
color_temp:
|
||||||
|
unit: kelvin
|
||||||
|
|
||||||
|
curve_type:
|
||||||
|
name: Curve Type
|
||||||
|
default: "parabolic"
|
||||||
|
description: “linear”, "parabolic" (quadratic), or “sigmoid” (an S-curve/logistic curve)
|
||||||
|
selector:
|
||||||
|
select:
|
||||||
|
options:
|
||||||
|
- "linear"
|
||||||
|
- "sigmoidal"
|
||||||
|
- "parabolic"
|
||||||
|
|
||||||
|
variables:
|
||||||
|
lights: !input target_lights
|
||||||
|
start_temp: !input start_temp
|
||||||
|
end_temp: !input end_temp
|
||||||
|
curve_type: !input curve_type
|
||||||
|
total_duration: !input total_duration
|
||||||
|
num_steps: !input steps
|
||||||
|
step_delay: "{{ (total_duration * 60 / num_steps) | round(0) }}"
|
||||||
|
start_bright: !input start_brightness
|
||||||
|
end_bright: !input end_brightness
|
||||||
|
reversed: !input reversed
|
||||||
|
|
||||||
|
# Loop through each step of the curve
|
||||||
|
sequence:
|
||||||
|
- repeat:
|
||||||
|
count: "{{ num_steps }}"
|
||||||
|
sequence:
|
||||||
|
- variables:
|
||||||
|
# Calculate current step (0 to 1 range)
|
||||||
|
x: "{{ (repeat.index - 1) / (num_steps - 1) }}"
|
||||||
|
|
||||||
|
# Reflects the curve in the y-axis if reversed is true
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ reversed }}"
|
||||||
|
sequence:
|
||||||
|
- variables:
|
||||||
|
x: "{{ 1 - x }}"
|
||||||
|
|
||||||
|
- variables:
|
||||||
|
curve_func: >
|
||||||
|
{%- if curve_type == 'linear' -%}
|
||||||
|
{{ x }}
|
||||||
|
{%- elif curve_type == 'sigmoidal' -%}
|
||||||
|
{{ 1 / (1 + (2.71828 ** (-12 * (x - 0.5)))) }}
|
||||||
|
{%- elif curve_type == 'parabolic' -%}
|
||||||
|
{{ x ** 2 }}
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
|
# Map result to brightness range and color temperature range respectively
|
||||||
|
current_brightness: "{{ (start_bright + (end_bright - start_bright) * curve_func | float) | round(0) }}"
|
||||||
|
current_color_temp: "{{ (start_temp + (end_temp - start_temp) * curve_func | float) | round(0) }}"
|
||||||
|
|
||||||
|
- service: light.turn_on
|
||||||
|
target: !input target_lights
|
||||||
|
data:
|
||||||
|
brightness_pct: "{{ current_brightness }}"
|
||||||
|
kelvin: "{{ current_color_temp }}"
|
||||||
|
transition: "{{ step_delay }}"
|
||||||
|
|
||||||
|
- delay: "{{ step_delay }}"
|
||||||
Reference in New Issue
Block a user