Templates: add countries for tariffs (#18609)

This commit is contained in:
Michael Geers 2025-02-08 14:55:37 +01:00 • committed by GitHub
parent f83da9376f
commit cd5a253d0b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 50 additions and 40 deletions

View file

@ -31,6 +31,13 @@
"$ref": "#/definitions/Linked"
}
},
"countries": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Z]{2}$"
}
},
"capabilities": {
"type": "array",
"items": {

View file

@ -4,10 +4,8 @@ products:
- brand: All in Power
requirements:
evcc: ["skiptest"]
description:
de: "Nur für die Niederlande verfügbar."
en: "Only available for the Netherlands."
group: price
countries: ["NL"]
params:
- preset: tariff-base
render: |

View file

@ -1,11 +1,8 @@
template: amber
products:
- brand: Amber Electric
requirements:
description:
de: "Nur für Australien verfügbar."
en: "Only available for Australia."
group: price
countries: ["AU"]
params:
- name: token
- name: siteid

View file

@ -1,11 +1,8 @@
template: awattar
products:
- brand: Awattar
requirements:
description:
de: "Nur für Deutschland und Österreich verfügbar."
en: "Only available for Germany and Austria."
group: price
countries: ["DE", "AT"]
params:
- name: region
example: AT

View file

@ -4,11 +4,8 @@ products:
- brand: Nordpool
description:
generic: "Elering"
requirements:
description:
de: "Nur für Estland verfügbar."
en: "Only available for Estonia."
group: price
countries: ["EE", "LT", "LV", "FI"]
params:
- name: region
example: ee

View file

@ -2,11 +2,9 @@ template: energinet
products:
- brand: Energinet
requirements:
description:
de: "Nur für Dänemark verfügbar."
en: "Only available for Denmark."
evcc: ["skiptest"]
group: price
countries: ["DK"]
params:
- name: region
example: dk1

View file

@ -7,6 +7,7 @@ requirements:
en: "Day-ahead forecast of energy prices (per kWh) on the exchange. No prior registration for https://api.energy-charts.info/ necessary. Can be used for dynamic electricity tariffs, for example, where the supplier does not yet offer a price forecast on the customer interface."
evcc: ["skiptest"]
group: price
countries: ["EU"]
params:
- name: bzn
type: choice

View file

@ -2,11 +2,9 @@ template: enever
products:
- brand: Enever
requirements:
description:
de: Nur für Niederlande verfügbar.
en: Only available for Netherlands.
evcc: ["skiptest"]
group: price
countries: ["NL"]
params:
- name: token
required: true

View file

@ -10,6 +10,7 @@ requirements:
Day-ahead prices for the European electricity market. See https://transparency.entsoe.eu for more information.
Basis for many dynamic tariffs.
group: price
countries: ["EU"]
params:
- name: securitytoken
help:

View file

@ -4,11 +4,9 @@ products:
description:
generic: Vario Plus
requirements:
description:
de: "Nur für die Schweiz verfügbar."
en: "Only available for Switzerland."
evcc: ["skiptest"]
group: price
countries: ["CH"]
params:
- preset: tariff-base
render: |

View file

@ -3,10 +3,11 @@ products:
- brand: Grünstromindex
requirements:
description:
de: "Regionale Emissionsdaten von https://gruenstromindex.de. Nur für Deutschland verfügbar."
en: "Regional emission data from https://gruenstromindex.de. Only available for Germany."
de: "Regionale Emissionsdaten von https://gruenstromindex.de"
en: "Regional emission data from https://gruenstromindex.de"
evcc: ["skiptest"]
group: co2
countries: ["DE"]
params:
- name: zip
required: true

View file

@ -1,11 +1,8 @@
template: ngeso
products:
- brand: National Grid ESO
requirements:
description:
de: "Nur für Großbritannien verfügbar."
en: "Only available for the United Kingdom."
group: co2
countries: ["GB"]
params:
- name: region
type: string

View file

@ -7,6 +7,7 @@ requirements:
en: "Nordpool spot prices in day-ahead market for all markets in the Nordpool region."
evcc: ["skiptest"]
group: price
countries: ["EU"]
params:
- name: region
example: GER

View file

@ -7,6 +7,7 @@ requirements:
description:
de: "Den API-Key bekommst du im Octopus Portal https://octopus.energy/dashboard/new/accounts/personal-details/api-access"
en: "You can get the API key in the Octopus portal https://octopus.energy/dashboard/new/accounts/personal-details/api-access"
countries: ["GB"]
group: price
params:
- name: apiKey

View file

@ -4,6 +4,7 @@ products:
description:
generic: Product Code
group: price
countries: ["GB"]
params:
- name: productCode
type: string

View file

@ -7,6 +7,7 @@ requirements:
de: "Erzeuge einen 'Production Client' im Ostrom-Entwicklerportal: https://developer.ostrom-api.io/"
evcc: ["skiptest"]
group: price
countries: ["DE"]
params:
- name: clientid
example: 476c477d8a039529478ebd690d35ddd80e3308ffc49b59c65b142321aee963a4

View file

@ -4,9 +4,10 @@ products:
requirements:
evcc: ["skiptest"]
description:
de: "Preisdaten von https://www.mercatoelettrico.org/it/. Wird oft zur Einspeisung ins Netz verwendet. Nur für Italien verfügbar."
en: "Price data from https://www.mercatoelettrico.org/it/. Often used for feeding into the grid. Only available for Italy."
de: "Preisdaten von https://www.mercatoelettrico.org/it/. Wird oft zur Einspeisung ins Netz verwendet."
en: "Price data from https://www.mercatoelettrico.org/it/. Often used for feeding into the grid."
group: price
countries: ["IT"]
params:
- preset: tariff-base
render: |

View file

@ -3,11 +3,8 @@ products:
- brand: SmartEnergy
description:
generic: smartCONTROL
requirements:
description:
de: Nur für Österreich verfügbar.
en: Only available for Austria.
group: price
countries: ["AT"]
params:
- preset: tariff-base
render: |

View file

@ -1,11 +1,8 @@
template: spottyenergy
products:
- brand: Spotty Energie
requirements:
description:
de: "Nur für Österreich verfügbar."
en: "Only available for Austria."
group: price
countries: ["AT"]
params:
- name: contractid
example: ffffffff-4444-6666-2222-aaaaaabbbbbb

View file

@ -7,6 +7,7 @@ requirements:
de: "Hol dir deinen API-Token aus dem Tibber-Entwicklerportal: https://developer.tibber.com/"
evcc: ["skiptest"]
group: price
countries: ["NO", "SE", "DE", "NL"]
params:
- name: token
example: 476c477d8a039529478ebd690d35ddd80e3308ffc49b59c65b142321aee963a4

View file

@ -95,6 +95,7 @@ func (t *Template) RenderDocumentation(product Product, lang string) ([]byte, er
"ProductDescription": product.Description.String(lang),
"ProductGroup": t.GroupTitle(lang),
"Capabilities": t.Capabilities,
"Countries": t.Countries,
"Requirements": t.Requirements.EVCC,
"RequirementDescription": t.Requirements.Description.String(lang),
"Params": filteredParams,

View file

@ -52,6 +52,9 @@ product:
{{- if .Capabilities }}
capabilities: ["{{ join "\", \"" .Capabilities }}"]
{{- end }}
{{- if .Countries }}
countries: ["{{ join "\", \"" .Countries }}"]
{{- end }}
{{- if .Requirements }}
requirements: ["{{ join "\", \"" .Requirements }}"]
{{- end }}

