Skip to content

Commit f2d87f5

Browse files
Easenspringfall2008claude
authored
feat(whatif): edf tariffs (#4406)
* feat: edf tariffs for import and export * fix: base line tariff not be supplied with a dno_region * fix: use static rates as edf empower fixed only has 1 month from 2025 * test(web-annual): use an export rate the catalogue does not claim The unmatched-tariff case renders a flat export rate that matches no EXPORT_TARIFFS entry, to check it falls back to "flat Np" rather than blanking. It used 15.0p, which this branch's new EDF Export entry now claims, so the renderer correctly named it and the fallback assertion failed. Move the fixture to 21.5p, which no catalogue entry uses, and say so in a comment. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Trefor Southwell <tdlj@tdlj.net> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 72b1603 commit f2d87f5

4 files changed

Lines changed: 26 additions & 4 deletions

File tree

‎apps/predbat/tariff_catalogue.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
# export entry below to a distinct export code; that product does not exist and 404s.
7575
_INTELLI_FLUX = "{}/INTELLI-FLUX-IMPORT-23-07-14/electricity-tariffs/E-1R-INTELLI-FLUX-IMPORT-23-07-14-{{dno_region}}/standard-unit-rates/".format(_OCTOPUS)
7676

77+
# EDF Kraken API base URL for EDF tariffs
78+
_EDF = "https://api.edfgb-kraken.energy/v1/products"
79+
80+
7781
# Import and export are chosen independently, so they are listed independently. They used
7882
# to be one list of pre-paired combinations, which could not express a pairing nobody had
7983
# thought to enumerate - and, because the pairs were matched back to the dropdown on their
@@ -93,6 +97,17 @@
9397
{"id": "snug", "name": "Octopus Snug", "import_octopus_url": "{}/SNUG-24-11-07/electricity-tariffs/E-1R-SNUG-24-11-07-{{dno_region}}/standard-unit-rates/".format(_OCTOPUS)},
9498
{"id": "flux", "name": "Octopus Flux", "import_octopus_url": "{}/FLUX-IMPORT-23-02-14/electricity-tariffs/E-1R-FLUX-IMPORT-23-02-14-{{dno_region}}/standard-unit-rates".format(_OCTOPUS)},
9599
{"id": "intelligent_flux", "name": "Octopus Intelligent Flux", "import_octopus_url": _INTELLI_FLUX},
100+
{"id": "edf_go", "name": "EDF Go Electric", "import_octopus_url": "{}/EDF_EV_FIX_GOELEC_12M_HH/electricity-tariffs/E-1R-EDF_EV_FIX_GOELEC_12M_HH-{{dno_region}}/standard-unit-rates/".format(_EDF)},
101+
{
102+
"id": "edf_empower_fixed",
103+
"name": "EDF Empower Fixed",
104+
"rates_import": [
105+
{"rate": 10, "start": "00:00:00", "end": "03:00:00"},
106+
{"rate": 20, "start": "03:00:00", "end": "16:00:00"},
107+
{"rate": 30, "start": "16:00:00", "end": "19:00:00"},
108+
{"rate": 20, "start": "19:00:00", "end": "00:00:00"},
109+
],
110+
},
96111
]
97112

98113
EXPORT_TARIFFS = [
@@ -104,6 +119,8 @@
104119
{"id": "flux_export", "name": "Octopus Flux export", "export_octopus_url": "{}/FLUX-EXPORT-23-02-14/electricity-tariffs/E-1R-FLUX-EXPORT-23-02-14-{{dno_region}}/standard-unit-rates".format(_OCTOPUS)},
105120
{"id": "intelligent_flux_export", "name": "Octopus Intelligent Flux export", "export_octopus_url": _INTELLI_FLUX},
106121
{"id": "eon_next_export", "name": "Eon Next export (16.5p)", "rates_export": [{"rate": 16.5}]},
122+
{"id": "edf_export", "name": "EDF Export (15p)", "rates_export": [{"rate": 15.0}]},
123+
{"id": "edf_export_exclusive", "name": "EDF Export Exclusive (18p)", "rates_export": [{"rate": 18.0}]},
107124
]
108125

