Skip to content

docs(integration-toolkit): always map a counter direction - #152

Merged
karlrank merged 1 commit into
mainfrom
docs/meter-reading-direction
Sep 10, 2026
Merged

docs(integration-toolkit): always map a counter direction#152
karlrank merged 1 commit into
mainfrom
docs/meter-reading-direction

Conversation

@karlrank

Copy link
Copy Markdown
Member

Adds a Counter Direction section to the inbound meter-readings page.

direction is part of how a reading is stored and queried — every reading is persisted with one — but nothing in the docs said so, and the obvious mapping is a trap.

Covers:

  • Resolution order: the reading's direction → the counter's → derived from the counter's obis_number. Set it at step 1 or 2; step 3 is a safety net, not a plan.
  • Where to set it, with the JSONata fallback for the counter (where obis_number is in scope) and the constant form for single-direction use cases — plus the warning that a direction on the reading wins over the counter's, so a blanket constant will relabel feed-in readings.
  • Why straight-through mapping is a trap: { "attribute": "direction", "field": "direction" } assigns unconditionally, so an ERP sending the key empty writes an empty attribute and the meter_counter schema's feed-out default never applies — entity-api only defaults attributes that are absent.
  • That heat, gas and water have no meaningful direction, so an ERP sending nothing for them is expected and fine.

Why now

One org accumulated 132,722 direction-less counters through a straight-through mapping; 621,747 of its water and heat readings were rejected and dropped over 31h before metering-api gained the OBIS fallback (metering-api!241).

🤖 Generated with Claude Code

`direction` is part of how a meter reading is stored and queried, so every
reading is persisted with one. Document the resolution order (reading ->
counter -> derived from OBIS), and that mapping it straight through when the
ERP sends the key empty writes an empty attribute and defeats the
`meter_counter` schema default — defaults only fill attributes that are
absent, not ones present and empty.

One org accumulated 132,722 direction-less counters this way; 621,747 of its
water and heat readings were rejected before metering gained an OBIS fallback.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@karlrank
karlrank merged commit c18f2f8 into main Sep 10, 2026
1 check passed
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