From b6b4477fdbd5f07e660c3e73184d5e98f4753c4c Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 18 Sep 2023 21:10:17 -0400 Subject: [PATCH] Only reset cough meds notification on wakeup if it's been 4 hours #130 --- packages/emmalynn.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/emmalynn.yaml b/packages/emmalynn.yaml index 337eeed..65100ab 100644 --- a/packages/emmalynn.yaml +++ b/packages/emmalynn.yaml @@ -1053,9 +1053,12 @@ script: - variables: brightness: "{{ state_attr('switch.adaptive_lighting_emma_bedroom','brightness_pct') | int }}" - if: - - condition: state - entity_id: input_boolean.emma_cough_meds_active - state: 'on' + - condition: template + value_template: > + {% set current = as_timestamp(now()) | int %} + {% set lastdose = state_attr('input_datetime.emma_cough_meds','timestamp') | int %} + {% set diff = current - lastdose %} + {{ is_state('input_boolean.emma_cough_meds_active','on') and diff > 14400 }} then: - service: input_datetime.set_datetime target: