šŸ§Æ Person_Alert_Blueprint

This is 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!

:bookmark_tabs: Changelog

  • 2024-06-08: Blueprint Input Sections for enhanced Descriptions.
    • (Documentation change 2-7-2024 to add License notice. Changes only to Descriptions.)
  • 2024-01-24: Changed zones default to auto-list all zones.
  • 2023-08-07: Updates for Home Assistant 2023.8
    • Selector syntax change
    • Condition Selector addition (where applicable)
    • MQTT Discovery name changes (where applicable)
    • Clean-up code formatting
  • 2023-05-11: Fix for some devices that think home is spelled Home. (IOS I thinkā€¦)
    • Issue link
    • Fix Typoā€™s in header and title. May affect your calling Automation (M not H)
  • 2023-03-01.1: Minor adjustments to sample script files for smoother operation
  • 2023-03-01: :tada: First release!

:crystal_ball: About this blueprint

Type of blueprint: AUTOMATION

What if I am having problems getting it going?

You can contact me for help, see the links below.

Why do I need this?

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
Open your Home Assistant instance and show your 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 acquainted with any of them. SEE:

Open your Home Assistant instance and show your people.

LIFE360 INTEGRATION LINK

PERSON INTEGRATION LINK

:moyai:License 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 expected to be followed & referenced as attribution should you use this code elsewhere.

:wrench: Configuration

Requirements

  • LAT/LOG software running to report person GPS location
  • The Person Integration has to have people set-up in Home Assistant
  • Zones set-up in Home Assistant to monitor

:card_index_dividers: Input fields

people2monitor/name: Person or People to follow
    Select the Person you want this BP to trigger 
    on for this action. Multiples are allowed.

zone2monitor/name: Zone to watch
    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.

hold_period/name: Hold Period
    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.

enter_action/name: Enter the Zone Action
    Build the action here that you want to 
    happen when they enter this zone. Samples 
    and examples below.

leave_action/name: Leave the Zone Action
    Build the action here that you want to 
    happen when they leave this zone. 
    Samples and examples below.

jump_action/name: Jump known zone to known zone Action
    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.

enable_time/name: Time of day to begin action(s)
    Set this for the time of day you want to 
    allow action(s) to begin.

disable_time/name: Time of day to end action(s)
    Set this for the time of day you want 
    action(s) to end.

weekday/name: Day of the week to allow action(s)
    Change options if you want to include or 
    exclude any specific day.

additional_conditions:
    Extra conditions you may want to add to this automation 
    (Example: Home occupied, TV on, etc)

:eyes: :airplane: Extended Information

For further information, reference these links.

My TTS Blueprint.

My Media Player Blueprint.

Home Assistant Actionable Notification Script Blueprint.

:magic_wand: How do I use this to send a Persistent Notification

I have created a sample script as one possible example of how to do this. I grabs values from the Automation itself and generates a Persistent Notification that the trigger person entered or left the triggered zone. The notification is set to clear itself. You can use this as-is or use it to help you write the exact action you want to take when the Automation calls for it.

Sample file here: Sample file containing Persistent Notification sample code

For this to work you will need Persistent Notification Integration. You must have this integration enabled on your system to run the automation, since the these notifications are generated by this integration. This should be activated in your HA Instance by default, so unless you tweaked the default configuration, youā€™re good to go.

HA Persistent Notification Integration Docs

:microphone: How do I use this to send a message to my Google Speakers

I have created a sample script as one possible example of how to do this. I grabs values from the Automation itself and generates a TTS message that the trigger person entered or left the triggered zone. It will also play an MP3 file that you provide to make the announcement more fun. You can use this as-is or use it to help you write the exact action you want to take when the Automation calls for it.

Sample file here: Sample file containing cloud_say & media_player sample code

Here is a link to the free sound file I used, but PLEASE download it to your local system and play it from there, donā€™t try to run it live from my Github. That just isnā€™t going to work properly and thatā€™s not the kind of bandwidth usage I signed up for.

For this to work you can use the provided Home Assistant integration(s) or install another TTS Integration. There are many available.

Home Assistant TTS Integration Documentation

