We all knew this would happen! Sonoff ZB Mini (review) was made to work with Sonoff ZigBee Bridge (review), but there is nothing stopping me from trying it with ZigBee2MQTT and my USB stick of choice CC2531. I’m sure, I’m not the only person that wants to take the advantage of Sonoff Mini (review) form factor and ZigBee protocol, which means no flashing is involved.
Good to have choices
ZigBee is the biggest advantage here, there is no need for hardware flashing, no messing about with Sonoff DIY as well. We can simply pair Sonoff ZB Mini with a ZigBee sniffer of our choice. Then, the sky is the limit, as Sonoff ZB Mini will work with any ecosystem you want thanks to the power of NodeRED (or Home Assistant if that’s your thing). By the way, if you want to know more how to wire it, take a look at my Sonoff Mini article. The same principles apply for both devices.
Sonoff ZB Mini & ZigBee2MQTT
I have some good and bad news. At the time of the writing, Sonoff ZB Mini isn’t supported by default by ZigBee2MQTT. Fortunately, I will show you how to make it work. The good news is that I would expect the device to be added to the list of supported devices within a couple of weeks.
The device pairs in the usual way. Enable joining flag in the configuration.yaml
, press and hold the Sonoff ZB Mini button for 5 seconds, and you will be greeted with a message like this:
21:46:07: Successfully interviewed '0xecxxxxxx536', device has successfully been paired
Oct 27 21:46:07 automation npm[1931]: zigbee2mqtt:warn
2020-10-27 21:46:07: Device '0xexxxxxf536' with Zigbee model '01MINIZB' is NOT supported, please follow https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html
The device will be paired with your CC debugger, but the configuration is missing. I already covered the process of adding unsupported devices in this article. Please read it, as in here I will only provide you with a template to use in your devices.js
file without further explaining.
{
zigbeeModel: ['01MINIZB'],
model: 'Sonoff ZB Mini',
vendor: 'Sonoff',
description: 'Smart switch - 1 gang, 3.3V switch logic',
supports: 'on/off',
fromZigbee: [fz.on_off],
toZigbee: [tz.on_off],
},
Please add the following template to the file, then restart the ZigBee2MQTT with the following commands:
#Stopping zigbee2mqtt
sudo systemctl stop zigbee2mqtt
#Starting zigbee2mqtt
sudo systemctl start zigbee2mqtt
You shouldn’t see any errors in your ZigBee2MQTT log after this.
Sonoff ZB Mini in NodeRED
From there it’s just plain sailing. The device is paired with my CC2531 and I can send and receive commands via MQTT. Reading log messages isn’t fun so let’s quickly add some functionality:
Buy Sonoff Zigbee Sensors
Buy it using these links to support NotEnoughTech.
Each section is covered in detail in relevant articles linked in the list above, so I’m just going to mention some changes.
Alexa comes thanks to Alexa NodeRED skill. You will have to remember to change the payloads from true|false
to {"state": "ON"}
respectively as ZigBee2MQTT uses these commands instead.
While NORA can be configured to send the correct payload to the MQTT node, so it’s pretty much plugged and play! Awesome.
I have a great inching node, which enables inching via dashboard or payload. Just add the node according to the instruction in the article and you will see the switch on the dashboard. The default inching is set to 10 sec and can be adjusted in the script. I also added an option to sync your Android alarm with NodeRED so you can turn on the lights before your alarm goes off!
As for timers, you could use the big-timer node or try my timer related writeups to set up a timer with dashboard support.
You can try the flow listed for yourself by importing the NodeRED from below:
Final thoughts
With a small effort, Sonoff ZB Mini had been added to my NodeRED sever. Now I can integrate the switch with any ecosystem I want. I already did so for other Sonoff ZigBee gadgets. It’s ZigBee, so you don’t have to stick to a single ecosystem, you can take a look at these Tuya sensors, compatible Aqara devices or IKEA Tradfri integration. Also if you want you can add an external antenna to the Sonoff ZB Mini and CC2531 – I have a tutorial about it too. Mix and match it all! I hope you enjoyed the article, leave me a comment in this Reddit thread.