- {{ range $index, $thiscode := $codes }}
- {{ $code := .Int "" }}
-
- {{ $wtype := "" }}
- {{ $wicon := "" }}
- {{ $wcolor := "" }}
- {{ if eq $code 0 }}
- {{ $wtype = "Clear" }}
- {{ $wicon = "fas fa-sun" }}
- {{ $wcolor = $color_clear }}
- {{ else if or (eq $code 1) (eq $code 2) }}
- {{ $wtype = "Part Clear" }}
- {{ $wicon = "fas fa-cloud-sun" }}
- {{ $wcolor = $color_partly }}
- {{ else if eq $code 3 }}
- {{ $wtype = "Cloudy" }}
- {{ $wicon = "fas fa-cloud" }}
- {{ $wcolor = $color_cloud }}
- {{ else if or (eq $code 45) (eq $code 48) }}
- {{ $wtype = "Fog" }}
- {{ $wicon = "fas fa-smog" }}
- {{ $wcolor = $color_smog }}
- {{/* Drizzle */}}
- {{ else if or (eq $code 51) (eq $code 53) (eq $code 55) (eq $code 56) (eq $code 57) }}
- {{ $wtype = "Drizzle" }}
- {{ $wicon = "fas fa-cloud-rain" }}
- {{ $wcolor = $color_drizzle }}
- {{/* Rain */}}
- {{ else if or (eq $code 61) (eq $code 63) (eq $code 65) (eq $code 80) (eq $code 81) (eq $code 82) }}
- {{ $wtype = "Rain" }}
- {{ $wicon = "fas fa-cloud-showers-heavy" }}
- {{ $wcolor = $color_rain }}
- {{ else if or (eq $code 66) (eq $code 67) }}
- {{ $wtype = "Freezing Rain" }}
- {{ $wicon = "fas fa-snowflake" }}
- {{ $wcolor = $color_freezing_rain }}
- {{/* Snow */}}
- {{ else if or (eq $code 71) (eq $code 73) (eq $code 75) (eq $code 77) (eq $code 85) (eq $code 86) }}
- {{ $wtype = "Snow" }}
- {{ $wicon = "fas fa-snowman" }}
- {{ $wcolor = $color_snow }}
- {{/* Thunderstorm */}}
- {{ else if or (eq $code 95) (eq $code 96) (eq $code 99) }}
- {{ $wtype = "Thunderstorm" }}
- {{ $wicon = "fas fa-bolt" }}
- {{ $wcolor = $color_thunderstorm }}
- {{ else }}
- {{ $wtype = "Other" }}
- {{ $wicon = "fa-solid fa-question" }}
- {{ $wcolor = $color_other }}
- {{ end }}
-
+ title: WEATHER FORECAST
+ cache: 30m
+ url: https://api.open-meteo.com/v1/forecast?latitude=47.4979&longitude=19.0402&daily=weathercode,temperature_2m_max,temperature_2m_min&timezone=auto&forecast_days=7
+ template: |
+ {{/* ---- tweakables ---- */}}
+ {{ $overlayColor := "rgba(0,0,0,0.20)" }}
+
+ {{/* ---- find min/max for scaling ---- */}}
+ {{ $minT := 9999.0 }}
+ {{ $maxT := -9999.0 }}
+ {{ range $i, $d := .JSON.Array "daily.time" }}
+ {{ $lo := $.JSON.Float (printf "daily.temperature_2m_min.%d" $i) }}
+ {{ $hi := $.JSON.Float (printf "daily.temperature_2m_max.%d" $i) }}
+ {{ if lt $lo $minT }}{{ $minT = $lo }}{{ end }}
+ {{ if gt $hi $maxT }}{{ $maxT = $hi }}{{ end }}
+ {{ end }}
+ {{ $rangeT := sub $maxT $minT }}
+ {{ if le $rangeT 0.1 }}{{ $rangeT = 1.0 }}{{ end }}
+
+
+
+
+
+ {{ range $i, $d := .JSON.Array "daily.time" }}
+ {{ $date := $d.String }}
+
+ {{/* Day label: W Th F Sa Su M Tu (like your screenshot) */}}
+ {{ $dow3 := $date | parseTime "2006-01-02" | formatTime "Mon" }}
+ {{ $dow := "" }}
+ {{ if eq $dow3 "Thu" }}{{ $dow = "Th" }}
+ {{ else if eq $dow3 "Tue" }}{{ $dow = "Tu" }}
+ {{ else if eq $dow3 "Sat" }}{{ $dow = "Sa" }}
+ {{ else if eq $dow3 "Sun" }}{{ $dow = "Su" }}
+ {{ else }}{{ $dow = printf "%.1s" $dow3 }}{{ end }}
+
+ {{ $dom := $date | parseTime "2006-01-02" | formatTime "2" }}
+
+ {{ $code := $.JSON.Int (printf "daily.weathercode.%d" $i) }}
+ {{ $lo := $.JSON.Float (printf "daily.temperature_2m_min.%d" $i) }}
+ {{ $hi := $.JSON.Float (printf "daily.temperature_2m_max.%d" $i) }}
+
+ {{ $loPct := div (sub $lo $minT) $rangeT }}
+ {{ $hiPct := div (sub $hi $minT) $rangeT }}
+ {{ $bottom := mul $loPct 100 | toInt }}
+ {{ $height := mul (sub $hiPct $loPct) 100 | toInt }}
+
+ {{/* Map temp->hue: cold=blue(220) ... hot=red(0) */}}
+ {{ $hueLo := sub 220 (mul 220 $loPct) | toInt }}
+ {{ $hueHi := sub 220 (mul 220 $hiPct) | toInt }}
+ {{ $grad := printf "linear-gradient(to top, hsl(%d,80%%,55%%), hsl(%d,80%%,55%%))" $hueLo $hueHi }}
+
+
+
{{ $dow }}
+
{{ $dom }}
+
+
+ {{/* very lightweight weather icons (emoji) */}}
+ {{ if eq $code 0 }}☀️
+ {{ else if or (eq $code 1) (eq $code 2) }}⛅
+ {{ else if eq $code 3 }}☁️
+ {{ else if or (eq $code 45) (eq $code 48) }}🌫️
+ {{ else if or (eq $code 51) (eq $code 53) (eq $code 55) (eq $code 61) (eq $code 63) (eq $code 65) }}🌧️
+ {{ else if or (eq $code 71) (eq $code 73) (eq $code 75) (eq $code 77) }}❄️
+ {{ else if or (eq $code 80) (eq $code 81) (eq $code 82) }}🌦️
+ {{ else if or (eq $code 95) (eq $code 96) (eq $code 99) }}⛈️
+ {{ else }}☁️
+ {{ end }}
+
+
+
+
+
+
{{ $hi | toInt }}
+
{{ $lo | toInt }}
+
+
{{ end }}
- {{ $maxTemps := $req2.JSON.Array "daily.temperature_2m_max" }}
- {{ $minTemps := $req2.JSON.Array "daily.temperature_2m_min" }}
-
- {{ $max_max := 0 }}
- {{ range $maxTemps }}
- {{ if gt (.Int "") $max_max }}
- {{ $max_max = (.Int "") }}
- {{ end }}
- {{ end }}
- {{ $min_min := 999 }}
- {{ range $minTemps }}
- {{ if lt (.Int "") $min_min }}
- {{ $min_min = (.Int "") }}
- {{ end }}
- {{ end }}
- {{ $max_max = add $max_max 1 }}
- {{ $min_min = sub $min_min 1 }}
-
- {{ $temp_range := sub $max_max $min_min }}
- {{ range $index, $thisHigh := $maxTemps }}
- {{ $thisLow := index $minTemps $index }}
- {{ $thisHigh = $thisHigh.Float "" }}
- {{ $thisLow = $thisLow.Float "" }}
- {{ $thisHighPct := sub 1 (div (sub $max_max $thisHigh) $temp_range) }}
- {{ $thisLowPct := div (sub $thisLow $min_min) $temp_range }}
- {{ $thisTempRange := sub $thisHigh $thisLow }}
-
- {{/* Guard against division-by-zero if highs == lows */}}
- {{ if eq $thisTempRange 0.0 }}
- {{ $thisTempRange = 0.0001 }}
- {{ end }}
-
- {{ $red_pos := mul 100 (div (sub $thisHigh $temp_red) $thisTempRange) | toInt }}
- {{ $yel_pos := mul 100 (div (sub $thisHigh $temp_yellow) $thisTempRange) | toInt }}
- {{ $blu_pos := mul 100 (div (sub $thisHigh $temp_blue) $thisTempRange) | toInt }}
- {{ $whi_pos := mul 100 (div (sub $thisHigh $temp_white) $thisTempRange) | toInt }}
-
- {{/* Clamp to 0..100 */}}
- {{ $pRed := $red_pos }}{{ if lt $pRed 0 }}{{ $pRed = 0 }}{{ end }}{{ if gt $pRed 100 }}{{ $pRed = 100 }}{{ end }}
- {{ $pYel := $yel_pos }}{{ if lt $pYel 0 }}{{ $pYel = 0 }}{{ end }}{{ if gt $pYel 100 }}{{ $pYel = 100 }}{{ end }}
- {{ $pBlu := $blu_pos }}{{ if lt $pBlu 0 }}{{ $pBlu = 0 }}{{ end }}{{ if gt $pBlu 100 }}{{ $pBlu = 100 }}{{ end }}
- {{ $pWhi := $whi_pos }}{{ if lt $pWhi 0 }}{{ $pWhi = 0 }}{{ end }}{{ if gt $pWhi 100 }}{{ $pWhi = 100 }}{{ end }}
- {{/* Ensure non-decreasing stops */}}
- {{ if lt $pYel $pRed }}{{ $pYel = $pRed }}{{ end }}
- {{ if lt $pBlu $pYel }}{{ $pBlu = $pYel }}{{ end }}
- {{ if lt $pWhi $pBlu }}{{ $pWhi = $pBlu }}{{ end }}
-
- {{/* “Gradient” as stacked bands so Glance sanitizer won’t kill it */}}
-
- {{ $top_pos := -2 }}
- {{ $bot_pos := -2 }}
- {{ $pos_thresh := 0.20 }}
- {{ if lt (div $thisTempRange $temp_range) $pos_thresh }}
- {{ $top_pos = -17 }}
- {{ $bot_pos = -19 }}
- {{ else if and (lt (div $thisTempRange $temp_range) (mul $pos_thresh 2)) (lt (sub 1 $thisHighPct) $thisLowPct) }}
- {{ $bot_pos = -19 }}
- {{ else if and (lt (div $thisTempRange $temp_range) (mul $pos_thresh 2)) (gt (sub 1 $thisHighPct) $thisLowPct) }}
- {{ $top_pos = -17 }}
- {{ end }}
- {{/* Overlay layer for numbers */}}
-
-
{{ $thisHigh | toInt }}
-
{{ $thisLow | toInt }}
-
-
- {{ end }}
-
-
# Calendar Widget
- type: calendar