Xiaomi mi wifi plug & air purifier

Hi all,

I just started to integrate the Xiaomi Mi Air Purifier and wifi mi plug into HASS (there)
It works perfectly with one device, but as soon as I put 2 (air purifier + wifi plug), it leads to a checksum error.
It seems that the devices are sharing the same instance from the platform.

got error when receiving: wrong checksum, read b’ffffffffffffffffffffffffffffffff’, computed b’d244a4aeb1074936b12dcac897c0799f’

It may be better to use some kind of hub for Xiaomi devices (like in the light platform example) but I prefer to have your opinion on it beforehand.

My config is as folow:

switch:

  • platform: xiaomi
    host: 192.168.1.103
    name: air_purifier
    token: 90e359e00383bc7912ba845388fa8110
  • platform: xiaomi
    host: 192.168.1.110
    name: switch_chauffe_eau
    token: 3d497faf3391594bc496ab4794a770e9
5 Likes

HI, and thanks for your effort!
I own an air purifier and would love to integrate in into ha.

Can you tell me, where I can find the token for the air-purifier?

And where do I have to put which files, if I only want to use the air purifier?

I’m also curious about this - how to find token and where to put files?

I 'm also wondering how to get this integration working, any chance for a step by step guide or even some sample code?

Does the wifi switch work for you?
I’m currently just using the mirobo component in a switch from here.
I can discover the device by running “mirobo discover”. I even get the ip and they key back.

This is my config.

switch:

  • platform: mirobo
    name: ‘name’
    host: Ip
    token: Token

I get the error as below

2017-05-17 11:12:18 ERROR (Thread-8) [custom_components.switch.mirobo] Got exception while fetching the state: timed out

Hi, i’m also very interested about the integration between Xiaomi air purifier 2 and Home assistant. Can you write a step by step guide to do it?
I actually have the xiaomi gateway with zigbee socket plugs, switches, door sensors and temperature sensor, everything works except for the purifier and a Smart Wifi Socket Plug ZNCZ02CM

My wifi plug arrives today.
+1 on the Step-by-Step guide.

No one on the token?
EDIT 1:
I get the following error (assuming it is because of the missing token):

Got exception while fetching the state: cannot import name 'Device'

EDIT 2:

You can get your tokens like this: https://github.com/aholstenson/miio/blob/master/docs/management.md
Unfortunately this does not solve my error message.

See above. I got my token by implementing mirobo library on the pi. I’m not sure i wasnt to install node.js for just getting the token.

Did you find a solution? I get the following error:

2017-06-04 13:43:41 INFO (Thread-3) [custom_components.switch.mirobo] initializing with host 192.168.0.81 token b'8735e7bd8f10b45ea6708ba89c1a4f7b'
2017-06-04 13:43:41 ERROR (Thread-3) [custom_components.switch.mirobo] Got exception while fetching the state: non-hexadecimal number found in fromhex() arg at position 0

I’m using (trying to…) the mirobo-component as a switch for the plug as well.

I havent been able to integrate the socket with HA; but have managed to get the token working - which is of no use as of now :frowning:

I think your problem is that your are using b'token instead of just token

Yes, if I eliminate the " b’ " and the " ’ " from the token - I get the same error as you. Connection timed out. :frowning:

I’ve got some success with the miio platform


It also offers CLI to manage devices. I’m thinking of heading down the path of using this only for the switch.
I’m holding back as it seems like a bit of an overkill to install node.js on the pi to just switch on/off a switch with HA.

In which way did you succeed? Did you just install the miio-component as described?

Well I assume this repo isn’t maintained anymore? Currently I’m stuck with the error

Cannot import name ‘device’

I’ve opened an issue at his GitHub-repo… Just in case.
For now I’ve to schedule my plug with the Xiaomi-App. But maybe someday someone with more knowledge of python than me (which shouldn’t be difficult :-D) integrates this thing into HA.

@eiolos @maunsen @FletchNZ @seesopento

If anyone of you is still interested: it works now for me. I did the following (assuming you have the token and the device’s IP).

  1. Where to put the files:
    custom_components/switch/xiaomi.py --> /home/homeassistant/.homeassistant/custom_components/switch/xiaomiplug.py (I had to rename it - because of my integration of the Gateway)

I put the folder “xiaomi” under:
/home/homeassistant/.homeassistant/

And after adding the following to my configuration.yaml I got it working (remember to change the platform according to the name of the file you put under custom_components:

switch:
  - platform: xiaomiplug
    host: 192.168.0.81
    name: Kaffeemaschine
    token: 8735e7bd8f10b45ea6708ba89c1a4f7b

If there’re any questions just ask. I’ll try my best.

1 Like

which files did you get? just the switch/xiaomi.py??? or did you get the whole platform?

No. I put the xiaomi.py under my /home/homeassistant/.homeassistant/custom_components and the folder (!) xiaomi under /home/homeassistant/.homeassistant/ (ie. one level above the custom_components-folder

Didn’t see that too excited :grin:

Awesome!!! Works for me too.

1 Like