Hi @Danielhiversen ,
I’m using home assistant with xiaomi body sensor (the old one) and i saw that sometimes, something goes wrong while detecting the “motion” status. I think the source of the problem is not your code but xiaomi gateway (firmware version: 1.4.1_149.0143) that is sending a “cmd”:“heartbeat” with status “motion”, whenever the motion is not detected (I’m 100% sure of this). There are no packets before with “report” commands…
So I fixed this bug (or strange command) changing the following code of your “PyXiaomiGateway/init.py” row 146
elif cmd == 'report' or cmd == 'heartbeat':
with:
elif cmd == 'report':
I saw this little bug dumping the packets sent from gateway for about 72h and I saw some of these packets:
Aug 21, 2017 15:09:38.365920430 CEST,{“cmd”:“heartbeat”,“model”:“motion”,“sid”:“158XXXXXXXX”,“short_id”:YYYYY,“data”:"{“voltage”:3065,“status”:“motion”}"}
Aug 21, 2017 16:59:40.267295896 CEST,{"cmd":"heartbeat","model":"motion","sid":"158XXXXXXXX","short_id":YYYYY,"data":"{\"voltage\":3065,\"status\":\"motion\"}"}
I think that the trouble coming from gateway not from your code, but I think this can be a fix…but I don’t know if it’s working for all sensors…I tried only with these xiaomi sensors:
- body_sensor (1st version)
- weather station (2nd version)
- door sensor (1st version)
I want to know your opinion about this and I hope it could be useful
Thanks and you’re doing a very nice work with home assistant and xiaomi