Implement new trackers for K

#205
This commit is contained in:
2024-08-04 14:36:25 -04:00
parent 8865a237ca
commit 59b17d5833
3 changed files with 369 additions and 253 deletions

View File

@ -4681,26 +4681,34 @@
mode: restart mode: restart
- id: '1710611198911' - id: '1710611198911'
alias: Kallen Meds Handler alias: Kallen Meds Handler
description: Make sure Kallen has taken his meds in the morning and at night description: Handles the scheduling of medication reminders for Kallen
trigger: trigger:
- platform: time_pattern
minutes: /30
id: trigger30
alias: Every 30 minutes
- platform: time - platform: time
at: input_datetime.kallen_morning_meds_notify at: input_datetime.kallen_morning_meds_notify
id: wakeup id: morning-notify
alias: Morning Notify alias: Morning Notify
- platform: time - platform: time
at: input_datetime.kallen_night_meds_notify at: input_datetime.kallen_night_meds_notify
id: sleep id: night-notify
alias: Night Notify alias: Night Notify
- platform: state - platform: state
entity_id: input_boolean.kallen_morning_meds_taken entity_id:
- input_boolean.kallen_morning_meds_taken
to: 'on' to: 'on'
id: boolean-morning id: boolean-morning
alias: Morning Taken alias: Morning Taken
from: 'off'
- platform: state - platform: state
entity_id: input_boolean.kallen_night_meds_taken entity_id:
to: 'on' - input_boolean.kallen_night_meds_taken
id: boolean-night id: boolean-night
alias: Night Taken alias: Night Taken
from: 'off'
to: 'on'
condition: condition:
- condition: state - condition: state
entity_id: input_boolean.kallen_overnight entity_id: input_boolean.kallen_overnight
@ -4709,90 +4717,133 @@
action: action:
- alias: Routing - alias: Routing
choose: choose:
- conditions:
- condition: trigger
id:
- trigger30
sequence:
- alias: Check morning reminder switch
if:
- condition: state
entity_id: input_boolean.kallen_morning_meds_reminder
state: 'on'
alias: Morning meds reminder needed
then:
- service: script.kallen_morning_meds
metadata: {}
data: {}
alias: Run morning meds notification script
- alias: Check night reminder switch
if:
- condition: state
entity_id: input_boolean.kallen_night_meds_reminder
state: 'on'
alias: Night meds reminder needed
then:
- service: script.kallen_night_meds
metadata: {}
data: {}
alias: Run night meds notification script
alias: Every 30 minutes
- conditions: - conditions:
- condition: and - condition: and
conditions: conditions:
- condition: trigger - condition: trigger
id: wakeup id: morning-notify
- condition: state - condition: state
entity_id: input_boolean.kallen_morning_meds_taken entity_id: input_boolean.kallen_morning_meds_taken
state: 'off' state: 'off'
alias: Morning Notify alias: Morning Notify
sequence: sequence:
- service: counter.increment - service: input_boolean.turn_on
metadata: {} metadata: {}
data: {} data: {}
target: target:
entity_id: counter.kallen_morning_meds_reminder_count entity_id: input_boolean.kallen_morning_meds_reminder
alias: Increment counter alias: Activate morning reminders
- service: script.turn_on - service: script.kallen_morning_meds
target: metadata: {}
entity_id: script.kallen_morning_meds
data: {} data: {}
alias: Run morning meds script alias: Run morning meds notification script
- conditions: - conditions:
- condition: and - condition: and
conditions: conditions:
- condition: trigger - condition: trigger
id: sleep id:
- night-notify
- condition: state - condition: state
entity_id: input_boolean.kallen_night_meds_taken entity_id: input_boolean.kallen_night_meds_taken
state: 'off' state: 'off'
alias: Night Notify alias: Night Notify
sequence: sequence:
- alias: Increment counter - alias: Activate night reminders
service: counter.increment service: input_boolean.turn_on
metadata: {} metadata: {}
data: {} data: {}
target: target:
entity_id: counter.kallen_night_meds_reminder_count entity_id: input_boolean.kallen_night_meds_reminder
- service: script.turn_on - service: script.kallen_night_meds
target: metadata: {}
entity_id: script.kallen_night_meds
data: {} data: {}
alias: Run night meds script alias: Run night meds notification script
- conditions: - conditions:
- condition: trigger - condition: trigger
id: boolean-morning id: boolean-morning
alias: Morning Taken alias: Morning Taken
sequence: sequence:
- service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.kallen_morning_meds_reminder_count
alias: Reset counter
- service: input_datetime.set_datetime - service: input_datetime.set_datetime
target: target:
entity_id: input_datetime.kallen_morning_meds_taken entity_id: input_datetime.kallen_morning_meds_taken
data: data:
datetime: '{% from ''time.jinja'' import current_time %} {{ current_time(''datetime'',24) datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0)
}} }}
' '
alias: Set time morning meds were taken alias: Set time morning meds were taken
- service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.kallen_morning_meds_reminder
alias: Deactivate morning reminders
- service: script.text_notify
metadata: {}
data:
type: alert
who: kallen
message: clear_notification
tag: kallen-left-meds
alias: Clear kallen-left-meds notification tag
- conditions: - conditions:
- condition: trigger - condition: trigger
id: boolean-night id: boolean-night
alias: Night Taken alias: Night Taken
sequence: sequence:
- alias: Reset counter
service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.kallen_night_meds_reminder_count
- service: input_datetime.set_datetime - service: input_datetime.set_datetime
target: target:
entity_id: input_datetime.kallen_night_meds_taken entity_id: input_datetime.kallen_night_meds_taken
data: data:
datetime: '{% from ''time.jinja'' import current_time %} {{ current_time(''datetime'',24) datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0)
}} }}
' '
alias: Set time night meds were taken alias: Set time night meds were taken
- alias: Deactivate night reminders
service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.kallen_night_meds_reminder
- service: script.text_notify
metadata: {}
data:
type: alert
who: kallen
message: clear_notification
tag: kallen-left-meds
alias: Clear kallen-left-meds notification tag
mode: parallel mode: parallel
max: 4 max: 12
- id: '1711657679853' - id: '1711657679853'
alias: Basement Briefing alias: Basement Briefing
description: '' description: ''
@ -5760,3 +5811,172 @@
tag: tina-left-meds tag: tina-left-meds
mode: queued mode: queued
max: 10 max: 10
- id: '1722387020007'
alias: Kallen Meds Cleanup
description: Handles the setting/clearing of medication configs for Kallen
trigger:
- platform: state
entity_id:
- input_boolean.kallen_morning_meds_reminder
from: 'on'
to: 'off'
id: morning-reminders-off
alias: Morning reminders off
- alias: Night reminders off
platform: state
entity_id:
- input_boolean.kallen_night_meds_reminder
from: 'on'
to: 'off'
id: night-reminders-off
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: KALLEN_MORNING_MEDS_TAKEN
id: morning-taken
alias: Morning taken
- alias: Night taken
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: KALLEN_NIGHT_MEDS_TAKEN
id: night-taken
- alias: Morning skipped
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: KALLEN_MORNING_MEDS_SKIPPED
id: morning-skipped
- alias: Night skipped
platform: event
event_type: ios.notification_action_fired
event_data:
actionName: KALLEN_NIGHT_MEDS_SKIPPED
id: night-skipped
- platform: state
entity_id:
- person.kallen_stork
from: home
id: left
alias: Left
condition: []
action:
- alias: Routing
choose:
- conditions:
- condition: trigger
id:
- morning-reminders-off
alias: Morning Reminders Off
sequence:
- service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.kallen_morning_meds_reminder_count
alias: Reset morning reminder count
- service: script.text_notify
data:
type: alert
who: kallen
message: clear_notification
tag: kallen-morning-meds
alias: Clear morning notification
- conditions:
- condition: trigger
id:
- night-reminders-off
alias: Night reminders off
sequence:
- alias: Reset night reminder count
service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.kallen_night_meds_reminder_count
- service: script.text_notify
data:
type: alert
who: kallen
message: clear_notification
tag: kallen-night-meds
alias: Clear night notification
- conditions:
- condition: trigger
id:
- morning-taken
alias: Morning taken
sequence:
- service: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.kallen_morning_meds_taken
alias: Turn on morning meds taken
- conditions:
- condition: trigger
id:
- night-taken
alias: Night taken
sequence:
- service: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.kallen_night_meds_taken
alias: Turn on night meds taken
- conditions:
- condition: trigger
id:
- morning-skipped
alias: Morning skipped
sequence:
- service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.kallen_morning_meds_reminder
alias: Deactivate morning reminders
- conditions:
- condition: trigger
id:
- night-skipped
alias: Night skipped
sequence:
- service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.kallen_night_meds_reminder
alias: Deactivate night reminders
- conditions:
- condition: trigger
id:
- left
alias: Left
sequence:
- alias: Send critical TTS notification if any meds aren't taken
if:
- alias: Check if any reminders are active
condition: or
conditions:
- condition: state
entity_id: input_boolean.kallen_morning_meds_reminder
state: 'on'
alias: Morning meds reminder active
- condition: state
entity_id: input_boolean.kallen_night_meds_reminder
state: ''
alias: Night meds reminder active
then:
- alias: Send critical TTS notification
service: script.text_notify
metadata: {}
data:
type: critical
who: kallen
title: EYYO
message: YOU FORGOT TO TAKE YOUR MEDS!!!!!
tag: kallen-left-meds
mode: queued
max: 10

