Xiaomi gateway issue

hi, i am new in home assistant, just set up hass.io , the discovery found yeelight lights, gateway, temperature sensor, door sensor, zigbee switch, everything works except for the the xiaomi switch that press the toggle and nothing happens, and the light in the gateway, what can i do, sorry for my english

I can confirm that controlling the Gateway light does not work from home-assistant as of yet.
But weirdly enough, it’s able to read the state of the light (on/off and the color).

The Xiaomi Aquara Component is fairly new and afaik the Xiaomi API is undocumented which makes development difficult. You probably just have to give the people working on this some time :slight_smile:

I can confirm that gateway light works perfectly. So… :slight_smile:

ok,thank you very much, thats exactly what happens, read the color and state, but not working, same thing for the plug, so its not a configuration problem?

how can you manage to get ir working?and the plug? it works?

Are you using hass.io or home-assistant? What version are you on? I just updated and it definitely doesn’t work. :confused:
Are you using the Mi Home App? Maybe it’s some sort of side effect?

Home assistant. Gateway light has been working since it was introduced. Now i’m on HA57.3

For the plug - do you have a zigbee or a wifi version? The latter needs the xiaomi_miio component and not the xiaomi_aqara

Hi, I’m using ha 57.3 in hass.io , the Gateway Light not working, and i have a zigbee plug that’s working on the mi home app, but not on HA, What can i do?

Check the log

Hey I had the same issue with the switch today.

You have to add the following to your config file

xiaomi_aqara:
discovery_retry: 5
gateways:
- key: xxxxxxxxxxxxxxxx

Follow the instruction here to get your key, note that the key needs to be 16 characters long or it wont validate for some reason, so just keep refreshing until you get a 16 character code and dont forget to press confirm on the mi home app.

https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)#Adding_the_Xiaomi_Gateway_to_Domoticz

1 Like

OK, that will solve the problems? ill do it as soon as i get home

im new in home assistant, dont know what to do with the log

hi, i get the key, add that to my config and now it wont recognized the gateway, and the states of the temperature, sensor, motion sensor, door , etc

Hey, did you run check config?

Then you should read the documentation https://home-assistant.io/docs/configuration/troubleshooting/

Did you get the gateway light to work from Hassio?

Hello,

I am having an issue with Xiaomi gateway too.
When I add gateway’s parameters into configuration.yaml and restarted HA - it finds the gateway, shows me all its connected sensors (one temp and one motion) and even shows me a switch to turn on the light.
When I click on the switch - it slides right and the gateways indeed turns its light on.
However 2-3 seconds later the switch turns itself off! The light on the gateway is still going on. If I click the switch again - it moves right, a message pops up saying "Turned on gateway light … " and 2-3 seconds later - again moves back left into “off” position. The light keeps going.
In the log I see messages like
ERROR (SyncWorker_14) [xiaomi_gateway] Got error element in data {“error”:“Invalid key”} which does not make sense since it was able to turn on the light at first place.

If I turn off the light via Mi Home app - the light switches off and then HA can turn it on again successfully and the whole process could be repeated again and again.

If that is important, I have defined the gateway like:
xiaomi_aqara:
discovery_retry: 5
interface: ‘192.168.1.65’
gateways:
- mac: ‘aabbccddeeff’
key: ‘abcdefghijklmnop’
host: ‘192.168.102.21’

The only “non-standard” thing here is that the gateway sits in different subnet from HA.
I’m using Hassbian.

If I use “Services” tools to manually call the service - it works without any problem - I can turn on the light, turn off and even toggle. All works fine but I am still getting the same error in logs.

Any help would be greatly appreciated.

Thanks.

The gateway light can always be controlled even with an invalid key. Check the troubleshooting part of the docs and move the gateway to the same subnet as that is most likely causing the problem.

Hi sjee,

with all due respect, my observation gave me different result.
When I put deliberately wrong key - I could NOT control lights, no matter how I tried.

Below is the log with correct key and incorrect key:
GOOD:
#
U 192.168.1.10:50870 -> 192.168.102.21:9898
{“cmd”: “write”, “sid”: “7c49ebb180a3”, “data”: {“rgb”: 1694498815, “key”: “06a82f04d7edef301aa226951be11454”}}
#
U 192.168.102.21:9898 -> 192.168.1.10:50870
{“cmd”:“write_ack”,“sid”:“7c49ebb180a3”,“data”:"{“error”:“Invalid key”}"}
#
U 192.168.1.10:36891 -> 192.168.102.21:9898
{“cmd” : “get_id_list”}
#
U 192.168.102.21:9898 -> 192.168.1.10:36891
{“cmd”:“get_id_list_ack”,“sid”:“7c49ebb180a3”,“token”:“rpQfQ7HjpI42MYqa”,“data”:"[“158d0002389f79”,“158d00029a9e01”]"}
#
U 192.168.1.10:51967 -> 192.168.102.21:9898
{“cmd”: “write”, “sid”: “7c49ebb180a3”, “data”: {“rgb”: 1694498815, “key”: “371b8a6cdd977a4650fa6a7a264e1411”}}
#
U 192.168.102.21:9898 -> 192.168.1.10:51967
{“cmd”:“write_ack”,“model”:“gateway”,“sid”:“7c49ebb180a3”,“short_id”:0,“data”:"{“rgb”:1694498815,“illumination”:1292,“proto_version”:
“1.1.2”}"}

