I retrofit Sonoff MINI-ZBRBS roller shutter modules into my exterior blinds. Sometimes one of these randomly drops off the network. No other type of zigbee device ever does this - only the roller shutters. I haven't figured out why.
Anyway, its a serious pain to reconnect them so I asked Claude to help with this. We came up with an automation that triggers on mqtt event device_leave. When that happens, it sends a notification that a device dropped off the network, then it permits join. It turns out that the device does attempt to reconnect, and allowing it to do so actually works. Then the automation tests if the device is on or off the network and sends another notification with success/failure.
This works. It's not a daily thing where this happens, but after waiting several days it did happen again and the automation worked. And even if it doesn't work, I still get the notification when a device drops off. But, yeah, its much better when it automatically reconnects.
Its an automation. Just create a new automation and dump the yaml.
No, I'm not sure. I really don't know enough to say one way or another. Claude helped me get through it. I looked at traces and the last time the trigger was hit was yesterday, so it doesn't seem to be a problem. The one in the screenshot failed the template condition: {{ trigger.payload_json.type == 'device_leave' }}, so obviously it did not run. But there doesn't appear to be a ton of traffic hitting the trigger.
Just a disclaimer I should have put in the OP. I have no idea if this will work with any other ZigBee devices other than the Sonoff shade module. Obviously, it depends on whether the the device attempts to pair immediately after dropping off the network. I can only confirm this with the MINI-ZBRBS because (so far) that's the only thing that's ever dropped off my network, and the only thing that this automation reconnected. Additionally, I suspect only router devices will work, for obvious reasons. Probably other Sonoff devices behave the same way as the MINI-ZBRBS, but I can't say for sure.
But IF the device attempts to immediately reconnect after dropping off, then this automation should work to allow it to reconnect.
No sensor data is sent and most of those items require initiation by me. That explains why there was only one triggering in the screenshot above. There simply are hardly any bridge events until I intervene with new devices or whatever.
I like the logging idea, even without auto-rejoin. I have a few devices that will drop off the network from time to time and by checking the logged messages after a while maybe there's even a pattern.
But then again, one of them is the Zigbee rainsensor and it probably just melted in the current weather
Will check how much traffic this creates but the trigger didn't fire yet in the first 15 minutes.
If there's no power going to your coordinator & your devices, then you're not going to get messages that devices left the network. Your devices will simply be marked as offline after 10 minutes*
*10 minutes is the default for most mains-powered devices (routers) if you have enabled device availability in Z2M. Battery devices (end-devices) take up to 25 hours to report.
You can change the availability timeout globally or per-device as explained in the docs I linked, but be aware that reducing the availability for battery devices will lead to increased battery drain.
EDIT: @palinkas-jo-reggelt I'm starting to think that the cause of your issue is that the MINI-ZBRBS don't report every 10 minutes, which is why they're dropping off the network.
What happens when they drop off? Do you see them as offline in Z2M, or are they simply missing from the device list?
What I meant was that I thought I would get some bridge event messages when the power came back on. Maybe nothing occurred because my zigbee coordinator is on a UPS along with the rest of my networking gear and HA box? But I understand what you mean. No power, no message.
The outage was only 5 minutes. 5 < 10. That could be the reason too.
They are missing from the device list. Once they re-pair, the previous settings are retained (friendly name, calibration, etc). I assume they are re-pairing because allowing them to join actually works. But I thought re-pairing was equivalent to resetting. Not really sure one way or the other.
Then they're actually leaving the network, not failing to report.
Had a look at the reviews & it seems to be a common problem. That's besides other issues, like the relays not actually closing when reaching the end (0 or 100%) & the fact that they only support a 1A load, which might be an issue if your motor doesn't have built in limit switches & the relay keeps running.
If this happened to me, I'd consider that device defective & send it back or trash it. While your automation may work, you're trying to fix the symptom rather than the cause.
Negative ghost rider, it's retains its identity. I have two Osram bulbs that consistently drop if I don't allow re-pairing. I'm using z2m but the same was true a few years ago in my prior system. Those two stupid bulbs. Disable rejoin and they'd always fall off and not come back. Allow rejoin and they are rock solid. I can only guess the connection is borderline. They lose connection then ask permission to join back when they see the network again.