View file

@ -45,6 +45,12 @@ func (t *Template) Validate() error {
}
}
for _, c := range t.Countries {
if !c.IsValid() {
return fmt.Errorf("invalid country code '%s' in template %s", c, t.Template)
}
}
for _, r := range t.Requirements.EVCC {
if !slices.Contains(ValidRequirements, r) {
return fmt.Errorf("invalid requirement '%s' in template %s", r, t.Template)

View file

@ -4,6 +4,7 @@ import (
"bufio"
"encoding/json"
"fmt"
"regexp"
"strings"
"dario.cat/mergo"
@ -252,6 +253,14 @@ func (p Product) Title(lang string) string {
return strings.TrimSpace(fmt.Sprintf("%s %s", p.Brand, p.Description.String(lang)))
}
type CountryCode string
func (c CountryCode) IsValid() bool {
// ensure ISO 3166-1 alpha-2 format
var validCode = regexp.MustCompile(`^[A-Z]{2}$`)
return validCode.MatchString(string(c))
}
// TemplateDefinition contains properties of a device template
type TemplateDefinition struct {
Template string
@ -260,6 +269,7 @@ type TemplateDefinition struct {
Covers []string `json:",omitempty"` // list of covered outdated template names
Products []Product `json:",omitempty"` // list of products this template is compatible with
Capabilities []string `json:",omitempty"`
Countries []CountryCode `json:",omitempty"` // list of countries supported by this template
Requirements Requirements `json:",omitempty"`
Linked []LinkedTemplate `json:",omitempty"` // a list of templates that should be processed as part of the guided setup
Params []Param `json:",omitempty"`