Don't let refresh requests pile up while not awake #521
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.
This change fixes a bug whereby identical refresh requests may pile up in a non-awake device's send queue over time. For example, I had an automation running at 15-minute intervals that would perform a refresh-all command. Several days later, when I performed an "awake" command against a mini-remote device (2342-232), Insteon-MQTT tried to send several hundred refresh commands to the mini-remote.
This change avoids queuing more than one refresh command by replacing identical queued refresh commands with newly-received refresh commands (under the assumption that it might be more convenient to the user if the new command is still waiting for a response at the time the device is woken up).
Confirmed no new flake8 errors, pylint errors, or code coverage gaps. All tests passing. Also, confirmed new test (test_queued_refresh_replace) fails prior to applying fix:
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: