Tweak detection of E's sleeping

This commit is contained in:
2023-07-25 12:54:46 -04:00
parent 0fb1706155
commit fd0fb93903
2 changed files with 12 additions and 9 deletions

View File

@ -479,9 +479,9 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% set day = now().strftime("%-d") %} {% set day = now().strftime("%-d") %}
{% set asleep_day = asleep | timestamp_custom("%-d") %} {% set asleep_day = asleep | timestamp_custom("%-d") %}
{% set wakeup_day = wakeup | 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_day == day)) %} {% 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','withdate') | trim }}. 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','withdate') | trim }}.
{% 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') %} {% 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','withdate') | trim }}. She has been asleep for {{ custom_time('input_datetime.emma_down_for_nap','hour,minute') }}. Emma is down for nap. She was put down at around {{ input_datetime_read('input_datetime.emma_down_for_nap','withdate') | trim }}. She has been asleep for {{ custom_time('input_datetime.emma_down_for_nap','hour,minute') }}.
{% elif is_state('input_boolean.emma_sleeping','on') %} {% elif is_state('input_boolean.emma_sleeping','on') %}
{% if is_state('binary_sensor.early_night_mode','on') %} {% if is_state('binary_sensor.early_night_mode','on') %}
@ -500,7 +500,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% set day = now().strftime("%-d") %} {% set day = now().strftime("%-d") %}
{% set asleep_day = asleep | timestamp_custom("%-d") %} {% set asleep_day = asleep | timestamp_custom("%-d") %}
{% set wakeup_day = wakeup | 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_day == day)) %} {% 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') }} 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)) %} {% 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)) %}
Emma has awoken for the day at {{ clock('12-hr') }} Emma has awoken for the day at {{ clock('12-hr') }}

View File

@ -277,7 +277,7 @@ automation:
state: 'on' state: 'on'
- condition: time - condition: time
after: "23:00:00" after: "23:00:00"
before: "04:00:00" before: "07:00:00"
sequence: sequence:
- service: timer.start - service: timer.start
target: target:
@ -292,7 +292,6 @@ automation:
target: target:
entity_id: entity_id:
- timer.emma_bedtime_update - timer.emma_bedtime_update
- timer.emma_naptime_update
- if: - if:
- condition: state - condition: state
entity_id: input_boolean.emma_sleeping entity_id: input_boolean.emma_sleeping
@ -307,7 +306,7 @@ automation:
state: 'off' state: 'off'
- condition: time - condition: time
before: "23:00:00" before: "23:00:00"
after: "04:00:00" after: "07:00:00"
sequence: sequence:
- service: input_datetime.set_datetime - service: input_datetime.set_datetime
target: target:
@ -322,7 +321,7 @@ automation:
state: 'on' state: 'on'
- condition: time - condition: time
after: "23:00:00" after: "23:00:00"
before: "04:00:00" before: "07:00:00"
sequence: sequence:
- service: input_datetime.set_datetime - service: input_datetime.set_datetime
target: target:
@ -339,7 +338,9 @@ automation:
- condition: state - condition: state
entity_id: light.emma_bedroom_light entity_id: light.emma_bedroom_light
state: 'on' state: 'on'
then: then:
- delay:
seconds: 1
- service: timer.start - service: timer.start
target: target:
entity_id: timer.emma_naptime_update entity_id: timer.emma_naptime_update
@ -359,7 +360,9 @@ automation:
- condition: state - condition: state
entity_id: light.emma_bedroom_light entity_id: light.emma_bedroom_light
state: 'on' state: 'on'
then: then:
- delay:
seconds: 1
- service: timer.start - service: timer.start
target: target:
entity_id: timer.emma_bedtime_update entity_id: timer.emma_bedtime_update