More time-based Jinja2 custom templates

This commit is contained in:
2023-04-19 20:38:13 -04:00
parent ad2735d414
commit 53c0d4e86a
7 changed files with 45 additions and 28 deletions

View File

@ -6,6 +6,10 @@
{{ now().strftime("%I:%M %p") }}
{% endmacro %}
{% macro input_datetime_12hr(entity) %}
{{ state_attr(entity,'timestamp') | int | timestamp_custom('%I:%M %p', False) }}
{% endmacro %}
{% macro current_date_readout() %}
{{ states('sensor.today_is') }}, {{ as_timestamp(now()) | timestamp_custom('%B %d %Y') }}
{% endmacro %}
@ -16,4 +20,8 @@
{% macro set_time_from_calendar(calendar,start_or_end) %}
{{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%H:%M") }}
{% endmacro %}
{% macro read_time_from_calendar(calendar,start_or_end) %}
{{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }}
{% endmacro %}