@rave I have found a way to reproduce the ghost issue! I manually sent the following message to the gateway (the id was valid, not 111):
{“cmd”:“read”,“sid”:111111111111}
Notice that “” is missing around the id! That caused the gateway to stop responding for about 5 seconds (no heartbeats), and after that the sensor was “open”! Could the component be sending an invalid message? I’m not on the latest code due to the following issue, so I may be delayed on fixes: https://github.com/lazcad/homeassistant/issues/28
Good finding. Did anything shows up in the error log? If HA sends something to gateway and it doesn’t respond in 10 seconds, it will log an error below
So, tonight all sensors went into ghost mode. I’ve checked the logs and saw no timeouts or errors. I do see the heartbeats from the sensors with the “open” status. I don’t see any pooling message sent from HA to the gateway on the logs, is that normal? I have the following config on the logger, do I need anything else?
Config looks fine. And polling is only for motion sensor. It could be network connection because i still haven’t experienced another ghost event. Maybe try another router if you have an extra sitting around?
I had the last 2 days unfortunately as well ghost openings and motions… its really annoying. It’s not necessarily connected with the wifi connection, i unplugged and replugged the gateway and the same happens directly. I can confirm that there is a heartbeat “open” status send from the gateway without a report before.
Does anywant knows why this happen? i would be very happy if you help me, i have the ip but i cant make this work. i only have xiaomi: in configuration
17-03-18 03:28:20 INFO (MainThread) [homeassistant.loader] Loaded xiaomi from custom_components.xiaomi
17-03-18 03:28:20 INFO (MainThread) [homeassistant.setup] Setting up xiaomi
17-03-18 03:28:20 WARNING (<concurrent.futures.thread.ThreadPoolExecutor object at 0x102ee7588>_9) [custom_components.xiaomi] Gateway Key is not provided. Controlling gateway device will not be possible.
17-03-18 03:28:20 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x102ee7588>_9) [custom_components.xiaomi] Expecting 1 gateways
17-03-18 03:28:20 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x102ee7588>_9) [custom_components.xiaomi] Discovering Xiaomi Gateways (Try 1)
17-03-18 03:28:25 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x102ee7588>_9) [custom_components.xiaomi] Gateway finding finished in 5 seconds
17-03-18 03:28:25 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x102ee7588>_9) [custom_components.xiaomi] Discovering Xiaomi Gateways (Try 2)
17-03-18 03:28:30 WARNING (MainThread) [homeassistant.setup] Setup of xiaomi is taking over 10 seconds.
17-03-18 03:28:30 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x102ee7588>_9) [custom_components.xiaomi] Gateway finding finished in 5 seconds
17-03-18 03:28:30 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x102ee7588>_9) [custom_components.xiaomi] Discovering Xiaomi Gateways (Try 3)
17-03-18 03:28:35 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x102ee7588>_9) [custom_components.xiaomi] Gateway finding finished in 5 seconds
17-03-18 03:28:35 ERROR (<concurrent.futures.thread.ThreadPoolExecutor object at 0x102ee7588>_9) [custom_components.xiaomi] No gateway discovered
17-03-18 03:28:35 ERROR (MainThread) [homeassistant.setup] Setup failed for xiaomi: Component failed to initialize.
I think I have found a workaround for the ghost problem. When I get an event from a sensor I connect to the hub for a confirmation. This result in a short delay (less than 1 sec) before an event is fired.
It seams to solve the ghost problem, but it would be great if other want to test it too.
You will find the code here: https://github.com/Danielhiversen/homeassistant Add check_ghost to the config
wow, that’s great news! I updated my component already, lets see if its working, that would be awesome, i think 1 second delay is acceptable, anyway since i updated to 0.40 i have quite a delay in hass itself till my light automations are taking effect.
Check_ghost is an invalid option after i updated the custom_comp with your version.
17-03-18 20:46:34 ERROR (MainThread) [homeassistant.config] Invalid config for [xiaomi]: [check_ghost] is an invalid option for [xiaomi]. Check: xiaomi->xiaomi->check_ghost. (See /root/.homeassistant/configuration.yaml, line 280). Please check the docs at https://home-assistant.io/components/xiaomi/
it doesn’t seems to be included in your master, is the code included in some branch?
@rave Many thanks for your component. It works like a charm.
I’ve bought the cube switch from Xiaomi. I want to activate an automation when I rotate the cube. The cube send value like “rotate: 12.500” with positive or negative values depending on the direction.
I have no idea how to retrieve the rotate value.
great it worked, i will let you know my experience. Thanks a lot in advance if it works! I was already worried, that i can dump my 25 devices from xiaomi because they are not reliable enough.
17-03-19 23:59:41 ERROR (Thread-3) [custom_components.xiaomi] Cannot connect to Gateway
17-03-19 23:59:41 ERROR (Thread-3) [custom_components.xiaomi] No data in response from hub None
17-03-20 00:02:06 ERROR (Thread-7) [custom_components.xiaomi] Cannot connect to Gateway
17-03-20 00:02:06 ERROR (Thread-7) [custom_components.xiaomi] No data in response from hub None
17-03-20 00:03:39 ERROR (Thread-3) [custom_components.xiaomi] Cannot connect to Gateway
17-03-20 00:03:39 ERROR (Thread-3) [custom_components.xiaomi] No data in response from hub None
in my log, seems to be that the connection fails sometimes when the comp ask for confirmation, the result is no movement detected.
I’ve tested it and I think this works! I was having my sensors permanently in “motion” and “open” state after a power cut and this fixed it!
I also saw that domoticz has implementation for the Xiaomi hub and I don’t see anyone there complaining about ghost openings. I think what they are doing is to rely only on the broadcast without polling (i.e. cmd: “read”) the gateway.
I also reported this API bug to Xiaomi but the response I got was that they can’t understand the issue I think any bug reports should be submitted in chinese to get this up the chain and this API bug resolved.