109126

‎apps/predbat/tests/test_tariff_catalogue.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ def test_tariff_catalogue(my_predbat):
6565
failed = True
6666

6767
print("Test: the built-in catalogues contain exactly the expected ids")
68-
expected_import = ["price_cap", "eon_next_drive", "agile", "intelligent_go", "go", "cosy", "snug", "flux", "intelligent_flux"]
68+
expected_import = ["price_cap", "eon_next_drive", "agile", "intelligent_go", "go", "cosy", "snug", "flux", "intelligent_flux", "edf_go", "edf_empower_fixed"]
6969
actual_import = [entry["id"] for entry in IMPORT_TARIFFS]
7070
if actual_import != expected_import:
7171
print(" ERROR: import ids changed, expected {} got {}".format(expected_import, actual_import))
7272
failed = True
73-
expected_export = [NO_EXPORT_ID, "seg", "outgoing_fixed", "outgoing_prime", "agile_outgoing", "flux_export", "intelligent_flux_export", "eon_next_export"]
73+
expected_export = [NO_EXPORT_ID, "seg", "outgoing_fixed", "outgoing_prime", "agile_outgoing", "flux_export", "intelligent_flux_export", "eon_next_export", "edf_export", "edf_export_exclusive"]
7474
actual_export = [entry["id"] for entry in EXPORT_TARIFFS]
7575
if actual_export != expected_export:
7676
print(" ERROR: export ids changed, expected {} got {}".format(expected_export, actual_export))

‎apps/predbat/tests/test_web_annual.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,12 +2030,15 @@ def catalogue_entry(entries, entry_id):
20302030
print("Test: a tariff that matches no catalogue entry falls back to something readable, not a blank")
20312031
# A hand-entered URL, or a compare_list entry the user has since deleted. The
20322032
# product code is the part of a 130-character URL anyone recognises.
2033+
# The export rate has to be one no EXPORT_TARIFFS entry uses, or it matches the
2034+
# catalogue and is named rather than falling back - 15.0p stopped being unmatched
2035+
# once EDF Export was added, which is what this rate is dodging.
20332036
odd = [
20342037
{
20352038
"id": "odd",
20362039
"label": "System Delta",
20372040
"summary": {
2038-
"tariff": {"import_octopus_url": "https://api.octopus.energy/v1/products/MY-OWN-DEAL-24/electricity-tariffs/x/", "rates_export": [{"rate": 15.0}]},
2041+
"tariff": {"import_octopus_url": "https://api.octopus.energy/v1/products/MY-OWN-DEAL-24/electricity-tariffs/x/", "rates_export": [{"rate": 21.5}]},
20392042
"baseline_tariff": {},
20402043
"payback_years": {},
20412044
},
@@ -2045,7 +2048,7 @@ def catalogue_entry(entries, entry_id):
20452048
if "MY-OWN-DEAL-24" not in odd_table:
20462049
print(" ERROR: an unmatched import URL should fall back to its product code, got {}".format(odd_table))
20472050
failed = True
2048-
if "flat 15.0p" not in odd_table:
2051+
if "flat 21.5p" not in odd_table:
20492052
print(" ERROR: an unmatched export rate should be described rather than blanked, got {}".format(odd_table))
20502053
failed = True
20512054

‎apps/predbat/web_annual.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ def numeric(name, default=None):
763763
baseline.update({key: copy.deepcopy(export_entry[key]) for key in ["export_octopus_url", "rates_export"] if export_entry.get(key)})
764764
break
765765
config["baseline_tariff"] = baseline
766+
if value("tariff_dno_region"):
767+
config["baseline_tariff"]["dno_region"] = value("tariff_dno_region")
766768
break
767769

768770
if value("year"):

0 commit comments

Comments
 (0)