From 5e69a6226da49d9c6eeef7d2b190023e2f93dec6 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 7 Aug 2026 17:47:30 +0200 Subject: [PATCH] pvnode: resample interval averages to power at slot start (#32604) --- templates/definition/tariff/pvnode-v2.yaml | 18 +++++++++++------- templates/definition/tariff/pvnode.yaml | 18 +++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/templates/definition/tariff/pvnode-v2.yaml b/templates/definition/tariff/pvnode-v2.yaml index 89a417064..34ea67906 100644 --- a/templates/definition/tariff/pvnode-v2.yaml +++ b/templates/definition/tariff/pvnode-v2.yaml @@ -50,11 +50,15 @@ render: | type: bearer token: {{ .apikey }} jq: | - [.values[] | - { - start: (.timestamp), - end: (.timestamp | fromdateiso8601 + 900 | todateiso8601 ), - value: (.pv_power | round ) - } - ] | tostring + # values are the average power of the 15min interval ending at the timestamp. + # evcc expects the power at the timestamp, which is the mean of the intervals + # meeting there- the trailing interval is dropped as its successor is unknown. + [.values[] | {t: (.timestamp | fromdateiso8601), v: .pv_power}] as $s + | [ range(0; ($s|length)-1) | + { + start: ($s[.].t | todateiso8601), + end: ($s[.].t + 900 | todateiso8601), + value: ((($s[.].v + $s[.+1].v) / 2) | round) + } + ] | tostring interval: {{ .interval }} diff --git a/templates/definition/tariff/pvnode.yaml b/templates/definition/tariff/pvnode.yaml index 4d7e81518..62c51997f 100644 --- a/templates/definition/tariff/pvnode.yaml +++ b/templates/definition/tariff/pvnode.yaml @@ -54,11 +54,15 @@ render: | type: bearer token: {{ .apikey }} jq: | - [.values[] | - { - start: (.dtm | sub(" "; "T") + "Z"), - end: (.dtm | sub(" "; "T") + "Z" | fromdateiso8601 + 900 | todateiso8601 ), - value: (.pv_watts | round ) - } - ] | tostring + # values are the average power of the 15min interval ending at the timestamp. + # evcc expects the power at the timestamp, which is the mean of the intervals + # meeting there- the trailing interval is dropped as its successor is unknown. + [.values[] | {t: (.dtm | sub(" "; "T") + "Z" | fromdateiso8601), v: .pv_watts}] as $s + | [ range(0; ($s|length)-1) | + { + start: ($s[.].t | todateiso8601), + end: ($s[.].t + 900 | todateiso8601), + value: ((($s[.].v + $s[.+1].v) / 2) | round) + } + ] | tostring interval: {{ .interval }}