From 410ce22313b98af7597ec1232fa76eacd4efb9a6 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Thu, 25 Jul 2024 17:16:40 -0400 Subject: [PATCH] Change logic for setting and resetting notification times #205 --- automations.yaml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/automations.yaml b/automations.yaml index f256fea..c46d186 100644 --- a/automations.yaml +++ b/automations.yaml @@ -2514,6 +2514,29 @@ ' alias: Set time to start notifying for morning meds + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.tony_afternoon_meds_notify + data: + datetime: '{% from ''time.jinja'' import set_datetime %} {% set morning + = state_attr(''input_datetime.tony_morning_meds_notify'',''timestamp'') + | int %} {% set interval = states(''input_number.tony_afternoon_meds_interval'') + | int %} {% set math = (interval * 60) * 60 %} {% set newtime = morning + + math %} {{ newtime | timestamp_custom(''%Y-%m-%d %H:%M:%S'') }} + + ' + alias: Set time to start notifying for afternoon meds + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.tony_night_meds_notify + data: + date: '{% from ''time.jinja'' import set_datetime %} {% set current = as_timestamp(now()) + %} {% set math = (24 * 60) * 60 %} {% set newtime = current + math %} + {{ newtime | timestamp_custom(''%Y-%m-%d'') }} + + ' + time: 04:00:00 + alias: Set time to start notifying for night meds - alias: Turn off all meds taken service: input_boolean.turn_off metadata: {} @@ -2542,10 +2565,11 @@ target: entity_id: input_datetime.tony_afternoon_meds_notify data: - time: '{% from ''time.jinja'' import set_datetime %} {% set morning = state_attr(''input_datetime.tony_morning_meds_taken'',''timestamp'') + datetime: '{% from ''time.jinja'' import set_datetime %} {% set morning + = state_attr(''input_datetime.tony_morning_meds_taken'',''timestamp'') | int %} {% set interval = states(''input_number.tony_afternoon_meds_interval'') | int %} {% set math = (interval * 60) * 60 %} {% set newtime = morning - + math %} {{ newtime | timestamp_custom(''%H:%M'') }} + + math %} {{ newtime | timestamp_custom(''%Y-%m-%d %H:%M:%S'') }} ' alias: Update notification