From 1afa59747f8917e82a273382de5d595001c3873b Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 2 Oct 2023 20:46:08 -0400 Subject: [PATCH] Migrate my personal automations and scripts #154 --- automations.yaml | 106 +++++++++++++++++ packages/tony.yaml | 281 +-------------------------------------------- scripts.yaml | 216 ++++++++++++++++++++++++++++++++++ 3 files changed, 323 insertions(+), 280 deletions(-) diff --git a/automations.yaml b/automations.yaml index 7a7e886..547f9c7 100644 --- a/automations.yaml +++ b/automations.yaml @@ -2201,6 +2201,112 @@ data: value: '{{ states(''sensor.todays_high_temp'') | int }}' mode: single +- id: '1696288846954' + alias: Tony Meds Handler + description: Make sure Tony has taken his meds in the morning and at night + trigger: + - platform: time + at: input_datetime.tony_morning_meds_notify + id: wakeup + - platform: time + at: input_datetime.tony_night_meds_notify + id: sleep + - platform: state + entity_id: input_boolean.tony_morning_meds_taken + to: 'on' + id: boolean-morning + - platform: state + entity_id: input_boolean.tony_night_meds_taken + to: 'on' + id: boolean-night + - platform: state + entity_id: input_boolean.master_bedroom_sleeping + to: 'off' + id: sleep-off + condition: [] + action: + - choose: + - conditions: + - condition: and + conditions: + - condition: trigger + id: wakeup + - condition: state + entity_id: input_boolean.tony_morning_meds_taken + state: 'off' + sequence: + - service: script.turn_on + target: + entity_id: script.tony_morning_meds + data: {} + - conditions: + - condition: and + conditions: + - condition: trigger + id: sleep + - condition: state + entity_id: input_boolean.tony_night_meds_taken + state: 'off' + sequence: + - service: script.turn_on + target: + entity_id: script.tony_night_meds + data: {} + - conditions: + - condition: trigger + id: boolean-morning + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.tony_morning_meds_taken + data: + datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0) + }} + + ' + - conditions: + - condition: trigger + id: boolean-night + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.tony_night_meds_taken + data: + datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0) + }} + + ' + - conditions: + - condition: trigger + id: sleep-off + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.tony_morning_meds_notify + data: + datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,1) + }} + + ' + mode: parallel + max: 4 +- id: '1696288939707' + alias: Tony Stream Today + description: '' + trigger: + - platform: time + at: 08:00:00 + condition: + - condition: template + value_template: '{% from ''time.jinja'' import calendar_event_today %} {{ calendar_event_today(''calendar.tony_s_twitch_schedule'') + }} + + ' + action: + - service: script.tony_stream_today + data: {} + mode: single + initial_state: true - id: '1696293127764' alias: Timer Handling description: This automation will handle when house timers (usually set by voice) diff --git a/packages/tony.yaml b/packages/tony.yaml index 2a3aa59..a3890cc 100644 --- a/packages/tony.yaml +++ b/packages/tony.yaml @@ -51,283 +51,4 @@ sensor: json_attributes: - project - items - scan_interval: 30 - -automation: - - id: c583aebf-4500-412c-9436-e1b534ba1a44 - alias: Tony Meds Handler - description: Make sure Tony has taken his meds in the morning and at night - mode: parallel - max: 4 - trigger: - - platform: time - at: input_datetime.tony_morning_meds_notify - id: wakeup - - platform: time - at: input_datetime.tony_night_meds_notify - id: sleep - - platform: state - entity_id: input_boolean.tony_morning_meds_taken - to: 'on' - id: boolean-morning - - platform: state - entity_id: input_boolean.tony_night_meds_taken - to: 'on' - id: boolean-night - - platform: state - entity_id: input_boolean.master_bedroom_sleeping - to: 'off' - id: sleep-off - action: - - choose: - - conditions: - - condition: and - conditions: - - condition: trigger - id: wakeup - - condition: state - entity_id: input_boolean.tony_morning_meds_taken - state: 'off' - sequence: - - service: script.turn_on - target: - entity_id: script.tony_morning_meds - - conditions: - - condition: and - conditions: - - condition: trigger - id: sleep - - condition: state - entity_id: input_boolean.tony_night_meds_taken - state: 'off' - sequence: - - service: script.turn_on - target: - entity_id: script.tony_night_meds - - conditions: - - condition: trigger - id: boolean-morning - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.tony_morning_meds_taken - data: - datetime: > - {% from 'time.jinja' import set_datetime %} - {{ set_datetime(0) }} - - conditions: - - condition: trigger - id: boolean-night - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.tony_night_meds_taken - data: - datetime: > - {% from 'time.jinja' import set_datetime %} - {{ set_datetime(0) }} - - conditions: - - condition: trigger - id: sleep-off - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.tony_morning_meds_notify - data: - datetime: > - {% from 'time.jinja' import set_datetime %} - {{ set_datetime(0,1) }} - - - id: 77f33070-4405-41b6-84c4-05b4f3697199 - alias: Tony Stream Today - initial_state: true - trigger: - - platform: time - at: '08:00:00' - condition: - - condition: template - value_template: > - {% from 'time.jinja' import calendar_event_today %} - {{ calendar_event_today('calendar.tony_s_twitch_schedule') }} - action: - - service: script.tony_stream_today - -script: - tony_morning_meds: - alias: '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 - - wait_for_trigger: - - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: "TONY_MORNING_MEDS_TAKEN" - id: taken - - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: "TONY_MORNING_MEDS_SKIPPED" - id: skipped - - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: "TONY_MORNING_MEDS_ASK_LATER" - id: ask-later - - platform: state - entity_id: person.tony_stork - from: 'home' - id: left - - platform: state - entity_id: input_boolean.tony_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.tony_morning_meds_taken - - conditions: "{{ wait.trigger.id == 'ask-later' }}" - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.tony_morning_meds_notify - data: - datetime: > - {% from 'time.jinja' import set_datetime %} - {{ set_datetime(0,30) }} - - conditions: "{{ wait.trigger.id == 'left' }}" - sequence: - - service: script.text_notify - data: - who: tony - type: critical - 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.tony_morning_meds_notify - data: - datetime: > - {% from 'time.jinja' import set_datetime %} - {{ set_datetime(0,1) }} - - service: script.text_notify - data: - type: alert - who: tony - message: clear_notification - tag: tony-morning-meds - - tony_night_meds: - alias: 'Tony Night Meds' - icon: mdi:medication - mode: restart - sequence: - - service: script.text_notify - data: - who: tony - type: alert - title: Night Meds - message: You need to take your night meds - tag: tony-night-meds - actions: - - action: "TONY_NIGHT_MEDS_TAKEN" - title: Taken - - action: "TONY_NIGHT_MEDS_SKIPPED" - title: Skip - - action: "TONY_NIGHT_MEDS_ASK_LATER" - title: Ask Later - - wait_for_trigger: - - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: "TONY_NIGHT_MEDS_TAKEN" - id: taken - - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: "TONY_NIGHT_MEDS_SKIPPED" - id: skipped - - platform: event - event_type: ios.notification_action_fired - event_data: - actionName: "TONY_NIGHT_MEDS_ASK_LATER" - id: ask-later - - platform: state - entity_id: input_boolean.tony_night_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.tony_night_meds_taken - - conditions: "{{ wait.trigger.id == 'ask-later' }}" - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.tony_night_meds_notify - data: - datetime: > - {% from 'time.jinja' import set_datetime %} - {{ set_datetime(0,30) }} - - conditions: "{{ wait.trigger == 'none' or wait.trigger.idx is undefined }}" - sequence: - - if: - - condition: and - conditions: - - condition: state - entity_id: person.tony_stork - state: 'home' - - condition: state - entity_id: binary_sensor.morning - state: 'off' - then: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.tony_night_meds_notify - data: - datetime: > - {% from 'time.jinja' import set_datetime %} - {{ set_datetime(0,1) }} - - service: script.text_notify - data: - type: alert - who: tony - message: clear_notification - tag: tony-night-meds - - tony_stream_today: - alias: 'Tony Stream Today' - sequence: - - service: input_datetime.set_datetime - target: - entity_id: input_datetime.tony_streaming_start_time - data: - time: > - {% from 'time.jinja' import time_from_calendar %} - {{ time_from_calendar('calendar.tony_s_twitch_schedule','start_time','set') }} - - service: input_boolean.turn_on - entity_id: input_boolean.tony_streaming_today \ No newline at end of file + scan_interval: 30 \ No newline at end of file diff --git a/scripts.yaml b/scripts.yaml index b2a41cf..091dc4d 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -1778,6 +1778,222 @@ bright_mode_in_tina_desk: brightness: 255 mode: restart icon: mdi:palette +tony_morning_meds: + alias: 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 + - wait_for_trigger: + - platform: event + event_type: ios.notification_action_fired + event_data: + actionName: TONY_MORNING_MEDS_TAKEN + id: taken + alias: Taken + - platform: event + event_type: ios.notification_action_fired + event_data: + actionName: TONY_MORNING_MEDS_SKIPPED + id: skipped + alias: Skipped + - platform: event + event_type: ios.notification_action_fired + event_data: + actionName: TONY_MORNING_MEDS_ASK_LATER + id: ask-later + alias: Ask Later + - platform: state + entity_id: person.tony_stork + from: home + id: left + alias: Left + - platform: state + entity_id: input_boolean.tony_morning_meds_taken + to: 'on' + id: manual + alias: Manual + timeout: 00:30:00 + continue_on_timeout: true + - choose: + - conditions: + - condition: template + value_template: '{{ wait.trigger.id in [''taken'',''manual''] }}' + alias: Taken, Manual + sequence: + - service: input_boolean.turn_on + target: + entity_id: input_boolean.tony_morning_meds_taken + data: {} + - conditions: + - condition: template + value_template: '{{ wait.trigger.id == ''ask-later'' }}' + alias: Ask Later + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.tony_morning_meds_notify + data: + datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,30) + }} + + ' + - conditions: + - condition: template + value_template: '{{ wait.trigger.id == ''left'' }}' + alias: Left + sequence: + - service: script.text_notify + data: + who: tony + type: critical + title: HEY DUMBASS + message: YOU FORGOT TO TAKE YOUR MORNING MEDS!!!!! + - conditions: + - condition: template + value_template: '{{ wait.trigger == ''none'' or wait.trigger.idx is undefined + }}' + alias: None or undefined + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.tony_morning_meds_notify + data: + datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,1) + }} + + ' + - service: script.text_notify + data: + type: alert + who: tony + message: clear_notification + tag: tony-morning-meds +tony_night_meds: + alias: Tony Night Meds + icon: mdi:medication + mode: restart + sequence: + - service: script.text_notify + data: + who: tony + type: alert + title: Night Meds + message: You need to take your night meds + tag: tony-night-meds + actions: + - action: TONY_NIGHT_MEDS_TAKEN + title: Taken + - action: TONY_NIGHT_MEDS_SKIPPED + title: Skip + - action: TONY_NIGHT_MEDS_ASK_LATER + title: Ask Later + - wait_for_trigger: + - platform: event + event_type: ios.notification_action_fired + event_data: + actionName: TONY_NIGHT_MEDS_TAKEN + id: taken + alias: Taken + - platform: event + event_type: ios.notification_action_fired + event_data: + actionName: TONY_NIGHT_MEDS_SKIPPED + id: skipped + alias: Skipped + - platform: event + event_type: ios.notification_action_fired + event_data: + actionName: TONY_NIGHT_MEDS_ASK_LATER + id: ask-later + alias: Ask Later + - platform: state + entity_id: input_boolean.tony_night_meds_taken + to: 'on' + id: manual + alias: Manual + timeout: 00:30:00 + continue_on_timeout: true + - choose: + - conditions: + - condition: template + value_template: '{{ wait.trigger.id in [''taken'',''manual''] }}' + alias: Taken, Manual + sequence: + - service: input_boolean.turn_on + target: + entity_id: input_boolean.tony_night_meds_taken + data: {} + - conditions: + - condition: template + value_template: '{{ wait.trigger.id == ''ask-later'' }}' + alias: Ask Later + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.tony_night_meds_notify + data: + datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,30) + }} + + ' + - conditions: + - condition: template + value_template: '{{ wait.trigger == ''none'' or wait.trigger.idx is undefined + }}' + alias: None or undefined + sequence: + - if: + - condition: and + conditions: + - condition: state + entity_id: person.tony_stork + state: home + - condition: state + entity_id: binary_sensor.morning + state: 'off' + then: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.tony_night_meds_notify + data: + datetime: '{% from ''time.jinja'' import set_datetime %} {{ set_datetime(0,1) + }} + + ' + - service: script.text_notify + data: + type: alert + who: tony + message: clear_notification + tag: tony-night-meds +tony_stream_today: + alias: Tony Stream Today + sequence: + - service: input_datetime.set_datetime + target: + entity_id: input_datetime.tony_streaming_start_time + data: + time: '{% from ''time.jinja'' import time_from_calendar %} {{ time_from_calendar(''calendar.tony_s_twitch_schedule'',''start_time'',''set'') + }} + + ' + - service: input_boolean.turn_on + entity_id: input_boolean.tony_streaming_today + mode: single timer_modify: alias: Timer Modify description: For adding/subtracting time from a running timer