imsys

Electricity metering

Run Rust examples for the seven BSI v1.1 metering use cases, from monthly billing closes to TAF 14 measurement blocks for value-added services.

A tariff use case (German Tarifanwendungsfall, TAF) specifies what the gateway does with meter data. The billing examples use cumulative watt-hours. TAF 9 and TAF 10 use instantaneous measurements. The host authenticates the meter, authorizes recipients and handles retention and delivery. For gateway-calculated demand and meter-registered histories, see the TAF 8 and TAF 15 guide.

Select a TAF 1 closing reading

Run cargo run -p smgw-core --example taf1. The meter reports 544,900 Wh shortly before the monthly close and 545,000 Wh at the close. The output contains one value, 545,000 Wh, with the profile ID, meter channel and scheduled closing time.

Commission one import or export channel. Convert each local billing close to UTC and call Profile::close after the reception window ends. A wrong channel or slot leaves the close pending. Finalizing a missing or invalid reading consumes the close without producing a report. Closing profile API · BSI TR-03109-1 v1.1, §4.2.2

Simulate TAF 2 energy registers

Run cargo run -p smgw-core --example taf2 to replay a single cumulative electricity meter. At 09:45 UTC the baseline is 1,000 Wh. The tariff changes at 10:00. At 10:15 the meter reads 1,200 Wh.

Reading at 10:00Outgoing registerIncoming registerError register (63)Total (0)
1,120 Wh120 Wh80 Wh0 Wh200 Wh
Missing0 Wh0 Wh200 Wh200 Wh

Create one accumulator per meter, energy direction and evaluation profile. Submit every quarter-hour in order, including missing slots. Supply the register that applied throughout the elapsed period. A gap wholly within one tariff credits that register on recovery. A change anywhere inside a gap makes the recovered delta ambiguous. A nonfatal meter fault sends both adjacent measured deltas to the error register. The simulator stops the instance on a fatal fault.

An FSCH schedule supplies price windows. Commissioning maps each price to a metering register. Register API · BSI TR-03109-1 v1.1, §§4.2.3.2–5

Retrieve a TAF 6 daily balance

Run cargo run -p smgw-core --example taf6. The example retrieves 545,000 Wh for the opening of March 29, 2026 in Berlin. The next day opens 23 hours later. Each history holds one profile, meter, import or export direction, and register. Use the physical meter balance or a derived total, tariff or error register.

Supply consecutive local day boundaries resolved to UTC. Record qualified balances at the exact opening and call advance_to as billing days pass, including days with missing readings. A lookup uses the trusted current time and returns a single exact match within the current day and its 41 predecessors. Authorize the exceptional request for that recipient, quantity and date before lookup. The application handles durable retention, the HAN access log, signing, encryption and delivery. History API · BSI v1.1, §4.2.4

Record a TAF 7 meter series

Run cargo run -p smgw-core --example taf7 to record 1,000 Wh at 09:45 UTC, a missing slot at 10:00 and 1,200 Wh at 10:15. All three entries remain visible after recovery. With a tariff switch at 10:00, TAF 2 books the 200 Wh difference to its error register.

Create a Series::<N> for one commissioned meter and import or export direction. Choose quarter-hour or hourly slots, starting on the UTC grid. Submit every slot in sequence, with its scheduled time. For a received reading supply its source timestamp, cumulative whole Wh and quality. Use Observation::Missing for a gap. Archive the block when full and begin the next one explicitly.

Use quarter-hour slots to feed the same trace to TAF 2. Series API · BSI TR-03109-1 v1.1, §4.2.5

Report TAF 9 feed-in power

Run cargo run -p smgw-core --example taf9. The generation meter reports 1,800, 2,100 and 1,900 W at one-minute intervals. With a 2,000 W threshold, the second reading crosses above and the third crosses below. The sample identifies the triggering channel even when a periodic report falls at the same instant.

Commission one meter and one active-power quantity (total, L1, L2 or L3). Use its signed watt convention for both measurements and threshold. Pass None for a missing or invalid sample. The first qualified sample after a gap establishes a new baseline. An on-demand lookup expires at the next reception slot. Feed-in profile API · BSI v1.1, §4.2.6 and table 4.7

Report TAF 10 grid-state measurements

Run cargo run -p smgw-core --example taf10. L1 voltage rises from 239.5 V to 240.5 V. The second periodic report also signals the upward crossing of 240 V. Its meter reference is the commissioned pseudonym feeder-17. The same sample is available on demand until the next minute begins.

Commission one meter and one of the 16 permitted OBIS channels per profile. Normalize active power to signed watts, current to milliamps, voltage to millivolts, frequency to millihertz and phase differences to signed millidegrees. Use the same angle convention for the threshold and the samples. Submit a value or a gap for each 60-second slot. A wrong source or unit leaves the slot open for correction.

For pseudonymous reports, commission a pseudonym and use a profile ID that does not identify the meter. After on-demand delivery, log the recipient and omit the measured value. Grid-state profile API · BSI TR-03109-1 v1.1, §4.2.7

Deliver TAF 14 measurement blocks

Run cargo run -p smgw-core --example taf14. A customer portal receives 800, 950 and 1,050 W in one block. Its third sample crosses 1,000 W just as the three-slot period ends. The block identifies that sample and both reasons for delivery.

Commission one active-energy register (Wh), reactive-energy register (varh) or instantaneous active-power channel (W). By default, each qualified reading is ready for delivery on arrival, with one reception slot per minute. Set delivery_every_slots for periodic blocks or supply increasing thresholds for event delivery. Submit gaps as None. A gap breaks the threshold comparison and still counts toward the periodic boundary.

Choose Profile::<N> to hold up to N qualified samples. A periodic block must fit in full. If a threshold-only profile waits longer than its buffer can hold, the block returns the latest N readings in order and counts displaced readings in omitted. Consume or copy the block before submitting the next slot. The host checks customer consent and recipient permissions, records the delivery configuration without measured values in the customer log, and handles transmission and retries. Measurement block API · BSI v1.1, §4.2.8 and table 4.11