Files
Home-Assistant-Configs/packages/tina.yaml

427 lines
13 KiB
YAML

# This file is for entities/automations that are specific to Tina
input_boolean:
work_today:
name: Work Today
icon: mdi:briefcase
work_today_extended:
name: Work Today Extended
icon: mdi:briefcase-plus
tina_morning_meds_taken:
name: Tina Morning Meds Taken
icon: mdi:medication
tina_night_meds_taken:
name: Tina Night Meds Taken
icon: mdi:medication
tina_awake:
name: Tina Awake
icon: mdi:eye-check
input_datetime:
tina_workday_start:
name: Tina Workday Start
has_date: false
has_time: true
icon: mdi:briefcase
tina_workday_end:
name: Tina Workday End
has_date: false
has_time: true
icon: mdi:briefcase-off
tina_morning_meds_taken:
name: Tina Morning Meds Taken
has_date: true
has_time: true
icon: mdi:medication
tina_morning_meds_notify:
name: Tina Morning Meds Notify
has_date: false
has_time: true
icon: mdi:medication
tina_night_meds_taken:
name: Tina Night Meds Taken
has_date: true
has_time: true
icon: mdi:medication
tina_night_meds_notify:
name: Tina Night Meds Notify
has_date: false
has_time: true
icon: mdi:medication
automation:
- id: cd9f921f-71c7-4e29-9aee-7421ef19bdd3
alias: Work Today
initial_state: true
trigger:
- platform: time
at: '03:55:00'
condition:
- condition: state
entity_id: input_boolean.tina_work_schedule_override
state: 'off'
action:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.work_today_extended
- if:
- condition: template
value_template: >
{% from 'time.jinja' import calendar_event_today %}
{{ calendar_event_today('calendar.family_tinawork') }}
then:
- service: script.tina_work_today
- service: input_boolean.turn_on
target:
entity_id: input_boolean.work_today_ran
- id: a6eeb075-d21b-436c-983f-39188ee9b016
alias: Work Reset
initial_state: true
trigger:
- platform: zone
entity_id: person.christina_stork
zone: zone.home
event: enter
id: home
variables:
reason: "{{ trigger.id }}"
- platform: time
at: input_datetime.tina_workday_end
id: end
variables:
reason: "{{ trigger.id }}"
condition:
- condition: state
entity_id: input_boolean.work_today
state: 'on'
- condition: time
after: "15:00:00"
before: "01:00:00"
action:
- service: script.tina_work_reset
data:
reason: "{{ reason }}"
- 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
- platform: time
at: input_datetime.tina_night_meds_notify
id: sleep
- platform: state
entity_id: input_boolean.tina_night_meds_taken
to: 'on'
id: boolean-night
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 current_time %}
{{ current_time('datetime',24) }}
- conditions:
- condition: and
conditions:
- condition: trigger
id: sleep
- condition: state
entity_id: input_boolean.tina_night_meds_taken
state: 'off'
- condition: state
entity_id: input_boolean.master_bedroom_sleeping
state: 'off'
sequence:
- service: script.turn_on
target:
entity_id: script.tina_night_meds
- conditions:
- condition: trigger
id: boolean-night
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tina_night_meds_taken
data:
datetime: >
{% from 'time.jinja' import current_time %}
{{ current_time('datetime',24) }}
script:
tina_work_today:
alias: 'Tina Work Today'
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tina_workday_start
data:
time: >
{% from 'time.jinja' import time_from_calendar %}
{{ time_from_calendar('calendar.family_tinawork','start_time','set') }}
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tina_workday_end
data:
time: >
{% from 'time.jinja' import time_from_calendar %}
{{ time_from_calendar('calendar.family_tinawork','end_time','set') }}
- service: input_boolean.turn_on
target:
entity_id:
- input_boolean.work_today
- input_boolean.work_today_extended
tina_work_reset:
alias: 'Tina Work Reset'
variables:
reason: '{{ reason|default("{}") }}'
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ reason == 'home' }}"
sequence:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.work_today
- conditions:
- condition: template
value_template: "{{ reason == 'end' }}"
sequence:
- if:
- condition: template
value_template: "{{ states('person.christina_stork') not in ['Bob Evans','BobEvans'] }}"
then:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.work_today
default:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.work_today
# This is in case her schedule changes after the regular 4:00AM scheduling scripts run
tina_schedule_change:
alias: 'Tina Schedule Change'
sequence:
- if:
- condition: template
value_template: >
{% from 'time.jinja' import calendar_event_today %}
{{ calendar_event_today('calendar.family_tinawork') }}
then:
- service: script.tina_work_today
else:
- service: script.tina_work_reset
- service: input_boolean.turn_off
target:
entity_id: input_boolean.work_today_extended
- choose:
- conditions:
- condition: time
after: "04:00:00"
before: "16:00:00"
sequence:
- service: script.house_scheduling_morning
- service: script.emma_bedroom_scheduling_morning
- service: script.master_bedroom_scheduling_morning
- service: script.security_scheduling
- conditions:
- condition: time
after: "16:00:00"
before: "04:00:00"
sequence:
- service: script.house_scheduling_evening
- service: script.master_bedroom_scheduling_evening
- service: script.emma_bedroom_scheduling_evening
- service: script.security_scheduling
tina_morning_meds:
alias: 'Tina Morning Meds'
icon: mdi:medication
mode: restart
sequence:
- 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 == '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) }}
- 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: script.text_notify
data:
type: alert
who: tina
message: clear_notification
tag: tina-morning-meds
tina_night_meds:
alias: 'Tina Night Meds'
icon: mdi:medication
mode: restart
sequence:
- service: script.text_notify
data:
who: tina
type: alert
title: Night Meds
message: You need to take your night meds
tag: tina-night-meds
actions:
- action: "TINA_NIGHT_MEDS_TAKEN"
title: Taken
- action: "TINA_NIGHT_MEDS_SKIPPED"
title: Skip
- action: "TINA_NIGHT_MEDS_ASK_LATER"
title: Ask Later
- wait_for_trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: "TINA_NIGHT_MEDS_TAKEN"
id: taken
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: "TINA_NIGHT_MEDS_SKIPPED"
id: skipped
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: "TINA_NIGHT_MEDS_ASK_LATER"
id: ask-later
- platform: state
entity_id: input_boolean.tina_night_meds_taken
to: 'on'
id: manual
- platform: state
entity_id:
- input_boolean.master_bedroom_sleeping
- input_boolean.goodnight
to: 'on'
id: sleeping
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_night_meds_taken
- conditions: "{{ wait.trigger.id == 'ask-later' }}"
sequence:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tina_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:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.tina_night_meds_notify
data:
datetime: >
{% from 'time.jinja' import set_datetime %}
{{ set_datetime(0,1) }}
- service: script.text_notify
data:
type: alert
who: tina
message: clear_notification
tag: tina-night-meds