Motion sensor xiaomi


I have a home assistant version 0.84.6 and I integrated a xiaomi gateway with two motion sensors. I can see two sensor in my home assistant but I can not do any trigger.

I can see that if I select the motion sensor, its state is “clear” but dont change if I move in front of sensor.

In the documentation I can see that the trigger must be like below:

    platform: state
    entity_id: binary_sensor.motion_sensor_158d000xxxxxc2
    from: 'off'
    to: 'on'

but the state is not off or on, as I say before.

I looked for in this community but I can’t find any information that it can help me. Possibily I didnt use the correct words…

Can I help me please? :slight_smile:

Thank you in advance.


I’m not 100% sure what you mean, but if you move in front of it the dashboard icon you have doesn’t change at all?

No, nothing :frowning:


Unavailable status is because I powered off my home assistant.

If you open the Mi Home app (if you are using it) do you then see the “motion” being detected?
How does your Xiaomi Gateway conf look like?

Yes, I use Mi Home app and can see motion:

Do you refer to home assistant configuration?


thank you!!!

Strange… mine works without an issue.
Do you see any errors in the log?

Currently I use only this in my conf file:

  discovery_retry: 10
    - key: xxxxxxxxxxxxxxxxxxxxx

i set up my gateway yesterday and the first password the MI Home app gave me didn’t work, try refreshing the password

Good idea suggested here. I did the same for a friend, I did hit the refresh key a couple of times and finally it worked.

Hi guys,

I changed it the password and the motion sensor doesn’t work :frowning:
I think the comunication of gateway with home assistant is correct.

@Yoinkz do you have motion sensors too? do you have additional configuration?

I found in the log this:

2019-01-04 00:23:12 ERROR (SyncWorker_1) [xiaomi_gateway] Got error element in data {“error”:“Invalid key”}

My Config is the same as Yonkz

discovery_retry: 5

Try removing the Host and Mac. If I remember correctly the Mac is only needed if your’re using 2+ Gateways…

I would also try refreshing the key in the MI Home le app and paste the new one into your config file. Then restart hassio and give it another shot.

If I remove the host and mac the gateway disappear in the hasio and in the log appear this missage:

2019-01-04 17:25:02 WARNING (MainThread) [homeassistant.setup] Setup of xiaomi_aq
ara is taking over 10 seconds.
2019-01-04 17:25:44 ERROR (SyncWorker_3) [homeassistant.components.xiaomi_aqara]
No gateway discovered
2019-01-04 17:25:44 ERROR (MainThread) [homeassistant.setup] Setup failed for xia
omi_aqara: Component failed to initialize.

Also I tried some times refreshing the key in the Mi Home and doesnt work neither.

I found this thread:

And I think is the same problem that mine. For two reason:

  • I can not power on the light of gateway because power off itself.
  • The Home assistant doesnt pick up the motion information of sensor and for this reason not change the state.

I will try to fresh install of all devices (HA, gateway, sensors…). But I think is not the solution.

Thank you everybody.

You need to fix this first. The key is invalid. Removing key won’t help.