feat(s4): change a Micromate's settings by serial, audited, schedule-checked

s4_change_settings runs the shared change core with a read-back verdict
for its state (as asked / unchanged / differs).  It reads the active
setup's name (unstripped), the preferences, trigger and setup blocks and
the schedule; patches the setup through micromate.setup_fields; sends
THOR's setup push (0xDA 68 73 82 83 71 72, now enableable) once; reads
the setup back.  Refused before sending: a monitoring unit, a value the
unit does not allow (422), a stale preview (SettingsChanged, 409), and --
shown as 'blocked' in the preview -- the factory setup, a schedule that
loads another setup, an unreadable schedule, or a block SFM has not seen
(ChangeRefused, 409).  s4_settings carries the editable fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-11-03 21:43:03 -05:00
1 parent d0335dbbbd
commit c082f72d62
9 files changed
+407 -16

No files matched your search

+15
View File
@@ -233,6 +233,21 @@ def field_values(content: bytes, series: int) -> Dict[str, Any]:
return {d["field"]: d["value"] for d in editable_fields(content, series)}
def field_rows(before: bytes, written: bytes, series: int, fields, now: Optional[bytes] = None) -> Dict[str, Dict[str, Any]]:
"""For each changed field: its label, the value the unit had (old), the value
sent (new) and, given a read-back, what the unit now holds (now)."""
a, w = field_values(before, series), field_values(written, series)
n = field_values(now, series) if now is not None else None
labels = {d["field"]: d["label"] for d in editable_fields(written, series)}
out: Dict[str, Dict[str, Any]] = {}
for f in fields:
row: Dict[str, Any] = {"label": labels[f], "old": a[f], "new": w[f]}
if n is not None:
row["now"] = n[f]
out[f] = row
return out
# ── Checking ────────────────────────────────────────────────────────────────
def _number(field: str, v: Any) -> float: