🧯 Device_tracker Monitor & Notifier

This Blueprint monitors device_tracker entities that you choose & notifies you if they go offline. Then it gives you the opportunity to devise an action to deal with it. It started as a pfSense centered project but any device_tracker that has a state of home when it is running and something else when it is not available will work with this.

:bookmark_tabs: Changelog

  • 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-03-01: Add Author Tag. Bump HA required Version to 2023-3-0
  • 2022-02-12: Added 4 levels of optional delay to make this useful for firing restarts.
    • Redid the Instruction file to new format.
    • Added sample code :nut_and_bolt: to turn this into an entity restart machine.
    • This update will work with an automation created with the last version.
  • 2022-12-12: Add Update Method Note, minor code change.
    • Name of Blueprint may have changed meaing you have to re-download with a new link.
    • If name changed, it is similar. Variables have not changed.
  • 2022-12-10: :tada: First Released Version.

: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?

In it’s simplest form, this blueprint will monitor an entity and put up a persistent notification that the entity is no longer home.

This is intended to be used with pfSense HACS Integration: GitHub - travisghansen/hass-pfsense: pfSense integration with Home Assistant. However it could be used with any device tracker that reports home when the device is up and something else when it isn’t.

It will create a persistent notification when triggered. Triggers / notifications can be enabled for a time period each day and/or for specific days of the week. There is also the ability to roll 4 levels of your own specific notification or other action as action statements. These are optional and default to doing nothing when you start.

I use this blueprint to drive a restart automation to make sure my MOCA adapters that feed my garage stay connected. They are a bit finicky. That code is included here for you to use or work from if you like.

I also found that Home Assistant has created a blueprint to send actionable persistent notifications to your phone, so I reference that here to be helpful if you are looking for that. If you want to send these notifications to a mobile device, i suggest you look at Home Assistant Actionable Notification Script Blueprint. to use in conjunction with my blueprint.

:wrench: Configuration

Requirements

Standard Home Assistant setup version 2022.11.0 or better.

Persistent Notification Integration Required
    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.

Persistent Notification Integration Docs

:card_index_dividers: Input fields

trackees:/name: Devices to Track  ✯ REQUIRED ✯
    This is the entity you want to monitor. Multiples are allowed.

gone_for:/name: Time delay before reporting outage 1st time
  and
alt_notify:/name: Manual Notifications Level 1
    There are levels 1 > 4 of these inputs and are set inert at the 
    start. They are used for you to add your own actions at times that 
    you pick after the flip from status ```home```. They are intended 
    to have increasing time delays as you use level 1, then level 2, 
    etc, as the default times suggest.
    Left as-is they will have no visible action.

notification_id:/name: Optional Notification ID
    See instructions explaining this. It is not required & is blank
    in most use cases.

skip_p_notifcation:/name: Choose to send persistent notification (or not)
    If you don't want the notifications at all, here you can turn them off.

notify_enable_time:\name: Time of day to begin notifications
    Set this for the time of day you want to allow notifications to begin.
    Leave as is to always be enabled.

notify_disable_time:/name: Time of day to end notifications
    Set this for the time of day you want notificatons to end.
    Leave as is to always be enabled.

weekday:/name: Day of the week to allow notifications
    Change options if you want to include or exclude any specific day.
    All days are selected by default.

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

:eyes: Installation example

Once you have the entities created or decided upon you can build the Automation. To build the automation:

  1. Click on ‘Create Automation’ Open your Home Assistant instance and show your automations. and ‘Use Blueprint’
  2. Add a Description so you can tell what this one is for
  3. Use the Drop-downs to select the Entities for the listed purposes.
  4. Set the time-frame that the automation will be active. Default is always on.
  5. Select the device you want to monitor.
  6. Write the yaml scripting to perform your own actions, or just use the persistent notification that’s already written for you.

:mechanical_leg: Device Reset

As I was making this, I decided that instead of re-writing the code and timing to ‘reset’ a stuck device, why not make a BP to do that for me. So I did. Here’s a script blueprint that accepts an entity name and a delay time, will take that and shut something off, wait the delay, and turn it back on. How about that for a shortcut for you? Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

: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/Device_tracker_Monitor_and_Notifier.yaml

:bow_and_arrow: Example from my Configuration to use this as a Restart Tool :nut_and_bolt:

I use thie blueprint to keep the 2 MOCA adapters feeding my garage connected. Here is a file with a static sample of this code:

Sample Code for entity restart

You can also find this in a live version on my [Home Assistant Config repo]
(GitHub - SirGoodenough/Home-Assistant-Config: My HA Configuration... This is what I run for production in my house.) if you want to browse for other nuggets.

:speak_no_evil: Helpful HINTS for alternate set-ups

Here are some of the variables you might want if writing you’re own notification thru notify, pushbullet, texting, notify, telegram, or whatever:

Name of the triggered entity: {{ states[trigger.to_state.entity_id].name }}

State of the triggered entity: {{ states[trigger.to_state.entity_id].state }}

Friendy_name of the triggered entity: {{ states[trigger.to_state.entity_id].friendly_name }}

Others are available if you look at the persistent_notification because it shows you all that are available from that sensor:


Sample Persistent Notification result.

: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.

alias: aaaaaaa office Fan Test
description: 'See how to increase the number of Traces available''
trace:
  stored_traces: 10
use_blueprint:
.....

: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

2 Likes