Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
00f61879c1 | |||
c23177b62d | |||
86653cf589 | |||
fa0a9f4ddc | |||
689790fe86 | |||
3af1cc40a5 | |||
4ff684abe3 |
3
TODO.md
3
TODO.md
@ -1,10 +1,13 @@
|
||||
# TODO
|
||||
- [ ] Configuration for app
|
||||
- [ ] Configurable metric prefix
|
||||
- [ ] Helm Chart
|
||||
- [ ] Update README
|
||||
- [ ] Add Grafana dashboard
|
||||
- [ ] Add device name field with ID/Key mappings
|
||||
- [ ] Add device type field with ID/Key mappings
|
||||
- [ ] Move EVERYTHING to pointers to support nil
|
||||
- [ ] Add proxy to upstream support
|
||||
|
||||
## Done
|
||||
- [x] Consolidate battery status into one metric with device label
|
||||
|
12
go.mod
12
go.mod
@ -3,7 +3,7 @@ module gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter
|
||||
go 1.23.4
|
||||
|
||||
require (
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.3.0
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.3.1
|
||||
github.com/gorilla/schema v1.4.1
|
||||
github.com/rs/zerolog v1.33.0
|
||||
go.opentelemetry.io/otel v1.33.0
|
||||
@ -40,12 +40,12 @@ require (
|
||||
go.opentelemetry.io/otel/sdk v1.33.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk/metric v1.33.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.33.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
|
||||
golang.org/x/net v0.33.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
|
||||
golang.org/x/net v0.34.0 // indirect
|
||||
golang.org/x/text v0.21.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250102185135-69823020774d // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250102185135-69823020774d // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422 // indirect
|
||||
google.golang.org/grpc v1.69.2 // indirect
|
||||
google.golang.org/protobuf v1.36.1 // indirect
|
||||
google.golang.org/protobuf v1.36.2 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
16
go.sum
16
go.sum
@ -1,9 +1,7 @@
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.3 h1:EwmEJLpN+rQjJ5stGEkZsqEDa5F/YnDAEeqJB9XlFn4=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.3/go.mod h1:wHOWh4O4AMDATQ3WEUYjq5a5bnICPBpu5G6BsNxqN38=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.2.0 h1:pOm/PysC0IWPuEbmEjNSHHa8Qc5OhuoksYExcuJMFE4=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.2.0/go.mod h1:wHOWh4O4AMDATQ3WEUYjq5a5bnICPBpu5G6BsNxqN38=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.3.0 h1:TSR6oEDBX+83975gmgGgU/cTFgfG999+9N/1h4RAXq0=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.3.0/go.mod h1:wHOWh4O4AMDATQ3WEUYjq5a5bnICPBpu5G6BsNxqN38=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.3.1 h1:jydcJ+Vv8sk+Le7nTI2+b6E7FfV+ShBJo7YdxmdaCYc=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.3.1/go.mod h1:wHOWh4O4AMDATQ3WEUYjq5a5bnICPBpu5G6BsNxqN38=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/caarlos0/env/v11 v11.3.1 h1:cArPWC15hWmEt+gWk7YBi7lEXTXCvpaSdCiZE2X5mCA=
|
||||
@ -95,10 +93,14 @@ go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qq
|
||||
go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37CbGV4fr1f2nBck=
|
||||
go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg=
|
||||
go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY=
|
||||
go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4=
|
||||
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
||||
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@ -108,12 +110,18 @@ golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250102185135-69823020774d h1:H8tOf8XM88HvKqLTxe755haY6r1fqqzLbEnfrmLXlSA=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250102185135-69823020774d/go.mod h1:2v7Z7gP2ZUOGsaFyxATQSRoBnKygqVq2Cwnvom7QiqY=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 h1:GVIKPyP/kLIyVOgOnTwFOrvQaQUzOzGMCxgFUOEmm24=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422/go.mod h1:b6h1vNKhxaSoEI+5jc3PJUCustfli/mRab7295pY7rw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250102185135-69823020774d h1:xJJRGY7TJcvIlpSrN3K6LAWgNFUILlO+OMAqtg9aqnw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250102185135-69823020774d/go.mod h1:3ENsm/5D1mzDyhpzeRi1NR784I0BcofWBoSc5QqqMK4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422 h1:3UsHvIr4Wc2aW4brOaSCmcxh9ksica6fHEr8P1XhkYw=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422/go.mod h1:3ENsm/5D1mzDyhpzeRi1NR784I0BcofWBoSc5QqqMK4=
|
||||
google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU=
|
||||
google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
|
||||
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk=
|
||||
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU=
|
||||
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
17
main.go
17
main.go
@ -12,15 +12,26 @@ import (
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/ambient"
|
||||
)
|
||||
|
||||
const defaultMetricPrefix = "weather"
|
||||
|
||||
func main() {
|
||||
ctx, cncl := signal.NotifyContext(context.Background(), os.Kill, unix.SIGTERM)
|
||||
defer cncl()
|
||||
|
||||
// Config type for app, which implements go-app/config.AppConfig
|
||||
awConfig := &ambient.AmbientLocalExporterConfig{
|
||||
MetricPrefix: defaultMetricPrefix,
|
||||
WeatherStations: make([]ambient.WeatherStation, 0),
|
||||
}
|
||||
|
||||
// Read config and environment, set up logging, load up
|
||||
// an appCtx, and prepare ambient weather local exporter
|
||||
ctx = app.MustSetupConfigAndLogging(ctx)
|
||||
aw := ambient.New(ctx).Init()
|
||||
ctx, awConfig = app.MustLoadConfigInto(ctx, awConfig)
|
||||
|
||||
// Prepare the exporter
|
||||
aw := ambient.New(ctx, awConfig).Init()
|
||||
|
||||
// Define and prepare the app
|
||||
awApp := app.App{
|
||||
AppContext: ctx,
|
||||
HTTP: &app.AppHTTP{
|
||||
@ -43,7 +54,7 @@ func main() {
|
||||
},
|
||||
}
|
||||
|
||||
// Run and wait
|
||||
awApp.MustRun()
|
||||
|
||||
<-awApp.Done()
|
||||
}
|
||||
|
@ -24,6 +24,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 *AmbientLocalExporterConfig
|
||||
awnProvider provider.AmbientProvider
|
||||
wuProvider provider.AmbientProvider
|
||||
appCtx context.Context
|
||||
@ -31,7 +32,7 @@ type AmbientWeather struct {
|
||||
l *zerolog.Logger
|
||||
}
|
||||
|
||||
func New(appCtx context.Context) *AmbientWeather {
|
||||
func New(appCtx context.Context, awConfig *AmbientLocalExporterConfig) *AmbientWeather {
|
||||
return &AmbientWeather{
|
||||
appCtx: appCtx,
|
||||
}
|
||||
@ -96,6 +97,9 @@ func (aw *AmbientWeather) handleProviderRequest(
|
||||
|
||||
// Update metrics
|
||||
if aw.metrics == nil {
|
||||
if aw.config.MetricPrefix != "" {
|
||||
weather.MetricPrefix = aw.config.MetricPrefix
|
||||
}
|
||||
aw.metrics = weather.MustInitMetrics(aw.appCtx)
|
||||
}
|
||||
aw.metrics.Update(update)
|
||||
|
33
pkg/ambient/config.go
Normal file
33
pkg/ambient/config.go
Normal file
@ -0,0 +1,33 @@
|
||||
package ambient
|
||||
|
||||
import (
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/weather"
|
||||
)
|
||||
|
||||
// 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
|
||||
*config.AppConfig // Extends app config
|
||||
}
|
||||
|
||||
type WeatherStation struct {
|
||||
Name string `yaml:"name"` // Human Friendly Name (e.g. Back Yard Weather)
|
||||
Equipment string `yaml:"equipment"` // Equipment Type (e.g. WS-5000)
|
||||
|
||||
// One of these is required, based on the type
|
||||
// set in the "Custom" weather service on your
|
||||
// console, weather station, or weather hub
|
||||
WundergroundID string `yaml:"wundergroundID"`
|
||||
AWNPassKey string `yaml:"awnPassKey"`
|
||||
|
||||
// Proxy updates to AWN or Wunderground
|
||||
ProxyToAWN bool `yaml:"proxyToAWN"`
|
||||
ProxyToWunderground bool `yaml:"proxyToWunderground"`
|
||||
|
||||
// Unreliable / unwanted metrics by name of WeatherUpdate Field
|
||||
// These fields are mapped from the provider fields
|
||||
DiscardMetrics []weather.WeatherUpdateField `yaml:"discardMetrics"`
|
||||
}
|
@ -43,7 +43,7 @@ func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
|
||||
DateUTC: &updateTime,
|
||||
TempOutdoorF: awnUpdate.TempF,
|
||||
HumidityOudoor: awnUpdate.Humidity,
|
||||
WindSpeedMPH: awnUpdate.WindGustMPH,
|
||||
WindSpeedMPH: awnUpdate.WindSpeedMPH,
|
||||
WindGustMPH: awnUpdate.WindGustMPH,
|
||||
MaxDailyGust: awnUpdate.MaxDailyGust,
|
||||
WindDir: awnUpdate.WindDir,
|
||||
|
@ -43,6 +43,8 @@ type WeatherMetrics struct {
|
||||
meter metric.Meter
|
||||
}
|
||||
|
||||
var MetricPrefix = "weather"
|
||||
|
||||
func MustInitMetrics(appCtx context.Context) *WeatherMetrics {
|
||||
wm := &WeatherMetrics{
|
||||
appCtx: appCtx,
|
||||
@ -52,55 +54,55 @@ func MustInitMetrics(appCtx context.Context) *WeatherMetrics {
|
||||
wm.meter = otel.GetMeter(appCtx, "weather", "metrics")
|
||||
|
||||
// Weather Metrics
|
||||
wm.TempOutdoorF, _ = wm.meter.Float64Gauge("weather_temp_outdoor_f",
|
||||
wm.TempOutdoorF, _ = wm.meter.Float64Gauge(MetricPrefix+"_temp_outdoor_f",
|
||||
metric.WithDescription("Outdoor Temperature in Faherenheit"))
|
||||
wm.TempIndoorF, _ = wm.meter.Float64Gauge("weather_temp_indoor_f",
|
||||
wm.TempIndoorF, _ = wm.meter.Float64Gauge(MetricPrefix+"_temp_indoor_f",
|
||||
metric.WithDescription("Indoor Temperature in Faherenheit"))
|
||||
wm.HumidityOudoor, _ = wm.meter.Int64Gauge("weather_humidity_outdoor",
|
||||
wm.HumidityOudoor, _ = wm.meter.Int64Gauge(MetricPrefix+"_humidity_outdoor",
|
||||
metric.WithDescription("Outdoor Humidity %"))
|
||||
wm.HumidityIndoor, _ = wm.meter.Int64Gauge("weather_humidity_indoor",
|
||||
wm.HumidityIndoor, _ = wm.meter.Int64Gauge(MetricPrefix+"_humidity_indoor",
|
||||
metric.WithDescription("Indoor Humidity %"))
|
||||
wm.WindSpeedMPH, _ = wm.meter.Float64Gauge("weather_wind_speed_mph",
|
||||
wm.WindSpeedMPH, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_speed_mph",
|
||||
metric.WithDescription("Wind Speed in MPH"))
|
||||
wm.WindGustMPH, _ = wm.meter.Float64Gauge("weather_wind_gust_mph",
|
||||
wm.WindGustMPH, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_gust_mph",
|
||||
metric.WithDescription("Wind Gust in MPH"))
|
||||
wm.MaxDailyGust, _ = wm.meter.Float64Gauge("weather_max_daily_gust",
|
||||
wm.MaxDailyGust, _ = wm.meter.Float64Gauge(MetricPrefix+"_max_daily_gust",
|
||||
metric.WithDescription("Max Daily Wind Gust"))
|
||||
wm.WindDir, _ = wm.meter.Int64Gauge("weather_wind_dir",
|
||||
wm.WindDir, _ = wm.meter.Int64Gauge(MetricPrefix+"_wind_dir",
|
||||
metric.WithDescription("Wind Direction in Degrees"))
|
||||
wm.WindDirAvg10m, _ = wm.meter.Int64Gauge("weather_wind_dir_avg_10m",
|
||||
wm.WindDirAvg10m, _ = wm.meter.Int64Gauge(MetricPrefix+"_wind_dir_avg_10m",
|
||||
metric.WithDescription("Wind Direction 10m Average"))
|
||||
wm.UV, _ = wm.meter.Int64Gauge("weather_uv",
|
||||
wm.UV, _ = wm.meter.Int64Gauge(MetricPrefix+"_uv",
|
||||
metric.WithDescription("UV Index"))
|
||||
wm.SolarRadiation, _ = wm.meter.Float64Gauge("weather_solar_radiation",
|
||||
wm.SolarRadiation, _ = wm.meter.Float64Gauge(MetricPrefix+"_solar_radiation",
|
||||
metric.WithDescription("Solar Radiation in W/㎡"))
|
||||
wm.HourlyRainIn, _ = wm.meter.Float64Gauge("weather_hourly_rain_in",
|
||||
wm.HourlyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_hourly_rain_in",
|
||||
metric.WithDescription("Hourly Rain in Inches"))
|
||||
wm.EventRainIn, _ = wm.meter.Float64Gauge("weather_event_rain_in",
|
||||
wm.EventRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_event_rain_in",
|
||||
metric.WithDescription("Event Rain in Inches"))
|
||||
wm.DailyRainIn, _ = wm.meter.Float64Gauge("weather_daily_rain_in",
|
||||
wm.DailyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_daily_rain_in",
|
||||
metric.WithDescription("Daily Rain in Inches"))
|
||||
wm.WeeklyRainIn, _ = wm.meter.Float64Gauge("weather_weekly_rain_in",
|
||||
wm.WeeklyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_weekly_rain_in",
|
||||
metric.WithDescription("Weekly Rain in Inches"))
|
||||
wm.MonthlyRainIn, _ = wm.meter.Float64Gauge("weather_monthly_rain_in",
|
||||
wm.MonthlyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_monthly_rain_in",
|
||||
metric.WithDescription("Monthly Rain in Inches"))
|
||||
wm.YearlyRainIn, _ = wm.meter.Float64Gauge("weather_yearly_rain_in",
|
||||
wm.YearlyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_yearly_rain_in",
|
||||
metric.WithDescription("Yearly Rain in Inches"))
|
||||
wm.TotalRainIn, _ = wm.meter.Float64Gauge("weather_total_rain_in",
|
||||
wm.TotalRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_total_rain_in",
|
||||
metric.WithDescription("Total Rain in Inches"))
|
||||
wm.BatteryStatus, _ = wm.meter.Int64Gauge("battery_status",
|
||||
wm.BatteryStatus, _ = wm.meter.Int64Gauge(MetricPrefix+"_battery_status",
|
||||
metric.WithDescription("Per-component battery status"))
|
||||
wm.BaromRelativeIn, _ = wm.meter.Float64Gauge("weather_barometric_pressure_relative_in",
|
||||
wm.BaromRelativeIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_barometric_pressure_relative_in",
|
||||
metric.WithDescription("Relative Pressure in Inches of Mercury"))
|
||||
wm.BaromAbsoluteIn, _ = wm.meter.Float64Gauge("weather_barometric_pressure_absolute_in",
|
||||
wm.BaromAbsoluteIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_barometric_pressure_absolute_in",
|
||||
metric.WithDescription("Absolute Pressure in Inches of Mercury"))
|
||||
wm.DewPointF, _ = wm.meter.Float64Gauge("weather_dew_point_f",
|
||||
wm.DewPointF, _ = wm.meter.Float64Gauge(MetricPrefix+"_dew_point_f",
|
||||
metric.WithDescription("Dew Point in Faherenheit"))
|
||||
wm.WindChillF, _ = wm.meter.Float64Gauge("weather_wind_chill_f",
|
||||
wm.WindChillF, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_chill_f",
|
||||
metric.WithDescription("Wind Chill in Faherenheit"))
|
||||
|
||||
// Internal Telemetry
|
||||
wm.UpdatesReceived, _ = wm.meter.Int64Counter("weather_updates_received",
|
||||
wm.UpdatesReceived, _ = wm.meter.Int64Counter(MetricPrefix+"_updates_received",
|
||||
metric.WithDescription("Metric Updates Processed by Exporter"))
|
||||
|
||||
return wm
|
||||
|
@ -7,31 +7,27 @@ import (
|
||||
// Stable intermediate struct containing superset of fields
|
||||
// between AWN and Wunderground style updates from Ambient devices
|
||||
type WeatherUpdate struct {
|
||||
DateUTC *time.Time
|
||||
StationType string
|
||||
TempOutdoorF float64
|
||||
TempIndoorF float64
|
||||
HumidityOudoor int
|
||||
HumidityIndoor int
|
||||
WindSpeedMPH float64
|
||||
WindGustMPH float64
|
||||
MaxDailyGust float64
|
||||
WindDir int
|
||||
WindDirAvg10m int
|
||||
UV int
|
||||
SolarRadiation float64
|
||||
HourlyRainIn float64
|
||||
EventRainIn float64
|
||||
DailyRainIn float64
|
||||
WeeklyRainIn float64
|
||||
MonthlyRainIn float64
|
||||
YearlyRainIn float64
|
||||
TotalRainIn float64
|
||||
Batteries []BatteryStatus
|
||||
// BattOutdoorSensor int
|
||||
// BattIndoorSensor int
|
||||
// BattRainSensor int
|
||||
// BattCO2Sensor int
|
||||
DateUTC *time.Time
|
||||
StationType string
|
||||
TempOutdoorF float64
|
||||
TempIndoorF float64
|
||||
HumidityOudoor int
|
||||
HumidityIndoor int
|
||||
WindSpeedMPH float64
|
||||
WindGustMPH float64
|
||||
MaxDailyGust float64
|
||||
WindDir int
|
||||
WindDirAvg10m int
|
||||
UV int
|
||||
SolarRadiation float64
|
||||
HourlyRainIn float64
|
||||
EventRainIn float64
|
||||
DailyRainIn float64
|
||||
WeeklyRainIn float64
|
||||
MonthlyRainIn float64
|
||||
YearlyRainIn float64
|
||||
TotalRainIn float64
|
||||
Batteries []BatteryStatus
|
||||
BaromRelativeIn float64
|
||||
BaromAbsoluteIn float64
|
||||
// These fields may be calculated
|
||||
@ -44,3 +40,35 @@ type BatteryStatus struct {
|
||||
Component string
|
||||
Status int
|
||||
}
|
||||
|
||||
type WeatherUpdateField string
|
||||
|
||||
// NOTE: Annoyance to avoid string constant comparisons
|
||||
// CHORE: Maintain this
|
||||
const (
|
||||
FieldDateUTC WeatherUpdateField = "DateUTC"
|
||||
FieldStationType WeatherUpdateField = "StationType"
|
||||
FieldTempOutdoorF WeatherUpdateField = "TempOutdoorF"
|
||||
FieldTempIndoorF WeatherUpdateField = "TempIndoorF"
|
||||
FieldHumidityOudoor WeatherUpdateField = "HumidityOudoor"
|
||||
FieldHumidityIndoor WeatherUpdateField = "HumidityIndoor"
|
||||
FieldWindSpeedMPH WeatherUpdateField = "WindSpeedMPH"
|
||||
FieldWindGustMPH WeatherUpdateField = "WindGustMPH"
|
||||
FieldMaxDailyGust WeatherUpdateField = "MaxDailyGust"
|
||||
FieldWindDir WeatherUpdateField = "WindDir"
|
||||
FieldWindDirAvg10m WeatherUpdateField = "WindDirAvg10m"
|
||||
FieldUV WeatherUpdateField = "UV"
|
||||
FieldSolarRadiation WeatherUpdateField = "SolarRadiation"
|
||||
FieldHourlyRainIn WeatherUpdateField = "HourlyRainIn"
|
||||
FieldEventRainIn WeatherUpdateField = "EventRainIn"
|
||||
FieldDailyRainIn WeatherUpdateField = "DailyRainIn"
|
||||
FieldWeeklyRainIn WeatherUpdateField = "WeeklyRainIn"
|
||||
FieldMonthlyRainIn WeatherUpdateField = "MonthlyRainIn"
|
||||
FieldYearlyRainIn WeatherUpdateField = "YearlyRainIn"
|
||||
FieldTotalRainIn WeatherUpdateField = "TotalRainIn"
|
||||
FieldBatteries WeatherUpdateField = "Batteries"
|
||||
FieldBaromRelativeIn WeatherUpdateField = "BaromRelativeIn"
|
||||
FieldBaromAbsoluteIn WeatherUpdateField = "BaromAbsoluteIn"
|
||||
FieldDewPointF WeatherUpdateField = "DewPointF"
|
||||
FieldWindChillF WeatherUpdateField = "WindChillF"
|
||||
)
|
||||
|
Reference in New Issue
Block a user