380 lines
11 KiB
YAML
Executable File
380 lines
11 KiB
YAML
Executable File
###############################################################################
|
|
# @author : Jeffrey Stone
|
|
# @date : 02/19/2019
|
|
# @package : Presence
|
|
# @description : A Collection of Presence Related Trackers and Sensors
|
|
###############################################################################
|
|
|
|
sensor:
|
|
- platform: template
|
|
sensors:
|
|
jeff_location:
|
|
friendly_name: "Jeff's Current Location"
|
|
unit_of_measurement: ''
|
|
value_template: >-
|
|
{%- if is_state('person.jeffrey', 'not_home') %}
|
|
{%- if states.device_tracker.life360_jeffrey_stone.attributes.moving == True %}
|
|
Flue Network
|
|
{%- elif states.device_tracker.life360_jeffrey_stone.attributes.driving == True %}
|
|
Flue Network
|
|
{% else %}
|
|
Lost
|
|
{%- endif %}
|
|
{% elif is_state('person.jeffrey', 'Sprouts') %}
|
|
Grocery Store
|
|
{% elif is_state('person.jeffrey', 'Kroger1') %}
|
|
Grocery Store
|
|
{% elif is_state('person.jeffrey', 'Kroger2') %}
|
|
Grocery Store
|
|
{% elif is_state('person.jeffrey', 'Home Depot') %}
|
|
Home Improvement Store
|
|
{% elif is_state('person.jeffrey', 'Lowes') %}
|
|
Home Improvement Store
|
|
{% elif is_state('person.jeffrey', 'Walmart') %}
|
|
Super Store
|
|
{% elif is_state('person.jeffrey', 'Target') %}
|
|
Super Store
|
|
{% else %}
|
|
{{ states.person.jeffrey.state }}
|
|
{%- endif %}
|
|
jeff_driving:
|
|
friendly_name: "Jeff' Driving"
|
|
unit_of_measurement: ''
|
|
value_template: >-
|
|
{%- if states.device_tracker.life360_jeffrey_stone.attributes.moving == True %}
|
|
on
|
|
{% elif states.device_tracker.life360_jeffrey_stone.attributes.driving == True %}
|
|
on
|
|
{% else %}
|
|
off
|
|
{% endif %}
|
|
- platform: template
|
|
sensors:
|
|
skylar_location:
|
|
friendly_name: "Skylar's Current Location"
|
|
unit_of_measurement: ''
|
|
value_template: >-
|
|
{%- if is_state('person.jeffrey', 'home') and is_state('person.jeffrey', 'home')%}
|
|
home
|
|
{% else %}
|
|
Mortal Peril
|
|
{%- endif %}
|
|
- platform: template
|
|
sensors:
|
|
kat_location:
|
|
friendly_name: "Kat's Current Location"
|
|
unit_of_measurement: ''
|
|
value_template: >-
|
|
{%- if is_state('person.katherine', 'not_home') %}
|
|
{%- if states.device_tracker.life360_kat_stone.attributes.moving == True %}
|
|
Flue Network
|
|
{% elif states.device_tracker.life360_kat_stone.attributes.driving == True %}
|
|
Flue Network
|
|
{% else %}
|
|
Lost
|
|
{%- endif %}
|
|
{% elif is_state('person.katherine', 'Sprouts') %}
|
|
Grocery Store
|
|
{% elif is_state('person.katherine', 'Kroger1') %}
|
|
Grocery Store
|
|
{% elif is_state('person.katherine', 'Kroger2') %}
|
|
Grocery Store
|
|
{% elif is_state('person.katherine', 'Home Depot') %}
|
|
Home Improvement Store
|
|
{% elif is_state('person.katherine', 'Lowes') %}
|
|
Home Improvement Store
|
|
{% elif is_state('person.katherine', 'Walmart') %}
|
|
Super Store
|
|
{% elif is_state('person.katherine', 'Target') %}
|
|
Super Store
|
|
{% else %}
|
|
{{ states.person.katherine.state }}
|
|
{%- endif %}
|
|
- platform: template
|
|
sensors:
|
|
kat_driving:
|
|
friendly_name: "Kat Driving"
|
|
unit_of_measurement: ''
|
|
value_template: >-
|
|
{%- if states.device_tracker.life360_kat_stone.attributes.moving == True %}
|
|
'on'
|
|
{% elif states.device_tracker.life360_kat_stone.attributes.driving == True %}
|
|
'on'
|
|
{% else %}
|
|
'off'
|
|
{% endif %}
|
|
- platform: mqtt
|
|
name: "Family Status"
|
|
state_topic: "house/family/status"
|
|
payload_available: "online"
|
|
payload_not_available: "offline"
|
|
- platform: template
|
|
sensors:
|
|
jeff_home:
|
|
value_template: >-
|
|
{{ is_state('device_tracker.jeffreystonesiphone', 'home')
|
|
or is_state('device_tracker.hass_jeffsiphone', 'home')
|
|
or is_state('device_tracker.life360_jeffrey_stone', 'home') }}
|
|
- platform: template
|
|
sensors:
|
|
kat_home:
|
|
value_template: >-
|
|
{{ is_state('device_tracker.katherinestonesiphone', 'home')
|
|
or is_state('device_tracker.life360_kat_stone', 'home') }}
|
|
- platform: template
|
|
sensors:
|
|
family_home:
|
|
value_template: >-
|
|
{{ is_state('device_tracker.jeffreystonesiphone', 'home')
|
|
or is_state('device_tracker.hass_jeffsiphone', 'home')
|
|
or is_state('device_tracker.life360_jeffrey_stone', 'home')
|
|
or is_state('device_tracker.katherinestonesiphone', 'home')
|
|
or is_state('device_tracker.life360_kat_stone', 'home')
|
|
or is_state('sensor.family_status', 'Home') }}
|
|
|
|
automation:
|
|
- id: kat_arrives_zoo
|
|
alias: Kat Arrives at Zoo
|
|
initial_state: true
|
|
trigger:
|
|
- platform: zone
|
|
event: enter
|
|
zone: zone.zoo_atlanta
|
|
entity_id: person.katherine
|
|
action:
|
|
- service: input_boolean.turn_off
|
|
entity_id: input_boolean.kat_travel_monitor
|
|
- service: script.ah_report
|
|
data:
|
|
speech_message: 'Kat has arrived at worked.'
|
|
call_interuption: 1
|
|
|
|
- id: kat_leaves_zoo
|
|
alias: Kat Leaves Zoo Notification
|
|
initial_state: true
|
|
trigger:
|
|
- platform: zone
|
|
event: leave
|
|
zone: zone.zoo_atlanta
|
|
entity_id: person.katherine
|
|
condition:
|
|
action:
|
|
- service: input_boolean.turn_on
|
|
entity_id: input_boolean.kat_travel_monitor
|
|
- service: script.ah_report
|
|
data:
|
|
call_interuption: 1
|
|
call_kat_headed_home: 1
|
|
|
|
- id: '1550109528753'
|
|
alias: Jeff Is Heading Home
|
|
initial_state: true
|
|
trigger:
|
|
- platform: webhook
|
|
webhook_id: jeff_heading_home
|
|
condition: []
|
|
action:
|
|
- service: script.jeff_destination_home
|
|
- service: script.ah_report
|
|
data:
|
|
call_interurption: 1
|
|
call_jeff_headed_home: 1
|
|
|
|
- id: family_has_arrived
|
|
alias: Family Has arrived
|
|
trigger:
|
|
- entity_id: sensor.family_status
|
|
from: Away
|
|
platform: state
|
|
to: Home
|
|
- entity_id: person.jeffrey
|
|
event: enter
|
|
platform: zone
|
|
zone: zone.home
|
|
- entity_id: person.katherine
|
|
event: enter
|
|
platform: zone
|
|
zone: zone.home
|
|
condition:
|
|
- condition: state
|
|
entity_id: sensor.family_status
|
|
state: Away
|
|
action:
|
|
- service: script.vacation_canceled
|
|
- service: script.appliances_on
|
|
- service: script.standby
|
|
- service: script.washer_finished_notification_audible
|
|
- service: alarm_control_panel.alarm_disarm
|
|
entity_id: alarm_control_panel.ah_base_station
|
|
initial_state: true
|
|
|
|
- id: family_has_left
|
|
alias: Family Has Left
|
|
initial_state: true
|
|
trigger:
|
|
- entity_id: sensor.family_status
|
|
from: Home
|
|
platform: state
|
|
to: Away
|
|
condition:
|
|
- condition: state
|
|
entity_id: input_boolean.guest_mode
|
|
state: 'off'
|
|
action:
|
|
- service: script.appliances_off
|
|
- service: script.inside_all_off
|
|
- service: script.security_check_garage
|
|
- service: script.security_check_zones
|
|
- service: script.lockdown
|
|
- service: script.lockdown_issue
|
|
- service: script.all_fans_off
|
|
- service: alarm_control_panel.alarm_arm_away
|
|
entity_id: alarm_control_panel.ah_base_station
|
|
|
|
- id: jeff_is_home
|
|
alias: Jeff is Home
|
|
initial_state: true
|
|
trigger:
|
|
- entity_id: person.jeffrey
|
|
event: enter
|
|
platform: zone
|
|
zone: zone.home
|
|
action:
|
|
- service: script.family_is_home
|
|
- service: script.jeff_destination_na
|
|
- service: script.driveway_on
|
|
- entity_id: input_boolean.jeff_travel_monitor
|
|
service: input_boolean.turn_off
|
|
|
|
- id: jeff_arrives_summit
|
|
alias: Jeff Arrives At Summit
|
|
trigger:
|
|
- entity_id: person.jeffrey
|
|
event: enter
|
|
platform: zone
|
|
zone: zone.summit
|
|
action:
|
|
- service: script.text_notify
|
|
data:
|
|
who: "kat"
|
|
message: "Jeff has arrived at Summit"
|
|
initial_state: true
|
|
|
|
- id: jeff_arrives_summit_notification
|
|
alias: Notify Kat Jeff At Summit
|
|
trigger:
|
|
- entity_id: person.jeffrey
|
|
event: enter
|
|
platform: zone
|
|
zone: zone.summit
|
|
action:
|
|
- service: script.jeff_destination_na
|
|
initial_state: true
|
|
|
|
- id: jeff_leaves_summit
|
|
alias: Jeff Leaves Summit
|
|
initial_state: true
|
|
trigger:
|
|
- entity_id: person.jeffrey
|
|
event: leave
|
|
platform: zone
|
|
zone: zone.summit
|
|
action:
|
|
- service: input_boolean.turn_off
|
|
entity_id: input_boolean.jeff_traffic_alert_home
|
|
|
|
- id: kat_is_home
|
|
alias: Kat is Home
|
|
initial_state: true
|
|
trigger:
|
|
- entity_id: person.katherine
|
|
event: enter
|
|
platform: zone
|
|
zone: zone.home
|
|
action:
|
|
- service: script.family_is_home
|
|
- service: script.driveway_on
|
|
- service: input_boolean.turn_off
|
|
entity_id: input_boolean.kat_travel_monitor
|
|
|
|
- id: welcome_home
|
|
alias: Welcome Home
|
|
trigger:
|
|
- platform: state
|
|
entity_id:
|
|
- device_tracker.jeffreystonesiphone
|
|
- device_tracker.katherinestonesiphone
|
|
from: 'not_home'
|
|
to: 'home'
|
|
condition:
|
|
- condition: state
|
|
entity_id: sensor.family_status
|
|
state: Home
|
|
action:
|
|
- service: script.ah_report
|
|
data_template:
|
|
welcome_home: >
|
|
{% set person = trigger.to_state.attributes.friendly_name %}
|
|
{%- macro greeting_sentence(person) -%}
|
|
{{ [
|
|
person + " has arrived.",
|
|
person + " is in the neighborhood.",
|
|
person + " is arriving.",
|
|
"My sensors are picking up the presence of additional humans. " ~ person +" has been identified as home.",
|
|
person + " has finally made it home."
|
|
] | random }}
|
|
{%- endmacro -%}
|
|
{{greeting_sentence(person)}}
|
|
call_interuption: 1
|
|
|
|
|
|
script:
|
|
jeff_destination_zoo:
|
|
sequence:
|
|
- service: mqtt.publish
|
|
data:
|
|
topic: jeff/driving/destination
|
|
payload: Zoo
|
|
retain: true
|
|
jeff_destination_summit:
|
|
sequence:
|
|
- service: mqtt.publish
|
|
data:
|
|
topic: jeff/driving/destination
|
|
payload: Summit
|
|
retain: true
|
|
jeff_destination_none:
|
|
sequence:
|
|
- service: mqtt.publish
|
|
data:
|
|
topic: jeff/driving/destination
|
|
payload: none
|
|
retain: true
|
|
jeff_destination_na:
|
|
sequence:
|
|
- service: mqtt.publish
|
|
data:
|
|
topic: jeff/driving/destination
|
|
payload: na
|
|
retain: true
|
|
jeff_destination_home:
|
|
sequence:
|
|
- service: mqtt.publish
|
|
data:
|
|
topic: jeff/driving/destination
|
|
payload: Home
|
|
retain: true
|
|
jeff_destination_harbins:
|
|
sequence:
|
|
- service: mqtt.publish
|
|
data:
|
|
topic: jeff/driving/destination
|
|
payload: Harbins
|
|
retain: true
|
|
kat_destination_na:
|
|
sequence:
|
|
- service: mqtt.publish
|
|
data:
|
|
topic: kat/driving/destination
|
|
payload: na
|
|
retain: true |