Xiaomi Gateway Integration


Tried enabling and disabling local control in the app, didn’t help though

In the app, under network info I have current mode: remote connection - is that the same for you? do I need to restart the gateway after enabling local control?


Is now possible to use other server (like Singapore) and still use the gateway in HASS?



Is it just me that the wall switches binary_sensor.wall_switch_* stopped working?
On the MiHome app they are there and creating an automation they work fine.
On HA I see the devices binary_sensor.wall_switch_* with the same name as the gateway app JSON response but debugging HA when I click on the wall switch it doesn’t even show. Any other stuff like illumination, binary_sensor.switch_*, etc shows fine on the debugger when I use them.


Edit: gateway version: 2.32 json version code: 140



I’ve some issues with the two channel wall switch also. Xiaomi component have created 3 binary sensor (wall switch left, wall switch right, and both). But since a few days, I can’t trigger automation using the left one. Maybe an issue related to the recent firmware upgrade ?


I have the same with a two channel wall switch, only works 1 of them…


Hi guys,
First of all, you have done a great job with Xiaomi Gateway.
Only recently I have got Xiaomi Smart Home set and started playing with it.
It is a great thing that most of sensors and options already working with HAAS.

One important feature is still missing, it is an ability to Arm or DisArm Alarm using HAAS.
I have done some research and found at page (https://www.gitbook.com/book/forrestfung/lumi-gateway-local-api/details) that there is API version 1.0.9 (https://cnbj2.fds.api.xiaomi.com/lumiaiot/common/gateway/绿米网关局域网通信协议V1.0.9_2017.08.01.doc).

It has the ability to simulate virtual click event over multicast with a command:
{“cmd”:“write”,“model”:“switch”,“sid”:“112316”,“short_id”:4343,“data”:"{“status”:“click”}" }

Perhaps we can make event function that would trigger this event on call, so HAAS could be configured to send Arm/DisArm (double click event).


There are also some nice features that could be useful for HAAS like API call for sub-device connection:
{“cmd”:“write”,“model”:“gateway”,“sid”:“6409802da2af”,“short_id”:0,“data”:"{“join_permission”:“yes”}" }


It’s possible to arm/disarm the gateway by the mi home app? I don’t think so.


Hey guys,

you have done an amazing job.
Since there are only components manageable, which are directly connected to the gateway, I cannot control my Xiaomi Wifi Remote Control Outlet Power Strip.
But my cube flip90 event turns the power strip on (Definition in the Xiaomi Home App).
And I can handle the event in HA.

Is the other way also possible?
I’d like to fire the same flip90 event from home assistant, so I can control the power strip indirectly through HA?

If so, could you please help me with some basic example?



The power strip is supported by another component. Take a look here: Xiaomi mi wifi plug & air purifier

Next step will be a home assistant automation to connect both devices.


It’s possible, it also shows the status of arm/disarm.


Cool. May be the feature will be exposed for the local network protocol soon. I assume the “virtual click event” cannot be used.


my single wireless wall switch has stopped working and I have the latest firmware, grrr

Also what is the range of the hub and sensors please? I have a several motion/temp sensors down stairs, all perfect. but on my landing, the motion sensor/lux are sketchy and the temp on next to it, keeps going to offline. It is wise to have 1 gateway up and 1 downstairs?



that’s how I do


thanks Claudio. Is it possible to roll back firmware? The wall switch produces a log of a click, but not in ha since the firmware upgrade :frowning:


I don’t know how to


Can you tell me the type of the device? It’s the wireless wall switch without a relay, right?


it is the Xiaomi Aqara Smart Light Switch Wireless Version, that runs from battery. It was working perfectly with a toggle automation, thanks to you :slight_smile:


May be the format of the event has changed. I will check it and report.


How guys can you see the json messages between the gateway and HA ? Only using Wireshark ? Or is there any other way ?