Xiaomi Gateway Integration


I’ll get the cube in 2 days. So i should be able to test it then


Nice find!


Seems like Aqara is crowdsourcing a new in-wall outlet. Looks much nicer than Xiaomi Plug. You can see it from Mi Home App. I’m getting 2 of those :grin:

Also, Xiaomi has increased the price for temp/humidity sensor in their official website. So they have increased the price of all their sensors in the last 2 months. But they’re still cheap :grin:


Is the smart plug supported?


Yep, but only zigbee version (not wifi).


A few weeks back I modified my standard alarms into smart smoke alarms with xiaomi sensors.

Here is a guide for anyone else that want a cheaper smart smoke alarm.

You can use either a door/windows sensor or a switch. The door and window sensor is preferred due to it’s tiny size and integrated battery holder. The sensor has 2 signal contacts that simulates the action of the reed switch onboard. If we close the contacts (short circuit) it means the door is closed and if we open up the contacts, it means the door is open.

The wiring is extremely simple and only require 3 extra components:
• 1x diode I used a standard 4004 type
• 1xreed relay, which I bought from here http://www.gearbest.com/relays/pp_142262.html
• 1x 1uF capacitor, I’ve used electrolytic, note negative ( - ) terminal

How it works
For this mod, the xiaomi door sensor is in a normally open state (relay opened).

  1. The activation of the smoke alarm sends a 9V PWM signal to the piezo. The frequency of the wave is very high.
  2. The 9V signal powers the relay. Since the PWM is so high, the relay closes.
  3. This then closes the contacts on the xiaomi sensor, signalling a door closed signal.

The wiring diagram is as follows

So the steps are:

  1. Wireup the 3 components per the wiring diagram. Open the smoke alarm and identify the piezo pins. Mine is a 3 pin piezo. 1 is GND, 1 is positive, 1 is osilate. We ignore the osilate pin. For me GND is the outer ring. Positive is the middle ring.
  2. Solder in the wires from the relay to piezo
  3. Open up the xiaomi smoke alarm using your finger nails/small object at the notch. Remove the circuit board out of the case. Indentify the 2 signal contacts. Solder wires onto the contacts.
  4. Complete the circuit by soldering the wires from the xiaomi sensor to the relay
  5. Secure the relay in the casing with electrical tape
  6. Secure the sensor using double sided tape

You can then use the xiaomi app / HA for your automation.


  • Due to the PWM wave, the sensor’s state will toggle between close and open. Having a bigger sized capacitor may prevent this but since it was good enough to trigger, I wasn’t too bothered.
  • The smoke alarm will chirp on low battery, this will also set off the sensor
  • Smoke alarm I used https://www.bunnings.com.au/family-first-9v-photoelectric-smoke-alarm-with-test-button_p4210432
  • The door sensor has a bug where if you quickly close it and open it, it will still show as closed in the xiaomi app. Since when the alarm goes off, it toggles the relay, it will trigger the sensor still.
  • For the adventurous, you can remove the piezo if you hate the buzzing, you can wire in a chip that you can record a voice onto. Then you get a nice ‘nest’ style alarm that talks to you for 1/5 of the cost.

Edit more photos of the mod

What Wall Switch Options are there?

did you go in
alarm setting, alarm ringtone, linkage alarm, and add the two gateway together?


Second gateway is working fine now. I have programmed it to work in NodeJS for my side project. Will move the code over to HA


My devices arrived yesterday and I was able to set them up with the gateway using the app.
However, I’m having some trouble activation the developer mode and getting the key.
I’m using the iOS app and am able to go to About, tap in the white area and open the other menu items. I get the attached error message when I try to open the Developer page, and after tapping confirm, it goes back to the about menu …
FW 1.4.1_142.0141

Any ideas?


Make sure you have mainland china set as the country + try several times. Had the same. Guess it is due to the connectivity problems to xiaomi servers.


Had same problem on iOS device. You can activate it on android device - it works well.


Where can I check this?
Unfortunately, I don’t have an Android on hand :-/


You can install a android emulator on your pc or laptop, and then install mi home.apk and do it on android.


Hi @rave,

When you say that aqara is working on new in-wall, which one you refer? Becausei don’t see any new device in-wall in mi home app.



It’s not available yet. They’re crowd sourcing it.


I have tested my setup (4 motion sensors + yeelight (4pcs) + 2 temperature sensors) in few days and sometimes lazcad’s plugin miss events (it happens often at night when motion is very rare), for example: sometimes i get near movement sensor and it generates event - but home assistant didn’t ‘see’ it and didn’t turn on the light.
I have made some research: I have run jon1012’s “aqara to mqtt gateway”, add mqtt loop fix, subscibed to all events (also get them in python script). When I catch motion sensor miss, I have looked at console (aqara-mqtt) - I got this event, I have looked at mqtt-client - and I aslo got this motion event, but i didn’t get it on home assistant gui (motion sensor is still ‘off’) and also i didn’t get it on home assistant console log and also i didn’t got any errors in hass log. But other motion sensors are working fine in same time. After motion time is over - next motion with first sensor also works perfectly.

How i can help to catch this error?


Hey @rave. Did you receive your magic cube yet? I’m waiting for the function so badly😂 create so many scripts and automations just for this cube at the moment:).
Btw. Is it possible to integrate a kind of debug window to collect all data from the xiaomi hub with unsupported devices?. To help you for implementing them? Or Maybe a autoconfiguration for new unknown devices


Installed this today. Picked up my wireless button easily. Doesn’t recognize the cube. Did see a message in the log, " custom_components.xiaomi: Unsupported devices : "


Not yet. But from what i saw from @monster1025 post, it seems like there’s an issue with the device firmware itself. I think its an easy fix. Will post an update later today.

Since there’s only 1 unsupported device, I’ll hold that feature for a later date :slight_smile:


Hi,@rave,thanks for your work!
Did you know about XiaoMi Smart Power strip which not an Aqara production.It use a Marvell 88WM300 Wifi module.Is there a possible to connect it to home-assistat?
There 's two links about it :