Xiaomi Gateway Integration

Hi all,

I need your help. I have been desperately trying to integrate Xiaomi GW in homeassistant (both latest versions).

I cannot see the GW and I cannot debug because my homeassistant.log does not write events. It is a very small file that was last updated many days ago.

Is there smh I can do to enable logging?

Thank you very much in advance.

Could you create a new topic please?

If this is not the proper place for my post then I can create a new topic.

Sorry for the inconvenience.

Please point out the correct thread.

You could take this one Xiaomi gateway not discovered or just create a new one. It will help other users to find a solution without reading the 3000 messages of this thread. :wink:

Hi all,

I’ve noticed a strange behaviour on motions sensors. Sometimes I see that one of my sensor detects a movement even if there’s no one at home.

I remember that some one noticed the same issue and I’ve searched inside this discussion to find it without result.

Can someone please knows if this issue have been solved?

Thank you

Please study this thread for the current state: Xiaomi body sensor gateway maybe wrong motion detection

Please update home assistant if you don’t use the latest version.

2 Likes

Oh thank you!

I upgraded my home assistant. So I think this have been fixed!

I found some more potential devices in the EigenStone app:

I decrypted the 96 character token using this webpage:

Pasted the token I had into the “Input text” and made sure the Function was AES and Mode ECB. For the key I entered “00000000000000000000000000000000” as @syssi wrote. Make sure you change to HEX before you press Decrypt. You will now have the 32 char Token you need for Xiaomi to work! :slight_smile:

1 Like

I have exactly the same problem as @snwtoy and managed to install pycryto manually, as per my following “pip list” output:

aiohttp (2.2.5)
astral (1.4)
async-timeout (1.2.1)
chardet (3.0.4)
enum-compat (0.0.2)
homeassistant (0.52.1)
Jinja2 (2.9.6)
MarkupSafe (1.0)
multidict (3.1.3)
netdisco (1.1.0)
netifaces (0.10.4)
pip (9.0.1)
pycrypto (2.6.1)
pytz (2017.2)
pyxiaomigateway (0.3.0)
PyYAML (3.12)
requests (2.14.2)
setuptools (28.8.0)
six (1.10.0)
typing (3.6.2)
voluptuous (0.10.5)
yarl (0.12.0)
zeroconf (0.19.0)

But now when starting HASS, I get the following error. Has anyone seen this or can advise how to fix?

2017-09-19 13:21:05 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=37 from 2017-09-19 03:11:32.677610)
2017-09-19 13:21:06 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomi
Traceback (most recent call last):
  File "c:\software\python\python36-32\lib\site-packages\homeassistant\setup.py", line 194, in _async_setup_component
    component.setup, hass, processed_config)
  File "c:\software\python\python36-32\lib\asyncio\futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "c:\software\python\python36-32\lib\asyncio\tasks.py", line 250, in _wakeup
    future.result()
  File "c:\software\python\python36-32\lib\asyncio\futures.py", line 245, in result
    raise self._exception
  File "c:\software\python\python36-32\lib\concurrent\futures\thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "c:\software\python\python36-32\lib\site-packages\homeassistant\components\xiaomi.py", line 64, in setup
    from PyXiaomiGateway import PyXiaomiGateway
  File "c:\software\python\python36-32\lib\site-packages\pyxiaomigateway-0.3.0-py3.6.egg\PyXiaomiGateway\__init__.py", line 7, in <module>
    from Crypto.Cipher import AES
  File "c:\software\python\python36-32\lib\site-packages\pycrypto-2.6.1-py3.6-win32.egg\Crypto\Cipher\AES.py", line 50, in <module>
    from Crypto.Cipher import _AES
ImportError: DLL load failed: The specified module could not be found.

Thank you all :slight_smile:

Try https://home-assistant.io/components/sensor.broadlink/#microsoft-windows-installation

Thanks, I was able to install pycrypto manually, but it was not easy. There seems to be a bug in the latest VC installation - I was able to resolve it using help from here: https://stackoverflow.com/questions/41843266/microsoft-windows-python-3-6-pycrypto-installation-error/41843310#41843310

Still not able to connect to the Xiaomi gateway no matter what I try.

My config is as follows:

xiaomi:      
  discovery_retry: 5
  gateways:
    - mac: 
      key: YG83LTZPNXXXXX  (not the real one)

No matter how many discovery retries it doesn’t find it.
I’ve tried turning the network communication protocol on and off
Tried multiple keys, in upper and lower
Tried with and without mac address (with and without : separatos).

Logs:
:[code]e[32m2017-09-19 20:55:49 INFO (SyncWorker_6) [homeassistant.components.xiaomi] Discovering Xiaomi Gateways (Try 5)e[0m
e[32m2017-09-19 20:55:54 INFO (SyncWorker_6) [PyXiaomiGateway] Gateway discovery finished in 5 secondse[0m
e[31m2017-09-19 20:55:54 ERROR (SyncWorker_6) [homeassistant.components.xiaomi] No gateway discoverede[0m
e[32m2017-09-19 20:55:54 INFO (MainThread) [homeassistant.setup] Setup of domain xiaomi took 25.2 seconds.e[0m
e[31m2017-09-19 20:55:54 ERROR (MainThread) [homeassistant.setup] Setup failed for xiaomi: Component failed to initialize.e[0m
e[32m2017-09-19 20:55:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=persistent_notification, service=create, service_data=title=Invalid config, message=The following components and platforms could not be set up:

  • xiaomi
    Please check your config, notification_id=invalid_config, service_call_id=1371799624840-4>e[0m
    e[32m2017-09-19 20:55:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=persistent_notification.invalid_config, old_state=None, new_state=<state persistent_notification.invalid_config=The following components and platforms could not be set up:
  • xiaomi
    Please check your config; title=Invalid config @ 2017-09-19T20:55:54.082342+12:00>>[/code]

I am running it on a different subnet to the one my PC is on, but it is fully routed. Does the discovery do a broadcast which would be stopped by the router? The app on my android doesn’t have any problem traversing subnet. I wish there was a way of simply specifying the IP address of the gateway rather than having to search for it!

It will be possible with home assistant 0.54:

@Danielhiversen Thanks :slight_smile: I gave it a try and now get:

pip install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win_amd64.whl pycrypto
Collecting pycrypto
  Could not find a version that satisfies the requirement pycrypto (from versions: )
No matching distribution found for pycrypto

Argh.

Try with pip3 instead of pip

Guys new update from xiaomi appeared on the app.
Gonna try it latter tonight, and post if the bug was fixed. It was a long wait let’s hope it’s fixed!! :slight_smile:

thermostat looks very interesting

I have detected that after switching off the gateway light via home assistant, the brightness of this light is set to 0 (checked in MiHome app). Then when you try to switch back on via app or via automation, the light reminds off until you raise the brightness again.
Where should I report this issue?
Thanks

Just dont use mi app. :slight_smile: i report that when this thread was <1000 posts long and rave said it is bug. So i stoped using mi home app for gateway light.

1 Like