From d03c7b12837598db3fbdc11b6a6b68481152fdb7 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 18 Dec 2023 19:09:10 -0500 Subject: [PATCH] Be more annoying about making sure I take my meds. Also, #184 --- automations.yaml | 16 ++++++++++ scripts.yaml | 80 +++++++++++++++++++++++++++++++----------------- 2 files changed, 68 insertions(+), 28 deletions(-) diff --git a/automations.yaml b/automations.yaml index feca1ce..76b0cf9 100644 --- a/automations.yaml +++ b/automations.yaml @@ -2540,6 +2540,11 @@ state: 'off' alias: Morning Notify sequence: + - service: counter.increment + target: + entity_id: counter.tony_morning_meds_reminder_count + data: {} + alias: Increment counter - service: script.turn_on target: entity_id: script.tony_morning_meds @@ -2556,6 +2561,11 @@ entity_id: input_boolean.tony_afternoon_meds_taken state: 'off' sequence: + - service: counter.increment + target: + entity_id: counter.tony_afternoon_meds_reminder_count + data: {} + alias: Increment counter - service: script.tony_afternoon_meds data: {} alias: Run afternoon meds script @@ -2795,6 +2805,12 @@ - input_boolean.tina_morning_meds_taken - input_boolean.tony_afternoon_meds_taken data: {} + - service: counter.reset + target: + entity_id: + - counter.tony_morning_meds_reminder_count + - counter.tony_afternoon_meds_reminder_count + data: {} - conditions: - condition: trigger id: 6am diff --git a/scripts.yaml b/scripts.yaml index 1b35602..dd27c75 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -1871,20 +1871,32 @@ tony_morning_meds: icon: mdi:medication mode: restart sequence: - - service: script.text_notify - data: - who: tony - type: alert - title: Morning Meds - message: You need to take your morning meds - tag: tony-morning-meds - actions: - - action: TONY_MORNING_MEDS_TAKEN - title: Taken - - action: TONY_MORNING_MEDS_SKIPPED - title: Skip - - action: TONY_MORNING_MEDS_ASK_LATER - title: Ask Later + - parallel: + - if: + - condition: numeric_state + entity_id: counter.tony_morning_meds_reminder_count + above: 2 + then: + - service: script.speech_engine + data: + who: common_areas + type: alert + message: Tony, you need to take your morning meds. This is reminder number + {{ states('counter.tony_morning_meds_reminder_count') }} for today. + - service: script.text_notify + data: + who: tony + type: alert + title: Morning Meds + message: You need to take your morning meds + tag: tony-morning-meds + actions: + - action: TONY_MORNING_MEDS_TAKEN + title: Taken + - action: TONY_MORNING_MEDS_SKIPPED + title: Skip + - action: TONY_MORNING_MEDS_ASK_LATER + title: Ask Later - wait_for_trigger: - platform: event event_type: ios.notification_action_fired @@ -2217,20 +2229,32 @@ tony_custom_meds: tony_afternoon_meds: alias: Tony Afternoon Meds sequence: - - service: script.text_notify - data: - who: tony - type: alert - title: Afternoon Meds - message: You need to take your afternoon meds - tag: tony-afternoon-meds - actions: - - action: TONY_AFTERNOON_MEDS_TAKEN - title: Taken - - action: TONY_AFTERNOON_MEDS_SKIPPED - title: Skip - - action: TONY_AFTERNOON_MEDS_ASK_LATER - title: Ask Later + - parallel: + - if: + - condition: numeric_state + entity_id: counter.tony_afternoon_meds_reminder_count + above: 2 + then: + - service: script.speech_engine + data: + who: common_areas + type: alert + message: Tony, you need to take your afternoon meds. This is reminder number + {{ states('counter.tony_afternoon_meds_reminder_count') }} for today. + - service: script.text_notify + data: + who: tony + type: alert + title: Afternoon Meds + message: You need to take your afternoon meds + tag: tony-afternoon-meds + actions: + - action: TONY_AFTERNOON_MEDS_TAKEN + title: Taken + - action: TONY_AFTERNOON_MEDS_SKIPPED + title: Skip + - action: TONY_AFTERNOON_MEDS_ASK_LATER + title: Ask Later - wait_for_trigger: - alias: Taken platform: event