Add better provision for interrupting wakeup lights fading in

Improve the previous
This commit is contained in:
2023-05-01 18:08:54 -04:00
parent 48f38ccbe6
commit 9620344ce9
2 changed files with 119 additions and 123 deletions

View File

@ -329,25 +329,11 @@ script:
# Lighting # Lighting
- variables: - variables:
brightness: "{{ state_attr('switch.adaptive_lighting_emma_bedroom','brightness_pct') }}" brightness: "{{ state_attr('switch.adaptive_lighting_emma_bedroom','brightness_pct') }}"
- choose: - if:
- conditions:
- condition: state - condition: state
entity_id: binary_sensor.early_night_mode entity_id: binary_sensor.early_night_mode
state: 'on' state: 'on'
sequence: then:
- service: switch.turn_off
target:
entity_id: switch.adaptive_lighting_emma_bedroom
- delay:
seconds: 1
- service: light.turn_on
target:
entity_id: light.emma_bedroom_light
data:
brightness_pct: "{{ brightness }}"
transition: >
{% from 'time.jinja' import timer_duration %}
{{ timer_duration('input_number.wakeup_lights_fade_night') }}
- service: light.turn_on - service: light.turn_on
target: target:
entity_id: light.hallway_overhead entity_id: light.hallway_overhead
@ -358,11 +344,6 @@ script:
- input_select.master_bedroom_scenes - input_select.master_bedroom_scenes
data: data:
option: Adaptive option: Adaptive
- conditions:
- condition: state
entity_id: binary_sensor.early_night_mode
state: 'off'
sequence:
- service: switch.turn_off - service: switch.turn_off
target: target:
entity_id: switch.adaptive_lighting_emma_bedroom entity_id: switch.adaptive_lighting_emma_bedroom
@ -375,18 +356,49 @@ script:
brightness_pct: "{{ brightness }}" brightness_pct: "{{ brightness }}"
transition: > transition: >
{% from 'time.jinja' import timer_duration %} {% from 'time.jinja' import timer_duration %}
{% if is_state('binary_sensor.early_night_mode','on') %}
{{ timer_duration('input_number.wakeup_lights_fade_night') }}
{% else %}
{{ timer_duration('input_number.wakeup_lights_fade_day') }} {{ timer_duration('input_number.wakeup_lights_fade_day') }}
{% endif %}
- wait_for_trigger:
- platform: state
entity_id: light.emma_bedroom_light
to: 'off'
id: lights-off
- platform: state
entity_id: input_select.emma_bedroom_scenes
to: 'Adaptive'
id: adaptive
timeout:
minutes: >
{% if is_state('binary_sensor.early_night_mode','on') %}
{{ states('input_number.wakeup_lights_fade_night') }}
{% else %}
5
{% endif %}
- choose:
- conditions: "{{ wait.trigger == none }}"
sequence:
- service: input_select.select_option
target:
entity_id: input_select.emma_bedroom_scenes
data:
option: Adaptive
- conditions: "{{ wait.trigger.id == 'lights-off' }}"
sequence:
- service: switch.turn_on
target:
entity_id: switch.adaptive_lighting_emma_bedroom
- service: switch.turn_off
target:
entity_id: switch.adaptive_lighting_sleep_mode_emma_bedroom
- service: input_text.set_value
target:
entity_id: input_text.emma_bedroom_selected_scene
data:
value: Adaptive
# Climate/White Noise # Climate/White Noise
- if:
- condition: state
entity_id: binary_sensor.early_night_mode
state: 'off'
then:
- delay:
minutes: 5
else:
- delay:
minutes: "{{ states('input_number.wakeup_lights_fade_night') }}"
- service: input_boolean.turn_off - service: input_boolean.turn_off
target: target:
entity_id: input_boolean.white_noise_emma_bedroom entity_id: input_boolean.white_noise_emma_bedroom
@ -398,11 +410,6 @@ script:
- service: script.turn_on - service: script.turn_on
target: target:
entity_id: script.emma_aircon_shutoff entity_id: script.emma_aircon_shutoff
- service: input_select.select_option
target:
entity_id: input_select.emma_bedroom_scenes
data:
option: Adaptive
emma_aircon_shutoff: emma_aircon_shutoff:
alias: 'Emma Air Conditioner Shutoff' alias: 'Emma Air Conditioner Shutoff'

