eebus

Home / Docs / Sign conventions

Sign conventions

What a positive number means in every power-carrying use case, with the requirement that says so — and where this crate takes a magnitude instead.

A wrong sign is the one mistake that looks right in every log line: a battery charges when it was meant to discharge, a limit caps feed-in when it was meant to cap draw. This page is the one place the rule is stated for every use case this crate implements, so a converter's "known consumption, known feed-in" test has something to cite.

One rule underneath

Every EEBUS use case here uses the passive sign convention, which the specifications also call the load convention. The SPINE Resource Specification states it once (§3.10.1.14.1, EnergyDirectionEnumType):

consume — Positive values SHALL be interpreted as consumption; negative values SHALL be interpreted as production.

What differs per use case is whether the API takes a signed value or a magnitude.

Per use case

Use caseIn this crate's APIOn the wireSource
LPC — Limitation of Power Consumptionnonnegative magnitudeactive limit ≥ 0; failsafe and nominal max ≥ 0[LPC-001], [LPC-010]
LPP — Limitation of Power Productionnonnegative magnitudeactive limit ≤ 0, negated at the boundary; failsafe and nominal max ≥ 0[LPP-001], [LPP-010]
COB — Control of Batterysigned: + charges or draws from the grid, − discharges or feeds inas given[COB-001/1], PCC §2.1.2.1
MPC, MGCPsigned power, current and energyas given, positiveEnergyDirection: consume; voltage unsigned[MPC-001], [MGCP-001]
MOB — Monitoring of Batterysigned: + charging, − dischargingas given, powerSupplyType: dc[MOB-001]
MOI — Monitoring of Invertersigned: yields are production, so −as given; apparent power ≥ 0; cos φ ≤ 0 while producing[MOI-001], [MOI-002/1..3]
MPS — Monitoring of PV Stringsigned: a producing string is −as given, powerSupplyType: dc; voltage unsigned[MPS-001], [MPS-002]
EVCEMsigned, charging +as given, positiveEnergyDirection: consumeEVCEM TS §3
OPEV, OSCEVcurrent limits are magnitudes≥ 0 (maxValueLimit)OPEV/OSCEV TS §3
OHPCFpower slots are consumption, +as givenSPINE Resource §4.3.24.3.7.1

The two that take a magnitude

LPC and LPP share one state machine, and both sides of it — the Energy Guard and the Controllable System — take the limit as a nonnegative magnitude. "Cap at 4 kW" is LimitWrite::active(4_000) in both directions. The direction is a property of the use case, applied at the wire boundary: LPC writes +4 000 W, LPP writes −4 000 W, and both read the signed value back as 4 000. The failsafe limit and the nominal maximum are magnitudes on the wire as well; only the active production limit carries the minus sign.

use eebus::usecases::limitation::LimitWrite;

// The same request, whichever direction the guard was built for.
guard.require(&inverter, Some(LimitWrite::active(4_000)), now)?;

Counters of production

Cumulative production counters — MPC's produced energy, MGCP's grid feed-in, MOI's yields, MOB's discharge energy — only ever grow in magnitude (MGCP says so for feed-in, [MGCP-007]), and the load convention lists each of them as production. Read literally, a publisher sends them negative. This crate passes measured values through unchanged: it neither negates nor refuses one, and a client reading a counter from a device it did not build should be prepared for either spelling.

Held by a test

tests/sign_conventions.rs encodes a known consumption and a known production through every use case that writes power, and asserts the sign that goes on the wire: COB ±3 000 W, LPC +4 000 W, LPP −4 000 W, failsafe and nominal maximum positive in both directions, and consume and dc on the monitored units that must say so. The table above and the one in the crate documentation are the same table; a row that drifts from the encoders fails there.