Compare commits
54 Commits
Author | SHA1 | Date | |
---|---|---|---|
8674bb4e01 | |||
74120183ab | |||
f05496632a | |||
ffac524cfc | |||
64ca321c3a | |||
3329c980a9 | |||
b4412a461f | |||
042fd221c4 | |||
29433cddd7 | |||
f98a4cf348 | |||
8b46238e49 | |||
4ed1e465d2 | |||
ea93beb6b2 | |||
ae53a1d5fd | |||
cd04beeec6 | |||
3d3492a283 | |||
ce0ef7d291 | |||
f2f160b112 | |||
2c29493229 | |||
59433cc77f | |||
16d3f9cb17 | |||
e93c7ec5c0 | |||
c2bde1e1dd | |||
44bf293eab | |||
f87b35b306 | |||
eaf2cf211d | |||
e8fbacfe6d | |||
19823ea08f | |||
7fc1fc9b56 | |||
849dbfb6ff | |||
dc2470da71 | |||
c23177b62d | |||
86653cf589 | |||
fa0a9f4ddc | |||
689790fe86 | |||
3af1cc40a5 | |||
4ff684abe3 | |||
87f0cbac01 | |||
4c93303f27 | |||
e8654e76bc | |||
54f725c822 | |||
c002331fd4 | |||
2ed4eca56c | |||
2e3cfb44f4 | |||
be8a4f3bca | |||
96dfcf7e53 | |||
5fc16b39af | |||
1ae58f64ca | |||
bb4e4aa2af | |||
f102ef50bf | |||
d3d251ef30 | |||
eecaf2a82e | |||
f0f6c58f0b | |||
681c7f703b |
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
.git
|
||||
config.y*ml
|
||||
go.work*
|
||||
docker-compose-sample*
|
@ -54,6 +54,7 @@ jobs:
|
||||
done
|
||||
|
||||
- name: Run Go List
|
||||
continue-on-error: true
|
||||
env:
|
||||
TAG_NAME: ${{ github.ref_name }} # Use the pushed tag name
|
||||
run: |
|
||||
@ -79,7 +80,9 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ env.DOCKER_IMG }}:${{ github.ref_name }}
|
||||
tags: |
|
||||
${{ env.DOCKER_IMG }}:${{ github.ref_name }}
|
||||
${{ env.DOCKER_IMG }}:latest
|
||||
build-args: |
|
||||
VER_PKG={{ env.VER_PKG }}
|
||||
VER_PKG=${{ env.VER_PKG }}
|
||||
VERSION=${{ github.ref_name }}
|
||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -20,7 +20,13 @@
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
go.work.sum
|
||||
|
||||
.env
|
||||
|
||||
bin/*
|
||||
|
||||
config.y*ml
|
||||
docker-compose.yml
|
||||
|
||||
.vscode
|
||||
|
25
Makefile
25
Makefile
@ -1,14 +1,23 @@
|
||||
CMD_NAME := ambient-local-exporter
|
||||
|
||||
.PHONY: all test build docker install clean
|
||||
.PHONY: all test build docker install clean proto check_protoc
|
||||
|
||||
VERSION ?= development # Default to "development" if VERSION is not set
|
||||
PLATFORMS := linux/amd64 darwin/amd64 darwin/arm64
|
||||
APIVERSION := v1alpha1
|
||||
API_DIR := api/$(APIVERSION)
|
||||
PROTO_DIRS := $(wildcard proto/*)
|
||||
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
|
||||
OUTPUT_DIR := bin
|
||||
VER_PKG := gitea.libretechconsulting.com/rmcguire/go-app/pkg/config.Version
|
||||
DOCKER_IMG := gitea.libretechconsulting.com/rmcguire/ambient-local-exporter
|
||||
|
||||
all: test build docker
|
||||
all: proto test build docker
|
||||
|
||||
proto: check_protoc $(API_DIR)
|
||||
protoc --proto_path=proto \
|
||||
--go_out=$(API_DIR) --go_opt=paths=source_relative \
|
||||
--go-grpc_out=$(API_DIR) --go-grpc_opt=paths=source_relative \
|
||||
$(foreach dir, $(PROTO_DIRS), $(wildcard $(dir)/*.proto))
|
||||
|
||||
test:
|
||||
go test -v ./...
|
||||
@ -37,3 +46,13 @@ install:
|
||||
|
||||
clean:
|
||||
rm -rf bin/${CMD_NAME}
|
||||
|
||||
check_protoc:
|
||||
@if ! command -v protoc-gen-go > /dev/null; then \
|
||||
echo "Error: protoc-gen-go not found in PATH"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@if ! command -v protoc-gen-go-grpc > /dev/null; then \
|
||||
echo "Error: protoc-gen-go-grpc not found in PATH"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
@ -1,3 +1,3 @@
|
||||
# ambient-weather-local-exporter
|
||||
# ambient-local-exporter
|
||||
|
||||
A simple exporter that takes data from an Ambient Weather weather station or Weather Hub. Requires no internet connection, and does not use any cloud APIs.
|
27
TODO.md
27
TODO.md
@ -1,10 +1,23 @@
|
||||
# TODO
|
||||
|
||||
- [ ] Fix shutdown
|
||||
- [ ] Configuration for app
|
||||
- [ ] Makefile
|
||||
- [ ] Dockerfile
|
||||
- [ ] Finish implementing weather GRPC
|
||||
- [ ] Helm Chart
|
||||
- [ ] Gitea CI
|
||||
- [ ] Update README
|
||||
- [ ] Version flag
|
||||
- [ ] Add Grafana dashboard
|
||||
- [ ] Add new spans
|
||||
|
||||
## Done
|
||||
- [x] Add proxy to upstream support
|
||||
- [x] Fix wunderground 401
|
||||
- [x] Perform proxy calls in goroutines
|
||||
- [x] Configuration for app
|
||||
- [x] Configurable metric prefix
|
||||
- [x] Add device name field with ID/Key mappings
|
||||
- [x] Add device type field with ID/Key mappings
|
||||
- [x] Move EVERYTHING to pointers to support nil
|
||||
- [x] Consolidate battery status into one metric with device label
|
||||
- [x] Fix shutdown
|
||||
- [x] Add new fields from WS-2192
|
||||
- [x] Gitea CI
|
||||
- [x] Version flag
|
||||
- [x] Makefile
|
||||
- [x] Dockerfile
|
||||
|
752
api/v1alpha1/weather/weather.pb.go
Normal file
752
api/v1alpha1/weather/weather.pb.go
Normal file
@ -0,0 +1,752 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.5
|
||||
// protoc v5.29.3
|
||||
// source: weather/weather.proto
|
||||
|
||||
package weather
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type GetWeatherRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Opts *GetWeatherOpts `protobuf:"bytes,1,opt,name=opts,proto3" json:"opts,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetWeatherRequest) Reset() {
|
||||
*x = GetWeatherRequest{}
|
||||
mi := &file_weather_weather_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetWeatherRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetWeatherRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetWeatherRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_weather_weather_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetWeatherRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetWeatherRequest) Descriptor() ([]byte, []int) {
|
||||
return file_weather_weather_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GetWeatherRequest) GetOpts() *GetWeatherOpts {
|
||||
if x != nil {
|
||||
return x.Opts
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetWeatherResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
LastUpdated *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=last_updated,json=lastUpdated,proto3" json:"last_updated,omitempty"`
|
||||
WeatherUpdates []*WeatherUpdate `protobuf:"bytes,2,rep,name=weather_updates,json=weatherUpdates,proto3" json:"weather_updates,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetWeatherResponse) Reset() {
|
||||
*x = GetWeatherResponse{}
|
||||
mi := &file_weather_weather_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetWeatherResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetWeatherResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetWeatherResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_weather_weather_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetWeatherResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetWeatherResponse) Descriptor() ([]byte, []int) {
|
||||
return file_weather_weather_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GetWeatherResponse) GetLastUpdated() *timestamppb.Timestamp {
|
||||
if x != nil {
|
||||
return x.LastUpdated
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GetWeatherResponse) GetWeatherUpdates() []*WeatherUpdate {
|
||||
if x != nil {
|
||||
return x.WeatherUpdates
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetWeatherOpts struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
StationName *string `protobuf:"bytes,1,opt,name=station_name,json=stationName,proto3,oneof" json:"station_name,omitempty"`
|
||||
StationType *string `protobuf:"bytes,2,opt,name=station_type,json=stationType,proto3,oneof" json:"station_type,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetWeatherOpts) Reset() {
|
||||
*x = GetWeatherOpts{}
|
||||
mi := &file_weather_weather_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetWeatherOpts) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetWeatherOpts) ProtoMessage() {}
|
||||
|
||||
func (x *GetWeatherOpts) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_weather_weather_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetWeatherOpts.ProtoReflect.Descriptor instead.
|
||||
func (*GetWeatherOpts) Descriptor() ([]byte, []int) {
|
||||
return file_weather_weather_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *GetWeatherOpts) GetStationName() string {
|
||||
if x != nil && x.StationName != nil {
|
||||
return *x.StationName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetWeatherOpts) GetStationType() string {
|
||||
if x != nil && x.StationType != nil {
|
||||
return *x.StationType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type WeatherUpdate struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
StationName string `protobuf:"bytes,1,opt,name=station_name,json=stationName,proto3" json:"station_name,omitempty"`
|
||||
StationType string `protobuf:"bytes,2,opt,name=station_type,json=stationType,proto3" json:"station_type,omitempty"`
|
||||
StationId string `protobuf:"bytes,3,opt,name=station_id,json=stationId,proto3" json:"station_id,omitempty"`
|
||||
TempOutdoorF *float64 `protobuf:"fixed64,4,opt,name=temp_outdoor_f,json=tempOutdoorF,proto3,oneof" json:"temp_outdoor_f,omitempty"`
|
||||
TempIndoorF *float64 `protobuf:"fixed64,5,opt,name=temp_indoor_f,json=tempIndoorF,proto3,oneof" json:"temp_indoor_f,omitempty"`
|
||||
HumidityOutdoor *int32 `protobuf:"varint,6,opt,name=humidity_outdoor,json=humidityOutdoor,proto3,oneof" json:"humidity_outdoor,omitempty"`
|
||||
HumidityIndoor *int32 `protobuf:"varint,7,opt,name=humidity_indoor,json=humidityIndoor,proto3,oneof" json:"humidity_indoor,omitempty"`
|
||||
WindSpeedMph *float64 `protobuf:"fixed64,8,opt,name=wind_speed_mph,json=windSpeedMph,proto3,oneof" json:"wind_speed_mph,omitempty"`
|
||||
WindGustMph *float64 `protobuf:"fixed64,9,opt,name=wind_gust_mph,json=windGustMph,proto3,oneof" json:"wind_gust_mph,omitempty"`
|
||||
MaxDailyGust *float64 `protobuf:"fixed64,10,opt,name=max_daily_gust,json=maxDailyGust,proto3,oneof" json:"max_daily_gust,omitempty"`
|
||||
WindDir *int32 `protobuf:"varint,11,opt,name=wind_dir,json=windDir,proto3,oneof" json:"wind_dir,omitempty"`
|
||||
WindDirAvg_10M *int32 `protobuf:"varint,12,opt,name=wind_dir_avg_10m,json=windDirAvg10m,proto3,oneof" json:"wind_dir_avg_10m,omitempty"`
|
||||
Uv *int32 `protobuf:"varint,13,opt,name=uv,proto3,oneof" json:"uv,omitempty"`
|
||||
SolarRadiation *float64 `protobuf:"fixed64,14,opt,name=solar_radiation,json=solarRadiation,proto3,oneof" json:"solar_radiation,omitempty"`
|
||||
HourlyRainIn *float64 `protobuf:"fixed64,15,opt,name=hourly_rain_in,json=hourlyRainIn,proto3,oneof" json:"hourly_rain_in,omitempty"`
|
||||
EventRainIn *float64 `protobuf:"fixed64,16,opt,name=event_rain_in,json=eventRainIn,proto3,oneof" json:"event_rain_in,omitempty"`
|
||||
DailyRainIn *float64 `protobuf:"fixed64,17,opt,name=daily_rain_in,json=dailyRainIn,proto3,oneof" json:"daily_rain_in,omitempty"`
|
||||
WeeklyRainIn *float64 `protobuf:"fixed64,18,opt,name=weekly_rain_in,json=weeklyRainIn,proto3,oneof" json:"weekly_rain_in,omitempty"`
|
||||
MonthlyRainIn *float64 `protobuf:"fixed64,19,opt,name=monthly_rain_in,json=monthlyRainIn,proto3,oneof" json:"monthly_rain_in,omitempty"`
|
||||
YearlyRainIn *float64 `protobuf:"fixed64,20,opt,name=yearly_rain_in,json=yearlyRainIn,proto3,oneof" json:"yearly_rain_in,omitempty"`
|
||||
TotalRainIn *float64 `protobuf:"fixed64,21,opt,name=total_rain_in,json=totalRainIn,proto3,oneof" json:"total_rain_in,omitempty"`
|
||||
Batteries []*BatteryStatus `protobuf:"bytes,22,rep,name=batteries,proto3" json:"batteries,omitempty"`
|
||||
BaromRelativeIn *float64 `protobuf:"fixed64,23,opt,name=barom_relative_in,json=baromRelativeIn,proto3,oneof" json:"barom_relative_in,omitempty"`
|
||||
BaromAbsoluteIn *float64 `protobuf:"fixed64,24,opt,name=barom_absolute_in,json=baromAbsoluteIn,proto3,oneof" json:"barom_absolute_in,omitempty"`
|
||||
DewPointF *float64 `protobuf:"fixed64,25,opt,name=dew_point_f,json=dewPointF,proto3,oneof" json:"dew_point_f,omitempty"`
|
||||
WindChillF *float64 `protobuf:"fixed64,26,opt,name=wind_chill_f,json=windChillF,proto3,oneof" json:"wind_chill_f,omitempty"`
|
||||
TempHumiditySensors []*TempHumiditySensor `protobuf:"bytes,27,rep,name=temp_humidity_sensors,json=tempHumiditySensors,proto3" json:"temp_humidity_sensors,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) Reset() {
|
||||
*x = WeatherUpdate{}
|
||||
mi := &file_weather_weather_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*WeatherUpdate) ProtoMessage() {}
|
||||
|
||||
func (x *WeatherUpdate) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_weather_weather_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use WeatherUpdate.ProtoReflect.Descriptor instead.
|
||||
func (*WeatherUpdate) Descriptor() ([]byte, []int) {
|
||||
return file_weather_weather_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetStationName() string {
|
||||
if x != nil {
|
||||
return x.StationName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetStationType() string {
|
||||
if x != nil {
|
||||
return x.StationType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetStationId() string {
|
||||
if x != nil {
|
||||
return x.StationId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetTempOutdoorF() float64 {
|
||||
if x != nil && x.TempOutdoorF != nil {
|
||||
return *x.TempOutdoorF
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetTempIndoorF() float64 {
|
||||
if x != nil && x.TempIndoorF != nil {
|
||||
return *x.TempIndoorF
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetHumidityOutdoor() int32 {
|
||||
if x != nil && x.HumidityOutdoor != nil {
|
||||
return *x.HumidityOutdoor
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetHumidityIndoor() int32 {
|
||||
if x != nil && x.HumidityIndoor != nil {
|
||||
return *x.HumidityIndoor
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetWindSpeedMph() float64 {
|
||||
if x != nil && x.WindSpeedMph != nil {
|
||||
return *x.WindSpeedMph
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetWindGustMph() float64 {
|
||||
if x != nil && x.WindGustMph != nil {
|
||||
return *x.WindGustMph
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetMaxDailyGust() float64 {
|
||||
if x != nil && x.MaxDailyGust != nil {
|
||||
return *x.MaxDailyGust
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetWindDir() int32 {
|
||||
if x != nil && x.WindDir != nil {
|
||||
return *x.WindDir
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetWindDirAvg_10M() int32 {
|
||||
if x != nil && x.WindDirAvg_10M != nil {
|
||||
return *x.WindDirAvg_10M
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetUv() int32 {
|
||||
if x != nil && x.Uv != nil {
|
||||
return *x.Uv
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetSolarRadiation() float64 {
|
||||
if x != nil && x.SolarRadiation != nil {
|
||||
return *x.SolarRadiation
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetHourlyRainIn() float64 {
|
||||
if x != nil && x.HourlyRainIn != nil {
|
||||
return *x.HourlyRainIn
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetEventRainIn() float64 {
|
||||
if x != nil && x.EventRainIn != nil {
|
||||
return *x.EventRainIn
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetDailyRainIn() float64 {
|
||||
if x != nil && x.DailyRainIn != nil {
|
||||
return *x.DailyRainIn
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetWeeklyRainIn() float64 {
|
||||
if x != nil && x.WeeklyRainIn != nil {
|
||||
return *x.WeeklyRainIn
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetMonthlyRainIn() float64 {
|
||||
if x != nil && x.MonthlyRainIn != nil {
|
||||
return *x.MonthlyRainIn
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetYearlyRainIn() float64 {
|
||||
if x != nil && x.YearlyRainIn != nil {
|
||||
return *x.YearlyRainIn
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetTotalRainIn() float64 {
|
||||
if x != nil && x.TotalRainIn != nil {
|
||||
return *x.TotalRainIn
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetBatteries() []*BatteryStatus {
|
||||
if x != nil {
|
||||
return x.Batteries
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetBaromRelativeIn() float64 {
|
||||
if x != nil && x.BaromRelativeIn != nil {
|
||||
return *x.BaromRelativeIn
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetBaromAbsoluteIn() float64 {
|
||||
if x != nil && x.BaromAbsoluteIn != nil {
|
||||
return *x.BaromAbsoluteIn
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetDewPointF() float64 {
|
||||
if x != nil && x.DewPointF != nil {
|
||||
return *x.DewPointF
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetWindChillF() float64 {
|
||||
if x != nil && x.WindChillF != nil {
|
||||
return *x.WindChillF
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetTempHumiditySensors() []*TempHumiditySensor {
|
||||
if x != nil {
|
||||
return x.TempHumiditySensors
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Represents a temperature and humidity sensor
|
||||
type TempHumiditySensor struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
TempF *float64 `protobuf:"fixed64,2,opt,name=temp_f,json=tempF,proto3,oneof" json:"temp_f,omitempty"`
|
||||
Humidity *int32 `protobuf:"varint,3,opt,name=humidity,proto3,oneof" json:"humidity,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *TempHumiditySensor) Reset() {
|
||||
*x = TempHumiditySensor{}
|
||||
mi := &file_weather_weather_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *TempHumiditySensor) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*TempHumiditySensor) ProtoMessage() {}
|
||||
|
||||
func (x *TempHumiditySensor) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_weather_weather_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use TempHumiditySensor.ProtoReflect.Descriptor instead.
|
||||
func (*TempHumiditySensor) Descriptor() ([]byte, []int) {
|
||||
return file_weather_weather_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *TempHumiditySensor) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *TempHumiditySensor) GetTempF() float64 {
|
||||
if x != nil && x.TempF != nil {
|
||||
return *x.TempF
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *TempHumiditySensor) GetHumidity() int32 {
|
||||
if x != nil && x.Humidity != nil {
|
||||
return *x.Humidity
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Represents battery status for different components
|
||||
type BatteryStatus struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Component string `protobuf:"bytes,1,opt,name=component,proto3" json:"component,omitempty"`
|
||||
Status *int32 `protobuf:"varint,2,opt,name=status,proto3,oneof" json:"status,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *BatteryStatus) Reset() {
|
||||
*x = BatteryStatus{}
|
||||
mi := &file_weather_weather_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *BatteryStatus) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BatteryStatus) ProtoMessage() {}
|
||||
|
||||
func (x *BatteryStatus) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_weather_weather_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use BatteryStatus.ProtoReflect.Descriptor instead.
|
||||
func (*BatteryStatus) Descriptor() ([]byte, []int) {
|
||||
return file_weather_weather_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *BatteryStatus) GetComponent() string {
|
||||
if x != nil {
|
||||
return x.Component
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BatteryStatus) GetStatus() int32 {
|
||||
if x != nil && x.Status != nil {
|
||||
return *x.Status
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_weather_weather_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_weather_weather_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x15, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x2f, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65,
|
||||
0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74,
|
||||
0x2e, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
|
||||
0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x48, 0x0a, 0x11, 0x47, 0x65, 0x74,
|
||||
0x57, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x33,
|
||||
0x0a, 0x04, 0x6f, 0x70, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x61,
|
||||
0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x2e, 0x47,
|
||||
0x65, 0x74, 0x57, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x4f, 0x70, 0x74, 0x73, 0x52, 0x04, 0x6f,
|
||||
0x70, 0x74, 0x73, 0x22, 0x9c, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x57, 0x65, 0x61, 0x74, 0x68,
|
||||
0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0c, 0x6c, 0x61,
|
||||
0x73, 0x74, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x6c, 0x61,
|
||||
0x73, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x12, 0x47, 0x0a, 0x0f, 0x77, 0x65, 0x61,
|
||||
0x74, 0x68, 0x65, 0x72, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03,
|
||||
0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x77, 0x65, 0x61,
|
||||
0x74, 0x68, 0x65, 0x72, 0x2e, 0x57, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x55, 0x70, 0x64, 0x61,
|
||||
0x74, 0x65, 0x52, 0x0e, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x55, 0x70, 0x64, 0x61, 0x74,
|
||||
0x65, 0x73, 0x22, 0x82, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x57, 0x65, 0x61, 0x74, 0x68, 0x65,
|
||||
0x72, 0x4f, 0x70, 0x74, 0x73, 0x12, 0x26, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x73,
|
||||
0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x26, 0x0a,
|
||||
0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79,
|
||||
0x70, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x22, 0xb7, 0x0c, 0x0a, 0x0d, 0x57, 0x65, 0x61, 0x74,
|
||||
0x68, 0x65, 0x72, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c,
|
||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12,
|
||||
0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x29,
|
||||
0x0a, 0x0e, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x6f, 0x75, 0x74, 0x64, 0x6f, 0x6f, 0x72, 0x5f, 0x66,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x0c, 0x74, 0x65, 0x6d, 0x70, 0x4f, 0x75,
|
||||
0x74, 0x64, 0x6f, 0x6f, 0x72, 0x46, 0x88, 0x01, 0x01, 0x12, 0x27, 0x0a, 0x0d, 0x74, 0x65, 0x6d,
|
||||
0x70, 0x5f, 0x69, 0x6e, 0x64, 0x6f, 0x6f, 0x72, 0x5f, 0x66, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01,
|
||||
0x48, 0x01, 0x52, 0x0b, 0x74, 0x65, 0x6d, 0x70, 0x49, 0x6e, 0x64, 0x6f, 0x6f, 0x72, 0x46, 0x88,
|
||||
0x01, 0x01, 0x12, 0x2e, 0x0a, 0x10, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x5f, 0x6f,
|
||||
0x75, 0x74, 0x64, 0x6f, 0x6f, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x48, 0x02, 0x52, 0x0f,
|
||||
0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x4f, 0x75, 0x74, 0x64, 0x6f, 0x6f, 0x72, 0x88,
|
||||
0x01, 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x5f, 0x69,
|
||||
0x6e, 0x64, 0x6f, 0x6f, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x48, 0x03, 0x52, 0x0e, 0x68,
|
||||
0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x49, 0x6e, 0x64, 0x6f, 0x6f, 0x72, 0x88, 0x01, 0x01,
|
||||
0x12, 0x29, 0x0a, 0x0e, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x73, 0x70, 0x65, 0x65, 0x64, 0x5f, 0x6d,
|
||||
0x70, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, 0x01, 0x48, 0x04, 0x52, 0x0c, 0x77, 0x69, 0x6e, 0x64,
|
||||
0x53, 0x70, 0x65, 0x65, 0x64, 0x4d, 0x70, 0x68, 0x88, 0x01, 0x01, 0x12, 0x27, 0x0a, 0x0d, 0x77,
|
||||
0x69, 0x6e, 0x64, 0x5f, 0x67, 0x75, 0x73, 0x74, 0x5f, 0x6d, 0x70, 0x68, 0x18, 0x09, 0x20, 0x01,
|
||||
0x28, 0x01, 0x48, 0x05, 0x52, 0x0b, 0x77, 0x69, 0x6e, 0x64, 0x47, 0x75, 0x73, 0x74, 0x4d, 0x70,
|
||||
0x68, 0x88, 0x01, 0x01, 0x12, 0x29, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x5f, 0x64, 0x61, 0x69, 0x6c,
|
||||
0x79, 0x5f, 0x67, 0x75, 0x73, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x01, 0x48, 0x06, 0x52, 0x0c,
|
||||
0x6d, 0x61, 0x78, 0x44, 0x61, 0x69, 0x6c, 0x79, 0x47, 0x75, 0x73, 0x74, 0x88, 0x01, 0x01, 0x12,
|
||||
0x1e, 0x0a, 0x08, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x64, 0x69, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28,
|
||||
0x05, 0x48, 0x07, 0x52, 0x07, 0x77, 0x69, 0x6e, 0x64, 0x44, 0x69, 0x72, 0x88, 0x01, 0x01, 0x12,
|
||||
0x2c, 0x0a, 0x10, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x64, 0x69, 0x72, 0x5f, 0x61, 0x76, 0x67, 0x5f,
|
||||
0x31, 0x30, 0x6d, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x48, 0x08, 0x52, 0x0d, 0x77, 0x69, 0x6e,
|
||||
0x64, 0x44, 0x69, 0x72, 0x41, 0x76, 0x67, 0x31, 0x30, 0x6d, 0x88, 0x01, 0x01, 0x12, 0x13, 0x0a,
|
||||
0x02, 0x75, 0x76, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x48, 0x09, 0x52, 0x02, 0x75, 0x76, 0x88,
|
||||
0x01, 0x01, 0x12, 0x2c, 0x0a, 0x0f, 0x73, 0x6f, 0x6c, 0x61, 0x72, 0x5f, 0x72, 0x61, 0x64, 0x69,
|
||||
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x01, 0x48, 0x0a, 0x52, 0x0e, 0x73,
|
||||
0x6f, 0x6c, 0x61, 0x72, 0x52, 0x61, 0x64, 0x69, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x88, 0x01, 0x01,
|
||||
0x12, 0x29, 0x0a, 0x0e, 0x68, 0x6f, 0x75, 0x72, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f,
|
||||
0x69, 0x6e, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x01, 0x48, 0x0b, 0x52, 0x0c, 0x68, 0x6f, 0x75, 0x72,
|
||||
0x6c, 0x79, 0x52, 0x61, 0x69, 0x6e, 0x49, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x27, 0x0a, 0x0d, 0x65,
|
||||
0x76, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x18, 0x10, 0x20, 0x01,
|
||||
0x28, 0x01, 0x48, 0x0c, 0x52, 0x0b, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x61, 0x69, 0x6e, 0x49,
|
||||
0x6e, 0x88, 0x01, 0x01, 0x12, 0x27, 0x0a, 0x0d, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x5f, 0x72, 0x61,
|
||||
0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x18, 0x11, 0x20, 0x01, 0x28, 0x01, 0x48, 0x0d, 0x52, 0x0b, 0x64,
|
||||
0x61, 0x69, 0x6c, 0x79, 0x52, 0x61, 0x69, 0x6e, 0x49, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x29, 0x0a,
|
||||
0x0e, 0x77, 0x65, 0x65, 0x6b, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x18,
|
||||
0x12, 0x20, 0x01, 0x28, 0x01, 0x48, 0x0e, 0x52, 0x0c, 0x77, 0x65, 0x65, 0x6b, 0x6c, 0x79, 0x52,
|
||||
0x61, 0x69, 0x6e, 0x49, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x2b, 0x0a, 0x0f, 0x6d, 0x6f, 0x6e, 0x74,
|
||||
0x68, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x18, 0x13, 0x20, 0x01, 0x28,
|
||||
0x01, 0x48, 0x0f, 0x52, 0x0d, 0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x52, 0x61, 0x69, 0x6e,
|
||||
0x49, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x29, 0x0a, 0x0e, 0x79, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x5f,
|
||||
0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x18, 0x14, 0x20, 0x01, 0x28, 0x01, 0x48, 0x10, 0x52,
|
||||
0x0c, 0x79, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x52, 0x61, 0x69, 0x6e, 0x49, 0x6e, 0x88, 0x01, 0x01,
|
||||
0x12, 0x27, 0x0a, 0x0d, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69,
|
||||
0x6e, 0x18, 0x15, 0x20, 0x01, 0x28, 0x01, 0x48, 0x11, 0x52, 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c,
|
||||
0x52, 0x61, 0x69, 0x6e, 0x49, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x3c, 0x0a, 0x09, 0x62, 0x61, 0x74,
|
||||
0x74, 0x65, 0x72, 0x69, 0x65, 0x73, 0x18, 0x16, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x61,
|
||||
0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x2e, 0x42,
|
||||
0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x09, 0x62, 0x61,
|
||||
0x74, 0x74, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x2f, 0x0a, 0x11, 0x62, 0x61, 0x72, 0x6f, 0x6d,
|
||||
0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x18, 0x17, 0x20, 0x01,
|
||||
0x28, 0x01, 0x48, 0x12, 0x52, 0x0f, 0x62, 0x61, 0x72, 0x6f, 0x6d, 0x52, 0x65, 0x6c, 0x61, 0x74,
|
||||
0x69, 0x76, 0x65, 0x49, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x2f, 0x0a, 0x11, 0x62, 0x61, 0x72, 0x6f,
|
||||
0x6d, 0x5f, 0x61, 0x62, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x65, 0x5f, 0x69, 0x6e, 0x18, 0x18, 0x20,
|
||||
0x01, 0x28, 0x01, 0x48, 0x13, 0x52, 0x0f, 0x62, 0x61, 0x72, 0x6f, 0x6d, 0x41, 0x62, 0x73, 0x6f,
|
||||
0x6c, 0x75, 0x74, 0x65, 0x49, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x23, 0x0a, 0x0b, 0x64, 0x65, 0x77,
|
||||
0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x66, 0x18, 0x19, 0x20, 0x01, 0x28, 0x01, 0x48, 0x14,
|
||||
0x52, 0x09, 0x64, 0x65, 0x77, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x46, 0x88, 0x01, 0x01, 0x12, 0x25,
|
||||
0x0a, 0x0c, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x63, 0x68, 0x69, 0x6c, 0x6c, 0x5f, 0x66, 0x18, 0x1a,
|
||||
0x20, 0x01, 0x28, 0x01, 0x48, 0x15, 0x52, 0x0a, 0x77, 0x69, 0x6e, 0x64, 0x43, 0x68, 0x69, 0x6c,
|
||||
0x6c, 0x46, 0x88, 0x01, 0x01, 0x12, 0x57, 0x0a, 0x15, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x68, 0x75,
|
||||
0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x5f, 0x73, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x73, 0x18, 0x1b,
|
||||
0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x77,
|
||||
0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x48, 0x75, 0x6d, 0x69, 0x64,
|
||||
0x69, 0x74, 0x79, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x52, 0x13, 0x74, 0x65, 0x6d, 0x70, 0x48,
|
||||
0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x73, 0x42, 0x11,
|
||||
0x0a, 0x0f, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x6f, 0x75, 0x74, 0x64, 0x6f, 0x6f, 0x72, 0x5f,
|
||||
0x66, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x69, 0x6e, 0x64, 0x6f, 0x6f,
|
||||
0x72, 0x5f, 0x66, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79,
|
||||
0x5f, 0x6f, 0x75, 0x74, 0x64, 0x6f, 0x6f, 0x72, 0x42, 0x12, 0x0a, 0x10, 0x5f, 0x68, 0x75, 0x6d,
|
||||
0x69, 0x64, 0x69, 0x74, 0x79, 0x5f, 0x69, 0x6e, 0x64, 0x6f, 0x6f, 0x72, 0x42, 0x11, 0x0a, 0x0f,
|
||||
0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x73, 0x70, 0x65, 0x65, 0x64, 0x5f, 0x6d, 0x70, 0x68, 0x42,
|
||||
0x10, 0x0a, 0x0e, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x67, 0x75, 0x73, 0x74, 0x5f, 0x6d, 0x70,
|
||||
0x68, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x64, 0x61, 0x69, 0x6c, 0x79, 0x5f,
|
||||
0x67, 0x75, 0x73, 0x74, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x64, 0x69,
|
||||
0x72, 0x42, 0x13, 0x0a, 0x11, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x64, 0x69, 0x72, 0x5f, 0x61,
|
||||
0x76, 0x67, 0x5f, 0x31, 0x30, 0x6d, 0x42, 0x05, 0x0a, 0x03, 0x5f, 0x75, 0x76, 0x42, 0x12, 0x0a,
|
||||
0x10, 0x5f, 0x73, 0x6f, 0x6c, 0x61, 0x72, 0x5f, 0x72, 0x61, 0x64, 0x69, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x68, 0x6f, 0x75, 0x72, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69,
|
||||
0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x72,
|
||||
0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x64, 0x61, 0x69, 0x6c, 0x79,
|
||||
0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x11, 0x0a, 0x0f, 0x5f, 0x77, 0x65, 0x65,
|
||||
0x6b, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x12, 0x0a, 0x10, 0x5f,
|
||||
0x6d, 0x6f, 0x6e, 0x74, 0x68, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x42,
|
||||
0x11, 0x0a, 0x0f, 0x5f, 0x79, 0x65, 0x61, 0x72, 0x6c, 0x79, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x5f,
|
||||
0x69, 0x6e, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x72, 0x61, 0x69,
|
||||
0x6e, 0x5f, 0x69, 0x6e, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x62, 0x61, 0x72, 0x6f, 0x6d, 0x5f, 0x72,
|
||||
0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x42, 0x14, 0x0a, 0x12, 0x5f, 0x62,
|
||||
0x61, 0x72, 0x6f, 0x6d, 0x5f, 0x61, 0x62, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x65, 0x5f, 0x69, 0x6e,
|
||||
0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x64, 0x65, 0x77, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x66,
|
||||
0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x5f, 0x63, 0x68, 0x69, 0x6c, 0x6c, 0x5f,
|
||||
0x66, 0x22, 0x7d, 0x0a, 0x12, 0x54, 0x65, 0x6d, 0x70, 0x48, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74,
|
||||
0x79, 0x53, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x06, 0x74,
|
||||
0x65, 0x6d, 0x70, 0x5f, 0x66, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x05, 0x74,
|
||||
0x65, 0x6d, 0x70, 0x46, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x68, 0x75, 0x6d, 0x69, 0x64,
|
||||
0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01, 0x52, 0x08, 0x68, 0x75, 0x6d,
|
||||
0x69, 0x64, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x74, 0x65, 0x6d,
|
||||
0x70, 0x5f, 0x66, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x68, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79,
|
||||
0x22, 0x55, 0x0a, 0x0d, 0x42, 0x61, 0x74, 0x74, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x75,
|
||||
0x73, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12,
|
||||
0x1b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48,
|
||||
0x00, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x88, 0x01, 0x01, 0x42, 0x09, 0x0a, 0x07,
|
||||
0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x54, 0x5a, 0x52, 0x67, 0x69, 0x74, 0x65, 0x61,
|
||||
0x2e, 0x6c, 0x69, 0x62, 0x72, 0x65, 0x74, 0x65, 0x63, 0x68, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c,
|
||||
0x74, 0x69, 0x6e, 0x67, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x6d, 0x63, 0x67, 0x75, 0x69, 0x72,
|
||||
0x65, 0x2f, 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x2d, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x2d,
|
||||
0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x61,
|
||||
0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
})
|
||||
|
||||
var (
|
||||
file_weather_weather_proto_rawDescOnce sync.Once
|
||||
file_weather_weather_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_weather_weather_proto_rawDescGZIP() []byte {
|
||||
file_weather_weather_proto_rawDescOnce.Do(func() {
|
||||
file_weather_weather_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_weather_weather_proto_rawDesc), len(file_weather_weather_proto_rawDesc)))
|
||||
})
|
||||
return file_weather_weather_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_weather_weather_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_weather_weather_proto_goTypes = []any{
|
||||
(*GetWeatherRequest)(nil), // 0: ambient.weather.GetWeatherRequest
|
||||
(*GetWeatherResponse)(nil), // 1: ambient.weather.GetWeatherResponse
|
||||
(*GetWeatherOpts)(nil), // 2: ambient.weather.GetWeatherOpts
|
||||
(*WeatherUpdate)(nil), // 3: ambient.weather.WeatherUpdate
|
||||
(*TempHumiditySensor)(nil), // 4: ambient.weather.TempHumiditySensor
|
||||
(*BatteryStatus)(nil), // 5: ambient.weather.BatteryStatus
|
||||
(*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp
|
||||
}
|
||||
var file_weather_weather_proto_depIdxs = []int32{
|
||||
2, // 0: ambient.weather.GetWeatherRequest.opts:type_name -> ambient.weather.GetWeatherOpts
|
||||
6, // 1: ambient.weather.GetWeatherResponse.last_updated:type_name -> google.protobuf.Timestamp
|
||||
3, // 2: ambient.weather.GetWeatherResponse.weather_updates:type_name -> ambient.weather.WeatherUpdate
|
||||
5, // 3: ambient.weather.WeatherUpdate.batteries:type_name -> ambient.weather.BatteryStatus
|
||||
4, // 4: ambient.weather.WeatherUpdate.temp_humidity_sensors:type_name -> ambient.weather.TempHumiditySensor
|
||||
5, // [5:5] is the sub-list for method output_type
|
||||
5, // [5:5] is the sub-list for method input_type
|
||||
5, // [5:5] is the sub-list for extension type_name
|
||||
5, // [5:5] is the sub-list for extension extendee
|
||||
0, // [0:5] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_weather_weather_proto_init() }
|
||||
func file_weather_weather_proto_init() {
|
||||
if File_weather_weather_proto != nil {
|
||||
return
|
||||
}
|
||||
file_weather_weather_proto_msgTypes[2].OneofWrappers = []any{}
|
||||
file_weather_weather_proto_msgTypes[3].OneofWrappers = []any{}
|
||||
file_weather_weather_proto_msgTypes[4].OneofWrappers = []any{}
|
||||
file_weather_weather_proto_msgTypes[5].OneofWrappers = []any{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_weather_weather_proto_rawDesc), len(file_weather_weather_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 6,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_weather_weather_proto_goTypes,
|
||||
DependencyIndexes: file_weather_weather_proto_depIdxs,
|
||||
MessageInfos: file_weather_weather_proto_msgTypes,
|
||||
}.Build()
|
||||
File_weather_weather_proto = out.File
|
||||
file_weather_weather_proto_goTypes = nil
|
||||
file_weather_weather_proto_depIdxs = nil
|
||||
}
|
82
api/v1alpha1/weather/weather_service.pb.go
Normal file
82
api/v1alpha1/weather/weather_service.pb.go
Normal file
@ -0,0 +1,82 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.5
|
||||
// protoc v5.29.3
|
||||
// source: weather/weather_service.proto
|
||||
|
||||
package weather
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
var File_weather_weather_service_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_weather_weather_service_proto_rawDesc = string([]byte{
|
||||
0x0a, 0x1d, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x2f, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65,
|
||||
0x72, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x0f, 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72,
|
||||
0x1a, 0x15, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x2f, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65,
|
||||
0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x73, 0x0a, 0x1a, 0x41, 0x6d, 0x62, 0x69, 0x65,
|
||||
0x6e, 0x74, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x57, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x53, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x55, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x57, 0x65, 0x61, 0x74,
|
||||
0x68, 0x65, 0x72, 0x12, 0x22, 0x2e, 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x77, 0x65,
|
||||
0x61, 0x74, 0x68, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e,
|
||||
0x74, 0x2e, 0x77, 0x65, 0x61, 0x74, 0x68, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x57, 0x65, 0x61,
|
||||
0x74, 0x68, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x54, 0x5a, 0x52,
|
||||
0x67, 0x69, 0x74, 0x65, 0x61, 0x2e, 0x6c, 0x69, 0x62, 0x72, 0x65, 0x74, 0x65, 0x63, 0x68, 0x63,
|
||||
0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x6d,
|
||||
0x63, 0x67, 0x75, 0x69, 0x72, 0x65, 0x2f, 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x2d, 0x6c,
|
||||
0x6f, 0x63, 0x61, 0x6c, 0x2d, 0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x2f, 0x61, 0x70,
|
||||
0x69, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x77, 0x65, 0x61, 0x74, 0x68,
|
||||
0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
})
|
||||
|
||||
var file_weather_weather_service_proto_goTypes = []any{
|
||||
(*GetWeatherRequest)(nil), // 0: ambient.weather.GetWeatherRequest
|
||||
(*GetWeatherResponse)(nil), // 1: ambient.weather.GetWeatherResponse
|
||||
}
|
||||
var file_weather_weather_service_proto_depIdxs = []int32{
|
||||
0, // 0: ambient.weather.AmbientLocalWeatherService.GetWeather:input_type -> ambient.weather.GetWeatherRequest
|
||||
1, // 1: ambient.weather.AmbientLocalWeatherService.GetWeather:output_type -> ambient.weather.GetWeatherResponse
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_weather_weather_service_proto_init() }
|
||||
func file_weather_weather_service_proto_init() {
|
||||
if File_weather_weather_service_proto != nil {
|
||||
return
|
||||
}
|
||||
file_weather_weather_proto_init()
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_weather_weather_service_proto_rawDesc), len(file_weather_weather_service_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 0,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_weather_weather_service_proto_goTypes,
|
||||
DependencyIndexes: file_weather_weather_service_proto_depIdxs,
|
||||
}.Build()
|
||||
File_weather_weather_service_proto = out.File
|
||||
file_weather_weather_service_proto_goTypes = nil
|
||||
file_weather_weather_service_proto_depIdxs = nil
|
||||
}
|
122
api/v1alpha1/weather/weather_service_grpc.pb.go
Normal file
122
api/v1alpha1/weather/weather_service_grpc.pb.go
Normal file
@ -0,0 +1,122 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.29.3
|
||||
// source: weather/weather_service.proto
|
||||
|
||||
package weather
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
AmbientLocalWeatherService_GetWeather_FullMethodName = "/ambient.weather.AmbientLocalWeatherService/GetWeather"
|
||||
)
|
||||
|
||||
// AmbientLocalWeatherServiceClient is the client API for AmbientLocalWeatherService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type AmbientLocalWeatherServiceClient interface {
|
||||
GetWeather(ctx context.Context, in *GetWeatherRequest, opts ...grpc.CallOption) (*GetWeatherResponse, error)
|
||||
}
|
||||
|
||||
type ambientLocalWeatherServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAmbientLocalWeatherServiceClient(cc grpc.ClientConnInterface) AmbientLocalWeatherServiceClient {
|
||||
return &ambientLocalWeatherServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *ambientLocalWeatherServiceClient) GetWeather(ctx context.Context, in *GetWeatherRequest, opts ...grpc.CallOption) (*GetWeatherResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetWeatherResponse)
|
||||
err := c.cc.Invoke(ctx, AmbientLocalWeatherService_GetWeather_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AmbientLocalWeatherServiceServer is the server API for AmbientLocalWeatherService service.
|
||||
// All implementations must embed UnimplementedAmbientLocalWeatherServiceServer
|
||||
// for forward compatibility.
|
||||
type AmbientLocalWeatherServiceServer interface {
|
||||
GetWeather(context.Context, *GetWeatherRequest) (*GetWeatherResponse, error)
|
||||
mustEmbedUnimplementedAmbientLocalWeatherServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedAmbientLocalWeatherServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedAmbientLocalWeatherServiceServer struct{}
|
||||
|
||||
func (UnimplementedAmbientLocalWeatherServiceServer) GetWeather(context.Context, *GetWeatherRequest) (*GetWeatherResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetWeather not implemented")
|
||||
}
|
||||
func (UnimplementedAmbientLocalWeatherServiceServer) mustEmbedUnimplementedAmbientLocalWeatherServiceServer() {
|
||||
}
|
||||
func (UnimplementedAmbientLocalWeatherServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeAmbientLocalWeatherServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to AmbientLocalWeatherServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeAmbientLocalWeatherServiceServer interface {
|
||||
mustEmbedUnimplementedAmbientLocalWeatherServiceServer()
|
||||
}
|
||||
|
||||
func RegisterAmbientLocalWeatherServiceServer(s grpc.ServiceRegistrar, srv AmbientLocalWeatherServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedAmbientLocalWeatherServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&AmbientLocalWeatherService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _AmbientLocalWeatherService_GetWeather_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetWeatherRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AmbientLocalWeatherServiceServer).GetWeather(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AmbientLocalWeatherService_GetWeather_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AmbientLocalWeatherServiceServer).GetWeather(ctx, req.(*GetWeatherRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// AmbientLocalWeatherService_ServiceDesc is the grpc.ServiceDesc for AmbientLocalWeatherService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var AmbientLocalWeatherService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "ambient.weather.AmbientLocalWeatherService",
|
||||
HandlerType: (*AmbientLocalWeatherServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetWeather",
|
||||
Handler: _AmbientLocalWeatherService_GetWeather_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "weather/weather_service.proto",
|
||||
}
|
@ -10,6 +10,10 @@ services:
|
||||
APP_LOG_FORMAT: json ## console, json
|
||||
APP_LOG_TIME_FORMAT: rfc3339 ## long, short, unix, rfc3339, off
|
||||
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_METRIC_INTERVAL_SECS: 30
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel.libretechconsulting.com:4317 # Set to your otel collector
|
5059
contrib/grafana-dashboard.json
Normal file
5059
contrib/grafana-dashboard.json
Normal file
File diff suppressed because it is too large
Load Diff
8
contrib/unset_env.sh
Executable file
8
contrib/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
|
26
docker-compose-sample.yml
Normal file
26
docker-compose-sample.yml
Normal file
@ -0,0 +1,26 @@
|
||||
name: Ambient Local Exporter
|
||||
services:
|
||||
ambient-local-exporter:
|
||||
build: .
|
||||
ports:
|
||||
- 8080:8080
|
||||
volumes:
|
||||
- ./config.yaml:/app/config.yaml
|
||||
command:
|
||||
- -config
|
||||
- /app/config.yaml
|
||||
environment:
|
||||
APP_NAME: ambient-local-exporter
|
||||
APP_LOG_LEVEL: debug ## For testing only
|
||||
APP_LOG_FORMAT: json ## console, json
|
||||
APP_LOG_TIME_FORMAT: rfc3339 ## long, short, unix, rfc3339, off
|
||||
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_METRIC_INTERVAL_SECS: 30
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel.libretechconsulting.com:4317 # Set to your otel collector
|
||||
OTEL_SERVICE_NAME: ambient-local-exporter
|
||||
OTEL_RESOURCE_ATTRIBUTES: "env=development,service.version=(devel)"
|
60
go.mod
60
go.mod
@ -1,51 +1,55 @@
|
||||
module gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter
|
||||
module gitea.libretechconsulting.com/rmcguire/ambient-local-exporter
|
||||
|
||||
go 1.23.4
|
||||
|
||||
require (
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.1
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.6.3
|
||||
github.com/go-resty/resty/v2 v2.16.5
|
||||
github.com/gorilla/schema v1.4.1
|
||||
github.com/rs/zerolog v1.33.0
|
||||
go.opentelemetry.io/otel v1.33.0
|
||||
go.opentelemetry.io/otel/metric v1.33.0
|
||||
golang.org/x/sys v0.29.0
|
||||
go.opentelemetry.io/otel v1.35.0
|
||||
go.opentelemetry.io/otel/metric v1.35.0
|
||||
go.opentelemetry.io/otel/trace v1.35.0
|
||||
golang.org/x/sys v0.31.0
|
||||
google.golang.org/grpc v1.71.0
|
||||
google.golang.org/protobuf v1.36.5
|
||||
k8s.io/utils v0.0.0-20241210054802-24370beab758
|
||||
)
|
||||
|
||||
require (
|
||||
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/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.1 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
|
||||
github.com/klauspost/compress v1.18.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/prometheus/client_golang v1.20.5 // indirect
|
||||
github.com/prometheus/client_golang v1.21.1 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.61.0 // indirect
|
||||
github.com/prometheus/common v0.62.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.33.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.55.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.33.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.33.0 // indirect
|
||||
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
|
||||
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/grpc v1.69.2 // indirect
|
||||
google.golang.org/protobuf v1.36.1 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.57.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.35.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
|
||||
golang.org/x/net v0.37.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
127
go.sum
127
go.sum
@ -1,11 +1,13 @@
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.0 h1:H4TMgQ463oRNOyoi0FAvfGtOoDn651zNZStxM+sdNuU=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.0/go.mod h1:p0ajkpFvzzD6VZ4xSjuowtwGRb1DjMfo/iG6LyFqFCs=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.1 h1:Hrxqi1tqz8mf0baBsWgFe/S4jyMtIuPqH2FlanJUMNc=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.1.1/go.mod h1:p0ajkpFvzzD6VZ4xSjuowtwGRb1DjMfo/iG6LyFqFCs=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.6.0 h1:XIqk2xpKZ+GzCyh3ZpST93nu+WqteXBPCRcWVliEiks=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.6.0/go.mod h1:S3/vdMEiRWWIdD0Fr+tjJc627VzxNzO4Ia2HgTBXe+g=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.6.2 h1:vpEdZu7WI8qIil5NLf6OUF/Tk8+3txZ7fTv1NRRnOoc=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.6.2/go.mod h1:S3/vdMEiRWWIdD0Fr+tjJc627VzxNzO4Ia2HgTBXe+g=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.6.3 h1:dXYHJxK/1vmWBj1wqbqEUncFt3O92agy9gNWoa9NpA0=
|
||||
gitea.libretechconsulting.com/rmcguire/go-app v0.6.3/go.mod h1:S3/vdMEiRWWIdD0Fr+tjJc627VzxNzO4Ia2HgTBXe+g=
|
||||
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/v9 v9.0.0 h1:SI6JNsOA+y5gj9njpgybykATIylrRMklbs5ch6wO6pc=
|
||||
github.com/caarlos0/env/v9 v9.0.0/go.mod h1:ye5mlCVMYh6tZ+vCgrs/B95sj88cg5Tlnc0XIzgZ020=
|
||||
github.com/caarlos0/env/v11 v11.3.1 h1:cArPWC15hWmEt+gWk7YBi7lEXTXCvpaSdCiZE2X5mCA=
|
||||
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/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
@ -20,27 +22,32 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-resty/resty/v2 v2.16.5 h1:hBKqmWrr7uRc3euHVqmh1HTHcKn99Smr7o5spptdhTM=
|
||||
github.com/go-resty/resty/v2 v2.16.5/go.mod h1:hkJtXbA2iKHzJheXYvQ8snQES5ZLGKMwQ07xAwp/fiA=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E=
|
||||
github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ=
|
||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.1 h1:KcFzXwzM/kGhIRHvc8jdixfIJjVzuUJdnv+5xsPutog=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.1/go.mod h1:qOchhhIlmRcqk/O9uCo/puJlyo07YINaIqdZfZG3Jkc=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo=
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI=
|
||||
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
@ -50,12 +57,12 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y=
|
||||
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
|
||||
github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk=
|
||||
github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFSRQQ=
|
||||
github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s=
|
||||
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
|
||||
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
@ -67,53 +74,59 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 h1:yd02MEjBdJkG3uabWP9apV+OuWRIXGDuJEUJbOHmCFU=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0/go.mod h1:umTcuxiv1n/s/S6/c2AT/g2CQ7u5C59sHDNmfSwgz7Q=
|
||||
go.opentelemetry.io/otel v1.33.0 h1:/FerN9bax5LoK51X/sI0SVYrjSE0/yUL7DpxW4K3FWw=
|
||||
go.opentelemetry.io/otel v1.33.0/go.mod h1:SUUkR6csvUQl+yjReHu5uM3EtVV7MBm5FHKRlNx4I8I=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.33.0 h1:7F29RDmnlqk6B5d+sUqemt8TBfDqxryYW5gX6L74RFA=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.33.0/go.mod h1:ZiGDq7xwDMKmWDrN1XsXAj0iC7hns+2DhxBFSncNHSE=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 h1:Vh5HayB/0HHfOQA7Ctx69E/Y/DcQSMPpKANYVMQ7fBA=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0/go.mod h1:cpgtDBaqD/6ok/UG0jT15/uKjAY8mRA53diogHBg3UI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 h1:5pojmb1U1AogINhN3SurB+zm/nIcusopeBNp42f45QM=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0/go.mod h1:57gTHJSE5S1tqg+EKsLPlTWhpHMsWlVmer+LA926XiA=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.55.0 h1:sSPw658Lk2NWAv74lkD3B/RSDb+xRFx46GjkrL3VUZo=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.55.0/go.mod h1:nC00vyCmQixoeaxF6KNyP42II/RHa9UdruK02qBmHvI=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.33.0 h1:FiOTYABOX4tdzi8A0+mtzcsTmi6WBOxk66u0f1Mj9Gs=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.33.0/go.mod h1:xyo5rS8DgzV0Jtsht+LCEMwyiDbjpsxBpWETwFRF0/4=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.33.0 h1:W5AWUn/IVe8RFb5pZx1Uh9Laf/4+Qmm4kJL5zPuvR+0=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.33.0/go.mod h1:mzKxJywMNBdEX8TSJais3NnsVZUaJ+bAy6UxPTng2vk=
|
||||
go.opentelemetry.io/otel/metric v1.33.0 h1:r+JOocAyeRVXD8lZpjdQjzMadVZp2M4WmQ+5WtEnklQ=
|
||||
go.opentelemetry.io/otel/metric v1.33.0/go.mod h1:L9+Fyctbp6HFTddIxClbQkjtubW6O9QS3Ann/M82u6M=
|
||||
go.opentelemetry.io/otel/sdk v1.33.0 h1:iax7M131HuAm9QkZotNHEfstof92xM+N8sr3uHXc2IM=
|
||||
go.opentelemetry.io/otel/sdk v1.33.0/go.mod h1:A1Q5oi7/9XaMlIWzPSxLRWOI8nG3FnzHJNbiENQuihM=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.33.0 h1:Gs5VK9/WUJhNXZgn8MR6ITatvAmKeIuCtNbsP3JkNqU=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.33.0/go.mod h1:dL5ykHZmm1B1nVRk9dDjChwDmt81MjVp3gLkQRwKf/Q=
|
||||
go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qqW2d/s=
|
||||
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/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0 h1:x7wzEgXfnzJcHDwStJT+mxOz4etr2EcexjqhBvmoakw=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0/go.mod h1:rg+RlpR5dKwaS95IyyZqj5Wd4E13lk/msnTS0Xl9lJM=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 h1:sbiXRNDSWJOTobXh5HyQKjq6wUC5tNybqjIqDpAY4CU=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0/go.mod h1:69uWxva0WgAA/4bu2Yy70SLDBwZXuQ6PbBpbsa5iZrQ=
|
||||
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
|
||||
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.35.0 h1:QcFwRrZLc82r8wODjvyCbP7Ifp3UANaBSmhDSFjnqSc=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.35.0/go.mod h1:CXIWhUomyWBG/oY2/r/kLp6K/cmx9e/7DLpBuuGdLCA=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 h1:1fTNlAIJZGWLP5FVu0fikVry1IsiUnXjf7QFvoNN3Xw=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0/go.mod h1:zjPK58DtkqQFn+YUMbx0M2XV3QgKU0gS9LeGohREyK4=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0 h1:m639+BofXTvcY1q8CGs4ItwQarYtJPOWmVobfM1HpVI=
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.35.0/go.mod h1:LjReUci/F4BUyv+y4dwnq3h/26iNOeC3wAIqgvTIZVo=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.57.0 h1:AHh/lAP1BHrY5gBwk8ncc25FXWm/gmmY3BX258z5nuk=
|
||||
go.opentelemetry.io/otel/exporters/prometheus v0.57.0/go.mod h1:QpFWz1QxqevfjwzYdbMb4Y1NnlJvqSGwyuU0B4iuc9c=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.35.0 h1:PB3Zrjs1sG1GBX51SXyTSoOTqcDglmsk7nT6tkKPb/k=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v1.35.0/go.mod h1:U2R3XyVPzn0WX7wOIypPuptulsMcPDPs/oiSVOMVnHY=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.35.0 h1:T0Ec2E+3YZf5bgTNQVet8iTDW7oIk03tXHq+wkwIDnE=
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.35.0/go.mod h1:30v2gqH+vYGJsesLWFov8u47EpYTcIQcBjKpI6pJThg=
|
||||
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
|
||||
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
|
||||
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
|
||||
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
|
||||
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
|
||||
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.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
|
||||
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
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=
|
||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
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/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/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=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
|
||||
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb h1:p31xT4yrYrSM/G4Sn2+TNUkVhFCbG9y8itM2S6Th950=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:jbe3Bkdp+Dh2IrslsFCklNhweNTBgSYanP1UXhJDhKg=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb h1:TLPQVbx1GJ8VKZxz52VAxl1EBgKXXbTiU9Fc5fZeLn4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:LuRYeWDFV6WOn90g357N17oMCaxpgCnbi/44qJvDn2I=
|
||||
google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg=
|
||||
google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec=
|
||||
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
|
||||
google.golang.org/protobuf v1.36.5/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=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJJI8IUa1AmH/qa0=
|
||||
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
|
||||
|
49
main.go
49
main.go
@ -6,25 +6,42 @@ import (
|
||||
"os/signal"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/app"
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv"
|
||||
grpcopts "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/grpc/opts"
|
||||
httpopts "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/http/opts"
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/ambient"
|
||||
weatherpb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient/ambienthttp"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient/config"
|
||||
weathergrpc "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather/grpc"
|
||||
)
|
||||
|
||||
const defaultMetricPrefix = "weather"
|
||||
|
||||
func main() {
|
||||
ctx, cncl := signal.NotifyContext(context.Background(), os.Kill, unix.SIGTERM)
|
||||
ctx, cncl := signal.NotifyContext(context.Background(), os.Kill, os.Interrupt, unix.SIGTERM)
|
||||
defer cncl()
|
||||
|
||||
ctx = app.MustSetupConfigAndLogging(ctx)
|
||||
// Config type for app, which implements go-app/config.AppConfig
|
||||
awConfig := &config.AmbientLocalExporterConfig{
|
||||
MetricPrefix: defaultMetricPrefix,
|
||||
WeatherStations: make([]config.WeatherStation, 0),
|
||||
}
|
||||
|
||||
aw := ambient.New(ctx)
|
||||
aw.MustInit()
|
||||
// Read config and environment, set up logging, load up
|
||||
// an appCtx, and prepare ambient weather local exporter
|
||||
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{
|
||||
Funcs: []srv.HTTPFunc{
|
||||
// HTTP Endpoints for Ambient Weather Stations
|
||||
HTTP: &httpopts.AppHTTP{
|
||||
Funcs: []httpopts.HTTPFunc{
|
||||
{
|
||||
Path: "/weatherstation/updateweatherstation.php",
|
||||
HandlerFunc: aw.GetWundergroundHandlerFunc(ctx),
|
||||
@ -34,16 +51,28 @@ func main() {
|
||||
HandlerFunc: aw.GetAWNHandlerFunc(ctx),
|
||||
},
|
||||
},
|
||||
HealthChecks: []srv.HealthCheckFunc{
|
||||
CustomListener: ambienthttp.NewAWNMutatingListener(ctx,
|
||||
awConfig.HTTP.Listen), // Necessary to fix certain bad AWN firmware
|
||||
HealthChecks: []httpopts.HealthCheckFunc{
|
||||
// TODO: Implement
|
||||
func(ctx context.Context) error {
|
||||
return nil
|
||||
},
|
||||
},
|
||||
},
|
||||
// GRPC Service for retrieving current weather
|
||||
GRPC: &grpcopts.AppGRPC{
|
||||
Services: []*grpcopts.GRPCService{
|
||||
{
|
||||
Name: "Weather Service",
|
||||
Type: &weatherpb.AmbientLocalWeatherService_ServiceDesc,
|
||||
Service: weathergrpc.GRPCWeather{},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Run and wait
|
||||
awApp.MustRun()
|
||||
|
||||
<-awApp.Done()
|
||||
}
|
||||
|
@ -7,16 +7,19 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel"
|
||||
"github.com/rs/zerolog"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/provider"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/provider/awn"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/provider/wunderground"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/weather"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/provider"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/provider/awn"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/provider/wunderground"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||
)
|
||||
|
||||
type AmbientWeather struct {
|
||||
@ -24,6 +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
|
||||
awnProvider provider.AmbientProvider
|
||||
wuProvider provider.AmbientProvider
|
||||
appCtx context.Context
|
||||
@ -31,16 +35,21 @@ type AmbientWeather struct {
|
||||
l *zerolog.Logger
|
||||
}
|
||||
|
||||
func New(appCtx context.Context) *AmbientWeather {
|
||||
func New(appCtx context.Context, awConfig *config.AmbientLocalExporterConfig) *AmbientWeather {
|
||||
return &AmbientWeather{
|
||||
config: awConfig,
|
||||
appCtx: appCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) MustInit() {
|
||||
// Initialize with defaults, set logger from context
|
||||
func (aw *AmbientWeather) Init() *AmbientWeather {
|
||||
aw.awnProvider = &awn.AWNProvider{}
|
||||
aw.wuProvider = &wunderground.WUProvider{}
|
||||
aw.l = zerolog.Ctx(aw.appCtx)
|
||||
|
||||
aw.l.Trace().Any("awConfig", aw.config).Send()
|
||||
return aw
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) GetAWNHandlerFunc(appCtx context.Context) func(http.ResponseWriter, *http.Request) {
|
||||
@ -55,10 +64,15 @@ func (aw *AmbientWeather) GetWundergroundHandlerFunc(appCtx context.Context) fun
|
||||
}
|
||||
}
|
||||
|
||||
// Takes an HTTP requests and convers it to a
|
||||
// Takes an HTTP requests and converts it to a
|
||||
// stable type. Enrich is called on the type to complete
|
||||
// any missing fields as the two providers supported by Ambient
|
||||
// devices (awn/wunderground) produce different fields
|
||||
//
|
||||
// This will call Update on metrics, and will also proxy
|
||||
// requests to AWN/Wunderground if enabled
|
||||
// This is the main work performed when a weather station or
|
||||
// weather hub sends an update
|
||||
func (aw *AmbientWeather) handleProviderRequest(
|
||||
p provider.AmbientProvider,
|
||||
w http.ResponseWriter,
|
||||
@ -67,9 +81,9 @@ func (aw *AmbientWeather) handleProviderRequest(
|
||||
l := zerolog.Ctx(aw.appCtx)
|
||||
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
||||
|
||||
ctx, span := tracer.Start(r.Context(), p.Name()+".update")
|
||||
span.SetAttributes(attribute.String("provider", p.Name()))
|
||||
defer span.End()
|
||||
ctx, updateSpan := tracer.Start(r.Context(), p.Name()+".update")
|
||||
updateSpan.SetAttributes(attribute.String("provider", p.Name()))
|
||||
defer updateSpan.End()
|
||||
|
||||
l.Trace().Str("p", p.Name()).
|
||||
Any("query", r.URL.Query()).Send()
|
||||
@ -78,28 +92,153 @@ func (aw *AmbientWeather) handleProviderRequest(
|
||||
update, err := p.ReqToWeather(ctx, r)
|
||||
if err != nil {
|
||||
l.Err(err).Send()
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error,
|
||||
updateSpan.RecordError(err)
|
||||
updateSpan.SetStatus(codes.Error,
|
||||
fmt.Sprintf("failed to handle %s update: %s",
|
||||
p.Name(), err.Error()))
|
||||
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
// Calculate any fields that may be missing
|
||||
// such as dew point and wind chill
|
||||
update.Enrich()
|
||||
// Perform enrichment
|
||||
aw.enrichUpdate(ctx, p, update)
|
||||
|
||||
// We may know which station this was for now
|
||||
if update.StationConfig != nil {
|
||||
updateSpan.SetAttributes(attribute.String("stationName", update.StationConfig.Name))
|
||||
}
|
||||
|
||||
// Update metrics
|
||||
if aw.metrics == nil {
|
||||
aw.metrics = weather.MustInitMetrics(aw.appCtx)
|
||||
}
|
||||
aw.metrics.Update(update)
|
||||
aw.metricsUpdate(ctx, p, update)
|
||||
|
||||
l.Debug().
|
||||
Str("provider", p.Name()).
|
||||
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 update.StationConfig != nil {
|
||||
aw.proxyUpdate(ctx, p, update)
|
||||
}
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) enrichUpdate(
|
||||
ctx context.Context,
|
||||
p provider.AmbientProvider,
|
||||
update *weather.WeatherUpdate,
|
||||
) {
|
||||
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
||||
|
||||
// Calculate any fields that may be missing
|
||||
// such as dew point and wind chill
|
||||
_, enrichSpan := tracer.Start(ctx, p.Name()+".update.enrich")
|
||||
defer enrichSpan.End()
|
||||
|
||||
// Metric enrichment
|
||||
update.Enrich()
|
||||
|
||||
// Enrich station if configured
|
||||
aw.enrichStation(update)
|
||||
|
||||
// Map sensor names
|
||||
update.MapSensors()
|
||||
|
||||
enrichSpan.SetStatus(codes.Ok, "")
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) metricsUpdate(
|
||||
ctx context.Context,
|
||||
p provider.AmbientProvider,
|
||||
update *weather.WeatherUpdate,
|
||||
) {
|
||||
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
||||
_, metricsSpan := tracer.Start(ctx, p.Name()+".update.metrics")
|
||||
|
||||
if aw.metrics == nil {
|
||||
aw.InitMetrics()
|
||||
}
|
||||
|
||||
aw.metrics.Update(update)
|
||||
|
||||
metricsSpan.SetStatus(codes.Ok, "")
|
||||
metricsSpan.End()
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) proxyUpdate(
|
||||
ctx context.Context,
|
||||
p provider.AmbientProvider,
|
||||
update *weather.WeatherUpdate,
|
||||
) {
|
||||
var proxyWg sync.WaitGroup
|
||||
|
||||
tracer := otel.GetTracer(aw.appCtx, p.Name()+".http.handler")
|
||||
station := update.StationConfig
|
||||
|
||||
ctx, proxySpan := tracer.Start(ctx, p.Name()+".update.proxy", trace.WithAttributes(
|
||||
attribute.Bool("proxyToWunderground", station.ProxyToWunderground),
|
||||
attribute.Bool("proxyToAWN", station.ProxyToAWN),
|
||||
))
|
||||
defer proxySpan.End()
|
||||
|
||||
// Perform proxy updates in parallel if enabled
|
||||
|
||||
if station.ProxyToAWN {
|
||||
proxyWg.Add(1)
|
||||
go func() {
|
||||
defer proxyWg.Done()
|
||||
defer proxySpan.AddEvent("proxied to ambient weather network")
|
||||
err := aw.awnProvider.ProxyReq(ctx, update)
|
||||
if err != nil {
|
||||
zerolog.Ctx(aw.appCtx).Err(err).Msg("failed to proxy to ambient weather")
|
||||
proxySpan.RecordError(err)
|
||||
proxySpan.SetStatus(codes.Error, err.Error())
|
||||
return
|
||||
}
|
||||
zerolog.Ctx(aw.appCtx).Debug().
|
||||
Str("station", station.Name).
|
||||
Msg("proxied weather update to awn")
|
||||
}()
|
||||
}
|
||||
|
||||
if station.ProxyToWunderground {
|
||||
proxyWg.Add(1)
|
||||
go func() {
|
||||
defer proxyWg.Done()
|
||||
defer proxySpan.AddEvent("proxied to wunderground")
|
||||
err := aw.wuProvider.ProxyReq(ctx, update)
|
||||
if err != nil {
|
||||
zerolog.Ctx(aw.appCtx).Err(err).Msg("failed to proxy to ambient weather")
|
||||
proxySpan.RecordError(err)
|
||||
proxySpan.SetStatus(codes.Error, err.Error())
|
||||
return
|
||||
}
|
||||
zerolog.Ctx(aw.appCtx).Debug().
|
||||
Str("station", station.Name).
|
||||
Msg("proxied weather update to wunderground")
|
||||
}()
|
||||
}
|
||||
|
||||
proxyWg.Wait()
|
||||
}
|
||||
|
||||
func (aw *AmbientWeather) InitMetrics() {
|
||||
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 {
|
||||
if *update.StationID == station.AWNPassKey || *update.StationID == station.WundergroundID {
|
||||
update.StationConfig = &station
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
112
pkg/ambient/ambienthttp/ambienthttp.go
Normal file
112
pkg/ambient/ambienthttp/ambienthttp.go
Normal file
@ -0,0 +1,112 @@
|
||||
// This package exists purely to override the net.Listener used
|
||||
// by the application's http server. This is necessary for certain versions
|
||||
// of firmware which errantly put an 0x0a (LF) following PASSKEY for
|
||||
// AmbientWeather type http reporting.
|
||||
//
|
||||
// This needs to be fixed upstream by Ambient Weather and is a complete
|
||||
// hack that should never be necessary. Without this, the http server
|
||||
// will silently crank back an HTTP:400
|
||||
package ambienthttp
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"net"
|
||||
"regexp"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
// Invalid Request Pattern
|
||||
var badReqURI = regexp.MustCompile(`PASSKEY=[^\n&]{16,}$`)
|
||||
|
||||
// Listener encapsulates LFStrippingConn to perform
|
||||
// infuriating strip of newline character present after PASSKEY
|
||||
// sent errantly by specific versions of firmware sending updates
|
||||
// in AmbientWeather protocol
|
||||
type LFStrippingListener struct {
|
||||
ctx context.Context
|
||||
net.Listener
|
||||
}
|
||||
|
||||
type LFStrippingConn struct {
|
||||
ctx context.Context
|
||||
reader io.Reader
|
||||
net.Conn
|
||||
}
|
||||
|
||||
func (l *LFStrippingListener) WrapConn(conn net.Conn) net.Conn {
|
||||
buf := new(bytes.Buffer)
|
||||
reader := io.TeeReader(conn, buf)
|
||||
|
||||
scanner := bufio.NewScanner(reader)
|
||||
var newData []byte
|
||||
for scanner.Scan() {
|
||||
line := scanner.Bytes()
|
||||
newData = append(newData, line...)
|
||||
|
||||
// Only restore newline if not a bad request
|
||||
if !badReqURI.Match(line) {
|
||||
newData = append(newData, '\n')
|
||||
} else {
|
||||
zerolog.Ctx(l.ctx).Warn().Bytes("line", line).
|
||||
Msg("malformed request found, stripped 0x0a")
|
||||
}
|
||||
|
||||
if len(line) == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if scanner.Err() != nil {
|
||||
zerolog.Ctx(l.ctx).Err(scanner.Err()).Send()
|
||||
}
|
||||
|
||||
zerolog.Ctx(l.ctx).Trace().
|
||||
Int("numBytes", len(newData)).
|
||||
Bytes("request", newData).
|
||||
Msg("stripping conn complete")
|
||||
|
||||
// Use a multi-reader to prepend the modified request
|
||||
finalReader := io.MultiReader(bytes.NewReader(newData), conn)
|
||||
|
||||
return &LFStrippingConn{
|
||||
Conn: conn,
|
||||
ctx: l.ctx,
|
||||
reader: finalReader,
|
||||
}
|
||||
}
|
||||
|
||||
func NewAWNMutatingListener(ctx context.Context, listen string) net.Listener {
|
||||
rawListener, err := net.Listen("tcp", listen)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Encapsulate the raw listener with ours
|
||||
return &LFStrippingListener{
|
||||
Listener: rawListener,
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LFStrippingListener) Accept() (net.Conn, error) {
|
||||
conn, err := l.Listener.Accept()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return l.WrapConn(conn), nil
|
||||
}
|
||||
|
||||
func (l *LFStrippingListener) Close() error {
|
||||
return l.Listener.Close()
|
||||
}
|
||||
|
||||
func (l *LFStrippingListener) Addr() net.Addr {
|
||||
return l.Listener.Addr()
|
||||
}
|
||||
|
||||
func (c *LFStrippingConn) Read(b []byte) (int, error) {
|
||||
return c.reader.Read(b)
|
||||
}
|
46
pkg/ambient/config/config.go
Normal file
46
pkg/ambient/config/config.go
Normal file
@ -0,0 +1,46 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
|
||||
)
|
||||
|
||||
// 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)
|
||||
|
||||
// Required if proxying to awn/wu is enabled
|
||||
WundergroundID string `yaml:"wundergroundID"`
|
||||
WundergroundPassword string `yaml:"wundergroundPassword"`
|
||||
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
|
||||
// will be excluded if present in discardMetrics
|
||||
//
|
||||
// If anything is present in keepMetrics, it is solely applied,
|
||||
// ignoring discardMetrics.
|
||||
//
|
||||
// Check weather.WeatherUpdateField for options
|
||||
KeepMetrics []string `yaml:"keepMetrics"`
|
||||
DropMetrics []string `yaml:"dropMetrics"`
|
||||
|
||||
// Relabels battery and sensor names
|
||||
// Temp+Humidity Sensors:
|
||||
// - TempHumiditySensor[1-8]
|
||||
// Batteries:
|
||||
// - IndoorSensor
|
||||
// - OutdoorSensor
|
||||
// - RainSensor
|
||||
// - CO2Sensor
|
||||
SensorMappings map[string]string `yaml:"sensorMappings"`
|
||||
}
|
12
pkg/ambient/config/ws_map.go
Normal file
12
pkg/ambient/config/ws_map.go
Normal file
@ -0,0 +1,12 @@
|
||||
package config
|
||||
|
||||
// If the weather-station has a mapping, returns the new
|
||||
// name for the sensor
|
||||
func (ws *WeatherStation) MapSensor(sensor string) string {
|
||||
for name, replacement := range ws.SensorMappings {
|
||||
if name == sensor && replacement != "" {
|
||||
return replacement
|
||||
}
|
||||
}
|
||||
return sensor
|
||||
}
|
67
pkg/ambient/config/ws_map_test.go
Normal file
67
pkg/ambient/config/ws_map_test.go
Normal file
@ -0,0 +1,67 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestWeatherStation_MapSensor(t *testing.T) {
|
||||
type fields struct {
|
||||
Name string
|
||||
Equipment string
|
||||
WundergroundID string
|
||||
WundergroundPassword string
|
||||
AWNPassKey string
|
||||
ProxyToAWN bool
|
||||
ProxyToWunderground bool
|
||||
KeepMetrics []string
|
||||
DropMetrics []string
|
||||
SensorMappings map[string]string
|
||||
}
|
||||
type args struct {
|
||||
sensor string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Check sensor mapping",
|
||||
fields: fields{
|
||||
SensorMappings: map[string]string{
|
||||
"TempHumiditySensor1": "TestSensor",
|
||||
},
|
||||
},
|
||||
args: args{sensor: "TempHumiditySensor1"},
|
||||
want: "TestSensor",
|
||||
},
|
||||
{
|
||||
name: "Check sensor no mapping",
|
||||
fields: fields{
|
||||
SensorMappings: map[string]string{
|
||||
"TempHumiditySensor1": "TestSensor",
|
||||
},
|
||||
},
|
||||
args: args{sensor: "TempHumiditySensor2"},
|
||||
want: "TempHumiditySensor2",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ws := &WeatherStation{
|
||||
Name: tt.fields.Name,
|
||||
Equipment: tt.fields.Equipment,
|
||||
WundergroundID: tt.fields.WundergroundID,
|
||||
WundergroundPassword: tt.fields.WundergroundPassword,
|
||||
AWNPassKey: tt.fields.AWNPassKey,
|
||||
ProxyToAWN: tt.fields.ProxyToAWN,
|
||||
ProxyToWunderground: tt.fields.ProxyToWunderground,
|
||||
KeepMetrics: tt.fields.KeepMetrics,
|
||||
DropMetrics: tt.fields.DropMetrics,
|
||||
SensorMappings: tt.fields.SensorMappings,
|
||||
}
|
||||
if got := ws.MapSensor(tt.args.sensor); got != tt.want {
|
||||
t.Errorf("WeatherStation.MapSensor() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -8,12 +8,24 @@ import (
|
||||
|
||||
"github.com/gorilla/schema"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/weather"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||
)
|
||||
|
||||
type AWNProvider struct{}
|
||||
|
||||
const providerName = "awn"
|
||||
const (
|
||||
providerName = "awn"
|
||||
awnURL = "http://ambientweather.net/data/report"
|
||||
)
|
||||
|
||||
// Battery Sensors
|
||||
const (
|
||||
BattOutdoorSensor = "OutdoorSensor"
|
||||
BattIndoorSensor = "IndoorSensor"
|
||||
BattRainSensor = "RainSensor"
|
||||
BattCO2Sensor = "CO2Sensor"
|
||||
THSensor = "TempHumiditySensor"
|
||||
)
|
||||
|
||||
func (awn *AWNProvider) Name() string {
|
||||
return providerName
|
||||
@ -33,37 +45,99 @@ func (awn *AWNProvider) ReqToWeather(_ context.Context, r *http.Request) (
|
||||
}
|
||||
|
||||
func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
|
||||
updateTime, err := time.Parse(time.DateTime, awnUpdate.DateUTC)
|
||||
if err != nil {
|
||||
updateTime = time.Now()
|
||||
updateTime := time.Now()
|
||||
if awnUpdate.DateUTC != nil {
|
||||
ut, err := time.Parse(time.DateTime, *awnUpdate.DateUTC)
|
||||
if err == nil {
|
||||
updateTime = ut
|
||||
}
|
||||
}
|
||||
|
||||
return &weather.WeatherUpdate{
|
||||
StationType: awnUpdate.StationType,
|
||||
DateUTC: &updateTime,
|
||||
TempOutdoorF: awnUpdate.TempF,
|
||||
HumidityOudoor: awnUpdate.Humidity,
|
||||
WindSpeedMPH: awnUpdate.WindGustMPH,
|
||||
WindGustMPH: awnUpdate.WindGustMPH,
|
||||
MaxDailyGust: awnUpdate.MaxDailyGust,
|
||||
WindDir: awnUpdate.WindDir,
|
||||
WindDirAvg10m: awnUpdate.WindDirAVG10m,
|
||||
UV: awnUpdate.UV,
|
||||
SolarRadiation: awnUpdate.SolarRadiation,
|
||||
HourlyRainIn: awnUpdate.HourlyRainIn,
|
||||
EventRainIn: awnUpdate.EventRainIn,
|
||||
DailyRainIn: awnUpdate.DailyRainIn,
|
||||
WeeklyRainIn: awnUpdate.WeeklyRainIn,
|
||||
MonthlyRainIn: awnUpdate.MonthlyRainIn,
|
||||
YearlyRainIn: awnUpdate.YearlyRainIn,
|
||||
TotalRainIn: awnUpdate.TotalRainIn,
|
||||
BattOutdoorSensor: awnUpdate.BattOut,
|
||||
BattIndoorSensor: awnUpdate.BattIn,
|
||||
BattRainSensor: awnUpdate.BattRain,
|
||||
TempIndoorF: awnUpdate.TempInF,
|
||||
HumidityIndoor: awnUpdate.HumidityIn,
|
||||
BaromRelativeIn: awnUpdate.BaromRelIn,
|
||||
BaromAbsoluteIn: awnUpdate.BaromAbsIn,
|
||||
DateUTC: &updateTime,
|
||||
StationID: awnUpdate.PassKey,
|
||||
StationType: awnUpdate.StationType,
|
||||
TempOutdoorF: awnUpdate.TempF,
|
||||
HumidityOudoor: awnUpdate.Humidity,
|
||||
WindSpeedMPH: awnUpdate.WindSpeedMPH,
|
||||
WindGustMPH: awnUpdate.WindGustMPH,
|
||||
MaxDailyGust: awnUpdate.MaxDailyGust,
|
||||
WindDir: awnUpdate.WindDir,
|
||||
WindDirAvg10m: awnUpdate.WindDirAVG10m,
|
||||
UV: awnUpdate.UV,
|
||||
SolarRadiation: awnUpdate.SolarRadiation,
|
||||
HourlyRainIn: awnUpdate.HourlyRainIn,
|
||||
EventRainIn: awnUpdate.EventRainIn,
|
||||
DailyRainIn: awnUpdate.DailyRainIn,
|
||||
WeeklyRainIn: awnUpdate.WeeklyRainIn,
|
||||
MonthlyRainIn: awnUpdate.MonthlyRainIn,
|
||||
YearlyRainIn: awnUpdate.YearlyRainIn,
|
||||
TotalRainIn: awnUpdate.TotalRainIn,
|
||||
Batteries: []weather.BatteryStatus{
|
||||
{
|
||||
Component: BattOutdoorSensor,
|
||||
Status: awnUpdate.BattOut,
|
||||
},
|
||||
{
|
||||
Component: BattIndoorSensor,
|
||||
Status: awnUpdate.BattIn,
|
||||
},
|
||||
{
|
||||
Component: BattRainSensor,
|
||||
Status: awnUpdate.BattRain,
|
||||
},
|
||||
{
|
||||
Component: BattCO2Sensor,
|
||||
Status: awnUpdate.BattCO2,
|
||||
},
|
||||
// Temp and Humidity Sensors
|
||||
{
|
||||
Component: THSensor + "1",
|
||||
Status: awnUpdate.Batt1,
|
||||
},
|
||||
{
|
||||
Component: THSensor + "2",
|
||||
Status: awnUpdate.Batt2,
|
||||
},
|
||||
{
|
||||
Component: THSensor + "3",
|
||||
Status: awnUpdate.Batt3,
|
||||
},
|
||||
{
|
||||
Component: THSensor + "4",
|
||||
Status: awnUpdate.Batt4,
|
||||
},
|
||||
{
|
||||
Component: THSensor + "5",
|
||||
Status: awnUpdate.Batt5,
|
||||
},
|
||||
{
|
||||
Component: THSensor + "6",
|
||||
Status: awnUpdate.Batt6,
|
||||
},
|
||||
{
|
||||
Component: THSensor + "7",
|
||||
Status: awnUpdate.Batt7,
|
||||
},
|
||||
{
|
||||
Component: THSensor + "8",
|
||||
Status: awnUpdate.Batt8,
|
||||
},
|
||||
},
|
||||
TempIndoorF: awnUpdate.TempInF,
|
||||
HumidityIndoor: awnUpdate.HumidityIn,
|
||||
BaromRelativeIn: awnUpdate.BaromRelIn,
|
||||
BaromAbsoluteIn: awnUpdate.BaromAbsIn,
|
||||
TempHumiditySensors: []*weather.TempHumiditySensor{
|
||||
{Name: THSensor + "1", TempF: awnUpdate.Temp1F, Humidity: awnUpdate.Humidity1},
|
||||
{Name: THSensor + "2", TempF: awnUpdate.Temp2F, Humidity: awnUpdate.Humidity2},
|
||||
{Name: THSensor + "3", TempF: awnUpdate.Temp3F, Humidity: awnUpdate.Humidity3},
|
||||
{Name: THSensor + "4", TempF: awnUpdate.Temp4F, Humidity: awnUpdate.Humidity4},
|
||||
{Name: THSensor + "5", TempF: awnUpdate.Temp5F, Humidity: awnUpdate.Humidity5},
|
||||
{Name: THSensor + "6", TempF: awnUpdate.Temp6F, Humidity: awnUpdate.Humidity6},
|
||||
{Name: THSensor + "7", TempF: awnUpdate.Temp7F, Humidity: awnUpdate.Humidity7},
|
||||
{Name: THSensor + "8", TempF: awnUpdate.Temp8F, Humidity: awnUpdate.Humidity8},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
105
pkg/provider/awn/proxy.go
Normal file
105
pkg/provider/awn/proxy.go
Normal file
@ -0,0 +1,105 @@
|
||||
package awn
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||
)
|
||||
|
||||
// Attempts to proxy the weather station update to awn
|
||||
// SAMPLE:
|
||||
// {"PASSKEY":["ABF7E052BC7325A32300ACC89112AA91"],"baromabsin":["28.895"],
|
||||
// "baromrelin":["29.876"],"battin":["1"],"battout":["1"],"battrain":["1"],
|
||||
// "dailyrainin":["0.000"],"dateutc":["2025-01-11 22:07:57"],"eventrainin":["0.000"],
|
||||
// "hourlyrainin":["0.000"],"humidity":["76"],"humidityin":["31"],"maxdailygust":["7.83"],
|
||||
// "monthlyrainin":["0.000"],"solarradiation":["14.21"],"stationtype":["WeatherHub_V1.0.1"],
|
||||
// "tempf":["29.48"],"tempinf":["66.20"],"totalrainin":["0.000"],"uv":["0"],
|
||||
// "weeklyrainin":["0.000"],"winddir":["66"],"winddir_avg10m":["268"],"windgustmph":["2.68"],
|
||||
// "windspeedmph":["0.00"],"yearlyrainin":["0.000"]}
|
||||
func (awn *AWNProvider) ProxyReq(ctx context.Context, update *weather.WeatherUpdate) error {
|
||||
tracer := otel.GetTracer(ctx, "awnProvider", "proxyReq")
|
||||
ctx, span := tracer.Start(ctx, "proxyToAWN")
|
||||
defer span.End()
|
||||
|
||||
if update.StationConfig.AWNPassKey == "" {
|
||||
err := errors.New("no PASSKEY set in update")
|
||||
span.RecordError(err)
|
||||
return err
|
||||
}
|
||||
|
||||
params := updateToAWNParams(update)
|
||||
|
||||
resp, err := resty.New().R().
|
||||
SetContext(ctx).
|
||||
SetQueryParamsFromValues(*params).
|
||||
Get(awnURL)
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetAttributes(
|
||||
attribute.String("query", resp.Request.QueryParam.Encode()),
|
||||
attribute.String("body", string(resp.Body())),
|
||||
)
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
log.Err(err).Any("query", resp.Request.PathParams).
|
||||
Int("statusCode", resp.StatusCode()).
|
||||
Msg("awn proxy failed")
|
||||
}
|
||||
|
||||
span.SetAttributes(
|
||||
attribute.Int("statusCode", resp.StatusCode()),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func updateToAWNParams(update *weather.WeatherUpdate) *url.Values {
|
||||
params := &url.Values{}
|
||||
params.Set("dateutc", time.Now().Format(time.DateTime))
|
||||
weather.SetURLVal(params, "PASSKEY", &update.StationConfig.AWNPassKey)
|
||||
weather.SetURLVal(params, "baromabsin", update.BaromAbsoluteIn)
|
||||
weather.SetURLVal(params, "baromrelin", update.BaromRelativeIn)
|
||||
weather.SetURLVal(params, "dailyrainin", update.DailyRainIn)
|
||||
weather.SetURLVal(params, "weeklyrainin", update.WeeklyRainIn)
|
||||
weather.SetURLVal(params, "eventrainin", update.EventRainIn)
|
||||
weather.SetURLVal(params, "hourlyrainin", update.HourlyRainIn)
|
||||
weather.SetURLVal(params, "monthlyrainin", update.MonthlyRainIn)
|
||||
weather.SetURLVal(params, "yearlyrainin", update.YearlyRainIn)
|
||||
weather.SetURLVal(params, "totalrainin", update.TotalRainIn)
|
||||
weather.SetURLVal(params, "humidity", update.HumidityOudoor)
|
||||
weather.SetURLVal(params, "humidityin", update.HumidityIndoor)
|
||||
weather.SetURLVal(params, "solarradiation", update.SolarRadiation)
|
||||
weather.SetURLVal(params, "uv", update.UV)
|
||||
weather.SetURLVal(params, "stationtype", update.StationType)
|
||||
weather.SetURLVal(params, "tempf", update.TempOutdoorF)
|
||||
weather.SetURLVal(params, "tempinf", update.TempIndoorF)
|
||||
weather.SetURLVal(params, "winddir", update.WindDir)
|
||||
weather.SetURLVal(params, "winddir_avg10m", update.WindDirAvg10m)
|
||||
weather.SetURLVal(params, "windgustmph", update.WindGustMPH)
|
||||
weather.SetURLVal(params, "windspeedmph", update.WindSpeedMPH)
|
||||
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
|
||||
}
|
@ -1,30 +1,59 @@
|
||||
package awn
|
||||
|
||||
type AmbientWeatherUpdate struct {
|
||||
PassKey string `json:"PASSKEY,omitempty" schema:"PASSKEY"`
|
||||
StationType string `json:"stationtype,omitempty" schema:"stationtype"`
|
||||
DateUTC string `json:"dateutc,omitempty" schema:"dateutc"`
|
||||
TempF float64 `json:"tempf,omitempty" schema:"tempf"`
|
||||
Humidity int `json:"humidity,omitempty" schema:"humidity"`
|
||||
WindSpeedMPH float64 `json:"windspeedmph,omitempty" schema:"windspeedmph"`
|
||||
WindGustMPH float64 `json:"windgustmph,omitempty" schema:"windgustmph"`
|
||||
MaxDailyGust float64 `json:"maxdailygust,omitempty" schema:"maxdailygust"`
|
||||
WindDir int `json:"winddir,omitempty" schema:"winddir"`
|
||||
WindDirAVG10m int `json:"winddir_avg10m,omitempty" schema:"winddir_avg10m"`
|
||||
UV int `json:"uv,omitempty" schema:"uv"`
|
||||
SolarRadiation float64 `json:"solarradiation,omitempty" schema:"solarradiation"`
|
||||
HourlyRainIn float64 `json:"hourlyrainin,omitempty" schema:"hourlyrainin"`
|
||||
EventRainIn float64 `json:"eventrainin,omitempty" schema:"eventrainin"`
|
||||
DailyRainIn float64 `json:"dailyrainin,omitempty" schema:"dailyrainin"`
|
||||
WeeklyRainIn float64 `json:"weeklyrainin,omitempty" schema:"weeklyrainin"`
|
||||
MonthlyRainIn float64 `json:"monthlyrainin,omitempty" schema:"monthlyrainin"`
|
||||
YearlyRainIn float64 `json:"yearlyrainin,omitempty" schema:"yearlyrainin"`
|
||||
TotalRainIn float64 `json:"totalrainin,omitempty" schema:"totalrainin"`
|
||||
BattOut int `json:"battout,omitempty" schema:"battout"`
|
||||
BattRain int `json:"battrain,omitempty" schema:"battrain"`
|
||||
TempInF float64 `json:"tempinf,omitempty" schema:"tempinf"`
|
||||
HumidityIn int `json:"humidityin,omitempty" schema:"humidityin"`
|
||||
BaromRelIn float64 `json:"baromrelin,omitempty" schema:"baromrelin"`
|
||||
BaromAbsIn float64 `json:"baromabsin,omitempty" schema:"baromabsin"`
|
||||
BattIn int `json:"battin,omitempty" schema:"battin"`
|
||||
PassKey *string `json:"PASSKEY,omitempty" schema:"PASSKEY"`
|
||||
StationType *string `json:"stationtype,omitempty" schema:"stationtype"`
|
||||
DateUTC *string `json:"dateutc,omitempty" schema:"dateutc"`
|
||||
TempF *float64 `json:"tempf,omitempty" schema:"tempf"`
|
||||
Humidity *int `json:"humidity,omitempty" schema:"humidity"`
|
||||
WindSpeedMPH *float64 `json:"windspeedmph,omitempty" schema:"windspeedmph"`
|
||||
WindGustMPH *float64 `json:"windgustmph,omitempty" schema:"windgustmph"`
|
||||
MaxDailyGust *float64 `json:"maxdailygust,omitempty" schema:"maxdailygust"`
|
||||
WindDir *int `json:"winddir,omitempty" schema:"winddir"`
|
||||
WindDirAVG10m *int `json:"winddir_avg10m,omitempty" schema:"winddir_avg10m"`
|
||||
UV *int `json:"uv,omitempty" schema:"uv"`
|
||||
SolarRadiation *float64 `json:"solarradiation,omitempty" schema:"solarradiation"`
|
||||
HourlyRainIn *float64 `json:"hourlyrainin,omitempty" schema:"hourlyrainin"`
|
||||
EventRainIn *float64 `json:"eventrainin,omitempty" schema:"eventrainin"`
|
||||
DailyRainIn *float64 `json:"dailyrainin,omitempty" schema:"dailyrainin"`
|
||||
WeeklyRainIn *float64 `json:"weeklyrainin,omitempty" schema:"weeklyrainin"`
|
||||
MonthlyRainIn *float64 `json:"monthlyrainin,omitempty" schema:"monthlyrainin"`
|
||||
YearlyRainIn *float64 `json:"yearlyrainin,omitempty" schema:"yearlyrainin"`
|
||||
TotalRainIn *float64 `json:"totalrainin,omitempty" schema:"totalrainin"`
|
||||
BattOut *int `json:"battout,omitempty" schema:"battout"`
|
||||
BattRain *int `json:"battrain,omitempty" schema:"battrain"`
|
||||
TempInF *float64 `json:"tempinf,omitempty" schema:"tempinf"`
|
||||
HumidityIn *int `json:"humidityin,omitempty" schema:"humidityin"`
|
||||
BaromRelIn *float64 `json:"baromrelin,omitempty" schema:"baromrelin"`
|
||||
BaromAbsIn *float64 `json:"baromabsin,omitempty" schema:"baromabsin"`
|
||||
BattIn *int `json:"battin,omitempty" schema:"battin"`
|
||||
BattCO2 *int `json:"batt_co2,omitempty" schema:"batt_co2"`
|
||||
*AmbientTempHumiditySensors
|
||||
}
|
||||
|
||||
type AmbientTempHumiditySensors struct {
|
||||
Temp1F *float64 `json:"temp1f,omitempty" schema:"temp1f"`
|
||||
Temp2F *float64 `json:"temp2f,omitempty" schema:"temp2f"`
|
||||
Temp3F *float64 `json:"temp3f,omitempty" schema:"temp3f"`
|
||||
Temp4F *float64 `json:"temp4f,omitempty" schema:"temp4f"`
|
||||
Temp5F *float64 `json:"temp5f,omitempty" schema:"temp5f"`
|
||||
Temp6F *float64 `json:"temp6f,omitempty" schema:"temp6f"`
|
||||
Temp7F *float64 `json:"temp7f,omitempty" schema:"temp7f"`
|
||||
Temp8F *float64 `json:"temp8f,omitempty" schema:"temp8f"`
|
||||
Humidity1 *int `json:"humidity1,omitempty" schema:"humidity1"`
|
||||
Humidity2 *int `json:"humidity2,omitempty" schema:"humidity2"`
|
||||
Humidity3 *int `json:"humidity3,omitempty" schema:"humidity3"`
|
||||
Humidity4 *int `json:"humidity4,omitempty" schema:"humidity4"`
|
||||
Humidity5 *int `json:"humidity5,omitempty" schema:"humidity5"`
|
||||
Humidity6 *int `json:"humidity6,omitempty" schema:"humidity6"`
|
||||
Humidity7 *int `json:"humidity7,omitempty" schema:"humidity7"`
|
||||
Humidity8 *int `json:"humidity8,omitempty" schema:"humidity8"`
|
||||
Batt1 *int `json:"batt1,omitempty" schema:"batt1"`
|
||||
Batt2 *int `json:"batt2,omitempty" schema:"batt2"`
|
||||
Batt3 *int `json:"batt3,omitempty" schema:"batt3"`
|
||||
Batt4 *int `json:"batt4,omitempty" schema:"batt4"`
|
||||
Batt5 *int `json:"batt5,omitempty" schema:"batt5"`
|
||||
Batt6 *int `json:"batt6,omitempty" schema:"batt6"`
|
||||
Batt7 *int `json:"batt7,omitempty" schema:"batt7"`
|
||||
Batt8 *int `json:"batt8,omitempty" schema:"batt8"`
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/weather"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||
)
|
||||
|
||||
// Simple interface used for converting Wunderground and
|
||||
// Ambient Weather Network HTTP requests to a stable struct
|
||||
type AmbientProvider interface {
|
||||
ReqToWeather(context.Context, *http.Request) (*weather.WeatherUpdate, error)
|
||||
ProxyReq(context.Context, *weather.WeatherUpdate) error
|
||||
Name() string
|
||||
}
|
||||
|
@ -8,12 +8,15 @@ import (
|
||||
|
||||
"github.com/gorilla/schema"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-weather-local-exporter/pkg/weather"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||
)
|
||||
|
||||
type WUProvider struct{}
|
||||
|
||||
const providerName = "weatherunderground"
|
||||
const (
|
||||
providerName = "weatherunderground"
|
||||
wuURL = "https://rtupdate.wunderground.com/weatherstation/updateweatherstation.php"
|
||||
)
|
||||
|
||||
func (wu *WUProvider) Name() string {
|
||||
return providerName
|
||||
@ -33,17 +36,22 @@ func (wu *WUProvider) ReqToWeather(_ context.Context, r *http.Request) (
|
||||
}
|
||||
|
||||
func MapWUUpdate(wuUpdate *WundergroundUpdate) *weather.WeatherUpdate {
|
||||
updateTime, err := time.Parse(time.DateTime, wuUpdate.DateUTC)
|
||||
if err != nil {
|
||||
updateTime = time.Now()
|
||||
updateTime := time.Now()
|
||||
|
||||
if wuUpdate.DateUTC != nil {
|
||||
ut, err := time.Parse(time.DateTime, *wuUpdate.DateUTC)
|
||||
if err == nil {
|
||||
updateTime = ut
|
||||
}
|
||||
}
|
||||
|
||||
return &weather.WeatherUpdate{
|
||||
StationType: wuUpdate.SoftwareType,
|
||||
DateUTC: &updateTime,
|
||||
TempOutdoorF: wuUpdate.Tempf,
|
||||
HumidityOudoor: wuUpdate.Humidity,
|
||||
WindSpeedMPH: wuUpdate.WindGustMPH,
|
||||
StationID: wuUpdate.ID,
|
||||
StationType: wuUpdate.SoftwareType,
|
||||
TempOutdoorF: wuUpdate.Tempf,
|
||||
HumidityOudoor: wuUpdate.Humidity,
|
||||
WindSpeedMPH: wuUpdate.WindSpeedMPH,
|
||||
WindGustMPH: wuUpdate.WindGustMPH,
|
||||
WindDir: wuUpdate.WindDir,
|
||||
UV: wuUpdate.UV,
|
||||
|
88
pkg/provider/wunderground/proxy.go
Normal file
88
pkg/provider/wunderground/proxy.go
Normal file
@ -0,0 +1,88 @@
|
||||
package wunderground
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/url"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||
)
|
||||
|
||||
func (wu *WUProvider) ProxyReq(ctx context.Context, update *weather.WeatherUpdate) error {
|
||||
tracer := otel.GetTracer(ctx, "wuProvider", "proxyReq")
|
||||
ctx, span := tracer.Start(ctx, "proxyToWunderground")
|
||||
defer span.End()
|
||||
|
||||
if update.StationConfig.WundergroundID == "" {
|
||||
err := errors.New("no wunderground id set in update")
|
||||
span.RecordError(err)
|
||||
return err
|
||||
} else if update.StationConfig.WundergroundPassword == "" {
|
||||
err := errors.New("no wunderground id set in update")
|
||||
span.RecordError(err)
|
||||
return err
|
||||
}
|
||||
|
||||
params := updateToWuParams(update)
|
||||
|
||||
resp, err := resty.New().R().
|
||||
SetContext(ctx).
|
||||
SetQueryParamsFromValues(*params).
|
||||
Get(wuURL)
|
||||
if err != nil {
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
span.SetAttributes(
|
||||
attribute.String("query", resp.Request.QueryParam.Encode()),
|
||||
attribute.String("body", string(resp.Body())),
|
||||
)
|
||||
span.RecordError(err)
|
||||
log.Err(err).
|
||||
Int("statusCode", resp.StatusCode()).
|
||||
Any("query", resp.Request.PathParams).
|
||||
Msg("wunderground proxy failed")
|
||||
}
|
||||
|
||||
span.SetAttributes(
|
||||
attribute.Int("statusCode", resp.StatusCode()),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func updateToWuParams(u *weather.WeatherUpdate) *url.Values {
|
||||
params := &url.Values{}
|
||||
weather.SetURLVal(params, "ID", &u.StationConfig.WundergroundID)
|
||||
weather.SetURLVal(params, "PASSWORD", &u.StationConfig.WundergroundPassword)
|
||||
params.Set("action", "updateraw")
|
||||
params.Set("dateutc", "now")
|
||||
weather.SetURLVal(params, "UV", u.UV)
|
||||
weather.SetURLVal(params, "baromin", u.BaromRelativeIn)
|
||||
weather.SetURLVal(params, "dailyrainin", u.DailyRainIn)
|
||||
weather.SetURLVal(params, "dewptf", u.DewPointF)
|
||||
weather.SetURLVal(params, "humidity", u.HumidityOudoor)
|
||||
weather.SetURLVal(params, "indoorhumidity", u.HumidityIndoor)
|
||||
weather.SetURLVal(params, "indoortempf", u.TempIndoorF)
|
||||
weather.SetURLVal(params, "lowbatt", ptr.To(0))
|
||||
weather.SetURLVal(params, "monthlyrainin", u.MonthlyRainIn)
|
||||
weather.SetURLVal(params, "rainin", u.HourlyRainIn)
|
||||
weather.SetURLVal(params, "realtime", ptr.To(1))
|
||||
weather.SetURLVal(params, "rtfreq", ptr.To(60))
|
||||
weather.SetURLVal(params, "softwaretype", u.StationType)
|
||||
weather.SetURLVal(params, "solarradiation", u.SolarRadiation)
|
||||
weather.SetURLVal(params, "tempf", u.TempOutdoorF)
|
||||
weather.SetURLVal(params, "weeklyrainin", u.WeeklyRainIn)
|
||||
weather.SetURLVal(params, "windchillf", u.WindChillF)
|
||||
weather.SetURLVal(params, "winddir", u.WindDir)
|
||||
weather.SetURLVal(params, "windgustmph", u.WindGustMPH)
|
||||
weather.SetURLVal(params, "windspeedmph", u.WindSpeedMPH)
|
||||
weather.SetURLVal(params, "yearlyrainin", u.YearlyRainIn)
|
||||
return params
|
||||
}
|
@ -1,29 +1,29 @@
|
||||
package wunderground
|
||||
|
||||
type WundergroundUpdate struct {
|
||||
ID string `json:"ID,omitempty" schema:"ID"`
|
||||
Password string `json:"PASSWORD,omitempty" schema:"PASSWORD"`
|
||||
UV int `json:"UV,omitempty" schema:"UV"`
|
||||
Action string `json:"action,omitempty" schema:"action"`
|
||||
BaromIn float64 `json:"baromin,omitempty" schema:"baromin"`
|
||||
DailyRainIn float64 `json:"dailyrainin,omitempty" schema:"dailyrainin"`
|
||||
DateUTC string `json:"dateutc,omitempty" schema:"dateutc"`
|
||||
DewPtF float64 `json:"dewptf,omitempty" schema:"dewptf"`
|
||||
Humidity int `json:"humidity,omitempty" schema:"humidity"`
|
||||
IndoorHumidity int `json:"indoorhumidity,omitempty" schema:"indoorhumidity"`
|
||||
IndoorTempF float64 `json:"indoortempf,omitempty" schema:"indoortempf"`
|
||||
LowBatt bool `json:"lowbatt,omitempty" schema:"lowbatt"`
|
||||
MonthlyRainIn float64 `json:"monthlyrainin,omitempty" schema:"monthlyrainin"`
|
||||
RainIn float64 `json:"rainin,omitempty" schema:"rainin"`
|
||||
Realtime bool `json:"realtime,omitempty" schema:"realtime"`
|
||||
Rtfreq int `json:"rtfreq,omitempty" schema:"rtfreq"`
|
||||
SoftwareType string `json:"softwaretype,omitempty" schema:"softwaretype"`
|
||||
SolarRadiation float64 `json:"solarradiation,omitempty" schema:"solarradiation"`
|
||||
Tempf float64 `json:"tempf,omitempty" schema:"tempf"`
|
||||
WeeklyRainIn float64 `json:"weeklyrainin,omitempty" schema:"weeklyrainin"`
|
||||
WindChillF float64 `json:"windchillf,omitempty" schema:"windchillf"`
|
||||
WindDir int `json:"winddir,omitempty" schema:"winddir"`
|
||||
WindGustMPH float64 `json:"windgustmph,omitempty" schema:"windgustmph"`
|
||||
WindSpeedMPH float64 `json:"windspeedmph,omitempty" schema:"windspeedmph"`
|
||||
YearlyRainIn float64 `json:"yearlyrainin,omitempty" schema:"yearlyrainin"`
|
||||
ID *string `json:"ID,omitempty" schema:"ID"`
|
||||
Password *string `json:"PASSWORD,omitempty" schema:"PASSWORD"`
|
||||
UV *int `json:"UV,omitempty" schema:"UV"`
|
||||
Action *string `json:"action,omitempty" schema:"action"`
|
||||
BaromIn *float64 `json:"baromin,omitempty" schema:"baromin"`
|
||||
DailyRainIn *float64 `json:"dailyrainin,omitempty" schema:"dailyrainin"`
|
||||
DateUTC *string `json:"dateutc,omitempty" schema:"dateutc"`
|
||||
DewPtF *float64 `json:"dewptf,omitempty" schema:"dewptf"`
|
||||
Humidity *int `json:"humidity,omitempty" schema:"humidity"`
|
||||
IndoorHumidity *int `json:"indoorhumidity,omitempty" schema:"indoorhumidity"`
|
||||
IndoorTempF *float64 `json:"indoortempf,omitempty" schema:"indoortempf"`
|
||||
LowBatt *bool `json:"lowbatt,omitempty" schema:"lowbatt"`
|
||||
MonthlyRainIn *float64 `json:"monthlyrainin,omitempty" schema:"monthlyrainin"`
|
||||
RainIn *float64 `json:"rainin,omitempty" schema:"rainin"`
|
||||
Realtime *bool `json:"realtime,omitempty" schema:"realtime"`
|
||||
Rtfreq *int `json:"rtfreq,omitempty" schema:"rtfreq"`
|
||||
SoftwareType *string `json:"softwaretype,omitempty" schema:"softwaretype"`
|
||||
SolarRadiation *float64 `json:"solarradiation,omitempty" schema:"solarradiation"`
|
||||
Tempf *float64 `json:"tempf,omitempty" schema:"tempf"`
|
||||
WeeklyRainIn *float64 `json:"weeklyrainin,omitempty" schema:"weeklyrainin"`
|
||||
WindChillF *float64 `json:"windchillf,omitempty" schema:"windchillf"`
|
||||
WindDir *int `json:"winddir,omitempty" schema:"winddir"`
|
||||
WindGustMPH *float64 `json:"windgustmph,omitempty" schema:"windgustmph"`
|
||||
WindSpeedMPH *float64 `json:"windspeedmph,omitempty" schema:"windspeedmph"`
|
||||
YearlyRainIn *float64 `json:"yearlyrainin,omitempty" schema:"yearlyrainin"`
|
||||
}
|
||||
|
@ -1,23 +1,73 @@
|
||||
package weather
|
||||
|
||||
import "math"
|
||||
import (
|
||||
"math"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient/config"
|
||||
)
|
||||
|
||||
// Attempts to complete missing fields that may not
|
||||
// be set by a specific provider, such as DewPoint and WindChill
|
||||
func (u *WeatherUpdate) Enrich() {
|
||||
if u.WindChillF == 0 {
|
||||
u.WindChillF = CalculateWindChill(u.TempOutdoorF, u.WindSpeedMPH)
|
||||
// TODO: Add span
|
||||
func (u *WeatherUpdate) Enrich(weatherStations ...*config.WeatherStation) {
|
||||
if u == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if u.DewPointF == 0 {
|
||||
u.DewPointF = CalculateDewPoint(u.TempOutdoorF, float64(u.HumidityOudoor))
|
||||
// Clear invalid measurements, would be better if these weren't
|
||||
// sent when sensor was out of range.
|
||||
// TODO: This should probably just be done for all fields where
|
||||
// the value is -9999
|
||||
if u.BaromAbsoluteIn != nil && *u.BaromAbsoluteIn < 20 {
|
||||
u.BaromAbsoluteIn = nil
|
||||
}
|
||||
if u.BaromRelativeIn != nil && *u.BaromRelativeIn < 20 {
|
||||
u.BaromRelativeIn = nil
|
||||
}
|
||||
if u.TempIndoorF != nil && *u.TempIndoorF < -1000 {
|
||||
u.TempIndoorF = nil
|
||||
}
|
||||
|
||||
if u.BaromAbsoluteIn == 0 {
|
||||
// Calculate Wind Chill
|
||||
if u.WindChillF == nil && u.TempOutdoorF != nil && u.WindSpeedMPH != nil {
|
||||
wc := CalculateWindChill(*u.TempOutdoorF, *u.WindSpeedMPH)
|
||||
u.WindChillF = &wc
|
||||
}
|
||||
|
||||
// Calculate Dew Point
|
||||
if u.DewPointF == nil && (u.TempOutdoorF != nil && u.HumidityOudoor != nil) {
|
||||
if *u.TempOutdoorF != 0 || *u.HumidityOudoor != 0 {
|
||||
dp := CalculateDewPoint(*u.TempOutdoorF, float64(*u.HumidityOudoor))
|
||||
u.DewPointF = &dp
|
||||
}
|
||||
}
|
||||
|
||||
// Use relative pressure if absolute isn't provided
|
||||
if u.BaromAbsoluteIn == nil && u.BaromRelativeIn != nil {
|
||||
u.BaromAbsoluteIn = u.BaromRelativeIn
|
||||
}
|
||||
}
|
||||
|
||||
// Swaps sensor and component names based on
|
||||
// user provided configuration
|
||||
func (u *WeatherUpdate) MapSensors() {
|
||||
if u.StationConfig == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Map sensor battery components
|
||||
for i, batt := range u.Batteries {
|
||||
u.Batteries[i].Component = u.StationConfig.MapSensor(batt.Component)
|
||||
}
|
||||
|
||||
// Map other sensors
|
||||
for _, th := range u.TempHumiditySensors {
|
||||
th.Name = u.StationConfig.MapSensor(th.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func CalculateDewPoint(tempF, humidity float64) float64 {
|
||||
// Convert temperature from Fahrenheit to Celsius
|
||||
tempC := (tempF - 32) * 5 / 9
|
||||
@ -45,3 +95,31 @@ func CalculateWindChill(tempF float64, windSpeedMPH float64) float64 {
|
||||
35.75*math.Pow(windSpeedMPH, 0.16) +
|
||||
0.4275*tempF*math.Pow(windSpeedMPH, 0.16)
|
||||
}
|
||||
|
||||
// Helper function to set values from fields
|
||||
// typically from a WeatherUpdate
|
||||
func SetURLVal(vals *url.Values, key string, value any) {
|
||||
if value == nil {
|
||||
return
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case *float64:
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
str := strconv.FormatFloat(*v, 'f', 4, 64)
|
||||
vals.Set(key, str)
|
||||
case *int:
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
str := strconv.FormatInt(int64(*v), 10)
|
||||
vals.Set(key, str)
|
||||
case *string:
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
vals.Set(key, *v)
|
||||
}
|
||||
}
|
||||
|
13
pkg/weather/grpc/weather.go
Normal file
13
pkg/weather/grpc/weather.go
Normal file
@ -0,0 +1,13 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
||||
)
|
||||
|
||||
// TODO: Implement
|
||||
type GRPCWeather struct {
|
||||
ctx context.Context
|
||||
*pb.UnimplementedAmbientLocalWeatherServiceServer
|
||||
}
|
@ -4,145 +4,144 @@ import (
|
||||
"context"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
|
||||
)
|
||||
|
||||
var MetricPrefix = "weather"
|
||||
|
||||
type WeatherMetrics struct {
|
||||
// Weather Metrics
|
||||
TempOutdoorF metric.Float64Gauge
|
||||
TempIndoorF metric.Float64Gauge
|
||||
HumidityOudoor metric.Int64Gauge
|
||||
HumidityIndoor metric.Int64Gauge
|
||||
WindSpeedMPH metric.Float64Gauge
|
||||
WindGustMPH metric.Float64Gauge
|
||||
MaxDailyGust metric.Float64Gauge
|
||||
WindDir metric.Int64Gauge
|
||||
WindDirAvg10m metric.Int64Gauge
|
||||
UV metric.Int64Gauge
|
||||
SolarRadiation metric.Float64Gauge
|
||||
HourlyRainIn metric.Float64Gauge
|
||||
EventRainIn metric.Float64Gauge
|
||||
DailyRainIn metric.Float64Gauge
|
||||
WeeklyRainIn metric.Float64Gauge
|
||||
MonthlyRainIn metric.Float64Gauge
|
||||
YearlyRainIn metric.Float64Gauge
|
||||
TotalRainIn metric.Float64Gauge
|
||||
BattOutdoorSensor metric.Int64Gauge
|
||||
BattIndoorSensor metric.Int64Gauge
|
||||
BattRainSensor metric.Int64Gauge
|
||||
BaromRelativeIn metric.Float64Gauge
|
||||
BaromAbsoluteIn metric.Float64Gauge
|
||||
DewPointF metric.Float64Gauge
|
||||
WindChillF metric.Float64Gauge
|
||||
TempOutdoorF metric.Float64Gauge
|
||||
TempIndoorF metric.Float64Gauge
|
||||
HumidityOudoor metric.Int64Gauge
|
||||
HumidityIndoor metric.Int64Gauge
|
||||
WindSpeedMPH metric.Float64Gauge
|
||||
WindGustMPH metric.Float64Gauge
|
||||
MaxDailyGust metric.Float64Gauge
|
||||
WindDir metric.Int64Gauge
|
||||
WindDirAvg10m metric.Int64Gauge
|
||||
UV metric.Int64Gauge
|
||||
SolarRadiation metric.Float64Gauge
|
||||
HourlyRainIn metric.Float64Gauge
|
||||
EventRainIn metric.Float64Gauge
|
||||
DailyRainIn metric.Float64Gauge
|
||||
WeeklyRainIn metric.Float64Gauge
|
||||
MonthlyRainIn metric.Float64Gauge
|
||||
YearlyRainIn metric.Float64Gauge
|
||||
TotalRainIn metric.Float64Gauge
|
||||
BatteryStatus metric.Int64Gauge
|
||||
BaromRelativeIn metric.Float64Gauge
|
||||
BaromAbsoluteIn metric.Float64Gauge
|
||||
DewPointF metric.Float64Gauge
|
||||
WindChillF metric.Float64Gauge
|
||||
|
||||
// Temp and Humidity Sensors
|
||||
SensorTempF metric.Float64Gauge
|
||||
SensorHumidity metric.Int64Gauge
|
||||
|
||||
// Internal Telemetry
|
||||
UpdatesReceived metric.Int64Counter
|
||||
appCtx context.Context
|
||||
cfg *config.AppConfig
|
||||
meter metric.Meter
|
||||
}
|
||||
|
||||
func MustInitMetrics(appCtx context.Context) *WeatherMetrics {
|
||||
wm := &WeatherMetrics{
|
||||
appCtx: appCtx,
|
||||
cfg: config.MustFromCtx(appCtx),
|
||||
}
|
||||
|
||||
wm.meter = otel.GetMeter(appCtx, "weather", "metrics")
|
||||
|
||||
// Weather Metrics
|
||||
wm.TempOutdoorF, _ = wm.meter.Float64Gauge("weather_temp_outdoor_f",
|
||||
metric.WithDescription("Outdoor Temperature in Faherenheit"))
|
||||
wm.TempIndoorF, _ = wm.meter.Float64Gauge("weather_temp_indoor_f",
|
||||
metric.WithDescription("Indoor Temperature in Faherenheit"))
|
||||
wm.HumidityOudoor, _ = wm.meter.Int64Gauge("weather_humidity_oudoor",
|
||||
metric.WithDescription("Outdoor Humidity %"))
|
||||
wm.HumidityIndoor, _ = wm.meter.Int64Gauge("weather_humidity_indoor",
|
||||
metric.WithDescription("Indoor Humidity %"))
|
||||
wm.WindSpeedMPH, _ = wm.meter.Float64Gauge("weather_wind_speed_mph",
|
||||
metric.WithDescription("Wind Speed in MPH"))
|
||||
wm.WindGustMPH, _ = wm.meter.Float64Gauge("weather_wind_gust_mph",
|
||||
metric.WithDescription("Wind Gust in MPH"))
|
||||
wm.MaxDailyGust, _ = wm.meter.Float64Gauge("weather_max_daily_gust",
|
||||
metric.WithDescription("Max Daily Wind Gust"))
|
||||
wm.WindDir, _ = wm.meter.Int64Gauge("weather_wind_dir",
|
||||
metric.WithDescription("Wind Direction in Degrees"))
|
||||
wm.WindDirAvg10m, _ = wm.meter.Int64Gauge("weather_wind_dir_avg_10m",
|
||||
metric.WithDescription("Wind Direction 10m Average"))
|
||||
wm.UV, _ = wm.meter.Int64Gauge("weather_uv",
|
||||
metric.WithDescription("UV Index"))
|
||||
wm.SolarRadiation, _ = wm.meter.Float64Gauge("weather_solar_radiation",
|
||||
metric.WithDescription("Solar Radiation in W/㎡"))
|
||||
wm.HourlyRainIn, _ = wm.meter.Float64Gauge("weather_hourly_rain_in",
|
||||
metric.WithDescription("Hourly Rain in Inches"))
|
||||
wm.EventRainIn, _ = wm.meter.Float64Gauge("weather_event_rain_in",
|
||||
metric.WithDescription("Event Rain in Inches"))
|
||||
wm.DailyRainIn, _ = wm.meter.Float64Gauge("weather_daily_rain_in",
|
||||
metric.WithDescription("Daily Rain in Inches"))
|
||||
wm.WeeklyRainIn, _ = wm.meter.Float64Gauge("weather_weekly_rain_in",
|
||||
metric.WithDescription("Weekly Rain in Inches"))
|
||||
wm.MonthlyRainIn, _ = wm.meter.Float64Gauge("weather_monthly_rain_in",
|
||||
metric.WithDescription("Monthly Rain in Inches"))
|
||||
wm.YearlyRainIn, _ = wm.meter.Float64Gauge("weather_yearly_rain_in",
|
||||
metric.WithDescription("Yearly Rain in Inches"))
|
||||
wm.TotalRainIn, _ = wm.meter.Float64Gauge("weather_total_rain_in",
|
||||
metric.WithDescription("Total Rain in Inches"))
|
||||
wm.BattOutdoorSensor, _ = wm.meter.Int64Gauge("weather_batt_outdoor_sensor",
|
||||
metric.WithDescription("Outdoor Equipment Battery"))
|
||||
wm.BattIndoorSensor, _ = wm.meter.Int64Gauge("weather_batt_indoor_sensor",
|
||||
metric.WithDescription("Indoor Equipmenet Battery"))
|
||||
wm.BattRainSensor, _ = wm.meter.Int64Gauge("weather_batt_rain_sensor",
|
||||
metric.WithDescription("Rain Sensor Battery"))
|
||||
wm.BaromRelativeIn, _ = wm.meter.Float64Gauge("weather_barometric_pressure_relative_in",
|
||||
metric.WithDescription("Relative Pressure in Inches of Mercury"))
|
||||
wm.BaromAbsoluteIn, _ = wm.meter.Float64Gauge("weather_barometric_pressure_absolute_in",
|
||||
metric.WithDescription("Absolute Pressure in Inches of Mercury"))
|
||||
wm.DewPointF, _ = wm.meter.Float64Gauge("weather_dew_point_f",
|
||||
metric.WithDescription("Dew Point in Faherenheit"))
|
||||
wm.WindChillF, _ = wm.meter.Float64Gauge("weather_wind_chill_f",
|
||||
metric.WithDescription("Wind Chill in Faherenheit"))
|
||||
|
||||
// Internal Telemetry
|
||||
wm.UpdatesReceived, _ = wm.meter.Int64Counter("weather_updates_received",
|
||||
metric.WithDescription("Metric Updates Processed by Exporter"))
|
||||
|
||||
return wm
|
||||
recorder *MetricRecorder
|
||||
}
|
||||
|
||||
func (wm *WeatherMetrics) Update(u *WeatherUpdate) {
|
||||
attributes := attribute.NewSet(
|
||||
semconv.ServiceVersion(wm.cfg.Version),
|
||||
attribute.String("station_type", u.StationType),
|
||||
)
|
||||
attributes := wm.GetAttributes(u)
|
||||
|
||||
wm.TempOutdoorF.Record(wm.appCtx, u.TempOutdoorF, metric.WithAttributeSet(attributes))
|
||||
wm.TempIndoorF.Record(wm.appCtx, u.TempIndoorF, metric.WithAttributeSet(attributes))
|
||||
wm.HumidityOudoor.Record(wm.appCtx, int64(u.HumidityOudoor), metric.WithAttributeSet(attributes))
|
||||
wm.HumidityIndoor.Record(wm.appCtx, int64(u.HumidityIndoor), metric.WithAttributeSet(attributes))
|
||||
wm.WindSpeedMPH.Record(wm.appCtx, u.WindSpeedMPH, metric.WithAttributeSet(attributes))
|
||||
wm.WindGustMPH.Record(wm.appCtx, u.WindGustMPH, metric.WithAttributeSet(attributes))
|
||||
wm.MaxDailyGust.Record(wm.appCtx, u.MaxDailyGust, metric.WithAttributeSet(attributes))
|
||||
wm.WindDir.Record(wm.appCtx, int64(u.WindDir), metric.WithAttributeSet(attributes))
|
||||
wm.WindDirAvg10m.Record(wm.appCtx, int64(u.WindDirAvg10m), metric.WithAttributeSet(attributes))
|
||||
wm.UV.Record(wm.appCtx, int64(u.UV), metric.WithAttributeSet(attributes))
|
||||
wm.SolarRadiation.Record(wm.appCtx, u.SolarRadiation, metric.WithAttributeSet(attributes))
|
||||
wm.HourlyRainIn.Record(wm.appCtx, u.HourlyRainIn, metric.WithAttributeSet(attributes))
|
||||
wm.EventRainIn.Record(wm.appCtx, u.EventRainIn, metric.WithAttributeSet(attributes))
|
||||
wm.DailyRainIn.Record(wm.appCtx, u.DailyRainIn, metric.WithAttributeSet(attributes))
|
||||
wm.WeeklyRainIn.Record(wm.appCtx, u.WeeklyRainIn, metric.WithAttributeSet(attributes))
|
||||
wm.MonthlyRainIn.Record(wm.appCtx, u.MonthlyRainIn, metric.WithAttributeSet(attributes))
|
||||
wm.YearlyRainIn.Record(wm.appCtx, u.YearlyRainIn, metric.WithAttributeSet(attributes))
|
||||
wm.TotalRainIn.Record(wm.appCtx, u.TotalRainIn, metric.WithAttributeSet(attributes))
|
||||
wm.BattOutdoorSensor.Record(wm.appCtx, int64(u.BattOutdoorSensor), metric.WithAttributeSet(attributes))
|
||||
wm.BattIndoorSensor.Record(wm.appCtx, int64(u.BattIndoorSensor), metric.WithAttributeSet(attributes))
|
||||
wm.BattRainSensor.Record(wm.appCtx, int64(u.BattRainSensor), metric.WithAttributeSet(attributes))
|
||||
wm.BaromRelativeIn.Record(wm.appCtx, u.BaromRelativeIn, metric.WithAttributeSet(attributes))
|
||||
wm.BaromAbsoluteIn.Record(wm.appCtx, u.BaromAbsoluteIn, metric.WithAttributeSet(attributes))
|
||||
wm.DewPointF.Record(wm.appCtx, u.DewPointF, metric.WithAttributeSet(attributes))
|
||||
wm.WindChillF.Record(wm.appCtx, u.WindChillF, metric.WithAttributeSet(attributes))
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.TempOutdoorF, FloatVal: u.TempOutdoorF, Field: FieldTempOutdoorF, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.TempIndoorF, FloatVal: u.TempIndoorF, Field: FieldTempIndoorF, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Int64Gauge: wm.HumidityOudoor, IntVal: u.HumidityOudoor, Field: FieldHumidityOudoor, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Int64Gauge: wm.HumidityIndoor, IntVal: u.HumidityIndoor, Field: FieldHumidityIndoor, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.WindSpeedMPH, FloatVal: u.WindSpeedMPH, Field: FieldWindSpeedMPH, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.WindGustMPH, FloatVal: u.WindGustMPH, Field: FieldWindGustMPH, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.MaxDailyGust, FloatVal: u.MaxDailyGust, Field: FieldMaxDailyGust, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Int64Gauge: wm.WindDir, IntVal: u.WindDir, Field: FieldWindDir, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Int64Gauge: wm.WindDirAvg10m, IntVal: u.WindDirAvg10m, Field: FieldWindDirAvg10m, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Int64Gauge: wm.UV, IntVal: u.UV, Field: FieldUV, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.SolarRadiation, FloatVal: u.SolarRadiation, Field: FieldSolarRadiation, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.HourlyRainIn, FloatVal: u.HourlyRainIn, Field: FieldHourlyRainIn, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.EventRainIn, FloatVal: u.EventRainIn, Field: FieldEventRainIn, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.DailyRainIn, FloatVal: u.DailyRainIn, Field: FieldDailyRainIn, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.WeeklyRainIn, FloatVal: u.WeeklyRainIn, Field: FieldWeeklyRainIn, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.MonthlyRainIn, FloatVal: u.MonthlyRainIn, Field: FieldMonthlyRainIn, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.YearlyRainIn, FloatVal: u.YearlyRainIn, Field: FieldYearlyRainIn, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.TotalRainIn, FloatVal: u.TotalRainIn, Field: FieldTotalRainIn, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.BaromRelativeIn, FloatVal: u.BaromRelativeIn, Field: FieldBaromRelativeIn, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.BaromAbsoluteIn, FloatVal: u.BaromAbsoluteIn, Field: FieldBaromAbsoluteIn, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.DewPointF, FloatVal: u.DewPointF, Field: FieldDewPointF, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Float64Gauge: wm.WindChillF, FloatVal: u.WindChillF, Field: FieldWindChillF, Attributes: attributes, Station: u.StationConfig})
|
||||
|
||||
wm.RecordBatteries(u, attributes)
|
||||
wm.RecordTempHumiditySensors(u, attributes)
|
||||
|
||||
wm.UpdatesReceived.Add(wm.appCtx, 1)
|
||||
}
|
||||
|
||||
func (wm *WeatherMetrics) RecordBatteries(u *WeatherUpdate, attr []attribute.KeyValue) {
|
||||
for _, battery := range u.Batteries {
|
||||
batAttr := attr
|
||||
batAttr = append(batAttr, attribute.String("component", battery.Component))
|
||||
|
||||
wm.recorder.Record(&RecordOpts{
|
||||
Int64Gauge: wm.BatteryStatus,
|
||||
IntVal: battery.Status,
|
||||
Field: FieldBatteries,
|
||||
Attributes: batAttr,
|
||||
Station: u.StationConfig,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (wm *WeatherMetrics) RecordTempHumiditySensors(u *WeatherUpdate, attr []attribute.KeyValue) {
|
||||
if u == nil || u.TempHumiditySensors == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, sensor := range u.TempHumiditySensors {
|
||||
sensorAttr := attr
|
||||
sensorAttr = append(sensorAttr, attribute.String("sensorName", sensor.Name))
|
||||
|
||||
wm.recorder.Record(&RecordOpts{
|
||||
Float64Gauge: wm.SensorTempF,
|
||||
FloatVal: sensor.TempF,
|
||||
Field: FieldSensorTempF,
|
||||
Attributes: sensorAttr,
|
||||
Station: u.StationConfig,
|
||||
})
|
||||
wm.recorder.Record(&RecordOpts{
|
||||
Int64Gauge: wm.SensorHumidity,
|
||||
IntVal: sensor.Humidity,
|
||||
Field: FieldSensorHumidity,
|
||||
Attributes: sensorAttr,
|
||||
Station: u.StationConfig,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (wm *WeatherMetrics) GetAttributes(u *WeatherUpdate) []attribute.KeyValue {
|
||||
attributes := []attribute.KeyValue{
|
||||
semconv.ServiceVersion(wm.cfg.Version),
|
||||
semconv.ServiceName(wm.cfg.Name),
|
||||
semconv.DeploymentEnvironment(wm.cfg.Environment),
|
||||
}
|
||||
if u.StationType != nil {
|
||||
attributes = append(attributes,
|
||||
attribute.String("station_type", *u.StationType))
|
||||
}
|
||||
if u.StationConfig != nil {
|
||||
if u.StationConfig.Name != "" {
|
||||
attributes = append(attributes,
|
||||
attribute.String("station_name", u.StationConfig.Name))
|
||||
}
|
||||
if u.StationConfig.Equipment != "" {
|
||||
attributes = append(attributes,
|
||||
attribute.String("station_equipment", u.StationConfig.Equipment))
|
||||
}
|
||||
}
|
||||
|
||||
return attributes
|
||||
}
|
||||
|
80
pkg/weather/metrics_init.go
Normal file
80
pkg/weather/metrics_init.go
Normal file
@ -0,0 +1,80 @@
|
||||
package weather
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel"
|
||||
"github.com/rs/zerolog"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
)
|
||||
|
||||
func MustInitMetrics(appCtx context.Context) *WeatherMetrics {
|
||||
wm := &WeatherMetrics{
|
||||
appCtx: appCtx,
|
||||
cfg: config.MustFromCtx(appCtx),
|
||||
recorder: &MetricRecorder{ctx: appCtx, l: zerolog.Ctx(appCtx)},
|
||||
}
|
||||
|
||||
wm.meter = otel.GetMeter(appCtx, "weather", "metrics")
|
||||
|
||||
// Weather Metrics
|
||||
wm.TempOutdoorF, _ = wm.meter.Float64Gauge(MetricPrefix+"_temp_outdoor_f",
|
||||
metric.WithDescription("Outdoor Temperature in Faherenheit"))
|
||||
wm.TempIndoorF, _ = wm.meter.Float64Gauge(MetricPrefix+"_temp_indoor_f",
|
||||
metric.WithDescription("Indoor Temperature in Faherenheit"))
|
||||
wm.HumidityOudoor, _ = wm.meter.Int64Gauge(MetricPrefix+"_humidity_outdoor",
|
||||
metric.WithDescription("Outdoor Humidity %"))
|
||||
wm.HumidityIndoor, _ = wm.meter.Int64Gauge(MetricPrefix+"_humidity_indoor",
|
||||
metric.WithDescription("Indoor Humidity %"))
|
||||
wm.WindSpeedMPH, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_speed_mph",
|
||||
metric.WithDescription("Wind Speed in MPH"))
|
||||
wm.WindGustMPH, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_gust_mph",
|
||||
metric.WithDescription("Wind Gust in MPH"))
|
||||
wm.MaxDailyGust, _ = wm.meter.Float64Gauge(MetricPrefix+"_max_daily_gust",
|
||||
metric.WithDescription("Max Daily Wind Gust"))
|
||||
wm.WindDir, _ = wm.meter.Int64Gauge(MetricPrefix+"_wind_dir",
|
||||
metric.WithDescription("Wind Direction in Degrees"))
|
||||
wm.WindDirAvg10m, _ = wm.meter.Int64Gauge(MetricPrefix+"_wind_dir_avg_10m",
|
||||
metric.WithDescription("Wind Direction 10m Average"))
|
||||
wm.UV, _ = wm.meter.Int64Gauge(MetricPrefix+"_uv",
|
||||
metric.WithDescription("UV Index"))
|
||||
wm.SolarRadiation, _ = wm.meter.Float64Gauge(MetricPrefix+"_solar_radiation",
|
||||
metric.WithDescription("Solar Radiation in W/㎡"))
|
||||
wm.HourlyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_hourly_rain_in",
|
||||
metric.WithDescription("Hourly Rain in Inches"))
|
||||
wm.EventRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_event_rain_in",
|
||||
metric.WithDescription("Event Rain in Inches"))
|
||||
wm.DailyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_daily_rain_in",
|
||||
metric.WithDescription("Daily Rain in Inches"))
|
||||
wm.WeeklyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_weekly_rain_in",
|
||||
metric.WithDescription("Weekly Rain in Inches"))
|
||||
wm.MonthlyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_monthly_rain_in",
|
||||
metric.WithDescription("Monthly Rain in Inches"))
|
||||
wm.YearlyRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_yearly_rain_in",
|
||||
metric.WithDescription("Yearly Rain in Inches"))
|
||||
wm.TotalRainIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_total_rain_in",
|
||||
metric.WithDescription("Total Rain in Inches"))
|
||||
wm.BatteryStatus, _ = wm.meter.Int64Gauge(MetricPrefix+"_battery_status",
|
||||
metric.WithDescription("Per-component battery status"))
|
||||
wm.BaromRelativeIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_barometric_pressure_relative_in",
|
||||
metric.WithDescription("Relative Pressure in Inches of Mercury"))
|
||||
wm.BaromAbsoluteIn, _ = wm.meter.Float64Gauge(MetricPrefix+"_barometric_pressure_absolute_in",
|
||||
metric.WithDescription("Absolute Pressure in Inches of Mercury"))
|
||||
wm.DewPointF, _ = wm.meter.Float64Gauge(MetricPrefix+"_dew_point_f",
|
||||
metric.WithDescription("Dew Point in Faherenheit"))
|
||||
wm.WindChillF, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_chill_f",
|
||||
metric.WithDescription("Wind Chill in Faherenheit"))
|
||||
|
||||
// Temp and Humidity Sensors
|
||||
wm.SensorTempF, _ = wm.meter.Float64Gauge(MetricPrefix+"_sensor_temp_f",
|
||||
metric.WithDescription("Temperature Sensor in Faherenheit"))
|
||||
wm.SensorHumidity, _ = wm.meter.Int64Gauge(MetricPrefix+"_sensor_humidity",
|
||||
metric.WithDescription("Humidity % Sensor"))
|
||||
|
||||
// Internal Telemetry
|
||||
wm.UpdatesReceived, _ = wm.meter.Int64Counter(MetricPrefix+"_updates_received",
|
||||
metric.WithDescription("Metric Updates Processed by Exporter"))
|
||||
|
||||
return wm
|
||||
}
|
106
pkg/weather/metrics_record.go
Normal file
106
pkg/weather/metrics_record.go
Normal file
@ -0,0 +1,106 @@
|
||||
package weather
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient/config"
|
||||
)
|
||||
|
||||
type MetricRecorder struct {
|
||||
ctx context.Context
|
||||
l *zerolog.Logger
|
||||
}
|
||||
|
||||
type RecordOpts struct {
|
||||
Float64Gauge metric.Float64Gauge
|
||||
Int64Gauge metric.Int64Gauge
|
||||
IntVal *int
|
||||
FloatVal *float64
|
||||
Attributes []attribute.KeyValue
|
||||
Field string
|
||||
Station *config.WeatherStation
|
||||
}
|
||||
|
||||
func (r *MetricRecorder) Record(opts *RecordOpts) {
|
||||
if opts.Station != nil && !opts.keep() {
|
||||
r.l.Trace().
|
||||
Str("field", string(opts.Field)).
|
||||
Str("station", opts.Station.Name).
|
||||
Msg("Metric dropped by station config")
|
||||
return
|
||||
} else if opts.Int64Gauge == nil && opts.Float64Gauge == nil {
|
||||
r.l.Err(errors.New("neither int nor float gauge provided")).Send()
|
||||
return
|
||||
}
|
||||
|
||||
if opts.Int64Gauge != nil {
|
||||
if opts.IntVal == nil {
|
||||
log := r.l.Trace().Str("field", string(opts.Field))
|
||||
if opts.Station != nil {
|
||||
log = log.Str("station", opts.Station.Name)
|
||||
}
|
||||
log.Msg("Dropping nil int metric")
|
||||
return
|
||||
}
|
||||
r.recordInt(opts.Int64Gauge, *opts.IntVal, opts.Attributes...)
|
||||
} else if opts.Float64Gauge != nil {
|
||||
if opts.FloatVal == nil {
|
||||
log := r.l.Trace().Str("field", string(opts.Field))
|
||||
if opts.Station != nil {
|
||||
log = log.Str("station", opts.Station.Name)
|
||||
}
|
||||
log.Msg("Dropping nil float metric")
|
||||
return
|
||||
}
|
||||
r.recordFloat(opts.Float64Gauge, *opts.FloatVal, opts.Attributes...)
|
||||
}
|
||||
}
|
||||
|
||||
func (o *RecordOpts) keep() bool {
|
||||
// If keep fields are given, only check keep fields
|
||||
if len(o.Station.KeepMetrics) > 0 {
|
||||
for _, f := range o.Station.KeepMetrics {
|
||||
if f == o.Field {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
for _, f := range o.Station.DropMetrics {
|
||||
if f == o.Field {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (r *MetricRecorder) recordInt(
|
||||
m metric.Int64Gauge, value int, attributes ...attribute.KeyValue,
|
||||
) {
|
||||
// Prepare metric attributes
|
||||
options := make([]metric.RecordOption, 0, len(attributes))
|
||||
if len(attributes) > 0 {
|
||||
options = append(options, metric.WithAttributes(attributes...))
|
||||
}
|
||||
|
||||
val := int64(value)
|
||||
m.Record(r.ctx, val, options...)
|
||||
}
|
||||
|
||||
func (r *MetricRecorder) recordFloat(
|
||||
m metric.Float64Gauge, value float64, attributes ...attribute.KeyValue,
|
||||
) {
|
||||
// Prepare metric attributes
|
||||
options := make([]metric.RecordOption, 0, len(attributes))
|
||||
if len(attributes) > 0 {
|
||||
options = append(options, metric.WithAttributes(attributes...))
|
||||
}
|
||||
|
||||
m.Record(r.ctx, value, options...)
|
||||
}
|
@ -2,38 +2,93 @@ package weather
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient/config"
|
||||
)
|
||||
|
||||
// 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
|
||||
BattOutdoorSensor int
|
||||
BattIndoorSensor int
|
||||
BattRainSensor int
|
||||
BaromRelativeIn float64
|
||||
BaromAbsoluteIn float64
|
||||
DateUTC *time.Time
|
||||
StationConfig *config.WeatherStation
|
||||
StationID *string
|
||||
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
|
||||
// if not otherwise set
|
||||
DewPointF float64
|
||||
WindChillF float64
|
||||
DewPointF *float64
|
||||
WindChillF *float64
|
||||
// Extra Temp+Humidity Sensors
|
||||
TempHumiditySensors []*TempHumiditySensor
|
||||
}
|
||||
|
||||
type TempHumiditySensor struct {
|
||||
Name string
|
||||
TempF *float64
|
||||
Humidity *int
|
||||
}
|
||||
|
||||
type BatteryStatus struct {
|
||||
Component string
|
||||
Status *int
|
||||
}
|
||||
|
||||
// CHORE: Maintain this, used to check against
|
||||
// keep and drop lists
|
||||
// TODO: Use refelct/ast to generate code
|
||||
const (
|
||||
FieldDateUTC = "DateUTC"
|
||||
FieldStationType = "StationType"
|
||||
FieldTempOutdoorF = "TempOutdoorF"
|
||||
FieldTempIndoorF = "TempIndoorF"
|
||||
FieldHumidityOudoor = "HumidityOudoor"
|
||||
FieldHumidityIndoor = "HumidityIndoor"
|
||||
FieldWindSpeedMPH = "WindSpeedMPH"
|
||||
FieldWindGustMPH = "WindGustMPH"
|
||||
FieldMaxDailyGust = "MaxDailyGust"
|
||||
FieldWindDir = "WindDir"
|
||||
FieldWindDirAvg10m = "WindDirAvg10m"
|
||||
FieldUV = "UV"
|
||||
FieldSolarRadiation = "SolarRadiation"
|
||||
FieldHourlyRainIn = "HourlyRainIn"
|
||||
FieldEventRainIn = "EventRainIn"
|
||||
FieldDailyRainIn = "DailyRainIn"
|
||||
FieldWeeklyRainIn = "WeeklyRainIn"
|
||||
FieldMonthlyRainIn = "MonthlyRainIn"
|
||||
FieldYearlyRainIn = "YearlyRainIn"
|
||||
FieldTotalRainIn = "TotalRainIn"
|
||||
FieldBatteries = "Batteries"
|
||||
FieldBaromRelativeIn = "BaromRelativeIn"
|
||||
FieldBaromAbsoluteIn = "BaromAbsoluteIn"
|
||||
FieldDewPointF = "DewPointF"
|
||||
FieldWindChillF = "WindChillF"
|
||||
FieldSensorTempF = "SensorTempF"
|
||||
FieldSensorHumidity = "SensorHumidity"
|
||||
)
|
||||
|
||||
func (u *WeatherUpdate) GetStationName() string {
|
||||
if u.StationConfig != nil {
|
||||
return u.StationConfig.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
63
proto/weather/weather.proto
Normal file
63
proto/weather/weather.proto
Normal file
@ -0,0 +1,63 @@
|
||||
syntax = "proto3";
|
||||
package ambient.weather;
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather";
|
||||
|
||||
message GetWeatherRequest {
|
||||
GetWeatherOpts opts = 1;
|
||||
}
|
||||
|
||||
message GetWeatherResponse{
|
||||
google.protobuf.Timestamp last_updated = 1;
|
||||
repeated WeatherUpdate weather_updates = 2;
|
||||
}
|
||||
|
||||
message GetWeatherOpts {
|
||||
optional string station_name = 1;
|
||||
optional string station_type = 2;
|
||||
}
|
||||
|
||||
message WeatherUpdate {
|
||||
string station_name = 1;
|
||||
string station_type = 2;
|
||||
string station_id = 3;
|
||||
optional double temp_outdoor_f = 4;
|
||||
optional double temp_indoor_f = 5;
|
||||
optional int32 humidity_outdoor = 6;
|
||||
optional int32 humidity_indoor = 7;
|
||||
optional double wind_speed_mph = 8;
|
||||
optional double wind_gust_mph = 9;
|
||||
optional double max_daily_gust = 10;
|
||||
optional int32 wind_dir = 11;
|
||||
optional int32 wind_dir_avg_10m = 12;
|
||||
optional int32 uv = 13;
|
||||
optional double solar_radiation = 14;
|
||||
optional double hourly_rain_in = 15;
|
||||
optional double event_rain_in = 16;
|
||||
optional double daily_rain_in = 17;
|
||||
optional double weekly_rain_in = 18;
|
||||
optional double monthly_rain_in = 19;
|
||||
optional double yearly_rain_in = 20;
|
||||
optional double total_rain_in = 21;
|
||||
repeated BatteryStatus batteries = 22;
|
||||
optional double barom_relative_in = 23;
|
||||
optional double barom_absolute_in = 24;
|
||||
optional double dew_point_f = 25;
|
||||
optional double wind_chill_f = 26;
|
||||
repeated TempHumiditySensor temp_humidity_sensors = 27;
|
||||
}
|
||||
|
||||
// Represents a temperature and humidity sensor
|
||||
message TempHumiditySensor {
|
||||
string name = 1;
|
||||
optional double temp_f = 2;
|
||||
optional int32 humidity = 3;
|
||||
}
|
||||
|
||||
// Represents battery status for different components
|
||||
message BatteryStatus {
|
||||
string component = 1;
|
||||
optional int32 status = 2;
|
||||
}
|
10
proto/weather/weather_service.proto
Normal file
10
proto/weather/weather_service.proto
Normal file
@ -0,0 +1,10 @@
|
||||
syntax = "proto3";
|
||||
package ambient.weather;
|
||||
|
||||
import "weather/weather.proto";
|
||||
|
||||
option go_package = "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather";
|
||||
|
||||
service AmbientLocalWeatherService {
|
||||
rpc GetWeather(GetWeatherRequest) returns (GetWeatherResponse);
|
||||
}
|
Reference in New Issue
Block a user