From 1c3e2f189eb78e25d1c295aabf4bb6ef04a71d35 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Tue, 3 Jan 2023 16:23:32 -0500 Subject: [PATCH] Revamp how morning/night works in E's bedroom --- packages/climate.yaml | 134 ++++++++++++++++++++++-------- packages/lighting_and_scenes.yaml | 42 ---------- 2 files changed, 101 insertions(+), 75 deletions(-) diff --git a/packages/climate.yaml b/packages/climate.yaml index 7ff66cf..4bf54bb 100644 --- a/packages/climate.yaml +++ b/packages/climate.yaml @@ -179,47 +179,115 @@ input_number: automation: - id: '1655415573165' - alias: Emma Bedroom Cooling - description: For keeping the baby’s room at a safe temperature + alias: Emma Bedroom Handling + description: "For scheduled operations in Emma's bedroom" trigger: + - platform: time + at: input_datetime.emma_wakeup + id: emma-wakeup - platform: time at: input_datetime.emma_bedtime + id: emma-bedtime condition: - condition: state entity_id: input_boolean.vacation_mode state: 'off' action: - - choose: - - conditions: + - if: + - condition: trigger + id: emma-wakeup + then: + - service: script.emma_wakeup + - if: + - condition: trigger + id: emma-bedtime + then: + - choose: + - conditions: + - condition: state + entity_id: input_select.scheduled_climate_mode_emma_aircon + state: AC + sequence: + - service: fan.turn_on + target: + entity_id: fan.emma_air_conditioner + - service: script.text_notify + data: + who: "parents" + title: "Emma Climate Schedule" + message: "The air conditioner in Emma's Bedroom has been activated." + - conditions: + - condition: state + entity_id: input_select.scheduled_climate_mode_emma_aircon + state: White Noise + sequence: + - service: input_boolean.turn_on + target: + entity_id: input_boolean.white_noise_emma_bedroom + - service: script.text_notify + data: + who: "parents" + title: "Emma Climate Schedule" + message: "White noise has been activated in Emma's Bedroom." + default: + - service: script.text_notify + data: + who: "parents" + title: "Emma Climate Schedule" + message: "No option selected for Emma's climate mode. No devices will be activated." + mode: restart + +script: + emma_wakeup: + alias: "Emma Wakeup" + mode: restart + sequence: + - if: - condition: state - entity_id: input_select.scheduled_climate_mode_emma_aircon - state: AC - sequence: - - service: fan.turn_on + entity_id: input_boolean.early_night_mode + state: 'on' + then: + - service: input_select.select_option + target: + entity_id: input_select.emma_bedroom_scenes + data: + option: Nightlight + - service: light.turn_on + target: + entity_id: light.hallway_overhead + - delay: + seconds: 2 + - service: input_select.select_option + target: + entity_id: + - input_select.upstairs_hallway_scenes + - input_select.master_bedroom_scenes + data: + option: Adaptive + else: + - service: light.turn_on + target: + entity_id: light.emma_bedroom_light + - service: input_select.select_option + target: + entity_id: input_select.emma_bedroom_scenes + data: + option: Adaptive + - delay: + minutes: 5 + - service: input_boolean.turn_off + target: + entity_id: input_boolean.white_noise_emma_bedroom + - if: + - condition: template + value_template: >- + {% set ct = ((now().hour * 60 + now().minute) * 60 ) %} + {% if is_state('input_boolean.hot_day','off') and ct < state_attr('input_datetime.emma_bedtime','timestamp') and ct >= state_attr('input_datetime.emma_wakeup','timestamp') %} + true + {% else %} + false + {% endif %} + then: + - service: fan.turn_off target: entity_id: fan.emma_air_conditioner - - service: script.text_notify - data: - who: "parents" - title: "Emma Climate Schedule" - message: "The air conditioner in Emma's Bedroom has been activated." - - conditions: - - condition: state - entity_id: input_select.scheduled_climate_mode_emma_aircon - state: White Noise - sequence: - - service: input_boolean.turn_on - target: - entity_id: input_boolean.white_noise_emma_bedroom - - service: script.text_notify - data: - who: "parents" - title: "Emma Climate Schedule" - message: "White noise has been activated in Emma's Bedroom." - default: - - service: script.text_notify - data: - who: "parents" - title: "Emma Climate Schedule" - message: "No option selected for Emma's climate mode. No devices will be activated." - mode: restart diff --git a/packages/lighting_and_scenes.yaml b/packages/lighting_and_scenes.yaml index 1e555d7..18907e8 100644 --- a/packages/lighting_and_scenes.yaml +++ b/packages/lighting_and_scenes.yaml @@ -561,48 +561,6 @@ automation: seconds: 2 # The delay is to prevent the boolean from re-running the automation if the lights were turned on manually -script: - emma_wakeup: - alias: "Emma Wakeup" - mode: restart - sequence: - - if: - - condition: state - entity_id: input_boolean.early_night_mode - state: 'on' - then: - - service: input_select.select_option - target: - entity_id: input_select.emma_bedroom_scenes - data: - option: Nightlight - - service: light.turn_on - target: - entity_id: light.hallway_overhead - - delay: - seconds: 2 - - service: input_select.select_option - target: - entity_id: - - input_select.upstairs_hallway_scenes - - input_select.master_bedroom_scenes - data: - option: Adaptive - else: - - service: light.turn_on - target: - entity_id: light.emma_bedroom_light - - service: input_select.select_option - target: - entity_id: input_select.emma_bedroom_scenes - data: - option: Adaptive - - delay: - minutes: 5 - - service: input_boolean.turn_off - target: - entity_id: input_boolean.white_noise_emma_bedroom - scene: - name: Adaptive in Living Room icon: mdi:palette