Skip to content

AqaraHub is an open-source Zigbee hub for Xiaomi Aqara devices. It aims to be a replacement to the Xiaomi Gateway that does not require communication to outside servers, and a saner communication option (e.g. MQTT).

Notifications You must be signed in to change notification settings

Gabor9/AqaraHub

 
 

Repository files navigation

AqaraHub

This is an open-source Zigbee hub for Xiaomi Aqara devices, as pictured here. It aims to be a replacement to the Xiaomi Gateway that does not require communication to outside servers, and uses a saner communication option (e.g. MQTT).

This project is spefically aimed at Xiaomi Aqara devices, and there are currently no plans to support other Zigbee devices with this project.

Get in touch!

I've been writing this thing on my own, and it appears to solve my use-case fairly well, but I'd love to get feedback from others!

Some of the things I'd like to know:

  • Is anyone else even interested in a project like this?
  • Were others able to compile it ?
  • Has anyone actually got it to run ?
  • Is anyone missing specific functionality ?

So instead of only following or starring this project, just drop me a message at [email protected] too :)

Getting Started

At this point, reporting attributes received from the Xiaomi devices to MQTT appears to be working quite well. If this is all that you require, I encourage you to give it a shot. Support for sending things back, like turning the Smart Plug on or off, is still on the to-do list.

Libraries and tools used

This project uses a lot of C++14 features, so obviously a compiler supporting these is required. GCC 5 or later, Clang 3.4 or later, or Microsoft Visual Studio 2017 should fit the bill.

On top of that it makes heavy use of the Boost C++ Libraries, the Adobe Software Technology Lab Concurrency Libraries (hereafter "STLab-libraries"), Takatoshi Kondo's excellent mqtt_cpp library, and The Art of C++ / JSON libraries.

All dependencies except for Boost can be pulled in as git submodules:

git submodule update --init --recursive

There is no need to compile these libraries, as they are all header-only.

The Boost libraries should be available on most Linux distributions, likely named either boost-devel, boost-libs, or just boost.

Compiling using CMake

On my machine, I can compile using the following commands:

git submodule update --init --recursive
mkdir build
cd build
cmake ..
make

Afterwards a binary named AqaraHub should have appeared in the build folder.

Deployment

Prerequisites

To run AqaraHub, several things are needed:

  • A CC2531 Zigbee USB dongle, like one of these
  • A programmer to flash the CC2531, like one of these
  • A cable from the standard double-row 2.54-spaced connector to the teeny-tiny connector on the CC2531, like one of these
  • A functioning MQTT Server
  • One or more Xiaomi Aqara devices

Flashing the Zigbee dongle

The Zigbee dongle should be running the "Pro-Secure_LinkKeyJoin" firmware, available here. You can use CC-Tool from here or here to flash it to the dongle.

I've succesfully flashed my device using the following steps:

git clone https://github.com/dashesy/cc-tool.git
cd cc-tool
./configure
make
wget https://raw.githubusercontent.com/mtornblad/zstack-1.2.2a.44539/master/CC2531/CC2531ZNP-Pro-Secure_LinkKeyJoin.hex

Next connect the programmer to the dongle. Note that there is a very small "1" on one side of the plug on the dongle, and a "10" on the other side. The cable should be plugged in to have the red wire on the side of the "1". Then connect the USB dongle to the computer, and finally plug in the programmer to the computer. I'm not entirely sure why, but any other order does not appear to work for me. Finally, instruct cc-tool to flash the firmware:

sudo ./cc-tool -e -w CC2531ZNP-Pro-Secure_LinkKeyJoin.hex

Note that I'm using sudo as otherwise cc-tool is unable to use libusb, for some reason. This is not the safest decision. If anyone knows the proper way to give this executable access to libusb, please let me know!

Finally disconnect both the dongle and the programmer from your computer, disconnect the debugging cable, and plug the dongle back in the computer. Once the green light turns off, The dongle should be ready to be used by AqaraHub.

Running AqaraHub

Running AqaraHub is relatively simple. Simply instruct it to which serial port the USB dongle is using, the MQTT server to connect to, and the topic under which to publish all received information:

./AqaraHub --port /dev/ttyACM0 --mqtt mqtt://ArchServer/ --topic AqaraHub

Contributing

Any and all help would be greatly appreciated. Feel free to make pull requests or add issues through Github.

Code formatting wise, I try to stick to the Google C++ Style Guide. Don't feel obligated to make pull requests perfect, most of the formatting can be solved with clang-format, and we can always clean it up together...

Authors

AqaraHub is written by Frans-Willem Hardijzer. See my Github profile for contact options.

License

AqaraHub is licensed under the GNU General Public License, version v3.0. See LICENSE-gpl-3.0.txt or the online version for more information.

Acknowledgments

I'd like to thank the zigbee-shepherd project both as inspiration as well as being a very good example on ZNP programming. It's debug output has helped me immensely in actually getting started programming the ZNP dongle.

About

AqaraHub is an open-source Zigbee hub for Xiaomi Aqara devices. It aims to be a replacement to the Xiaomi Gateway that does not require communication to outside servers, and a saner communication option (e.g. MQTT).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 97.9%
  • CMake 1.8%
  • Python 0.3%