Add support for the MQTT integration's expire_after
setting
#200
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First off, thanks for this great project! I have been using it for months to get usage from my gas and water meters into HA.
Recently I discovered that I was missing a couple weeks of data for my sensors - rtlamr2mqtt had stopped collecting and sending sensor information to MQTT. It apparently didn't lose its MQTT connection, because it didn't publish the LWT message. I didn't see any obvious issues and a restart solved it, so I focused on finding a way to alert and recover from this if it happened again.
It turns out, Home Assistant's MQTT integration has a setting called
expire_after
which is exactly what I am looking for:This PR doesn't change the default behavior, but if
expire_after
is provided for a meter, it will pass that option into the MQTT discovery payload, which HA will use to cause the sensor to becomeunavailable
afterexpire_after
seconds have passed without a sensor reading. This should thus be set to something larger than the expected period between sensor readings (e.g. larger thansleep_for
).Thanks again!