Xiaomi Gateway Integration

Just to double-check, some of you are running on 0.36.1 and this component is working fine?

yes 0.36.1 and no errors

1 Like

@rave as far as I know you got 2 gateways right?
Did you figure out how they communicate? Is is via WiFi or ZigBee?
Is one going in a concept of ‘primary mode’?

And if it’s ZigBee, do they have to be in radio-range of each other to work/not interfere?

For those who have this issue, I guess it was related for having the plug switch registered in xiaomi gateway but it was turned off. After turning it on, the errors are gone!

I believe Hub to hub communication is through wifi since the hub itself never initiate the joining process. And really, the only time they’ll need to communicate is when you setup an automation in its app across multiple hub

In essence, they’re 2 different hub with its own devices.

1 Like

For anyone having issues with initial setup and pairing the hub to your wifi network try temporarily disabling 5ghz Wifi on your router and rebooting. This fixed my problem with a TP-Link router.

I knew my hub was OK as I did a test run on my workplace network when I received it and paired all my sensors. When I got home I was unable to get it to connect to my home wifi, connection would time out every time. I tried changing wifi channels, reinstalling the app, using different devices, an android emulator, even different power points.

Once I disabled the 5ghz it connected straight away. I have experienced this same problem with Google Home.

1 Like

What exactly do I have to rename ? The config-entry, the components ? Upgraded to 36.1 and I get this error:

homeassistant.bootstrap: Invalid config for [xiaomi]: [key] is an invalid option for [xiaomi]. Check: xiaomi->xiaomi->key.

I’ve renamed the name of the files and also on the root file the line DOMAIN = ‘xiaomi’ to DOMAIN = ‘xiaomigateway’.
Hope it helps.
Cheers

Check the readme in github. You need to update your configuration.yaml

2 Likes

Hi,

First of all, thank you for all who’s been helping in the development of this plugin :slight_smile:

I’ve just updated my Home Assistant installation to 0.36.1 and also did clean install of https://github.com/lazcad/homeassistant as custom component (removed any old files and copied the new versions)

The gateway, one temp sensor and one switch work and register as before, but I’m having trouble with the latest addition of gateway light support. I don’t see the light entity in any logs nor in the developer tools in web gui.

Here are some snippets from running hass --debug

INFO:custom_components.xiaomi:Discovering Xiaomi Gateways
INFO:custom_components.xiaomi:Xiaomi Gateway f0b429b44592 found at IP 192.168.xxx.xxx
INFO:custom_components.xiaomi:Discovering Xiaomi Devices
INFO:custom_components.xiaomi:Found 3 devices
ERROR:custom_components.xiaomi:Not a device
INFO:custom_components.xiaomi:Gateway finding finished in 5 seconds

INFO:homeassistant.loader:Loaded light from homeassistant.components.light
INFO:homeassistant.loader:Loaded switch.xiaomi from custom_components.switch.xiaomi
INFO:homeassistant.bootstrap:Setting up light
INFO:homeassistant.components.switch:Setting up switch.xiaomi
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_on, domain=light>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=turn_off, domain=light>
INFO:homeassistant.core:Bus:Handling <Event service_registered[L]: service=toggle, domain=light>
INFO:homeassistant.core:Bus:Handling <Event component_loaded[L]: component=light>
INFO:homeassistant.core:Bus:Handling <Event platform_discovered[L]: service=load_platform.light, discovered=, platform=xiaomi>
INFO:homeassistant.loader:Loaded light.xiaomi from custom_components.light.xiaomi
INFO:homeassistant.components.light:Setting up light.xiaomi

I tried to add the Gateway light to customize.yaml as

light.gateway_light_f0b429b44592:
friendly_name: Night light

with no success.

What I find interesting is this line in debug log and also ind home-assistant.log

custom_components.xiaomi: Not a device

I can provide more detailed logs if told how :slight_smile:

Thanks, Timo

You need latest gateway firmware as i describe in readme

Yes you did, and I red it, but somehow I just seemed to ignore it :smile:

Will install the latest firmware, sorry for the stupid question :slight_smile:

–Timo

How do youy use the cube, looks cool, but having 10 commands is probably difficult to remember each. Which are your uses?

BTW the Xiaomi app and website says 6 commands. ARe they 6 or 10??

Xiaomi
flip 90, flip 180, push, rotate, shake, tap twice

Compoinent
Available actions are flip90, flip180, move, tap_twice, shake_air, swing, alert, free_fall and rotate

???

Thank you very much for all the work on this, beer incoming. Installation was very straightforward and everything worked right away. Time to source more sensors and maybe a few of the aqara bits and pieces like the outlets and wall switches. It’s a shame the prices appear to have doubled, but still great value.

If it’s OK I have a question that relates to github moreso than this component. I tried to install this by navigating to my custom_components hass directory and then using

git clone https://github.com/lazcad/homeassistant.git

But this meant I ended up with /home/hass/.homeassistant/custom_components/homeassistant/components/

Is it possible to clone a github subdirectory to a specific local directory? And in addition then being able to update using something like…

$ git pull origin

2 Likes

edit: I figured out my issue.

Notes for others that run into an issue turning the gateway light on or off:

  • sid == mac address without colons in all lowercase. If you enter it in uppercase Home Assistant will find your device, but will not have a token associated with the the gateway, and therefore will only be able to receive commands.
  • You might have to cycle the key a few times in the app to make it happy - also make sure you click the ok button.
1 Like

This has happened today again :-
The motion sensor turned on and after about 40min the magnet turned on, without any movement. They are both still stuck on.

Ghosts??

Sorry could not resist :smiley:

Ahah the Mi Home has nothing on the logs, so I don’t think so!
:smile:

All of a sudden this error is coming.

17-01-24 18:29:27 custom_components.xiaomi: Cannot connect to Gateway
17-01-24 18:29:27 homeassistant.bootstrap: Error during setup of component xiaomi
Traceback (most recent call last):
  File "/srv/hass/hass_venv/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/hass/.homeassistant/custom_components/xiaomi.py", line 53, in setup
    comp.discoverGateways()
  File "/home/hass/.homeassistant/custom_components/xiaomi.py", line 128, in discoverGateways
    gateway = XiaomiGateway(resp["ip"], resp["port"], resp["sid"], gatewayKey, self._socket)
  File "/home/hass/.homeassistant/custom_components/xiaomi.py", line 225, in __init__
    self._discover_devices()
  File "/home/hass/.homeassistant/custom_components/xiaomi.py", line 246, in _discover_devices
    data = json.loads(resp["data"])
TypeError: 'NoneType' object is not subscriptable
17-01-24 18:29:27 homeassistant.core: Bus:Handling <Event call_service[L]: service_data=notification_id=invalid_config, message=The following components and platforms could not be set up:
* [notify](https://home-assistant.io/components/notify/)
* [xiaomi](https://home-assistant.io/components/xiaomi/)

I’m having random errors as well

this is a clean HASSbian image installation in a rpi3. I was having similar issues with a hand made install on a rpi1 and though it was related with some missing app or so…

The hub stop replying for a few seconds and it gives a timeout I guess. Is anyone in latest xiaomi code ans latest hass as well?