Xiaomi Gateway Integration

Hey, were you able to solve this problem? I get exactly the same error message.

In case anyone else comes across this, I found a work around. I downgraded HA to a version below when the Xiaomi smart home component was integrated and then upgraded and it fixed my issue.

Is it possible to use virtual events to trigger other devices of XiaoMi? For example Xiaomi Universal IR Remote Controller .

Send a “virtual event” in the “write” mode (the virtual event only works within the gateway and will not be reported to the millet cloud) to trigger a local linkage (automation) associated with the event:
{“CMD”: “write”, “mode”: “switch”, “SID”: “112316”, “short_id”: 4343, “data”: "{" status \ ": " click " }


Hey guys! I have the gateway, door/window sensor, temperature sensor and a switch set up, but I bought an extra switch. I’m not sure how I would go about adding this in my HA setup? I downloaded the MiHome app again (new phone), but it says I have no devices, even after I log in. Do I have to reset all my devices and set them up again? I’d rather not, especially since I went through this whole ordeal to get the gateway working…

hi guys, i add 2 gateway to my network and i want to use it as an alarm system.
when i have only one gateway all works good, and i was also able to make the gatway ring, after i add the second gateway i can’t make the two gateways ring. i tried to delete the second gateways, but no luck on sound. all the sensor works fine, only the sound don’t works.
here’s my config and automation:
config:

    xiaomi:
     gateways:
       - mac: xxxxxxxxxxxx
         key: xxxxxxxxxxxxxxxx
       - mac: xxxxxxxxxxxx
         key: xxxxxxxxxxxxxxxx

automation:

#ALARM
- id: alarm_panel  
  alias: Trigger alarm while armed away
  trigger:
    - platform: state
      entity_id: sensor.pir1
      to: 'active'
      #scale giozzz
    - platform: state
      entity_id: binary_sensor.motion_sensor_158d0001549ffc
      to: 'on'
      #garage mamma
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00019da8e2
      to: 'on'
      #garage trattorino
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00019da81d
      to: 'on'
      #garage giozzz
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00019da8b6
      to: 'on'
      #porta lav
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00019da943
      to: 'on'
      #porta cuc
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00019da899
      to: 'on'
      #porta ing      
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00019da8f3
      to: 'on'
      #porta gar 
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00019f6354
      to: 'on' 
      #porta sottotetto      
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d0001a21b0a
      to: 'on'      
  condition:
    - condition: state
      entity_id: alarm_control_panel.ha_alarm
      state: armed_away
  action:
    - service: alarm_control_panel.alarm_trigger
      entity_id: alarm_control_panel.ha_alarm 
    - service: xiaomi.play_ringotne
      data:
        gw_mac: xxfirstgatewayxxx 
        ringtone_id: 2
        ringtone_vol: 100  
    - service: xiaomi.play_ringotne
      data:
        gw_mac: xxxsecondgatewayxxx 
        ringtone_id: 2
        ringtone_vol: 100

i also try {“ringtone_id”:“2”, “ringtone_vol”:“100”, “gw_sid”:“xxxxxxxxxxx”} in the developer tools of home assistant with no luck, any ideas? thanks

Hey,
as i remeber right, i did update the gateway again, tripple-checked the sid and key and bought i fritzbox, have had a easybox from vodafone before.

A few minutes ago my Xiaomi Gateway stopped working in hass:

Aug 20 19:28:02 hass dockerd[674]: 2017-08-20 19:28:02 ERROR (SyncWorker_10) [PyXiaomiGateway] Got error element in data {"error":"Invalid key"}

I have already tried to change the network key in the app but I still get this error. I can still see the sensors in the gateway in home assistant. But I cannot change the light or see any new movement events… What could be the reason?

I have not changed anything in home assistant before this error occured…

The gateway works fine in the mi app.

I had a kinda similar issue, try going to the MIHome app, go to the gateway, disable the “Lan” access and make sure you get a “Result: OK” or whatever it says, then re-enable the LAN access, get a “Result: OK”, then put you new code into the config and restart

i’m running hassbian v50.2 and my config is :

xiaomi:
  gateways:
    - mac: XXMacHereXX
      key: XXKeyHereXX

You can do it without the app by pressing the button on the gateway three times to get it in pairing mode and then whatever needs to be done on the device. (I think - google it first or search this thread for @syssi instructions.)

That said, last week I thought I had completely messed mine up trying to do this because I held the button in for to long and did a reset. The good news is that once I added the gateway into the app it had kept all its sub devices, the bad news is that I had to put it in developer mode again and get a new key.

Also, I’ll mention here that setup wouldn’t work at all with Android O (8), I had to get an older tablet out and install the mi-app on that. Again, once signed in to my Xiaomi account it pulled everything in.

Enable debugging for the xiaomi component and check the log

I’ve just started switching from domoticz to home assistant. I’m impressed.
I’ve managed to add my xiaomi gateway. All 8 motion sensors, 8 smoke detectors, 3 switches / buttons and a few outlet switches are properly recognized.

I’ve added some alarm automation rules, while motion detected when armed_away, I get a push message in my iphone.

Currently I’m on vacation… and I scared a bit… because all my motion sensors got triggered in the span of about an hour.
I opened my mi home app, there hasn’t been any motion detected in the log’s since I’ve left home.

The motion sensors remain active in home assistant. Because i’m running HASS in a docker container i’ve pulled some log engtries.

{
"log": "\u001b[32m2017-08-21 11:37:16 INFO (MainThread) [homeassistant.core] Bus:Handling \u003cEvent motion[L]:entity_id=binary_sensor.motion_sensor_158d00013fb0af\u003e\u001b[0m\n",
"stream": "stderr",
"time": "2017-08-21T09:37:16.338920377Z"
}
{"log":"\u001b[32m2017-08-21 11:37:16 INFO (MainThread) [homeassistant.core] Bus:Handling \u003cEvent motion[L]: entity_id=binary_sensor.motion_sensor_158d00013fb0af\u003e\u001b[0m\n","stream":"stderr","time":"2017-08-21T09:37:16.338920377Z"}
{"log":"\u001b[32m2017-08-21 11:37:16 INFO (MainThread) [homeassistant.core] Bus:Handling \u003cEvent state_changed[L]: entity_id=binary_sensor.motion_sensor_158d00013fb0af, old_state=\u003cstate binary_sensor.motion_sensor_158d00013fb0af=off; No motion since=0, battery_level=53.0, friendly_name=Woonkamer, device_class=motion @ 2017-08-21T00:46:09.987461+02:00\u003e, new_state=\u003cstate binary_sensor.motion_sensor_158d00013fb0af=on; No motion since=0, battery_level=53.0, friendly_name=Woonkamer, device_class=motion @ 2017-08-21T11:37:16.339105+02:00\u003e\u003e\u001b[0m\n","stream":"stderr","time":"2017-08-21T09:37:16.340825998Z"}
{"log":"\u001b[32m2017-08-21 11:37:16 INFO (MainThread) [homeassistant.components.automation] Executing iOs beweging woonkamer\u001b[0m\n","stream":"stderr","time":"2017-08-21T09:37:16.343232024Z"}

All motion sensors report state “on” in the states panel.

{
 "No motion since": 0,
 "battery_level": 49,
 "friendly_name": "Keuken",
 "device_class": "motion"
}

After restarting HASS the states remain “on”

Can anyone tell me what’s happening?

I’m running the latest firmware and hass version.

Hi guys,

Just wondering if the Xiaomi smart power strip (https://www.zapals.com/xiaomi-mi-smart-power-strip-6-sockets-wi-fi-remote-control.html) is supported by the Gateway component?

Cheers.

The power strip is a WiFi device (and not a zigbee one). It can be integrated by another (so far) unoffical component: GitHub - syssi/xiaomiplug: Xiaomi Mi Smart WiFi Socket integration for Home Assistant.

Thank you.

thanks for the reply but i solved the problem, i repleced the “sid” with mac (with colon) and it starts working again.

is it possible to set in the automation how much time the gateway has to fire the alarm?

Great, thanks a lot! I also had an easybox - changed that, now everything works just fine.

I seem to be getting this error message quite often lately.

However, I can still control gateway light via HASS which means gateway is working?

Is this a known problem?

2017-08-22 18:49:05 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 18:49:05 ERROR (Thread-11) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 18:49:05 ERROR (Thread-11) [PyXiaomiGateway] No data in response from hub None 2017-08-22 18:52:24 ERROR (Thread-5) [homeassistant.components.light.yeelight] Unable to update bulb status: A socket error occurred when sending the command. 2017-08-22 19:05:06 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 19:05:06 ERROR (Thread-5) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 19:05:06 ERROR (Thread-5) [PyXiaomiGateway] No data in response from hub None 2017-08-22 19:14:54 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 19:14:54 ERROR (Thread-8) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 19:14:54 ERROR (Thread-8) [PyXiaomiGateway] No data in response from hub None 2017-08-22 19:21:23 ERROR (Thread-2) [homeassistant.components.light.yeelight] Unable to update bulb status: Bulb closed the connection. 2017-08-22 19:22:07 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 19:22:07 ERROR (Thread-7) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 19:22:07 ERROR (Thread-7) [PyXiaomiGateway] No data in response from hub None 2017-08-22 19:23:53 ERROR (Thread-6) [homeassistant.components.light.yeelight] Unable to update bulb status: A socket error occurred when sending the command. 2017-08-22 19:25:13 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 19:25:13 ERROR (Thread-11) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 19:25:13 ERROR (Thread-11) [PyXiaomiGateway] No data in response from hub None 2017-08-22 19:26:15 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 19:26:15 ERROR (Thread-7) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 19:26:15 ERROR (Thread-7) [PyXiaomiGateway] No data in response from hub None 2017-08-22 19:30:54 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 19:30:54 ERROR (Thread-3) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 19:30:54 ERROR (Thread-3) [PyXiaomiGateway] No data in response from hub None 2017-08-22 19:32:27 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 19:32:27 ERROR (Thread-3) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 19:32:27 ERROR (Thread-3) [PyXiaomiGateway] No data in response from hub None 2017-08-22 19:47:57 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 19:47:57 ERROR (Thread-3) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 19:47:57 ERROR (Thread-3) [PyXiaomiGateway] No data in response from hub None 2017-08-22 19:54:40 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 19:54:40 ERROR (Thread-11) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 19:54:40 ERROR (Thread-11) [PyXiaomiGateway] No data in response from hub None 2017-08-22 20:46:08 WARNING (MainThread) [homeassistant.helpers.entity] Update for light.lr_standing_lamp is already in progress 2017-08-22 20:50:55 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.motion_sensor_158d000155df00 is taking over 10 seconds 2017-08-22 20:50:55 ERROR (Thread-2) [PyXiaomiGateway] Cannot connect to Gateway 2017-08-22 20:50:55 ERROR (Thread-2) [PyXiaomiGateway] No data in response from hub None

Im wondering how do you install this? I am on raspberry pi 3 virtualenv.
thanks

Just put the xiaomiplug.py in your custom components folder.