diff --git a/templates/definition/devices-schema.json b/templates/definition/devices-schema.json index efedc8b1f..9f0f42d0e 100644 --- a/templates/definition/devices-schema.json +++ b/templates/definition/devices-schema.json @@ -31,6 +31,13 @@ "$ref": "#/definitions/Linked" } }, + "countries": { + "type": "array", + "items": { + "type": "string", + "pattern": "^[A-Z]{2}$" + } + }, "capabilities": { "type": "array", "items": { diff --git a/templates/definition/tariff/allinpower.yaml b/templates/definition/tariff/allinpower.yaml index 321381604..6d471c9aa 100644 --- a/templates/definition/tariff/allinpower.yaml +++ b/templates/definition/tariff/allinpower.yaml @@ -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: | diff --git a/templates/definition/tariff/amber.yaml b/templates/definition/tariff/amber.yaml index a8ea6620d..e6cac52a9 100644 --- a/templates/definition/tariff/amber.yaml +++ b/templates/definition/tariff/amber.yaml @@ -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 diff --git a/templates/definition/tariff/awattar.yaml b/templates/definition/tariff/awattar.yaml index 27c795a5e..ae4096240 100644 --- a/templates/definition/tariff/awattar.yaml +++ b/templates/definition/tariff/awattar.yaml @@ -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 diff --git a/templates/definition/tariff/elering.yaml b/templates/definition/tariff/elering.yaml index 9656c76d0..a346c7b13 100644 --- a/templates/definition/tariff/elering.yaml +++ b/templates/definition/tariff/elering.yaml @@ -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 diff --git a/templates/definition/tariff/energinet.yaml b/templates/definition/tariff/energinet.yaml index 280877aa3..15b92ac67 100644 --- a/templates/definition/tariff/energinet.yaml +++ b/templates/definition/tariff/energinet.yaml @@ -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 diff --git a/templates/definition/tariff/energy-charts-api.yaml b/templates/definition/tariff/energy-charts-api.yaml index 5b364ca03..76d8458cf 100644 --- a/templates/definition/tariff/energy-charts-api.yaml +++ b/templates/definition/tariff/energy-charts-api.yaml @@ -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 diff --git a/templates/definition/tariff/enever.yaml b/templates/definition/tariff/enever.yaml index 366bc4580..697a0099c 100644 --- a/templates/definition/tariff/enever.yaml +++ b/templates/definition/tariff/enever.yaml @@ -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 diff --git a/templates/definition/tariff/entsoe.yaml b/templates/definition/tariff/entsoe.yaml index 5a7fd4a2f..248aa12ff 100644 --- a/templates/definition/tariff/entsoe.yaml +++ b/templates/definition/tariff/entsoe.yaml @@ -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: diff --git a/templates/definition/tariff/groupe-e.yaml b/templates/definition/tariff/groupe-e.yaml index 720665626..22ffda056 100644 --- a/templates/definition/tariff/groupe-e.yaml +++ b/templates/definition/tariff/groupe-e.yaml @@ -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: | diff --git a/templates/definition/tariff/gruenstromindex.yaml b/templates/definition/tariff/gruenstromindex.yaml index 10af7b025..df0745a4d 100644 --- a/templates/definition/tariff/gruenstromindex.yaml +++ b/templates/definition/tariff/gruenstromindex.yaml @@ -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 diff --git a/templates/definition/tariff/ngeso.yaml b/templates/definition/tariff/ngeso.yaml index a63b5a17c..46171464f 100644 --- a/templates/definition/tariff/ngeso.yaml +++ b/templates/definition/tariff/ngeso.yaml @@ -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 diff --git a/templates/definition/tariff/nordpool.yaml b/templates/definition/tariff/nordpool.yaml index 7490ab331..30887443f 100644 --- a/templates/definition/tariff/nordpool.yaml +++ b/templates/definition/tariff/nordpool.yaml @@ -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 diff --git a/templates/definition/tariff/octopus-api.yaml b/templates/definition/tariff/octopus-api.yaml index c492f7b20..71eec107e 100644 --- a/templates/definition/tariff/octopus-api.yaml +++ b/templates/definition/tariff/octopus-api.yaml @@ -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 diff --git a/templates/definition/tariff/octopus-productcode.yaml b/templates/definition/tariff/octopus-productcode.yaml index bc8108610..1d5e0b041 100644 --- a/templates/definition/tariff/octopus-productcode.yaml +++ b/templates/definition/tariff/octopus-productcode.yaml @@ -4,6 +4,7 @@ products: description: generic: Product Code group: price +countries: ["GB"] params: - name: productCode type: string diff --git a/templates/definition/tariff/ostrom.yaml b/templates/definition/tariff/ostrom.yaml index 542a3093d..b573a534a 100644 --- a/templates/definition/tariff/ostrom.yaml +++ b/templates/definition/tariff/ostrom.yaml @@ -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 diff --git a/templates/definition/tariff/pun.yaml b/templates/definition/tariff/pun.yaml index 5a5ec47d8..f0683da4c 100644 --- a/templates/definition/tariff/pun.yaml +++ b/templates/definition/tariff/pun.yaml @@ -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: | diff --git a/templates/definition/tariff/smartenergy.yaml b/templates/definition/tariff/smartenergy.yaml index 6d7762eaf..c66964b05 100644 --- a/templates/definition/tariff/smartenergy.yaml +++ b/templates/definition/tariff/smartenergy.yaml @@ -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: | diff --git a/templates/definition/tariff/spottyenergy.yaml b/templates/definition/tariff/spottyenergy.yaml index b0c859600..7e4af83d0 100644 --- a/templates/definition/tariff/spottyenergy.yaml +++ b/templates/definition/tariff/spottyenergy.yaml @@ -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 diff --git a/templates/definition/tariff/tibber.yaml b/templates/definition/tariff/tibber.yaml index 77dd86de6..b33ac8046 100644 --- a/templates/definition/tariff/tibber.yaml +++ b/templates/definition/tariff/tibber.yaml @@ -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 diff --git a/util/templates/documentation.go b/util/templates/documentation.go index 63505613f..68c4e9d57 100644 --- a/util/templates/documentation.go +++ b/util/templates/documentation.go @@ -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, diff --git a/util/templates/documentation.tpl b/util/templates/documentation.tpl index b512db85d..a9a1e51b6 100644 --- a/util/templates/documentation.tpl +++ b/util/templates/documentation.tpl @@ -52,6 +52,9 @@ product: {{- if .Capabilities }} capabilities: ["{{ join "\", \"" .Capabilities }}"] {{- end }} +{{- if .Countries }} +countries: ["{{ join "\", \"" .Countries }}"] +{{- end }} {{- if .Requirements }} requirements: ["{{ join "\", \"" .Requirements }}"] {{- end }} diff --git a/util/templates/template.go b/util/templates/template.go index f5fdb61ce..c79beaca5 100644 --- a/util/templates/template.go +++ b/util/templates/template.go @@ -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) diff --git a/util/templates/types.go b/util/templates/types.go index 9b834192c..d08baa972 100644 --- a/util/templates/types.go +++ b/util/templates/types.go @@ -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"`