View File

@ -16,9 +16,15 @@ input_boolean:
kallen_late_bedtime: kallen_late_bedtime:
name: Kallen Late Bedtime name: Kallen Late Bedtime
icon: mdi:weather-night icon: mdi:weather-night
kallen_morning_meds_reminder:
name: Kallen Morning Meds Reminder
icon: mdi:medication
kallen_morning_meds_taken: kallen_morning_meds_taken:
name: Kallen Morning Meds Taken name: Kallen Morning Meds Taken
icon: mdi:medication icon: mdi:medication
kallen_night_meds_reminder:
name: Kallen Night Meds Reminder
icon: mdi:medication
kallen_night_meds_taken: kallen_night_meds_taken:
name: Kallen Night Meds Taken name: Kallen Night Meds Taken
icon: mdi:medication icon: mdi:medication
@ -67,12 +73,12 @@ input_datetime:
icon: mdi:medication icon: mdi:medication
kallen_morning_meds_notify: kallen_morning_meds_notify:
name: Kallen Morning Meds Notify name: Kallen Morning Meds Notify
has_date: false has_date: true
has_time: true has_time: true
icon: mdi:medication icon: mdi:medication
kallen_night_meds_notify: kallen_night_meds_notify:
name: Kallen Night Meds Notify name: Kallen Night Meds Notify
has_date: false has_date: true
has_time: true has_time: true
icon: mdi:medication icon: mdi:medication
kallen_alarm_clock: kallen_alarm_clock:

