From e5b86620304d689df92eeda535ae64907232f840 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Fri, 5 May 2023 14:14:09 -0400 Subject: [PATCH] set_datetime now accepts seconds --- custom_templates/time.jinja | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_templates/time.jinja b/custom_templates/time.jinja index 8e05a25..bec8381 100644 --- a/custom_templates/time.jinja +++ b/custom_templates/time.jinja @@ -38,8 +38,10 @@ {{ as_timestamp(strptime(state_attr(calendar,start_or_end), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }} {% endmacro %} -{% macro set_datetime(hours,minutes) %} -{% if minutes is defined %} +{% macro set_datetime(hours,minutes,seconds) %} +{% if seconds is defined %} +{{ (as_timestamp(now()) + ((((hours * 60) * 60) + (minutes * 60))) + seconds) | int | timestamp_custom('%Y-%m-%d %H:%M:%S') }} +{% elif 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') }}