#
U 192.168.1.10:35880 -> 192.168.102.21:9898
  {"cmd": "write", "sid": "7c49ebb180a3", "data": {"rgb": 0, "key": "371b8a6cdd977a4650fa6a7a264e1411"}}
#
U 192.168.102.21:9898 -> 192.168.1.10:35880
  {"cmd":"write_ack","model":"gateway","sid":"7c49ebb180a3","short_id":0,"data":"{\"rgb\":0,\"illumination\":1292,\"proto_version\":\"1.1.2\"
  }"}

Below is a log with WRONG key - you can easily see the difference:
BAD:
#
U 192.168.1.10:34736 -> 192.168.102.21:9898
{“cmd”: “write”, “sid”: “7c49ebb180a3”, “data”: {“rgb”: 1694498815, “key”: “7af615582021f0f1190baf3e4272bd17”}}
#
U 192.168.102.21:9898 -> 192.168.1.10:34736
{“cmd”:“write_ack”,“sid”:“7c49ebb180a3”,“data”:"{“error”:“Invalid key”}"}
#
U 192.168.1.10:45790 -> 192.168.102.21:9898
{“cmd” : “get_id_list”}
#
U 192.168.102.21:9898 -> 192.168.1.10:45790
{“cmd”:“get_id_list_ack”,“sid”:“7c49ebb180a3”,“token”:“fQAHHoorwDlbad0U”,“data”:"[“158d0002389f79”,“158d00029a9e01”]"}
#
U 192.168.1.10:41994 -> 192.168.102.21:9898
{“cmd”: “write”, “sid”: “7c49ebb180a3”, “data”: {“rgb”: 1694498815, “key”: “698cde88db61675774b00179435b6133”}}
#
U 192.168.102.21:9898 -> 192.168.1.10:41994
{“cmd”:“write_ack”,“sid”:“7c49ebb180a3”,“data”:"{“error”:“Invalid key”}"}
#
U 192.168.1.10:54829 -> 192.168.102.21:9898
{“cmd”: “write”, “sid”: “7c49ebb180a3”, “data”: {“rgb”: 1694498815, “key”: “698cde88db61675774b00179435b6133”}}
#
U 192.168.102.21:9898 -> 192.168.1.10:54829
{“cmd”:“write_ack”,“sid”:“7c49ebb180a3”,“data”:"{“error”:“Invalid key”}"}
#
U 192.168.1.10:55482 -> 192.168.102.21:9898
{“cmd” : “get_id_list”}
#
U 192.168.102.21:9898 -> 192.168.1.10:55482
{“cmd”:“get_id_list_ack”,“sid”:“7c49ebb180a3”,“token”:“b8iF0rUb0GMIOFhY”,“data”:"[“158d0002389f79”,“158d00029a9e01”]"}
#
U 192.168.1.10:49520 -> 192.168.102.21:9898
{“cmd”: “write”, “sid”: “7c49ebb180a3”, “data”: {“rgb”: 1694498815, “key”: “3eb11f90127b05e70be57e2252399fae”}}
#
U 192.168.102.21:9898 -> 192.168.1.10:49520
{“cmd”:“write_ack”,“sid”:“7c49ebb180a3”,“data”:"{“error”:“Invalid key”}"}

192.168.102.21 is a Xiaomi GW,
192.168.1.10 - my Linux server with HA running in docker.

I did use --net=host key:
docker run -d --name=“home-assistant” -v /srv/homeassistant:/config -v /etc/localtime:/etc/localtime:ro --net=host homeassistant/home-assistant

P.S. Well, my GW is still in different subnet but according to the HA manual, this is why “host” is here - in that case multicast mode is disabled and unicast is used. Am I wrong here?

My config:
xiaomi_aqara:
discovery_retry: 10
# interface: ‘192.168.1.10’
gateways:
- mac: 7c49ebb180a3
key: zx46e6tez9qwi4tz
host: 192.168.102.21

Move it to the same subnet like I mentioned before. Atleast to try it out.