diff --git a/templates/definition/tariff/forecast-solar.yaml b/templates/definition/tariff/forecast-solar.yaml index f7e6ccac4..27bfb2ad9 100644 --- a/templates/definition/tariff/forecast-solar.yaml +++ b/templates/definition/tariff/forecast-solar.yaml @@ -66,7 +66,7 @@ render: | tariff: solar forecast: source: http - uri: https://api.forecast.solar/{{ if .apikey }}{{ .apikey }}/{{ end }}estimate/{{ .lat }}/{{ .lon }}/{{ .dec }}/{{ .az }}/{{ .kwp }}?time=utc&full=1&resolution=60{{ if .horizon }}&horizon={{ .horizon }}{{ end }} + uri: https://api.forecast.solar/{{ if .apikey }}{{ .apikey }}/{{ end }}estimate/{{ .lat }}/{{ .lon }}/{{ .dec }}/{{ .az }}/{{ .kwp }}?time=utc&full=1&resolution=60{{ if .horizon }}&horizon={{ unquote .horizon }}{{ end }} jq: | [ .result.watts | to_entries.[] | { "start": (.key | strptime("%FT%T%z") | strftime("%FT%TZ")), diff --git a/util/templates/utils.go b/util/templates/utils.go index b63660806..b95bb555e 100644 --- a/util/templates/utils.go +++ b/util/templates/utils.go @@ -44,6 +44,10 @@ func trimLines(s string) string { return strings.Join(lines, "\n") } +func unquote(s string) string { + return strings.Trim(s, `"'`) +} + // FuncMap returns a sprig template.FuncMap with additional include function func FuncMap(tmpl *template.Template) *template.Template { funcMap := template.FuncMap{ @@ -57,6 +61,7 @@ func FuncMap(tmpl *template.Template) *template.Template { return buf.String(), nil }, "urlEncode": url.QueryEscape, + "unquote": unquote, } return tmpl.Funcs(sprig.FuncMap()).Funcs(funcMap)