Xiaomi Gateway Integration

Well once again ghost motion and the sensors get stuck in th on position. I’m not sure this can help but a graph from grafana clearly shows it fired at 22 and never reported an off state. Nobody was there at that time.
I believe this started when the polling mechanism has changed.

As do I. I think before the state was not polled and relied on the gateway to send the no_motion event via multicast. Now this is polled from the gateway and the gateway responds with a motion event, probably because at some point there was such an event.

Also had some ghost tonight. Interestingly (or not), the door sensor “opened” first, and after half an hour or so the motion sensor fired too. They never fire simultaneously.

The sensor information will be broadcasted periodically by the gateway. What polling does is get the information in advance

You can disable polling by setting

poll_motion=false

Just got the following reply from xiaomi regarding ghost triggers :

In fact, I moved the gateway a little further away from the sensors Saturday, and had two ghost situations since…

1 Like

Sorry perhaps I am missing something but the below is not triggering at all?

>  - alias: "Motion On"

trigger:
platform: event
event_type: motion
event_data:
entity_id: binary_sensor.motion_sensor_158d000xxxxxx1
action:
service: light.turn_on
entity_id: light.xxxx_light

Also the documentation for state says to use motion/no_motion however that isn’t working. Should it be on/off?

Thanks in advance

Will try to move the gateway and report back. Hopefully it will work

Has anyone had any luck getting the zigbee plugs to report power?

If so how can you use it as a tile on the home screen?

i see in smartthings community that battery power status is supported… how it’s possible?

Here is the code that Smartthings use: https://github.com/a4refillpad/Xiaomi/blob/master/devicetypes/a4refillpad/xiaomi-motion-sensor.src/xiaomi-motion-sensor.groovy#L114
It is not clear to me how we can get the battery data. Have to study the code in more detail.

Actually i develop that code initially. It’s in my repo. Anyway, the device broadcast battery power to the Zigbee coordinator, and because they connect the sensor to ST hub directly, ST hub can receive and parse the battery data.

In the case of HA, since the sensor is connected to xiaomi gateway (Zigbee coordinator), it receives the battery as well. It’s just that the battery info is not exposed through the API. But it is scheduled to include battery information in the next firmware update

It’s because they don’t use xiaomi gateway, they connect the sensor directly to ST hub

ahhhh ok :slight_smile: we’ll wait for next firmware update :wink:

but in xiaomi mi home app battery level is visible?

897 command…
Any one here work with this and show what exactly need to be do?

or share the code on your HA?

Thanks!

MP

My gateway is located 1m away from both sensors (PIR, door). Furthermore I tested the range and I had no trouble going through walls and slab 10m away.

I have solved this by deleting/renaming the folder /home/homeassistant/.homeassistant/deps/Crypto

In your install it should be /var/opt/homeassistant/deps/Crypto

Check the first post

Sorry I meant power consumption for 240v appliances

Its not the distance for sure, i have 9 door sensors spreaded over 4 floors, my closest door sensor next to the gateway is 3 Meters away and was ghost opening first.

How did you get in touch with the support, can you report them back when the gateway has wifi flapping’s this ghost openings/movements happens. the Mi home app shows the correct status ALL the time.

The 2,4ghz band is going crazy good in my house, as i just need ONE AP for 4 floors! i have still in the last corner of the house good connection.

The gateway reported “mcast reports open”, i had a debugging running, look 2km above in this thread i posted detailed logging of the gateway itself.

All my door sensor opened, when one started the other followed over the next hours and 9 with bad connection is simply not possible :tired_face:

When i last time un- and replugged the gateway the rest of the sensors changed the state, the mi home app still showed everything correct.

I run still on an older commit of this comp and i had just once the ghost motions itself.