Xiaomi Gateway Integration

@Jur93n Yes it does. I am not sure if you are refering to the round button or the square aqara non-wall-switch one, but both work ok with the gateway and the lazcad-github components

Edit: Forgot to add: The single click, the long click and the double click. They all work :slight_smile:

1 Like

I was referring to the small round one, good to hear that it works, was curious to know if it does.

That’s Zigbee btw

@rave - thanks again for all your hard work and support… I’ve shouted you a few more beers :smiley:

I’ve moved into the stage of customising everything and getting it all setup - it would be great if a few people could share some of the automations they have setup to use these great sensors!

I’ve got motion sensors, switches, door / window sensors to play with… I am thinking switches with multiple functions (e.g. one click dim, two clicks bright, long click something else…) motion sensors with timeout to turn on / off lights, starting to struggle with YAML again :expressionless:

1 Like

You can find my config files here: https://github.com/Danielhiversen/home-assistant_config/search?utf8=✓&q=cube_action+OR+click_type&type=Code

2 Likes

Thanks! The switch is great, here’s my switch automation which i like and used a lot

Click - toggle countertop light
Double click - toggle kitchen light
Hold - toggle both light

Hi,

In the automation that i added in few post before, was refered on the switch button, to switch on in white, with 1 click, 2 click switch off, and press button i switch on with special color.

I’m waiting, 3 new switch button (zigbee) to install it back my normal light home switch, to switch lights in one room without, any relay or change bulbs.

If system works well, then i will buy more, to use in lamps that i don’t have yeelight bulbs.

Nobody has the ghost opening problematic anymore, did i miss an update? :frowning:

Thanks Dan now I just need to brush up on my Norwegian :wink:

Great to see the whole setup in github!

Sorry for bothering you guys again.

The Xiaomi Gateway was acting quite unstably in the past days. Before upgrading to 0.38, it worked like a charm. After upgrading to 0.38.1, 0.38.2, and 0.38.3, all Xiaomi devices could no longer be detected. I tried downgrading the HASS version, it worked again. But after reboot, it didn’t work again. I reinstalled HASS from scratch, it worked again. Same case, after rebooting, not working again.

Here’re the error messages. Do you have any suggestion what went wrong?

Invalid config
The following components and platforms could not be set up:

xiaomi

Please check your config

17-02-15 23:10:46 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_off> 17-02-15 23:10:46 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=turn_on> 17-02-15 23:10:46 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=toggle> 17-02-15 23:10:46 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=stop> 17-02-15 23:10:46 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=restart> 17-02-15 23:10:46 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=check_config> 17-02-15 23:10:46 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=homeassistant, service=reload_core_config> 17-02-15 23:10:56 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=persistent_notification, service=create> 17-02-15 23:10:56 INFO (MainThread) [homeassistant.bootstrap] Home Assistant core initialized 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded script from homeassistant.components.script 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded group from homeassistant.components.group 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded switch from homeassistant.components.switch 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded sensor from homeassistant.components.sensor 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded device_tracker from homeassistant.components.device_tracker 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded zone from homeassistant.components.zone 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded conversation from homeassistant.components.conversation 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded logbook from homeassistant.components.logbook 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded recorder from homeassistant.components.recorder 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded frontend from homeassistant.components.frontend 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded api from homeassistant.components.api 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded http from homeassistant.components.http 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded websocket_api from homeassistant.components.websocket_api 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded updater from homeassistant.components.updater 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded history from homeassistant.components.history 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded sun from homeassistant.components.sun 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded logger from homeassistant.components.logger 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded discovery from homeassistant.components.discovery 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded mqtt from homeassistant.components.mqtt 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded xiaomi from custom_components.xiaomi 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded light from homeassistant.components.light 17-02-15 23:10:56 INFO (MainThread) [homeassistant.loader] Loaded camera from homeassistant.components.camera 17-02-15 23:10:56 INFO (MainThread) [homeassistant.bootstrap] Setting up recorder 17-02-15 23:10:56 INFO (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=recorder> 17-02-15 23:10:56 INFO (MainThread) [homeassistant.bootstrap] Setting up logger 17-02-15 23:10:59 INFO (Thread-3) [homeassistant.components.switch.orvibo] Discovering S20 switches …

2nd part of the log:

17-02-15 23:11:07 INFO (Thread-5) [custom_components.xiaomi] Expecting 1 gateways 17-02-15 23:11:07 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Gateways (Try 1) 17-02-15 23:11:07 INFO (Thread-5) [custom_components.xiaomi] Xiaomi Gateway 286c0785919f found at IP 192.168.11.172 17-02-15 23:11:07 INFO (Thread-5) [custom_components.xiaomi] Discovering Xiaomi Devices 17-02-15 23:11:07 DEBUG (Thread-5) [custom_components.xiaomi] >> b’{“cmd” : “get_id_list”}’ 17-02-15 23:11:08 DEBUG (Thread-5) [custom_components.xiaomi] << {‘data’: ‘[“158d000156f96f”,“158d000129b181”,“158d00012636f5”,“158d00012f54bc”]’, ‘cmd’: ‘get_id_list_ack’, ‘token’: ‘You02SmjTIGWLZsf’, ‘sid’: ‘286c0785919f’} 17-02-15 23:11:08 ERROR (MainThread) [homeassistant.bootstrap] Error during setup of component xiaomi Traceback (most recent call last): File “/usr/local/lib/python3.4/dist-packages/homeassistant/bootstrap.py”, line 152, 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 “/var/opt/homeassistant/custom_components/xiaomi.py”, line 77, in setup PY_XIAOMI_GATEWAY.discover_gateways() File “/var/opt/homeassistant/custom_components/xiaomi.py”, line 167, in discover_gateways self.gateways[ip_add] = XiaomiGateway(ip_add, port, sid, gateway_key, self._socket) File “/var/opt/homeassistant/custom_components/xiaomi.py”, line 262, in init if self._discover_devices(): File “/var/opt/homeassistant/custom_components/xiaomi.py”, line 271, in _discover_devices self.update_key(resp[“token”]) File “/var/opt/homeassistant/custom_components/xiaomi.py”, line 370, in update_key encryptor = AES.new(self.key, AES.MODE_CBC, IV=init_vector) File “/var/opt/homeassistant/deps/Crypto/Cipher/AES.py”, line 264, in new return _create_cipher(sys.modules[name], key, mode, *args, **kwargs) File “/var/opt/homeassistant/deps/Crypto/Cipher/init.py”, line 130, in _create_cipher return modes[mode](factory, **kwargs) File “/var/opt/homeassistant/deps/Crypto/Cipher/_mode_cbc.py”, line 232, in _create_cbc_cipher cipher_state = factory._create_base_cipher(kwargs) File “/var/opt/homeassistant/deps/Crypto/Cipher/AES.py”, line 131, in _create_base_cipher expect_byte_string(key) File “/var/opt/homeassistant/deps/Crypto/Util/_raw_api.py”, line 175, in expect_byte_string raise TypeError(“Only byte strings can be passed to C code”) TypeError: Only byte strings can be passed to C code 17-02-15 23:11:09 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 237, in _step result = next(coro) File “/usr/local/lib/python3.4/dist-packages/homeassistant/components/device_tracker/init.py”, line 312, in async_see yield from device.set_vendor_for_mac() File “/usr/local/lib/python3.4/dist-packages/homeassistant/components/device_tracker/init.py”, line 515, in set_vendor_for_mac self.vendor = yield from self.get_vendor_for_mac() File “/usr/local/lib/python3.4/dist-packages/homeassistant/components/device_tracker/init.py”, line 544, in get_vendor_for_mac resp = yield from websession.get(url) File “/var/opt/homeassistant/deps/aiohttp/client.py”, line 577, in iter resp = yield from self._coro File “/var/opt/homeassistant/deps/aiohttp/client.py”, line 213, in _request proxy=proxy, proxy_auth=proxy_auth, timer=timer) File “/var/opt/homeassistant/deps/aiohttp/client_reqrep.py”, line 73, in init assert isinstance(url, URL), url AssertionError: http://api.macvendors.com/8c:be:be

