Forecast.Solar: fix horizon quoting
This commit is contained in:
parent
598a105f64
commit
b4db9e8e04
2 changed files with 6 additions and 1 deletions
|
|
@ -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")),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue