monster1025 / aqara-mqtt

Aqara (Xiaomi) Gateway to MQTT bridge (I use it for home assistant integration)
Apache License 2.0
88 stars 21 forks source link

Blocked in _read_unwanted_data #6

Closed seblucas closed 6 years ago

seblucas commented 7 years ago

Hi,

I started to test your program last week and for an unknown reason it wasn't working at all. At first I was blaming my iptables setup, next docker and finally I spend some time to debug and found out that once started it remained stuck in _read_unwanted_data (exactly here)

I saw that you added it with this commit : https://github.com/monster1025/aqara-mqtt/commit/54eda1250223415c2cb316983f2c363b59b65ecc

For now I just put a return at the top of the function and it seems to work fine (I'll let it run a day or two before being sure)

I'm not using your docker python container (because I use a small armhf SBC) but mine should be almost the same :

This function has to be useful and the problem got to be on my end, I hope you have an idea ;)

Thanks in advance

monster1025 commented 7 years ago

This function is dirty hack for case when we poll some data and have a network delays: for example we ask for state of sensor1 and sensor2, we send following packets: read_sensor1, read_sensor2 and we miss first replay and than we have: read_sensor1 - sensor2_replay and read_sensor2 - ...next packet replay.

I got this case 2 times when gateway works for some days\week without restart(rare case) - so I haven't more beautiful fix for now =(

If your setup will work without this problem - you can simply leave it removed =)

But when i will have some free time - i will try to think how to do it more correctly =)

seblucas commented 7 years ago

Thanks a lot for your answer. I have only one motion sensor (the other was dead when I received it so I got some repairing to do).

I'll let it run for a week with full logs and see if everything is fine.

monster1025 commented 7 years ago

I'll let it run for a week with full logs and see if everything is fine. Yep, i hope you have configured sensor polling (this problem exist only when I have a lot of sensor polls - my setup is polling all 20 sensors every 2sec).

seblucas commented 7 years ago

For now I only have one motion sensor and 2 magnets .... I won't be able to test that for now. Hopefully I'll be able to fix my other motion sensor but don't count on me to confirm that for now.

monster1025 commented 6 years ago

I have maid a settings switch to turn off "read_unwanted_data" fix (for now), but really need to fix all work with udp =)

  unwanted_data_fix: True #leave it True if it works for you. Otherwise (if you didn't recieve any data from sensors) - set it to False
seblucas commented 6 years ago

Sorry for the delay but I can confirm that with unwanted_data_fix: False everything works perfectly fine.

I retried unwanted_data_fix: True and it still hangs after printing INFO:xiaomihub:Discovering Xiaomi Devices

Anyway I'll close this. Thanks a lot