Xiaomi Gateway Integration

I have implemented the both_click event: https://github.com/Danielhiversen/homeassistant/pull/14

Thanks, just merged it

@syssi what is in the log when you press both buttons? All three switches reports both_click?

Take a look here: https://github.com/Danielhiversen/homeassistant/pull/14

The message is filtered by the data key “channel_{0,1}” vs. “dual_channel”. Therefore the event is just fired once by:

[homeassistant.core] Bus:Handling <Event click[L]: entity_id=binary_sensor.wall_switch_both_158d000xxxxxxx, click_type=both>

hey guys, just received my Hub but I’m not able to find the options to get the Hub’s key (as explained at http://bbs.xiaomi.cn/t-13198850)

This is what I get!

I’ve searched all around the app but there’s no way to access network settings or something like that. Am I missing something?

Choose ‘About’ and then you should see a screen like this:

Touch repeatedly on the blank space right below Tutorial until this appears:

After this, I think you can follow the instructions that you can find here.

1 Like

thanks so much man! I didn’t see the “touch repeatedly” to show these options on the tutorial website!

No worries, I went through the same, it was still fresh in my mind.

Yea, I had missed enabling the local LAN control as it wasnt in English on my app… So now my YAML looks like
- sid: redacted
key: redacted

but I still get
2017-05-31 12:36:30 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/setup.py”, line 188, in _async_setup_component
None, component.setup, hass, processed_config)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/pi/.homeassistant/custom_components/xiaomi.py”, line 61, in setup
gateway[‘sid’] = gateway[‘sid’].replace(":", “”).lower()
AttributeError: ‘int’ object has no attribute ‘replace’

Any ideas?

I might do a PR to the repository to explain this better using your post!

I only have these settings as I only have one gateway, try as the follows:

    - sid:
      key: REDACTED

Only add your key!

The procedure is already documented in fooxys repo here:

This is linked in this thread (more than once I think) but its tricky for new users to find since its not linked directly from rave or daniels repos.

If I only use my key, I get
2017-05-31 13:23:58 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/setup.py”, line 188, in _async_setup_component
None, component.setup, hass, processed_config)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/pi/.homeassistant/custom_components/xiaomi.py”, line 77, in setup
File “/home/pi/.homeassistant/custom_components/xiaomi.py”, line 167, in discover_gateways
self.gateways[ip_add] = XiaomiGateway(ip_add, port, sid, gateway_key, self._socket)
File “/home/pi/.homeassistant/custom_components/xiaomi.py”, line 262, in init
if self._discover_devices():
File “/home/pi/.homeassistant/custom_components/xiaomi.py”, line 271, in _discover_devices
File “/home/pi/.homeassistant/custom_components/xiaomi.py”, line 368, in update_key
from Crypto.Cipher import AES
File “/home/pi/.homeassistant/deps/Crypto/Cipher/AES.py”, line 50, in
from Crypto.Cipher import _AES
ImportError: cannot import name ‘_AES’

Edit: I get get this w/ both pycrypto and pycryptodome

Does anybody use aqara wall plug? It’s still unsupported now.

Hello @all

I want to automate my heating in my house (I have 10+ electric heater), I already have temperateur sensor in all rooms, I want to simply start/stop heater depending on sensors.

Question is : how can I control my heaters with Xiaomi devices ?

(I was about to add Chacon 54755 micro modules and a rfxcom but maybe there’s a trick I did not get)

My heaters are not connected to a plug, they are directly linked to wires so using a wall plug is not the “easy” solution… (maybe someone has already “opened” a Xiaomi plug and solder wire directly on it ?)

You would be better off with a SONOFF http://sonoff.itead.cc/en/products/sonoff/sonoff-basic

1 Like

100% agree. The sonoffs are pretty much exactly what you are after:
Cheap, designed to be connected inline (as opposed to a socket), supported by HA, can switch 10A (and also 16A versions)

Just remember to check how powerful your heaters are before buying as a quick google says the 10A has a power limit of 2200w and going over that could have very serious consequences, if you don’t like house fires. If they’re based on the same voltage the 16A can do ~3500w.

fyi The Xiaomi Zigbee/Wifi plugs are also 2200w and the Aircon Companion plug is 3500w, which probably isn’t a coincidence.

Normally the limit is calculated with 220V at the plug, so:
220v * 10A = 2200W
220V * 16A = 3520 -> 3500W

Thanks !

I didn’t know sonoff, it looks like a quite good solution. But I think it’s not as small as needed to fit IN the wall behind the heater. I need to check.

After some digging I found that we need to flash them for use with ha and I also saw that there are plenty of versions. One with power consumption sensor, do you know is it supported by HA ?

It’s quite off topic, sorry :slight_smile: but it looks amazing with cheap xiami sensors. I will have a full automated heating for a waaaay smaller budget than I thought.

To come back to topic, I just received 3 fire and 2 gas sensors, I have not yet installed them but are they supported by official plugin or a fork ?