############################################################################### # @author : Jeffrey Stone # @date : 02/19/2019 # @package : Presence # @description : A Collection of Presence Related Trackers and Sensors ############################################################################### # Testing Proximity Sensors proximity: home_jeff: devices: - device_tracker.life360_jeffrey_stone zone: home tolerance: 5 unit_of_measurement: mi home_kat: devices: - device_tracker.life360_kat_stone zone: home tolerance: 5 unit_of_measurement: mi home: devices: - device_tracker.life360_jeffrey_stone - device_tracker.life360_kat_stone zone: home tolerance: 5 unit_of_measurement: mi 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.skylar', 'home') %} home {%- elif is_state('input_boolean.skylar_school', 'on') or is_state('person.skylar', 'Starling')%} school {%- elif is_state('sensor.jeff_location', 'home') and is_state('sensor.kat_location', 'home') and is_state('input_boolean.skylar_school', 'off')%} home {%- elif is_state('sensor.jeff_location', 'Summit') and is_state('input_boolean.skylar_school', 'off')%} {{ states.sensor.kat_location.state }} {%- elif is_state('sensor.kat_location', 'Zoo Atlanta') and is_state('input_boolean.skylar_school', 'off')%} {{ states.sensor.jeff_location.state }} {% 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.jeffreys_iphone_8', 'home') or is_state('device_tracker.jeffreys_iphone_8_2', 'home') or is_state('device_tracker.life360_jeffrey_stone', 'home') }} - platform: template sensors: kat_home: value_template: >- {{ is_state('device_tracker.iphone', 'home') or is_state('device_tracker.life360_kat_stone', 'home') or is_state('device_tracker.iphone_2', 'home') }} - platform: template sensors: family_home: value_template: >- {{ is_state('device_tracker.jeffreys_iphone_8_2', 'home') or is_state('device_tracker.jeffreys_iphone_8_2', 'home') or is_state('device_tracker.life360_jeffrey_stone', 'home') or is_state('device_tracker.iphone', 'home') or is_state('device_tracker.iphone_2', 'home') or is_state('device_tracker.life360_kat_stone', 'home') or is_state('sensor.family_status', 'Home') }} automation: - id: skylar_is_awake alias: Skylar is Awake initial_state: true trigger: - platform: state entity_id: binary_sensor.skylar_room_occupancy to: 'on' from: 'off' condition: - condition: time after: '05:00:00' before: '08:30:00' - condition: state entity_id: input_boolean.skylar_awake state: 'off' action: - service: input_datetime.set_datetime entity_id: input_datetime.skylar_awake_at data: time: "{{ now().strftime('%H:%M') }}" - service: input_boolean.turn_on entity_id: input_boolean.skylar_awake - 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 - wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - service: script.jarvis_voice data_template: who: '{{ states.sensor.room_audio.state }}' message: 'Kat has arrived at work.' - 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 action: - service: input_boolean.turn_on entity_id: input_boolean.kat_travel_monitor - wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - service: script.jarvis_voice data_template: who: '{{ states.sensor.room_audio.state }}' message: Katherine appears to be headed home. Based on current traffic conditions, she should be here in {{states.sensor.kat_ett_home.attributes.duration | round}} minutes. - 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 - wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}" - service: script.jarvis_voice data_template: who: '{{ states.sensor.room_audio.state }}' message: Jeff appears to be headed home. Based on current traffic conditions, he should be here in {{states.sensor.jeff_ett_home.attributes.duration | round}} minutes. - id: jeff_heading_to_work alias: Jeff Is Heading To Work initial_state: true trigger: - platform: webhook webhook_id: jeff_heading_work condition: [] action: - service: script.jeff_destination_summit - id: skylar_at_school alias: Skylar is at School trigger: - entity_id: device_tracker.life360_jeffrey_stone event: enter platform: zone zone: zone.starling - entity_id: device_tracker.life360_kat_stone event: enter platform: zone zone: zone.starling condition: condition: time after: '07:25:00' before: '09:00:00' weekday: - mon - tue - wed - thu - fri action: - service: input_boolean.turn_on entity_id: input_boolean.skylar_school - service: switch.turn_off entity_id: switch.forest initial_state: true - id: skylar_left_school alias: Skylar left School trigger: - entity_id: device_tracker.life360_jeffrey_stone event: leave platform: zone zone: zone.starling - entity_id: device_tracker.life360_kat_stone event: leave platform: zone zone: zone.starling condition: condition: time after: '14:45:00' before: '15:30:00' weekday: - mon - tue - wed - thu - fri action: - service: input_boolean.turn_off entity_id: input_boolean.skylar_school initial_state: true ######################################################### # - id: family_has_arrived # alias: Family Has arrived # trigger: # - platform: webhook # webhook_id: home_webhook # - entity_id: sensor.family_status # from: Away # platform: state # to: Home # - entity_id: group.family # from: not_home # platform: state # to: home # - entity_id: device_tracker.mal # from: not_home # platform: state # to: home # mode: single # condition: # - condition: state # entity_id: sensor.family_status # state: Away # action: # - service: script.family_is_home # 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 # - platform: webhook # webhook_id: away_webhook # - entity_id: group.family # from: home # platform: state # to: not_home # mode: single # condition: # - condition: state # entity_id: input_boolean.guest_mode # state: 'off' # action: # - service: script.family_is_away ######################################################### # - id: jeff_is_home # alias: Jeff is Home # initial_state: true # trigger: # - entity_id: person.jeffrey # event: enter # platform: zone # zone: zone.home # mode: single # 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 # - delay: # minutes: 2 # - id: kat_is_home # alias: Kat is Home # initial_state: true # trigger: # - entity_id: person.katherine # event: enter # platform: zone # zone: zone.home # mode: single # action: # - service: script.family_is_home # - service: script.driveway_on # - service: input_boolean.turn_off # entity_id: input_boolean.kat_travel_monitor # - delay: # minutes: 2 ######################################################## - 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: welcome_home alias: Welcome Home mode: restart trigger: - platform: state entity_id: - person.jeffrey - person.katherine - person.uncle_matt - person.papa - person.skylar from: 'not_home' to: 'home' action: - service: group.set data: object_id: "arriving" add_entities: >- {{ trigger.to_state.entity_id }} - service: script.standby - service: script.washer_finished_notification_audible - wait_template: "{{ states.binary_sensor.kitchen_door.state == 'on' }}" timeout: '00:01:00' - delay: '00:02:00' - service: script.jarvis_voice data_template: who: main message: > {% set person = expand('group.arriving')|map(attribute='name')|join(' and ') %} {% set peoplecount = expand('group.arriving') | count %} {% if peoplecount == 1 %} {% set is_are = ' is ' %} {% else %} {% set is_are = ' are ' %} {% endif %} {%- macro greeting_sentence(person, is_are) -%} {{ [ person + " has arrived.", person ~ is_are + " in the neighborhood.", person ~ is_are + " arriving.", "My sensors are picking up the presence of additional humans. " ~ person +" has been identified as home.", "Welcome back home " ~ person, "Guess who is home?" ~ person ~ is_are, "I am sensing a disturbance in the force. " ~ person +" must be home!", person ~ is_are + "now in the house.", person ~ "! You are home!", person ~ is_are + " now here. Hash tag Welcome Home.", person ~ is_are + " now here. Hash tag Home.", person ~ is_are + " now here. Hash tag Smart Home.", "I know a secret! " ~ person ~ is_are +" home!", "Just a quick announcement. " ~ person +" has arrived!", "Hey" ~ person + "! High Five! Glad you are finally home.", "Just a quick announcement. " ~ person +" has arrived!", person + " has finally made it home." ] | random }} {%- endmacro -%} {{greeting_sentence(person)}} - service: group.set data: object_id: "arriving" entities: [] - id: guests_have_arrived alias: Guests have arrived trigger: - entity_id: person.papa event: enter platform: zone zone: zone.home - entity_id: person.uncle_matt event: enter platform: zone zone: zone.home action: - service: script.standby - service: script.family_is_home - service: input_boolean.turn_on entity_id: input_boolean.guest_mode initial_state: true - id: disable_bad_traffic_home_jeff alias: Disabling Jeff Bad Traffic Home initial_state: true trigger: - platform: numeric_state entity_id: sensor.jeff_ett_home below: 40 - platform: state entity_id: sensor.jeff_destination to: Home condition: - condition: state entity_id: input_boolean.jeff_traffic_alert_home state: 'on' action: - service: input_boolean.turn_off entity_id: input_boolean.jeff_traffic_alert_home script: family_is_home: sequence: - condition: state entity_id: sensor.family_status state: Away - service: script.standby - service: script.washer_finished_notification_audible - service: mqtt.publish data: topic: house/family/status payload_template: Home retain: true family_is_away: sequence: - condition: state entity_id: sensor.family_status state: Home - service: script.appliances_off - service: scene.turn_on entity_id: scene.lights_out - service: script.security_check_garage - service: script.security_check_zones - service: script.lockdown - service: script.lockdown_issue - service: scene.turn_on entity_id: scene.all_fans_off - service: mqtt.publish data: topic: house/family/status payload_template: Away retain: true 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 reset_skylar_sensors: sequence: - delay: 02:00:00 - service: input_datetime.set_datetime entity_id: input_datetime.skylar_awake_at data: time: "00:00:00" - service: input_boolean.turn_off entity_id: input_boolean.skylar_awake