View File

@ -90,28 +90,9 @@ script:
- service: switch.turn_off - service: switch.turn_off
target: target:
entity_id: switch.master_bedroom_echo_dot_do_not_disturb_switch entity_id: switch.master_bedroom_echo_dot_do_not_disturb_switch
- service: media_player.volume_set - service: script.turn_on
target: target:
entity_id: media_player.master_bedroom_echo_dot entity_id: script.volume_reset
data:
volume_level: >
{% if is_state('input_boolean.give_me_darkness','on') %}
{{ states('input_number.master_bedroom_echo_dot_night_volume') }}
{% else %}
{{ states('input_number.master_bedroom_echo_dot_day_volume') }}
{% endif %}
- if:
- condition: template
value_template: >
{% set weather = states('weather.iron_nerd_weather_station') %}
{{ weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] }}
then:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.early_night_mode
state: 'on'
sequence:
- service: switch.turn_off - service: switch.turn_off
target: target:
entity_id: switch.adaptive_lighting_master_bedroom entity_id: switch.adaptive_lighting_master_bedroom
@ -124,40 +105,48 @@ script:
brightness_pct: "{{ brightness }}" brightness_pct: "{{ brightness }}"
transition: > transition: >
{% from 'time.jinja' import timer_duration %} {% from 'time.jinja' import timer_duration %}
{% if is_state('binary_sensor.early_night_mode','on') %}
{{ timer_duration('input_number.wakeup_lights_fade_night') }} {{ timer_duration('input_number.wakeup_lights_fade_night') }}
- delay: {% else %}
minutes: "{{ states('input_number.wakeup_lights_fade_night') }}" {{ timer_duration('input_number.wakeup_lights_fade_day') }}
{% endif %}
- wait_for_trigger:
- platform: state
entity_id: light.master_bedroom_lights
to: 'off'
id: lights-off
- platform: state
entity_id: input_select.master_bedroom_scenes
to: 'Adaptive'
id: adaptive
timeout:
minutes: >
{% if is_state('binary_sensor.early_night_mode','on') %}
{{ states('input_number.wakeup_lights_fade_night') }}
{% else %}
{{ states('input_number.wakeup_lights_fade_day') }}
{% endif %}
- choose:
- conditions: "{{ wait.trigger == none }}"
sequence:
- service: input_select.select_option - service: input_select.select_option
target: target:
entity_id: input_select.master_bedroom_scenes entity_id: input_select.master_bedroom_scenes
data: data:
option: Adaptive option: Adaptive
- conditions: - conditions: "{{ wait.trigger.id == 'lights-off' }}"
- condition: state
entity_id: binary_sensor.early_night_mode
state: 'off'
sequence: sequence:
- service: switch.turn_off - service: switch.turn_on
target: target:
entity_id: switch.adaptive_lighting_master_bedroom entity_id: switch.adaptive_lighting_master_bedroom
- delay: - service: switch.turn_off
seconds: 1
- service: light.turn_on
target: target:
entity_id: light.master_bedroom_lights entity_id: switch.adaptive_lighting_sleep_mode_master_bedroom
data: - service: input_text.set_value
brightness_pct: "{{ brightness }}"
transition: >
{% from 'time.jinja' import timer_duration %}
{{ timer_duration('input_number.wakeup_lights_fade_day') }}
- delay:
minutes: "{{ states('input_number.wakeup_lights_fade_day') }}"
- service: input_select.select_option
target: target:
entity_id: input_select.master_bedroom_scenes entity_id: input_text.master_bedroom_selected_scene
data: data:
option: Adaptive value: Adaptive
- service: script.volume_reset
master_bedroom_sleep: master_bedroom_sleep:
alias: 'Master Bedroom Sleep' alias: 'Master Bedroom Sleep'