Change logic for setting and resetting notification times

#205
This commit is contained in:
2024-07-25 17:16:40 -04:00
parent 4dbdb87e8c
commit a22a830148

View File

@ -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