:sun_with_face: :snowflake: Troubleshooting tip

If you are troubleshooting and you want to see more traces back when doing so, here is a TIP Iā€™ve found.
Manually edit the automation created with the ui editor (or manually with a text editor) and add the following to have this automation contain 10 traces instead of the normal 5. Then if the automation is triggering often, you can see the last 10 traces to help you decide what the issue is.
HA Docs on this here.

trace:
  stored_traces: 10

:envelope_with_arrow: Version Updates

Updates will be published on my GIT repository with the rest of my Home Assistant Blueprint collection.

:envelope_with_arrow: There is not an official version control system for Blueprints. However I have found something that comes pretty close. It is not perfect, but for MOST Blueprints, it does just fine. I encourage you to check this script out and use it to easily check if I have updated this blueprint. :link:koter84 Blueprint Update Script

Please Click the :orange_heart: at the end of this top Post if you find this Useful

:calling: Software to Download :floppy_disk:

HA link to download blueprint: Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Direct link to download Blueprint: https://github.com/SirGoodenough/HA_Blueprints/blob/master/Automations/Person_Alert_Blueprint.yaml

:globe_with_meridians: All My Blueprints

Link to ALL my Blueprints

https://github.com/SirGoodenough/HA_Blueprints/blob/master/README.md

:man_juggling:t5: Contact Links or see my other work

What are we Fixing Today Homepage / Website: https://www.WhatAreWeFixing.Today/

Channel Link URL: (WhatAreWeFixingToday) https://bit.ly/WhatAreWeFixingTodaysYT

Discord Guild: (Sir_Goodenough#9683) WhatAreWeFixingToday?

:cheese: If you want to support me

Buy me Coffee: https://www.buymeacoffee.com/SirGoodenough

PayPal one-off donation link: PayPal.Me

#WhatAreWeFixingToday

#SirGoodEnough

6 Likes

I am trying to set this Blueprint up but when I am creating a notification to be sent out for someone leaving a zone I am having trouble getting it show the previous zone the person is leaving from. I thought it would be the variable ā€œfrom_stateā€ but the notification doesnā€™t show the previous zone or any info. Can you help me figure out where I am going wrong?

I set it up to only announce a previous zone that is also in the zone list that the automation knows about. Otherwise it will most often state from away to ā€¦

You may have to look at the code and build your own version if this doesnā€™t work for you.

I have basically all the zones in my list listed for everyone, about 15 of them.

  description: Alert when we go places
  trace:
    stored_traces: 20
  use_blueprint:
    path: SirGoodenough/Person_Alert_Blueprint.yaml
    input:
      people2monitor:
      - person.jen
      zone2monitor:
      - zone.home
      - zone.katy_s_kloset
      - zone.follicle_assembly_building
      - zone.feed_store
      - zone.nail_shop2
      - zone.belva
      - zone.clinic
      - zone.expo
      - zone.lakewood
      - zone.mountain
      - zone.shawano
      - zone.somerhome
      - zone.suring
      - zone.townsend
      - zone.rose_estate
      - zone.wisconsin_illinois_border
      enter_action:

It will announce arriving or leaving for any of these if the the other is unknown, or announce both of them if both are known.

The other thing you may be running into is the hold period.
Also the device takes time to sample and send the change to Home Assistant. That all has to happen before HA knows to do anything. Often we get home, out of the car, and take off our coats before the message pops that we are home.

1 Like

Hi
not sure what is wrong but i do not get any information for leaving and coming HOME.
Other ones work ā€¦ well mostly.
any idea?

for example
my daughter came back home 20:09.53. I can see in home assistant ā€œWas detected at homeā€
Screenshot 2023-05-02 201845

blueprint

What does your BluePrint calling Automation look? do you have the home zone in the monitor list?

      zone2monitor:
      - zone.home

Also there is a settling time (hold period) that makes sure the person is in a zone for a time period you set before it allows action.

      hold_period:
        hours: 0
        minutes: 5
        seconds: 0

5 minutes has been working for me but I believe I miss a few, however I still hear a few left home, arrived home when they were here but rebooted their phone or something or the phone went brain dead for a bitā€¦

Hi
Yes. All the zones are setup correctly.
I left home today and didnā€™t get notification. But i got one when I arrived at work.



You will have to look at what the variables are on a trace like the first one there where you think it should trigger but doesnā€™t. Possibly a capitalization problem, some timing thing, hard to guess without it happening to me. Since it seems to work except for a single zone, it comes down to the details.

Also, to everyone, I added in some code I had missing in the samples. I forgot the sequence section of the helper script last time I edited the samples. It should all be there now. Thanks to @Valiante for pointing that out. (I hope you are the same person that got to me on Discord!!)

@Sir_Goodenough - yes it was me! :blush:

@Chaos666uk - I was experiencing the same thing. It turned out to be the case-sensitive nature of YAML, and the condition deciding Home <> home. Iā€™ve just made a fork & a pull request on the repo that should sort it by converting the variables to lowercase before theyā€™re compared.

Can you explain then how to update the Blue Print to make the changes.

I have been using the blueprint for almost two weeks and have problems.
I have many zones created and the all trigger as expected, but here is my problem that I do not know where to look to fix it.

I have a weekly Drā€™s appointment for treatment.
When I went yesterday my phone startedto go ā€œcrazyā€. Within a span of 13 minutes I had over 70 messages saying I was enetering home, leaving home, and entering and leaving the Drā€™s.

This also happens at other places as well. It will tag me as enetering and leaving multiple times in the space of a few minutes.

I have gone back to the companion app (android) and looked at my settings, but am unsure what might be the conflict.

Can anyone shed some light on this.

Also on my automation page for the blue print there is a typo

Person Alert Honitor - 2023-03-01.1

I think it should be

Person Alert "M"onitor - 2023-03-01.1

Thank you.

Certainly. I simply edited the variables section to convert them to lowercase on the fly, thus:

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 }}'
1 Like

