Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
35374ab6e0 | |||
dcb60e6898 | |||
e2c464b34e | |||
8a4f360a45 |
@ -24,6 +24,7 @@ const (
|
||||
BattIndoorSensor = "IndoorSensor"
|
||||
BattRainSensor = "RainSensor"
|
||||
BattCO2Sensor = "CO2Sensor"
|
||||
BattLightningSensor = "LightningSensor"
|
||||
THSensor = "TempHumiditySensor"
|
||||
)
|
||||
|
||||
@ -74,6 +75,10 @@ func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
|
||||
YearlyRainIn: awnUpdate.YearlyRainIn,
|
||||
TotalRainIn: awnUpdate.TotalRainIn,
|
||||
Batteries: []weather.BatteryStatus{
|
||||
{
|
||||
Component: BattLightningSensor,
|
||||
Status: awnUpdate.BattLightning,
|
||||
},
|
||||
{
|
||||
Component: BattOutdoorSensor,
|
||||
Status: awnUpdate.BattOut,
|
||||
@ -138,6 +143,11 @@ func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
|
||||
{Name: THSensor + "7", TempF: awnUpdate.Temp7F, Humidity: awnUpdate.Humidity7},
|
||||
{Name: THSensor + "8", TempF: awnUpdate.Temp8F, Humidity: awnUpdate.Humidity8},
|
||||
},
|
||||
LightningData: &weather.LightningData{
|
||||
LightningDay: awnUpdate.LightningDay,
|
||||
LightningDistance: awnUpdate.LightningDistance,
|
||||
LightningTime: awnUpdate.LightningTime,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,6 +155,8 @@ func UnmarshalQueryParams(query url.Values) (*AmbientWeatherUpdate, error) {
|
||||
update := new(AmbientWeatherUpdate)
|
||||
|
||||
decoder := schema.NewDecoder()
|
||||
decoder.IgnoreUnknownKeys(true)
|
||||
|
||||
if err := decoder.Decode(update, query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -29,6 +29,14 @@ type AmbientWeatherUpdate struct {
|
||||
BattIn *int `json:"battin,omitempty" schema:"battin"`
|
||||
BattCO2 *int `json:"batt_co2,omitempty" schema:"batt_co2"`
|
||||
*AmbientTempHumiditySensors
|
||||
*AmbientLightningData
|
||||
}
|
||||
|
||||
type AmbientLightningData struct {
|
||||
BattLightning *int `json:"batt_lightning,omitempty" schema:"batt_lightning"`
|
||||
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 {
|
||||
|
@ -37,6 +37,10 @@ type WeatherMetrics struct {
|
||||
DewPointF metric.Float64Gauge
|
||||
WindChillF metric.Float64Gauge
|
||||
|
||||
// Lightning Sensor
|
||||
LightningCountDay metric.Int64Gauge
|
||||
LightningLastDistance metric.Int64Gauge
|
||||
|
||||
// Temp and Humidity Sensors
|
||||
SensorTempF metric.Float64Gauge
|
||||
SensorHumidity metric.Int64Gauge
|
||||
@ -74,6 +78,8 @@ func (wm *WeatherMetrics) Update(u *WeatherUpdate) {
|
||||
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.recorder.Record(&RecordOpts{Int64Gauge: wm.LightningCountDay, IntVal: u.LightningDay, Field: FieldLightningDay, Attributes: attributes, Station: u.StationConfig})
|
||||
wm.recorder.Record(&RecordOpts{Int64Gauge: wm.LightningLastDistance, IntVal: u.LightningDistance, Field: FieldLightningDistance, Attributes: attributes, Station: u.StationConfig})
|
||||
|
||||
wm.RecordBatteries(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",
|
||||
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
|
||||
wm.SensorTempF, _ = wm.meter.Float64Gauge(MetricPrefix+"_sensor_temp_f",
|
||||
metric.WithDescription("Temperature Sensor in Faherenheit"))
|
||||
|
@ -40,6 +40,14 @@ type WeatherUpdate struct {
|
||||
WindChillF *float64
|
||||
// Extra Temp+Humidity Sensors
|
||||
TempHumiditySensors []*TempHumiditySensor
|
||||
// Lightning Data
|
||||
*LightningData
|
||||
}
|
||||
|
||||
type LightningData struct {
|
||||
LightningDay *int // Count of detections
|
||||
LightningDistance *int // Last detection distance [kilometers]
|
||||
LightningTime *int // Last detection time
|
||||
}
|
||||
|
||||
type TempHumiditySensor struct {
|
||||
@ -84,6 +92,8 @@ const (
|
||||
FieldWindChillF = "WindChillF"
|
||||
FieldSensorTempF = "SensorTempF"
|
||||
FieldSensorHumidity = "SensorHumidity"
|
||||
FieldLightningDay = "LightningDay"
|
||||
FieldLightningDistance = "LightningDistance"
|
||||
)
|
||||
|
||||
func (u *WeatherUpdate) GetStationName() string {
|
||||
|
Reference in New Issue
Block a user