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

669 lines
20 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:
kallen_awake:
name: Kallen Awake
icon: mdi:eye-check
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"
unit_of_measurement: ""
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"
unit_of_measurement: ""
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"
unit_of_measurement: ""
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"
unit_of_measurement: 'home'
value_template: >-
{{ states['person'] | selectattr('state','eq','home') | list | count }}
people_away:
friendly_name: "People"
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"
unit_of_measurement: 'times'
value_template: >-
{{ states('input_number.front_door_opened_today') | int }}
back_door_opened_today:
friendly_name: "Back Door Opened Today"
unit_of_measurement: 'times'
value_template: >-
{{ states('input_number.back_door_opened_today') | int }}
basement_studio_door_opened_today:
friendly_name: "Basement Studio Door Opened Today"
unit_of_measurement: 'times'
value_template: >-
{{ states('input_number.basement_studio_door_opened_today') | int }}
downstairs_bathroom_door_opened_today:
friendly_name: "Downstairs Bathroom Door Opened Today"
unit_of_measurement: 'times'
value_template: >-
{{ states('input_number.downstairs_bathroom_door_opened_today') | int }}
template:
- binary_sensor:
- name: "Tony Home"
state: "{{ is_state('device_tracker.tony_s_iphone', 'home') or is_state('device_tracker.life360_tony_stork','home') }}"
device_class: presence
- binary_sensor:
- name: "Tina Home"
state: "{{ is_state('device_tracker.tinas_iphone', 'home') or is_state('device_tracker.life360_christina_stork','home') }}"
device_class: presence
- binary_sensor:
- name: "Kallen Home"
state: "{{ is_state('device_tracker.kallen_iphone','home') or is_state('device_tracker.life360_kallen_stork','home') }}"
device_class: presence
- binary_sensor:
- name: "Nerds Home"
state: >-
{% if is_state('group.family','home') %}
{% if is_state('binary_sensor.tony_home','on') or is_state('binary_sensor.kallen_home','on') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{% endif %}
device_class: presence
- binary_sensor:
- name: "Parents Home"
state: >-
{% if is_state('group.adults','home') %}
{% if is_state('binary_sensor.tony_home','on') or is_state('binary_sensor.tina_home','on') %}
true
{% else %}
false
{% endif %}
{% else %}
false
{% endif %}
device_class: presence
mqtt:
sensor:
- name: "Family Status"
state_topic: "house/family/status"
payload_available: "online"
payload_not_available: "offline"
- name: "Family Arrived"
state_topic: "house/family/arrived"
payload_available: "online"
payload_not_available: "offline"
- name: "Last Outdoor Presence Trigger"
state_topic: "house/presence/outdoor/last_trigger"
payload_available: "online"
payload_not_available: "offline"
automation:
- id: kallen_at_school
alias: Kallen is at School
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
entity_id: input_boolean.kallen_at_school
- service: input_boolean.turn_on
entity_id: input_boolean.kallen_awake
- service: script.text_alert
data:
who: parents
message: "Kallen has been dropped off at school."
- service: light.turn_off
entity_id: light.kallen_bedroom_lights
initial_state: true
- id: kallen_left_school
alias: Kallen left School
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_alert
data:
who: parents
message: "Kallen has been picked up from school."
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
- delay:
seconds: 5
- service: input_boolean.turn_off
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
data:
value: 0
script:
family_is_away:
alias: Family Is Away
sequence:
- condition: state
entity_id: group.adults
state: not_home
- service: notify.all_ios
data:
title: "Everyone Left"
message: "Away mode arming in 1 minute"
data:
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: notify.all_ios
data:
message: "clear_notification"
data:
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
- 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
data:
value: Adaptive
- service: input_text.set_value
target:
entity_id: input_text.dining_room_lamp_selected_scene
data:
value: Full
- 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
- 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') %}
{% if weather in ['cloudy','partlycloudy','rainy','snowy','hail','lightning','lightning-rainy','pouring','snowy-rainy'] %}
true
{% else %}
false
{% endif %}
then:
- 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
data:
option: Adaptive
- service: input_boolean.turn_on
target:
entity_id: input_boolean.tina_desk_lights
- service: input_select.select_option
target:
entity_id: input_select.dining_room_lamp_scenes
data:
option: Full
- service: light.turn_off
target:
area_id:
- furnace_room
- kallen_bedroom
- emma_bedroom
- master_bedroom
- upstairs_hallway
- basement_studio
- downstairs_bathroom
- upstairs_bathroom
- service: script.welcome_home
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
- 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
data:
option: Adaptive
- service: input_select.select_option
target:
entity_id: input_select.dining_room_lamp_scenes
data:
option: Full
- 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
- service: script.welcome_home
mode: single
icon: mdi:home-account