continue working on weather mapping
This commit is contained in:
@ -27,7 +27,7 @@ type AmbientWeather struct {
|
||||
// when either "AmbientWeather" or "Wunderground" are selected
|
||||
// in the "Custom" section of the AWNet app, or the web UI
|
||||
// of an Ambient WeatherHub
|
||||
config *config.AmbientLocalExporterConfig
|
||||
Config *config.AmbientLocalExporterConfig
|
||||
awnProvider provider.AmbientProvider
|
||||
wuProvider provider.AmbientProvider
|
||||
appCtx context.Context
|
||||
@ -37,7 +37,7 @@ type AmbientWeather struct {
|
||||
|
||||
func New(appCtx context.Context, awConfig *config.AmbientLocalExporterConfig) *AmbientWeather {
|
||||
return &AmbientWeather{
|
||||
config: awConfig,
|
||||
Config: awConfig,
|
||||
appCtx: appCtx,
|
||||
}
|
||||
}
|
||||
@ -48,7 +48,7 @@ func (aw *AmbientWeather) Init() *AmbientWeather {
|
||||
aw.wuProvider = &wunderground.WUProvider{}
|
||||
aw.l = zerolog.Ctx(aw.appCtx)
|
||||
|
||||
aw.l.Trace().Any("awConfig", aw.config).Send()
|
||||
aw.l.Trace().Any("awConfig", aw.Config).Send()
|
||||
return aw
|
||||
}
|
||||
|
||||
@ -227,15 +227,15 @@ func (aw *AmbientWeather) proxyUpdate(
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) InitMetrics() {
|
||||
if aw.config.MetricPrefix != "" {
|
||||
weather.MetricPrefix = aw.config.MetricPrefix
|
||||
if aw.Config.MetricPrefix != "" {
|
||||
weather.MetricPrefix = aw.Config.MetricPrefix
|
||||
}
|
||||
aw.metrics = weather.MustInitMetrics(aw.appCtx)
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) enrichStation(update *weather.WeatherUpdate) {
|
||||
if update != nil && update.StationID != nil && *update.StationID != "" {
|
||||
for _, station := range aw.config.WeatherStations {
|
||||
for _, station := range aw.Config.WeatherStations {
|
||||
if *update.StationID == station.AWNPassKey || *update.StationID == station.WundergroundID {
|
||||
update.StationConfig = &station
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ import (
|
||||
// This configuration includes all config from go-app/config.AppConfig
|
||||
type AmbientLocalExporterConfig struct {
|
||||
MetricPrefix string `yaml:"metricPrefix" default:"weather" env:"AMBIENT_METRIC_PREFIX"`
|
||||
WeatherStations []WeatherStation `yaml:"weatherStations"` // No env, too complex, not worth the time
|
||||
UpdatesToKeep *int `yaml:"updatesToKeep" default:"1" env:"AMBIENT_UPDATES_TO_KEEP"`
|
||||
WeatherStations []WeatherStation `yaml:"weatherStations" env:"weatherStations"` // No env, too complex, not worth the time
|
||||
*config.AppConfig // Extends app config
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user