From 59c49e7ce12c3dbac770bf5be419047ba753f5b9 Mon Sep 17 00:00:00 2001 From: Mathias Walter Date: Fri, 3 Apr 2026 14:47:52 +0200 Subject: [PATCH] Solarprognose.de: fix gaps and undeprecate (#28642) --- .../definition/tariff/solarprognose.yaml | 52 +++++++++++++++---- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/templates/definition/tariff/solarprognose.yaml b/templates/definition/tariff/solarprognose.yaml index f5d171d95..00103c9eb 100644 --- a/templates/definition/tariff/solarprognose.yaml +++ b/templates/definition/tariff/solarprognose.yaml @@ -1,5 +1,4 @@ template: solarprognose -deprecated: true products: - brand: Solarprognose requirements: @@ -13,7 +12,7 @@ params: description: en: Access Token from User Profile de: Zugriffs-Schlüssel aus Benutzer-Profil - advanced: true + required: true - name: item choice: ["location", "plant", "inverter", "module_field"] description: @@ -39,20 +38,55 @@ params: en: Forecasting Algorithm (mosmix, own-v1 or clearsky) de: Prognosealgorithmus (mosmix, own-v1 oder clearsky) advanced: true + - name: forecast_days + description: + en: Number of additional days to forecast (1-6) + de: Anzahl zusätzlicher Tage für die Prognose (1-6) + help: + en: "Number of additional days to forecast (1-6), excluding today. Remember: evcc calculates energy for today, tomorrow, and the day after tomorrow, effectively handling up to three days of solar forecast data, but the UI shows up to 96 hours." + de: "Anzahl der zusätzlichen Tage für die Prognose (1-6), ohne den heutigen Tag. Bedenke: evcc berechnet die Energie für heute, morgen und übermorgen und verarbeitet dabei effektiv bis zu drei Tage Solarprognosedaten, zeigt jedoch bis zu 96 Stunden an." + default: 4 + advanced: true - name: interval default: 1h advanced: true render: | type: custom tariff: solar + features: ["cacheable"] forecast: source: http - # Base URL with required params (format, type, algorithm, access token), then optional item-based parameters - uri: https://www.solarprognose.de/web/solarprediction/api/v1?_format=json&type=hourly{{ if .algorithm }}&algorithm={{ .algorithm }}{{ end }}&access-token={{ .token }}{{ if .item }}&item={{ .item }}{{ if .id }}&id={{ .id }}{{ else }}&token={{ unquote .uniquetoken }}{{ end }}{{ end }} + # Base URL with required params (format, type, access token), then optional item-based parameters + uri: https://www.solarprognose.de/web/solarprediction/api/v1?_format=json&type=hourly&project=https://evcc.io&access-token={{ .token }}{{ if .item }}&item={{ .item }}{{ if .id }}&id={{ .id }}{{ else }}&token={{ unquote .uniquetoken }}{{ end }}{{ end }}{{ if .algorithm }}&algorithm={{ .algorithm }}{{ end }}{{ if .forecast_days }}&end_day={{ .forecast_days }}{{ end }} jq: | - [ .data | to_entries.[] | { - "start": (.key | tonumber | strftime("%FT%TZ") ), - "end": (.key | tonumber + 3600 | strftime("%FT%TZ") ) , - "value": (.value.[0]*1000) # returned value unit is always kW - } ] | tostring + def step: 3600; # hourly interval + + def lookup: + (.data // {}) + | if type == "object" and length > 0 then + to_entries + | map({key, value: (.value[0] * 1000)}) + | from_entries + else + {} + end; + + . as $root + | ($root | lookup) as $L + | ($L | keys | map(tonumber) | sort) as $ts + | ($ts[0]) as $min + | ($ts[-1]) as $max + | reduce range($min; $max + step; step) as $t + ( { last: null, out: [] }; + ($L[($t|tostring)]?) as $v + | .last = (if $v == null then .last else $v end) + | .out += + [ { + start: ($t | strftime("%FT%TZ")), + end: (($t + step) | strftime("%FT%TZ")), + value: (.last // 0) + } ] + ) + | .out + | tostring interval: {{ .interval }}