Home Assistant Alert for Zigbee Device Unavailability

Home Assistant Alert for Zigbee Device Unavailability

Zigbee devices, especially battery-powered ones, can occasionally become unavailable due to various reasons such as battery drain or connection issues. It’s crucial to get notified when a Zigbee device goes offline to ensure your smart home setup runs smoothly. This guide will help you set up alerts in Home Assistant to monitor the availability of your Zigbee devices. I’m using Zigbee Home Automation (ZHA), but the same concept can be applied to Zigbee2MQTT.

Requirements

  1. Ensure the “rssi” property is enabled for all your Zigbee devices in the Diagnostic section. By default, this property is disabled.
  2. Add the following YAML code to your configuration.yaml:
- template:
  - binary_sensor:
      - name: "Any Zigbee Unavailable"
        state: "{{ integration_entities('zha') | select('search','rssi$') | select('is_state', 'unavailable') | list | count > 0 }}"
        attributes:
          entity_id: >
            {% set entities = integration_entities('zha') | select('search','rssi$') | select('is_state', 'unavailable') | list %}
            {% set names = entities | map('state_attr', 'friendly_name') | list %}
            {{ names }}
        unique_id: any_zha_unavailable
    

Creating the Automation

Next, create the following automation in Home Assistant to receive notifications when any Zigbee device is down for over a minute:

alias: Alert if Zigbee device is down
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.any_zigbee_unavailable
    attribute: entity_id
    for:
      hours: 0
      minutes: 1
      seconds: 0
condition: []
action:
  - service: notify.persistent_notification
    metadata: {}
    data:
      message: >-
        {{ state_attr('binary_sensor.any_zigbee_unavailable','entity_id')  |
        join(', ') | replace(' RSSI','')}}
mode: single
    

Explanation

This setup will immediately trigger when any Zigbee device becomes unavailable for over a minute. The binary sensor contains a list of all the devices that are down, so if anything changes in that list, the automation will trigger. It will then send a notification to Home Assistant with a list of the devices that are down.

Summary

By following these steps, you can ensure you are promptly alerted whenever a Zigbee device becomes unavailable, allowing you to take necessary actions to fix the issue. This method leverages Home Assistant’s powerful automation capabilities and keeps your smart home setup reliable.


Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply