JsBergbau / MiTemperature2

Read the values of the Xiaomi Mi Bluetooth Temperature sensor 2 including custom encrypted format.
705 stars 162 forks source link

[Feature Request] Connection lost callback #17

Closed jorisvaesen closed 4 years ago

jorisvaesen commented 4 years ago

Would it be possible to implement a connection lost callback? This would make it easier to debug the reliability of the connection or to make a trigger when the connection is lost for more than x minutes.

JsBergbau commented 4 years ago

Yeah that would be possible, But is it worth it? Whats your standard callback? If it is a database or a MQTT you just could query when was the last value reported.

jorisvaesen commented 4 years ago

My standard callback is just a curl to a custom backend i've build. Checking the last sync would make it less accurate since I use -skip 50 which makes it more of a guess if the connection is lost when it's lost for a short time. It would be useful to log all connection lost error through the callback to see how many times the connection is actually lost and trying some options to reduce it in the future like moving the Pi or the sensor.

JsBergbau commented 4 years ago

If you just want to know how often connection is lost, you could just redirect the output to a log file. Then you grep for "Connection lost" and you know how often connection gets lost. Thats already implemented and works instantly.