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
609 stars 140 forks source link

Enhancement: Provide mqtt information if connection to sensor failed or failed to retrieve data fro sensor. #78

Open wojciej opened 5 years ago

wojciej commented 5 years ago

Hello, Scenario: MiFlora work for some time and returns data but battery goes off and data stop to flow.

Openhab display value last returned over mqtt. User newer knows that sensor is offline.

I would like to propose enhancement: In the event of lost connectivity to the sensor or failure to retrieve data, deamon could returned either "N/A" or "connection lost" value in all measurements for lost sensor.

Do you think it would be possible ?

Thanks Jarek

aqualx commented 5 years ago

It is possible to add topic "timestamp" for device. And in openhab write a rule that checks last timestamp... This is already done for some mqtt conventions in daemon.

wojciej commented 5 years ago

Adding a timestamp is one way to go but then as you have mentioned, we would need another thing (rule) in openhab to check timestemp, while adding N/A or connection lost to a toppic would give user general idea of what have happened without additional rules in openhab.

wojciej commented 5 years ago

I have rethink this:

insertjokehere commented 5 years ago

@wojciej I have something like this kinda-sorta working in my branch https://github.com/insertjokehere/miflora-mqtt-daemon/tree/device_registry - it sets an availability topic in the home assistant discovery message. Currently all sensors that the daemon have discovered are marked as "available" if the daemon is up and connected; I've not implemented any logic around detecting if a specific sensor hasn't been contacted in a while