I do somthing similar. I have it on my bedside table:
Single click Toggle normal light
Double click night (dim light)
Long night light with 1 minute timer (not used this much)

I use it with a chromecast.
Click volume up
Double click volume down
Long click Toggle play pause

I have install two xiaomi sensors in my HA system. I want place one sensor1 out side the bedroom and the other sensor2 in the bedroom. If some one enter the room triggered sensor1 and sensor2 in a row then turn on the light.and I need a value to count how many man in the bedroom. to avoid if some one get out the bedroom trigger the sensor2 and sensor1 in a row.the light turn off automatically left someone in the dark. can I define a full range various in the automation? Need help!

With the latest code from github and latest HASS i’m having problems with ghost motion. Furthermore seems that sensors get stuck in the on position. Today had the light on in two rooms all night because of this. Will try to investigate although it’s hard to do

All i could notice upon restart (just in case)

07:27:49 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 237, in _step
    result = next(coro)
  File "/home/homeassistant/.homeassistant/custom_components/binary_sensor/xiaomi.py", line 122, in _async_poll_status
    self.xiaomi_hub.get_from_hub(self._sid)
  File "/home/homeassistant/.homeassistant/custom_components/xiaomi.py", line 351, in get_from_hub
    resp = self._send_cmd(cmd, "read_ack")
  File "/home/homeassistant/.homeassistant/custom_components/xiaomi.py", line 318, in _send_cmd
    self._socket.sendto(cmd.encode(), (self.ip_add, self.port))
OSError: [Errno 9] Bad file descriptor

hi there, after upgrading HA to 0.38.3 my gateway is not discovered anymore, anyone having the same problem ?

I am having the same problem.

1 Like

I’m not sure if it’s related but I just updated to 38.3 and on restart I lost Z-wave and had a few bits of my z-wave rediscovered with different names. I restarted again and have z-wave back but 4 of my lifx bulbs have been rediscovered and given new names. It’s nearly 1am so I’m not game to restart a 3rd time just now.

Xiaomi still seems to be there for now though.

I have installed the component in the custom_component. and put it into my configuration

xiaomi:

and then i tried to put this into the configuration

xiaomi:
  gateways:
     - sid: xxxxxxxxxx

But im still getting “invailid config” in my hass.

Allso is there anything to do with the key if you only have ios in your house hold