Xiaomi gateway integration - help needed

You forgot the last step.
Go to https://github.com/home-assistant/home-assistant.github.io/compare/current...jvimont:patch-1
And press Create pull request

Great, I will merge your pull request when the tests are finished.

3 more pull requests in October, and you will get a free T-shirt: https://home-assistant.io/blog/2017/09/29/hacktoberfest/

Hey everyone is there a way to Activate/Control the RGB portion of the Gateway’s light? HASS only sees it as a Normal Light not a Colour Light.

Hi,

Ones you switched on light, then you can control brightness and colour.

When it’s off, then you can’t.

imagen

Hi @Danielhiversen. Thanks for the explanation. I ran the ngrep command and it seems those packages are also lost (results below). However, I have no idea how to fix it. I’m not using docker, I’m running HA on a Ubuntu Sever machine on Virtualbox. Any ideas? Thank you!

U 192.168.1.158:58941 → 192.168.1.190:9898
{“cmd” : “get_id_list”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“get_id_list_ack”,“sid”:“34ce008392d4”,“token”:“pYXWDM7yty4AbB38”,“data”:“["158d0001716fbc","158d0001228
96c","158d000183fa7a","158d0001225b3b","158d0001107e27","158d00016bfb96","158d000124408d"]”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{“cmd”:“read”,“sid”:“158d0001716fbc”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“plug”,“sid”:“158d0001716fbc”,“short_id”:7524,“data”:“{"voltage":3600,"status":"off
","inuse":"0","power_consumed":"240","load_power":"0.00"}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{“cmd”:“read”,“sid”:“158d000122896c”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“motion”,“sid”:“158d000122896c”,“short_id”:33372,“data”:“{"voltage":3035,"status":"
motion"}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{“cmd”:“read”,“sid”:“158d000183fa7a”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“magnet”,“sid”:“158d000183fa7a”,“short_id”:31442,“data”:“{"voltage":2995,"status":"
close"}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{“cmd”:“read”,“sid”:“158d0001225b3b”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“switch”,“sid”:“158d0001225b3b”,“short_id”:10990,“data”:“{"voltage":3022}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{“cmd”:“read”,“sid”:“158d0001107e27”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“cube”,“sid”:“158d0001107e27”,“short_id”:44228,“data”:“{"voltage":2975}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{“cmd”:“read”,“sid”:“158d00016bfb96”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“switch”,“sid”:“158d00016bfb96”,“short_id”:4833,“data”:“{"voltage":3042}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{“cmd”:“read”,“sid”:“158d000124408d”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“switch”,“sid”:“158d000124408d”,“short_id”:31253,“data”:“{"voltage":3022}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{“cmd”:“read”,“sid”:“34ce008392d4”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“gateway”,“sid”:“34ce008392d4”,“short_id”:0,“data”:“{"rgb":0,"illumination":356,"pr
oto_version":"1.0.9"}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{ “cmd”:“read”,“sid”:“158d000122896c”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“motion”,“sid”:“158d000122896c”,“short_id”:33372,“data”:“{"voltage":3035,"status":"
motion"}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{ “cmd”:“read”,“sid”:“158d000122896c”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“motion”,“sid”:“158d000122896c”,“short_id”:33372,“data”:“{"voltage":3035,"status":"
motion"}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{ “cmd”:“read”,“sid”:“158d000122896c”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“motion”,“sid”:“158d000122896c”,“short_id”:33372,“data”:“{"voltage":3035,"status":"
motion"}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{ “cmd”:“read”,“sid”:“158d000122896c”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“motion”,“sid”:“158d000122896c”,“short_id”:33372,“data”:“{"voltage":3035,"status":"
motion"}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{ “cmd”:“read”,“sid”:“158d000122896c”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“motion”,“sid”:“158d000122896c”,“short_id”:33372,“data”:“{"voltage":3035,"status":"
motion"}”}

U 192.168.1.158:58941 → 192.168.1.190:9898
{ “cmd”:“read”,“sid”:“158d000122896c”}

U 192.168.1.190:9898 → 192.168.1.158:58941
{“cmd”:“read_ack”,“model”:“motion”,“sid”:“158d000122896c”,“short_id”:33372,“data”:“{"voltage":3035,"status":"
motion"}”}

You can also create scripts to turn on the light to a specific color.

purple_night_light:
  alias: Purple
  sequence:
    - service: homeassistant.turn_on
      entity_id: light.gateway_light_34ce008d4aae
      data:
        brightness: 255
        rgb_color: [88,0,82]

white_night_light:
  alias: White
  sequence:
    - service: homeassistant.turn_on
      entity_id: light.gateway_light_34ce008d4aae
      data:
        brightness: 255
        rgb_color: [255,255,255]
1 Like

Are you using --net=host ?

Sorry, I have no idea about how to check it. Anyway, I’m not using Docker, so that shouldn’t be affecting me, right?

However, I’m starting to think that my router does not support multicast…

Thank you

I’ve also been struggling with getting Home Assistant to find my gateway. I’ve tried pretty much everything in the Troubleshooting section of the documentation, I just can’t verify if my router is allowing Multicast traffic. Not sure how to debug that. Any tips on that? I’m running Home Assistant using Hass.io.

UPDATE: I tried messing around with this library https://github.com/quibusus/node-xiaomi-smart-home and can see heartbeats and reports coming in, so I guess Multicast is working. However, there doesn’t seem to be any response from the gateway to the “whois” command that is send at the beginning.

I created an issue and will try to implement some logging to address multicast issues in future:

https://github.com/Danielhiversen/PyXiaomiGateway/issues/26

as I tried everything else, I suppose, my router does not support multicast. how can I fix this?

do i have to replace the router or can i just add a switch, that supports multicast?

if the xiaomi gateway needs multicast - is this only in HA or is it the same in other software like openhab oder iobroker - so i could check, if it is really the router or the gateway does not work?

I assume all implementations rely on multicast. Just ensure the path/network between home assistant and the xiaomi gateway is multicast capable. In general your wifi access point is the problem.

ok, thanks. do you have any recommendations for multicast routers?

I went and bought myself a new router for this exact same issue (and the router my ISP gave me sucked anyway).

I got the TP-LINK Wireless Router Archer C2. Nice 4-port gigabit router with multiband wifi. And you should be able to find it under 50 euro’s. (Or whatever currency you use)

1 Like

great, i’ll give that a try. this worked for you?

Yea, it works perfectly now :slight_smile:

ok, i got the router today and tried - unfortunately it still changed nothing it agains shows the “invalid key” notice.
i again checked the key via ios and android.

what i did: i got the new router (tplink archer c2) and linked it to the original router which is now just serving as a modem. then i attached rasp pi 3/hass.io to the new router and also added the xiaomi gateway to the network of the new router. a changed the details in the config, but nothing happens. it again shows the invalid key message. i did the same to test it with a smart plug, this worked perfectly.

could you give me a hint what i can still try to get this running? i really would like to use this gateway, as the temperature sensors are really reasonably priced and i would like to monitor all my rooms with them.

would be great, if you have fürther hints for me, thanks!

What’s the distance between router (archer c2) and your xiaomi gateway? Packet loss would be a big problem, too. cp. https://github.com/Danielhiversen/PyXiaomiGateway/issues/26

just to test it, i set them very close together. it’s less than 5 metres.

i just read, that another user solved it by using capitals instead of lower case for the key. i tried this already - but for another router - so i’ll give this another try with the archer c2. it’s the only thing i know left to try.

I would try a fresh install of raspbian and HA.

1 Like