Unavailable entity detection & notification

This blueprint will run at a specific time and day of the week and will provide you a list of unavailable entities {{entities}} that could be used in one or more actions (I use it to send a notification)




Notification action example:

service: notify.home_email
data:
  title: Unavailable Entities
  message: Here is a list of unavailable entities in your home: {{entities}}

To use the blueprint use the link below to import it to your Home Assistant installation:
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

If you want to change something or check the code, go to my git repo: https://github.com/gmlupatelli/blueprints_repo


To do:

  • Figure out a way to expand the devices and areas inside the template. Right now I can only exclude entities :frowning:
10 Likes

2 things
Even though I have the automation/blueprint set to run everyday at 10am I only get a notification on Saturdays at 10am?

Is there an easy way to exclude a device/entity group e.g. all lights without having to exclude all entities individually?

Even though I have the automation/blueprint set to run everyday at 10am I only get a notification on Saturdays at 10am?

Strange, by any chance you have an entity that always became unavailable on Friday? I am asking that as you will not get a notification if there is no unavailable entities at the time the automation run.

Is there an easy way to exclude a device/entity group e.g. all lights without having to exclude all entities individually?

Unfortunately, I couldnā€™t figure out how to do it.

This is where the magic happens. So far I couldnā€™t; figure out a way to expand the exclude areas or devices to their entities using a template.

  exclude: !input 'exclude'

  entities: >-
    {% set result = namespace(entities=[]) %}
    {% for state in states %}
      {% if exclude.entity_id is defined %}
        {% if state.state == 'unavailable' and not state.entity_id in exclude.entity_id %}
          {% set result.entities = result.entities + [state.name] %}
        {% endif %}
      {% else %}
        {% if state.state == 'unavailable' %}
          {% set result.entities = result.entities + [state.name] %}
        {% endif %}
      {% endif %}
    {% endfor %}
    {{result.entities|join(', ')}}

Sorry I figured it out.

I have a custom script I use for all system notifications (save having to do multiple actions per automation).
There were multiple automations running at the same time and only the one that finished first was able to send using the script.

Iā€™ve now moved the schedule so there isnā€™t a clash.

Thanks again.

First of all I am a new to home automation and as i was using smartthings and webcore. The problem i am having is installing the blueprint. I clicked on the import blueprint button I get site not available after message open page in HA. What am I doing wrong. I tried importing it using url GitHub - gmlupatelli/blueprints_repo and that seems like I am using the wrong url. Can you help

@ian.robson, check if you have the right home assistance URL on the page that opens when you click Import Blueprint. The URL address is located at the bottom of the windows and you can edit by clicking the pencil icon at the right.

Alternatively use this URL to import it: https://github.com/gmlupatelli/blueprints_repo/blob/cab231edbd05820c070de5c6a38f140868cbbbcb/unavailable_entities_notification/unavailable_entities_notification.yams

1 Like

Thank you that fixed it.

Very nice blueprint! @gmlupatelli

I have this problem:

Everything works perfect but the telegram notification does not start. If I simply delete the word {{entities}} the notification is sent (obviously without the entity names)
Any idea on the possible solution?

Just remove the '' from entities.

Here is an example of a working message:

message: 'Here is a list of unavailable entities in your home: {{entities}}'

Unfortunately, the problem is not there.
Here is the image with the new message (I deleted every word I added before).

The blueprint works perfectly since the results (above in the image) are what I expected, but the telegram notification doesnā€™t start. The notification starts if I delete the word {{entities}} so the problem is not in the notifiy service either. What should I check for?

Thank you

I think I got it :slight_smile:

After doing some research at the forum I found someone with a problem with the telegram bot similar to the one you are having, and it was related to the fact that the variables in the message had underscore, here is the link to it: Telegram message with variables - #2 by anon43302295

Looking at what you have inside the entities variable I see you have some sensors that have _ in the name, given that you need to replace them with something else, try this {{ entities|replace('_', ' ') }}

Thank you so much! :pray:
That was the problem! I fixed it!

Any chance you could add an include list as well as the exclude?

Iā€™d like to track specific entities that fall offline, and I have many many entities that are ā€˜unavailableā€™ for other reasons, due to custom components considering that to be a valid state for ā€˜not activeā€™ (e g Google home timers).

No worries if not, just thought it might be a nice addition of easy enough.

3 Likes

This is really great.

Anyone know an easy way to adapt this to include and not exclude entries? or change it from daily to hours etcā€¦

1 Like

If you know how to edit the blueprint:
In the unavailable_entities_notification.yaml file edit the following:

Line 91:
Change
{% if state.state == ā€˜unavailableā€™ and not state.entity_id in exclude.entity_id %}
To
{% if state.state == ā€˜unavailableā€™ and state.entity_id in exclude.entity_id %}

You can also replace every word ā€œExcludeā€ (or ā€œexcludeā€¦ā€) with the word ā€œIncludeā€ for less confusion :sweat_smile:.
The Blueprint now works only with every Included entity!

1 Like

Is there any way to avoid triggering the automation when thereā€™s no unavailable entity? Iā€™ve tested with unavailable ones and work like a charm, a persistent notification is sent. But when all entities are available the notificaiton got triggered as well.

I have integrated the battery blueprint and works like a charm, not triggered when threshold is not under.

Thanks in advance

Iā€™ve found the issue: It was introduced with latest commit. I just copied the previous version were entities were shown using commas instead of /n. Hope it helps.

@marc.forn, just figure out as I also have a low battery automation that uses the same code base. Sorry about that. Just committed a fix to both.

I donā€™t find the verbose entity names useful, so I forked this Blueprint so that it spits out entity_ids instead: https://raw.githubusercontent.com/mmichon/blueprints_repo/master/unavailable_entities_notification/unavailable_entities_notification.yaml

1 Like