Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
f079d106a1 | |||
fc2d05e957 | |||
59f5bfbba1 | |||
0adab13221 | |||
3b0748da25 | |||
2d683e61b0 | |||
82bc3acfc3 |
9
TODO.md
9
TODO.md
@ -1,10 +1,15 @@
|
||||
# Issues
|
||||
- [x] Redis recorder panic
|
||||
|
||||
# TODO
|
||||
- [ ] Add json schema for config
|
||||
- [ ] Finish implementing weather GRPC
|
||||
- [ ] Add json schema to CI and README
|
||||
- [ ] Update README
|
||||
- [ ] Add Grafana dashboard
|
||||
|
||||
## Done
|
||||
- [x] Stop Marshaling sensors / batteries with no data
|
||||
- [x] Finish implementing weather GRPC
|
||||
- [x] Add json schema for config
|
||||
- [x] Add new spans
|
||||
- [x] Helm Chart
|
||||
- [x] Add proxy to upstream support
|
||||
|
@ -207,6 +207,7 @@ type WeatherUpdate struct {
|
||||
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"`
|
||||
UpdateTimestamp *timestamppb.Timestamp `protobuf:"bytes,28,opt,name=update_timestamp,json=updateTimestamp,proto3" json:"update_timestamp,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@ -430,6 +431,13 @@ func (x *WeatherUpdate) GetTempHumiditySensors() []*TempHumiditySensor {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *WeatherUpdate) GetUpdateTimestamp() *timestamppb.Timestamp {
|
||||
if x != nil {
|
||||
return x.UpdateTimestamp
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Represents a temperature and humidity sensor
|
||||
type TempHumiditySensor struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
@ -576,7 +584,7 @@ var file_weather_weather_proto_rawDesc = string([]byte{
|
||||
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,
|
||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x22, 0xfe, 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,
|
||||
@ -651,51 +659,56 @@ var file_weather_weather_proto_rawDesc = string([]byte{
|
||||
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,
|
||||
0x6f, 0x72, 0x73, 0x12, 0x45, 0x0a, 0x10, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x1c, 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, 0x0f, 0x75, 0x70, 0x64, 0x61, 0x74,
|
||||
0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 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 (
|
||||
@ -726,11 +739,12 @@ var file_weather_weather_proto_depIdxs = []int32{
|
||||
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
|
||||
6, // 5: ambient.weather.WeatherUpdate.update_timestamp:type_name -> google.protobuf.Timestamp
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_weather_weather_proto_init() }
|
||||
|
89
contrib/wu_sample.json
Normal file
89
contrib/wu_sample.json
Normal file
@ -0,0 +1,89 @@
|
||||
{
|
||||
"PASSKEY": [
|
||||
"DE:AD:BE:EF:BE:EF"
|
||||
],
|
||||
"baromabsin": [
|
||||
"29.025"
|
||||
],
|
||||
"baromrelin": [
|
||||
"30.005"
|
||||
],
|
||||
"batt1": [
|
||||
"1"
|
||||
],
|
||||
"battin": [
|
||||
"1"
|
||||
],
|
||||
"battout": [
|
||||
"1"
|
||||
],
|
||||
"battrain": [
|
||||
"1"
|
||||
],
|
||||
"dailyrainin": [
|
||||
"0.000"
|
||||
],
|
||||
"dateutc": [
|
||||
"2025-03-23 14:07:59"
|
||||
],
|
||||
"eventrainin": [
|
||||
"0.000"
|
||||
],
|
||||
"hourlyrainin": [
|
||||
"0.000"
|
||||
],
|
||||
"humidity": [
|
||||
"55"
|
||||
],
|
||||
"humidity1": [
|
||||
"53"
|
||||
],
|
||||
"humidityin": [
|
||||
"36"
|
||||
],
|
||||
"maxdailygust": [
|
||||
"20.36"
|
||||
],
|
||||
"monthlyrainin": [
|
||||
"1.969"
|
||||
],
|
||||
"solarradiation": [
|
||||
"142.15"
|
||||
],
|
||||
"stationtype": [
|
||||
"WeatherHub_V1.0.2"
|
||||
],
|
||||
"temp1f": [
|
||||
"-2.74"
|
||||
],
|
||||
"tempf": [
|
||||
"33.98"
|
||||
],
|
||||
"tempinf": [
|
||||
"70.52"
|
||||
],
|
||||
"totalrainin": [
|
||||
"2.421"
|
||||
],
|
||||
"uv": [
|
||||
"1"
|
||||
],
|
||||
"weeklyrainin": [
|
||||
"0.000"
|
||||
],
|
||||
"winddir": [
|
||||
"117"
|
||||
],
|
||||
"winddir_avg10m": [
|
||||
"127"
|
||||
],
|
||||
"windgustmph": [
|
||||
"17.22"
|
||||
],
|
||||
"windspeedmph": [
|
||||
"10.29"
|
||||
],
|
||||
"yearlyrainin": [
|
||||
"2.421"
|
||||
]
|
||||
}
|
9
contrib/wu_test_sample.sh
Executable file
9
contrib/wu_test_sample.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!env sh
|
||||
SCRIPT_DIR=$( dirname $0 )
|
||||
JSON_FILE="${SCRIPT_DIR}/wu_sample.json"
|
||||
BASE_URL="http://127.0.0.1:8080/data/report"
|
||||
|
||||
# Convert JSON to query parameters
|
||||
QUERY_STRING=$(jq -r 'to_entries | map("\(.key)=\(.value[0] | @uri)") | join("&")' "$JSON_FILE")
|
||||
|
||||
curl -G --data "$QUERY_STRING" "$BASE_URL"
|
@ -15,13 +15,13 @@ type: application
|
||||
# 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.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 0.1.2
|
||||
version: 0.1.4
|
||||
|
||||
# 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
|
||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||
# It is recommended to use it with quotes.
|
||||
appVersion: "v0.10.2"
|
||||
appVersion: "v0.11.2"
|
||||
|
||||
dependencies:
|
||||
- name: hull
|
||||
|
@ -1,11 +1,17 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/util"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||
)
|
||||
|
||||
// Converts a slice of weather.WeatherUpdate to proto structs
|
||||
func UpdatesToPbUpdates(u []*weather.WeatherUpdate) []*pb.WeatherUpdate {
|
||||
updates := make([]*pb.WeatherUpdate, len(u))
|
||||
for i, update := range u {
|
||||
@ -14,7 +20,16 @@ func UpdatesToPbUpdates(u []*weather.WeatherUpdate) []*pb.WeatherUpdate {
|
||||
return updates
|
||||
}
|
||||
|
||||
// Maps a weather.WeatherUpdate to the proto version.
|
||||
//
|
||||
// This should be auto-generated code, but as the proto should be
|
||||
// stable, it is probably not worth the effort.
|
||||
func UpdateToPbUpdate(u *weather.WeatherUpdate) *pb.WeatherUpdate {
|
||||
if u.DateUTC == nil {
|
||||
now := time.Now()
|
||||
u.DateUTC = &now
|
||||
}
|
||||
|
||||
return &pb.WeatherUpdate{
|
||||
StationName: u.StationConfig.Name,
|
||||
StationType: util.DerefStr(u.StationType),
|
||||
@ -43,28 +58,33 @@ func UpdateToPbUpdate(u *weather.WeatherUpdate) *pb.WeatherUpdate {
|
||||
DewPointF: u.DewPointF,
|
||||
WindChillF: u.WindChillF,
|
||||
TempHumiditySensors: thSensorsToPbSensors(u.TempHumiditySensors),
|
||||
UpdateTimestamp: timestamppb.New(*u.DateUTC),
|
||||
}
|
||||
}
|
||||
|
||||
func batteriesToPbBatteries(batteries []weather.BatteryStatus) []*pb.BatteryStatus {
|
||||
pbBatteries := make([]*pb.BatteryStatus, len(batteries))
|
||||
for i, b := range batteries {
|
||||
pbBatteries[i] = &pb.BatteryStatus{
|
||||
pbBatteries := make([]*pb.BatteryStatus, 0, len(batteries))
|
||||
for _, b := range batteries {
|
||||
if b.Status != nil {
|
||||
pbBatteries = append(pbBatteries, &pb.BatteryStatus{
|
||||
Component: b.Component,
|
||||
Status: util.Int32ptr(b.Status),
|
||||
})
|
||||
}
|
||||
}
|
||||
return pbBatteries
|
||||
return slices.Clip(pbBatteries)
|
||||
}
|
||||
|
||||
func thSensorsToPbSensors(sensors []*weather.TempHumiditySensor) []*pb.TempHumiditySensor {
|
||||
pbSensors := make([]*pb.TempHumiditySensor, len(sensors))
|
||||
for i, s := range sensors {
|
||||
pbSensors[i] = &pb.TempHumiditySensor{
|
||||
pbSensors := make([]*pb.TempHumiditySensor, 0, len(sensors))
|
||||
for _, s := range sensors {
|
||||
if s.TempF != nil || s.Humidity != nil {
|
||||
pbSensors = append(pbSensors, &pb.TempHumiditySensor{
|
||||
Name: s.Name,
|
||||
TempF: s.TempF,
|
||||
Humidity: util.Int32ptr(s.Humidity),
|
||||
})
|
||||
}
|
||||
}
|
||||
return pbSensors
|
||||
return slices.Clip(pbSensors)
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
||||
@ -12,8 +13,10 @@ import (
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||
)
|
||||
|
||||
var now = time.Now()
|
||||
|
||||
var mockUpdate = &weather.WeatherUpdate{
|
||||
DateUTC: &time.Time{},
|
||||
DateUTC: &now,
|
||||
StationConfig: &config.WeatherStation{
|
||||
Name: "50W",
|
||||
Equipment: "WS-5000",
|
||||
@ -100,6 +103,7 @@ func TestUpdateToPbUpdate(t *testing.T) {
|
||||
Humidity: nil,
|
||||
},
|
||||
},
|
||||
UpdateTimestamp: timestamppb.New(now),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -6,16 +6,28 @@ import (
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/ambient/config"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/util"
|
||||
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
||||
)
|
||||
|
||||
func (w *WeatherRecorder) Set(ctx context.Context, u *weather.WeatherUpdate) error {
|
||||
if u.StationConfig == nil {
|
||||
u.StationConfig = &config.WeatherStation{
|
||||
Name: "unregistered",
|
||||
Equipment: "unknown",
|
||||
ProxyToAWN: false,
|
||||
ProxyToWunderground: false,
|
||||
KeepMetrics: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
ctx, span := w.tracer.Start(ctx, "setRecorderUpdate", trace.WithAttributes(
|
||||
attribute.String("stationName", u.StationConfig.Name),
|
||||
attribute.String("stationType", util.DerefStr(u.StationType)),
|
||||
attribute.String("stationEquipment", u.StationConfig.Equipment),
|
||||
))
|
||||
defer span.End()
|
||||
|
||||
return w.recorder.Set(ctx, u)
|
||||
}
|
||||
|
@ -38,8 +38,9 @@ func (r *RedisRecorder) get(ctx context.Context, req *pb.GetWeatherRequest) (
|
||||
}
|
||||
|
||||
span.SetAttributes(attribute.Int("limit", limit))
|
||||
r.log.Debug().Int("limit", limit).Msg("getting updates from redis")
|
||||
|
||||
datas, err := r.redis.LRange(ctx, r.Key(), 0, int64(limit)).Result()
|
||||
datas, err := r.redis.LRange(ctx, r.Key(), 0, int64(limit)-1).Result()
|
||||
if err != nil {
|
||||
span.RecordError(err)
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
@ -48,6 +49,7 @@ func (r *RedisRecorder) get(ctx context.Context, req *pb.GetWeatherRequest) (
|
||||
}
|
||||
|
||||
span.AddEvent("redis queried")
|
||||
r.log.Debug().Int("results", len(datas)).Msg("redis queried")
|
||||
|
||||
updates, err := jsonDatasToUpdates(datas)
|
||||
if err != nil {
|
||||
@ -75,7 +77,7 @@ func (r *RedisRecorder) get(ctx context.Context, req *pb.GetWeatherRequest) (
|
||||
Int("updatesFiltered", len(updates)-len(filtered)).
|
||||
Msg("updates retrieved from redis")
|
||||
|
||||
return updates, err
|
||||
return filtered, err
|
||||
}
|
||||
|
||||
func jsonDatasToUpdates(datas []string) ([]*weather.WeatherUpdate, error) {
|
||||
@ -87,7 +89,7 @@ func jsonDatasToUpdates(datas []string) ([]*weather.WeatherUpdate, error) {
|
||||
err := json.Unmarshal([]byte(data), update)
|
||||
errs = errors.Join(errs, err)
|
||||
|
||||
if err != nil {
|
||||
if err == nil {
|
||||
updates = append(updates, update)
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
@ -20,7 +21,7 @@ func (r *RedisRecorder) Set(ctx context.Context, u *weather.WeatherUpdate) error
|
||||
defer span.End()
|
||||
|
||||
r.Lock()
|
||||
defer r.RUnlock()
|
||||
defer r.Unlock()
|
||||
|
||||
// First ensure we can prepare our payload
|
||||
data, err := json.Marshal(u)
|
||||
@ -42,11 +43,14 @@ func (r *RedisRecorder) set(ctx context.Context, data []byte) error {
|
||||
defer span.End()
|
||||
|
||||
// Atomic, push and trim
|
||||
tx := r.redis.TxPipeline()
|
||||
tx.LPush(ctx, r.Key(), data)
|
||||
tx.LTrim(ctx, r.Key(), 0, int64(r.keep)-1)
|
||||
|
||||
if rErr, err := tx.Exec(ctx); err != nil {
|
||||
var count *redis.IntCmd
|
||||
rErr, err := r.redis.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
|
||||
pipe.LPush(ctx, r.Key(), data)
|
||||
pipe.LTrim(ctx, r.Key(), 0, int64(r.keep)-1)
|
||||
count = pipe.LLen(ctx, r.Key())
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
for _, cmd := range rErr {
|
||||
span.RecordError(cmd.Err())
|
||||
}
|
||||
@ -55,7 +59,16 @@ func (r *RedisRecorder) set(ctx context.Context, data []byte) error {
|
||||
return err
|
||||
}
|
||||
|
||||
span.SetAttributes(attribute.Int("updateCount", r.count(ctx)))
|
||||
// Get new update count
|
||||
|
||||
r.log.Debug().
|
||||
Int("updateBytes", len(data)).
|
||||
Int64("updateCount", count.Val()).
|
||||
Str("redis", r.redis.String()).
|
||||
Str("key", r.Key()).
|
||||
Msg("pushed update to redis")
|
||||
|
||||
span.SetAttributes(attribute.Int64("updateCount", count.Val()))
|
||||
span.SetStatus(codes.Ok, "")
|
||||
return nil
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ message WeatherUpdate {
|
||||
optional double dew_point_f = 25;
|
||||
optional double wind_chill_f = 26;
|
||||
repeated TempHumiditySensor temp_humidity_sensors = 27;
|
||||
google.protobuf.Timestamp update_timestamp = 28;
|
||||
}
|
||||
|
||||
// Represents a temperature and humidity sensor
|
||||
|
Reference in New Issue
Block a user