Proxy support for AWN/Wunderground

This commit is contained in:
2025-01-12 15:30:37 -05:00
parent 849dbfb6ff
commit 7fc1fc9b56
9 changed files with 228 additions and 39 deletions

View File

@ -114,6 +114,26 @@ func (aw *AmbientWeather) handleProviderRequest(
Any("update", update).
Msg("successfully handled update")
w.Write([]byte("ok"))
// Proxy update to one or both services if configured to do so
// Uses a weather update to allow awn to publish to wunderground and
// visa versa.
if station := aw.config.GetStation(update.GetStationName()); station != nil {
if station.ProxyToAWN {
err := aw.awnProvider.ProxyReq(ctx, update)
if err != nil {
zerolog.Ctx(aw.appCtx).Err(err).Msg("failed to proxy to ambient weather")
}
}
if station.ProxyToWunderground {
err := aw.awnProvider.ProxyReq(ctx, update)
if err != nil {
zerolog.Ctx(aw.appCtx).Err(err).Msg("failed to proxy to ambient weather")
}
}
}
return
}
func (aw *AmbientWeather) InitMetrics() {