From 48186bb6c27dc9c65a601b5929b4b13034cf2fb7 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Thu, 4 May 2023 01:10:15 -0400 Subject: [PATCH] Made datetime increment macro capable of using minutes --- custom_templates/time.jinja | 6 +++++- packages/emmalynn.yaml | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/custom_templates/time.jinja b/custom_templates/time.jinja index dda51c7..bd1cad3 100644 --- a/custom_templates/time.jinja +++ b/custom_templates/time.jinja @@ -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() %} diff --git a/packages/emmalynn.yaml b/packages/emmalynn.yaml index e4d5c93..0d16419 100644 --- a/packages/emmalynn.yaml +++ b/packages/emmalynn.yaml @@ -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