Consolidate reading input datetimes into one macro

This commit is contained in:
2023-06-02 14:06:28 -04:00
parent 5e2bd6d80d
commit 6b29933088
8 changed files with 53 additions and 51 deletions

View File

@ -16,12 +16,16 @@
{{ now().strftime('%Y-%m-%d') }}
{% endmacro %}
{% macro input_datetime_12hr(entity) %}
{% macro input_datetime_read(entity,type) %}
{% if type is defined %}
{% if type == 'withdate' %}
{{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p') }}
{% elif type == 'nodate' %}
{{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p', False) }}
{% endif %}
{% else %}
{{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p', False) }}
{% endmacro %}
{% macro input_datetime_12hr_with_date(entity) %}
{{ state_attr(entity,'timestamp') | int | timestamp_custom('%-I:%M %p') }}
{% endif %}
{% endmacro %}
{% macro current_date_readout() %}