Compare commits
	
		
			10 Commits
		
	
	
		
			v0.15.0
			...
			f0bda0a3bd
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| f0bda0a3bd | |||
| 1ee231fe30 | |||
| 3279c6fd38 | |||
| 268bc7d8a2 | |||
| 2f83edc426 | |||
| 80f9c00615 | |||
| 53c22ab8c7 | |||
| 35374ab6e0 | |||
| dcb60e6898 | |||
| e2c464b34e | 
							
								
								
									
										1
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								TODO.md
									
									
									
									
									
								
							@@ -2,6 +2,7 @@
 | 
				
			|||||||
- [x] Redis recorder panic
 | 
					- [x] Redis recorder panic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# TODO
 | 
					# TODO
 | 
				
			||||||
 | 
					- [ ] Make lightning distance unit configurable (kph|mph)
 | 
				
			||||||
- [ ] Set TTL on redis key
 | 
					- [ ] Set TTL on redis key
 | 
				
			||||||
- [ ] Add json schema to CI and README
 | 
					- [ ] Add json schema to CI and README
 | 
				
			||||||
- [ ] Update README
 | 
					- [ ] Update README
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -296,6 +296,8 @@ type WeatherUpdate struct {
 | 
				
			|||||||
	WindChillF          *float64               `protobuf:"fixed64,26,opt,name=wind_chill_f,json=windChillF,proto3,oneof" json:"wind_chill_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"`
 | 
						TempHumiditySensors []*TempHumiditySensor  `protobuf:"bytes,27,rep,name=temp_humidity_sensors,json=tempHumiditySensors,proto3" json:"temp_humidity_sensors,omitempty"`
 | 
				
			||||||
	UpdateTimestamp     *timestamppb.Timestamp `protobuf:"bytes,28,opt,name=update_timestamp,json=updateTimestamp,proto3" json:"update_timestamp,omitempty"`
 | 
						UpdateTimestamp     *timestamppb.Timestamp `protobuf:"bytes,28,opt,name=update_timestamp,json=updateTimestamp,proto3" json:"update_timestamp,omitempty"`
 | 
				
			||||||
 | 
						LightningDay        *int32                 `protobuf:"varint,29,opt,name=lightning_day,json=lightningDay,proto3,oneof" json:"lightning_day,omitempty"`
 | 
				
			||||||
 | 
						LightningDistance   *int32                 `protobuf:"varint,30,opt,name=lightning_distance,json=lightningDistance,proto3,oneof" json:"lightning_distance,omitempty"`
 | 
				
			||||||
	unknownFields       protoimpl.UnknownFields
 | 
						unknownFields       protoimpl.UnknownFields
 | 
				
			||||||
	sizeCache           protoimpl.SizeCache
 | 
						sizeCache           protoimpl.SizeCache
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -526,6 +528,20 @@ func (x *WeatherUpdate) GetUpdateTimestamp() *timestamppb.Timestamp {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (x *WeatherUpdate) GetLightningDay() int32 {
 | 
				
			||||||
 | 
						if x != nil && x.LightningDay != nil {
 | 
				
			||||||
 | 
							return *x.LightningDay
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (x *WeatherUpdate) GetLightningDistance() int32 {
 | 
				
			||||||
 | 
						if x != nil && x.LightningDistance != nil {
 | 
				
			||||||
 | 
							return *x.LightningDistance
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return 0
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Represents a temperature and humidity sensor
 | 
					// Represents a temperature and humidity sensor
 | 
				
			||||||
type TempHumiditySensor struct {
 | 
					type TempHumiditySensor struct {
 | 
				
			||||||
	state         protoimpl.MessageState `protogen:"open.v1"`
 | 
						state         protoimpl.MessageState `protogen:"open.v1"`
 | 
				
			||||||
@@ -660,7 +676,7 @@ const file_weather_weather_proto_rawDesc = "" +
 | 
				
			|||||||
	"\fstation_name\x18\x01 \x01(\tH\x00R\vstationName\x88\x01\x01\x12&\n" +
 | 
						"\fstation_name\x18\x01 \x01(\tH\x00R\vstationName\x88\x01\x01\x12&\n" +
 | 
				
			||||||
	"\fstation_type\x18\x02 \x01(\tH\x01R\vstationType\x88\x01\x01B\x0f\n" +
 | 
						"\fstation_type\x18\x02 \x01(\tH\x01R\vstationType\x88\x01\x01B\x0f\n" +
 | 
				
			||||||
	"\r_station_nameB\x0f\n" +
 | 
						"\r_station_nameB\x0f\n" +
 | 
				
			||||||
	"\r_station_type\"\xfe\f\n" +
 | 
						"\r_station_type\"\x85\x0e\n" +
 | 
				
			||||||
	"\rWeatherUpdate\x12!\n" +
 | 
						"\rWeatherUpdate\x12!\n" +
 | 
				
			||||||
	"\fstation_name\x18\x01 \x01(\tR\vstationName\x12!\n" +
 | 
						"\fstation_name\x18\x01 \x01(\tR\vstationName\x12!\n" +
 | 
				
			||||||
	"\fstation_type\x18\x02 \x01(\tR\vstationType\x12\x1d\n" +
 | 
						"\fstation_type\x18\x02 \x01(\tR\vstationType\x12\x1d\n" +
 | 
				
			||||||
@@ -693,7 +709,9 @@ const file_weather_weather_proto_rawDesc = "" +
 | 
				
			|||||||
	"\fwind_chill_f\x18\x1a \x01(\x01H\x15R\n" +
 | 
						"\fwind_chill_f\x18\x1a \x01(\x01H\x15R\n" +
 | 
				
			||||||
	"windChillF\x88\x01\x01\x12W\n" +
 | 
						"windChillF\x88\x01\x01\x12W\n" +
 | 
				
			||||||
	"\x15temp_humidity_sensors\x18\x1b \x03(\v2#.ambient.weather.TempHumiditySensorR\x13tempHumiditySensors\x12E\n" +
 | 
						"\x15temp_humidity_sensors\x18\x1b \x03(\v2#.ambient.weather.TempHumiditySensorR\x13tempHumiditySensors\x12E\n" +
 | 
				
			||||||
	"\x10update_timestamp\x18\x1c \x01(\v2\x1a.google.protobuf.TimestampR\x0fupdateTimestampB\x11\n" +
 | 
						"\x10update_timestamp\x18\x1c \x01(\v2\x1a.google.protobuf.TimestampR\x0fupdateTimestamp\x12(\n" +
 | 
				
			||||||
 | 
						"\rlightning_day\x18\x1d \x01(\x05H\x16R\flightningDay\x88\x01\x01\x122\n" +
 | 
				
			||||||
 | 
						"\x12lightning_distance\x18\x1e \x01(\x05H\x17R\x11lightningDistance\x88\x01\x01B\x11\n" +
 | 
				
			||||||
	"\x0f_temp_outdoor_fB\x10\n" +
 | 
						"\x0f_temp_outdoor_fB\x10\n" +
 | 
				
			||||||
	"\x0e_temp_indoor_fB\x13\n" +
 | 
						"\x0e_temp_indoor_fB\x13\n" +
 | 
				
			||||||
	"\x11_humidity_outdoorB\x12\n" +
 | 
						"\x11_humidity_outdoorB\x12\n" +
 | 
				
			||||||
@@ -715,7 +733,9 @@ const file_weather_weather_proto_rawDesc = "" +
 | 
				
			|||||||
	"\x12_barom_relative_inB\x14\n" +
 | 
						"\x12_barom_relative_inB\x14\n" +
 | 
				
			||||||
	"\x12_barom_absolute_inB\x0e\n" +
 | 
						"\x12_barom_absolute_inB\x0e\n" +
 | 
				
			||||||
	"\f_dew_point_fB\x0f\n" +
 | 
						"\f_dew_point_fB\x0f\n" +
 | 
				
			||||||
	"\r_wind_chill_f\"}\n" +
 | 
						"\r_wind_chill_fB\x10\n" +
 | 
				
			||||||
 | 
						"\x0e_lightning_dayB\x15\n" +
 | 
				
			||||||
 | 
						"\x13_lightning_distance\"}\n" +
 | 
				
			||||||
	"\x12TempHumiditySensor\x12\x12\n" +
 | 
						"\x12TempHumiditySensor\x12\x12\n" +
 | 
				
			||||||
	"\x04name\x18\x01 \x01(\tR\x04name\x12\x1a\n" +
 | 
						"\x04name\x18\x01 \x01(\tR\x04name\x12\x1a\n" +
 | 
				
			||||||
	"\x06temp_f\x18\x02 \x01(\x01H\x00R\x05tempF\x88\x01\x01\x12\x1f\n" +
 | 
						"\x06temp_f\x18\x02 \x01(\x01H\x00R\x05tempF\x88\x01\x01\x12\x1f\n" +
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -308,6 +308,14 @@
 | 
				
			|||||||
        "updateTimestamp": {
 | 
					        "updateTimestamp": {
 | 
				
			||||||
          "type": "string",
 | 
					          "type": "string",
 | 
				
			||||||
          "format": "date-time"
 | 
					          "format": "date-time"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "lightningDay": {
 | 
				
			||||||
 | 
					          "type": "integer",
 | 
				
			||||||
 | 
					          "format": "int32"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "lightningDistance": {
 | 
				
			||||||
 | 
					          "type": "integer",
 | 
				
			||||||
 | 
					          "format": "int32"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,13 +15,13 @@ type: application
 | 
				
			|||||||
# This is the chart version. This version number should be incremented each time you make changes
 | 
					# This is the chart version. This version number should be incremented each time you make changes
 | 
				
			||||||
# to the chart and its templates, including the app version.
 | 
					# to the chart and its templates, including the app version.
 | 
				
			||||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
 | 
					# Versions are expected to follow Semantic Versioning (https://semver.org/)
 | 
				
			||||||
version: 0.1.8
 | 
					version: 0.1.10
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This is the version number of the application being deployed. This version number should be
 | 
					# This is the version number of the application being deployed. This version number should be
 | 
				
			||||||
# incremented each time you make changes to the application. Versions are not expected to
 | 
					# incremented each time you make changes to the application. Versions are not expected to
 | 
				
			||||||
# follow Semantic Versioning. They should reflect the version the application is using.
 | 
					# follow Semantic Versioning. They should reflect the version the application is using.
 | 
				
			||||||
# It is recommended to use it with quotes.
 | 
					# It is recommended to use it with quotes.
 | 
				
			||||||
appVersion: "v0.14.0"
 | 
					appVersion: "v0.15.6"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dependencies:
 | 
					dependencies:
 | 
				
			||||||
  - name: hull
 | 
					  - name: hull
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,6 +59,8 @@ func UpdateToPbUpdate(u *weather.WeatherUpdate) *pb.WeatherUpdate {
 | 
				
			|||||||
		WindChillF:          u.WindChillF,
 | 
							WindChillF:          u.WindChillF,
 | 
				
			||||||
		TempHumiditySensors: thSensorsToPbSensors(u.TempHumiditySensors),
 | 
							TempHumiditySensors: thSensorsToPbSensors(u.TempHumiditySensors),
 | 
				
			||||||
		UpdateTimestamp:     timestamppb.New(*u.DateUTC),
 | 
							UpdateTimestamp:     timestamppb.New(*u.DateUTC),
 | 
				
			||||||
 | 
							LightningDay:        util.Int32ptr(u.LightningDay),
 | 
				
			||||||
 | 
							LightningDistance:   util.Int32ptr(u.LightningDistance),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,6 +52,8 @@ var mockUpdate = &weather.WeatherUpdate{
 | 
				
			|||||||
	TempHumiditySensors: []*weather.TempHumiditySensor{
 | 
						TempHumiditySensors: []*weather.TempHumiditySensor{
 | 
				
			||||||
		{Name: "sensor1", TempF: ptr.To(99.999), Humidity: nil},
 | 
							{Name: "sensor1", TempF: ptr.To(99.999), Humidity: nil},
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						LightningDay:      ptr.To(1),
 | 
				
			||||||
 | 
						LightningDistance: ptr.To(20),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestUpdateToPbUpdate(t *testing.T) {
 | 
					func TestUpdateToPbUpdate(t *testing.T) {
 | 
				
			||||||
@@ -103,7 +105,9 @@ func TestUpdateToPbUpdate(t *testing.T) {
 | 
				
			|||||||
						Humidity: nil,
 | 
											Humidity: nil,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				UpdateTimestamp: timestamppb.New(now),
 | 
									UpdateTimestamp:   timestamppb.New(now),
 | 
				
			||||||
 | 
									LightningDay:      ptr.To(int32(1)),
 | 
				
			||||||
 | 
									LightningDistance: ptr.To(int32(20)),
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,11 +20,12 @@ const (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Battery Sensors
 | 
					// Battery Sensors
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	BattOutdoorSensor = "OutdoorSensor"
 | 
						BattOutdoorSensor   = "OutdoorSensor"
 | 
				
			||||||
	BattIndoorSensor  = "IndoorSensor"
 | 
						BattIndoorSensor    = "IndoorSensor"
 | 
				
			||||||
	BattRainSensor    = "RainSensor"
 | 
						BattRainSensor      = "RainSensor"
 | 
				
			||||||
	BattCO2Sensor     = "CO2Sensor"
 | 
						BattCO2Sensor       = "CO2Sensor"
 | 
				
			||||||
	THSensor          = "TempHumiditySensor"
 | 
						BattLightningSensor = "LightningSensor"
 | 
				
			||||||
 | 
						THSensor            = "TempHumiditySensor"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (awn *AWNProvider) Name() string {
 | 
					func (awn *AWNProvider) Name() string {
 | 
				
			||||||
@@ -74,6 +75,10 @@ func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
 | 
				
			|||||||
		YearlyRainIn:   awnUpdate.YearlyRainIn,
 | 
							YearlyRainIn:   awnUpdate.YearlyRainIn,
 | 
				
			||||||
		TotalRainIn:    awnUpdate.TotalRainIn,
 | 
							TotalRainIn:    awnUpdate.TotalRainIn,
 | 
				
			||||||
		Batteries: []weather.BatteryStatus{
 | 
							Batteries: []weather.BatteryStatus{
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									Component: BattLightningSensor,
 | 
				
			||||||
 | 
									Status:    awnUpdate.BattLightning,
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				Component: BattOutdoorSensor,
 | 
									Component: BattOutdoorSensor,
 | 
				
			||||||
				Status:    awnUpdate.BattOut,
 | 
									Status:    awnUpdate.BattOut,
 | 
				
			||||||
@@ -138,6 +143,9 @@ func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
 | 
				
			|||||||
			{Name: THSensor + "7", TempF: awnUpdate.Temp7F, Humidity: awnUpdate.Humidity7},
 | 
								{Name: THSensor + "7", TempF: awnUpdate.Temp7F, Humidity: awnUpdate.Humidity7},
 | 
				
			||||||
			{Name: THSensor + "8", TempF: awnUpdate.Temp8F, Humidity: awnUpdate.Humidity8},
 | 
								{Name: THSensor + "8", TempF: awnUpdate.Temp8F, Humidity: awnUpdate.Humidity8},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							LightningDay:      awnUpdate.LightningDay,
 | 
				
			||||||
 | 
							LightningDistance: awnUpdate.LightningDistance,
 | 
				
			||||||
 | 
							LightningTime:     awnUpdate.LightningTime,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -145,6 +153,8 @@ func UnmarshalQueryParams(query url.Values) (*AmbientWeatherUpdate, error) {
 | 
				
			|||||||
	update := new(AmbientWeatherUpdate)
 | 
						update := new(AmbientWeatherUpdate)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	decoder := schema.NewDecoder()
 | 
						decoder := schema.NewDecoder()
 | 
				
			||||||
 | 
						decoder.IgnoreUnknownKeys(true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err := decoder.Decode(update, query); err != nil {
 | 
						if err := decoder.Decode(update, query); err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,8 +33,10 @@ type AmbientWeatherUpdate struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type AmbientLightningData struct {
 | 
					type AmbientLightningData struct {
 | 
				
			||||||
	BattLightning *int `json:"batt_lightning,omitempty" schema:"batt_lightning"`
 | 
						BattLightning     *int `json:"batt_lightning,omitempty" schema:"batt_lightning"`
 | 
				
			||||||
	LightningDay  *int `json:"lightning_day,omitempty" schema:"lightning_day"`
 | 
						LightningDay      *int `json:"lightning_day,omitempty" schema:"lightning_day" description:"count of lightning detections"`
 | 
				
			||||||
 | 
						LightningDistance *int `json:"lightning_distance,omitempty" schema:"lightning_distance" description:"distance in kilometers"`
 | 
				
			||||||
 | 
						LightningTime     *int `json:"lightningTime,omitempty" schema:"lightningTime" description:"last lightning detection time"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type AmbientTempHumiditySensors struct {
 | 
					type AmbientTempHumiditySensors struct {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,6 +37,10 @@ type WeatherMetrics struct {
 | 
				
			|||||||
	DewPointF       metric.Float64Gauge
 | 
						DewPointF       metric.Float64Gauge
 | 
				
			||||||
	WindChillF      metric.Float64Gauge
 | 
						WindChillF      metric.Float64Gauge
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Lightning Sensor
 | 
				
			||||||
 | 
						LightningCountDay     metric.Int64Gauge
 | 
				
			||||||
 | 
						LightningLastDistance metric.Int64Gauge
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Temp and Humidity Sensors
 | 
						// Temp and Humidity Sensors
 | 
				
			||||||
	SensorTempF    metric.Float64Gauge
 | 
						SensorTempF    metric.Float64Gauge
 | 
				
			||||||
	SensorHumidity metric.Int64Gauge
 | 
						SensorHumidity metric.Int64Gauge
 | 
				
			||||||
@@ -75,6 +79,10 @@ func (wm *WeatherMetrics) Update(u *WeatherUpdate) {
 | 
				
			|||||||
	wm.recorder.Record(&RecordOpts{Float64Gauge: wm.DewPointF, FloatVal: u.DewPointF, Field: FieldDewPointF, 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.recorder.Record(&RecordOpts{Float64Gauge: wm.WindChillF, FloatVal: u.WindChillF, Field: FieldWindChillF, Attributes: attributes, Station: u.StationConfig})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						lightningAttributes := append(attributes, attribute.String("unit", "km"))
 | 
				
			||||||
 | 
						wm.recorder.Record(&RecordOpts{Int64Gauge: wm.LightningLastDistance, IntVal: u.LightningDistance, Field: FieldLightningDistance, Attributes: lightningAttributes, Station: u.StationConfig})
 | 
				
			||||||
 | 
						wm.recorder.Record(&RecordOpts{Int64Gauge: wm.LightningCountDay, IntVal: u.LightningDay, Field: FieldLightningDay, Attributes: attributes, Station: u.StationConfig})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wm.RecordBatteries(u, attributes)
 | 
						wm.RecordBatteries(u, attributes)
 | 
				
			||||||
	wm.RecordTempHumiditySensors(u, attributes)
 | 
						wm.RecordTempHumiditySensors(u, attributes)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,6 +66,12 @@ func MustInitMetrics(appCtx context.Context) *WeatherMetrics {
 | 
				
			|||||||
	wm.WindChillF, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_chill_f",
 | 
						wm.WindChillF, _ = wm.meter.Float64Gauge(MetricPrefix+"_wind_chill_f",
 | 
				
			||||||
		metric.WithDescription("Wind Chill in Faherenheit"))
 | 
							metric.WithDescription("Wind Chill in Faherenheit"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Lightning Sensor
 | 
				
			||||||
 | 
						wm.LightningCountDay, _ = wm.meter.Int64Gauge(MetricPrefix+"_lightning_day",
 | 
				
			||||||
 | 
							metric.WithDescription("Count of lightning strikes for current day"))
 | 
				
			||||||
 | 
						wm.LightningLastDistance, _ = wm.meter.Int64Gauge(MetricPrefix+"_lightning_last_distance",
 | 
				
			||||||
 | 
							metric.WithDescription("Last measured lightning distance"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Temp and Humidity Sensors
 | 
						// Temp and Humidity Sensors
 | 
				
			||||||
	wm.SensorTempF, _ = wm.meter.Float64Gauge(MetricPrefix+"_sensor_temp_f",
 | 
						wm.SensorTempF, _ = wm.meter.Float64Gauge(MetricPrefix+"_sensor_temp_f",
 | 
				
			||||||
		metric.WithDescription("Temperature Sensor in Faherenheit"))
 | 
							metric.WithDescription("Temperature Sensor in Faherenheit"))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,7 @@ package weather
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
 | 
						"slices"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/rs/zerolog"
 | 
						"github.com/rs/zerolog"
 | 
				
			||||||
	"go.opentelemetry.io/otel/attribute"
 | 
						"go.opentelemetry.io/otel/attribute"
 | 
				
			||||||
@@ -64,20 +65,10 @@ func (r *MetricRecorder) Record(opts *RecordOpts) {
 | 
				
			|||||||
func (o *RecordOpts) keep() bool {
 | 
					func (o *RecordOpts) keep() bool {
 | 
				
			||||||
	// If keep fields are given, only check keep fields
 | 
						// If keep fields are given, only check keep fields
 | 
				
			||||||
	if len(o.Station.KeepMetrics) > 0 {
 | 
						if len(o.Station.KeepMetrics) > 0 {
 | 
				
			||||||
		for _, f := range o.Station.KeepMetrics {
 | 
							return slices.Contains(o.Station.KeepMetrics, o.Field)
 | 
				
			||||||
			if f == o.Field {
 | 
					 | 
				
			||||||
				return true
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return false
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, f := range o.Station.DropMetrics {
 | 
						return !slices.Contains(o.Station.DropMetrics, o.Field)
 | 
				
			||||||
		if f == o.Field {
 | 
					 | 
				
			||||||
			return false
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return true
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (r *MetricRecorder) recordInt(
 | 
					func (r *MetricRecorder) recordInt(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,81 +9,87 @@ import (
 | 
				
			|||||||
// Stable intermediate struct containing superset of fields
 | 
					// Stable intermediate struct containing superset of fields
 | 
				
			||||||
// between AWN and Wunderground style updates from Ambient devices
 | 
					// between AWN and Wunderground style updates from Ambient devices
 | 
				
			||||||
type WeatherUpdate struct {
 | 
					type WeatherUpdate struct {
 | 
				
			||||||
	DateUTC         *time.Time
 | 
						DateUTC         *time.Time             `json:"dateUTC,omitempty"`
 | 
				
			||||||
	StationConfig   *config.WeatherStation
 | 
						StationConfig   *config.WeatherStation `json:"stationConfig,omitempty"`
 | 
				
			||||||
	StationID       *string
 | 
						StationID       *string                `json:"stationID,omitempty"`
 | 
				
			||||||
	StationType     *string
 | 
						StationType     *string                `json:"stationType,omitempty"`
 | 
				
			||||||
	TempOutdoorF    *float64
 | 
						TempOutdoorF    *float64               `json:"tempOutdoorF,omitempty"`
 | 
				
			||||||
	TempIndoorF     *float64
 | 
						TempIndoorF     *float64               `json:"tempIndoorF,omitempty"`
 | 
				
			||||||
	HumidityOudoor  *int
 | 
						HumidityOudoor  *int                   `json:"humidityOudoor,omitempty"`
 | 
				
			||||||
	HumidityIndoor  *int
 | 
						HumidityIndoor  *int                   `json:"humidityIndoor,omitempty"`
 | 
				
			||||||
	WindSpeedMPH    *float64
 | 
						WindSpeedMPH    *float64               `json:"windSpeedMPH,omitempty"`
 | 
				
			||||||
	WindGustMPH     *float64
 | 
						WindGustMPH     *float64               `json:"windGustMPH,omitempty"`
 | 
				
			||||||
	MaxDailyGust    *float64
 | 
						MaxDailyGust    *float64               `json:"maxDailyGust,omitempty"`
 | 
				
			||||||
	WindDir         *int
 | 
						WindDir         *int                   `json:"windDir,omitempty"`
 | 
				
			||||||
	WindDirAvg10m   *int
 | 
						WindDirAvg10m   *int                   `json:"windDirAvg10M,omitempty"`
 | 
				
			||||||
	UV              *int
 | 
						UV              *int                   `json:"uv,omitempty"`
 | 
				
			||||||
	SolarRadiation  *float64
 | 
						SolarRadiation  *float64               `json:"solarRadiation,omitempty"`
 | 
				
			||||||
	HourlyRainIn    *float64
 | 
						HourlyRainIn    *float64               `json:"hourlyRainIn,omitempty"`
 | 
				
			||||||
	EventRainIn     *float64
 | 
						EventRainIn     *float64               `json:"eventRainIn,omitempty"`
 | 
				
			||||||
	DailyRainIn     *float64
 | 
						DailyRainIn     *float64               `json:"dailyRainIn,omitempty"`
 | 
				
			||||||
	WeeklyRainIn    *float64
 | 
						WeeklyRainIn    *float64               `json:"weeklyRainIn,omitempty"`
 | 
				
			||||||
	MonthlyRainIn   *float64
 | 
						MonthlyRainIn   *float64               `json:"monthlyRainIn,omitempty"`
 | 
				
			||||||
	YearlyRainIn    *float64
 | 
						YearlyRainIn    *float64               `json:"yearlyRainIn,omitempty"`
 | 
				
			||||||
	TotalRainIn     *float64
 | 
						TotalRainIn     *float64               `json:"totalRainIn,omitempty"`
 | 
				
			||||||
	Batteries       []BatteryStatus
 | 
						Batteries       []BatteryStatus        `json:"batteries,omitempty"`
 | 
				
			||||||
	BaromRelativeIn *float64
 | 
						BaromRelativeIn *float64               `json:"baromRelativeIn,omitempty"`
 | 
				
			||||||
	BaromAbsoluteIn *float64
 | 
						BaromAbsoluteIn *float64               `json:"baromAbsoluteIn,omitempty"`
 | 
				
			||||||
	// These fields may be calculated
 | 
						// These fields may be calculated
 | 
				
			||||||
	// if not otherwise set
 | 
						// if not otherwise set
 | 
				
			||||||
	DewPointF  *float64
 | 
						DewPointF  *float64 `json:"dewPointF,omitempty"`
 | 
				
			||||||
	WindChillF *float64
 | 
						WindChillF *float64 `json:"windChillF,omitempty"`
 | 
				
			||||||
	// Extra Temp+Humidity Sensors
 | 
						// Extra Temp+Humidity Sensors
 | 
				
			||||||
	TempHumiditySensors []*TempHumiditySensor
 | 
						TempHumiditySensors []*TempHumiditySensor `json:"tempHumiditySensors,omitempty"`
 | 
				
			||||||
 | 
						// Lightning Data
 | 
				
			||||||
 | 
						LightningDay      *int `json:"lightningDay,omitempty"`      // Count of detections
 | 
				
			||||||
 | 
						LightningDistance *int `json:"lightningDistance,omitempty"` // Last detection distance [kilometers]
 | 
				
			||||||
 | 
						LightningTime     *int `json:"lightningTime,omitempty"`     // Last detection time
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type TempHumiditySensor struct {
 | 
					type TempHumiditySensor struct {
 | 
				
			||||||
	Name     string
 | 
						Name     string   `json:"name,omitempty"`
 | 
				
			||||||
	TempF    *float64
 | 
						TempF    *float64 `json:"tempF,omitempty"`
 | 
				
			||||||
	Humidity *int
 | 
						Humidity *int     `json:"humidity,omitempty"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type BatteryStatus struct {
 | 
					type BatteryStatus struct {
 | 
				
			||||||
	Component string
 | 
						Component string `json:"component,omitempty"`
 | 
				
			||||||
	Status    *int
 | 
						Status    *int   `json:"status,omitempty"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// CHORE: Maintain this, used to check against
 | 
					// CHORE: Maintain this, used to check against
 | 
				
			||||||
// keep and drop lists
 | 
					// keep and drop lists
 | 
				
			||||||
// TODO: Use refelct/ast to generate code
 | 
					// TODO: Use refelct/ast to generate code
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	FieldDateUTC         = "DateUTC"
 | 
						FieldDateUTC           = "DateUTC"
 | 
				
			||||||
	FieldStationType     = "StationType"
 | 
						FieldStationType       = "StationType"
 | 
				
			||||||
	FieldTempOutdoorF    = "TempOutdoorF"
 | 
						FieldTempOutdoorF      = "TempOutdoorF"
 | 
				
			||||||
	FieldTempIndoorF     = "TempIndoorF"
 | 
						FieldTempIndoorF       = "TempIndoorF"
 | 
				
			||||||
	FieldHumidityOudoor  = "HumidityOudoor"
 | 
						FieldHumidityOudoor    = "HumidityOudoor"
 | 
				
			||||||
	FieldHumidityIndoor  = "HumidityIndoor"
 | 
						FieldHumidityIndoor    = "HumidityIndoor"
 | 
				
			||||||
	FieldWindSpeedMPH    = "WindSpeedMPH"
 | 
						FieldWindSpeedMPH      = "WindSpeedMPH"
 | 
				
			||||||
	FieldWindGustMPH     = "WindGustMPH"
 | 
						FieldWindGustMPH       = "WindGustMPH"
 | 
				
			||||||
	FieldMaxDailyGust    = "MaxDailyGust"
 | 
						FieldMaxDailyGust      = "MaxDailyGust"
 | 
				
			||||||
	FieldWindDir         = "WindDir"
 | 
						FieldWindDir           = "WindDir"
 | 
				
			||||||
	FieldWindDirAvg10m   = "WindDirAvg10m"
 | 
						FieldWindDirAvg10m     = "WindDirAvg10m"
 | 
				
			||||||
	FieldUV              = "UV"
 | 
						FieldUV                = "UV"
 | 
				
			||||||
	FieldSolarRadiation  = "SolarRadiation"
 | 
						FieldSolarRadiation    = "SolarRadiation"
 | 
				
			||||||
	FieldHourlyRainIn    = "HourlyRainIn"
 | 
						FieldHourlyRainIn      = "HourlyRainIn"
 | 
				
			||||||
	FieldEventRainIn     = "EventRainIn"
 | 
						FieldEventRainIn       = "EventRainIn"
 | 
				
			||||||
	FieldDailyRainIn     = "DailyRainIn"
 | 
						FieldDailyRainIn       = "DailyRainIn"
 | 
				
			||||||
	FieldWeeklyRainIn    = "WeeklyRainIn"
 | 
						FieldWeeklyRainIn      = "WeeklyRainIn"
 | 
				
			||||||
	FieldMonthlyRainIn   = "MonthlyRainIn"
 | 
						FieldMonthlyRainIn     = "MonthlyRainIn"
 | 
				
			||||||
	FieldYearlyRainIn    = "YearlyRainIn"
 | 
						FieldYearlyRainIn      = "YearlyRainIn"
 | 
				
			||||||
	FieldTotalRainIn     = "TotalRainIn"
 | 
						FieldTotalRainIn       = "TotalRainIn"
 | 
				
			||||||
	FieldBatteries       = "Batteries"
 | 
						FieldBatteries         = "Batteries"
 | 
				
			||||||
	FieldBaromRelativeIn = "BaromRelativeIn"
 | 
						FieldBaromRelativeIn   = "BaromRelativeIn"
 | 
				
			||||||
	FieldBaromAbsoluteIn = "BaromAbsoluteIn"
 | 
						FieldBaromAbsoluteIn   = "BaromAbsoluteIn"
 | 
				
			||||||
	FieldDewPointF       = "DewPointF"
 | 
						FieldDewPointF         = "DewPointF"
 | 
				
			||||||
	FieldWindChillF      = "WindChillF"
 | 
						FieldWindChillF        = "WindChillF"
 | 
				
			||||||
	FieldSensorTempF     = "SensorTempF"
 | 
						FieldSensorTempF       = "SensorTempF"
 | 
				
			||||||
	FieldSensorHumidity  = "SensorHumidity"
 | 
						FieldSensorHumidity    = "SensorHumidity"
 | 
				
			||||||
 | 
						FieldLightningDay      = "LightningDay"
 | 
				
			||||||
 | 
						FieldLightningDistance = "LightningDistance"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (u *WeatherUpdate) GetStationName() string {
 | 
					func (u *WeatherUpdate) GetStationName() string {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,68 +6,70 @@ import "google/protobuf/timestamp.proto";
 | 
				
			|||||||
option go_package = "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather";
 | 
					option go_package = "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
message CountWeatherUpdatesRequest {
 | 
					message CountWeatherUpdatesRequest {
 | 
				
			||||||
	GetWeatherOpts opts = 1;
 | 
					  GetWeatherOpts opts = 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
message CountWeatherUpdatesResponse {
 | 
					message CountWeatherUpdatesResponse {
 | 
				
			||||||
	int32 count = 1;
 | 
					  int32 count = 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
message GetWeatherRequest {
 | 
					message GetWeatherRequest {
 | 
				
			||||||
	GetWeatherOpts opts = 1;
 | 
					  GetWeatherOpts opts = 1;
 | 
				
			||||||
	optional int32 limit = 2;
 | 
					  optional int32 limit = 2;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
message GetWeatherResponse{
 | 
					message GetWeatherResponse {
 | 
				
			||||||
	google.protobuf.Timestamp last_updated = 1;
 | 
					  google.protobuf.Timestamp last_updated = 1;
 | 
				
			||||||
	repeated WeatherUpdate weather_updates = 2;
 | 
					  repeated WeatherUpdate weather_updates = 2;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
message GetWeatherOpts {
 | 
					message GetWeatherOpts {
 | 
				
			||||||
	optional string station_name = 1;
 | 
					  optional string station_name = 1;
 | 
				
			||||||
	optional string station_type = 2;
 | 
					  optional string station_type = 2;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
message WeatherUpdate {
 | 
					message WeatherUpdate {
 | 
				
			||||||
	string station_name = 1;
 | 
					  string station_name = 1;
 | 
				
			||||||
	string station_type = 2;
 | 
					  string station_type = 2;
 | 
				
			||||||
	string station_id = 3;
 | 
					  string station_id = 3;
 | 
				
			||||||
	optional double temp_outdoor_f = 4;
 | 
					  optional double temp_outdoor_f = 4;
 | 
				
			||||||
	optional double temp_indoor_f = 5;
 | 
					  optional double temp_indoor_f = 5;
 | 
				
			||||||
	optional int32 humidity_outdoor = 6;
 | 
					  optional int32 humidity_outdoor = 6;
 | 
				
			||||||
	optional int32 humidity_indoor = 7;
 | 
					  optional int32 humidity_indoor = 7;
 | 
				
			||||||
	optional double wind_speed_mph = 8;
 | 
					  optional double wind_speed_mph = 8;
 | 
				
			||||||
	optional double wind_gust_mph = 9;
 | 
					  optional double wind_gust_mph = 9;
 | 
				
			||||||
	optional double max_daily_gust = 10;
 | 
					  optional double max_daily_gust = 10;
 | 
				
			||||||
	optional int32 wind_dir = 11;
 | 
					  optional int32 wind_dir = 11;
 | 
				
			||||||
	optional int32 wind_dir_avg_10m = 12;
 | 
					  optional int32 wind_dir_avg_10m = 12;
 | 
				
			||||||
	optional int32 uv = 13;
 | 
					  optional int32 uv = 13;
 | 
				
			||||||
	optional double solar_radiation = 14;
 | 
					  optional double solar_radiation = 14;
 | 
				
			||||||
	optional double hourly_rain_in = 15;
 | 
					  optional double hourly_rain_in = 15;
 | 
				
			||||||
	optional double event_rain_in = 16;
 | 
					  optional double event_rain_in = 16;
 | 
				
			||||||
	optional double daily_rain_in = 17;
 | 
					  optional double daily_rain_in = 17;
 | 
				
			||||||
	optional double weekly_rain_in = 18;
 | 
					  optional double weekly_rain_in = 18;
 | 
				
			||||||
	optional double monthly_rain_in = 19;
 | 
					  optional double monthly_rain_in = 19;
 | 
				
			||||||
	optional double yearly_rain_in = 20;
 | 
					  optional double yearly_rain_in = 20;
 | 
				
			||||||
	optional double total_rain_in = 21;
 | 
					  optional double total_rain_in = 21;
 | 
				
			||||||
	repeated BatteryStatus batteries = 22;
 | 
					  repeated BatteryStatus batteries = 22;
 | 
				
			||||||
	optional double barom_relative_in = 23;
 | 
					  optional double barom_relative_in = 23;
 | 
				
			||||||
	optional double barom_absolute_in = 24;
 | 
					  optional double barom_absolute_in = 24;
 | 
				
			||||||
	optional double dew_point_f = 25;
 | 
					  optional double dew_point_f = 25;
 | 
				
			||||||
	optional double wind_chill_f = 26;
 | 
					  optional double wind_chill_f = 26;
 | 
				
			||||||
	repeated TempHumiditySensor temp_humidity_sensors = 27;
 | 
					  repeated TempHumiditySensor temp_humidity_sensors = 27;
 | 
				
			||||||
	google.protobuf.Timestamp update_timestamp = 28;
 | 
					  google.protobuf.Timestamp update_timestamp = 28;
 | 
				
			||||||
 | 
					  optional int32 lightning_day = 29;
 | 
				
			||||||
 | 
					  optional int32 lightning_distance = 30;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Represents a temperature and humidity sensor
 | 
					// Represents a temperature and humidity sensor
 | 
				
			||||||
message TempHumiditySensor {
 | 
					message TempHumiditySensor {
 | 
				
			||||||
	string name = 1;
 | 
					  string name = 1;
 | 
				
			||||||
	optional double temp_f = 2;
 | 
					  optional double temp_f = 2;
 | 
				
			||||||
	optional int32 humidity = 3;
 | 
					  optional int32 humidity = 3;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Represents battery status for different components
 | 
					// Represents battery status for different components
 | 
				
			||||||
message BatteryStatus {
 | 
					message BatteryStatus {
 | 
				
			||||||
	string component = 1;
 | 
					  string component = 1;
 | 
				
			||||||
	optional int32 status = 2;
 | 
					  optional int32 status = 2;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user