Xiaomi Gateway Integration

The motion sensor takes 2 minutes to turn off in Home Assistant. However, it does seem to keep responding instantly to the Xiaomi Hub: I tested adding an automation in the Mi App to ring the doorbell whenever there is motion. It rings every time without delay!

Does anybody know how to increase the motion response resolution/delay in home assistant?

Besides, is it possible to detect and use the Xiaomi hub in HA if the hub has no internet connection? I noticed HA does not start up in that case.

Do you mean you start up HA when there’s no internet? What about if you already start up HA and you disconnect the internet, does it still work?

Also, it seems strange it xiaomi depends on internet connection. Do you have the log when you start up HA without internet?

you mean
xiaomi app ON instantly and OFF instantly

HA ON instantly OFF 2 minutes??

I think that is covered. Each hub gets its own instance with its own settings. Each hub instance also registers its own list of devices.

Devices already contain a reference to the hub I think. Will have to look into that. Currently it is working in my setup. Going to order some more plugs today, but it will take 4 weeks until they arrive. Maybe someone else can test the current setup. I do get all sensor data.

Yes, now everything is received 3 times and the commands are probably sent 3 times and only one has the correct token.

Great work, thank you!
BTW just saw the cube controller for 12.42 €

can you share?

Mine is arriving too (I hope as post from China can take 1 week, 1 monthm, 1 year, or simply never arrive))

I just noticed something strange relating to wrong status of the sensors.

I had a motion sensor that got stuck in the ‘on’ state, even though the history bar shows it as off. This is with edge on my phone. I opened up chrome on my other phone and everything displayed fine. The motion sensor is off and history showed it was triggered in the past. It showed the red little bar and then the off blue bars.

Might be something to consider and put into a FAQ section.

Did you try to refresh your phone browser?

Just wanted to say thank you to all of you and especially @rave
My setup is now working bare-bones

  • Ubuntu Server with Home-Assistant, Xiaomi-Plugin, Homebridge Plugin, Homebridge
  • Xiaomi GW with Plugs, Motion, Temperature
  • Working in HomeKit with Siri

I’m currently ironing some things out:

  • Motion does not show up in HomeKit but in HA
  • Friendly names for all sensors

But works great so far. Thanks heaps.

You’re welcome. There’s a bug fix i put in a few days ago which fixed this issue. Only the binary sensor py file is modified

Hey Guys,

sorry if this has been addressed, but I can’t seem to find the answer. I’ve set up the gateway and everything seems to be detected, but when I go to customize it to add friendly names I get an error mentioning that

[customize] is an invalid option for [xiaomi]

This is the code that I have in my configuration:

xiaomi:
  key: xxxxxxxxxxxxxxxx
  customize:
    binary_sensor.switch_xxxxxxxxxxxxxx:
        friendly_name: Bedroom Switch

If I start HA without the customize options, everything works.

yeah. made no difference. it was pretty strange.

I also have an issue where out of no where, some of the sensors becomes ‘stuck’ in the on state until they are triggered again. After triggering, they become normal again. It’s also strange that a bunch of them decided to activate around the same time. Most of them are motion sensors but 1 door sensor also triggered. The xiaomi app works fine and do NOT show these triggers

doesn’t seem to have anything that strange in my logs. 2 line where 2 of the sensor went of:f
17-01-10 16:07:16 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=<state binary_sensor.motion_sensor_158d00010aacbb=off; battery_level=-1, friendly_name=Bottom Gate @ 2017-01-08T22:34:47.146932+11:00>, entity_id=binary_sensor.motion_sensor_158d00010aacbb, new_state=<state binary_sensor.motion_sensor_158d00010aacbb=on; battery_level=-1, friendly_name=Bottom Gate @ 2017-01-10T16:07:16.162761+11:00>>

7-01-10 16:13:06 homeassistant.core: Bus:Handling <Event state_changed[L]: old_state=<state binary_sensor.door_window_sensor_158d00011c97ab=off; battery_level=-1, friendly_name=D Balcony @ 2017-01-08T22:34:47.137930+11:00>, entity_id=binary_sensor.door_window_sensor_158d00011c97ab, new_state=<state binary_sensor.door_window_sensor_158d00011c97ab=on; battery_level=-1, friendly_name=D Balcony @ 2017-01-10T16:13:06.486624+11:00>>

The only real errors in my logs are where sometimes, my tomato router device_tracker doesn’t find the router.

see my post on friendly names

customize need to be under home assistant in configuration.yaml

Xiaomi app works by polling updates from the hub. HA integration does not poll and depends on information push by the hub. In your case, the information push by the hub could be lost because of network traffic or maybe it couldn’t handle a surge of events at once.

What i can do is enable polling so HA gets updated data from the hub periodically. I’m not sure what’s the interval

But that means you’ll get more traffic on your network

1 Like

shouldn’t be too much network traffic should it? maybe make it customizable?

For HA to register a change of state, wouldn’t that mean the hub would have pushed that info to HA? Considering the sensor was in the off state, then if the info pushed by the hub is lost, wouldn’t HA keep reporting it as off?

What if the sensor is in on state and the hub pushes the data to turn off the state is lost?

The sensor were all off at the time though, as verified by the xiaomi app. I definitely didn’t trigger them. its strange that HA got those on signals and all around the 15-30min time window too. i’ll keep an eye out. if it happens again, i’ll turn off the device_tracker incase it is causing some issues with the xiaomi stuff.

I see. So it just randomly turn on itself. That’s strange

Crap! Thanks rexii454. I did see your post, but was a bit confused by some of it and didn’t realise it had the solution.

New firmware for the gateway released. Anyone tried it already?