When integrating other third party consumers using MQTT, there is currently no way of knowing whether the EmonESP is online or not. I'm pulling data into my HomeAssistant instance and if the EmonESP goes offline, the last received value is assumed to still be correct. This causes things like integration functions to produce incorrect results with no indication that they are wrong.
This is commonly solved by adding an availability topic that indicates whether the device is online. When connecting to the broker, a 'last will' message can be provided which would be to set the availability topic to it's offline state. That means that the broker would send the offline availability payload if the connection unexpectedly closed.
The MQTT library used has support for this in it's connect() function, so it's a very minor change.
When integrating other third party consumers using MQTT, there is currently no way of knowing whether the EmonESP is online or not. I'm pulling data into my HomeAssistant instance and if the EmonESP goes offline, the last received value is assumed to still be correct. This causes things like integration functions to produce incorrect results with no indication that they are wrong.
This is commonly solved by adding an availability topic that indicates whether the device is online. When connecting to the broker, a 'last will' message can be provided which would be to set the availability topic to it's offline state. That means that the broker would send the offline availability payload if the connection unexpectedly closed.
The MQTT library used has support for this in it's connect() function, so it's a very minor change.