Xiaomi Gateway Integration

That’s annoying sorry to hear that :-(, today i got my wireless switches… lets see if they work well…

When my second gateway arrives, i will mount it additional with another door sensor and pir sensor, lets see if its hardware dependent then…i guess not as it happens just with activated dev mode and the mcast notifications are wrong, but just to make sure.

I guess xiaomi will have to fix it with a firmware update… By the way, report it to them as an issue. You can do that from the app settings, on the feedback menu.

The more people report it, the more probable it is that they fix it.

1 Like

There is a chance that smoke and gas sensors from this Xiaomi camera http://www.gearbest.com/ip-cameras/pp_607361.html will work with this component?

Read it again it says it picks up the sound of a smoke alarm . The specs don’t have the smoke sensors.

Of course, you are right. I think I’m blind today :wink:

Mihome app reports the sensors properly while homeassistant component returns false positives after power outage.

Yeah, but its still a bug on the gateway. The gateway reports the state correctly to Xiaomi servers, but reports wrong status locally.

Is there a way to view (change) which Zigbee channel is the Gateway using?

Might be not a bug…

I had to roll back a few commits to get this fixed. Can you post this as an issue on the repo? And give some more details - like your config. This thread is overflowing with information.

Agreed. However my understanding is the siren will be managed by HASS. If it will be handled by the xiaomi gateway - then yes.

good to see it’s not just me then. will post issue on repo and rollback for the moment.

After upgrade to 0.39 noticed the following in logs. Something to worry about?

WARNING (MainThread) [custom_components.binary_sensor.xiaomi] sensor_class is deprecated. Please rename sensor_class to device_class in '/home/homeassistant/.homeassistant/custom_components/binary_sensor/xiaomi.py' to ensure future support.

@rave I have 3 Xiaomi power outlets and 2 are the zigbee version and the other one is just the wifi one. I bought the wifi only one as a standalone before i knew about the other sensors. I am able to add it to my devices in the Xiaomi app and use it just like all the other devices. However, the wifi one does not populate over to home assistant when everything else did. Is this because it doesn’t go via the gateway (straight through the wifi through to the chinese severs the app is hosted on)?
Sorry if that’s a dumb question…
Has anyone interfaced the wifi power socket one into home assistant? Thanks!

Which commit you rolled back to?

I’m still on 0.38. Let me updated to 0.39. For now, it should work

Yeah, only Zigbee devices which is connected to the gateway is supported. I couldn’t find anything online about any open port or API to connect to the plug. If someone has any slight about it then i would be happy to implement it as well

1 Like

I can add the XiaoMi gateway into the HASS, but I can’t control the Gateway-Light through the hass-webpage. When I closed the Gateway-Light on the HASS webpage, after 2 or 3 seconds, the toggle “back to OFF” by itself.

Another stange thing: when I use the phone-app(xiaomi app) to change the light color, the changing showing on the webpage of HASS.

Hardware:Rpi3 + XiaoMi gateway(only)
Software: HASSbian 1.1+toybox
HassVersion: 0.39.1
HASS-configuration:
xiaomi:
gateways:
- sid:
key: cf44de72xxxxxxxx

log:

17-02-27 07:50:52 INFO (Thread-5) [custom_components.xiaomi] Expecting 1 gateways
17-02-27 07:50:52 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Gateways (Try 1)
17-02-27 07:50:52 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway f0b429b3eae8 found at IP 192.168.1.188
17-02-27 07:50:52 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices
17-02-27 07:50:52 DEBUG (Thread-5) [custom_components.xiaomi] >> b’{“cmd” : “get_id_list”}’
17-02-27 07:50:52 DEBUG (Thread-5) [custom_components.xiaomi] << {‘sid’: ‘f0b429b3eae8’, ‘data’: ‘[]’, ‘token’: ‘J31zPwX8dLD8QM7R’, ‘cmd’: ‘get_id_list_ack’}
17-02-27 07:50:52 INFO (Thread-5) [custom_components.xiaomi] Found 1 devices
17-02-27 07:50:52 DEBUG (Thread-5) [custom_components.xiaomi] >> b’{“cmd”:“read”,“sid”:“f0b429b3eae8”}’
17-02-27 07:50:52 DEBUG (Thread-5) [custom_components.xiaomi] << {‘short_id’: 0, ‘sid’: ‘f0b429b3eae8’, ‘model’: ‘gateway’, ‘data’: ‘{“rgb”:637468881}’, ‘cmd’: ‘read_ack’}
17-02-27 07:50:57 INFO (Thread-5) [custom_components.xiaomi] Gateway finding finished in 5 seconds
17-02-27 07:50:57 INFO (Thread-5) [custom_components.xiaomi] Creating Multicast Socket
17-02-27 07:50:57 INFO (Thread-5) [custom_components.xiaomi] Listening for broadcast
17-02-27 07:51:03 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {‘short_id’: 0, ‘sid’: ‘f0b429b3eae8’, ‘model’: ‘gateway’, ‘data’: ‘{“rgb”:637468728}’, ‘cmd’: ‘report’}
17-02-27 07:51:03 DEBUG (Thread-8) [custom_components.xiaomi] PUSH >> : {‘rgb’: 637468728}
17-02-27 07:51:12 DEBUG (Thread-1) [custom_components.xiaomi] >> b’{“sid”: “f0b429b3eae8”, “data”: {“key”: “926c4816cf976ee46a11c3eddab5908d”, “rgb”: 1593831908}, “cmd”: “write”}’
17-02-27 07:51:12 DEBUG (Thread-1) [custom_components.xiaomi] << {‘sid’: ‘f0b429b3eae8’, ‘data’: ‘{“error”:“Invalid key”}’, ‘cmd’: ‘write_ack’}
17-02-27 07:51:12 ERROR (Thread-1) [custom_components.xiaomi] Got error element in data {“error”:“Invalid key”}
17-02-27 07:51:14 DEBUG (Thread-9) [custom_components.xiaomi] >> b’{“sid”: “f0b429b3eae8”, “data”: {“key”: “926c4816cf976ee46a11c3eddab5908d”, “rgb”: 1577910147}, “cmd”: “write”}’
17-02-27 07:51:14 DEBUG (Thread-9) [custom_components.xiaomi] << {‘sid’: ‘f0b429b3eae8’, ‘data’: ‘{“error”:“Invalid key”}’, ‘cmd’: ‘write_ack’}
17-02-27 07:51:14 ERROR (Thread-9) [custom_components.xiaomi] Got error element in data {“error”:“Invalid key”}
17-02-27 07:51:15 DEBUG (Thread-3) [custom_components.xiaomi] >> b’{“sid”: “f0b429b3eae8”, “data”: {“key”: “926c4816cf976ee46a11c3eddab5908d”, “rgb”: 1577910147}, “cmd”: “write”}’
17-02-27 07:51:15 DEBUG (Thread-3) [custom_components.xiaomi] << {‘sid’: ‘f0b429b3eae8’, ‘data’: ‘{“error”:“Invalid key”}’, ‘cmd’: ‘write_ack’}
17-02-27 07:51:15 ERROR (Thread-3) [custom_components.xiaomi] Got error element in data {“error”:“Invalid key”}
17-02-27 07:51:15 DEBUG (Thread-11) [custom_components.xiaomi] >> b’{“sid”: “f0b429b3eae8”, “data”: {“key”: “926c4816cf976ee46a11c3eddab5908d”, “rgb”: 1579555071}, “cmd”: “write”}’
17-02-27 07:51:15 DEBUG (Thread-11) [custom_components.xiaomi] << {‘sid’: ‘f0b429b3eae8’, ‘data’: ‘{“error”:“Invalid key”}’, ‘cmd’: ‘write_ack’}
17-02-27 07:51:15 ERROR (Thread-11) [custom_components.xiaomi] Got error element in data {“error”:“Invalid key”}
17-02-27 07:51:16 DEBUG (Thread-6) [custom_components.xiaomi] >> b’{“sid”: “f0b429b3eae8”, “data”: {“key”: “121a6577116b2fa703e627a487bae06b”, “rgb”: 1592330751}, “cmd”: “write”}’
17-02-27 07:51:16 DEBUG (Thread-6) [custom_components.xiaomi] << {‘sid’: ‘f0b429b3eae8’, ‘data’: ‘{“error”:“Invalid key”}’, ‘cmd’: ‘write_ack’}
17-02-27 07:51:16 ERROR (Thread-6) [custom_components.xiaomi] Got error element in data {“error”:“Invalid key”}
17-02-27 07:51:17 DEBUG (Thread-5) [custom_components.xiaomi] >> b’{“sid”: “f0b429b3eae8”, “data”: {“key”: “121a6577116b2fa703e627a487bae06b”, “rgb”: 1592852700}, “cmd”: “write”}’
17-02-27 07:51:17 DEBUG (Thread-5) [custom_components.xiaomi] << {‘sid’: ‘f0b429b3eae8’, ‘data’: ‘{“error”:“Invalid key”}’, ‘cmd’: ‘write_ack’}
17-02-27 07:51:17 ERROR (Thread-5) [custom_components.xiaomi] Got error element in data {“error”:“Invalid key”}
17-02-27 07:51:17 DEBUG (Thread-7) [custom_components.xiaomi] >> b’{“sid”: “f0b429b3eae8”, “data”: {“key”: “121a6577116b2fa703e627a487bae06b”, “rgb”: 1593180298}, “cmd”: “write”}’
17-02-27 07:51:17 DEBUG (Thread-7) [custom_components.xiaomi] << {‘sid’: ‘f0b429b3eae8’, ‘data’: ‘{“error”:“Invalid key”}’, ‘cmd’: ‘write_ack’}
17-02-27 07:51:17 ERROR (Thread-7) [custom_components.xiaomi] Got error element in data {“error”:“Invalid key”}
17-02-27 07:51:18 DEBUG (Thread-4) [custom_components.xiaomi] >> b’{“sid”: “f0b429b3eae8”, “data”: {“key”: “121a6577116b2fa703e627a487bae06b”, “rgb”: 1581974271}, “cmd”: “write”}’
17-02-27 07:51:18 DEBUG (Thread-4) [custom_components.xiaomi] << {‘sid’: ‘f0b429b3eae8’, ‘data’: ‘{“error”:“Invalid key”}’, ‘cmd’: ‘write_ack’}
17-02-27 07:51:18 ERROR (Thread-4) [custom_components.xiaomi] Got error element in data {“error”:“Invalid key”}
17-02-27 07:51:44 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {‘short_id’: 0, ‘sid’: ‘f0b429b3eae8’, ‘model’: ‘gateway’, ‘data’: ‘{“rgb”:637534178}’, ‘cmd’: ‘report’}
17-02-27 07:51:44 DEBUG (Thread-1) [custom_components.xiaomi] PUSH >> : {‘rgb’: 637534178}
17-02-27 07:51:56 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {‘short_id’: 0, ‘sid’: ‘f0b429b3eae8’, ‘model’: ‘gateway’, ‘data’: ‘{“rgb”:1191182306}’, ‘cmd’: ‘report’}
17-02-27 07:51:56 DEBUG (Thread-9) [custom_components.xiaomi] PUSH >> : {‘rgb’: 1191182306}
17-02-27 07:52:01 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {‘short_id’: 0, ‘sid’: ‘f0b429b3eae8’, ‘model’: ‘gateway’, ‘data’: ‘{“rgb”:318767074}’, ‘cmd’: ‘report’}
17-02-27 07:52:01 DEBUG (Thread-11) [custom_components.xiaomi] PUSH >> : {‘rgb’: 318767074}
17-02-27 07:52:04 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {‘short_id’: 0, ‘sid’: ‘f0b429b3eae8’, ‘model’: ‘gateway’, ‘data’: ‘{“rgb”:1006632930}’, ‘cmd’: ‘report’}
17-02-27 07:52:04 DEBUG (Thread-6) [custom_components.xiaomi] PUSH >> : {‘rgb’: 1006632930}
17-02-27 07:52:07 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {‘short_id’: 0, ‘sid’: ‘f0b429b3eae8’, ‘model’: ‘gateway’, ‘data’: ‘{“rgb”:1577058274}’, ‘cmd’: ‘report’}
17-02-27 07:52:07 DEBUG (Thread-5) [custom_components.xiaomi] PUSH >> : {‘rgb’: 1577058274}
17-02-27 07:52:10 DEBUG (Thread-13) [custom_components.xiaomi] MCAST (report) << {‘short_id’: 0, ‘sid’: ‘f0b429b3eae8’, ‘model’: ‘gateway’, ‘data’: ‘{“rgb”:251658210}’, ‘cmd’: ‘report’}
17-02-27 07:52:10 DEBUG (Thread-7) [custom_components.xiaomi] PUSH >> : {‘rgb’: 251658210}

The one where you merged my pull request. I had been using it without too much trouble for quite some time (save for having an error thrown on shutdown/restarts about OSError). I updated it to take advantage of resolving the 100ºC/0% Humidity value of the temperature sensor and then rolled it back after a few hours.

https://github.com/lazcad/homeassistant/commit/1051dbc95d7f87d0fac96129b889d066b91f8d54

Invalid key means your API key is wrong. Double check the key for typo.