From 7866b4a34c907208b5c382a1b5a12b308f58c8d3 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 29 Jun 2026 22:55:40 +0000 Subject: [PATCH] =?UTF-8?q?Translate=20full-SAP=2018-hour=20off-peak=20tar?= =?UTF-8?q?iff=20(code=205)=20to=20EIGHTEEN=5FHOUR=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add code 5 → "off-peak 18 hour" to _SAP_TARIFF_TO_RDSAP_METER_TYPE so the full-SAP meter translation covers the whole energy_tariff code space, not just 1-4. Table 12a resolves the word alias to Tariff.EIGHTEEN_HOUR. Real SAP-19.1.0/19.2.0 sample certs lodge tariff 5 and now resolve to the 18-hour off-peak split instead of defaulting to STANDARD (under/over-rated). The same fix covers 17.0/17.1/18.0.0/19.0.0 — all route through the full-SAP mapper via the assessment_type=SAP gate. Co-Authored-By: Claude Opus 4.8 (1M context) --- datatypes/epc/domain/mapper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/datatypes/epc/domain/mapper.py b/datatypes/epc/domain/mapper.py index ec27d6fcb..e89062610 100644 --- a/datatypes/epc/domain/mapper.py +++ b/datatypes/epc/domain/mapper.py @@ -2966,8 +2966,9 @@ def _sap_17_1_meter_type(electricity_tariff: Optional[int]) -> str: The two code spaces *differ* (epc_codes.csv `energy_tariff` vs `_METER_INT_TO_TARIFF`): full-SAP 1=standard / 2=off-peak-7hr / 3=off-peak- - 10hr / 4=24-hour, whereas RdSAP meter 1=dual-7hr / 2=single / 3=unknown / - 4=24-hour. Passing the full-SAP code straight through (the prior bug) read a + 10hr / 4=24-hour / 5=off-peak-18hr, whereas RdSAP meter 1=dual-7hr / + 2=single / 3=unknown / 4=24-hour. Passing the full-SAP code straight + through (the prior bug) read a standard-tariff cert as Economy 7 (over-rated) and an Economy-7 cert as single (under-rated). Map onto the RdSAP word aliases so the resolved tariff is correct; absent/ND → "" (the unknown→standard sentinel).""" @@ -2985,6 +2986,7 @@ _SAP_TARIFF_TO_RDSAP_METER_TYPE: dict[int, str] = { 2: "dual", # off-peak 7 hour (Economy 7) 3: "dual", # off-peak 10 hour (§12 dispatch resolves 7/10hr) 4: "dual (24 hour)", # 24-hour tariff + 5: "off-peak 18 hour", # off-peak 18 hour (Table 12a EIGHTEEN_HOUR) }