EEBUS and metering

EEBUS LPC and LPP limits to and from power caps, and the § 14a minimum and Lastgang energy from German metering, in exact watts.

On this page

A German site under § 14a EnWG has three numbers from three places: the minimum it must always be allowed to draw (computed from its devices), the limit the control box writes over EEBUS, and the meter data that settles what happened. Two features bring them into this crate's shapes.

flexibility = { version = "0.4", features = ["eebus", "metering"] }

EEBUS limits (eebus)#

LPC (Limitation of Power Consumption) and LPP (of Power Production) both take a non-negative magnitude; LPP's is negated on the wire (the eebus crate's sign table). So an LPC limit is a consumption cap and an LPP limit a feed-in cap:

use flexibility::eebus::{self, Direction, LimitWrite};
use flexibility::Rounding;

let write = LimitWrite::active_for(8_500, Duration::from_secs(7_200));
let cap = eebus::limit(Direction::Consumption, &write, received, day.end(), Rounding::Exact, dso)?
    .ok_or("deactivated")?;
// max 8.5 kW from `received` for two hours

An EEBUS duration starts when the write arrives, and this crate has no clock, so you pass the instant. A write without a duration lasts until the horizon you pass. A deactivated write is None.

A device may acknowledge a fraction of a watt (4200.5 W), and is then bound by it. You name the rounding: Rounding::Exact refuses it, Rounding::TowardZero gives 4 200 W, the stricter cap for LPC and LPP alike, and HalfAwayFromZero the nearest watt. A negative value is always refused.

eebus::failsafe(direction, value, window, rounding, provenance) is the failsafe limit as a cap over the window you expect the fallback to last. Apply it to an envelope with the § 14a guarantee and a failsafe below the minimum is refused:

failsafe refused: ISP 69 (17:00–17:15 +01:00): bound 4.2 kW (dso.example lpc-2026-12-01-17) breaks the guarantee of 8.001 kW (bnetza.de BK6-22-300 Anlage 1 Ziff. 4.5)

eebus::write(&limit, at) goes the other way: the LPC or LPP write for a limit, with the duration left at at. eebus::write_open(&limit, at) leaves the duration out, so the device holds the limit until it is released (LimitWrite::deactivated()) or replaced: a reduction "until further notice". EEBUS carries one cap, so both refuse a band (both bounds), a consumption cap below zero, or a limit not in force at at. What both sides can carry round-trips.

The § 14a minimum (metering)#

metering computes the minimum per BK6-22-300 Anlage 1 Ziff. 4.5. metering::guarantee(minimum, window, provenance) turns it into a guarantee, in whole watts rounded up: the minimum is a power that must at least stay allowed, so 0.4 × 20.001 kW = 8 000.4 W is kept as 8 001 W.

Meter data as actual power (metering)#

metering::power(&[&import, &export], &grid, rounding) turns quarter-hour Lastgang energy into average power per ISP: import (1-0:1.29.0) positive, export (1-0:2.29.0) negative, summed exactly and rounded once per ISP. Rounding each channel first would differ by a watt (1.4 W import and 0.6 W export net to 0.8 W → 1 W, not 1 W − 1 W = 0 W), and a watt is enough to fail a digest comparison.

Every quarter must be present and billable, as metering defines it; a missing, Faulty or Unknown quarter is refused naming its instant, and so is a channel that is not an active-energy Lastgang in kWh. If your contract settles only on measured values, filter first: the gap is then refused, not filled.

The full program is examples/control_box.rs: cargo run --features eebus,metering --example control_box.