trying script blueprint

This commit is contained in:
Stephen Kuntz 2024-09-24 08:50:53 -04:00
parent 7c28897c56
commit 9bb6e5d5ca

View File

@ -71,18 +71,18 @@ blueprint:
default: 5
name: Light Timeout
variables:
steps: !input alarm_length * !input steps_per_minute
steps: !input 'alarm_length' * !input 'steps_per_minute'
min_brightness: |-
{% if states(!input target_light) == 'off' %}
{% if states(!input 'target_light') == 'off' %}
3
{% else %}
{{ state_attr(!input target_light, 'brightness') }}
{{ state_attr(!input 'target_light', 'brightness') }}
{% endif %}
max_brightness: !input max_brightness_pct * 2.55
kelvin_step: (!input target_kelvin - !input start_kelvin) / steps
bright_step: (!input max_brightness - !input min_brightness) / steps
max_brightness: !input 'max_brightness_pct' * 2.55
kelvin_step: (!input 'target_kelvin' - !input 'start_kelvin') / steps
bright_step: (!input 'max_brightness' - !input 'min_brightness') / steps
start_time: "{{ as_timestamp(now()) }}"
individual_step: 60 / !input steps_per_minute
individual_step: 60 / !input 'steps_per_minute'
mode: parallel
sequence:
- repeat:
@ -90,12 +90,12 @@ sequence:
- condition: or
conditions:
- condition: template
value_template: "{{ is_state(!input target_light, 'off') }}"
value_template: "{{ is_state(!input 'target_light', 'off') }}"
- condition: template
value_template: "{{ state_attr(!input target_light, 'brightness') >= max_brightness }}"
value_template: "{{ state_attr(!input 'target_light', 'brightness') >= max_brightness }}"
- condition: template
value_template: >-
{{ state_attr(!input target_light, 'color_temp_kelvin') >=
{{ state_attr(!input 'target_light', 'color_temp_kelvin') >=
target_kelvin }}
- condition: template
value_template: >-
@ -109,31 +109,31 @@ sequence:
brightness: >-
{{ min_brightness + (bright_step * steps_to_now) | round(0,
'ceil') }}
kelvin: "{{ !input start_kelvin + (kelvin_step * steps_to_now) }}"
kelvin: "{{ !input 'start_kelvin' + (kelvin_step * steps_to_now) }}"
- delay:
seconds: "{{ individual_step }}"
- if:
- condition: template
value_template: "{{ is_state(!input target_light, 'on') }}"
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 }}"
entity_id: "{{ !input 'target_light' }}"
action: light.turn_on
- if:
- condition: and
conditions:
- condition: template
value_template: "{{ !input light_timeout != 0 }}"
value_template: "{{ !input 'light_timeout' != 0 }}"
- condition: template
value_template: "{{ is_state(!input target_light, 'on') }}"
value_template: "{{ is_state(!input 'target_light', 'on') }}"
then:
- delay:
minutes: "{{ !input light_timeout }}"
minutes: "{{ !input 'light_timeout' }}"
- data: {}
target:
entity_id: "{{ !input target_light }}"
entity_id: "{{ !input 'target_light' }}"
action: light.turn_off