Skip to content

Commit 9f5289c

Browse files
committed
Add the UV index to the daily forecast.
Signed-off-by: Katharine Berry <[email protected]>
1 parent 8676764 commit 9f5289c

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

service/assistant/functions/weather.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ func processDailyForecast(ctx context.Context, lat, lon float64, units string) a
139139
if i == 0 {
140140
day += " (Today)"
141141
}
142+
dayPart := forecast.DayParts[i*2]
143+
if dayPart == nil {
144+
dayPart = forecast.DayParts[i*2+1]
145+
}
142146
response[day] = map[string]any{
143147
"high": forecast.CalendarDayTemperatureMax[i],
144148
"low": forecast.CalendarDayTemperatureMin[i],
@@ -150,6 +154,7 @@ func processDailyForecast(ctx context.Context, lat, lon float64, units string) a
150154
//"moon_phase": forecast.MoonPhase[i],
151155
"qpf": forecast.Qpf[i],
152156
"qpf_snow": forecast.QpfSnow[i],
157+
"uv_index": dayPart.UvIndex,
153158
}
154159
}
155160
response["temperatureUnit"] = forecast.TemperatureUnit

service/assistant/util/weather/weather.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,22 @@ func GetHourlyForecast(ctx context.Context, lat, lon float64, units string) (*Ho
123123
}
124124

125125
type Forecast struct {
126-
CalendarDayTemperatureMax []int `json:"calendarDayTemperatureMax"`
127-
CalendarDayTemperatureMin []int `json:"calendarDayTemperatureMin"`
128-
DayOfWeek []string `json:"dayOfWeek"`
129-
MoonPhaseCode []string `json:"moonPhaseCode"`
130-
MoonPhase []string `json:"moonPhase"`
131-
MoonPhaseDay []int `json:"moonPhaseDay"`
132-
Narrative []string `json:"narrative"`
133-
SunriseTimeLocal []string `json:"sunriseTimeLocal"`
134-
SunsetTimeLocal []string `json:"sunsetTimeLocal"`
135-
MoonriseTimeLocal []string `json:"moonriseTimeLocal"`
136-
MoonsetTimeLocal []string `json:"moonsetTimeLocal"`
137-
Qpf []float32 `json:"qpf"`
138-
QpfSnow []float32 `json:"qpfSnow"`
139-
DayParts []ForecastDayPart `json:"daypart"`
140-
WindSpeedUnit string `json:"windSpeedUnit"`
141-
TemperatureUnit string `json:"temperatureUnit"`
126+
CalendarDayTemperatureMax []int `json:"calendarDayTemperatureMax"`
127+
CalendarDayTemperatureMin []int `json:"calendarDayTemperatureMin"`
128+
DayOfWeek []string `json:"dayOfWeek"`
129+
MoonPhaseCode []string `json:"moonPhaseCode"`
130+
MoonPhase []string `json:"moonPhase"`
131+
MoonPhaseDay []int `json:"moonPhaseDay"`
132+
Narrative []string `json:"narrative"`
133+
SunriseTimeLocal []string `json:"sunriseTimeLocal"`
134+
SunsetTimeLocal []string `json:"sunsetTimeLocal"`
135+
MoonriseTimeLocal []string `json:"moonriseTimeLocal"`
136+
MoonsetTimeLocal []string `json:"moonsetTimeLocal"`
137+
Qpf []float32 `json:"qpf"`
138+
QpfSnow []float32 `json:"qpfSnow"`
139+
DayParts []*ForecastDayPart `json:"daypart"`
140+
WindSpeedUnit string `json:"windSpeedUnit"`
141+
TemperatureUnit string `json:"temperatureUnit"`
142142
}
143143

144144
type ForecastDayPart struct {

0 commit comments

Comments
 (0)