ENGY-ELEC
Electricity Consolidation Micro Engine
1. Identity
Depends on module:
Purpose
Consolidates electricity consumption from utility invoices, metering feeds, and/or on-site generation systems into canonical electricity series suitable for ESRS-aligned energy reporting and downstream aggregation.
This engine exists because electricity almost always has:
- distinct source systems (invoices, meters, SCADA/EMS),
- import/export/netting complexity,
- and assurance expectations higher than other carriers.
Typical usage
- Purchased electricity total (MWh)
- Self-generated electricity (MWh)
- Exported electricity (MWh)
- Net electricity used on-site (MWh)
- Input to
MEID_CALC_ENERGY_AGGR(as the authoritative electricity stream)
2. Contract References (ZAR)
2.1 Input Schema
ZAR Address: schema.compute.energy.electricity.inputs.v1_0_0
Required conceptual fields (v1 minimal):
records: list of electricity recordsalignment:BY_YEAR|BY_INDEX(defaultBY_YEAR)
Each record conceptually includes:
period(typically year; may be month if later supported)valueunit(e.g.kWh,MWh)record_type:INVOICE|METER|GENERATION|EXPORT- optional:
meter_idinvoice_idsite_idgrid_regiondirection:IMPORT|EXPORT(if record_type is meter-based)
Optional structured fields (preferred when available):
purchased_electricity: scalar or time-seriesself_generated_electricity: scalar or time-seriesexported_electricity: scalar or time-series
If the structured fields are provided,
recordsmay be omitted.
2.2 Options Schema
ZAR Address: schema.compute.energy.electricity.options.v1_0_0
Common options:
unit_output: defaultMWhsource_priority: ordered list (default["INVOICE","METER","GENERATION"])netting_policy:NO_NETTING|NET_IMPORT_EXPORT(defaultNET_IMPORT_EXPORT)duplicate_policy:ALLOW|DEDUPE_BY_ID|ERROR(defaultDEDUPE_BY_ID)missing_policy:ERROR|SKIPnegative_values_policy:ERROR|ALLOW_WITH_FLAGrounding: optional digits
2.3 Output Schema
ZAR Address: schema.compute.energy.electricity.output.v1_0_0
Outputs include:
E_purchased(t)E_self_generated(t)E_exported(t)E_net(t)metadata(source selection, dedupe actions, netting, unit conversions, coverage)
3. Accepted Input Shapes
A. Invoice-based records (most common)
{
"records": [
{ "record_type": "INVOICE", "invoice_id": "INV-001", "period": 2025, "value": 12000000, "unit": "kWh" },
{ "record_type": "INVOICE", "invoice_id": "INV-002", "period": 2026, "value": 11800000, "unit": "kWh" }
],
"alignment": "BY_YEAR"
}
B. Meter import/export with netting
{
"records": [
{ "record_type": "METER", "meter_id": "M-11", "direction": "IMPORT", "period": 2025, "value": 12500, "unit": "MWh" },
{ "record_type": "METER", "meter_id": "M-11", "direction": "EXPORT", "period": 2025, "value": 500, "unit": "MWh" }
],
"netting_policy": "NET_IMPORT_EXPORT"
}
C. Structured series (preferred if already consolidated upstream)
{
"purchased_electricity": [[2025, 12000], [2026, 11800]],
"self_generated_electricity": [[2025, 800], [2026, 900]],
"exported_electricity": [[2025, 100], [2026, 120]],
"unit_output": "MWh",
"alignment": "BY_YEAR"
}
All supported shapes MUST be normalized internally to:
Map<period, { purchased_MWh, self_generated_MWh, exported_MWh }>
4. Compute Semantics (Normative)
Let:
- be purchased electricity in period
- be self-generated electricity in period
- be exported electricity in period
4.1. Unit normalization
All values MUST be converted to unit_output (default MWh).
4.2. Source selection
If multiple sources overlap for the same period:
- prefer the first available source in
source_priority - record which source won per period in metadata
4.3. Purchased electricity
If structured purchased_electricity provided:
Else if invoice records exist for period :
Else if meter import exists:
4.4. Self-generated electricity
If structured self_generated_electricity provided:
Else if generation records exist:
4.5. Exported electricity
If structured exported_electricity provided:
Else if meter export exists:
4.6. Net electricity (site use)
If netting_policy = NET_IMPORT_EXPORT:
If netting_policy = NO_NETTING:
Export is reported separately either way; netting only affects the “net used” output series.
5. Validation & Error Model
Invariants
- Values must be finite
- Units must be convertible
- Duplicate invoices/meters must be handled per duplicate_policy
- Negative values default to error
Error codes (suggested)
ENERGY_ELEC_MISSING_INPUTENERGY_ELEC_UNIT_CONVERSION_FAILEDENERGY_ELEC_DUPLICATE_RECORD_ERRORENERGY_ELEC_NON_FINITE_VALUEENERGY_ELEC_ALIGNMENT_MISMATCH
Errors MUST include:
- engine
cmi_short_code - record identifier (
invoice_id/meter_id) and period
6. Dependencies
MEID_CALC_ENERGY_ELEC depends on:
- schema resolver (ZAR)
- unit conversion utilities
- optional invoice parsing/normalization utilities (upstream)
- optional meter feed normalization utilities (upstream)
Declared via ZAR dependencies.
7. Federation & Audit Requirements
To reproduce electricity consolidation externally, the export MUST include:
- engine identity (
cmiorzar_code) - engine build proof (
execution_ref+build_hash) - input/options/output schemas used
- raw records (invoice/meter/generation) or structured series used
source_priority,netting_policy, andduplicate_policy- unit conversion reference/version used
Provenance chain MUST show:
… → MEID_CALC_ENERGY_ELEC → …
with cmi_short_code recorded in USO tail arrays.
8. Performance Notes
- Complexity: per run
- Memory:
- Highly parallelizable by site or meter group
9. Methods Served (v1)
Energy.electricity.absEnergy.electricity.purchased.absEnergy.electricity.self_generated.absEnergy.electricity.exported.absEnergy.electricity.net.abs