Repository navigation
Make UARTEx optimistic default true and honor optimistic: false - #383
Merged
Merged
Conversation
control() used to reflect the requested state whenever enqueue_tx_cmd() queued a command, so optimistic: false never waited for feedback and a stale wallpad packet between control() and TX made the state bounce (#382). - optimistic now defaults to true and means: reflect the request immediately, with or without a command. optimistic: false queues the command and updates state only from received packets. - The option is accepted only on controllable platforms (switch, climate, cover, fan, lock, media_player, number, select, text, valve, water_heater); light, sensor, binary_sensor, text_sensor and button reject it. - climate: a mode command that carried the target temperature no longer triggers a second temperature command when optimistic is false. - select: restore_value saves on feedback, and control() saves only when the value is reflected. - light: internal dedupe fields always follow the light state, so feedback corrects lights without commands. - Docs (EN/KO) and switch native tests updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A command lambda returning no data is how wallpad packages reject a request. With optimistic now defaulting to true, rejected requests (and the target temperature a rejected climate mode packet carried) were reflected, failing the cvnet regression test. - Add UARTExDevice::enqueue_and_reflect(): reflect only when optimistic and the command is either not configured (virtual entity) or produced data. Use it on every optimistic-gated control path. - climate: a mode command that read the target never triggers a separate temperature command; mode/target are reflected only when accepted. - Docs: clarify rejection, combined climate packets and optimistic: false. - Tests: rejected-lambda switch case; cover entity in the ESPHome fixture. 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.
Fixes #382
Problem
Each entity's
control()usedenqueue_tx_cmd(cmd) || optimistic_.enqueue_tx_cmd()returns true as soon as the command is queued, sooptimistic: false(the old default) still reflected the request immediately. A periodic wallpad packet that arrived betweencontrol()and the actual TX then reverted the state (27 → 15 → 27).Change
optimisticnow defaults totrue. The request is reflected immediately, with or without a command. This matches ESPHome template entities and suits UART latency.optimistic: falsequeues the command and updates state only from received state packets, so there is no bounce.optimistic: false.restore_valuenow also saves on feedback.control()saves only when the value is reflected.UARTExDevice::enqueue_and_reflect()reflects only when optimistic and the command is not configured or produced data. This keeps the wallpad packages' empty-lambda rejections working (fixes the cvnet regression test).muted_is updated regardless ofoptimistic.Breaking changes
optimistic: falseto wait for feedback (the behaviour since Fix UARTEx command handling and wallpad packet processing #370).optimistic: falseto keep the old behaviour.optimistic: true. In climate, a rejected mode packet that read the target also rejects that target, and no separate temperature command is sent.optimisticon light/sensor/binary_sensor/text_sensor/button now fails config validation. Remove the key.Verification
tests/native/uartex_parser/run.sh(WSL g++,-Werror) passes. The switch tests were updated for the new default and the true/false cases. The suite compiles only the switch platform; the other platform.cppfiles were not compiled.esphome config(2026.7.4) reports valid for everytests/components/uartexfixture.optimistic: true.optimisticon light or binary_sensor is rejected.test_packet_validation.py: 12 tests OK.tests/packages/wallpad/protocol): 14 tests OK, includingtest_cvnet_combined_climate_calls.esphome compile test.esp8266-ard.yamlsucceeds. A cover entity was added to the fixture so CI compiles cover too.Review notes
has_value()check are left for a follow-up PR.🤖 Generated with Claude Code