Skip to content

Decode the Landis+Gyr push that carries no descriptors or OBIS codes - #1269

Merged
gskjold merged 2 commits into
mainfrom
feature/landisgyr-descriptorless-push
Oct 15, 2026
Merged

gskjold merged 2 commits into
mainfrom
feature/landisgyr-descriptorless-push

Conversation

@gskjold

@gskjold gskjold commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

A Landis+Gyr E450 (IDIS 2DLM) in Slovenia was reported as unsupported. The reader actually reads it fine — the failure is one layer up.

The problem

The meter pushes a bare COSEM structure: no capture-object descriptor array and no OBIS codes, just the meter id followed by naked integers. Two shapes alternate every ~2 s:

02 09  <id>  1.7.0 2.7.0 3.7.0 4.7.0 1.8.0 2.8.0 3.8.0 4.8.0    (double-long-unsigned)
02 0E  <id>  14.7.0 31/51/71.7.0 32/52/72.7.0                   (long-unsigned)
             21/41/61.7.0 22/42/62.7.0                          (double-long-unsigned)

LNG needs the descriptor array and LNG2 needs a long-unsigned first element, so neither claims these frames and IEC6205675 falls through to AMS unknown meter type, trying to identify....

The knock-on effect is what the reporter sees. Framing, CRC and DLMS unwrapping all succeed — the debug log shows Received valid DLMS at 30 +56 at 2400 8N1 — but the parser returns listType 0, so validDataReceived never reaches 2 and handleAutodetect() keeps rotating baud rates straight past the setting that works. It walked over the correct one twice in the submitted log. Pinning the port manually stops the rotation but still yields no data, so there is no configuration workaround.

The fix

LNG3, a third parser alongside LNG/LNG2, dispatched from PassiveMeterCommunicator::getData().

The format carries no identifier at all, so LNG3::matches() validates the shape instead of a magic string: structure tag, element count 9 or 14, a leading octet string, and the type byte of every value checked against the expected run — plus a length guard, since a bad cast here reads off the end of the HAN buffer. The test is behind a static method rather than inline in the dispatch because the existing if/else chain has no way back to IEC6205675 once a branch is taken.

Worth a look during review: Iskra sends a 9-item structure of exactly the same shape, led by its ISK1030777478586 list id (test/payloads/iskraemeco/gh869-6.hex). The first cut silently stole that frame and changed its decode; the golden sweep caught it. matches() now also requires the leading octet string to be all digits — every list identifier in this decoder contains letters, while this one is the bare serial.

Voltage is whole volts on this meter, so it is taken unscaled rather than divided by 10 as in the sibling lists — this avoids reintroducing the 23.7 V-instead-of-237 V bug seen on gh949/gh934.

Confirmed against the DSO's documentation

The mapping was originally reverse-engineered from the capture. The reporter has since obtained the meter's push object lists from the DSO, which confirm it register for register:

9-item frame — 0-0:96.1.0 Device ID 1 (manufacturer serial), then 1-0:1.7.0 +P, 2.7.0 -P, 3.7.0 +Q, 4.7.0 -Q, 1.8.0 +A (QI+QIV), 2.8.0 -A (QII+QIII), 3.8.0 +R (QI+QII), 4.8.0 -R (QIII+QIV).

14-item frame — 0-0:96.1.1 Device ID 2 (utility serial number 2), then 1-0:14.7.0 net frequency any phase, 31/51/71.7.0 currents, 32/52/72.7.0 voltages, 21/41/61.7.0 +P per phase, 22/42/62.7.0 -P per phase.

Everything matched except one thing, now fixed in the second commit: the two frames lead with different id registers. The parser assumed they were the same and wrote meterId from whichever frame arrived. On this meter both registers happen to hold the same digits so the capture doesn't expose it, but where they differ the id would flip every couple of seconds, taking the MQTT topic and the Home Assistant entity id with it. Only the 9-item frame (96.1.0) sets meterId now, matching what LNG does on the sibling L&G format.

Testing that carry-forward needed the parser to see the running meter state the way PassiveMeterCommunicator::getData() passes it, so decoder_harness gained a sequencing entry point rather than always decoding against an empty state.

The DSO also documents the port as 2400 8E1. The submitted log decoded five consecutive frames cleanly at 8N1 and autodetect never tried 8E1, so it settles there and runs — worth knowing, but nothing to change here.

