diff --git a/automations.yaml b/automations.yaml index 44c1822..64cc66c 100644 --- a/automations.yaml +++ b/automations.yaml @@ -4713,3 +4713,93 @@ target: entity_id: input_boolean.kallen_has_phone mode: restart +- id: '1710611198911' + alias: Kallen Meds Handler + description: Make sure Kallen has taken his meds in the morning and at night + trigger: + - platform: time + at: input_datetime.kallen_morning_meds_notify + id: wakeup + alias: Morning Notify + - platform: time + at: input_datetime.kallen_night_meds_notify + id: sleep + alias: Night Notify + - platform: state + entity_id: input_boolean.kallen_morning_meds_taken + to: 'on' + id: boolean-morning + alias: Morning Taken + - platform: state + entity_id: input_boolean.kallen_night_meds_taken + to: 'on' + id: boolean-night + alias: Night Taken + condition: + - condition: state + entity_id: input_boolean.kallen_overnight + state: 'off' + alias: Kallen is not staying the night elsewhere + action: + - alias: Routing + choose: + - conditions: + - condition: and + conditions: + - condition: trigger + id: wakeup + - condition: state + entity_id: input_boolean.kallen_morning_meds_taken + state: 'off' + alias: Morning Notify + sequence: + - service: script.turn_on + target: + entity_id: script.kallen_morning_meds + data: {} + alias: Run morning meds script + - conditions: + - condition: and + conditions: + - condition: trigger + id: sleep + - condition: state + entity_id: input_boolean.kallen_night_meds_taken + state: 'off' + alias: Night Notify + sequence: + - service: script.turn_on + target: + entity_id: script.kallen_night_meds + data: {} + alias: Run night meds script + - conditions: + - condition: trigger + id: boolean-morning + alias: Morning Taken + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.kallen_morning_meds_taken + data: + datetime: '{% from ''time.jinja'' import current_time %} {{ current_time(''datetime'',24) + }} + + ' + alias: Set time morning meds were taken + - conditions: + - condition: trigger + id: boolean-night + alias: Night Taken + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.kallen_night_meds_taken + data: + datetime: '{% from ''time.jinja'' import current_time %} {{ current_time(''datetime'',24) + }} + + ' + alias: Set time night meds were taken + mode: parallel + max: 4 diff --git a/packages/kallen.yaml b/packages/kallen.yaml index d08c028..bd117c6 100644 --- a/packages/kallen.yaml +++ b/packages/kallen.yaml @@ -97,75 +97,6 @@ sensor: scan_interval: 30 automation: - - id: 67fbdb66-b94b-4351-86de-a388d601e93c - alias: Kallen Meds Handler - description: Make sure Kallen has taken his meds in the morning and at night - mode: parallel - max: 4 - trigger: - - platform: time - at: input_datetime.kallen_morning_meds_notify - id: wakeup - - platform: time - at: input_datetime.kallen_night_meds_notify - id: sleep - - platform: state - entity_id: input_boolean.kallen_morning_meds_taken - to: 'on' - id: boolean-morning - - platform: state - entity_id: input_boolean.kallen_night_meds_taken - to: 'on' - id: boolean-night - action: - - choose: - - conditions: - - condition: and - conditions: - - condition: trigger - id: wakeup - - condition: state - entity_id: input_boolean.kallen_morning_meds_taken - state: 'off' - sequence: - - service: script.turn_on - target: - entity_id: script.kallen_morning_meds - - conditions: - - condition: and - conditions: - - condition: trigger - id: sleep - - condition: state - entity_id: input_boolean.kallen_night_meds_taken - state: 'off' - sequence: - - service: script.turn_on - target: - entity_id: script.kallen_night_meds - - conditions: - - condition: trigger - id: boolean-morning - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.kallen_morning_meds_taken - data: - datetime: > - {% from 'time.jinja' import current_time %} - {{ current_time('datetime',24) }} - - conditions: - - condition: trigger - id: boolean-night - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.kallen_night_meds_taken - data: - datetime: > - {% from 'time.jinja' import current_time %} - {{ current_time('datetime',24) }} - - id: 94b57d79-efe0-4f34-b5e3-baeaa5eea9f4 alias: Kallen Asleep trigger: @@ -173,190 +104,4 @@ automation: at: input_datetime.kallen_bedtime action: - service: input_boolean.turn_off - entity_id: input_boolean.kallen_awake - -script: - kallen_morning_meds: - alias: 'Kallen Morning Meds' - icon: mdi:medication - mode: restart - sequence: - - service: script.text_notify - data: - who: kallen - type: alert - title: Morning Meds - message: You need to take your morning meds. Go to mom or dad to confirm. - tag: kallen-morning-meds-self - - service: script.text_notify - data: - who: parents - type: alert - title: Morning Meds - message: Kallen needs to take his morning meds - tag: kallen-morning-meds-parents - actions: - - action: "KALLEN_MORNING_MEDS_TAKEN" - title: Taken - - action: "KALLEN_MORNING_MEDS_SKIPPED" - title: Skip - - action: "KALLEN_MORNING_MEDS_ASK_LATER" - title: Ask Later - - wait_for_trigger: - - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: "KALLEN_MORNING_MEDS_TAKEN" - id: taken - - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: "KALLEN_MORNING_MEDS_SKIPPED" - id: skipped - - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: "KALLEN_MORNING_MEDS_ASK_LATER" - id: ask-later - - platform: state - entity_id: person.kallen_stork - from: 'home' - id: left - - platform: state - entity_id: input_boolean.kallen_morning_meds_taken - to: 'on' - id: manual - timeout: "00:10:00" - continue_on_timeout: true - - choose: - - conditions: "{{ wait.trigger.id in ['taken','manual'] }}" - sequence: - - service: input_boolean.turn_on - target: - entity_id: input_boolean.kallen_morning_meds_taken - - conditions: "{{ 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: "{{ 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 - - kallen_night_meds: - alias: 'Kallen Night Meds' - icon: mdi:medication - mode: restart - sequence: - - 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 - - action: "KALLEN_NIGHT_MEDS_ASK_LATER" - title: Ask Later - - service: script.text_notify - data: - who: > - {% if states('person.christina_stork') in ['Bob Evans','BobEvans'] %} - tony - {% else %} - parents - {% endif %} - 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: "{{ wait.trigger.id in ['taken','manual'] }}" - sequence: - - service: input_boolean.turn_on - target: - entity_id: input_boolean.kallen_night_meds_taken - - conditions: "{{ 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: "{{ 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 - data: - type: alert - who: all - message: clear_notification - tag: kallen-night-meds \ No newline at end of file + entity_id: input_boolean.kallen_awake \ No newline at end of file diff --git a/scripts.yaml b/scripts.yaml index f68e663..7009ec1 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -2700,3 +2700,202 @@ tony_tylenol: mode: queued icon: mdi:medication max: 10 +'1710612011154': + alias: Kallen Morning Meds + sequence: + - service: script.text_notify + data: + who: kallen + type: alert + title: Morning Meds + message: You need to take your morning meds. Go to mom or dad to confirm. + tag: kallen-morning-meds-self + - service: script.text_notify + data: + who: parents + type: alert + title: Morning Meds + message: Kallen needs to take his morning meds + tag: kallen-morning-meds-parents + actions: + - action: KALLEN_MORNING_MEDS_TAKEN + title: Taken + - action: KALLEN_MORNING_MEDS_SKIPPED + title: Skip + - action: KALLEN_MORNING_MEDS_ASK_LATER + title: Ask Later + - wait_for_trigger: + - platform: event + event_type: ios.notification_action_fired + event_data: + actionName: KALLEN_MORNING_MEDS_TAKEN + id: taken + - platform: event + event_type: ios.notification_action_fired + event_data: + actionName: KALLEN_MORNING_MEDS_SKIPPED + id: skipped + - platform: event + event_type: ios.notification_action_fired + event_data: + actionName: KALLEN_MORNING_MEDS_ASK_LATER + id: ask-later + - platform: state + entity_id: person.kallen_stork + from: home + id: left + - platform: state + entity_id: input_boolean.kallen_morning_meds_taken + to: 'on' + id: manual + timeout: 00:10: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_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 + mode: restart +'1710612164315': + alias: Kallen Night Meds + sequence: + - 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 + - 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 + data: + type: alert + who: all + message: clear_notification + tag: kallen-night-meds + icon: mdi:medication + mode: restart