Made datetime increment macro capable of using minutes

This commit is contained in:
2023-05-04 01:10:15 -04:00
parent 8c2863b594
commit 48186bb6c2
2 changed files with 7 additions and 3 deletions

View File

@ -38,8 +38,12 @@
{{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }}
{% endmacro %}
{% macro increment_datetime_from_now(hours) %}
{% macro increment_datetime_from_now(hours,minutes) %}
{% if minutes is defined %}
{{ (as_timestamp(now()) + (((hours * 60) * 60) + (minutes * 60))) | int | timestamp_custom('%Y-%m-%d %H:%M:%S') }}
{% else %}
{{ (as_timestamp(now()) + ((hours* 60) * 60)) | int | timestamp_custom('%Y-%m-%d %H:%M:%S') }}
{% endif %}
{% endmacro %}
{% macro ct() %}

View File

@ -465,7 +465,7 @@ script:
data:
datetime: >
{% from 'time.jinja' import increment_datetime_from_now %}
{{ increment_datetime_from_now(0.5) }}
{{ increment_datetime_from_now(0,30) }}
- service: script.text_notify
data:
who: parents
@ -553,7 +553,7 @@ script:
data:
datetime: >
{% from 'time.jinja' import increment_datetime_from_now %}
{{ increment_datetime_from_now(0.5) }}
{{ increment_datetime_from_now(0,30) }}
- service: script.text_notify
data:
who: parents