# Presence Detection Package # ----------------------------------------------------------------------------- # Person Setup (handled by UI) person: # ----------------------------------------------------------------------------- # Person/Device Tracker Customization homeassistant: customize: person.jpk: entity_picture: https://gravatar.com/avatar/e78e623948f3675cf1c51544f9bec928 sensor.jp_presence_status: entity_picture: https://gravatar.com/avatar/e78e623948f3675cf1c51544f9bec928 # ----------------------------------------------------------------------------- # Proximity Sensors for Zones (deprecated in HA 2024.2) # proximity: # home: # devices: # - device_tracker.jen_iphone # - device_tracker.j_p_s_iphone # tolerance: 50 # unit_of_measurement: km # jpk: # devices: # - device_tracker.j_p_s_iphone # tolerance: 50 # unit_of_measurement: km # jen: # devices: # - device_tracker.jen_iphone # tolerance: 50 # unit_of_measurement: km # ----------------------------------------------------------------------------- # Extended Presence States input_select: jp_presence_state: name: J.P. options: - Home - Just Arrived - Just Left - Away - Extended Away jen_presence_state: name: Jen options: - Home - Just Arrived - Just Left - Away - Extended Away house_presence_state: name: House Occupancy options: - Home - Just Arrived - Just Left - Away - Extended Away # ----------------------------------------------------------------------------- # Extended Presence Sensors binary_sensor: # Home / Not-Home Sensors - platform: template sensors: jp_presence: friendly_name: J.P. device_class: presence value_template: "{{ is_state('person.jpk', 'home') }}" jen_presence: friendly_name: Jen device_class: presence value_template: "{{ is_state('person.jen', 'home') }}" house_presence: friendly_name: House device_class: presence value_template: >- {{ is_state('person.jpk', 'home') or is_state('person.jen', 'home') }} sensor: # Extended Presence Status - platform: template sensors: jp_presence_status: value_template: '{{ states.input_select.jp_presence_state.state }}' friendly_name_template: 'J.P. Presence Status' - platform: template sensors: jen_presence_status: value_template: '{{ states.input_select.jen_presence_state.state }}' friendly_name_template: 'Jen Presence Status' - platform: template sensors: house_presence_status: value_template: '{{ states.input_select.house_presence_state.state }}' friendly_name_template: 'House Presence Status' # ----------------------------------------------------------------------------- # Automations for Presence Detection automation: # Handle Just Arrived/Just Left State Transitions - alias: Mark Person as Just Arrived trigger: - platform: state entity_id: person.jpk to: 'home' - platform: state entity_id: person.jen to: 'home' - platform: state entity_id: binary_sensor.house_presence to: 'on' mode: queued action: - service: input_select.select_option data_template: entity_id: > {% if trigger.entity_id == 'person.jpk' %} input_select.jp_presence_state {% elif trigger.entity_id == 'person.jen' %} input_select.jen_presence_state {% elif trigger.entity_id == 'binary_sensor.house_presence' %} input_select.house_presence_state {% else %} {% endif %} option: > {% if trigger.entity_id == 'person.jpk' %} {% if states.input_select.jp_presence_state == 'Just Left' %} Home {% else %} Just Arrived {% endif %} {% elif trigger.entity_id == 'person.jen' %} {% if states.input_select.jen_presence_state == 'Just Left' %} Home {% else %} Just Arrived {% endif %} {% elif trigger.entity_id == 'binary_sensor.house_presence' %} {% if states.input_select.house_presence_state == 'Just Left' %} Home {% else %} Just Arrived {% endif %} {% else %} {% endif %} - alias: Mark Person as Just Left trigger: - platform: state entity_id: person.jpk from: 'home' - platform: state entity_id: person.jen from: 'home' - platform: state entity_id: binary_sensor.house_presence from: 'on' mode: queued action: - service: input_select.select_option data_template: entity_id: > {% if trigger.entity_id == 'person.jpk' %} input_select.jp_presence_state {% elif trigger.entity_id == 'person.jen' %} input_select.jen_presence_state {% elif trigger.entity_id == 'binary_sensor.house_presence' %} input_select.house_presence_state {% else %} {% endif %} option: 'Just Left' # Handle Timed State Changes to Home/Away/Extended Away - alias: Mark Person as Home trigger: - platform: state entity_id: input_select.jp_presence_state to: 'Just Arrived' for: minutes: 5 - platform: state entity_id: input_select.jen_presence_state to: 'Just Arrived' for: minutes: 5 - platform: state entity_id: input_select.house_presence_state to: 'Just Arrived' for: minutes: 5 mode: queued action: - service: input_select.select_option data_template: entity_id: '{{ trigger.entity_id }}' option: 'Home' - alias: Mark Person as Away trigger: - platform: state entity_id: input_select.jp_presence_state to: 'Just Left' for: minutes: 5 - platform: state entity_id: input_select.jen_presence_state to: 'Just Left' for: minutes: 5 - platform: state entity_id: input_select.house_presence_state to: 'Just Left' for: minutes: 5 mode: queued action: - service: input_select.select_option data_template: entity_id: '{{ trigger.entity_id }}' option: 'Away' - alias: Mark Person as Extended Away trigger: - platform: state entity_id: input_select.jp_presence_state to: 'Away' for: hours: 24 - platform: state entity_id: input_select.jen_presence_state to: 'Away' for: hours: 24 - platform: state entity_id: input_select.house_presence_state to: 'Away' for: hours: 24 mode: queued action: - service: input_select.select_option data_template: entity_id: '{{ trigger.entity_id }}' option: 'Extended Away'