Xiaomi Gateway Integration

This seems like good news, as it may mean it will work with the existing Yeelight component.

Hey guys,
I have the Mijia Smart LED Desk Lamp and confirm it works out of the box with the integrated Yeelight component, after enabling developer mode in the Yeelight app.
I have the yeelight component working with an rgb lightstrip, rgb e27 bulb, and now the desk lamp.
I don’t do any colour changes through home assistant, just on\off with transition time.

- platform: yeelight
  devices:
    192.168.1.206:
      name: Living Room Lamp
      transition: 2000
    192.168.1.205:
      name: Bedroom Light Strip
      transition: 1000
    192.168.1.217:
      name: Studio Desk Lamp
      transition: 1000
2 Likes

Perfect! My xiaomi_philipslight component was merged and will be an official component with release of HA 0.53.

1 Like

Good news: https://github.com/Danielhiversen/PyXiaomiGateway/issues/3

1 Like

Now, I just need to wait for a decent chinese price :wink:

(reposting, didn’t mean to answer to someone in particular)

Hello,

I’m having trouble discovering the gateway. Can someone help me?

Here is what I have so far:

On Mi Home
When I click on confirm in the screen to allow LAN control for the first time, it says “{“result”:[“ok”]}” but if I confirm again it says “{“error”:{“code”:-5010,“message”:“bind failed”},“id”:an incremented number}”.

I have to change the password for it to say “OK” again.

I don’t know if it’s normal or not.

On my Synology where HASS is installed with Docker
I can ping the gateway just fine.

My configuration.yaml

xiaomi:
  interface: <my nas ip>
  gateways:
    - mac: <xiaomi gateway mac address>
      key: <password>

I tried with and without the mac address, it doesn’t change anything. My NAS has 4 ethernet ports so I try to specify the interface, again, it doesn’t change anything.

Log file

2017-08-26 20:02:27 ERROR (SyncWorker_2) [homeassistant.components.xiaomi] No gateway discovered
2017-08-26 20:02:27 ERROR (MainThread) [homeassistant.setup] Setup failed for xiaomi: Component failed to initialize.

Router
It doesn’t seem to be a router problem. I tried some tools to send UDP packets from my PC (ethernet) to my phone (Wifi) and vice-versa and it worked.

1 Like

Can the alarm function be used now?

Anybody is using the cover? Received the motor (rails are still on the way).
Tried playing with the motor. All works within the mi home.
And the cover showed up nicely within HA. But the motor doesn’t react to commands from HA. Although if i move the position slider in MiHome it gets updated in HA.

Below is what i’ve found in the log

2017-08-27 18:06:03 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/__init__.py", line 173, in async_handle_cover_service
    yield from getattr(cover, method['method'])(**params)
  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 "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/xiaomi.py", line 55, in stop_cover
    self._write_to_hub(self._sid, self._data_key['status'], 'stop')
TypeError: write_to_hub() takes 2 positional arguments but 4 were given
2017-08-27 18:06:04 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/__init__.py", line 173, in async_handle_cover_service
    yield from getattr(cover, method['method'])(**params)
  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 "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/xiaomi.py", line 51, in open_cover
    self._write_to_hub(self._sid, self._data_key['status'], 'open')
TypeError: write_to_hub() takes 2 positional arguments but 4 were given
2017-08-27 18:06:05 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1025, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/__init__.py", line 173, in async_handle_cover_service
    yield from getattr(cover, method['method'])(**params)
  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 "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/xiaomi.py", line 47, in close_cover
    self._write_to_hub(self._sid, self._data_key['status'], 'close')
TypeError: write_to_hub() takes 2 positional arguments but 4 were given

Which rails did you get? Lonk/specs?

Well they are still on the way. Aliexpress suppliers selling the originals wanted the price of around 120USD for 1,7m so went for alternatives (dooya) as they are twice cheaper

Link of what you bought?

I will check the code. There must be something wrong in general.

I just prepared a PR to fix this issue:

I´m having exactly the same issue! And I have no idea to solve this :frowning:

Thank you for that! I see that it is already merged into dev. So hopefully it will get into 52.1 and will test it

Will post a link to rails as soon as they arrive and i test that they are compatible

The device is supported with the next release of home assistant.

1 Like

Just testing UDP traffic isn’t sufficient. It’s multicast traffic which must be possible.

We will try to solve the problem here: Xiaomi gateway not discovered - #3 by Danielhiversen

Hi All. There seems to be a large majority (myself included) who believe it will be best to close this thread and start supporting Xiaomi issues with a thread per issue.
E.g. a new thread to discuss water sensor support, a new thread to discuss phantom motion detection etc etc.

How can this be achieved @admins?

1 Like