Skip to content

Add tariff counter support (Tariff 1 & 2) for import/export - #1136

Merged
gskjold merged 2 commits into
UtilitechAS:mainfrom
matlab22:feature/tariff-counters
Jun 12, 2026
Merged

gskjold merged 2 commits into
UtilitechAS:mainfrom
matlab22:feature/tariff-counters

Conversation

@matlab22

@matlab22 matlab22 commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Adds support for separate tariff-based accumulated energy counters (Tariff 1 and Tariff 2) for both active import and export. Enables detailed tracking of energy consumption across different rate periods.

Fixes: Landis+Gyr parser bug where tariff values were read from meter but not stored.

Changes

Core Data Model

  • AmsData.h/cpp: Added activeImportCounterTariff1/2 and activeExportCounterTariff1/2 fields with getters
  • Modified apply() methods to handle OBIS tariff values (gr=8, tariff=1/2) and copy tariff counters between instances

Meter Parsers

  • IEC6205675.h/cpp: Added OBIS constants and parsing for 1.8.1, 1.8.2, 2.8.1, 2.8.2 (Iskra meters)
  • LNG.cpp: Fixed bug - parser now stores tariff values (o181, o182, o281, o282) instead of only summing them

MQTT Integration

  • JsonMqttHandler.cpp: Added tPIT1, tPIT2, tPOT1, tPOT2 fields to list3/list4 JSON
  • RawMqttHandler.cpp: Added topics for /meter/import/export/active/accumulated/tariff1 and /tariff2

Web UI

  • data.json: Added ict1, ict2, ect1, ect2 fields to data API
  • AmsWebServer.cpp: Populated tariff counter values in JSON response
  • Dashboard.svelte: Display tariff breakdown below total counters (only when tariff data present)
image

Compatibility

  • Fully backward compatible
  • Existing integrations continue with total counters (tPI, tPO)
  • Tariff fields only display when meter provides non-zero values

Testing

  • Tested on ESP32-C3 with Landis+Gyr meter
  • Verified MQTT JSON/Raw outputs
  • Confirmed UI displays tariff breakdown
  • Validated DLMS/HDLC parsing

Resolved AmsData::apply() onto main's 3-arg signature (tariff falls through
to the accumulated switch; std::max to match main) and re-applied the tariff
counter assignments onto main's rewritten IEC6205675 obis181/182 block.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@gskjold
gskjold merged commit f6ae2f5 into UtilitechAS:main Jun 12, 2026
gskjold added a commit that referenced this pull request Jun 12, 2026
Follow-up to #1136: source Tariff 1 & 2 counters from DSMR (IEC6205621) and additional IEC6205675 (DLMS) paths; wire up the previously-unused T1/T2 OBIS constants.
gskjold added a commit that referenced this pull request Nov 19, 2026
The Croatian Iskra IE.5 frames without OBIS codes (0x21, #1072, and 0x1C,
#1174) carry 1.8.1/1.8.2 and 2.8.1/2.8.2, but the positional decoder
skipped them, so the tariff counters added in #1136 stayed at zero and
the dashboard showed only the total.

Add the #1174 frame as a fixture (meter serial masked) and a test that
decodes both frame types twice, as a device does: the first frame only
identifies the meter as Iskra.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@matlab22
matlab22 deleted the feature/tariff-counters branch December 1, 2026 20:57
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