Wife morning meds tracker
This commit is contained in:
@ -386,11 +386,41 @@ Tony does not have a stream scheduled today. The next scheduled stream is in {{
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro tina_morning_meds(method) %}
|
||||||
|
{% from 'time.jinja' import input_datetime_12hr, input_datetime_12hr_with_date, ct %}
|
||||||
|
{% set ct = ct() | int %}
|
||||||
|
{% if is_state('binary_sensor.overnight','off') %}
|
||||||
|
{% if is_state('input_boolean.tina_morning_meds_taken','on') %}
|
||||||
|
Tina took her morning meds at {{ input_datetime_12hr_with_date('input_datetime.tina_morning_meds_taken') }} today.
|
||||||
|
{% elif is_state('input_boolean.tina_morning_meds_taken','off') and is_state('binary_sensor.after_midnight','off') %}
|
||||||
|
Tina has not taken her morning meds.
|
||||||
|
{% if ct < state_attr('input_datetime.tina_morning_meds_notify','timestamp') | int %}
|
||||||
|
{% if method == 'tts' %}
|
||||||
|
{{ ['She has a reminder scheduled for',
|
||||||
|
'Rest assured that I will pester her mercilessly about this, starting at',
|
||||||
|
'This is absolutely essential, and I will remind her to do it at',
|
||||||
|
'Her blood pressure is very important, so I will remind her at',
|
||||||
|
] | random }} {{ input_datetime_12hr('input_datetime.tina_morning_meds_notify') }} today.
|
||||||
|
{% else %}
|
||||||
|
She will be reminded at {{ input_datetime_12hr('input_datetime.tina_morning_meds_notify') }} today.
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro medReportTina(method) %}
|
||||||
|
{{ tina_morning_meds(method) }}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro tinaStatusReport(type,method) %}
|
{% macro tinaStatusReport(type,method) %}
|
||||||
{% from 'status.jinja' import workReportTina %}
|
{% from 'status.jinja' import workReportTina %}
|
||||||
{% if type == 'work' %}
|
{% if type == 'work' %}
|
||||||
{{ workReportTina(method) }}
|
{{ workReportTina(method) }}
|
||||||
|
{% elif type == 'meds' %}
|
||||||
|
{{ medReportTina(method) }}
|
||||||
{% elif type == 'full' %}
|
{% elif type == 'full' %}
|
||||||
|
{{ medReportTina(method) }}
|
||||||
{{ workReportTina(method) }}
|
{{ workReportTina(method) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
@ -569,9 +569,21 @@ script:
|
|||||||
entity_id: input_datetime.tony_morning_meds_notify
|
entity_id: input_datetime.tony_morning_meds_notify
|
||||||
data:
|
data:
|
||||||
time: "{{ states('input_datetime.master_bedroom_wakeup') }}"
|
time: "{{ states('input_datetime.master_bedroom_wakeup') }}"
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tina_morning_meds_notify
|
||||||
|
data:
|
||||||
|
time: >
|
||||||
|
{% if is_state('input_boolean.work_today','on') %}
|
||||||
|
{{ state_attr('input_datetime.tina_workday_start','timestamp') | int - 1800 }}
|
||||||
|
{% else %}
|
||||||
|
{{ states('input_datetime.master_bedroom_wakeup') }}
|
||||||
|
{% endif %}
|
||||||
- service: input_boolean.turn_off
|
- service: input_boolean.turn_off
|
||||||
target:
|
target:
|
||||||
entity_id: input_boolean.tony_morning_meds_taken
|
entity_id:
|
||||||
|
- input_boolean.tony_morning_meds_taken
|
||||||
|
- input_boolean.tina_morning_meds_taken
|
||||||
- service: input_boolean.turn_on
|
- service: input_boolean.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: input_boolean.master_bedroom_scheduling_morning_ran
|
entity_id: input_boolean.master_bedroom_scheduling_morning_ran
|
||||||
|
@ -7,6 +7,9 @@ input_boolean:
|
|||||||
work_today_extended:
|
work_today_extended:
|
||||||
name: Work Today Extended
|
name: Work Today Extended
|
||||||
icon: mdi:briefcase-plus
|
icon: mdi:briefcase-plus
|
||||||
|
tina_morning_meds_taken:
|
||||||
|
name: Tina Morning Meds Taken
|
||||||
|
icon: mdi:medical-bag
|
||||||
|
|
||||||
input_datetime:
|
input_datetime:
|
||||||
tina_workday_start:
|
tina_workday_start:
|
||||||
@ -19,6 +22,16 @@ input_datetime:
|
|||||||
has_date: false
|
has_date: false
|
||||||
has_time: true
|
has_time: true
|
||||||
icon: mdi:briefcase-off
|
icon: mdi:briefcase-off
|
||||||
|
tina_morning_meds_taken:
|
||||||
|
name: Tina Morning Meds Taken
|
||||||
|
has_date: true
|
||||||
|
has_time: true
|
||||||
|
icon: mdi:medical-bag
|
||||||
|
tina_morning_meds_notify:
|
||||||
|
name: Tina Morning Meds Notify
|
||||||
|
has_date: false
|
||||||
|
has_time: true
|
||||||
|
icon: mdi:medical-bag
|
||||||
|
|
||||||
automation:
|
automation:
|
||||||
- id: cd9f921f-71c7-4e29-9aee-7421ef19bdd3
|
- id: cd9f921f-71c7-4e29-9aee-7421ef19bdd3
|
||||||
@ -55,6 +68,51 @@ automation:
|
|||||||
action:
|
action:
|
||||||
- service: script.tina_work_reset
|
- service: script.tina_work_reset
|
||||||
|
|
||||||
|
- id: 513e33b8-a236-474b-a9cc-e40af36a052d
|
||||||
|
alias: Tina Meds Handler
|
||||||
|
description: Make sure Tina has taken her meds in the morning and at night
|
||||||
|
mode: parallel
|
||||||
|
max: 4
|
||||||
|
trigger:
|
||||||
|
- platform: time
|
||||||
|
at: input_datetime.tina_morning_meds_notify
|
||||||
|
id: wakeup
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_boolean.tina_morning_meds_taken
|
||||||
|
to: 'on'
|
||||||
|
id: boolean-morning
|
||||||
|
action:
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: and
|
||||||
|
conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id: wakeup
|
||||||
|
- condition: state
|
||||||
|
entity_id: input_boolean.tina_morning_meds_taken
|
||||||
|
state: 'off'
|
||||||
|
sequence:
|
||||||
|
- service: script.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: script.tina_morning_meds
|
||||||
|
- conditions:
|
||||||
|
- condition: trigger
|
||||||
|
id: boolean-morning
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tina_morning_meds_taken
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0) }}
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: Tina Morning Meds
|
||||||
|
message: Taken
|
||||||
|
entity_id: input_boolean.tina_morning_meds_taken
|
||||||
|
domain: input_boolean
|
||||||
|
|
||||||
script:
|
script:
|
||||||
tina_work_today:
|
tina_work_today:
|
||||||
alias: 'Tina Work Today'
|
alias: 'Tina Work Today'
|
||||||
@ -120,4 +178,111 @@ script:
|
|||||||
- service: script.house_scheduling_evening
|
- service: script.house_scheduling_evening
|
||||||
- service: script.master_bedroom_scheduling_evening
|
- service: script.master_bedroom_scheduling_evening
|
||||||
- service: script.emma_bedroom_scheduling_evening
|
- service: script.emma_bedroom_scheduling_evening
|
||||||
- service: script.security_scheduling
|
- service: script.security_scheduling
|
||||||
|
|
||||||
|
tina_morning_meds:
|
||||||
|
alias: 'Tina Morning Meds'
|
||||||
|
icon: mdi:medical-bag
|
||||||
|
mode: restart
|
||||||
|
sequence:
|
||||||
|
- service: input_boolean.turn_off
|
||||||
|
target:
|
||||||
|
entity_id: input_boolean.tina_morning_meds_taken
|
||||||
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
who: tina
|
||||||
|
type: alert
|
||||||
|
title: Morning Meds
|
||||||
|
message: You need to take your morning meds
|
||||||
|
tag: tina-morning-meds
|
||||||
|
actions:
|
||||||
|
- action: "TINA_MORNING_MEDS_TAKEN"
|
||||||
|
title: Taken
|
||||||
|
- action: "TINA_MORNING_MEDS_SKIPPED"
|
||||||
|
title: Skip
|
||||||
|
- action: "TINA_MORNING_MEDS_ASK_LATER"
|
||||||
|
title: Ask Later
|
||||||
|
- wait_for_trigger:
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "TINA_MORNING_MEDS_TAKEN"
|
||||||
|
id: taken
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "TINA_MORNING_MEDS_SKIPPED"
|
||||||
|
id: skipped
|
||||||
|
- platform: event
|
||||||
|
event_type: ios.notification_action_fired
|
||||||
|
event_data:
|
||||||
|
actionName: "TINA_MORNING_MEDS_ASK_LATER"
|
||||||
|
id: ask-later
|
||||||
|
- platform: state
|
||||||
|
entity_id: person.christina_stork
|
||||||
|
from: 'home'
|
||||||
|
id: left
|
||||||
|
- platform: state
|
||||||
|
entity_id: input_boolean.tina_morning_meds_taken
|
||||||
|
to: 'on'
|
||||||
|
id: manual
|
||||||
|
timeout: "00:30:00"
|
||||||
|
continue_on_timeout: true
|
||||||
|
- choose:
|
||||||
|
- conditions: "{{ wait.trigger.id in ['taken','manual'] }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_boolean.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: input_boolean.tina_morning_meds_taken
|
||||||
|
- conditions: "{{ wait.trigger.id == 'skipped' }}"
|
||||||
|
sequence:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: Tina Morning Meds
|
||||||
|
message: Skipped
|
||||||
|
entity_id: input_boolean.tina_morning_meds_taken
|
||||||
|
domain: input_boolean
|
||||||
|
- conditions: "{{ wait.trigger.id == 'ask-later' }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tina_morning_meds_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0,30) }}
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: Tina Morning Meds
|
||||||
|
message: Delayed for 30 minutes
|
||||||
|
entity_id: input_boolean.tina_morning_meds_taken
|
||||||
|
domain: input_boolean
|
||||||
|
- conditions: "{{ wait.trigger.id == 'left' }}"
|
||||||
|
sequence:
|
||||||
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
who: tina
|
||||||
|
type: alert
|
||||||
|
title: HEY DUMBASS
|
||||||
|
message: YOU FORGOT TO TAKE YOUR MORNING MEDS!!!!!
|
||||||
|
- conditions: "{{ wait.trigger == 'none' or wait.trigger.idx is undefined }}"
|
||||||
|
sequence:
|
||||||
|
- service: input_datetime.set_datetime
|
||||||
|
target:
|
||||||
|
entity_id: input_datetime.tina_morning_meds_notify
|
||||||
|
data:
|
||||||
|
datetime: >
|
||||||
|
{% from 'time.jinja' import set_datetime %}
|
||||||
|
{{ set_datetime(0,1) }}
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: Tina Morning Meds
|
||||||
|
message: No response, delayed for 1 minute
|
||||||
|
entity_id: input_boolean.tina_morning_meds_taken
|
||||||
|
domain: input_boolean
|
||||||
|
- service: script.text_notify
|
||||||
|
data:
|
||||||
|
type: alert
|
||||||
|
who: tina
|
||||||
|
message: clear_notification
|
||||||
|
tag: tina-morning-meds
|
Reference in New Issue
Block a user