Issue and PR created for this. I will look at it shortly.

@carltonb if you had the thing shifting zone 2 zone z zone really fast, you may want to increase the Hold Period. This thing is reacting to zone changes on the person listed. It does not generate zine changes. My only other thought is the phone was off line, and when it came back on line it caught up?

The PR is to fix problems with upper/lower case and some zone changes not being sceen because the value is case sensitive.

And thanks for the typo, my old eyes didnā€™t see it :cry:

Posted update version for above issue:

I will change the hold period and see what happens.
Thank you.

1 Like

Is there a way to write multiple messages and choose which one to send based on the person triggering the action? Alternatively, is it possible to customize the message with the name of the person triggering the action?

I would like to send a Telegram message to the person triggering the action in this way:

service: notify.telegram_person_1
data:
  message: Welcome back home, (name of person_1)!

There are sample files on how to do similar things in the documentation.

Nice blueprint, wanted to use it to drill down my current automation.

So I use the blueprint as followed.

  • Added Person A and Person B to Zone Home.
  • When person leave zone Home, he turns on Alarm and turns off Heater.
  • Person A went to work, this triggered to Turn off the Heater and Turn on Alarm.
  • Result: Person B (not that technical) got the chills, goes down to turn on the heater, triggers the alarm.

So is it possible to make the following with this blueprint?

  • When no one is not in the zone2monitor, activate Alarm and turn off heater.
  • When 1 person enters the zone2monitor, disable Alarm and turn on the Heater.

At this moment it looks like when person A leaves home, the alarm is turned on and the heater is turned off.

This is not real hard to do. You should be able to pull this off without this BP with a bit more knowledge.
Know that the actual value of a zone entity is the number of people in it. So look at the home zone, if the value is 0, no one is home. Just make an automation based on that.

1 Like

BLUEPRINT UPDATED:

Jump known zone to known zone Action

I think this is what i want to use, but only one direction. Hoping you could confirm/deny/ridicule me on how to do this.

Basically when my children leave our house to go to school I want it to shut off their room.
When they return home from school i want it to do something else.

Do i need a separate automations?

  1. For ChildX leaves house
  2. ChildX jumps from school to home? this is where iā€™m confused, jump seems to be a any-to-any relationship? can I do it just one direction?