[RELEASE] Xiaomi Zigbee Smart Outlet device handler (new ST App compatible)

Heya All!

I’ve been using some holiday time to get up to speed on how exactly SmartThings works with groovy more in depth, and specially the Zigbee protocol.

So my first challenge was to make @ArstenA’s DTH for the Xiaomi Zigbee outlets work with the newer ST App and groovy code (Thanks for the previous work @ArstenA! ).

This took me into a heavy journey of reading the ZCL standard, the ST groovy docs, groovy, and re-visiting java and data types.

The Device handler is now written in the latest Zigbee groovy code (zigbee.something()), and I heavily commented it for anyone to understand how a Zigbee device handler works, and other things. Also removed most of the debugs, added some info events, and removed the tiles code, which is no longer needed in the new app.

TL;DR: It now fully works under the new App, Temperature works (measurements are ugly, has an offset setting), Power works, Energy usage works.

Note: I’ve made the fingerprinting specially for the ZNCZ02LM model (CN/AU/NZ/AR), but in theory should work with the other zigbee models since if understood correctly it uses the same clusters. (If you read this and you can, test it by setting the device type in the IDE manually and then send me the fingerprint data if it works (Data and Raw description in the device, in ''My Devices" in the IDE) so I can add it to the code :slight_smile: )


Current Version: V1.2 (12 Jan, 2021)

Changelog:

V1.1 (Jan 10, 2021):

  • Fix for correct encoding data type

V1.2 (Jan 12, 2021):

  • Add health check capability
  • more and more comments and learnings
  • added data refresh poll setting
  • added automatic data poll refresh every X minutes just in case some zigbee message is not reported even if set by configureReporting for any reason
  • reorganized code structure so native/non-native methods are understood

Screenshots:


Device Handler Code: Xioami Zigbee Smart Outlet DTH :

https://raw.githubusercontent.com/cristianhares/smartthings/main/devicetypes/chares/xiaomi-zigbee-smart-outlet/xiaomi-zigbee-smart-outlet.groovy

How to install the device handler:
1.- go into the SmartThings Groovy IDE: SmartThings IDE
2.- go into the tab 'device handlers’
3.- Click on the upper right button '+ Create New Device Handler’
4.- Select the tab ‘From code’
5.- Copy the previous link’s code in there.
6.- Click on the ‘create’ button.
7.- on the upper right corner, click on the ‘save’ button, and then, click on the ‘publish’ button, and select ‘for me’

That’s it!, now adding the Xiaomi Zigbee Smart Outlet should be automatically recognized :slight_smile:

If you like it and/or find it useful, and If you can of course, get me a coffee so I can keep programming :smiley: : Ko-Fi / Buymeacoffee

1 Like

Thanks for the great work I just recall though xiaomi outlet is not well known for being a good zigbee repeater is that still an issue ? I still have an unused xiaomi outlet and eager to try if it works well as a repeater

Heya,

I’ve got 3 of them, and until now I haven’t seen any issues (I was using bspranger’s one), most of my zigbee devices are SmartThings, a few heiman (owon), and some xiaomi’s.

I’ve heard of the same comment, but at least in my case haven’t seen any problems (yet). I wonder what kind of behavior would be seen as an unstable zigbee network.

Edit: just seen the previous comment, so it happens when one repeats another, interesting, at least 1 of mine is repeating another, and haven’t seen that kind of problems (yet).

UPDATE: I’ve also updated the code, as the data type for the report config interval was wrong (its a Float4 for power/energy, and INT16 for temp).

That sounds promising I will try later even I got 2 ST outlet already

1 Like

Just updated it to v1.2, Here’s the changelog:

  • Add health check capability
  • more and more comments and learnings
  • added data refresh poll setting
  • added automatic data poll refresh every X minutes just in case some zigbee message is not reported even if set by configureReporting for any reason
  • reorganized code structure so native/non-native methods are understood

As I added an extra setting to that anyone can set the refresh interval for data polling just in case a zigbee message is not sent, you may need to clear the App cache before reopening the app after updating the handler.

I’ve also added LOTS of learned lessons and details, behaviour lessons, etc. in the comments :smiley:

Enjoy :slight_smile:

Updated it to V1.3 :slight_smile:

  • Removed method for custom on/off (unused)
  • Changed logic order, and added ability to parse natively via zigbee.getEvent
  • Added notes on how exactly Xiaomi does its Zigbee reports via a custom attribute ID which is 0xFF01 or 0xFF02, and how to understand them
  • Modified value type from decimal to number for temperature offset, as it was breaking the reading to 0 degrees (not fully tested)