Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
2ed4eca56c | |||
2e3cfb44f4 | |||
be8a4f3bca | |||
96dfcf7e53 | |||
5fc16b39af | |||
1ae58f64ca | |||
bb4e4aa2af | |||
f102ef50bf | |||
d3d251ef30 | |||
eecaf2a82e |
@ -79,7 +79,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ env.DOCKER_IMG }}:${{ github.ref_name }}
|
tags: |
|
||||||
|
${{ env.DOCKER_IMG }}:${{ github.ref_name }}
|
||||||
|
${{ env.DOCKER_IMG }}:latest
|
||||||
build-args: |
|
build-args: |
|
||||||
VER_PKG=${{ env.VER_PKG }}
|
VER_PKG=${{ env.VER_PKG }}
|
||||||
VERSION=${{ github.ref_name }}
|
VERSION=${{ github.ref_name }}
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -20,7 +20,11 @@
|
|||||||
|
|
||||||
# Go workspace file
|
# Go workspace file
|
||||||
go.work
|
go.work
|
||||||
|
go.work.sum
|
||||||
|
|
||||||
.env
|
.env
|
||||||
|
|
||||||
bin/*
|
bin/*
|
||||||
|
|
||||||
|
config.yaml
|
||||||
|
docker-compose.yml
|
||||||
|
12
TODO.md
12
TODO.md
@ -1,10 +1,12 @@
|
|||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- [ ] Fix shutdown
|
- [ ] Fix shutdown
|
||||||
- [ ] Configuration for app
|
- [ ] Configuration for app
|
||||||
- [ ] Makefile
|
|
||||||
- [ ] Dockerfile
|
|
||||||
- [ ] Helm Chart
|
- [ ] Helm Chart
|
||||||
- [ ] Gitea CI
|
|
||||||
- [ ] Update README
|
- [ ] Update README
|
||||||
- [ ] Version flag
|
- [ ] Add new fields from WS-2192
|
||||||
|
|
||||||
|
## Done
|
||||||
|
- [x] Gitea CI
|
||||||
|
- [x] Version flag
|
||||||
|
- [x] Makefile
|
||||||
|
- [x] Dockerfile
|
||||||
|
@ -10,6 +10,10 @@ services:
|
|||||||
APP_LOG_FORMAT: json ## console, json
|
APP_LOG_FORMAT: json ## console, json
|
||||||
APP_LOG_TIME_FORMAT: rfc3339 ## long, short, unix, rfc3339, off
|
APP_LOG_TIME_FORMAT: rfc3339 ## long, short, unix, rfc3339, off
|
||||||
APP_HTTP_LISTEN: 0.0.0.0:8080
|
APP_HTTP_LISTEN: 0.0.0.0:8080
|
||||||
|
APP_HTTP_READ_TIMEOUT: 10s
|
||||||
|
APP_HTTP_WRITE_TIMEOUT: 10s
|
||||||
|
APP_HTTP_IDLE_TIMEOUT: 30s
|
||||||
|
APP_HTTP_LOG_REQUESTS: true
|
||||||
APP_OTEL_STDOUT_ENABLED: false
|
APP_OTEL_STDOUT_ENABLED: false
|
||||||
APP_OTEL_METRIC_INTERVAL_SECS: 30
|
APP_OTEL_METRIC_INTERVAL_SECS: 30
|
||||||
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel.libretechconsulting.com:4317 # Set to your otel collector
|
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel.libretechconsulting.com:4317 # Set to your otel collector
|
4
go.mod
4
go.mod
@ -3,7 +3,7 @@ module gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter
|
|||||||
go 1.23.4
|
go 1.23.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.1
|
gitea.libretechconsulting.com/rmcguire/go-app v0.2.0
|
||||||
github.com/gorilla/schema v1.4.1
|
github.com/gorilla/schema v1.4.1
|
||||||
github.com/rs/zerolog v1.33.0
|
github.com/rs/zerolog v1.33.0
|
||||||
go.opentelemetry.io/otel v1.33.0
|
go.opentelemetry.io/otel v1.33.0
|
||||||
@ -13,7 +13,7 @@ require (
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/caarlos0/env/v9 v9.0.0 // indirect
|
github.com/caarlos0/env/v11 v11.3.1 // indirect
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
|
12
go.sum
12
go.sum
@ -1,11 +1,11 @@
|
|||||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.0 h1:H4TMgQ463oRNOyoi0FAvfGtOoDn651zNZStxM+sdNuU=
|
gitea.libretechconsulting.com/rmcguire/go-app v0.1.3 h1:EwmEJLpN+rQjJ5stGEkZsqEDa5F/YnDAEeqJB9XlFn4=
|
||||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.0/go.mod h1:p0ajkpFvzzD6VZ4xSjuowtwGRb1DjMfo/iG6LyFqFCs=
|
gitea.libretechconsulting.com/rmcguire/go-app v0.1.3/go.mod h1:wHOWh4O4AMDATQ3WEUYjq5a5bnICPBpu5G6BsNxqN38=
|
||||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.1 h1:Hrxqi1tqz8mf0baBsWgFe/S4jyMtIuPqH2FlanJUMNc=
|
gitea.libretechconsulting.com/rmcguire/go-app v0.2.0 h1:pOm/PysC0IWPuEbmEjNSHHa8Qc5OhuoksYExcuJMFE4=
|
||||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.1/go.mod h1:p0ajkpFvzzD6VZ4xSjuowtwGRb1DjMfo/iG6LyFqFCs=
|
gitea.libretechconsulting.com/rmcguire/go-app v0.2.0/go.mod h1:wHOWh4O4AMDATQ3WEUYjq5a5bnICPBpu5G6BsNxqN38=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
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/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||||
github.com/caarlos0/env/v9 v9.0.0 h1:SI6JNsOA+y5gj9njpgybykATIylrRMklbs5ch6wO6pc=
|
github.com/caarlos0/env/v11 v11.3.1 h1:cArPWC15hWmEt+gWk7YBi7lEXTXCvpaSdCiZE2X5mCA=
|
||||||
github.com/caarlos0/env/v9 v9.0.0/go.mod h1:ye5mlCVMYh6tZ+vCgrs/B95sj88cg5Tlnc0XIzgZ020=
|
github.com/caarlos0/env/v11 v11.3.1/go.mod h1:qupehSf/Y0TUTsxKywqRt/vJjN5nz6vauiYEUUr8P4U=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
|
@ -85,6 +85,7 @@ func (aw *AmbientWeather) handleProviderRequest(
|
|||||||
|
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
w.Write([]byte(err.Error()))
|
w.Write([]byte(err.Error()))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate any fields that may be missing
|
// Calculate any fields that may be missing
|
||||||
|
@ -41,8 +41,8 @@ func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
|
|||||||
return &weather.WeatherUpdate{
|
return &weather.WeatherUpdate{
|
||||||
StationType: awnUpdate.StationType,
|
StationType: awnUpdate.StationType,
|
||||||
DateUTC: &updateTime,
|
DateUTC: &updateTime,
|
||||||
TempOutdoorF: awnUpdate.TempF,
|
TempOutdoorF: awnUpdate.TempF,
|
||||||
HumidityOudoor: awnUpdate.Humidity,
|
HumidityOudoor: awnUpdate.Humidity,
|
||||||
WindSpeedMPH: awnUpdate.WindGustMPH,
|
WindSpeedMPH: awnUpdate.WindGustMPH,
|
||||||
WindGustMPH: awnUpdate.WindGustMPH,
|
WindGustMPH: awnUpdate.WindGustMPH,
|
||||||
MaxDailyGust: awnUpdate.MaxDailyGust,
|
MaxDailyGust: awnUpdate.MaxDailyGust,
|
||||||
@ -60,6 +60,7 @@ func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
|
|||||||
BattOutdoorSensor: awnUpdate.BattOut,
|
BattOutdoorSensor: awnUpdate.BattOut,
|
||||||
BattIndoorSensor: awnUpdate.BattIn,
|
BattIndoorSensor: awnUpdate.BattIn,
|
||||||
BattRainSensor: awnUpdate.BattRain,
|
BattRainSensor: awnUpdate.BattRain,
|
||||||
|
BattCO2Sensor: awnUpdate.BattCO2,
|
||||||
TempIndoorF: awnUpdate.TempInF,
|
TempIndoorF: awnUpdate.TempInF,
|
||||||
HumidityIndoor: awnUpdate.HumidityIn,
|
HumidityIndoor: awnUpdate.HumidityIn,
|
||||||
BaromRelativeIn: awnUpdate.BaromRelIn,
|
BaromRelativeIn: awnUpdate.BaromRelIn,
|
||||||
|
@ -27,4 +27,5 @@ type AmbientWeatherUpdate struct {
|
|||||||
BaromRelIn float64 `json:"baromrelin,omitempty" schema:"baromrelin"`
|
BaromRelIn float64 `json:"baromrelin,omitempty" schema:"baromrelin"`
|
||||||
BaromAbsIn float64 `json:"baromabsin,omitempty" schema:"baromabsin"`
|
BaromAbsIn float64 `json:"baromabsin,omitempty" schema:"baromabsin"`
|
||||||
BattIn int `json:"battin,omitempty" schema:"battin"`
|
BattIn int `json:"battin,omitempty" schema:"battin"`
|
||||||
|
BattCO2 int `json:"batt_co2,omitempty" schema:"batt_co2"`
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,10 @@ import "math"
|
|||||||
// Attempts to complete missing fields that may not
|
// Attempts to complete missing fields that may not
|
||||||
// be set by a specific provider, such as DewPoint and WindChill
|
// be set by a specific provider, such as DewPoint and WindChill
|
||||||
func (u *WeatherUpdate) Enrich() {
|
func (u *WeatherUpdate) Enrich() {
|
||||||
|
if u == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if u.WindChillF == 0 {
|
if u.WindChillF == 0 {
|
||||||
u.WindChillF = CalculateWindChill(u.TempOutdoorF, u.WindSpeedMPH)
|
u.WindChillF = CalculateWindChill(u.TempOutdoorF, u.WindSpeedMPH)
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ type WeatherUpdate struct {
|
|||||||
BattOutdoorSensor int
|
BattOutdoorSensor int
|
||||||
BattIndoorSensor int
|
BattIndoorSensor int
|
||||||
BattRainSensor int
|
BattRainSensor int
|
||||||
|
BattCO2Sensor int
|
||||||
BaromRelativeIn float64
|
BaromRelativeIn float64
|
||||||
BaromAbsoluteIn float64
|
BaromAbsoluteIn float64
|
||||||
// These fields may be calculated
|
// These fields may be calculated
|
||||||
|
8
unset_env.sh
Executable file
8
unset_env.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!env sh
|
||||||
|
unset APP_NAME
|
||||||
|
unset APP_LOG_LEVEL
|
||||||
|
unset APP_LOG_FORMAT
|
||||||
|
unset APP_LOG_TIME_FORMAT
|
||||||
|
unset APP_HTTP_LISTEN
|
||||||
|
unset APP_OTEL_STDOUT_ENABLED
|
||||||
|
unset APP_OTEL_METRIC_INTERVAL_SECS
|
Reference in New Issue
Block a user