ThomDietrich / miflora-mqtt-daemon

Linux service to collect and transfer Xiaomi Mi Flora plant sensor data via MQTT to your smart home system, with cluster support 🌱🌼πŸ₯€πŸ‘🌳
MIT License
610 stars 140 forks source link

Deamon stop to work after some time - not yet merged fork #79

Closed wojciej closed 5 years ago

wojciej commented 5 years ago

Hello, So I could not raise an issue on https://github.com/aqualx/miflora-mqtt-daemon directly so I am doing it here hoping that @aqualx would see it.

I have been using your fork and I believe I run into issue. I have both miflora sensors and and Mija bluetooth temperature monitor configured, some of the miflora sensors became unavailable from time to time (they are on a balcony and when blinds close BLE connection is lost). Nevertheless I have noticed that the deamon freeze from time to time. I had it run in a screen session to see the output:

[2019-03-25 00:51:08] Result: {"humidity": 44.4, "temperature": 23.0, "battery": 93} [2019-03-25 00:51:08] Publishing to MQTT topic "misensor/XMiTH_Bedroom"

[2019-03-25 00:51:08] Sleeping for Mijia Bluetooth Temperature Smart Humidity (60 seconds) ...

[2019-03-25 00:52:08] Retrieving data from Mijia Bluetooth Temperature Smart Humidity sensor "XMiTH_Bedroom" ... [2019-03-25 00:52:16] Result: {"humidity": 44.5, "temperature": 23.0, "battery": 93} [2019-03-25 00:52:16] Publishing to MQTT topic "misensor/XMiTH_Bedroom"

[2019-03-25 00:52:16] Sleeping for Mijia Bluetooth Temperature Smart Humidity (60 seconds) ...

[2019-03-25 00:53:16] Retrieving data from Mijia Bluetooth Temperature Smart Humidity sensor "XMiTH_Bedroom" ... [2019-03-25 00:53:31] Result: {"humidity": 44.3, "temperature": 23.0, "battery": 93} [2019-03-25 00:53:31] Publishing to MQTT topic "misensor/XMiTH_Bedroom"

[2019-03-25 00:53:31] Sleeping for Mijia Bluetooth Temperature Smart Humidity (60 seconds) ...

[2019-03-25 00:54:31] Retrieving data from Mijia Bluetooth Temperature Smart Humidity sensor "XMiTH_Bedroom" ...

And today its like almost 24h after the last output being displayed and no new response has show up. After I restart the deamon everything gets back to normal for like a day.

Let me know if I could add more input to this.

aqualx commented 5 years ago

Hi

Sorry, this has nothing to do with daemon itself. From my observation either Bluetooth stack crashes in Linux (I had this several time) or underlying Bluetooth wrapper. On my side I've added external watchdog that checks that daemon send any data from any sensor during 2 scan periods (I use timestamps). If no data received than watchdog restarts Bluetooth service (systemctl restart bluetooth.service) & miflora-mqtt-daemon. In my case restarting only miflora-mqtt-daemon might not help. In 2 months I've only 3 or 4 times when watchdog restarts services. With watchdog I have no issues with daemon at all.

PS: All this issues are indeed due to lost/weak BLE connection.

wojciej commented 5 years ago

Hey @aqualx That was in deed very good hint. Once I have restarted bluetooth service - while miflora seemed to be freeze and it started to work again. So as you have mentioned this is not a deamon issue here.

Would you elaborate on that external watchdog of yours ?

Thanks Jarek

aqualx commented 5 years ago

Sorry, my watchdog is written on custom JavaScript based rules engine for Wiren Board.

wojciej commented 5 years ago

Hey, I did some tests, every time i restart BT service only the deamon return to operations so I closing this ticket.

Thanks for your help