From 91d6a322748352eb9e840702f472c999d740acb6 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 11 Nov 2024 20:13:33 -0500 Subject: [PATCH] Remove Emma naptime entities and related code --- automations.yaml | 5 - custom_templates/status.jinja | 24 +--- packages/climate.yaml | 14 --- packages/emmalynn.yaml | 221 ++++------------------------------ packages/scheduling.yaml | 16 +-- scripts.yaml | 195 ++++++++++-------------------- 6 files changed, 90 insertions(+), 385 deletions(-) diff --git a/automations.yaml b/automations.yaml index b69b020..bae2a45 100644 --- a/automations.yaml +++ b/automations.yaml @@ -5132,11 +5132,6 @@ - input_number.emma_bedtime_hours id: hours-update alias: Hours Update - - platform: state - entity_id: - - input_datetime.emma_up_from_nap - id: up-from-nap - alias: Up From Nap condition: - condition: state entity_id: input_boolean.emma_sleeping diff --git a/custom_templates/status.jinja b/custom_templates/status.jinja index a0bbb9e..43f5b34 100644 --- a/custom_templates/status.jinja +++ b/custom_templates/status.jinja @@ -591,38 +591,20 @@ {% endmacro %} {% macro emma_sleep(type,method) %} -{% set asleep = state_attr('input_datetime.emma_down_for_nap','timestamp') | int %} -{% set wakeup = state_attr('input_datetime.emma_up_from_nap','timestamp') | int %} -{% set day = now().strftime("%-d") %} -{% set asleep_day = asleep | timestamp_custom("%-d") %} -{% set wakeup_day = wakeup | timestamp_custom("%-d") %} -{% if is_state('input_boolean.emma_sleeping','off') and (is_state('input_boolean.emma_has_napped','on') or ((asleep_day == day) and (wakeup > asleep))) %} - Emma napped today for {{ custom_time_between('input_datetime.emma_down_for_nap','input_datetime.emma_up_from_nap','hour,minute') }}. She was retrieved from her room at around {{ input_datetime_read('input_datetime.emma_up_from_nap') | trim }}. -{% elif (is_state('input_boolean.emma_has_napped','off') and (((asleep_day == day) and (wakeup_day != day)) or wakeup < asleep)) and is_state('input_boolean.emma_sleeping','on') %} - Emma is down for nap. She was put down at around {{ input_datetime_read('input_datetime.emma_down_for_nap') | trim }}. She has been asleep for {{ custom_time('input_datetime.emma_down_for_nap','hour,minute') }}. -{% elif is_state('input_boolean.emma_sleeping','on') %} +{% if is_state('input_boolean.emma_sleeping','on') %} {% if is_state('binary_sensor.early_night_mode','on') %} Emma is asleep for the night. She went to bed at {{ input_datetime_read('input_datetime.emma_asleep_at') | trim }}. {% else %} Emma has not yet awoken for the day. She went to bed at {{ input_datetime_read('input_datetime.emma_asleep_at') | trim }}. Her wakeup time is scheduled for {{ input_datetime_read('input_datetime.emma_wakeup') | trim }}. {% endif %} {% else %} - Emma is awake, and does not appear to have napped yet. She woke up at {{ input_datetime_read('input_datetime.emma_awake_at') | trim }}. + Emma is awake. She woke up at {{ input_datetime_read('input_datetime.emma_awake_at') | trim }}. {% endif %} {% endmacro %} {% macro emma_sleep_notification(type,method) %} -{% set asleep = state_attr('input_datetime.emma_down_for_nap','timestamp') | int %} -{% set wakeup = state_attr('input_datetime.emma_up_from_nap','timestamp') | int %} -{% set day = now().strftime("%-d") %} -{% set asleep_day = asleep | timestamp_custom("%-d") %} -{% set wakeup_day = wakeup | timestamp_custom("%-d") %} -{% if is_state('input_boolean.emma_sleeping','off') and (is_state('input_boolean.emma_has_napped','on') or ((asleep_day == day) and (wakeup > asleep))) %} - Emma has awoken. She napped today for {{ custom_time_between('input_datetime.emma_down_for_nap','input_datetime.emma_up_from_nap','hour,minute') }}. She was retrieved from her room at {{ clock('12-hr') }} -{% elif is_state('input_boolean.emma_has_napped','off') and is_state('input_boolean.emma_sleeping','off') and ((asleep_day != day) or (wakeup_day != day)) %} +{% if is_state('input_boolean.emma_sleeping','off') %} Emma has awoken for the day at {{ clock('12-hr') }} -{% elif is_state('input_boolean.emma_has_napped','off') and ((asleep_day == day) and (wakeup_day != day)) and is_state('input_boolean.emma_sleeping','on') %} - Emma is being put down for nap. She was put down at {{ clock('12-hr') }} {% elif is_state('input_boolean.emma_sleeping','on') %} Emma is asleep for the night (or at least, her sleep switch is active) at {{ clock('12-hr') }} {% else %} diff --git a/packages/climate.yaml b/packages/climate.yaml index f35562e..2c5059a 100644 --- a/packages/climate.yaml +++ b/packages/climate.yaml @@ -238,13 +238,6 @@ input_select: - White Noise - N/A icon: mdi:home-thermometer - naptime_climate_mode_emma_aircon: - name: Naptime Climate Mode - Emma Aircon - options: - - AC - - White Noise - - N/A - icon: mdi:home-thermometer scheduled_climate_mode_kallen_fan: name: Scheduled Climate Mode - Kallen Fan options: @@ -310,13 +303,6 @@ input_number: step: 1 unit_of_measurement: °F icon: mdi:thermometer - emma_naptime_aircon_threshold: - name: Emma Naptime Aircon Threshold - min: 40 - max: 80 - step: 1 - unit_of_measurement: °F - icon: mdi:thermometer kallen_fan_threshold: name: Kallen Fan Threshold min: 40 diff --git a/packages/emmalynn.yaml b/packages/emmalynn.yaml index 8170968..400da73 100644 --- a/packages/emmalynn.yaml +++ b/packages/emmalynn.yaml @@ -4,9 +4,6 @@ input_boolean: emma_sleeping: name: Emma Sleeping icon: mdi:sleep - emma_has_napped: - name: Emma Has Napped - icon: mdi:check emma_alternating_meds_active: name: Emma Alternating Meds Active icon: mdi:medication @@ -71,16 +68,6 @@ input_datetime: has_date: false has_time: true icon: mdi:weather-sunset-up - emma_down_for_nap: - name: Emma Down For Nap - has_date: true - has_time: true - icon: mdi:sleep - emma_up_from_nap: - name: Emma Up From Nap - has_date: true - has_time: true - icon: mdi:eye # These are for use in remembering which medications she has had when she is sick, and when to safely give them again emma_ibuprofen: name: Emma Ibuprofen @@ -145,31 +132,13 @@ automation: id: sleep-on sequence: - service: script.emma_sleep - - if: - - condition: and - conditions: - - condition: state - entity_id: input_boolean.emma_has_napped - state: 'off' - - condition: time - before: "23:00:00" - after: "07:00:00" - then: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.emma_down_for_nap - data: - datetime: > - {% from 'time.jinja' import current_time %} - {{ current_time('datetime',24) }} - else: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.emma_asleep_at - data: - time: > - {% from 'time.jinja' import current_time %} - {{ current_time('time',24) }} + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.emma_asleep_at + data: + time: > + {% from 'time.jinja' import current_time %} + {{ current_time('time',24) }} - delay: seconds: 1 - service: script.text_notify @@ -186,28 +155,6 @@ automation: - condition: trigger id: sleep-off sequence: - - if: - - condition: and - conditions: - - condition: state - entity_id: input_boolean.emma_has_napped - state: 'off' - - condition: time - after: "18:00:00" - before: "01:00:00" - then: - - service: input_boolean.turn_on - target: - entity_id: input_boolean.emma_has_napped - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.emma_up_from_nap - data: - datetime: > - {% from 'time.jinja' import current_time %} - {{ current_time('datetime',24) }} - - delay: - seconds: 1 - if: - condition: state entity_id: input_boolean.emma_scheduling_evening_ran @@ -260,41 +207,6 @@ automation: target: entity_id: input_boolean.emma_sleeping - - id: e44c2ab8-00cd-40ab-9b42-824511ac20aa - alias: Emma Naptime Climate - description: Sets the climate mode for when Emma goes down for nap - mode: restart - trigger: - - platform: time_pattern - minutes: "/5" - - platform: state - entity_id: input_number.emma_naptime_aircon_threshold - - platform: state - entity_id: input_boolean.hot_day - condition: - - condition: state - entity_id: input_boolean.emma_sleeping - state: 'off' - - condition: state - entity_id: input_boolean.emma_bedroom_climate_override - state: 'off' - - condition: state - entity_id: input_boolean.emma_bedroom_aircon_installed - state: 'on' - action: - - service: input_select.select_option - target: - entity_id: input_select.naptime_climate_mode_emma_aircon - data: - option: > - {% set temp = state_attr('weather.iron_nerd_weather_station','temperature') | int %} - {% set threshold = states('input_number.emma_naptime_aircon_threshold') | int %} - {% if (temp >= threshold) or is_state('input_boolean.hot_day','on') %} - AC - {% else %} - White Noise - {% endif %} - - id: 5b45eeb2-171e-4bac-825b-8ac7aa672dab alias: Emma Asleep Update description: Attempt to make readouts of when Emma went to bed more accurate @@ -310,11 +222,6 @@ automation: event_data: entity_id: timer.emma_bedtime_update id: bedtime-timer-finished - - platform: event - event_type: timer.finished - event_data: - entity_id: timer.emma_naptime_update - id: naptime-timer-finished - platform: state entity_id: light.emma_bedroom_light to: 'off' @@ -325,37 +232,11 @@ automation: - condition: trigger id: initial sequence: - - choose: - - conditions: - - condition: and - conditions: - - condition: state - entity_id: input_boolean.emma_has_napped - state: 'off' - - condition: time - before: "23:00:00" - after: "07:00:00" - sequence: - - service: timer.start - target: - entity_id: timer.emma_naptime_update - data: - duration: "01:00:00" - - conditions: - - condition: or - conditions: - - condition: state - entity_id: input_boolean.emma_has_napped - state: 'on' - - condition: time - after: "23:00:00" - before: "07:00:00" - sequence: - - service: timer.start - target: - entity_id: timer.emma_bedtime_update - data: - duration: "01:00:00" + - service: timer.start + target: + entity_id: timer.emma_bedtime_update + data: + duration: "01:00:00" - conditions: - condition: trigger id: lights-off @@ -364,71 +245,18 @@ automation: target: entity_id: - timer.emma_bedtime_update - - timer.emma_naptime_update - if: - condition: state entity_id: input_boolean.emma_sleeping state: 'on' then: - - choose: - - conditions: - - condition: and - conditions: - - condition: state - entity_id: input_boolean.emma_has_napped - state: 'off' - - condition: time - before: "23:00:00" - after: "07:00:00" - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.emma_down_for_nap - data: - datetime: > - {% from 'time.jinja' import current_time %} - {{ current_time('datetime',24) }} - - conditions: - - condition: or - conditions: - - condition: state - entity_id: input_boolean.emma_has_napped - state: 'on' - - condition: time - after: "23:00:00" - before: "07:00:00" - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.emma_asleep_at - data: - time: > - {% from 'time.jinja' import current_time %} - {{ current_time('time',24) }} - - conditions: - - condition: trigger - id: naptime-timer-finished - sequence: - - if: - - condition: state - entity_id: light.emma_bedroom_light - state: 'on' - then: - - delay: - seconds: 1 - - service: timer.start - target: - entity_id: timer.emma_naptime_update - data: - duration: "01:00:00" - else: - service: input_datetime.set_datetime target: - entity_id: input_datetime.emma_down_for_nap + entity_id: input_datetime.emma_asleep_at data: - datetime: > + time: > {% from 'time.jinja' import current_time %} - {{ current_time('datetime',24) }} + {{ current_time('time',24) }} - conditions: - condition: trigger id: bedtime-timer-finished @@ -986,18 +814,13 @@ script: who: basement type: normal message: Emma has awoken, so it is time to make your way upstairs now - - if: - - condition: time - before: "18:00:00" - after: "07:00:00" - then: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.emma_awake_at - data: - time: > - {% from 'time.jinja' import current_time %} - {{ current_time('time',24) }} + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.emma_awake_at + data: + time: > + {% from 'time.jinja' import current_time %} + {{ current_time('time',24) }} - service: switch.turn_off target: entity_id: diff --git a/packages/scheduling.yaml b/packages/scheduling.yaml index 21c6c16..509214f 100644 --- a/packages/scheduling.yaml +++ b/packages/scheduling.yaml @@ -697,9 +697,6 @@ script: emma_bedroom_scheduling_morning: alias: 'Emma Bedroom Scheduling Morning' sequence: - - service: input_boolean.turn_off - target: - entity_id: input_boolean.emma_has_napped - if: - condition: state entity_id: input_boolean.emma_wakeup_override @@ -709,11 +706,6 @@ script: entity_id: input_datetime.emma_wakeup data: time: "{{ states('input_datetime.master_bedroom_wakeup') }}" - - service: input_select.select_option - target: - entity_id: input_select.naptime_climate_mode_emma_aircon - data: - option: "{{ states('input_select.scheduled_climate_mode_emma_aircon') }}" - service: input_boolean.turn_on target: entity_id: input_boolean.emma_scheduling_morning_ran @@ -731,15 +723,9 @@ script: data: time: > {% set awake = state_attr('input_datetime.emma_awake_at','timestamp') | int %} - {% set up_from_nap = state_attr('input_datetime.emma_up_from_nap','timestamp') | int %} {% set hours = states('input_number.emma_bedtime_hours') | int %} {% set math = (hours * 60) * 60 %} - {% set math_nap = 14400 %} - {% if is_state('input_boolean.emma_has_napped','on') %} - {{ (up_from_nap + math_nap) | timestamp_custom('%H:%M') }} - {% else %} - {{ (awake + math) | timestamp_custom('%H:%M',false) }} - {% endif %} + {{ (awake + math) | timestamp_custom('%H:%M',false) }} - if: - condition: state entity_id: input_boolean.emma_bedroom_climate_override diff --git a/scripts.yaml b/scripts.yaml index ab733c7..15f1f03 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -2830,162 +2830,95 @@ emma_sleep: after: 04:00:00 before: '17:00:00' then: - - service: script.emma_bedroom_scheduling_evening - data: {} + - data: {} + action: script.emma_bedroom_scheduling_evening alias: Run scheduling if it hasn't already been run - - service: script.turn_off - target: + - target: entity_id: - script.emma_ibuprofen - script.emma_tylenol - script.emma_cough_meds data: {} alias: Reset med trackers - - service: light.turn_on - target: + action: script.turn_off + - target: entity_id: - light.emma_bedroom_light data: {} alias: Turn on light + action: light.turn_on - delay: seconds: 1 - - service: input_select.select_option - target: + - target: entity_id: - input_select.emma_bedroom_scenes data: option: Adaptive alias: Set lights to adaptive - - alias: Climate Controls + action: input_select.select_option + - alias: Select climate mode 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 + - alias: AC condition: and conditions: - condition: state - entity_id: input_boolean.emma_has_napped + 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: Emma has not napped - - condition: time - before: '23:00:00' - after: 04:00:00 - alias: It is not bedtime + alias: Air conditioner is not already on 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 + - target: + entity_id: fan.emma_air_conditioner + data: {} + alias: Turn on air conditioner + action: fan.turn_on + - 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 + action: script.text_notify + - 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: + - target: + entity_id: input_boolean.white_noise_emma_bedroom + data: {} + alias: Turn on white noise + action: input_boolean.turn_on + - 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 + action: script.text_notify + default: + - 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 + action: script.text_notify icon: mdi:lightbulb-night mode: restart tina_morning_meds: