419 lines
12 KiB
YAML
419 lines
12 KiB
YAML
# This file is for entities/automations that are specific to Tony
|
|
|
|
input_boolean:
|
|
tony_streaming_today:
|
|
name: Tony Streaming Today
|
|
icon: mdi:twitch
|
|
tony_morning_meds_taken:
|
|
name: Tony Morning Meds Taken
|
|
icon: mdi:medical-bag
|
|
tony_night_meds_taken:
|
|
name: Tony Night Meds Taken
|
|
icon: mdi:medical-bag
|
|
|
|
input_datetime:
|
|
tony_streaming_start_time:
|
|
name: Tony Streaming Start Time
|
|
has_date: false
|
|
has_time: true
|
|
icon: mdi:twitch
|
|
tony_morning_meds_taken:
|
|
name: Tony Morning Meds Taken
|
|
has_date: true
|
|
has_time: true
|
|
icon: mdi:medical-bag
|
|
tony_night_meds_taken:
|
|
name: Tony Night Meds Taken
|
|
has_date: true
|
|
has_time: true
|
|
icon: mdi:medical-bag
|
|
tony_morning_meds_notify:
|
|
name: Tony Morning Meds Notify
|
|
has_date: false
|
|
has_time: true
|
|
icon: mdi:medical-bag
|
|
tony_night_meds_notify:
|
|
name: Tony Night Meds Notify
|
|
has_date: false
|
|
has_time: true
|
|
icon: mdi:medical-bag
|
|
|
|
sensor:
|
|
- platform: rest
|
|
name: Home Tech
|
|
method: GET
|
|
resource: 'https://api.todoist.com/sync/v9/projects/get_data'
|
|
params:
|
|
project_id: 2285967948
|
|
headers:
|
|
Authorization: !secret todoist_api_token
|
|
value_template: '{{value_json[''project''][''id'']}}'
|
|
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
|
|
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) }}
|
|
- service: logbook.log
|
|
data:
|
|
name: Tony Morning Meds
|
|
message: Taken
|
|
entity_id: input_boolean.tony_morning_meds_taken
|
|
domain: input_boolean
|
|
- 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) }}
|
|
- service: logbook.log
|
|
data:
|
|
name: Tony Night Meds
|
|
message: have been taken
|
|
entity_id: input_boolean.tony_night_meds_taken
|
|
domain: input_boolean
|
|
|
|
- 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
|
|
|
|
- id: 465ec4be-8e6c-444b-bfe7-6d4796888be4
|
|
alias: Tony Stream Reset
|
|
initial_state: true
|
|
trigger:
|
|
- platform: state
|
|
entity_id: sensor.twitch_ironnerd24
|
|
from: 'streaming'
|
|
to: 'offline'
|
|
id: offline
|
|
- platform: time
|
|
at: "06:00:00"
|
|
id: time
|
|
action:
|
|
- choose:
|
|
- conditions:
|
|
- condition: trigger
|
|
id: offline
|
|
sequence:
|
|
- service: script.tony_stream_reset
|
|
- conditions:
|
|
- condition: trigger
|
|
id: time
|
|
sequence:
|
|
- if:
|
|
- condition: state
|
|
entity_id: sensor.twitch_ironnerd24
|
|
state: 'offline'
|
|
then:
|
|
- service: script.tony_stream_reset
|
|
|
|
script:
|
|
tony_morning_meds:
|
|
alias: 'Tony Morning Meds'
|
|
icon: mdi:medical-bag
|
|
mode: restart
|
|
sequence:
|
|
- service: input_boolean.turn_off
|
|
target:
|
|
entity_id: input_boolean.tony_morning_meds_taken
|
|
- 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 == 'skipped' }}"
|
|
sequence:
|
|
- service: logbook.log
|
|
data:
|
|
name: Tony Morning Meds
|
|
message: Skipped
|
|
entity_id: input_boolean.tony_morning_meds_taken
|
|
domain: input_boolean
|
|
- 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) }}
|
|
- service: logbook.log
|
|
data:
|
|
name: Tony Morning Meds
|
|
message: Delayed for 30 minutes
|
|
entity_id: input_boolean.tony_morning_meds_taken
|
|
domain: input_boolean
|
|
- 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: logbook.log
|
|
data:
|
|
name: Tony Morning Meds
|
|
message: No response, delayed for 1 minute
|
|
entity_id: input_boolean.tony_morning_meds_taken
|
|
domain: input_boolean
|
|
- 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:medical-bag
|
|
mode: restart
|
|
sequence:
|
|
- service: input_boolean.turn_off
|
|
target:
|
|
entity_id: input_boolean.tony_night_meds_taken
|
|
- 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 == 'skipped' }}"
|
|
sequence:
|
|
- service: logbook.log
|
|
data:
|
|
name: Tony Night Meds
|
|
message: have been skipped
|
|
entity_id: input_boolean.tony_night_meds_taken
|
|
domain: input_boolean
|
|
- 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) }}
|
|
- service: logbook.log
|
|
data:
|
|
name: Tony Night Meds
|
|
message: delayed for 30 minutes
|
|
entity_id: input_boolean.tony_night_meds_taken
|
|
domain: input_boolean
|
|
- 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: logbook.log
|
|
data:
|
|
name: Tony Night Meds
|
|
message: No response, delayed for 1 minute
|
|
entity_id: input_boolean.tony_night_meds_taken
|
|
domain: input_boolean
|
|
else:
|
|
- service: logbook.log
|
|
data:
|
|
name: Tony Night Meds
|
|
message: No response, cancelled
|
|
entity_id: input_boolean.tony_night_meds_taken
|
|
domain: input_boolean
|
|
- 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
|
|
|
|
tony_stream_reset:
|
|
alias: 'Tony Stream Reset'
|
|
sequence:
|
|
- service: input_boolean.turn_off
|
|
entity_id: input_boolean.tony_streaming_today |