Xiaomi Home : Which API is best suited for Eg Integration?

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Foune
Experienced User
Posts: 94
Joined: Sun Jul 03, 2011 7:08 pm

Xiaomi Home : Which API is best suited for Eg Integration?

Post by Foune » Tue Aug 29, 2017 11:24 am

Hello,

I'd like the Xiaomi Gateway to generate nice Eg events with payloads. Currently Eg relies on Domotic'z xiaomi plugin, but being dependant of Domoticz is a problem as I depend on third party developper updates, which are frequently needed when xiaomi updates it's protocol (usually for new hardware).

I found two API :

The simpler : https://github.com/jon1012/mihome
The evolution of the previous one : https://github.com/monster1025/aqara-mqtt

I don't know which one is the more appropriate for an Eg adaptation, can somebody look quickly and tell me which one would best match with Eg?

User avatar
yokel22
Experienced User
Posts: 229
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Xiaomi Home : Which API is best suited for Eg Integratio

Post by yokel22 » Tue Aug 29, 2017 3:34 pm

They both use MQTT, so either should work. I'd try the second one. It looks like it's setup a bit smarter.

Foune
Experienced User
Posts: 94
Joined: Sun Jul 03, 2011 7:08 pm

Re: Xiaomi Home : Which API is best suited for Eg Integratio

Post by Foune » Tue Aug 29, 2017 4:52 pm

Thank you for your advice. In fact I don't want the MQTT part, I'm looking for Eg Events, so I'll have to dig on this;

User avatar
yokel22
Experienced User
Posts: 229
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Xiaomi Home : Which API is best suited for Eg Integratio

Post by yokel22 » Tue Aug 29, 2017 5:00 pm

Sorry, I completely misunderstood what you were asking. Upon actually looking at the source code. They both are using websocket connections for comm with the bridge. There isn't a ton of difference in how the connection is setup. Either one should be adaptable for an e.g. plugin.

Foune
Experienced User
Posts: 94
Joined: Sun Jul 03, 2011 7:08 pm

Re: Xiaomi Home : Which API is best suited for Eg Integratio

Post by Foune » Wed Aug 30, 2017 8:52 am

Nice.
Last question : do you know a very simple Eg plugin that could be a template for the xiaomi plugin? The main feature is the keep alive mechanism.

User avatar
yokel22
Experienced User
Posts: 229
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Xiaomi Home : Which API is best suited for Eg Integratio

Post by yokel22 » Wed Aug 30, 2017 5:04 pm

The simplest I can think of off hand is the denon plugin. http://eventghost.net/forum/viewtopic.php?f=9&t=7464. However, that plugin doesn't keep an open pipe for events. It would help with setting up the basic socket connection though. I'll see if I can't find a better example for you.

Also see the socket module documentation here: https://docs.python.org/2/library/socket.html

Post Reply