Repository navigation
Add state_debounce option to UARTEx entities - #379
Merged
Merged
Conversation
Hold matched state packets and apply them only after the configured time since the change started (latest packet wins). A packet equal to the last applied state cancels the pending change and re-publishes, so transient wallpad packets no longer reach Home Assistant. Default 0 keeps the previous behaviour. Requires `state`, max 60s. Closes #378 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When an entity transmits a control command, arm a one-shot window of state_debounce length; the first differing state packet inside it is the confirmation and is applied immediately. Polling (command_update), write_command and rx replies do not arm it, packets equal to the last applied state do not consume it, and retries re-arm it. This keeps command results prompt for entities without optimistic, e.g. switch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a common per-entity
state_debounceoption touartex(refs #378). Wallpads sometimes emit transient state packets (e.g. climateoff↔heatfor 1–2 s); these were published to Home Assistant immediately.Behaviour
statepattern matches, the packet is held in a pending buffer instead of being published.UARTExComponent::loop()applies it once the debounce time has elapsed.state_response/ACK handling is unchanged; HA commands still reflect immediately viacontrol/optimistic.state_debouncelength is armed: the first state packet that differs from the last applied state is treated as the confirmation and applied immediately (so command results are not delayed even withoutoptimistic, e.g. switch). Polling (command_update),write_commandand rx replies do not arm it; packets equal to the last state do not consume it; retries re-arm it. Only the first change after the latest command is immediate.preserve_statecommands wait while a change is pending (last_state is not settled yet).0= previous behaviour. Requiresstate; max60s.Notes / limitations
Tests
tests/native/uartex_parser/test_state_debounce.cpp(disabled path identical, first packet, glitch filtered, latest wins, stuck-state after control, loop() wiring, millis wraparound, preserve_state interaction, post-command bypass incl. polling/write_command/rx-reply not arming, one-shot, expiry, retry re-arm) —run.shpasses.esphome configandcompile --only-generateontests/components/uartex/test.esp32-idf.yamlpass; negative checks (90s, missingstate) rejected.🤖 Generated with Claude Code