⛔ Offline Devices Report : Easy Customize Includes & Excludes, Notifications + More

you find some rare ones… I think I fixed. try Version 2026.03.08.47c (just posted)

No errors this time. Thanks!

1 Like

@Ltek I discovered another issue. The button will not run the automation. I think it’s failing at the following condition. I know the logic is there to prevent unwanted runs from other sources, but it also stops the UI button too.

     value_template: >-
       {{ trigger.id == "button_trigger" and trigger.event is defined and
       trigger.event.data.new_state.state not in ["unknown", "unavailable",
       "off"] }}

Here is the full trace images:


yeah, I must have forgotten to test it.

fixed in 48c, posted

Works! Thank you.

1 Like

Hey,

maybe i misunderstand this BP, but should it not send automatically notifications when a device/entity goes offline/unavailable?
When i manual trigger the automation, it works fine:

alias: ⛔ Offline Devices Report with Notification Actions
description: ""
use_blueprint:
  path: Ltek/offline-devices-report-ltek.yaml
  input:
    include_easy_notify: enable_easy_notify
    notify_device:
      - 3a6fc44ae355c73cf48de565206a3aaf
    notify_data:
      - high_priority
      - sticky
    include_persistent_notification: enable_persistent_notification
    exclude_entities:
      - switch.steckdose_pc_arbeitszimmer_bjorn_child_lock
      - switch.steckdose_pc_arbeitszimmer_bjorn
      - switch.steckdose_trockner_keller_child_lock
      - switch.steckdose_trockner_keller
      - switch.steckdose_waschmaschine_keller_child_lock
      - switch.steckdose_waschmaschine_keller
      - switch.tp10
      - switch.tp09
      - switch.3fach_1
      - switch.3fach_2
      - switch.3fach_3
      - switch.3fach_usb
    exclude_strings: 0x
    global_conditions: []
    time: "01:00:00"
    include_time: time_enabled

Default is to run on the schedule you input. If you want it to happen in Real Time, this is explained the top of the description…

DEBUG README... Real-Time Debug trigger code is commented out. To use, you need to uncomment 'Real-Time Debug Code' section

1 Like

Okay, how can i uncomment it?
I can’t find the line in the yaml code.

I already set this:

Why is it commented out in the first place, but i still can set it in the BP/Automation itself?
Also why its called debug?
When a device/entity goes offline/unavailable i want a notification, thats the main purpose of this or not?

You must enable Real-Time in the blueprint source code since it should only be used for troubleshooting (aka Debug). On most systems real-time causes high CPU use since it must trigger on all entity changes, no matter what they are. The HA system does not give us any way to only trigger when something changes to unavailable. This blueprint is for a scheduled daily or weekly report. If you need to monitor a few specific entities in real time, you should make an automation just for those, so they monitor/trigger on only those few entities.

1 Like

Okay, thanks.
So to trigger it f.e. every hour, i just create another automation to trigger this BP/automation?
Also one of my WiFi plugs is not detected as offline:

you can schedule a run if you want, sure. next time I mod the BP I’ll add a configurable timeframe… I wont have time for a while.

the BP monitors entities from these domains…

  • sensor.*
  • binary_sensor.*
  • switch.*

If you think it should see your Sensor, I’d you to show me the make/model and the entity info from the main device. I have wifi devices from Tuya, Tapo, Shelly, and others which report offline for me.

1 Like

Its a Nous A1T WiFi with Tasmota, other Tasmota devices work fine with the BP, but this device showed “Unknown” instead of “Unavailable”.
I already restarted the device and see if its happen again.

“Unknown” means the entity exists but has no state/value yet. Many entities do not start with a value - happens a lot when HA restarts, it does not cache values. So if the device has not reported in, it will be ‘unknown’ until it reports or is polled.

1 Like

Thanks for this and so far it works great for me.
But I’m trying to add a custom action to also notify my discord channel.
I’m trying to figure out what variables to use. I tried {{sensor}} but it shows blank.

What are the different variables can I use to show all offline or unavailable devices for battery and switches. Is that even possible? Tnx

I added the list to the first post. Glad you find the BP useful!

1 Like

I think I understand how the automation works — it’s basically tracking device availability via Zigbee2MQTT and using the “availability/last_seen” information to generate the report and notifications. In my case, notifications are working fine :+1:

However, I noticed that the “availability” (or last_seen update) is not very real-time. It seems to update only when the device reports something, which can be quite infrequent depending on the device and its reporting configuration.

Is there any way to make this more responsive, for example:

  • poll devices every 10–15 seconds, or
  • track last_seen with a much shorter interval, especially for mains-powered devices like smart plugs?

My use case is detecting power loss quickly on Zigbee plugs. Ideally, I would like to get a notification almost immediately when a socket goes offline (e.g. power outage).

Is this even possible with Zigbee2MQTT, or is it limited by the way Zigbee devices report state? Would adjusting reporting intervals or using a different approach (like last_seen) help here?

It is designed to run once a day at the time you specify in the blueprint settings.

You can force it trigger more often via an automation, but I wouldn’t do it too often (no faster than every 5 minutes).

Thanks for the reply, I created a new automation (cycle) that runs this automation much more frequently.

@alvian

this blueprint is not meant for real-time. It queries Home Assistant, I suggest you want a real-time Event-Based automation. You’d need to make the automation trigger that listens for an MQTT offline messages based on Z2Ms ‘availability’ feature.
Ensure the availability feature is enabled in your Zigbee2MQTT configuration.yaml . This setting makes Z2M publish a message to the topic zigbee2mqtt/[device_friendly_name]/availability whenever the network state of a device changes

zigbee2mqtt/configuration.yaml …

availability:
  enabled: true

HA automation…

alias: "Notify for Zigbee2MQTT offline devices"
description: "Send a notification when any Z2M device goes offline"
triggers:
  - trigger: mqtt
    topic: "zigbee2mqtt/+/availability"  # '+' is a wildcard for any device
conditions:
  - condition: template
    value_template: "{{ trigger.payload_json.state == 'offline' }}"
actions:
  - action: notify.mobile_app_your_phone
    data:
      title: "Zigbee Device Offline"
      message: >
        {{ trigger.topic | regex_replace('zigbee2mqtt/(.+)/availability', '\\1') }} has gone offline.

Hi, the automation seems to have a problem, when there are entities in the exclude list, which are not available anymore.

In the log of HA I can see:

Error rendering variables: TypeError: '<' not supported between instances of 'NoneType' and 'str'

As I have no own coding ability of Jinja2, Claude Coding suggested the following fix. (I’m just using this to help me to identify the possible problem - I am well aware that this might not be the real problem.) I have no idea where Claude did gather the branch information, I’m just leaving this in case it helps.

Where: _offline_devices variable, friendly_names branch

Root cause: offline_entities | map('state_attr', 'friendly_name') returns None for entities that exist in exclude_entities list but have since been removed from HA. The subsequent | sort in offline_devices and all_sensors variables then fails because Python can’t compare NoneType with str.

Proposed fix — replace this:

{% elif display_options == 'friendly_names' %}
  {{ offline_entities | map('state_attr', 'friendly_name') | list }}

with this (same pattern already used in the both branch):

{% elif display_options == 'friendly_names' %}
  {% set result = namespace(items=[]) %}
  {% for e in offline_entities %}
    {% set friendly_name = state_attr(e, 'friendly_name') %}
    {% set result.items = result.items + [friendly_name if friendly_name is not none else e] %}
  {% endfor %}
  {{ result.items }}

The both branch already handles this correctly. The friendly_names branch needs the same None-guard.