Xiaomi Gateway Integration

Tried again today and it has worked!

Must have been something with the syntax before…

Great to hear that. I always check for syntax using the below command and has helped me multiple times even though I have been very careful. :wink:

hass --script check_config

Would it be possible to use fooxy code and integrate that one in HASS?

Why would we want to do that? fooxy code is implemented based on Aqara and what we have now is based on Xiaomi. We would have to change all the syntax. :cold_sweat: Besides, I believed @Danielhiversen fork is the most up-to-date for supporting the different features and devices.

But @Danielhiversen can’t integrate its repo to HA since it is forked from @rave 's repo, and @rave has not given permission for that,

It is really sad that we are currently at this state. I started few months back with HA and at that time had been very interested in Xiaomi platform. Very greatful that @rave has contributed so much to this but at the same time, we are limiting this component from really moving forward. When I started with Xiaomi, I was already using @Danielhiversen fork as that was the time that @rave kinda gone MIA. Last I checked, it was early May that he resurfaced and then went dark again. :disappointed: As of now, I am already having 17 devices and still adding. Not been having any issues with them except once in a while, my wireless switch is not able to control the gateway light on/off till i turned on the gateway light 1st using Mi Home app.

@Danielhiversen Is there really nothing you can help in making this component become official so that everyone can benefit from it? I believed @rave would also have the interest of this whole community. Especially now that there are a whole lot more new devices added to the family, the more we need to see the plan. :wink: Guess most of us here will be very eager to soon have those new devices working.

Sorry for the long thread…Just wanted to also acknowledge the great community here as I have learned a lot. :+1:

4 Likes

@Danielhiversen may start working on the fooxy code.

Besides more and more Xiaomi devices are coming out, Aqara brand, that are not working with rave code.

I think we should forget rave code, and move on with others code

I can not add the code to the main repository without a license. I have opened a pull request here https://github.com/lazcad/homeassistant/pull/63 and hope @rave will merge it

2 Likes

Hey, does anyone has a suggestion for my problem :(?

I’ll be back from my business trip tomorrow and would LOVE to fix this issue so that I can go on!

Thanks for all your help,
Daniel

Did you change the behaviour of your Aqara Wall Switch by the Mi Home app to a “Wireless switch”? Take a look at the screenshot of @jcastro. I’ve connected a Aqara Wall Switch today and changed the behaviour of the buttons to “Wireless Switch”. Unfortunately the gateway does not expose any button event. A wireshark capture of the network traffic shows nothing. The Mi Home app (“logs”) knows about the button events. The relays are decoupled now.

I know about the mode setting in the Mi Home app. In fact, I have a partial implementation for the the decoupled mode to work in HA (i.e. acts as if they are a wireless button and an independent switch).

Does anyone have one of these or this?

Or do you by chance know if these work with @Danielhiversen fork of Xiaomi custom component?

These are much cheaper than the older ones at the moment, that’s why I’m asking…

I have the new motion sensor and Temp sensor, they are both NOT working with HA at the moment. so I wouldn’t bet on the door sensor working either.

Currently there are no chance for them working in any fork/branch. The problem lies in the fact that the gateway is reporting their “model” as ‘’(empty string). I think we need to wait till at least version 1.0.8 of their gateway protocol before any of these sensors can be supported.

So it seems to be more a problem of gateway firnware rather than HA?

Does their app recognize the devices and readings properly yet?

I have both of those - the square temp and door sensor, they are supported in the MiHome android/IOS app but not in HA. Not for me at least.

1 Like

Can you give me a hint how do you access the button state programmatically? On my gateway firmware there is no MCAST or PUSH available.

Well Both, the gateway firmware is not exposing the new sensors yet, so there is no way HA can access it. By the time it does, there will be some update to the integration code needed because of the added functionalities.

With the wireless switch in decoupled mode, set the log level to debug for custom_components.xiaomi and you should see 1 PUSH per click with the channel remain a “off” or “on” when you press the button. something like the following.

2017-07-02 23:03:32 DEBUG (Thread-12) [custom_components.xiaomi] MCAST (report) << {‘short_id’: 40785, ‘cmd’: ‘report’, ‘data’: ‘{“channel_0”:“off”}’, ‘sid’: ‘158d00012900d2’, ‘model’: ‘ctrl_neutral2’}
2017-07-02 23:03:32 DEBUG (Thread-9) [custom_components.xiaomi] PUSH >> : {‘channel_0’: ‘off’}
2017-07-02 23:03:33 DEBUG (Thread-12) [custom_components.xiaomi] MCAST (report) << {‘short_id’: 40785, ‘cmd’: ‘report’, ‘data’: ‘{“channel_0”:“off”}’, ‘sid’: ‘158d00012900d2’, ‘model’: ‘ctrl_neutral2’}
2017-07-02 23:03:33 DEBUG (Thread-10) [custom_components.xiaomi] PUSH >> : {‘channel_0’: ‘off’}

I use the fact that there is a new “report” with the channel state remain unchanged as a cue for a “click” event.

Sadly the report-event disappears if I enable the decoupled mode. I’ve enabled the decoupled mode for the second channel. If I toggle both buttons there is just one event of the coupled mode :cold_sweat::

2017-07-02 20:11:34 DEBUG (Thread-20) [custom_components.xiaomi] MCAST (report) << {'sid': '158d00012f7c26', 'cmd': 'report', 'short_id': 51170, 'data': '{"channel_1":"off"}', 'model': 'ctrl_neutral2'}
2017-07-02 20:11:34 DEBUG (Thread-20) [custom_components.xiaomi] MCAST (report) << {'sid': '158d00012f7c26', 'cmd': 'report', 'short_id': 51170, 'data': '{"channel_1":"off"}', 'model': 'ctrl_neutral2'}
2017-07-02 20:11:34 DEBUG (Thread-20) [custom_components.xiaomi] MCAST (report) << {'sid': '158d00012f7c26', 'cmd': 'report', 'short_id': 51170, 'data': '{"channel_1":"on"}', 'model': 'ctrl_neutral2'}

Sorry can anybody help me with this, I had the gateway running before but nowI get errors when during startup:

2017-07-02 21:44:45 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/setup.py”, line 190, in _async_setup_component
component.setup, hass, processed_config)
AttributeError: ‘module’ object has no attribute ‘setup’

My config: (here without spaces)
xiaomi:
gateways:

  • sid:
    key: t6cbylnjpfdn1z9y

pleae help