Source code for energy_data_retrieval.bess_catalogue.pmg
"""Offline staging of the 7 October 2026 NW5130 parliamentary reply via PMG."""
from decimal import Decimal
from energy_data_retrieval.bess_oem_catalogue.bsb import _Table
EXPECTED = (
"Oya Energy Hybrid Facility",
"Umoyilanga Energy - Avondale1",
"Mulilo Total Hydra Storage",
"Mogobe BESS",
"Oasis Mookodi",
"Oasis Aggeneis",
"Oasis Nieuwehoop",
"Red Sand BESS",
"Mulilo Mercury BESS",
"Hartebeesfontein BESS",
"Oasis Ararat",
"Gianfar BESS",
"Boitekong BESS",
"Welverdiend BESS",
"Leeuwpoort BESS",
"Rooikoppies BESS",
"Haru BESS",
"Erfdeel BESS",
"Retreat BESS",
"Bloemhoek BESS",
"Vanilla BESS",
)
[docs]
def stage_reply(html: str) -> list[dict]:
"""Keep contracted MW, hybrid scope and native forecasts; never assign COD."""
if "07 October 2026" not in html or "NW5130" not in html or "June 2026" not in html:
raise ValueError("Unreviewed reply/date")
parser = _Table()
parser.feed(html)
result = []
stage = None
for number, row in enumerate(parser.rows, 1):
if row[0] == "Programme":
if len(row) != 6 or row[2:4] != ["Project", "Technology"]:
raise ValueError("Changed header")
if row[4:] == ["Contracted Capacity (MW) in construction", "Expected COD"]:
stage = "under_construction"
elif row[4:] == ["Capacity (MW) preparing to close", "Estimated COD"]:
stage = "preparing_financial_close"
else:
raise ValueError("Changed capacity/date units")
continue
if len(row) != 6 or not row[0]:
continue
if row[3] not in {"BESS", "PV+BESS", "PV+OW+BESS", "PV", "OW"}:
raise ValueError("Unreviewed technology")
if "BESS" not in row[3]:
continue
value = Decimal(row[4])
if stage is None or not value.is_finite() or value <= 0:
raise ValueError("Invalid stage/capacity")
result.append(
dict(
name=row[2],
programme=row[0],
bid_window_native=row[1],
technology=row[3],
contracted_capacity_mw=float(value),
capacity_boundary="contracted project output; not installed battery nameplate",
stage=stage,
forecast_cod_native=row[5],
reporting_date="2026-06-30",
html_table_row=number,
)
)
if tuple(r["name"] for r in result) != EXPECTED:
raise ValueError("Missing, duplicate or changed named battery rows")
return result