From c3239ddec7963b5b0ccb0eb81adb8eacada55776 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Wed, 1 May 2024 20:30:46 -0400 Subject: [PATCH] Separate E's bedtime and cooling schedules --- automations.yaml | 32 +++++ packages/emmalynn.yaml | 153 ++--------------------- packages/scheduling.yaml | 25 ++-- scripts.yaml | 166 +++++++++++++++++++++++++ templates/speech/nightly_briefing.yaml | 2 +- 5 files changed, 227 insertions(+), 151 deletions(-) diff --git a/automations.yaml b/automations.yaml index 0c731ce..4cfe14b 100644 --- a/automations.yaml +++ b/automations.yaml @@ -4989,3 +4989,35 @@ alias: Update Notification mode: parallel max: 10 +- id: '1714595577405' + alias: Emma Bedroom Cooling + description: '' + trigger: + - platform: time + at: input_datetime.emma_bedroom_cooling + alias: At the scheduled cooling time + condition: + - condition: state + entity_id: input_boolean.emma_sleeping + state: 'off' + alias: If Emma is not already asleep + - condition: state + entity_id: input_select.scheduled_climate_mode_emma_aircon + state: AC + alias: If the AC is scheduled to run + action: + - service: fan.turn_on + metadata: {} + data: {} + target: + entity_id: fan.emma_air_conditioner + alias: Turn on Emma's air conditioner + - service: script.text_notify + data: + who: parents + title: Emma Climate Schedule + message: The air conditioner in Emma's Bedroom has been activated. + type: normal + tag: emma-climate + alias: Send AC notification + mode: restart diff --git a/packages/emmalynn.yaml b/packages/emmalynn.yaml index 8959517..4d25421 100644 --- a/packages/emmalynn.yaml +++ b/packages/emmalynn.yaml @@ -44,6 +44,11 @@ input_datetime: has_date: false has_time: true icon: mdi:fan-auto + emma_bedroom_cooling: + name: Emma Bedroom Cooling + has_date: false + has_time: true + icon: mdi:fan-auto emma_wakeup: name: Emma Wakeup has_date: false @@ -181,7 +186,7 @@ automation: entity_id: input_boolean.emma_has_napped state: 'off' - condition: time - after: "17:00:00" + after: "17:30:00" before: "01:00:00" then: - service: input_datetime.set_datetime @@ -208,6 +213,13 @@ automation: entity_id: input_datetime.emma_bedtime data: time: "{{ (state_attr('input_datetime.emma_up_from_nap','timestamp') + 14400) | timestamp_custom('%H:%M') }}" + - delay: + milliseconds: 500 + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.emma_bedroom_cooling + data: + time: "{{ state_attr('input_datetime.emma_bedtime','timestamp') | int - 3600 }}" - service: input_boolean.turn_on target: entity_id: input_boolean.emma_has_napped @@ -950,145 +962,6 @@ script: {% set interval = states('input_number.emma_cough_meds_interval') | int %} {{ set_datetime(interval) }} - emma_sleep: - alias: 'Emma Sleep' - icon: mdi:lightbulb-night - mode: restart - sequence: - - if: - - condition: time - after: '04:00:00' - before: '16:00:00' - then: - - service: script.emma_bedroom_scheduling_evening -# Meds - - service: script.turn_off - target: - entity_id: - - script.emma_ibuprofen - - script.emma_tylenol - - script.emma_cough_meds -# Lighting - - choose: - - conditions: - - condition: state - entity_id: binary_sensor.early_night_mode - state: 'on' - sequence: - - service: light.turn_on - target: - entity_id: - - light.emma_bedroom_light - - delay: - seconds: 1 - - service: input_select.select_option - target: - entity_id: - - input_select.emma_bedroom_scenes - data: - option: Adaptive - - service: adaptive_lighting.set_manual_control - data: - manual_control: false - entity_id: switch.adaptive_lighting_emma_bedroom - - conditions: - - condition: state - entity_id: binary_sensor.early_night_mode - state: 'off' - sequence: - - service: light.turn_on - target: - entity_id: light.emma_bedroom_light - - delay: - seconds: 1 - - service: input_select.select_option - target: - entity_id: input_select.emma_bedroom_scenes - data: - option: Adaptive - - service: adaptive_lighting.set_manual_control - data: - manual_control: false - entity_id: switch.adaptive_lighting_emma_bedroom -# Climate - - choose: - - conditions: - - condition: or - conditions: - - condition: state - entity_id: input_boolean.emma_has_napped - state: 'on' - - condition: time - after: "23:00:00" - before: "04:00:00" - sequence: - - 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." - type: normal - tag: emma-climate - - 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." - type: normal - tag: emma-climate - 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." - type: normal - tag: emma-climate - - conditions: - - condition: and - conditions: - - condition: state - entity_id: input_boolean.emma_has_napped - state: 'off' - - condition: time - before: "23:00:00" - after: "04:00:00" - sequence: - - choose: - - conditions: - - condition: state - entity_id: input_select.naptime_climate_mode_emma_aircon - state: AC - sequence: - - service: fan.turn_on - target: - entity_id: fan.emma_air_conditioner - - conditions: - - condition: state - entity_id: input_select.naptime_climate_mode_emma_aircon - state: White Noise - sequence: - - service: input_boolean.turn_on - target: - entity_id: input_boolean.white_noise_emma_bedroom - emma_wakeup: alias: 'Emma Wakeup' icon: mdi:weather-sunset-up diff --git a/packages/scheduling.yaml b/packages/scheduling.yaml index 6da363c..13b793b 100644 --- a/packages/scheduling.yaml +++ b/packages/scheduling.yaml @@ -699,16 +699,7 @@ script: - service: input_datetime.set_datetime entity_id: input_datetime.emma_bedtime data: - time: > - {% set high = states('sensor.todays_high_temp') | int %} - {% set low = states('sensor.overnight_lowest_temperature') | int %} - {% if is_state('input_boolean.hot_day','on') %} - 22:00 - {% elif high >= 80 or low >= 60 %} - 23:00 - {% else %} - 23:45 - {% endif %} + time: 02:00 - if: - condition: state entity_id: input_boolean.emma_bedroom_climate_override @@ -728,6 +719,20 @@ script: {% else %} White Noise {% endif %} + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.emma_bedroom_cooling + data: + time: > + {% set high = states('sensor.todays_high_temp') | int %} + {% set low = states('sensor.overnight_lowest_temperature') | int %} + {% if is_state('input_boolean.hot_day','on') %} + 23:00 + {% elif high >= 80 or low >= 60 %} + 00:00 + {% else %} + 01:00 + {% endif %} - service: input_boolean.turn_on target: entity_id: input_boolean.emma_scheduling_evening_ran diff --git a/scripts.yaml b/scripts.yaml index 1bef6c8..d059048 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -3137,3 +3137,169 @@ rabbit_hutch_cleaning: tag: rabbit-hutch-cleaning mode: restart icon: mdi:rabbit +emma_sleep: + alias: Emma Sleep + sequence: + - if: + - condition: time + after: 04:00:00 + before: '17:00:00' + then: + - service: script.emma_bedroom_scheduling_evening + data: {} + alias: Run scheduling if it hasn't already been run + - service: script.turn_off + target: + entity_id: + - script.emma_ibuprofen + - script.emma_tylenol + - script.emma_cough_meds + data: {} + alias: Reset med trackers + - service: light.turn_on + target: + entity_id: + - light.emma_bedroom_light + data: {} + alias: Turn on light + - delay: + seconds: 1 + - service: input_select.select_option + target: + entity_id: + - input_select.emma_bedroom_scenes + data: + option: Adaptive + alias: Set lights to adaptive + - alias: Climate Controls + choose: + - conditions: + - alias: If Emma has napped or it is clearly bedtime + condition: or + conditions: + - condition: state + entity_id: input_boolean.emma_has_napped + state: 'on' + alias: Emma has napped + - condition: time + after: '23:00:00' + before: 04:00:00 + alias: It is definitely bedtime + sequence: + - alias: Select climate mode + choose: + - conditions: + - alias: AC + condition: and + conditions: + - condition: state + entity_id: input_select.scheduled_climate_mode_emma_aircon + state: AC + alias: Scheduled mode is AC + - condition: state + entity_id: fan.emma_air_conditioner + state: 'off' + alias: Air conditioner is not already on + sequence: + - service: fan.turn_on + target: + entity_id: fan.emma_air_conditioner + data: {} + alias: Turn on air conditioner + - service: script.text_notify + data: + who: parents + title: Emma Climate Schedule + message: The air conditioner in Emma's Bedroom has been activated. + type: normal + tag: emma-climate + alias: Send AC notification + - conditions: + - alias: White Noise + condition: and + conditions: + - condition: state + entity_id: input_select.scheduled_climate_mode_emma_aircon + state: White Noise + alias: Scheduled mode is White Noise + - condition: state + entity_id: input_boolean.white_noise_emma_bedroom + state: 'off' + alias: White Noise is not already on + sequence: + - service: input_boolean.turn_on + target: + entity_id: input_boolean.white_noise_emma_bedroom + data: {} + alias: Turn on white noise + - service: script.text_notify + data: + who: parents + title: Emma Climate Schedule + message: White noise has been activated in Emma's Bedroom. + type: normal + tag: emma-climate + alias: Send white noise notification + 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. + type: normal + tag: emma-climate + alias: Send notification that no climate mode is selected + - conditions: + - alias: If Emma has NOT napped and the time is appropriate + condition: and + conditions: + - condition: state + entity_id: input_boolean.emma_has_napped + state: 'off' + alias: Emma has not napped + - condition: time + before: '23:00:00' + after: 04:00:00 + alias: It is not bedtime + sequence: + - alias: Select naptime climate mode + choose: + - conditions: + - alias: AC + condition: and + conditions: + - condition: state + entity_id: input_select.naptime_climate_mode_emma_aircon + state: AC + alias: Scheduled naptime mode is AC + - condition: state + entity_id: fan.emma_air_conditioner + state: 'off' + alias: Air conditioner is not already on + sequence: + - service: fan.turn_on + target: + entity_id: fan.emma_air_conditioner + data: {} + alias: Turn on AC + - conditions: + - alias: White Noise + condition: and + conditions: + - condition: state + entity_id: input_select.naptime_climate_mode_emma_aircon + state: White Noise + alias: Scheduled naptime mode is White Noise + - condition: state + entity_id: input_boolean.white_noise_emma_bedroom + state: 'off' + alias: White Noise is not already on + sequence: + - service: input_boolean.turn_on + target: + entity_id: input_boolean.white_noise_emma_bedroom + data: {} + alias: Turn on white noise + icon: mdi:lightbulb-night + mode: restart diff --git a/templates/speech/nightly_briefing.yaml b/templates/speech/nightly_briefing.yaml index 0694639..3fbf608 100644 --- a/templates/speech/nightly_briefing.yaml +++ b/templates/speech/nightly_briefing.yaml @@ -73,7 +73,7 @@ {% endif %} {% if states('input_select.scheduled_climate_mode_emma_aircon') != 'N/A' %} {% if is_state('input_select.scheduled_climate_mode_emma_aircon','AC') and is_state('fan.emma_air_conditioner','off') %} - "Emma's air conditioner will be activated at {{ input_datetime_read('input_datetime.emma_bedtime') }}. " + "Emma's air conditioner will be activated at {{ input_datetime_read('input_datetime.emma_bedroom_cooling') }}. " {% elif is_state('input_select.scheduled_climate_mode_emma_aircon','White Noise') and is_state('input_boolean.white_noise_emma_bedroom','off') %} "Emma's white noise generator will activate at {{ input_datetime_read('input_datetime.emma_bedtime') }}. " {% endif %}