Xiaomi Gateway Integration

So i’ve now also tried changing the settings on my TP-link router from IGMP version 2 to 3.

I also have added the sid in with lowercase and no dashes with the same outcome…

xiaomi:
  gateways:
    - sid: f0b429aa2ac1
      key: h8lfwhm7hw0szqq1

It’s in the DHCP table, it works directly from mobile devices on my network (and externally) to view sensors etc.

I have tried stripping back my config file to see if its a conflict, nothing seems to be resolving it.

Now I have just deleted the whole custom_components folder and installed it fresh from the github.

I found the virtual folder on my pi then tested putting the files in that folder as well, and removing from the custom_components folder.

Tested that… same result :expressionless:

I’m running outta ideas now…

Hmm, strange.You can try to increase the timeout: https://github.com/lazcad/homeassistant/blob/master/components/xiaomi.py#L108

1 Like

To me it more sounds like a network-related hardware config/defect issue.
The detection of the gateway goes with a multicast message (please correct me if i’m wrong).

Does your router allow this messages and send it thought the complete network?
Maybe you can use a network sniffer to see this behavior?

Then install the sniffer on the same WiFi as the gateway.

Got any mac sniffer suggestions? I’ll set it up and figure this out…

You have more then one wifi?
Extenders?
2.4 and 5 Bands?

Not sure if it is related to Xiaomi component we are using… But… Is there a way to pass an API call to the gateway to control a wifi device connected to Mi Home? Have a Philips Xiaomi Eyecare lamp

All API supported on the gateway is already exposed in the component. For the lamp, it might have API based on TCP/UDP to control it but i don’t think it is related to the gateway (zigbee only) at all.

try set the interface option and see if it helps

1 Like

What a wonderful work! I’m impressed.

Is there a known date for official component release in home assistant? Can I expect this plugin in the next version? Or are there still issues or bugs in the component?

Yes i guess it’s an TCP/UDP. Just wondering how it works.
I managed to create s rule in Mi Home that pressing a zigbee button will switch the lamp on and off. So those rules are cloud based? Or is it the gateway handling the TCP/UPD commands?

Does it go like
Scenario A
Button-Gateway-Cloud-Gateway-Lamp
Scenario B
Button-Gateway-Lamp

Wireshark is a nice sniffer

1 Like

@Danielhiversen is there something, you know of, that has to be refactored before it can be accepted in HA?
Maybe I can do some of this work already?

What I think should be done:

  • Merge the two pending pull requests.
  • Make vol.Schema for the gateways, not only test for list
  • Make sure flake8 and pylint pass (There are a lot of too long lines and invalid variable names)
  • sid is not very user friendly, so I think it would be better to have the user give the mac address. Then we should convert the mac address to the sid.
  • Move class XiaomiComponent to a separate library.
  • Split up class XiaomiGateway and move to the same library. (The external library should not have any HA code, so XIAOMI_HA_DEVICES should not be part of that library)
  • (The binary sensors are not actually binary. I am not sure how we should solve this, but specially the cube could be moved to a sensor. Where the state is the last action?)

Point 2, 3 and 4 could be a good start. But the pending pull request should be merged before starting with number 3

Once again thanks for this grate integration and look forward to send some beer to rave for all his hard work.
But in meanwhile i have a problem with the integration of the hub and home assistant.
So all is good all the components are in the Home Assistant and i receive updates of each individual component state.
As example i have a motion sensor and a door/window switch that works fine in home assistant.
But the plug and the gateway although i see it in HA and receives it’s state cannot be controlled from the HA. So if i push the button on the plug it turns on and the state changes in HA but cannot be turn off from the HA, same with the hub.
I read somewhere that i have to add the mack address of the gateway in config next to sid, deed that nothing i circulated the codes in the app with no result. I tried different combination like spaces of the mac address.
So if anyone can help please let me know, any help is much appreciated.
I have the latest version of hass and i copied the latest version of the xiaomi component.
Thanks

Just one wifi router - doing both 2/5ghz and a guest / private network… hub is only running on the private network which the pi with hass is on

Timeout now at 15 seconds - thanks @Danielhiversen hasn’t seemed to help though :dizzy_face:

Setup with the interface as the IP of the Pi

xiaomi:
  gateways:
    - sid:
      key: h8lfwhm7hw0szqq1
  interface: 192.168.0.10

17-01-30 20:24:49 custom_components.xiaomi: No gateway discovered
17-01-30 20:24:49 homeassistant.bootstrap: component xiaomi failed to initialize

Setup the inferface with the IP of the hub - that also doesn’t seem to work

17-01-30 20:18:02 homeassistant.bootstrap: Error during setup of component xiaomi
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/bootstrap.py”, line 151, in _async_setup_component
None, component.setup, hass, config)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/xiaomi.py”, line 48, in setup
comp = XiaomiComponent(hass, gateways, interface);
File “/home/homeassistant/.homeassistant/custom_components/xiaomi.py”, line 94, in init
self._socket.bind((interface, 0))
OSError: [Errno 99] Cannot assign requested address
17-01-30 20:18:14 pywemo.subscribe: Received event for unregistered device 192.168.0.197
17-01-30 20:18:32 plexapi: http://192.168.0.100:32400: (401) unauthorized

I also got this installed @jmvermeulen but this is certainly above my pay grade, not sure what I am looking for its all foreign to me.

Do you think doing a full factory reset of the hub help? - start again… Maybe start with a clean slate for HASS too see if that helps the situation…

try disabling the guest network, the 5G network. And conncet everything to one single 2,4G network …?

Here we go… does this say anything of value?

Looks like it did the trick!! I wonder why the 5.4ghz network stopped it working?

try disabling the guest network, the 5G network. And conncet everything to one single 2,4G network ...?
1 Like

Strangely I got it working… then it reverted back after turning on the 5ghz network, switched the network back off and still nothing… then rebooted the router and it came up.

I wonder why I can only get it working when I only have 2.4ghz enabled.