Add Frauenhofer ISE energy-charts-api | day ahead price (#13706)

This commit is contained in:
mdkeil 2024-05-07 18:48:24 +02:00 • committed by GitHub
parent 1ff1513c38
commit 81ba7dcc29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 56 additions and 3 deletions

View file

@ -12,10 +12,10 @@ import (
)
var (
//go:embed dist
// go:embed dist
web embed.FS
//go:embed i18n/*.toml
// go:embed i18n/*.toml
i18n embed.FS
)

View file

@ -6,8 +6,10 @@ import (
"math"
"strconv"
"strings"
"text/template"
"time"
"github.com/42atomys/sprout"
"github.com/evcc-io/evcc/provider/pipeline"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
@ -162,8 +164,18 @@ func (p *HTTP) request(url string, body ...string) ([]byte, error) {
b = strings.NewReader(body[0])
}
tmpl, err := template.New("url").Funcs(sprout.TxtFuncMap()).Parse(url)
if err != nil {
return nil, err
}
builder := new(strings.Builder)
if err := tmpl.Execute(builder, nil); err != nil {
return nil, err
}
// empty method becomes GET
req, err := request.New(strings.ToUpper(p.method), url, b, p.headers)
req, err := request.New(strings.ToUpper(p.method), builder.String(), b, p.headers)
if err != nil {
return []byte{}, err
}

View file

@ -0,0 +1,41 @@
template: energy-charts-api
products:
- brand: Fraunhofer ISE
description:
de: "Day-ahead Energiepreise (je kWh) an der Börse. Kann ohne vorherige Anmeldung auf https://api.energy-charts.info/ abgerufen werden. Nutzbar u.a. für dynamische Stromtarife, wo der Anbieter bis dato auf der Kundenschnittstelle noch kein Preis-Vorhersagen anbietet."
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."
params:
- name: bzn
type: string
required: true
validvalues:
[
"AT",
"BE",
"CH",
"CZ",
"DE-LU",
"DE-AT-LU",
"DK1",
"DK2",
"FR",
"HU",
"IT-NORTH",
"NL",
"NO2",
"PL",
"SE4",
"SI",
]
default: DE-LU
description:
de: "Gebotszonen - https://api.energy-charts.info/#/prices/day_ahead_price_price_get"
en: "Bidding zones - https://api.energy-charts.info/#/prices/day_ahead_price_price_get"
- preset: tariff-base
render: |
type: custom
{{ include "tariff-base" . }}
forecast:
source: http
uri: https://api.energy-charts.info/price?bzn={{ .bzn }}&end={{ now | dateModify "+24h" | date "2006-01-02" }}
jq: '[.unix_seconds, .price] | transpose | map({ "start": (.[0] | todate), "end": ((.[0]+3600) | todate), "price": (.[1]/1000)}) | tostring'