Proxy updates for AWN
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build and Publish / release (push) Successful in 2m53s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build and Publish / release (push) Successful in 2m53s
				
			This commit is contained in:
		@@ -124,13 +124,21 @@ func (aw *AmbientWeather) handleProviderRequest(
 | 
				
			|||||||
			err := aw.awnProvider.ProxyReq(ctx, update)
 | 
								err := aw.awnProvider.ProxyReq(ctx, update)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				zerolog.Ctx(aw.appCtx).Err(err).Msg("failed to proxy to ambient weather")
 | 
									zerolog.Ctx(aw.appCtx).Err(err).Msg("failed to proxy to ambient weather")
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								zerolog.Ctx(aw.appCtx).Debug().
 | 
				
			||||||
 | 
									Str("station", station.Name).
 | 
				
			||||||
 | 
									Msg("proxied weather update to awn")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if station.ProxyToWunderground {
 | 
							if station.ProxyToWunderground {
 | 
				
			||||||
			err := aw.wuProvider.ProxyReq(ctx, update)
 | 
								err := aw.wuProvider.ProxyReq(ctx, update)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				zerolog.Ctx(aw.appCtx).Err(err).Msg("failed to proxy to ambient weather")
 | 
									zerolog.Ctx(aw.appCtx).Err(err).Msg("failed to proxy to ambient weather")
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								zerolog.Ctx(aw.appCtx).Debug().
 | 
				
			||||||
 | 
									Str("station", station.Name).
 | 
				
			||||||
 | 
									Msg("proxied weather update to wunderground")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,6 +18,14 @@ const (
 | 
				
			|||||||
	awnURL       = "http://ambientweather.net/data/report"
 | 
						awnURL       = "http://ambientweather.net/data/report"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Battery Sensors
 | 
				
			||||||
 | 
					const (
 | 
				
			||||||
 | 
						BattOutdoorSensor = "OutdoorSensor"
 | 
				
			||||||
 | 
						BattIndoorSensor  = "IndoorSensor"
 | 
				
			||||||
 | 
						BattRainSensor    = "RainSensor"
 | 
				
			||||||
 | 
						BattCO2Sensor     = "CO2Sensor"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (awn *AWNProvider) Name() string {
 | 
					func (awn *AWNProvider) Name() string {
 | 
				
			||||||
	return providerName
 | 
						return providerName
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -66,19 +74,19 @@ func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
 | 
				
			|||||||
		TotalRainIn:    awnUpdate.TotalRainIn,
 | 
							TotalRainIn:    awnUpdate.TotalRainIn,
 | 
				
			||||||
		Batteries: []weather.BatteryStatus{
 | 
							Batteries: []weather.BatteryStatus{
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Component: "OutdoorSensor",
 | 
									Component: BattOutdoorSensor,
 | 
				
			||||||
				Status:    awnUpdate.BattOut,
 | 
									Status:    awnUpdate.BattOut,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Component: "IndoorSensor",
 | 
									Component: BattIndoorSensor,
 | 
				
			||||||
				Status:    awnUpdate.BattIn,
 | 
									Status:    awnUpdate.BattIn,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Component: "RainSensor",
 | 
									Component: BattRainSensor,
 | 
				
			||||||
				Status:    awnUpdate.BattRain,
 | 
									Status:    awnUpdate.BattRain,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Component: "CO2Sensor",
 | 
									Component: BattCO2Sensor,
 | 
				
			||||||
				Status:    awnUpdate.BattCO2,
 | 
									Status:    awnUpdate.BattCO2,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,5 +79,20 @@ func updateToAWNParams(update *weather.WeatherUpdate) *url.Values {
 | 
				
			|||||||
	weather.SetURLVal(params, "windgustmph", update.WindGustMPH)
 | 
						weather.SetURLVal(params, "windgustmph", update.WindGustMPH)
 | 
				
			||||||
	weather.SetURLVal(params, "windspeedmph", update.WindSpeedMPH)
 | 
						weather.SetURLVal(params, "windspeedmph", update.WindSpeedMPH)
 | 
				
			||||||
	weather.SetURLVal(params, "maxdailygust", update.MaxDailyGust)
 | 
						weather.SetURLVal(params, "maxdailygust", update.MaxDailyGust)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Batteries
 | 
				
			||||||
 | 
						for _, status := range update.Batteries {
 | 
				
			||||||
 | 
							switch status.Component {
 | 
				
			||||||
 | 
							case BattOutdoorSensor:
 | 
				
			||||||
 | 
								weather.SetURLVal(params, "battin", status.Status)
 | 
				
			||||||
 | 
							case BattIndoorSensor:
 | 
				
			||||||
 | 
								weather.SetURLVal(params, "battout", status.Status)
 | 
				
			||||||
 | 
							case BattRainSensor:
 | 
				
			||||||
 | 
								weather.SetURLVal(params, "battrain", status.Status)
 | 
				
			||||||
 | 
							case BattCO2Sensor:
 | 
				
			||||||
 | 
								weather.SetURLVal(params, "batt_co2", status.Status)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return params
 | 
						return params
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user