View File

@ -1717,35 +1717,19 @@ tony_night_meds:
minutes: 0 minutes: 0
seconds: 5 seconds: 5
milliseconds: 0 milliseconds: 0
- alias: Send night notifications via text, and TTS if needed - alias: Send text notification
parallel: service: script.text_notify
- alias: Send text notification data:
service: script.text_notify who: tony
data: type: alert
who: tony title: Night Meds
type: alert message: You need to take your night meds
title: Night Meds tag: tony-night-meds
message: You need to take your night meds actions:
tag: tony-night-meds - action: TONY_NIGHT_MEDS_TAKEN
actions: title: Taken
- action: TONY_NIGHT_MEDS_TAKEN - action: TONY_NIGHT_MEDS_SKIPPED
title: Taken title: Skip
- action: TONY_NIGHT_MEDS_SKIPPED
title: Skip
- alias: Send TTS if reminders > 2
if:
- condition: numeric_state
entity_id: counter.tony_night_meds_reminder_count
above: 2
alias: When reminder count > 2
then:
- service: script.speech_engine
data:
who: common_areas
type: alert
message: Tony, you need to take your night meds. This is reminder number
{{ states('counter.tony_night_meds_reminder_count') }} for today.
alias: Send TTS notification
tony_stream_today: tony_stream_today:
alias: Tony Stream Today alias: Tony Stream Today
sequence: sequence:
@ -2304,203 +2288,109 @@ tony_tylenol:
mode: queued mode: queued
icon: mdi:medication icon: mdi:medication
max: 10 max: 10
'1710612011154': kallen_morning_meds:
alias: Kallen Morning Meds alias: Kallen Morning Meds
sequence: sequence:
- service: script.text_notify - service: counter.increment
data: metadata: {}
who: kallen data: {}
type: alert target:
title: Morning Meds entity_id: counter.kallen_morning_meds_reminder_count
message: You need to take your morning meds. Go to mom or dad to confirm. alias: Increment morning reminder counter
tag: kallen-morning-meds-self - alias: Clear previous morning notifications
- service: script.text_notify parallel:
data: - service: script.text_notify
who: parents data:
type: alert type: alert
title: Morning Meds who: parents
message: Kallen needs to take his morning meds message: clear_notification
tag: kallen-morning-meds-parents tag: kallen-morning-meds-parents
actions: alias: Clear for parents
- action: KALLEN_MORNING_MEDS_TAKEN - service: script.text_notify
title: Taken data:
- action: KALLEN_MORNING_MEDS_SKIPPED type: alert
title: Skip who: kallen
- action: KALLEN_MORNING_MEDS_ASK_LATER message: clear_notification
title: Ask Later tag: kallen-morning-meds-self
- wait_for_trigger: alias: Clear for Kallen
- platform: event - delay:
event_type: ios.notification_action_fired hours: 0
event_data: minutes: 0
actionName: KALLEN_MORNING_MEDS_TAKEN seconds: 5
id: taken milliseconds: 0
- platform: event - alias: Send text notifications
event_type: ios.notification_action_fired parallel:
event_data: - alias: Send to parents
actionName: KALLEN_MORNING_MEDS_SKIPPED service: script.text_notify
id: skipped data:
- platform: event who: parents
event_type: ios.notification_action_fired type: alert
event_data: title: Morning Meds
actionName: KALLEN_MORNING_MEDS_ASK_LATER message: Kallen needs to take his morning meds
id: ask-later tag: kallen-morning-meds-parents
- platform: state actions:
entity_id: person.kallen_stork - action: KALLEN_MORNING_MEDS_TAKEN
from: home title: Taken
id: left - action: KALLEN_MORNING_MEDS_SKIPPED
- platform: state title: Skip
entity_id: input_boolean.kallen_morning_meds_taken - service: script.text_notify
to: 'on' data:
id: manual who: kallen
timeout: 00:10:00 type: alert
continue_on_timeout: true title: Morning Meds
- choose: message: You need to take your morning meds. Go to mom or dad to confirm.
- conditions: tag: kallen-morning-meds-self
- condition: template alias: Send to Kallen
value_template: '{{ wait.trigger.id in [''taken'',''manual''] }}'
sequence:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.kallen_morning_meds_taken
data: {}
- conditions:
- condition: template
value_template: '{{ wait.trigger.id == ''ask-later'' }}'
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.kallen_morning_meds_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,5)
}}
'
- conditions:
- condition: template
value_template: '{{ wait.trigger.id == ''left'' or wait.trigger == ''none''
or wait.trigger.idx is undefined }}'
sequence:
- if:
- condition: state
entity_id: person.kallen_stork
state: home
then:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.kallen_morning_meds_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,1)
}}
'
- service: script.text_notify
data:
type: alert
who: kallen
message: clear_notification
tag: kallen-morning-meds-parents
- service: script.text_notify
data:
type: alert
who: kallen
message: clear_notification
tag: kallen-morning-meds-self
icon: mdi:medication icon: mdi:medication
mode: restart mode: restart
'1710612164315': kallen_night_meds:
alias: Kallen Night Meds alias: Kallen Night Meds
sequence: sequence:
- service: script.text_notify - service: counter.increment
data: metadata: {}
who: kallen data: {}
type: alert alias: Increment night reminder counter
title: Night Meds
message: You need to take your night meds (melatonin)
tag: kallen-night-meds
actions:
- action: KALLEN_NIGHT_MEDS_TAKEN
title: Taken
- action: KALLEN_NIGHT_MEDS_SKIPPED
title: Skip
- action: KALLEN_NIGHT_MEDS_ASK_LATER
title: Ask Later
- service: script.text_notify
data:
who: "{% if states('person.christina_stork') in ['Bob Evans','BobEvans'] %}\n
\ tony\n{% else %}\n parents\n{% endif %}\n"
type: alert
title: Night Meds
message: Kallen needs to take his night meds (melatonin)
tag: kallen-night-meds
actions:
- action: KALLEN_NIGHT_MEDS_TAKEN
title: Taken
- action: KALLEN_NIGHT_MEDS_SKIPPED
title: Skip
- action: KALLEN_NIGHT_MEDS_ASK_LATER
title: Ask Later
- wait_for_trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: KALLEN_NIGHT_MEDS_TAKEN
id: taken
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: KALLEN_NIGHT_MEDS_SKIPPED
id: skipped
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: KALLEN_NIGHT_MEDS_ASK_LATER
id: ask-later
- platform: state
entity_id: input_boolean.kallen_night_meds_taken
to: 'on'
id: manual
timeout: 00:05:00
continue_on_timeout: true
- choose:
- conditions:
- condition: template
value_template: '{{ wait.trigger.id in [''taken'',''manual''] }}'
sequence:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.kallen_night_meds_taken
data: {}
- conditions:
- condition: template
value_template: '{{ wait.trigger.id == ''ask-later'' }}'
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.kallen_night_meds_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,15)
}}
'
- conditions:
- condition: template
value_template: '{{ wait.trigger == ''none'' or wait.trigger.idx is undefined
}}'
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.kallen_night_meds_notify
data:
datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,1)
}}
'
- service: script.text_notify - service: script.text_notify
data: data:
type: alert type: alert
who: all who: all
message: clear_notification message: clear_notification
tag: kallen-night-meds tag: kallen-night-meds
alias: Clear previous night notification
- delay:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
- parallel:
- service: script.text_notify
data:
who: "{% if states('person.christina_stork') in ['Bob Evans','BobEvans'] %}\n
\ tony\n{% else %}\n parents\n{% endif %}\n"
type: alert
title: Night Meds
message: Kallen needs to take his night meds (melatonin)
tag: kallen-night-meds
actions:
- action: KALLEN_NIGHT_MEDS_TAKEN
title: Taken
- action: KALLEN_NIGHT_MEDS_SKIPPED
title: Skip
alias: Send to parents
- alias: Send to Kallen
service: script.text_notify
data:
who: kallen
type: alert
title: Night Meds
message: You need to take your night meds (melatonin)
tag: kallen-night-meds
actions:
- action: KALLEN_NIGHT_MEDS_TAKEN
title: Taken
- action: KALLEN_NIGHT_MEDS_SKIPPED
title: Skip
alias: Send text notifications
icon: mdi:medication icon: mdi:medication
mode: restart mode: restart
reset_annc_switches: reset_annc_switches: