Xiaomi Gateway Integration

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?

Hi,

I’m pretty new to this, but I can’t get the job done.
I’ve tried it on my synology, but I can’t compile pycrypto there, so I tried is on my win10 machine and on my raspberry.
Both win10 and my raspbarry can’t discover my gateway.
I’ve set my developer mode on and entered the values in my configuration.yaml, but it’s still not working.
I’ve booted my gateway a few times and my raspberry, but nothing works.

INFO:homeassistant.bootstrap:Setting up xiaomi
INFO:homeassistant.components.xiaomi:Discovering Xiaomi Gateways
INFO:homeassistant.components.xiaomi:Gateway finding finished in 5 seconds
INFO:homeassistant.components.xiaomi:Discovering Xiaomi Gateways
INFO:homeassistant.components.xiaomi:Gateway finding finished in 5 seconds
ERROR:homeassistant.components.xiaomi:No gateway discovered
ERROR:homeassistant.bootstrap:component xiaomi failed to initialize

I’m kinda lost atm.

Grtz,

Frank

How to install pycrypto on windows:

Try turn off and on developer mode on your gateway. Also, make sure they’re on the network. The component search for gateways using multicast. If there’s no reply from the gateway, it will fail.

Hey guys, i have random state changes of the door sensors to on/opened. I can not see any log entry in the xiaomi gateway, so this hass component must have changed the state.

My hardware: pi3 latest raspbian.

Gateway has the latest firmware and version

Hass is on the latest version

I have a multiple interface setup (eth0 and wlan0) had already troubles with binding it to the interface to get xiaomi working.

My other pir sensors arrive hopefully the next days, that i can verify if its a general problem or just a door sensor specific one, not a single door sensor out of 3 keeps the right state.

Btw what i noticed, when the state is changed in the gui and dev tool to open/on, my automation don’t act like “window longer open than 30 mins notify” if the gateway really changes the state to open the automation works without issues.

does somebody has an idea what it could be?

I’ve turned off and on the developer mode a 1000 times by now, but still nothing.
Both are on the same network, my pi with ip# 192.168.2.10 and my gateway with 192.168.2.13, mask 255.255.255.0.
Should be right.

@Frank_Howell: Probably i can help you i had troubles to discover the gateway as well:

First question do you use multiple interfaces on your pi? if yes you need the latest merge with the binding interface fix, and use the interface option.

Debugging tips:

Android: use multicast tester to discover the xiaomi gateway, if you find it multicast discover works. 244.0.0.50 port 9898 the gateway will send a heartbeat message which will be visible in the console of the app.

Is your pi wired? i had troubles with alexa already, that my professional AP is blocking multicast to LAN. So basically i attached a wifi stick for the alexa setup.

Check with multicast tester for linux/windows if you see the xiaomi.

Same wifi, same network/subnet? it is obliged to have it in the same network.