mirror of
https://github.com/steku/ha_cercadian_alarm.git
synced 2025-12-14 18:39:40 +00:00
trying script blueprint
This commit is contained in:
@ -2,66 +2,13 @@ blueprint:
|
|||||||
name: Lamp Wake Up
|
name: Lamp Wake Up
|
||||||
author: steriku
|
author: steriku
|
||||||
description: >
|
description: >
|
||||||
|
IN TESTING ONLY. NOT FINISHED. DO NOT USE
|
||||||
Campanion Script to the parabolic alarm automation blueprint. Turn on lamps brighter based on wake time
|
Campanion Script to the parabolic alarm automation blueprint. Turn on lamps brighter based on wake time
|
||||||
source_url: https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/play_media_file_script.yaml
|
source_url: https://github.com/steku/ha_cercadian_alarm/blob/main/blueprint_parabolic_alarm_script.yaml
|
||||||
domain: script
|
domain: script
|
||||||
homeassistant:
|
homeassistant:
|
||||||
min_version: 2024.9.0
|
min_version: 2024.9.0
|
||||||
sequence:
|
inputs:
|
||||||
- repeat:
|
|
||||||
until:
|
|
||||||
- condition: or
|
|
||||||
conditions:
|
|
||||||
- condition: template
|
|
||||||
value_template: "{{ is_state(target_light, 'off') }}"
|
|
||||||
- condition: template
|
|
||||||
value_template: "{{ state_attr(target_light, 'brightness') >= max_brightness }}"
|
|
||||||
- condition: template
|
|
||||||
value_template: >-
|
|
||||||
{{ state_attr(target_light, 'color_temp_kelvin') >=
|
|
||||||
target_kelvin }}
|
|
||||||
- condition: template
|
|
||||||
value_template: >-
|
|
||||||
{{ (((as_timestamp(now()) - start_time) / individual_step) |
|
|
||||||
round(0, "ceil")) > steps }}
|
|
||||||
sequence:
|
|
||||||
- variables:
|
|
||||||
steps_to_now: |-
|
|
||||||
{{ ((as_timestamp(now()) - start_time) / individual_step) |
|
|
||||||
round(0, "ceil") }}
|
|
||||||
brightness: >-
|
|
||||||
{{ min_brightness + (bright_step * steps_to_now) | round(0,
|
|
||||||
'ceil') }}
|
|
||||||
kelvin: "{{ start_kelvin + (kelvin_step * steps_to_now) }}"
|
|
||||||
- delay:
|
|
||||||
seconds: "{{ individual_step }}"
|
|
||||||
- if:
|
|
||||||
- condition: template
|
|
||||||
value_template: "{{ is_state(target_light, 'on') }}"
|
|
||||||
then:
|
|
||||||
- data:
|
|
||||||
brightness: "{{ brightness }}"
|
|
||||||
color_temp_kelvin: "{{ kelvin }}"
|
|
||||||
transition: "{{ individual_step - 1 }}"
|
|
||||||
target:
|
|
||||||
entity_id: "{{ target_light }}"
|
|
||||||
action: light.turn_on
|
|
||||||
- if:
|
|
||||||
- condition: and
|
|
||||||
conditions:
|
|
||||||
- condition: template
|
|
||||||
value_template: "{{ light_timeout != 0 }}"
|
|
||||||
- condition: template
|
|
||||||
value_template: "{{ is_state(target_light, 'on') }}"
|
|
||||||
then:
|
|
||||||
- delay:
|
|
||||||
minutes: "{{ light_timeout }}"
|
|
||||||
- data: {}
|
|
||||||
target:
|
|
||||||
entity_id: "{{ target_light }}"
|
|
||||||
action: light.turn_off
|
|
||||||
|
|
||||||
fields:
|
|
||||||
target_kelvin:
|
target_kelvin:
|
||||||
description: Coldest Kelvin value. This is the end value - most white
|
description: Coldest Kelvin value. This is the end value - most white
|
||||||
selector:
|
selector:
|
||||||
@ -138,16 +85,69 @@ fields:
|
|||||||
name: Light Timeout
|
name: Light Timeout
|
||||||
required: true
|
required: true
|
||||||
variables:
|
variables:
|
||||||
steps: "{{ alarm_length * steps_per_minute }}"
|
steps: "{{ !input alarm_length * !input steps_per_minute }}"
|
||||||
min_brightness: |-
|
min_brightness: |-
|
||||||
{% if states(target_light) == 'off' %}
|
{% if states(!input target_light) == 'off' %}
|
||||||
3
|
3
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ state_attr(target_light, 'brightness') }}
|
{{ state_attr(!input target_light, 'brightness') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
max_brightness: "{{ max_brightness_pct * 2.55 }}"
|
max_brightness: "{{ !input max_brightness_pct * 2.55 }}"
|
||||||
kelvin_step: "{{ (target_kelvin - start_kelvin) / steps }}"
|
kelvin_step: "{{ (!input target_kelvin - !input start_kelvin) / steps }}"
|
||||||
bright_step: "{{ (max_brightness - min_brightness) / steps }}"
|
bright_step: "{{ (!input max_brightness - !input min_brightness) / steps }}"
|
||||||
start_time: "{{ as_timestamp(now()) }}"
|
start_time: "{{ as_timestamp(now()) }}"
|
||||||
individual_step: "{{ 60 / steps_per_minute }}"
|
individual_step: "{{ 60 / !input steps_per_minute }}"
|
||||||
mode: parallel
|
mode: parallel
|
||||||
|
sequence:
|
||||||
|
- repeat:
|
||||||
|
until:
|
||||||
|
- condition: or
|
||||||
|
conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ is_state(!input target_light, 'off') }}"
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ state_attr(!input target_light, 'brightness') >= max_brightness }}"
|
||||||
|
- condition: template
|
||||||
|
value_template: >-
|
||||||
|
{{ state_attr(!input target_light, 'color_temp_kelvin') >=
|
||||||
|
target_kelvin }}
|
||||||
|
- condition: template
|
||||||
|
value_template: >-
|
||||||
|
{{ (((as_timestamp(now()) - start_time) / individual_step) |
|
||||||
|
round(0, "ceil")) > steps }}
|
||||||
|
sequence:
|
||||||
|
- variables:
|
||||||
|
steps_to_now: |-
|
||||||
|
{{ ((as_timestamp(now()) - start_time) / individual_step) |
|
||||||
|
round(0, "ceil") }}
|
||||||
|
brightness: >-
|
||||||
|
{{ min_brightness + (bright_step * steps_to_now) | round(0,
|
||||||
|
'ceil') }}
|
||||||
|
kelvin: "{{ !input start_kelvin + (kelvin_step * steps_to_now) }}"
|
||||||
|
- delay:
|
||||||
|
seconds: "{{ individual_step }}"
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ is_state(!input target_light, 'on') }}"
|
||||||
|
then:
|
||||||
|
- data:
|
||||||
|
brightness: "{{ brightness }}"
|
||||||
|
color_temp_kelvin: "{{ kelvin }}"
|
||||||
|
transition: "{{ individual_step - 1 }}"
|
||||||
|
target:
|
||||||
|
entity_id: "{{ !input target_light }}"
|
||||||
|
action: light.turn_on
|
||||||
|
- if:
|
||||||
|
- condition: and
|
||||||
|
conditions:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ !input light_timeout != 0 }}"
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ is_state(!input target_light, 'on') }}"
|
||||||
|
then:
|
||||||
|
- delay:
|
||||||
|
minutes: "{{ !input light_timeout }}"
|
||||||
|
- data: {}
|
||||||
|
target:
|
||||||
|
entity_id: "{{ !input target_light }}"
|
||||||
|
action: light.turn_off
|
||||||
|
|||||||
Reference in New Issue
Block a user