From 2897a15396fbab8e0ae2621dfab18dcf6648f8f9 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 1 May 2023 16:42:15 -0400 Subject: [PATCH] Wakeup lights fading in is now a variable --- node-red/projects/NerdFlows | 2 +- packages/emmalynn.yaml | 20 ++++++++--- packages/lighting_and_scenes.yaml | 14 ++++++++ packages/master_bedroom.yaml | 58 ++++++++++++++++++++++++++++--- 4 files changed, 84 insertions(+), 10 deletions(-) diff --git a/node-red/projects/NerdFlows b/node-red/projects/NerdFlows index a0432e3..4c357d5 160000 --- a/node-red/projects/NerdFlows +++ b/node-red/projects/NerdFlows @@ -1 +1 @@ -Subproject commit a0432e373bcb91a2eb4cbb20c2dfe17f4afbf6f4 +Subproject commit 4c357d5b7370260725af0589557b48a0ad5e544a diff --git a/packages/emmalynn.yaml b/packages/emmalynn.yaml index 9868b5e..1fd58c2 100644 --- a/packages/emmalynn.yaml +++ b/packages/emmalynn.yaml @@ -321,7 +321,9 @@ script: entity_id: light.emma_bedroom_light data: brightness_pct: "{{ brightness }}" - transition: 300 + transition: > + {% from 'time.jinja' import timer_duration %} + {{ timer_duration('input_number.wakeup_lights_fade_night') }} - service: light.turn_on target: entity_id: light.hallway_overhead @@ -347,10 +349,20 @@ script: entity_id: light.emma_bedroom_light data: brightness_pct: "{{ brightness }}" - transition: 60 + transition: > + {% from 'time.jinja' import timer_duration %} + {{ timer_duration('input_number.wakeup_lights_fade_day') }} # Climate/White Noise - - delay: - minutes: 5 + - if: + - condition: state + entity_id: binary_sensor.early_night_mode + state: 'off' + then: + - delay: + minutes: 5 + else: + - delay: + minutes: "{{ states('input_boolean.wakeup_lights_fade_night') }}" - service: input_boolean.turn_off target: entity_id: input_boolean.white_noise_emma_bedroom diff --git a/packages/lighting_and_scenes.yaml b/packages/lighting_and_scenes.yaml index f84c781..0d28a11 100644 --- a/packages/lighting_and_scenes.yaml +++ b/packages/lighting_and_scenes.yaml @@ -72,6 +72,20 @@ input_number: step: 1 unit_of_measurement: minutes icon: mdi:timer + wakeup_lights_fade_day: + name: Wakeup Lights Fade Day + min: 0 + max: 15 + step: 1 + unit_of_measurement: minutes + icon: mdi:timer + wakeup_lights_fade_night: + name: Wakeup Lights Fade Night + min: 0 + max: 15 + step: 1 + unit_of_measurement: minutes + icon: mdi:timer input_select: living_room_scenes: diff --git a/packages/master_bedroom.yaml b/packages/master_bedroom.yaml index 0acbd7b..46f57c6 100644 --- a/packages/master_bedroom.yaml +++ b/packages/master_bedroom.yaml @@ -82,6 +82,8 @@ script: alias: 'Master Bedroom Wakeup' mode: restart sequence: + - variables: + brightness: "{{ state_attr('switch.adaptive_lighting_master_bedroom','brightness_pct') }}" - service: button.press target: entity_id: button.master_bedroom_day_mode @@ -104,11 +106,57 @@ script: {% set weather = states('weather.iron_nerd_weather_station') %} {{ weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] }} then: - - service: input_select.select_option - target: - entity_id: input_select.master_bedroom_scenes - data: - option: Adaptive + - choose: + - conditions: + - condition: state + entity_id: binary_sensor.early_night_mode + state: 'on' + sequence: + - service: switch.turn_off + target: + entity_id: switch.adaptive_lighting_master_bedroom + - delay: + seconds: 1 + - service: light.turn_on + target: + entity_id: light.master_bedroom_lights + data: + brightness_pct: "{{ brightness }}" + transition: > + {% from 'time.jinja' import timer_duration %} + {{ timer_duration('input_number.wakeup_lights_fade_night') }} + - delay: + minutes: "{{ states('input_number.wakeup_lights_fade_night') }}" + - service: input_select.select_option + target: + entity_id: input_select.master_bedroom_scenes + data: + option: Adaptive + - conditions: + - condition: state + entity_id: binary_sensor.early_night_mode + state: 'off' + sequence: + - service: switch.turn_off + target: + entity_id: switch.adaptive_lighting_master_bedroom + - delay: + seconds: 1 + - service: light.turn_on + target: + entity_id: light.master_bedroom_lights + data: + 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: + entity_id: input_select.master_bedroom_scenes + data: + option: Adaptive - service: script.volume_reset master_bedroom_sleep: