Address review: gate the AddWash master write on a readable mask

The master alarm switch wrote AddWashSet_7/_0 without consulting
_add_wash_mask, so a device reporting a wider mask (AddWashSet_15) or a
non-numeric one had it truncated to three bits -- the write that mask's
own docstring rules out, while the per-moment switches already refused it.

Also corrects the washer_ww6500 golden docstring: the fixture carries no
/oic/d and the test passes no device_types, so the device is typed solely
by the WW consumer prefix in its description. A51 is not a board token,
which makes that the fragile route worth naming.
This commit is contained in:
Marek Tyburec committed 2026-08-19 19:41:13 +02:00
1 parent 6003394cb2
commit 51bce3c8cf
3 files changed
+40 -5

No files matched your search

@@ -310,7 +310,10 @@ def _add_wash_set_write(mask):
def _add_wash_alarm_write(p, rep, href=None):
if p not in ("On", "Off") or not rep.get("x.com.samsung.da.options"):
# Gated on the mask being readable, like the per-moment writes: a device
# reporting a wider mask than these three bits would otherwise have it
# truncated to 7 here, silently dropping a moment it supports.
if p not in ("On", "Off") or _add_wash_mask(rep, "AddWashSet") is None:
return None
return _add_wash_set_write(0b111 if p == "On" else 0)
@@ -320,7 +323,10 @@ def _add_wash_bit_switch(key, icon, bit):
The mask is the only state, so switching the last moment off lands on 0
and takes the alarm with it, and switching one on from 0 turns the alarm
back on.
back on. The corollary is that switching the master off and on again
writes 7, resetting a rinse-only selection to all three moments -- the
appliance remembers no previous subset either, so there is nothing to
restore.
"""
def read(rep):
@@ -445,6 +451,10 @@ WASHER_COURSE = Capability(
_add_wash_bit_switch("add_wash_alarm_rinse", "mdi:water", 0),
_add_wash_bit_switch("add_wash_alarm_final_rinse", "mdi:water-check", 1),
_add_wash_bit_switch("add_wash_alarm_spin", "mdi:sync", 2),
# On at rest: an idle washer reports AddWashAvailable_7 and the mask
# only empties as the cycle consumes each moment. This says the cycle
# permits AddWash, not that laundry can go in now -- that is
# add_wash_indicator.
BinarySensorDesc(
key="add_wash_available",
icon="mdi:tshirt-crew-outline",