Version: 1.0 • Tested: Home Assistant 2025.10.3 + Zigbee2MQTT 2.6.2 •
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:
- Enable permit_join in Zigbee2MQTT so the device can rejoin
- Wait for a
device_joined,device_announce, ordevice_interviewevent - 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
Perfect for setups where a ZBMINI controls a Zigbee lamp behind a Detach Relay, ensuring both recover automatically after power or connection issues.
Requirements
- Home Assistant with Zigbee2MQTT
- MQTT properly configured
- ZBMINI / ZBMINIR2 exposing these entities:
switch– main relayswitch_detach_relay_modeselect_power_on_behavior
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) |
How It Works
- Detect Leave
Watches fordevice_leavefrom Zigbee2MQTT.
→ Sends a notification and enables permit_join. - Wait for Rejoin
Waits for the same IEEE to announce itself via
device_joined,device_announce, ordevice_interview. - 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
- Timeout (2 min)
If no rejoin within 2 minutes → notification:
5.“Device didn’t return within 2 minutes.”*
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
Setup
- Import this blueprint into Home Assistant
Settings → Automations & Scenes → Blueprints → Import Blueprint - Create Automation from it
- Enter your device IEEE
- Select the relay, detach relay, and power-on entities
- Save & Enable the automation
- Repeat for each ZBMINI + lamp pair in your network
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
Blueprint
Here is the link to GITHUB:
Feedback
If you test or improve this blueprint, please share results below.
Issues, timing tweaks, or additional device support are welcome!