Skip to content

fix: don't drop control() calls that arrive while a request is in flight - #48

Open
sterin wants to merge 1 commit into
dudanov:mainfrom
sterin:main
Open

sterin wants to merge 1 commit into
dudanov:mainfrom
sterin:main

Conversation

@sterin

@sterin sterin commented Aug 31, 2026

Copy link
Copy Markdown

AirConditioner::control() silently discarded any call made while m_sendControl was true, with no log line, queue, or merge. In practice this drops every attribute but the first when several are set in quick succession (e.g. a Home Assistant scene setting mode, target temperature, preset, swing, and fan on a midea climate entity within milliseconds).

Accumulate such calls into a pending Control instead, merging per field so the latest value for each field wins. Replay the accumulated pending control once the in-flight request completes (either success or failure). By then m_readStatus() has already refreshed the local state from the appliance's response, so mode-gated fields (fan/swing under MODE_OFF) evaluate against current rather than stale state.

Verified it compiles against esp8266-arduino, esp32-arduino, and esp32-idf, and OTA-flashed to real hardware (SLWF-01Pro dongle) driving an Electra/Midea AC unit: a scene setting mode/temp/preset/swing/fan now converges in one application instead of several.

Fixes #47

`AirConditioner::control()` silently discarded any call made while
`m_sendControl` was true, with no log line, queue, or merge. In practice
this drops every attribute but the first when several are set in quick
succession (e.g. a Home Assistant scene setting mode, target temperature,
preset, swing, and fan on a `midea` climate entity within milliseconds).

Accumulate such calls into a pending `Control` instead, merging per field
so the latest value for each field wins. Replay the accumulated pending
control once the in-flight request completes (either success or failure).
By then `m_readStatus()` has already refreshed the local state from the
appliance's response, so mode-gated fields (fan/swing under `MODE_OFF`)
evaluate against current rather than stale state.

Verified it compiles against esp8266-arduino, esp32-arduino, and
esp32-idf, and OTA-flashed to real hardware (SLWF-01Pro dongle) driving
an Electra/Midea AC unit: a scene setting mode/temp/preset/swing/fan
now converges in one application instead of several.

Fixes dudanov#47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AirConditioner::control() silently drops updates that arrive while a SET_STATUS request is in flight

1 participant