Several improvements to E's bedtime scheduling

This commit is contained in:
2024-05-23 17:07:23 -04:00
parent d29acd787b
commit ee53a35965
3 changed files with 59 additions and 33 deletions

View File

@ -110,7 +110,7 @@ automation:
at: '04:00:00'
id: morning-scheduling
- platform: time
at: '17:00:00'
at: '17:05:00'
id: evening-scheduling
action:
- choose:
@ -710,7 +710,17 @@ script:
- service: input_datetime.set_datetime
entity_id: input_datetime.emma_bedtime
data:
time: 02:00
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 %}
- if:
- condition: state
entity_id: input_boolean.emma_bedroom_climate_override
@ -737,12 +747,13 @@ script:
time: >
{% set high = states('sensor.todays_high_temp') | int %}
{% set low = states('sensor.overnight_lowest_temperature') | int %}
{% set bedtime = state_attr('input_datetime.emma_bedtime','timestamp') | int %}
{% if is_state('input_boolean.hot_day','on') %}
23:00
{{ (bedtime - 7200) | timestamp_custom('%H:%M',false) }}
{% elif high >= 80 or low >= 60 %}
00:00
{{ (bedtime - 5400) | timestamp_custom('%H:%M',false) }}
{% else %}
01:00
{{ (bedtime - 3600) | timestamp_custom('%H:%M',false) }}
{% endif %}
- service: input_boolean.turn_on
target: