blueprint: name: Person Alert Monitor - 2024-06-08 author: SirGoodenough description: > This BluePrint will monitor a person or persons, and when they 'enter' or 'leave' the zone or zones you pick, it will trigger an action for both enter and leave phases. Yes, it will watch multiple people and multiple zones at the same time! I use this BluePrint to follow family members around during their day so that the family members at home know where their loved ones are. I used this to eliminate over 2 dozen separate Automations and Scripts in my Home set-up. The multiple person/multiple zone watch ability is the key. The monitored areas need to be set up as zones in Home Assistant. SEE: [HA ZONES LINK](https://www.home-assistant.io/integrations/zone/) [![Open your Home Assistant instance and show your zones.](https://my.home-assistant.io/badges/zones.svg)](https://my.home-assistant.io/redirect/zones/) The person needs LAT/LOG software running to report their location. I use Life360, but the Home Assistant App running on their phone will also work. There are likely other location monitoring methods but I am not aquainted with any of them. SEE: [![Open your Home Assistant instance and show your people.](https://my.home-assistant.io/badges/people.svg)](https://my.home-assistant.io/redirect/people/) [LIFE360 INTEGRATION LINK ](https://www.home-assistant.io/integrations/life360/) [PERSON INTEGRATION LINK ](https://www.home-assistant.io/integrations/person/) [Community link for this blueprint](https://community.home-assistant.io/t/person-alert-blueprint/542209) ## 🗿Notice👮🏿‍♂️: * Copies of the original Blueprint that were converted via the 'Take Control' feature or other means are officially not supported by me. * I may or may not be able to support you when you have a problem after you make changes to my code, as some of the code is no longer mine. * I & my license also require attribution as a link back to the original should you use this code in your own creation. * [Here is a link to my license & the original github post](https://github.com/SirGoodenough/HA_Blueprints?tab=License-1-ov-file) expected to be followed & referenced as attribution should you use this code elsewhere. source_url: https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/Person_Alert_Blueprint.yaml domain: automation homeassistant: min_version: 2024.6.0 input: required_inputs: name: Required input 👀 icon: mdi:alert-box collapsed: false description: > These inputs are required for the blueprint to function and must be filled in. input: people2monitor: name: Person or People to follow description: > Select the Person you want this BP to trigger on for this action. Multiples are allowed. selector: entity: multiple: true filter: - domain: person zone2monitor: name: Zone to watch description: > Select the Zone you want this BP to trigger on when this person enters or leaves it. If you want to select all the zones you have listed in this HA instance then use the default. If you want to pick individual zones be sure to override the default because it auto-picks all. Multiples are allowed. default: '{{ states.zone | map(attribute="entity_id") | list }}' selector: entity: multiple: true filter: - domain: zone enter_action: name: Enter the Zone Action description: > Build the action here that you want to happen when they enter this zone. There is a 'Persistent Notification' example in [The Docs File.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/Person_Alert_Blueprint.md) If you want to do a TTS I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/tts_All_Message_Script_Blueprint.yaml) If you want to play a sound effect or music I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/play_media_file_script.yaml) There is also a built-in [Actionable Notification Script Blueprint](https://github.com/home-assistant/core/blob/master/homeassistant/components/script/blueprints/confirmable_notification.yaml) that could work here. It is included with Home Assistant. default: [] selector: action: {} leave_action: name: Leave the Zone Action description: > Build the action here that you want to happen when they leave this zone. There is a 'Persistent Notification' example in [The Docs File.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/Person_Alert_Blueprint.md) If you want to do a TTS I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/tts_All_Message_Script_Blueprint.yaml) If you want to play a sound effect or music I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/play_media_file_script.yaml) default: [] selector: action: {} jump_action: name: Jump known zone to known zone Action description: > Build the action here that you want to happen when both the zone they left and the zone they entered is known, but not the same zone. There is a 'Persistent Notification' example in [The Docs File.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/Person_Alert_Blueprint.md) If you want to do a TTS I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/tts_All_Message_Script_Blueprint.yaml) If you want to play a sound effect or music I suggest [This Blueprint.](https://github.com/SirGoodenough/HA_Blueprints/blob/master/Scripts/play_media_file_script.yaml) default: [] selector: action: {} optional_parameters: name: Optional parameters🤓 icon: mdi:alert-octagon-outline collapsed: true description: > These inputs set optional parameters that allow you to customize the intended actions. Read the individual descriptions for more details. The Blueprint will work if no changes are made to this section. input: hold_period: name: Hold Period description: > Sometimes devices want to disconnect and connect often, Home Assistant deals with this using a considered-on or considered-off time. This is the same thing. Sometimes you don't need anything here. I suggest you try the default 00:00:00 here and add time if you need it. Using this means the automation will be running the entire time period that you select and will not be available for other triggers. This time delay is not effective if automation is in parallel mode. default: hours: 0 minutes: 0 seconds: 0 selector: duration: enable_time: name: Time of day to begin action(s) description: > Set this for the time of day you want to allow action(s) to begin. Leave as is to always be enabled. default: 00:00:00 selector: time: {} disable_time: name: Time of day to end action(s) description: > Set this for the time of day you want action(s) to end. Leave as is to always be enabled. default: 00:00:00 selector: time: {} weekday: name: Day of the week to allow action(s) description: > Change options if you want to include or exclude any specific day. All days are selected by default. default: - mon - tue - wed - thu - fri - sat - sun selector: select: options: - label: Monday value: mon - label: Tuesday value: tue - label: Wednesday value: wed - label: Thursday value: thu - label: Friday value: fri - label: Saturday value: sat - label: Sunday value: sun custom_value: false multiple: true additional_conditions: name: Additional conditions description: | Extra conditions you may want to add to this automation (Example: Home occupied, TV on, etc) default: [] selector: condition: trigger: - platform: state id: Persons state has changed entity_id: !input people2monitor variables: people2monitor_var: !input people2monitor zone2monitor_var: !input zone2monitor friend_zone: > {% set ns = namespace(zone=[]) %} {% for z in zone2monitor_var %} {% set ns.zone = ns.zone + [states[z].attributes.friendly_name | lower] %} {% endfor %} {{ ns.zone }} to_state: '{{ trigger.to_state.state | lower }}' from_state: '{{ trigger.from_state.state | lower }}' condition: - alias: Make sure there even was a move condition: template value_template: '{{ to_state != from_state }}' - alias: Make sure it's not an I'm Lost move condition: template value_template: > {{ not to_state in ('unknown','unavailable','none','None','') and not from_state in ('unknown','unavailable','none','None','') }} - alias: Only allow execution within selected Hours / Weekdays condition: time after: !input 'enable_time' before: !input 'disable_time' weekday: !input 'weekday' - alias: User pick condition: !input additional_conditions action: - alias: Determine if there was an actionable event choose: - conditions: - alias: Has Person arrived at Zone? condition: and conditions: - condition: template alias: person is in target zone value_template: '{{ to_state in friend_zone }}' - condition: template alias: person is arriving from another zone value_template: '{{ not from_state in friend_zone }}' sequence: !input enter_action - conditions: - alias: Person left Zone? condition: and conditions: - alias: Person was in Zone condition: template value_template: '{{ from_state in friend_zone }}' - alias: Person not in zone now condition: template value_template: '{{ not to_state in friend_zone }}' sequence: !input leave_action - conditions: - alias: Person jumped from known zone to known zone condition: and conditions: - alias: Person left known zone condition: template value_template: '{{ from_state in friend_zone }}' - alias: Person arrived in known zone condition: template value_template: '{{ to_state in friend_zone }}' sequence: !input jump_action - alias: Time delay to hold on devices that disconnect often (if needed) delay: !input hold_period mode: queued max: 10