Macro updates

This commit is contained in:
2023-05-12 14:22:00 -04:00
parent af26105994
commit e30f1646c7
4 changed files with 19 additions and 12 deletions

View File

@ -1,5 +1,5 @@
{% macro emma_sleep() %} {% macro emma_sleep() %}
{% from 'time.jinja' import input_datetime_12hr_with_date %} {% from 'time.jinja' import input_datetime_12hr_with_date, input_datetime_12hr %}
{% from 'easy_time.jinja' import custom_time, custom_time_between %} {% from 'easy_time.jinja' import custom_time, custom_time_between %}
{% set asleep = state_attr('input_datetime.emma_down_for_nap','timestamp') | int %} {% 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 wakeup = state_attr('input_datetime.emma_up_from_nap','timestamp') | int %}
@ -17,7 +17,7 @@
Emma has not yet awoken for the day. Emma has not yet awoken for the day.
{% endif %} {% endif %}
{% else %} {% else %}
Emma is awake, and does not appear to have napped yet today. Emma is awake, and does not appear to have napped yet. She woke up at {{ input_datetime_12hr('input_datetime.emma_wakeup') }} today.
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
@ -54,8 +54,6 @@
'This is absolutely essential, and I will remind him to do it at', 'This is absolutely essential, and I will remind him to do it at',
'Since nobody including Tony himself likes him without his meds, I will remind him at', 'Since nobody including Tony himself likes him without his meds, I will remind him at',
] | random }} {{ input_datetime_12hr('input_datetime.tony_morning_meds_notify') }} today. ] | random }} {{ input_datetime_12hr('input_datetime.tony_morning_meds_notify') }} today.
{% else %}
There are no further notifications scheduled for him today.
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
@ -95,8 +93,6 @@
'Rest assured that I will pester him mercilessly about this, starting at', 'Rest assured that I will pester him mercilessly about this, starting at',
'This is absolutely essential, and I will remind him to do it at', 'This is absolutely essential, and I will remind him to do it at',
] | random }} {{ input_datetime_12hr('input_datetime.kallen_morning_meds_notify') }} today. ] | random }} {{ input_datetime_12hr('input_datetime.kallen_morning_meds_notify') }} today.
{% else %}
There are no further notifications scheduled for him today.
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@ -2,12 +2,12 @@
{{ (states(input_number)) | int * 60 }} {{ (states(input_number)) | int * 60 }}
{% endmacro %} {% endmacro %}
{% macro current_time_12hr() %} {% macro current_time(hr) %}
{% if hr == 12 %}
{{ now().strftime('%-I:%M %p') }} {{ now().strftime('%-I:%M %p') }}
{% endmacro %} {% elif hr == 24 %}
{% macro current_time_24hr() %}
{{ now().strftime('%H:%M') }} {{ now().strftime('%H:%M') }}
{% endif %}
{% endmacro %} {% endmacro %}
{% macro current_date_input() %} {% macro current_date_input() %}

View File

@ -682,6 +682,17 @@ script:
# Lighting # Lighting
- variables: - variables:
brightness: "{{ state_attr('switch.adaptive_lighting_emma_bedroom','brightness_pct') }}" brightness: "{{ state_attr('switch.adaptive_lighting_emma_bedroom','brightness_pct') }}"
- if:
- condition: template
value_template: "{{ is_state('binary_sensor.morning','on') or is_state('binary_sensor.midday','on') }}"
then:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.emma_wakeup
data:
time: >
{% from 'time.jinja' import current_time %}
{{ current_time(24) }}
- if: - if:
- condition: state - condition: state
entity_id: binary_sensor.early_night_mode entity_id: binary_sensor.early_night_mode

View File

@ -1,7 +1,7 @@
> >
{# Kallen Morning Briefing #} {# Kallen Morning Briefing #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'time.jinja' import current_time_12hr, current_date_readout, input_datetime_12hr %} {% from 'time.jinja' import current_time, current_date_readout, input_datetime_12hr %}
{% from 'speech.jinja' import dadjoke, inspirational_quote %} {% from 'speech.jinja' import dadjoke, inspirational_quote %}
{% from 'easy_time.jinja' import count_the_day, custom_time %} {% from 'easy_time.jinja' import count_the_day, custom_time %}
<p> <p>
@ -10,7 +10,7 @@
{% if is_state('binary_sensor.morning','on') %} {% if is_state('binary_sensor.morning','on') %}
<s>Today is {{ current_date_readout() }}.</s> <s>Today is {{ current_date_readout() }}.</s>
{% else %} {% else %}
<s>It is {{ current_time_12hr() }}.</s> <s>It is {{ current_time(12) }}.</s>
{% endif %} {% endif %}
{% if is_state('sensor.anniversary_kallen_s_birthday', '0') %} {% if is_state('sensor.anniversary_kallen_s_birthday', '0') %}