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

734 lines
23 KiB
YAML

input_datetime:
last_time_home_tony:
name: Tony Last Seen
has_date: true
has_time: true
icon: mdi:binoculars
last_time_home_tina:
name: Tina Last Seen
has_date: true
has_time: true
icon: mdi:binoculars
last_time_home_kallen:
name: Kallen Last Seen
has_date: true
has_time: true
icon: mdi:binoculars
input_boolean:
away_mode_skipped:
name: Away Mode Skipped
icon: mdi:debug-step-over
input_number:
front_door_opened_today:
name: Front Door Opened Today
min: 0
max: 200
step: 1
unit_of_measurement: times
icon: mdi:door-open
back_door_opened_today:
name: Back Door Opened Today
min: 0
max: 200
step: 1
unit_of_measurement: times
icon: mdi:door-open
basement_studio_door_opened_today:
name: Basement Studio Door Opened Today
min: 0
max: 200
step: 1
unit_of_measurement: times
icon: mdi:door-open
downstairs_bathroom_door_opened_today:
name: Downstairs Bathroom Door Opened Today
min: 0
max: 200
step: 1
unit_of_measurement: times
icon: mdi:door-open
proximity:
home_tony:
devices:
- device_tracker.tony_s_iphone
zone: home
tolerance: 5
unit_of_measurement: mi
home_tina:
devices:
- device_tracker.tinas_iphone
zone: home
tolerance: 5
unit_of_measurement: mi
home:
devices:
- device_tracker.tony_s_iphone
- device_tracker.tinas_iphone
zone: home
tolerance: 5
unit_of_measurement: mi
sensor:
- platform: template
sensors:
tony_location:
friendly_name: "Tony"
unique_id: 2620a9d0-01f0-4af4-8438-a0c860735aab
value_template: >-
{% set person = states.person.tony_stork.state %}
{% if person in ['Home','home'] %}
Home
{% elif person in ['WalMart','Wal-Mart','Kroger','Chief','Meijer','Dollar General - Clinton St','Aldi'] %}
Grocery Store
{% elif person in ['Rite Aid'] %}
Pharmacy
{% else %}
{% if person in ['not_home','Stationary'] %}
{{ state_attr('device_tracker.life360_tony_stork','address') }}
{% else %}
{{ states('person.tony_stork') }}
{%- endif %}
{%- endif %}
icon_template: >-
{% set person = states.person.tony_stork.state %}
{% if person in ['Home','home'] %}
mdi:home
{% else %}
mdi:car
{% endif %}
tina_location:
friendly_name: "Tina"
unique_id: 5439165c-f73e-4870-826a-d12c99e35487
value_template: >-
{% set person = states.person.christina_stork.state %}
{% if person in ['Home','home'] %}
Home
{% elif person in ['WalMart','Wal-Mart','Kroger','Chief','Meijer','Dollar General - Clinton St','Aldi'] %}
Grocery Store
{% elif person in ['Rite Aid'] %}
Pharmacy
{% elif person in ['Bob Evans','BobEvans'] and is_state('input_boolean.work_today','on') %}
Work
{% else %}
{% if person in ['not_home','Stationary'] %}
{{ state_attr('device_tracker.life360_christina_stork','address') }}
{% else %}
{{ states('person.christina_stork') }}
{%- endif %}
{%- endif %}
icon_template: >-
{% set person = states.person.christina_stork.state %}
{% if person in ['Home','home'] %}
mdi:home
{% else %}
mdi:car
{% endif %}
kallen_location:
friendly_name: "Kallen"
unique_id: d4b4c324-52aa-41e4-b446-8ba0d6b45cd3
value_template: >-
{% set person = states.person.kallen_stork.state %}
{% if person in ['Home','home'] %}
Home
{% elif person in ['School','Elementary School','High School'] %}
School
{% elif person in ['WalMart','Wal-Mart','Kroger','Chief','Meijer','Dollar General - Clinton St','Aldi'] %}
Grocery Store
{% elif person in ['Rite Aid'] %}
Pharmacy
{% else %}
{% if person in ['not_home','Stationary'] %}
{{ state_attr('device_tracker.life360_kallen_stork','address') }}
{% else %}
{{ states('person.kallen_stork') }}
{%- endif %}
{%- endif %}
icon_template: >-
{% set person = states.person.kallen_stork.state %}
{% if person in ['Home','home'] %}
mdi:home
{% else %}
mdi:car
{% endif %}
people_home:
friendly_name: "People"
unique_id: 053d3a0a-f5b4-48e0-a8df-4d847d0fe9c3
unit_of_measurement: 'home'
value_template: >-
{{ states['person'] | selectattr('state','eq','home') | list | count }}
people_away:
friendly_name: "People"
unique_id: e46e51a6-3c57-4599-840b-fca6884f867e
unit_of_measurement: 'away'
value_template: >-
{% set people = [
states.person.tony_stork,
states.person.christina_stork,
states.person.kallen_stork,
] %}
{{ people | selectattr('state','ne','home') | list | count }}
front_door_opened_today:
friendly_name: "Front Door Opened Today"
unique_id: 6a8bb32e-5f4e-4d1f-8e17-77f07e5b174a
unit_of_measurement: 'times'
value_template: >-
{{ states('input_number.front_door_opened_today') | int }}
icon_template: >-
{% if states('input_number.front_door_opened_today') | int > 0 %}
mdi:door-open
{% else %}
mdi:door-closed
{% endif %}
back_door_opened_today:
friendly_name: "Back Door Opened Today"
unique_id: 77786cc9-64de-4035-a635-e831a3b0ef63
unit_of_measurement: 'times'
value_template: >-
{{ states('input_number.back_door_opened_today') | int }}
icon_template: >-
{% if states('input_number.back_door_opened_today') | int > 0 %}
mdi:door-open
{% else %}
mdi:door-closed
{% endif %}
basement_studio_door_opened_today:
friendly_name: "Basement Studio Door Opened Today"
unique_id: 3d74efd0-2df5-438e-a015-26ac1ce2c4ee
unit_of_measurement: 'times'
value_template: >-
{{ states('input_number.basement_studio_door_opened_today') | int }}
icon_template: >-
{% if states('input_number.basement_studio_door_opened_today') | int > 0 %}
mdi:door-open
{% else %}
mdi:door-closed
{% endif %}
downstairs_bathroom_door_opened_today:
friendly_name: "Downstairs Bathroom Door Opened Today"
unique_id: cdc850bc-3747-405d-8b16-3b79ba9fbc87
unit_of_measurement: 'times'
value_template: >-
{{ states('input_number.downstairs_bathroom_door_opened_today') | int }}
icon_template: >-
{% if states('input_number.downstairs_bathroom_door_opened_today') | int > 0 %}
mdi:door-open
{% else %}
mdi:door-closed
{% endif %}
template:
- binary_sensor:
- name: "Tony Home"
unique_id: 4f0d8c3d-dc49-4b7a-a1fc-5d286b4a954d
state: "{{ is_state('device_tracker.tony_s_iphone', 'home') or is_state('device_tracker.life360_tony_stork','home') }}"
device_class: presence
- name: "Tina Home"
unique_id: 3d90e515-b204-4510-af0c-6c784fda2bd4
state: "{{ is_state('device_tracker.tinas_iphone', 'home') or is_state('device_tracker.life360_christina_stork','home') }}"
device_class: presence
- name: "Kallen Home"
unique_id: 2419e826-b276-434c-b5c6-e42c065a73ff
state: "{{ is_state('device_tracker.kallen_iphone','home') or is_state('device_tracker.life360_kallen_stork','home') }}"
device_class: presence
- name: "Nerds Home"
unique_id: 2672a6a2-4be4-495c-b479-ffc7c6df67d2
state: "{{ is_state('group.family','home') and (is_state('binary_sensor.tony_home','on') or is_state('binary_sensor.kallen_home','on')) }}"
device_class: presence
- name: "Parents Home"
unique_id: 8de02d19-60a6-436d-9187-1cfc70d6c297
state: "{{ is_state('group.adults','home') and (is_state('binary_sensor.tony_home','on') or is_state('binary_sensor.tina_home','on')) }}"
device_class: presence
- name: "Basement Unoccupied"
unique_id: 20039c29-8b9d-436d-ba6c-8f2c2bda1db0
state: >
{% if is_state('binary_sensor.tony_desktop_on','off') and is_state('binary_sensor.kallen_desktop_on','off') %}
true
{% elif is_state('binary_sensor.tony_desktop_idle','on') and is_state('binary_sensor.kallen_desktop_idle','on') %}
true
{% elif is_state('binary_sensor.tony_desktop_idle','on') and is_state('binary_sensor.kallen_desktop_on','off') %}
true
{% elif is_state('binary_sensor.kallen_desktop_idle','on') and is_state('binary_sensor.tony_desktop_on','off') %}
true
{% else %}
false
{% endif %}
- name: "Upstairs Bathroom Occupied"
unique_id: 7ec69a26-1013-4b0d-8662-a91ab9f040ca
state: "{{ is_state('timer.upstairs_bathroom_motion_timer','active') or is_state('binary_sensor.upstairs_bathroom_motion','on') or is_state('input_boolean.shower_mode','on') }}"
mqtt:
sensor:
- name: "Family Status"
unique_id: 47d0cef6-6c95-4e8e-bf89-6c657db6102c
state_topic: "house/family/status"
payload_available: "online"
payload_not_available: "offline"
- name: "Family Arrived"
unique_id: a6574daf-5345-43b9-90c8-5e99ce56df0b
state_topic: "house/family/arrived"
payload_available: "online"
payload_not_available: "offline"
- name: "Last Outdoor Presence Trigger"
unique_id: f16493e7-0344-4f2b-94b4-2c89ab0e3eb6
state_topic: "house/presence/outdoor/last_trigger"
payload_available: "online"
payload_not_available: "offline"
automation:
- id: kallen_at_school
alias: Kallen is at School
mode: single
trigger:
- entity_id: person.tony_stork
event: leave
platform: zone
zone: zone.elementary_school
- entity_id: person.christina_stork
event: leave
platform: zone
zone: zone.elementary_school
- entity_id: person.kallen_stork
event: enter
platform: zone
zone: zone.elementary_school
condition:
- condition: time
before: "11:30:00"
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: state
entity_id: input_boolean.kallen_at_school
state: "off"
- condition: state
entity_id: input_boolean.kallen_school_today
state: "on"
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.kallen_at_school
- service: input_boolean.turn_on
target:
entity_id: input_boolean.kallen_awake
- service: script.text_notify
data:
type: alert
who: parents
message: "Kallen has been dropped off at school."
title: "Kallen Location Alert"
tag: kallen-dropoff
- service: light.turn_off
target:
entity_id: light.kallen_bedroom_lights
- if:
- condition: state
entity_id: input_boolean.master_bedroom_sleeping
state: 'on'
then:
- service: light.turn_off
target:
entity_id: light.living_room_lights
initial_state: true
- id: kallen_left_school
alias: Kallen left School
mode: single
trigger:
- entity_id: person.tony_stork
event: leave
platform: zone
zone: zone.elementary_school
- entity_id: person.christina_stork
event: leave
platform: zone
zone: zone.elementary_school
- entity_id: person.kallen_stork
event: leave
platform: zone
zone: zone.elementary_school
condition:
- condition: time
after: "11:30:02"
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: state
entity_id: input_boolean.kallen_at_school
state: "on"
action:
- service: input_boolean.turn_off
entity_id: input_boolean.kallen_at_school
- service: script.text_notify
data:
type: alert
who: parents
message: "Kallen has been picked up from school."
title: "Kallen Location Alert"
tag: kallen-pickup
initial_state: true
- id: 94b57d79-efe0-4f34-b5e3-baeaa5eea9f4
alias: Kallen Asleep
trigger:
- platform: time
at: input_datetime.kallen_bedtime
action:
- service: input_boolean.turn_off
entity_id: input_boolean.kallen_awake
- id: 395ebb76-83e4-4a7c-913e-2598fef3d5c1
alias: Doorbell Alert
trigger:
- alias: "Doorbell Rings"
platform: state
entity_id: binary_sensor.front_doorbell_ding_mqtt
from: "off"
to: "on"
condition:
- alias: "Are we home?"
condition: state
entity_id: group.adults
state: "home"
action:
- alias: "Save Current Light State"
service: scene.create
data:
scene_id: doorbell_lights_restore
snapshot_entities:
- light.living_room_color_1
- light.living_room_color_2
- light.living_room_color_3
- light.tina_lamp_top
- light.tina_lamp_side
- light.tina_desk_strip
- alias: "Save Current Adaptive State"
service: scene.create
data:
scene_id: doorbell_adaptive_restore
snapshot_entities:
- switch.adaptive_lighting_tina_lamp
- switch.adaptive_lighting_living_room
- alias: "Turn Adaptive Lighting off"
service: switch.turn_off
target:
entity_id:
- switch.adaptive_lighting_tina_lamp
- switch.adaptive_lighting_living_room
- alias: "Turn Lights On"
service: light.turn_on
target:
entity_id:
- light.living_room_lights
- light.tina_lamp
- light.tina_desk_strip
data:
color_name: green
- alias: "End early if door opened"
wait_template: "{{ is_state('binary_sensor.front_door','on') }}"
timeout:
seconds: 30
- alias: "Return lights to previous state"
service: scene.turn_on
target:
entity_id: scene.doorbell_lights_restore
- delay:
seconds: 3
- alias: "Return Adaptive Lighting to previous state"
service: scene.turn_on
target:
entity_id: scene.doorbell_adaptive_restore
- id: 481e7756-9549-413f-9b41-5b0f8c5f5cba
alias: iOS Skip Away Mode
trigger:
- platform: event
event_type: ios.notification_action_fired
event_data:
actionName: 'SKIP_AWAY'
action:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.away_mode_skipped
- id: 11eee604-db2a-4ab2-a372-70026a4f1a6f
alias: Door Openings Reset
trigger:
- platform: time
at: 00:00
action:
- service: input_number.set_value
target:
entity_id:
- input_number.back_door_opened_today
- input_number.front_door_opened_today
- input_number.basement_studio_door_opened_today
- input_number.downstairs_bathroom_door_opened_today
data:
value: 0
script:
family_is_away:
alias: Family Is Away
sequence:
- condition: state
entity_id: group.adults
state: not_home
- service: script.text_notify
data:
who: >
{% if states('person.christina_stork') in ['Bob Evans','BobEvans'] %}
nerds
{% else %}
all
{% endif %}
type: alert
title: "Everyone Left"
message: "Away Mode arming in 1 minute"
tag: skip-away
actions:
- action: "SKIP_AWAY"
title: Skip Away Mode
icon: mdi:debug-step-over
- wait_template: "{{ is_state('input_boolean.away_mode_skipped','on') or is_state('group.adults','home') }}"
continue_on_timeout: true
timeout:
minutes: 1
- service: script.text_notify
data:
type: alert
who: all
message: "clear_notification"
tag: skip-away
- if:
- condition: template
value_template: "{{ is_state('input_boolean.away_mode_skipped','on') or is_state('group.adults','home') }}"
then:
- stop: Away Mode Skipped
- service: light.turn_off
target:
area_id:
- basement_studio
- furnace_room
- kallen_bedroom
- living_room
- master_bedroom
- mud_room
- emma_bedroom
- upstairs_hallway
- dining_room
- downstairs_bathroom
- upstairs_bathroom
- service: input_boolean.turn_off
target:
entity_id:
- input_boolean.tina_desk_lights
- input_boolean.white_noise_emma_bedroom
- service: fan.turn_off
target:
area_id:
- basement_studio
- kallen_bedroom
- master_bedroom
- emma_bedroom
- delay:
seconds: 5
- service: switch.turn_on
target:
entity_id:
- switch.adaptive_lighting_basement_studio
- switch.adaptive_lighting_living_room
- switch.adaptive_lighting_downstairs_bathroom
- switch.adaptive_lighting_dining_room_lamp
- switch.adaptive_lighting_tina_lamp
- switch.adaptive_lighting_mud_room
- switch.adaptive_lighting_upstairs_hallway
- switch.adaptive_lighting_upstairs_bathroom
- switch.adaptive_lighting_master_bedroom
- switch.adaptive_lighting_kallen_bedroom
- switch.adaptive_lighting_emma_bedroom
- service: input_text.set_value
target:
entity_id:
- input_text.basement_studio_selected_scene
- input_text.living_room_selected_scene
- input_text.downstairs_bathroom_selected_scene
- input_text.mud_room_selected_scene
- input_text.tina_lamp_selected_scene
- input_text.upstairs_hallway_selected_scene
- input_text.upstairs_bathroom_selected_scene
- input_text.master_bedroom_selected_scene
- input_text.kallen_bedroom_selected_scene
- input_text.emma_bedroom_selected_scene
- input_text.dining_room_lamp_selected_scene
data:
value: Adaptive
- service: media_player.turn_off
target:
entity_id: media_player.living_room_tv
- service: script.security_arm_away
mode: single
icon: mdi:shield-lock
family_is_home_day:
alias: Family Is Home Day
sequence:
- if:
- condition: state
entity_id: input_boolean.vacation_mode
state: 'on'
then:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.vacation_mode
- service: switch.turn_off
target:
entity_id: switch.presence_simulation
- if:
- condition: state
entity_id: input_boolean.away_mode_skipped
state: 'on'
then:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.away_mode_skipped
- stop: Away Mode was skipped
- service: light.turn_off
target:
area_id:
- living_room
- dining_room
- tina_desk
- mud_room
- furnace_room
- kallen_bedroom
- emma_bedroom
- master_bedroom
- upstairs_hallway
- basement_studio
- downstairs_bathroom
- upstairs_bathroom
- service: script.turn_on
target:
entity_id:
- script.welcome_home
- script.volume_reset
- service: script.security_disarm
- service: switch.turn_off
target:
entity_id:
- switch.basement_echo_dot_do_not_disturb_switch
- switch.living_room_echo_dot_do_not_disturb_switch
- switch.master_bedroom_echo_dot_do_not_disturb_switch
- if:
- condition: template
value_template: >
{% set weather = states('weather.iron_nerd_weather_station') %}
{{ weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] }}
then:
- service: light.turn_on
target:
area_id:
- front_porch
- living_room
- dining_room
- mud_room
- service: input_boolean.turn_on
target:
entity_id: input_boolean.tina_desk_lights
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- service: input_select.select_option
target:
entity_id:
- input_select.living_room_scenes
- input_select.mud_room_scenes
- input_select.dining_room_lamp_scenes
data:
option: Adaptive
mode: single
icon: mdi:home-account
family_is_home_night:
alias: Family Is Home Night
sequence:
- if:
- condition: state
entity_id: input_boolean.vacation_mode
state: 'on'
then:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.vacation_mode
- service: switch.turn_off
target:
entity_id: switch.presence_simulation
- if:
- condition: state
entity_id: input_boolean.away_mode_skipped
state: 'on'
then:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.away_mode_skipped
- stop: Away Mode was skipped
- service: script.turn_on
target:
entity_id:
- script.welcome_home
- script.volume_reset
- service: script.security_disarm
- service: switch.turn_off
target:
entity_id:
- switch.basement_echo_dot_do_not_disturb_switch
- switch.living_room_echo_dot_do_not_disturb_switch
- switch.master_bedroom_echo_dot_do_not_disturb_switch
- service: light.turn_on
target:
area_id:
- living_room
- dining_room
- mud_room
- service: input_boolean.turn_on
target:
entity_id: input_boolean.tina_desk_lights
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- service: input_select.select_option
target:
entity_id:
- input_select.living_room_scenes
- input_select.mud_room_scenes
- input_select.dining_room_lamp_scenes
data:
option: Adaptive
- service: input_select.select_option
target:
entity_id: input_select.upstairs_bathroom_scenes
data:
option: Nightlight
- service: light.turn_off
target:
area_id:
- furnace_room
- kallen_bedroom
- emma_bedroom
- master_bedroom
- upstairs_hallway
- basement_studio
- downstairs_bathroom
mode: single
icon: mdi:home-account