AC: quantize subdevice temperature writes against their own step (Opus review)

async_send_command handed write_fn/validate_fn the raw cache snapshot
(real, on-the-wire hrefs), not a subdevice-scoped view. Every other
consumer of a full resources dict (exists_fn, rep_fn, is_legacy_board,
...) reads through coordinator.canonical_resources() specifically to
avoid this; write_fn/validate_fn didn't, so on a composite AC (issue
#177) _temperature_step's resources.get(HREF_TEMP_CONTROL) saw the
master's /temperature/control/vs/0 instead of the subdevice's own
/temperature/control/vs/1, silently rounding a subdevice's 0.5-degree
write to a whole degree. The remote-control gate stays on the raw
snapshot -- /remotectrl/* is a shared, MAIN-only resource a
subdevice's owned-hrefs-only canonical view would drop entirely.

climate.py's target_temperature_step duplicated this same
read-in-order logic; pointed it at airconditioner._temperature_step
so the read and write paths can't drift again.

Also, from the same review:
- _quantize_temperature rejects non-finite floats (nan/inf survive
  float() but raise out of round()/division, escaping write_fn's
  documented None-on-bad-payload contract).
- Deduplicated the quantize-and-check block shared by the
  temperature_ocf/temperature branches of _climate_write.
- Added the /temperatures/vs/0 items[]-fallback test that was
  previously unreachable (every increment-carrying fixture also has
  /temperature/control/vs/0, which _temperature_step checks first).
- Added a coordinator-level test seeding an indexed subdevice with its
  own step, distinct from the master's, covering the fix above.
- The Towels/Bedding regression test now checks all 7 locale catalogs,
  not just English -- the bug is a code-mapping error, and
  test_every_language_mirrors_the_english_catalog only checks key
  topology, not values.
This commit is contained in:
Marc Billow committed 2026-08-09 16:25:12 +00:00
1 parent 846aefbcba
commit 676074b2f8
6 files changed
+94 -23

No files matched your search

+13 -5
View File
@@ -164,15 +164,23 @@ def test_confirmed_washer_table_02_towels_bedding_are_not_swapped():
"""Issue #343: DA_WM_TP1_21_COMMON's Table_02 had 24/33 transposed --
selecting 'Towels' in HA ran the washer's Bedding cycle and vice versa.
24 must agree with the 69/6A-79/88 family's own Bedding/Towels pair
(6f/70), not with each other."""
states = _load("en")["entity"]["select"]["washer_cycle_table_02"]["state"]
assert states["24"] == states["6f"] == "Bedding"
assert states["33"] == states["70"] == "Towels"
(6f/70), not with each other.
Checked in every locale catalog, not just English: the underlying bug
is a device-code mapping error, not a wording issue, and
test_every_language_mirrors_the_english_catalog only checks key
topology -- a locale-specific 24/33 swap (the exact shape of #343)
would still pass that test."""
for language in _languages():
states = _load(language)["entity"]["select"]["washer_cycle_table_02"]["state"]
assert states["24"] == states["6f"], language
assert states["33"] == states["70"], language
def test_confirmed_washer_table_02_missing_course_names():
"""Issue #342: 06/08/a0 had no translation and fell back to the raw
device code in the UI."""
device code in the UI; 74 was already translated by the time this
landed and is pinned here only as a "didn't regress" anchor."""
states = _load("en")["entity"]["select"]["washer_cycle_table_02"]["state"]
assert {code: states[code] for code in ("06", "08", "74", "a0")} == {
"06": "XXL Laundry",