laundry: fix six issues from review of the cloud-cycle branch

Also drops appliance-specific wording from the new user-facing strings. The
setup step said "your washer" and told people to "turn the dial", which is
wrong for the DW5000C dishwasher that advertises the same tokens.

The two that could have caused a wrong wash cycle:

- The Download-course candidate was counted on every poll that saw a loaded
  one-time payload, not on the polls where one was actually loaded. Since a
  stale token is never evicted, it keeps being reported through however long
  the appliance then sits on some ordinary course -- so "most frequent"
  ranked by dwell time. Reproduced: one poll on Course_87 then 200 on
  Course_1B suggests 1B, and accepting the suggestion makes picking a
  download program start a Cotton wash. Now only a change of the payload
  counts, which is the moment the device is known to accept a program.
- The Download-course dropdown had custom_value=True, contradicting its own
  comment, so a typed-in code went into the Course_ token of a real write
  unchecked. Off now, plus a server-side check against the device's own
  course list where the value is stored.

Two that quietly broke things beyond this feature:

- cycle_select now always supplies a display_fn (to label cloud programs),
  which defeated select._display's "no state table and no fallback -> return
  raw" exit. Every dryer, dishwasher and air dresser on an unrecognized
  course table would have had its options and state reshaped from '0E' to
  '0 E', breaking automations and recorder history. The exit now keys off
  whether anything actually named the value, not whether a fallback existed.
- The synthetic cloud field reached diagnostics, which reads
  canonical_resources -- publishing user-typed program names in a dump
  people paste into issues, directly against the comment claiming it never
  could. Dropped at the redaction boundary, with a matching strip for the
  debug read service, which wants device state unredacted but shouldn't
  present our bookkeeping as something the appliance said.

And two smaller ones:

- The repair fired on any device advertising slots, so the DW5000C -- four
  advertised, none ever loaded -- got a permanent warning nothing the owner
  did in Home Assistant could clear. It now waits until a payload has been
  seen, which is the only evidence that household uses downloaded programs.
- The name-collision check read only the translation catalog, missing the
  device's own personal-course labels, which the select renders identically.
This commit is contained in:
Marc Billow committed 2026-08-10 03:16:07 +00:00
1 parent 9d28b088cb
commit b921bdbb28
17 files changed
+279 -50

No files matched your search

+21
View File
@@ -207,6 +207,27 @@ class TestStoreRules:
assert store.observe(rep) is True
assert store.observe(rep) is False
def test_candidates_rank_by_program_loads_not_by_dwell_time(self):
"""A stale OneTimeCloudCourse_ token outlives the run it belonged to,
so it is still reported through every poll the appliance spends on
whatever ordinary course comes next. Counting polls would rank that
course first and suggest it as the Download course -- and accepting
the suggestion would start a real wash cycle. Only the poll where the
payload actually changed is evidence."""
store = cloudcourse.CloudCourses()
loaded = _rep(["CloudExtraCourse_55", "Course_87", f"OneTimeCloudCourse_{SPORTS}"])
stale = _rep(["CloudExtraCourse_55", "Course_1B", f"OneTimeCloudCourse_{SPORTS}"])
store.observe(loaded)
for _ in range(200): # ~100 minutes sitting on a cotton cycle
store.observe(stale)
assert store.download_candidates() == ["87"]
def test_a_second_distinct_load_is_counted(self):
store = cloudcourse.CloudCourses()
store.observe(_rep(["CloudExtraCourse_556B", "Course_87", f"OneTimeCloudCourse_{SPORTS}"]))
store.observe(_rep(["CloudExtraCourse_556B", "Course_87", f"OneTimeCloudCourse_{JEANS}"]))
assert store.download_candidates() == ["87"]
def test_view_is_empty_until_a_download_course_is_confirmed(self):
"""Both halves are required: without the course code there is no
write to build, so nothing should reach the select."""