Skip to content

fix(lighting): normalize_where canonicalises area-0 four-digit points only (0004 -> 04) - #141

Closed
gdluck wants to merge 1 commit into
OpenWebNet-HA:masterfrom
gdluck:fix/normalize-where-area0-four-digit
Closed

gdluck wants to merge 1 commit into
OpenWebNet-HA:masterfrom
gdluck:fix/normalize-where-area0-four-digit

Conversation

@gdluck

@gdluck gdluck commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Requested by A

Withdrawn 2026-10-24: OWNd #123 decided that normalize_where keeps 4-digit input as typed and MyHOME's own test pins it; MyHOME #798 canonicalises the yaml/registry spelling on its own, so no OWNd change is needed.

What is the problem

normalize_where("0004") returned "0004", a WHERE that no gateway accepts and none reports. Area 0 points 1..9 are 01..09 on the wire: writing them with four digits (0001) is refused by eleven of the twelve emulated gateways and by the physical F461, and the one gateway that accepts it (MH202) still reports the light as 01. A user who types where: "0004" (the "A=0, PL=4" spelling the configurator shows) got a light that never matched a bus frame; the MyHOME#147 thread resolves it by hand ("A=0 PL=3 will be 03; A=0 PL=12 will be 0012").

#123 decided that normalize_where leaves 0109 as typed (only non-APL numeric IDs > 15 have their 00 stripped). This PR does not change that; it only adds the area-0 case the oracle measures.

How is it solved

OWNd/message/lighting.py, normalize_where: a 4-digit base 000N with N in 1..9 becomes 0N, keeping any interface suffix (0007#4#01 → 07#4#01). Everything else is unchanged: 0109, 0209, 0010, 0015, 0112, 1015, 1001, 0000, 0900, 00, 0, #0004 all stay as typed (0021 → 21 as before). Callers: OWNd uses normalize_where only for the coarse-dimmer registry keys, which now match the addresses bus frames carry; nothing in OWNd sends the normalised value. CHANGELOG.md: entry under [Unreleased] / Fixed.

How is it tested

  • tests/test_who1_ts10_builders.py: new test_normalize_where_canonicalises_area_0_four_digit_points (19 cases: 3 rewritten, 4 four-digit non-area-0 inputs kept as typed per feat(message): protocol boundary cleanup APIs for MyHOME #736 #123, 5 real 4-digit addresses kept, 7 non-point or already canonical inputs kept). The existing test_apl_addressing_helpers (normalize_where("0109") == "0109") is untouched and still passes.
  • Fail before / pass after: on master 3 of the 19 fail (0004, 0001, 0007#4#01), the other 16 and test_apl_addressing_helpers pass; on this branch all pass.
  • Full suite: 1926 passed, 1 skipped (master: 1907 passed, 1 skipped); 100 % statement coverage, mypy clean, ruff clean, sync_documentation.py --check and verify_library_standards.py pass.
  • Live (F461 2.0.11, probe_area0, 2026-10): *#1*0001##, *1*1*0001##, *#1*0004## NACK within 10 ms; *#1*01##, *1*1*01## ACK; *1*1*1## addresses area 1 and has no effect on the point.

What does the Oracle say

Suite lights-area0, results/<P>/<V>/oracle/full/lights-area0.tsv:

Frame nack / silent ack / out
*#1*0001## F450 020010, F453 010100, F453AV 030014, F454 020051, F459 020105, F460 020012, F461 020011, H4684 020054, MH200 020102, MH200N 010108, MyHomeServer1 028206 (11) MH202 010024 (bus:$0301001500)
*1*1*0001## the same 11 MH202 010024 (bus:$0301001200, then own:*1*1000#1*01##)
*1*1*0010## (real 4-digit address) MH202 echoes own:*1*1000#1*0010##

So the only gateway that forwards 0001 reports the point as 01, while it echoes a real 4-digit address (0010) unchanged. The oracle exercises area 0 only; this PR changes nothing for areas 1..9.

Companion

MyHOME: OpenWebNet-HA/MyHOME#798 (the yaml validator currently accepts 0004 and the registry id keeps the 4-digit spelling; the MyHOME half warns and migrates, reports/09 F-05). Related: MyHOME#147.

Live MyHomeServer1 3.87.13 confirmation (2026-10-24)

Status reads on a second physical plant, a MyHomeServer1 running firmware 3.87.13 (*#13**16*3*87*13##, WHO 1013 model 67), captured in OpenWebNet-HA/MyHOME#799 (myhomeserver1_live_2026-10-24). The oracle emulates MyHomeServer1 2.82.06, so this is a newer firmware than the emulated one.

  • *#1*0001## NACK in 8 ms and *#1*0004## NACK in 14 ms (immediate firmware refusal), while *#1*01## / *#1*04## NACK after 2.0 s (forwarded, no device). *#1*0010## ACK (*1*0*0010##) and *#1*0014## ACK (*1*0*0014##) while *#1*10## NACKs after 2.0 s and *#1*14## answers *1*0*14##: 4-digit area-0 points 10-15 are real, distinct addresses that must stay as typed, exactly the boundary this PR implements (000N -> 0N, everything else untouched).

🤖 Generated with Claude Code

normalize_where("0004") returned "0004", an address no gateway accepts:
own-firmware-oracle lights-area0 records `*michnovka#1*0001##` and `*1*1*0001##`
as nack/silent on 11 of the 12 emulated gateways (F450, F453, F453AV,
F454, F459, F460, F461, H4684, MH200, MH200N, MyHomeServer1), and the
MH202, the only one that ACKs them, reports the light as `01`
(`*1*1000#1*01##`) while it echoes a real 4-digit `0010` as `0010`. The
live F461 2.0.11 NACKs `*michnovka#1*0001##` and `*1*1*0001##` within 10 ms and
ACKs `*michnovka#1*01##` / `*1*1*01##`. The same rule is what the MyHOME#147
thread gives users by hand (A=0 PL=3 is "03", A=0 PL=12 is "0012").

A 4-digit base with area 00 and point 1..9 (`000N`) now normalises to
`0N`, keeping any interface suffix (`0007#4#01` -> `07#4#01`). Every
other 4-digit input (`0109`, `0010`, `0112`, `1001`) is left as typed,
as decided in OpenWebNet-HA#123.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

2 participants