[Blueprint] ZBMINI Auto-Repair after Zigbee Disconnects (Zigbee2MQTT)

Version: 1.0 • Tested: Home Assistant 2025.10.3 + Zigbee2MQTT 2.6.2 •


:blue_book: Overview

Automatically repairs Sonoff ZBMINI / ZBMINIR2 devices when they unexpectedly leave the Zigbee network — e.g., after a power cycle or rapid toggling.

When a ZBMINI leaves, the automation will:

  1. Enable permit_join in Zigbee2MQTT so the device can rejoin
  2. Wait for a device_joined, device_announce, or device_interview event
  3. On rejoin, automatically
  • Re-enable Detach Relay mode
  • Turn on the relay to power the connected Zigbee lamp
  • Set “Power-On Behaviour” to on
  • Perform a short off → on pulse so the lamp restores connection

:bulb: Perfect for setups where a ZBMINI controls a Zigbee lamp behind a Detach Relay, ensuring both recover automatically after power or connection issues.


:gear: Requirements

  • Home Assistant with Zigbee2MQTT
  • MQTT properly configured
  • ZBMINI / ZBMINIR2 exposing these entities:
    • switch – main relay
    • switch_detach_relay_mode
    • select_power_on_behavior

:jigsaw: Inputs

Input Description
IEEE Address The device IEEE (e.g. 0x08b95ffffebacccd)
Friendly Name Display name used in notifications
Permit-Join (s) How long Zigbee2MQTT allows joining (default 60 s)
Switch (Relay) Entity for the relay, e.g. switch.livingroom_zbmini
Detach Relay Switch Entity controlling Detach Relay mode
Power-On Behaviour (Select) Entity defining the power-on behaviour
Power-On Option Desired default (on / off / toggle / previous)
Delay after On (s) Wait before off/on pulse (default 15 s)
Pulse Off Duration (ms) Duration of off pulse before turning on again (default 1500 ms)

:arrows_counterclockwise: How It Works

  1. Detect Leave
    Watches for device_leave from Zigbee2MQTT.
    → Sends a notification and enables permit_join.
  2. Wait for Rejoin
    Waits for the same IEEE to announce itself via
    device_joined, device_announce, or device_interview.
  3. Repair Sequence
    When the device returns:
  • Disables permit_join
  • Turns on Detach Relay mode
  • Turns on the Relay
  • Sets Power-On Behaviour to your selected option
  • Waits a few seconds
  • Pulses the relay off → on
  • Sends a “Device repaired” notification
  1. Timeout (2 min)
    If no rejoin within 2 minutes → notification:
    5.“Device didn’t return within 2 minutes.”*

:bulb: Example

Scenario:
A Sonoff ZBMINIR2 controls a Zigbee lamp. Detach Relay mode is enabled, so the wall switch sends Zigbee commands but doesn’t cut power.
If the ZBMINI leaves the Zigbee network, the lamp stops responding.

This blueprint automatically:

  • Opens permit join
  • Waits for the ZBMINI to rejoin
  • Restores Detach Relay mode, relay state, and power-on behaviour
  • Toggles the relay briefly
  • Your lamp comes back online :bulb:

:rocket: Setup

  1. Import this blueprint into Home Assistant
    Settings → Automations & Scenes → Blueprints → Import Blueprint
  2. Create Automation from it
  • Enter your device IEEE
  • Select the relay, detach relay, and power-on entities
  1. Save & Enable the automation
  2. Repeat for each ZBMINI + lamp pair in your network

:toolbox: Tips

  • Reduce timeout to 60 s if your devices rejoin quickly
  • Permit join is automatically disabled once repair begins
  • Works with both Sonoff ZBMINI and ZBMINIR2
  • Replace notifications with your mobile app notify service for push alerts

:receipt: Blueprint

Import Blueprint into Home Assistant

Here is the link to GITHUB:


:speaking_head: Feedback

If you test or improve this blueprint, please share results below.
Issues, timing tweaks, or additional device support are welcome!