examples: Add dup filtering to mqtt_relay #3018
Merged
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.
Keep information about the previous value sent. If it's been 5 seconds, or new value is different (ignorning keys like snr and frequency), then send it. Otherwise, just don't. This causes bursts of e.g. 4 transmissions to result in one MQTT message, on the theory that the 4 transmissions are not actually 4 messags, but a strategy to transmit one message more reliably.
Define a new configuration option to enable duplicate filtering, and default it to True.
Tonight, this is a draft with debug logging enabled.
But it's running on 3 systems, 1 macOS and 2 Debian, and seems to be working ok.
Obviously I should turn off debug logging, and I'm inclined to just change to debug = False, and not make it a config. I lean to understandability and defensive code over beauty.