Xiaomi Gateway Integration

Hey just a question before I dive in. Has anyone gotten the integration of Xiaomi Smart Home suite (Aqara switches, door sensors etc), Yeelights and Amazon Echo dialed in successfully with HA?

Reason why i’m asking is I noticed to enable Alexa skills for the Yeelight, one needs the set the yeelight locality to international servers (Singapore is the most commonly suggested). This guide requires the Xiaomi Smart home gateway to be under China Mainland locality and from what I gather you can’t have 2 different servers for proper integration?

I’d like to be able to control my Yeelights (ceiling, bulbs etc) as well as some dumb lights/fans (via aqara switches) via the Echo, while maintaining some automation (xiaomi sensors etc), through HA. Any advice?

emulated_hue

?

I think Echo has a direct integration with Yeelights now via the app (correct me if i’m wrong)? I know the regular RGB and white Yeelights work via emulated_hue, not so sure about the ceiling one (https://www.yeelight.com/en_US/product/luna).

yes, but I use the emulated_hue also for those (I do not own the ceiling one)

Excuse my question but I have checked current supported devices on https://github.com/lazcad/homeassistant and there’s no word about the Yeelight or Yeelight RGB… does it means it’s not supported? and if not… is something coming up or it’s not possible to do for now? thanks a lot!

Okay never mind, I’m replying myself. It seems to be separated from the Gateway but possible to control using HA https://home-assistant.io/components/light.yeelight/

Right. Yeelights aren’t zigbee devices. They are WiFi clients.

Hello guys, I am noob and trying to setup xiaomi gateway with home assistant. But still stuck with following error. May I ask for some help?
e[31m2017-05-20 01:05:20 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback _ProactorReadPipeTransport._loop_reading(<_OverlappedF…op_reading()]>)e[0m
Traceback (most recent call last):
File “c:\users\yao_s\appdata\local\programs\python\python36\lib\asyncio\events.py”, line 127, in _run
self._callback(*self._args)
File “c:\users\yao_s\appdata\local\programs\python\python36\lib\asyncio\proactor_events.py”, line 190, in _loop_reading
data = fut.result() # deliver data later in “finally” clause
asyncio.base_futures.InvalidStateError: Result is not ready.e[0m
e[32m2017-05-20 01:05:20 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.yr_symbol, old_state=<state sensor.yr_symbol=unknown; attribution=Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK., friendly_name=yr Symbol, entity_picture=//api.met.no/weatherapi/weathericon/1.1/?symbol=None;content_type=image/png @ 2017-05-20T01:05:18.989328+08:00>, new_state=<state sensor.yr_symbol=2; attribution=Weather forecast from yr.no, delivered by the Norwegian Meteorological Institute and the NRK., friendly_name=yr Symbol, entity_picture=//api.met.no/weatherapi/weathericon/1.1/?symbol=2;content_type=image/png @ 2017-05-20T01:05:20.344104+08:00>>e[0m
e[32m2017-05-20 01:05:20 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=sensor>e[0m
e[32m2017-05-20 01:05:23 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x00000250A0BE4D68>_3) [custom_components.xiaomi] Gateway finding finished in 5 secondse[0m
e[32m2017-05-20 01:05:23 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x00000250A0BE4D68>_3) [custom_components.xiaomi] Creating Multicast Sockete[0m
e[31m2017-05-20 01:05:23 ERROR (MainThread) [homeassistant.setup] Error during setup of component xiaomie[0m
Traceback (most recent call last):
File “c:\users\yao_s\appdata\local\programs\python\python36\lib\site-packages\homeassistant\setup.py”, line 188, in _async_setup_component
None, component.setup, hass, processed_config)
File “c:\users\yao_s\appdata\local\programs\python\python36\lib\concurrent\futures\thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “C:\Users\yao_s\AppData\Roaming.homeassistant\custom_components\xiaomi.py”, line 85, in setup
PY_XIAOMI_GATEWAY.listen()
File “C:\Users\yao_s\AppData\Roaming.homeassistant\custom_components\xiaomi.py”, line 195, in listen
self._mcastsocket = self._create_mcast_socket()
File “C:\Users\yao_s\AppData\Roaming.homeassistant\custom_components\xiaomi.py”, line 185, in _create_mcast_socket
sock.bind((self.MULTICAST_ADDRESS, self.MULTICAST_PORT))
OSError: [WinError 10049] The requested address is not valid in its contexte[0m
e[32m2017-05-20 01:05:23 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=2545319663432-1>e[0m
    e[32m2017-05-20 01:05:23 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-05-20T01:05:23.756386+08:00>>e[0m
    e[32m2017-05-20 01:05:23 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=2545319663432-1>e[0m
    e[32m2017-05-20 01:05:23 INFO (MainThread) [homeassistant.bootstrap] Home Assistant initialized in 6.00se[0m
    e[32m2017-05-20 01:05:23 INFO (MainThread) [homeassistant.core] Starting Home Assistant core loope[0m
    e[32m2017-05-20 01:05:23 INFO (MainThread) [homeassistant.core] Starting Home Assistante[0m
    e[32m2017-05-20 01:05:23 INFO (MainThread) [homeassistant.core] Bus:Handling <Event homeassistant_start[L]>e[0m
    e[32m2017-05-20 01:05:23 INFO (MainThread) [homeassistant.core] Timer:startinge[0m
    e[32m2017-05-20 01:05:25 INFO (MainThread) [homeassistant.components.http] Serving /api/websocket to 192.168.31.227 (auth: True)e[0m
    e[32m2017-05-20 01:05:25 INFO (MainThread) [homeassistant.components.http] Serving /api/websocket to 127.0.0.1 (auth: True)e[0m
    e[32m2017-05-20 01:05:29 INFO (MainThread) [homeassistant.components.http] Serving /api/websocket to 127.0.0.1 (auth: True)e[0m
    e[32m2017-05-20 01:05:30 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sun.sun, old_state=<state sun.sun=below_horizon; next_dawn=2017-05-19T20:23:35+00:00, next_dusk=2017-05-20T11:58:26+00:00, next_midnight=2017-05-20T16:11:06+00:00, next_noon=2017-05-20T04:11:00+00:00, next_rising=2017-05-19T20:54:43+00:00, next_setting=2017-05-20T11:27:18+00:00, elevation=0, azimuth=0, friendly_name=Sun @ 2017-05-20T01:05:18.660660+08:00>, new_state=<state sun.sun=below_horizon; next_dawn=2017-05-19T20:23:35+00:00, next_dusk=2017-05-20T11:58:26+00:00, next_midnight=2017-05-20T16:11:06+00:00, next_noon=2017-05-20T04:11:00+00:00, next_rising=2017-05-19T20:54:43+00:00, next_setting=2017-05-20T11:27:18+00:00, elevation=-28.67, azimuth=14.61, friendly_name=Sun @ 2017-05-20T01:05:18.660660+08:00>>e[0m
    e[31m2017-05-20 01:05:36 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback _ProactorReadPipeTransport._loop_reading(<_OverlappedF…ed result=b’’>)e[0m
    Traceback (most recent call last):
    File “c:\users\yao_s\appdata\local\programs\python\python36\lib\asyncio\events.py”, line 127, in _run
    self._callback(*self._args)
    File “c:\users\yao_s\appdata\local\programs\python\python36\lib\asyncio\proactor_events.py”, line 188, in _loop_reading
    self._closing)
    AssertionErrore[0m

Just got my door/window sensors to try this and it works perfect!
Thanks for this idea :+1:

2 Likes

Considering that there haven’t been any updates lately to any of the branches - might be time to put it into the main HA tree? It’s a pity that such a great component still doesn’t get enough credit

2 Likes

any one know if HA can enable \ disable the notification with pushbullet by phone locate ?
tired to on\ off wen i am at home or out.

@mp3llll maybe put an IF statement in your script like:

   - service_template: >
           {% if is_state("device_tracker.yourphoneorsomething", "not_home")  %} 
             service: notify.pushbullet
               data:
                 message: 'What you want to say.'
           {% endif %}

I have updated my gateway to latest firmware but last night my two motion sensors had ghost issues again. So it seems that ghost issues aren’t fixed in firmware yet.

nice! i new at ha i will read about it, thanks.

Worked like a charm.

Great work! Enjoy your beer :slight_smile:

In the end I’ve used only the trigger and it’s reliable to me, now I want to achieve something more complex:

shutdown the fan after the value gets under 50 or after an hour, BUT ONLY if has been started by the previous automation (trigger when value is above 70)

It’s possible?
I can write the inverted
trigger: platform: numeric_state entity_id: sensor.your.xiaomi.bathroom.entity.id below: your_value

but don’t know how to check if it has been turned on from an automation and not, for example a wireless switch

Hello all, thanks for the long but informative thread. I’m about to pull the trigger on the smart home starter kit, but wanted to make sure I’m buying the correct one. I see references on Aliexpress to a v2 (e.g. [Here](https://www.aliexpress.com/item/Original-Xiaomi-Smart-Home-Multifunctional-Gateway-Alarm-System-Intelligent-Mini-Online-Radio-Night-Light-Bell-EU/32749343672.html?ws_ab_test=searchweb0_0,searchweb201602_3_10152_10065_10151_10130_10068_10136_10137_10157_10060_10138_10155_10062_10156_437_10154_10056_10055_10054_10059_303_100031_10099_10103_10102_10096_10147_10052_10053_10050_10107_10142_10051_10084_10083_10119_10080_10082_10081_10178_10110_519_10111_10112_10113_10114_10181_10183_10182_10185_10078_10079_10073_10123_10120_142-10120,searchweb201603_1,ppcSwitch_5&btsid=d21f4a54-e7ef-4b8a-9f7e-fdcbe5c3571c&algo_expid=16797615-73ed-4bb0-bf40-82af9faf7e25-5&algo_pvid=16797615-73ed-4bb0-bf40-82af9faf7e25) or here). Is this version the right one or should I go for one that’s labelled as original (e.g. here).

1st link is for just the gateway. If it says it has radio (which this did) then you’re good.
The 2nd link is for a kit inc the v2 gateway. and this is featuring the very latest (as in from last month or so) 2nd generation sensor designs. Not sure if anyone on this thread has reported on whether these work the same or not.
My guess is basically cosmetic change - especially now we can see they sell a kit with what looks to be same gateway.
3rd link is also v2 gateway based on the description but comes with 1st gen design sensors

1 Like

all three you linked are the same. the v2 is the gateway with the “shield” icon instead of MI.
All versions beyond that I haven’t seen being sold for awhile already, only that and the Aqara which has a different design and functions

1 Like

Hi,

I got my starter kit a few days ago from Gearbest and I was pretty much in the same spot as you :slight_smile:

I received the new version and the integration with HA was very easy. As long as you can see the new logo (:smile_cat:) you should be ok.

I’m buying a few more sensors now and found apparently Xiaomi is adding all the home automation line to the aqara line and made some changes in the design language but I’m betting they should be pretty much the same. I’ll let you know when I get the new ones.

3 Likes