Mi(Xiaomi) Smart home bindings?

But maybe it might be smart to include it into the same binding? So that in the end ALL Mi Smart Home components can be used with this binding. It would then not go through the gateway, but use bluetooth. That might work and would be user friendly I think. But I have no idea yet how to use the bluetooth in a binding.
So depending on how that all works, it would make sense to split them into separate bindings or have them in one. For now I hope that in the future it can be included in the same binding. So I will call the binding mihome.

Here is the current version of the binding. Still work in progress. When done (or in a state that I think is acceptable), I will try to find out how to get it into the official repository so it can be installed from within openhab2.

7 Likes

O.k., so my efforts will be not in wasted time then. I will continue to convert the python based code that was written elsewhere to whatever BLE API will end up merged into ESH core.

1 Like

I don’t have a Xiaomi Gateway (i have OH and ISY), but I do have a Mi Air. Will this binding work with Mi Air? I think similar to Nest, the appliance connects back to some Xiaomi cloud gateway for control via smartphone app.

@Ondrej_Pecta, this is fantastic. Thank you so much for your work.
I just received my Gateway with the door, motion and button sensors. I got the door sensor and button up and running just fine with your binding. Motion however doesn’t trigger for me. I get the report for it in log, but the item does not update.

Log:
2017-01-05 21:04:34.786 [INFO ] [o.o.b.x.i.XiaomiGatewayBinding] - Xiaomi received packet: {“cmd”:“report”,“model”:“motion”,“sid”:“158d00010efcaa”,“short_id”:59354,“data”:"{“status”:“motion”}"}

Items file entry:
Contact XiaomiMotion “Xiaomi motion [%s]” { xiaomigateway=“158d00010efcaa.motion” }

Sorry this binding won’t work with Mi Air. But I found something interesting regarding this cloud solution - look here: https://github.com/louisZL/aiot-open-2b
There seems to be some cloud platform documentation and it has BTW support for this Xiaomi gateway with codename lumi.gateway.v3 (https://github.com/louisZL/aiot-open-2b/blob/master/resource_definition.md).
Maybe it supports other xiaomi products as well…

@acittlau thank you very much for testing my binding and sharing log entries. Since I have no motion sensor, the support was missing.
I’ve just added support for motion sensor, can you please test it?
Please see this new version and let me know…
If you find it working I’ll push it to master and release a new official snapshot
Thanks.

1 Like

@Ondrej_Pecta I can confirm that this new version works perfectly for the motion sensor also! Again, thank you for your work.

2017-01-05 23:29:16.895 [INFO ] [o.o.b.x.i.XiaomiGatewayBinding] - Xiaomi received packet: {"cmd":"report","model":"motion","sid":"158d00010efcaa","short_id":59354,"data":"{\"status\":\"motion\"}"}
2017-01-05 23:29:16.895 [INFO ] [runtime.busevents             ] - XiaomiMotion state updated to OPEN

@Ondrej_Pecta you are using my version? did you try my newest version? that one should support every sensor. in the first version i pushed here it was only the temperature sensor. now all should work fine. I have tested all here. Or if it was my new version, can you tell me what was buggy so i can fix it? :slight_smile:
I now have a nice setup for testing the button/switch. Works fine together with a rule that turns on/off a yeelight :slight_smile:.
On the links you published above they show many values available for the xiaomi gateway. I wonder how we can access them or even set them (light the light on the gateway). Do you know where to find such information? As well the plug seems to have power consumption values. Those are never sent over the network though. Do you or anyone else know how to get them? Would like to make this binding support all features. If possible even audio if someone knows how to send audio to the gateway.

Sorry, someone on OH2 must test your version, I am still on OH1 and I am using only my version. All sensor types and button have been tested so far, now we need to test controlling of switches. Moreover I have ordered a Xiaomi cube and I am eager to test it, but unfortunately I’ve heard no events from cube are broadcasted on local network yet - so we have to wait for a new firmware which (hopefully) enables other features including cube events…
Manipulation with gateway light is described here, but I haven’t manged to get it working, I’m getting an error of unknown sid, when I write something to my gateway…
I guess we need to wait either for a new gateway firmware which will spread more events to local network/enable controlling of other features or get an access to this cloud platform (e.g. by reverse engineering an android Mi Home application which must do this job)

I see. On your binding :). I actually based most my stuff on your binding. I actually used your code and just rewrote most of it to work with OH2. Great job you did! For how to getting stuff to work, you can just check my code. Should be fairly easy I think.
Thanks for the link for the gateway light! Will give it a try soon :slight_smile:. Hope I can get it to work.

@Ondrej_Pecta
Awesome work! I’m just waiting for my kit to arrive. It’s Out of stock at the moment
Can’t wait to try it.

I can confirm the RGB control works fine with the latest gateway firmware, I’ll release an updated binding version soon :slight_smile:

2 Likes

hi all, please help. sensors may be added without using the application on your smartphone?

Since firmware update to 1.4.1_143.0141 I cannot add new devices via the mihome app.

Will i get a notification when battery from the sensor is weak?

I’d like to know this as well. My sensors are still in the transit, so I can’t check it but someone might want to put an ‘used’ battery to see if the device(s) report anything to the gateway that we can capture somehow.

I don’t think so - you have to switch the gateway to learning mode. AFAIK there is no other way than using Mi Home application.

Thank you so much. When a new version mihome binding will be possible?

You can find new releases here: https://github.com/octa22/org.openhab.binding.xiaomigateway/releases

1 Like