Add Nordpool tariff api (#17628)

This commit is contained in:
andig 2024-12-07 14:28:32 +01:00 • committed by GitHub
parent 0f5ad83750
commit 93210dd021
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 84 additions and 0 deletions

View file

@ -0,0 +1,79 @@
template: nordpool
products:
- brand: Nordpool spot prices
requirements:
description:
de: "Nordpool Spot Preise im Day-Ahead-Markt für alle Märkte in der Nordpool-Region."
en: "Nordpool spot prices in day-ahead market for all markets in the Nordpool region."
evcc: ["skiptest"]
group: price
params:
- name: region
example: GER
validvalues:
[
"EE",
"LT",
"LV",
"AT",
"BE",
"FR",
"GER",
"NL",
"PL",
"DK1",
"DK2",
"FI",
"NO1",
"NO2",
"NO3",
"NO4",
"NO5",
"SE1",
"SE2",
"SE3",
"SE4",
"TEL",
"SYS",
]
- name: currency
default: EUR
validvalues: ["DKK", "EUR", "NOK", "PLN", "RON", "SEK"]
- preset: tariff-base
render: |
type: custom
forecast:
source: go
script: |
// concat today and tomorrow
"[" + strings.Trim(strings.Trim(today, "[]") + "," + strings.Trim(tomorrow, "[]"), ",") + "]"
in:
- name: today
type: string
config:
source: http
uri: https://dataportal-api.nordpoolgroup.com/api/DayAheadPrices?market=DayAhead&date={{ `{{ now.Local | date "2006-01-02" }}` }}&deliveryArea={{ .region }}&currency={{ .currency }}
jq: |
.multiAreaEntries | [
.[] |
{
"start": .deliveryStart,
"end": .deliveryEnd,
"price": .entryPerArea.{{ .region }}
}
] | tostring
- name: tomorrow
type: string
config:
source: http
uri: https://dataportal-api.nordpoolgroup.com/api/DayAheadPrices?market=DayAhead&date={{ `{{ addDate (now.Local) 0 0 1 | date "2006-01-02" }}` }}&deliveryArea={{ .region }}&currency={{ .currency }}
jq: |
.multiAreaEntries | [
.[] |
{
"start": .deliveryStart,
"end": .deliveryEnd,
"price": .entryPerArea.{{ .region }}
}
] | tostring
{{ include "tariff-base" . }}

View file

@ -53,6 +53,7 @@ func ReplaceFormatted(s string, kv map[string]interface{}) (string, error) {
Funcs(sprig.TxtFuncMap()).
Funcs(map[string]any{
"timeRound": timeRound,
"addDate": addDate,
}).Parse(s)
if err != nil {
return s, err

View file

@ -12,3 +12,7 @@ func timeRound(d time.Duration, round string) time.Duration {
return d
}
}
func addDate(ts time.Time, y, m, d int) time.Time {
return ts.AddDate(y, m, d)
}