Not addressed

  • Frequency is dropped. Element 2 of the 14-item frame is 1-0:14.7.0 net frequency (any phase), but AmsData has no field for it. It is named in the layout struct for offset correctness and left unread; adding the field would touch AmsData, the MQTT templates and the UI.
  • Pre-existing golden drift is in the diff. Three lines unrelated to this change (elgama/gh1177-1.txt and kamstrup/gh1191-1.hex added, gh175-2 counter 85820.920 → 0.000) come from manifest.json being stale on main — regenerating it on a clean tree reproduces them without any of these changes. The gh175-2 shift is state carry-over between fixtures in the golden sweep now that gh1191-1 decodes ahead of it, which is arguably a harness bug worth a separate look. Left alone rather than folded in here.

Verification

New fixtures test/payloads/landis-gyr/em-si2026-{1,2}.hex. The reporter's meter serial is redacted (replaced with 999999999999, HDLC FCS recomputed); every other byte is the original capture.

test_landisgyr_e450_slovenia asserts both frames field by field. Golden sweep now records:

{ ".../em-si2026-1.hex", 1, 3,9, 513,0, 0,0,0, 0,0,0, 65138.118, "999999999999" },
{ ".../em-si2026-2.hex", 1, 4,9, 0,0, 237.00,236.00,236.00, 1.05,0.37,1.20, 0.000, "999999999999" },

Cross-check on the per-phase frame: 221 + 82 + 205 W = 508 W, exactly the 1.7.0 the meter pushes 3 s later.

  • pio test -e native — 25/25 pass, no other fixture's decode changed
  • pio run -e esp8266dev — SUCCESS, +1372 bytes flash (98.1% → 98.3%, 18021 bytes still free)
  • pio run -e esp32dev — SUCCESS

🤖 Generated with Claude Code

gskjold and others added 2 commits September 10, 2026 09:34
A Landis+Gyr E450 (IDIS 2DLM, Slovenia) pushes a bare COSEM structure: no
capture-object descriptor array and no OBIS codes, just the meter id followed
by naked integers. Two shapes alternate every ~2 s -- a 9-item frame with the
totals (1/2/3/4.7.0 and 1/2/3/4.8.0) and a 14-item frame with the per-phase
values.

LNG needs the descriptor array and LNG2 needs a long-unsigned first element, so
neither claims these frames and IEC6205675 falls through to "unknown meter
type". The reader decodes the frames all the way to DLMS but produces
listType 0, so validDataReceived never reaches 2 and serial autodetect keeps
rotating baud rates past the setting that works (2400 8N1). There is no
configuration workaround.

Add LNG3 for the two shapes. The format carries no identifier, so
LNG3::matches() validates the structure tag, the element count and the type of
every value before the payload is cast onto a layout struct. Iskra sends a
9-item structure of the same shape led by its "ISK..." list id, so the leading
octet string must also be all digits -- every list identifier in this decoder
contains letters, while this one is the bare serial.

Voltage is whole volts here, so it is taken unscaled rather than divided by 10
as in the sibling lists.

Frequency (element 2 of the 14-item frame) is named in the layout struct for
offset correctness but not read: AmsData has no field for it.

Costs 1372 bytes of flash on ESP8266 (98.1% -> 98.3%).

The fixture serial is redacted and the HDLC FCS recomputed; every other byte is
the original capture.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The push object lists the DSO supplied show the two frames lead with
different registers: the 9-item frame with 0-0:96.1.0, the manufacturer
serial, and the 14-item frame with 0-0:96.1.1, a serial the utility assigns
separately. LNG3 assumed both were the same id and wrote meterId from
whichever frame arrived.

On the reporter's meter the two registers happen to hold the same digits, so
the capture does not show it, but where they differ meterId would flip every
couple of seconds and take the MQTT topic and the Home Assistant entity id
with it. LNG uses 96.1.0 on the sibling L&G format, so follow that: only the
9-item frame sets meterId, and apply() carries it into the other frame.

The same lists confirm the rest of the mapping register for register,
including element 2 of the 14-item frame as 1-0:14.7.0 net frequency. Recorded
in the layout structs and the payload README.

Testing the carry-forward needs the parser to see the running meter state, the
way PassiveMeterCommunicator::getData() passes it, so give the harness a
sequencing entry point instead of always decoding against an empty state.

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions

Copy link
Copy Markdown

🔧 PR Build Artifacts

Version: 2bf0f86

All environments built successfully. Download the zip files:

Artifacts expire after 7 days. View workflow run

@gskjold
gskjold merged commit 32a919f into main Oct 15, 2026
8 checks passed
@gskjold
gskjold deleted the feature/landisgyr-descriptorless-push branch October 15, 2026 09:38
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.

1 participant