Compare commits

...

20 Commits

Author SHA1 Message Date
e1ff48a262 bump chart
All checks were successful
Build and Publish / check-chart (push) Successful in 14s
Build and Publish / helm-release (push) Successful in 33s
Build and Publish / release (push) Successful in 5m10s
2025-04-19 12:29:46 -04:00
be629e3d00 correct lightning distance unit
All checks were successful
Build and Publish / release (push) Has been skipped
Build and Publish / check-chart (push) Successful in 10s
Build and Publish / helm-release (push) Has been skipped
2025-04-19 12:29:14 -04:00
f2fd297218 bump helm chart
All checks were successful
Build and Publish / release (push) Has been skipped
Build and Publish / check-chart (push) Successful in 10s
Build and Publish / helm-release (push) Successful in 24s
2025-04-03 16:17:04 -04:00
ac000112c3 implement redis key ttl
All checks were successful
Build and Publish / check-chart (push) Successful in 12s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Successful in 3m33s
2025-04-03 16:00:57 -04:00
21a4165489 implement redis key ttl
All checks were successful
Build and Publish / check-chart (push) Successful in 12s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Successful in 3m52s
2025-04-03 15:51:52 -04:00
15dd74d6ab implement lightning_time in grpc
All checks were successful
Build and Publish / check-chart (push) Successful in 12s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Successful in 4m6s
2025-04-03 15:31:43 -04:00
82ae3e4ba4 add counter support, add lightning time
All checks were successful
Build and Publish / check-chart (push) Successful in 11s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Successful in 3m49s
2025-04-03 15:16:42 -04:00
f0bda0a3bd bump helm chart
All checks were successful
Build and Publish / check-chart (push) Successful in 14s
Build and Publish / helm-release (push) Successful in 34s
Build and Publish / release (push) Successful in 3m48s
2025-04-03 13:49:11 -04:00
1ee231fe30 Fix embedded lightning data
All checks were successful
Build and Publish / release (push) Has been skipped
Build and Publish / check-chart (push) Successful in 10s
Build and Publish / helm-release (push) Has been skipped
2025-04-03 13:48:41 -04:00
3279c6fd38 add json tags
All checks were successful
Build and Publish / check-chart (push) Successful in 14s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Successful in 3m55s
2025-04-03 13:35:32 -04:00
268bc7d8a2 code tweaks
All checks were successful
Build and Publish / release (push) Has been skipped
Build and Publish / check-chart (push) Successful in 10s
Build and Publish / helm-release (push) Has been skipped
2025-04-03 10:44:43 -04:00
2f83edc426 bump chart
Some checks are pending
Build and Publish / release (push) Waiting to run
Build and Publish / check-chart (push) Successful in 15s
Build and Publish / helm-release (push) Successful in 47s
2025-04-02 20:45:36 -04:00
80f9c00615 add lightning sensor
All checks were successful
Build and Publish / check-chart (push) Successful in 17s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Successful in 7m58s
2025-04-02 20:44:58 -04:00
53c22ab8c7 add lightning sensor
Some checks failed
Build and Publish / check-chart (push) Successful in 15s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Failing after 1m14s
2025-04-02 20:09:44 -04:00
35374ab6e0 add lightning sensor
All checks were successful
Build and Publish / check-chart (push) Successful in 12s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Successful in 4m16s
2025-04-02 20:01:21 -04:00
dcb60e6898 add lightning sensor
All checks were successful
Build and Publish / release (push) Has been skipped
Build and Publish / check-chart (push) Successful in 10s
Build and Publish / helm-release (push) Has been skipped
2025-04-02 19:49:32 -04:00
e2c464b34e permit unknown keys
All checks were successful
Build and Publish / check-chart (push) Successful in 17s
Build and Publish / helm-release (push) Has been skipped
Build and Publish / release (push) Successful in 5m2s
2025-04-02 19:30:32 -04:00
8a4f360a45 add lightning sensor
Some checks failed
Build and Publish / release (push) Successful in 6m13s
Build and Publish / check-chart (push) Failing after 12m32s
Build and Publish / helm-release (push) Has been cancelled
2025-04-02 19:28:05 -04:00
7a6ad00f7f bump helm chart
All checks were successful
Build and Publish / check-chart (push) Successful in 13s
Build and Publish / helm-release (push) Successful in 43s
Build and Publish / release (push) Successful in 3m48s
2025-03-27 15:36:23 -04:00
d847c36715 implement count rpc
All checks were successful
Build and Publish / release (push) Has been skipped
Build and Publish / check-chart (push) Successful in 11s
Build and Publish / helm-release (push) Has been skipped
2025-03-27 15:32:10 -04:00
23 changed files with 616 additions and 178 deletions

View File

@ -2,6 +2,7 @@
- [x] Redis recorder panic
# TODO
- [ ] Make lightning distance unit configurable (kph|mph)
- [ ] Set TTL on redis key
- [ ] Add json schema to CI and README
- [ ] Update README

View File

@ -22,6 +22,94 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type CountWeatherUpdatesRequest 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 *CountWeatherUpdatesRequest) Reset() {
*x = CountWeatherUpdatesRequest{}
mi := &file_weather_weather_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CountWeatherUpdatesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CountWeatherUpdatesRequest) ProtoMessage() {}
func (x *CountWeatherUpdatesRequest) 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 CountWeatherUpdatesRequest.ProtoReflect.Descriptor instead.
func (*CountWeatherUpdatesRequest) Descriptor() ([]byte, []int) {
return file_weather_weather_proto_rawDescGZIP(), []int{0}
}
func (x *CountWeatherUpdatesRequest) GetOpts() *GetWeatherOpts {
if x != nil {
return x.Opts
}
return nil
}
type CountWeatherUpdatesResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Count int32 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *CountWeatherUpdatesResponse) Reset() {
*x = CountWeatherUpdatesResponse{}
mi := &file_weather_weather_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *CountWeatherUpdatesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CountWeatherUpdatesResponse) ProtoMessage() {}
func (x *CountWeatherUpdatesResponse) 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 CountWeatherUpdatesResponse.ProtoReflect.Descriptor instead.
func (*CountWeatherUpdatesResponse) Descriptor() ([]byte, []int) {
return file_weather_weather_proto_rawDescGZIP(), []int{1}
}
func (x *CountWeatherUpdatesResponse) GetCount() int32 {
if x != nil {
return x.Count
}
return 0
}
type GetWeatherRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Opts *GetWeatherOpts `protobuf:"bytes,1,opt,name=opts,proto3" json:"opts,omitempty"`
@ -32,7 +120,7 @@ type GetWeatherRequest struct {
func (x *GetWeatherRequest) Reset() {
*x = GetWeatherRequest{}
mi := &file_weather_weather_proto_msgTypes[0]
mi := &file_weather_weather_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -44,7 +132,7 @@ func (x *GetWeatherRequest) String() string {
func (*GetWeatherRequest) ProtoMessage() {}
func (x *GetWeatherRequest) ProtoReflect() protoreflect.Message {
mi := &file_weather_weather_proto_msgTypes[0]
mi := &file_weather_weather_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -57,7 +145,7 @@ func (x *GetWeatherRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetWeatherRequest.ProtoReflect.Descriptor instead.
func (*GetWeatherRequest) Descriptor() ([]byte, []int) {
return file_weather_weather_proto_rawDescGZIP(), []int{0}
return file_weather_weather_proto_rawDescGZIP(), []int{2}
}
func (x *GetWeatherRequest) GetOpts() *GetWeatherOpts {
@ -84,7 +172,7 @@ type GetWeatherResponse struct {
func (x *GetWeatherResponse) Reset() {
*x = GetWeatherResponse{}
mi := &file_weather_weather_proto_msgTypes[1]
mi := &file_weather_weather_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -96,7 +184,7 @@ func (x *GetWeatherResponse) String() string {
func (*GetWeatherResponse) ProtoMessage() {}
func (x *GetWeatherResponse) ProtoReflect() protoreflect.Message {
mi := &file_weather_weather_proto_msgTypes[1]
mi := &file_weather_weather_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -109,7 +197,7 @@ func (x *GetWeatherResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetWeatherResponse.ProtoReflect.Descriptor instead.
func (*GetWeatherResponse) Descriptor() ([]byte, []int) {
return file_weather_weather_proto_rawDescGZIP(), []int{1}
return file_weather_weather_proto_rawDescGZIP(), []int{3}
}
func (x *GetWeatherResponse) GetLastUpdated() *timestamppb.Timestamp {
@ -136,7 +224,7 @@ type GetWeatherOpts struct {
func (x *GetWeatherOpts) Reset() {
*x = GetWeatherOpts{}
mi := &file_weather_weather_proto_msgTypes[2]
mi := &file_weather_weather_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -148,7 +236,7 @@ func (x *GetWeatherOpts) String() string {
func (*GetWeatherOpts) ProtoMessage() {}
func (x *GetWeatherOpts) ProtoReflect() protoreflect.Message {
mi := &file_weather_weather_proto_msgTypes[2]
mi := &file_weather_weather_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -161,7 +249,7 @@ func (x *GetWeatherOpts) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetWeatherOpts.ProtoReflect.Descriptor instead.
func (*GetWeatherOpts) Descriptor() ([]byte, []int) {
return file_weather_weather_proto_rawDescGZIP(), []int{2}
return file_weather_weather_proto_rawDescGZIP(), []int{4}
}
func (x *GetWeatherOpts) GetStationName() string {
@ -208,13 +296,16 @@ type WeatherUpdate struct {
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"`
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"`
LightningLastTime *timestamppb.Timestamp `protobuf:"bytes,31,opt,name=lightning_last_time,json=lightningLastTime,proto3,oneof" json:"lightning_last_time,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *WeatherUpdate) Reset() {
*x = WeatherUpdate{}
mi := &file_weather_weather_proto_msgTypes[3]
mi := &file_weather_weather_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -226,7 +317,7 @@ func (x *WeatherUpdate) String() string {
func (*WeatherUpdate) ProtoMessage() {}
func (x *WeatherUpdate) ProtoReflect() protoreflect.Message {
mi := &file_weather_weather_proto_msgTypes[3]
mi := &file_weather_weather_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -239,7 +330,7 @@ func (x *WeatherUpdate) ProtoReflect() protoreflect.Message {
// Deprecated: Use WeatherUpdate.ProtoReflect.Descriptor instead.
func (*WeatherUpdate) Descriptor() ([]byte, []int) {
return file_weather_weather_proto_rawDescGZIP(), []int{3}
return file_weather_weather_proto_rawDescGZIP(), []int{5}
}
func (x *WeatherUpdate) GetStationName() string {
@ -438,6 +529,27 @@ func (x *WeatherUpdate) GetUpdateTimestamp() *timestamppb.Timestamp {
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
}
func (x *WeatherUpdate) GetLightningLastTime() *timestamppb.Timestamp {
if x != nil {
return x.LightningLastTime
}
return nil
}
// Represents a temperature and humidity sensor
type TempHumiditySensor struct {
state protoimpl.MessageState `protogen:"open.v1"`
@ -450,7 +562,7 @@ type TempHumiditySensor struct {
func (x *TempHumiditySensor) Reset() {
*x = TempHumiditySensor{}
mi := &file_weather_weather_proto_msgTypes[4]
mi := &file_weather_weather_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -462,7 +574,7 @@ func (x *TempHumiditySensor) String() string {
func (*TempHumiditySensor) ProtoMessage() {}
func (x *TempHumiditySensor) ProtoReflect() protoreflect.Message {
mi := &file_weather_weather_proto_msgTypes[4]
mi := &file_weather_weather_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -475,7 +587,7 @@ func (x *TempHumiditySensor) ProtoReflect() protoreflect.Message {
// Deprecated: Use TempHumiditySensor.ProtoReflect.Descriptor instead.
func (*TempHumiditySensor) Descriptor() ([]byte, []int) {
return file_weather_weather_proto_rawDescGZIP(), []int{4}
return file_weather_weather_proto_rawDescGZIP(), []int{6}
}
func (x *TempHumiditySensor) GetName() string {
@ -510,7 +622,7 @@ type BatteryStatus struct {
func (x *BatteryStatus) Reset() {
*x = BatteryStatus{}
mi := &file_weather_weather_proto_msgTypes[5]
mi := &file_weather_weather_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -522,7 +634,7 @@ func (x *BatteryStatus) String() string {
func (*BatteryStatus) ProtoMessage() {}
func (x *BatteryStatus) ProtoReflect() protoreflect.Message {
mi := &file_weather_weather_proto_msgTypes[5]
mi := &file_weather_weather_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -535,7 +647,7 @@ func (x *BatteryStatus) ProtoReflect() protoreflect.Message {
// Deprecated: Use BatteryStatus.ProtoReflect.Descriptor instead.
func (*BatteryStatus) Descriptor() ([]byte, []int) {
return file_weather_weather_proto_rawDescGZIP(), []int{5}
return file_weather_weather_proto_rawDescGZIP(), []int{7}
}
func (x *BatteryStatus) GetComponent() string {
@ -556,7 +668,11 @@ var File_weather_weather_proto protoreflect.FileDescriptor
const file_weather_weather_proto_rawDesc = "" +
"\n" +
"\x15weather/weather.proto\x12\x0fambient.weather\x1a\x1fgoogle/protobuf/timestamp.proto\"m\n" +
"\x15weather/weather.proto\x12\x0fambient.weather\x1a\x1fgoogle/protobuf/timestamp.proto\"Q\n" +
"\x1aCountWeatherUpdatesRequest\x123\n" +
"\x04opts\x18\x01 \x01(\v2\x1f.ambient.weather.GetWeatherOptsR\x04opts\"3\n" +
"\x1bCountWeatherUpdatesResponse\x12\x14\n" +
"\x05count\x18\x01 \x01(\x05R\x05count\"m\n" +
"\x11GetWeatherRequest\x123\n" +
"\x04opts\x18\x01 \x01(\v2\x1f.ambient.weather.GetWeatherOptsR\x04opts\x12\x19\n" +
"\x05limit\x18\x02 \x01(\x05H\x00R\x05limit\x88\x01\x01B\b\n" +
@ -568,7 +684,7 @@ const file_weather_weather_proto_rawDesc = "" +
"\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" +
"\r_station_nameB\x0f\n" +
"\r_station_type\"\xfe\f\n" +
"\r_station_type\"\xee\x0e\n" +
"\rWeatherUpdate\x12!\n" +
"\fstation_name\x18\x01 \x01(\tR\vstationName\x12!\n" +
"\fstation_type\x18\x02 \x01(\tR\vstationType\x12\x1d\n" +
@ -601,7 +717,10 @@ const file_weather_weather_proto_rawDesc = "" +
"\fwind_chill_f\x18\x1a \x01(\x01H\x15R\n" +
"windChillF\x88\x01\x01\x12W\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\x01\x12O\n" +
"\x13lightning_last_time\x18\x1f \x01(\v2\x1a.google.protobuf.TimestampH\x18R\x11lightningLastTime\x88\x01\x01B\x11\n" +
"\x0f_temp_outdoor_fB\x10\n" +
"\x0e_temp_indoor_fB\x13\n" +
"\x11_humidity_outdoorB\x12\n" +
@ -623,7 +742,10 @@ const file_weather_weather_proto_rawDesc = "" +
"\x12_barom_relative_inB\x14\n" +
"\x12_barom_absolute_inB\x0e\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_distanceB\x16\n" +
"\x14_lightning_last_time\"}\n" +
"\x12TempHumiditySensor\x12\x12\n" +
"\x04name\x18\x01 \x01(\tR\x04name\x12\x1a\n" +
"\x06temp_f\x18\x02 \x01(\x01H\x00R\x05tempF\x88\x01\x01\x12\x1f\n" +
@ -647,28 +769,32 @@ func file_weather_weather_proto_rawDescGZIP() []byte {
return file_weather_weather_proto_rawDescData
}
var file_weather_weather_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_weather_weather_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
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
(*CountWeatherUpdatesRequest)(nil), // 0: ambient.weather.CountWeatherUpdatesRequest
(*CountWeatherUpdatesResponse)(nil), // 1: ambient.weather.CountWeatherUpdatesResponse
(*GetWeatherRequest)(nil), // 2: ambient.weather.GetWeatherRequest
(*GetWeatherResponse)(nil), // 3: ambient.weather.GetWeatherResponse
(*GetWeatherOpts)(nil), // 4: ambient.weather.GetWeatherOpts
(*WeatherUpdate)(nil), // 5: ambient.weather.WeatherUpdate
(*TempHumiditySensor)(nil), // 6: ambient.weather.TempHumiditySensor
(*BatteryStatus)(nil), // 7: ambient.weather.BatteryStatus
(*timestamppb.Timestamp)(nil), // 8: 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
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
4, // 0: ambient.weather.CountWeatherUpdatesRequest.opts:type_name -> ambient.weather.GetWeatherOpts
4, // 1: ambient.weather.GetWeatherRequest.opts:type_name -> ambient.weather.GetWeatherOpts
8, // 2: ambient.weather.GetWeatherResponse.last_updated:type_name -> google.protobuf.Timestamp
5, // 3: ambient.weather.GetWeatherResponse.weather_updates:type_name -> ambient.weather.WeatherUpdate
7, // 4: ambient.weather.WeatherUpdate.batteries:type_name -> ambient.weather.BatteryStatus
6, // 5: ambient.weather.WeatherUpdate.temp_humidity_sensors:type_name -> ambient.weather.TempHumiditySensor
8, // 6: ambient.weather.WeatherUpdate.update_timestamp:type_name -> google.protobuf.Timestamp
8, // 7: ambient.weather.WeatherUpdate.lightning_last_time:type_name -> google.protobuf.Timestamp
8, // [8:8] is the sub-list for method output_type
8, // [8:8] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
}
func init() { file_weather_weather_proto_init() }
@ -676,18 +802,18 @@ func file_weather_weather_proto_init() {
if File_weather_weather_proto != nil {
return
}
file_weather_weather_proto_msgTypes[0].OneofWrappers = []any{}
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{}
file_weather_weather_proto_msgTypes[6].OneofWrappers = []any{}
file_weather_weather_proto_msgTypes[7].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,
NumMessages: 8,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -25,20 +25,25 @@ var File_weather_weather_service_proto protoreflect.FileDescriptor
const file_weather_weather_service_proto_rawDesc = "" +
"\n" +
"\x1dweather/weather_service.proto\x12\x0fambient.weather\x1a\x1cgoogle/api/annotations.proto\x1a\x15weather/weather.proto2\x88\x01\n" +
"\x1dweather/weather_service.proto\x12\x0fambient.weather\x1a\x1cgoogle/api/annotations.proto\x1a\x15weather/weather.proto2\x8e\x02\n" +
"\x1aAmbientLocalWeatherService\x12j\n" +
"\n" +
"GetWeather\x12\".ambient.weather.GetWeatherRequest\x1a#.ambient.weather.GetWeatherResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/v1/weatherBTZRgitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weatherb\x06proto3"
"GetWeather\x12\".ambient.weather.GetWeatherRequest\x1a#.ambient.weather.GetWeatherResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/v1/weather\x12\x83\x01\n" +
"\x13CountWeatherUpdates\x12+.ambient.weather.CountWeatherUpdatesRequest\x1a,.ambient.weather.CountWeatherUpdatesResponse\"\x11\x82\xd3\xe4\x93\x02\v\x12\t/v1/countBTZRgitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weatherb\x06proto3"
var file_weather_weather_service_proto_goTypes = []any{
(*GetWeatherRequest)(nil), // 0: ambient.weather.GetWeatherRequest
(*GetWeatherResponse)(nil), // 1: ambient.weather.GetWeatherResponse
(*CountWeatherUpdatesRequest)(nil), // 1: ambient.weather.CountWeatherUpdatesRequest
(*GetWeatherResponse)(nil), // 2: ambient.weather.GetWeatherResponse
(*CountWeatherUpdatesResponse)(nil), // 3: ambient.weather.CountWeatherUpdatesResponse
}
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
1, // 1: ambient.weather.AmbientLocalWeatherService.CountWeatherUpdates:input_type -> ambient.weather.CountWeatherUpdatesRequest
2, // 2: ambient.weather.AmbientLocalWeatherService.GetWeather:output_type -> ambient.weather.GetWeatherResponse
3, // 3: ambient.weather.AmbientLocalWeatherService.CountWeatherUpdates:output_type -> ambient.weather.CountWeatherUpdatesResponse
2, // [2:4] is the sub-list for method output_type
0, // [0:2] 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

View File

@ -68,6 +68,39 @@ func local_request_AmbientLocalWeatherService_GetWeather_0(ctx context.Context,
return msg, metadata, err
}
var filter_AmbientLocalWeatherService_CountWeatherUpdates_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
func request_AmbientLocalWeatherService_CountWeatherUpdates_0(ctx context.Context, marshaler runtime.Marshaler, client AmbientLocalWeatherServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CountWeatherUpdatesRequest
metadata runtime.ServerMetadata
)
io.Copy(io.Discard, req.Body)
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AmbientLocalWeatherService_CountWeatherUpdates_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.CountWeatherUpdates(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_AmbientLocalWeatherService_CountWeatherUpdates_0(ctx context.Context, marshaler runtime.Marshaler, server AmbientLocalWeatherServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq CountWeatherUpdatesRequest
metadata runtime.ServerMetadata
)
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AmbientLocalWeatherService_CountWeatherUpdates_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.CountWeatherUpdates(ctx, &protoReq)
return msg, metadata, err
}
// RegisterAmbientLocalWeatherServiceHandlerServer registers the http handlers for service AmbientLocalWeatherService to "mux".
// UnaryRPC :call AmbientLocalWeatherServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
@ -94,6 +127,26 @@ func RegisterAmbientLocalWeatherServiceHandlerServer(ctx context.Context, mux *r
}
forward_AmbientLocalWeatherService_GetWeather_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodGet, pattern_AmbientLocalWeatherService_CountWeatherUpdates_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/ambient.weather.AmbientLocalWeatherService/CountWeatherUpdates", runtime.WithHTTPPathPattern("/v1/count"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_AmbientLocalWeatherService_CountWeatherUpdates_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_AmbientLocalWeatherService_CountWeatherUpdates_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
@ -151,13 +204,32 @@ func RegisterAmbientLocalWeatherServiceHandlerClient(ctx context.Context, mux *r
}
forward_AmbientLocalWeatherService_GetWeather_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodGet, pattern_AmbientLocalWeatherService_CountWeatherUpdates_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/ambient.weather.AmbientLocalWeatherService/CountWeatherUpdates", runtime.WithHTTPPathPattern("/v1/count"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_AmbientLocalWeatherService_CountWeatherUpdates_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_AmbientLocalWeatherService_CountWeatherUpdates_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_AmbientLocalWeatherService_GetWeather_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "weather"}, ""))
pattern_AmbientLocalWeatherService_CountWeatherUpdates_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "count"}, ""))
)
var (
forward_AmbientLocalWeatherService_GetWeather_0 = runtime.ForwardResponseMessage
forward_AmbientLocalWeatherService_CountWeatherUpdates_0 = runtime.ForwardResponseMessage
)

View File

@ -16,6 +16,42 @@
"application/json"
],
"paths": {
"/v1/count": {
"get": {
"operationId": "AmbientLocalWeatherService_CountWeatherUpdates",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/weatherCountWeatherUpdatesResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "opts.stationName",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "opts.stationType",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"AmbientLocalWeatherService"
]
}
},
"/v1/weather": {
"get": {
"operationId": "AmbientLocalWeatherService_GetWeather",
@ -102,6 +138,15 @@
},
"title": "Represents battery status for different components"
},
"weatherCountWeatherUpdatesResponse": {
"type": "object",
"properties": {
"count": {
"type": "integer",
"format": "int32"
}
}
},
"weatherGetWeatherOpts": {
"type": "object",
"properties": {
@ -263,6 +308,18 @@
"updateTimestamp": {
"type": "string",
"format": "date-time"
},
"lightningDay": {
"type": "integer",
"format": "int32"
},
"lightningDistance": {
"type": "integer",
"format": "int32"
},
"lightningLastTime": {
"type": "string",
"format": "date-time"
}
}
}

View File

@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion9
const (
AmbientLocalWeatherService_GetWeather_FullMethodName = "/ambient.weather.AmbientLocalWeatherService/GetWeather"
AmbientLocalWeatherService_CountWeatherUpdates_FullMethodName = "/ambient.weather.AmbientLocalWeatherService/CountWeatherUpdates"
)
// AmbientLocalWeatherServiceClient is the client API for AmbientLocalWeatherService service.
@ -27,6 +28,7 @@ const (
// 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)
CountWeatherUpdates(ctx context.Context, in *CountWeatherUpdatesRequest, opts ...grpc.CallOption) (*CountWeatherUpdatesResponse, error)
}
type ambientLocalWeatherServiceClient struct {
@ -47,11 +49,22 @@ func (c *ambientLocalWeatherServiceClient) GetWeather(ctx context.Context, in *G
return out, nil
}
func (c *ambientLocalWeatherServiceClient) CountWeatherUpdates(ctx context.Context, in *CountWeatherUpdatesRequest, opts ...grpc.CallOption) (*CountWeatherUpdatesResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CountWeatherUpdatesResponse)
err := c.cc.Invoke(ctx, AmbientLocalWeatherService_CountWeatherUpdates_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)
CountWeatherUpdates(context.Context, *CountWeatherUpdatesRequest) (*CountWeatherUpdatesResponse, error)
mustEmbedUnimplementedAmbientLocalWeatherServiceServer()
}
@ -65,6 +78,9 @@ type UnimplementedAmbientLocalWeatherServiceServer struct{}
func (UnimplementedAmbientLocalWeatherServiceServer) GetWeather(context.Context, *GetWeatherRequest) (*GetWeatherResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetWeather not implemented")
}
func (UnimplementedAmbientLocalWeatherServiceServer) CountWeatherUpdates(context.Context, *CountWeatherUpdatesRequest) (*CountWeatherUpdatesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CountWeatherUpdates not implemented")
}
func (UnimplementedAmbientLocalWeatherServiceServer) mustEmbedUnimplementedAmbientLocalWeatherServiceServer() {
}
func (UnimplementedAmbientLocalWeatherServiceServer) testEmbeddedByValue() {}
@ -105,6 +121,24 @@ func _AmbientLocalWeatherService_GetWeather_Handler(srv interface{}, ctx context
return interceptor(ctx, in, info, handler)
}
func _AmbientLocalWeatherService_CountWeatherUpdates_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CountWeatherUpdatesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AmbientLocalWeatherServiceServer).CountWeatherUpdates(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AmbientLocalWeatherService_CountWeatherUpdates_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AmbientLocalWeatherServiceServer).CountWeatherUpdates(ctx, req.(*CountWeatherUpdatesRequest))
}
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)
@ -116,6 +150,10 @@ var AmbientLocalWeatherService_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetWeather",
Handler: _AmbientLocalWeatherService_GetWeather_Handler,
},
{
MethodName: "CountWeatherUpdates",
Handler: _AmbientLocalWeatherService_CountWeatherUpdates_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "weather/weather_service.proto",

View File

@ -121,6 +121,10 @@
"default": "127.0.0.1",
"type": "string"
},
"redisKeyTTL": {
"default": "24h",
"type": "string"
},
"redisPassword": {
"type": "string"
},

View File

@ -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.7
version: 0.1.12
# 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.13.0"
appVersion: "v0.18.1"
dependencies:
- name: hull

View File

@ -9,6 +9,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
"k8s.io/utils/ptr"
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel"
@ -31,6 +32,27 @@ func NewGRPCWeather(ctx context.Context, recorder *recorder.WeatherRecorder) *GR
}
}
func (w *GRPCWeather) CountWeatherUpdates(ctx context.Context, req *pb.CountWeatherUpdatesRequest) (
*pb.CountWeatherUpdatesResponse, error,
) {
if req.Opts == nil {
count := w.recorder.Count(ctx)
return &pb.CountWeatherUpdatesResponse{Count: int32(count)}, nil
}
resp, err := w.GetWeather(ctx, &pb.GetWeatherRequest{
Opts: req.Opts,
Limit: ptr.To(int32(-1)),
})
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
return &pb.CountWeatherUpdatesResponse{
Count: int32(len(resp.WeatherUpdates)),
}, nil
}
func (w *GRPCWeather) GetWeather(ctx context.Context, req *pb.GetWeatherRequest) (
*pb.GetWeatherResponse, error,
) {

View File

@ -59,6 +59,9 @@ func UpdateToPbUpdate(u *weather.WeatherUpdate) *pb.WeatherUpdate {
WindChillF: u.WindChillF,
TempHumiditySensors: thSensorsToPbSensors(u.TempHumiditySensors),
UpdateTimestamp: timestamppb.New(*u.DateUTC),
LightningDay: util.Int32ptr(u.LightningDay),
LightningDistance: util.Int32ptr(u.LightningDistance),
LightningLastTime: util.TimestampFromIntPtr(u.LightningLastTime),
}
}

View File

@ -52,6 +52,8 @@ var mockUpdate = &weather.WeatherUpdate{
TempHumiditySensors: []*weather.TempHumiditySensor{
{Name: "sensor1", TempF: ptr.To(99.999), Humidity: nil},
},
LightningDay: ptr.To(1),
LightningDistance: ptr.To(20),
}
func TestUpdateToPbUpdate(t *testing.T) {
@ -104,6 +106,8 @@ func TestUpdateToPbUpdate(t *testing.T) {
},
},
UpdateTimestamp: timestamppb.New(now),
LightningDay: ptr.To(int32(1)),
LightningDistance: ptr.To(int32(20)),
},
},
}

View File

@ -22,4 +22,5 @@ type RedisConfig struct {
RedisDB int `yaml:"redisDB" env:"REDIS_DB" default:"0" json:"redisDB,omitempty"`
RedisTLS bool `yaml:"redisTLS" env:"REDIS_TLS" default:"false" json:"redisTLS,omitempty"`
RedisTLSInsecure bool `yaml:"redisTLSInsecure" env:"REDIS_TLS_INSECURE" default:"false" json:"redisTLSInsecure,omitempty"`
RedisKeyTTL string `yaml:"redisKeyTTL" env:"REDIS_KEY_TTL" default:"24h" json:"redisKeyTTL,omitempty"`
}

View File

@ -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,9 @@ func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
{Name: THSensor + "7", TempF: awnUpdate.Temp7F, Humidity: awnUpdate.Humidity7},
{Name: THSensor + "8", TempF: awnUpdate.Temp8F, Humidity: awnUpdate.Humidity8},
},
LightningDay: awnUpdate.LightningDay,
LightningDistance: awnUpdate.LightningDistance,
LightningLastTime: awnUpdate.LightningLastTime,
}
}
@ -145,6 +153,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
}

View File

@ -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"`
LightningLastTime *int `json:"lightning_time,omitempty" schema:"lightning_time" description:"last lightning detection time"`
}
type AmbientTempHumiditySensors struct {

View File

@ -5,8 +5,10 @@ import (
"encoding/hex"
"fmt"
"slices"
"time"
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
"google.golang.org/protobuf/types/known/timestamppb"
"k8s.io/utils/ptr"
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
@ -29,6 +31,13 @@ func Int32ptr(i *int) *int32 {
return ptr.To(int32(*i))
}
func TimestampFromIntPtr(i *int) *timestamppb.Timestamp {
if i == nil {
return nil
}
return timestamppb.New(time.Unix(int64(*i), 0))
}
// Generates a hash that will be consistent
// across all running replicas
func GetAppHash(conf *config.AppConfig) string {
@ -75,7 +84,12 @@ func ApplyOptsToUpdates(updates []*weather.WeatherUpdate, limit int, opts *pb.Ge
return updates
}
filtered := make([]*weather.WeatherUpdate, 0, limit)
capacity := len(updates)
if limit > 0 {
capacity = limit
}
filtered := make([]*weather.WeatherUpdate, 0, capacity)
for i := len(updates) - 1; i >= 0; i-- {
update := updates[i]

View File

@ -37,6 +37,11 @@ type WeatherMetrics struct {
DewPointF metric.Float64Gauge
WindChillF metric.Float64Gauge
// Lightning Sensor
LightningCountDay metric.Int64Gauge
LightningLastDistance metric.Int64Gauge
LightningLastTime metric.Int64Gauge
// Temp and Humidity Sensors
SensorTempF metric.Float64Gauge
SensorHumidity metric.Int64Gauge
@ -75,6 +80,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.WindChillF, FloatVal: u.WindChillF, Field: FieldWindChillF, Attributes: attributes, Station: u.StationConfig})
wm.recorder.Record(&RecordOpts{Int64Gauge: wm.LightningLastDistance, IntVal: u.LightningDistance, Field: FieldLightningDistance, 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.LightningLastTime, IntVal: u.LightningLastTime, Field: FieldLightningLastTime, Attributes: attributes, Station: u.StationConfig})
wm.RecordBatteries(u, attributes)
wm.RecordTempHumiditySensors(u, attributes)

View File

@ -66,6 +66,16 @@ 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"),
metric.WithUnit("km"))
wm.LightningLastTime, _ = wm.meter.Int64Gauge(MetricPrefix+"_lightning_last_time",
metric.WithDescription("Last lightning time (epoch)"),
metric.WithUnit("s"))
// Temp and Humidity Sensors
wm.SensorTempF, _ = wm.meter.Float64Gauge(MetricPrefix+"_sensor_temp_f",
metric.WithDescription("Temperature Sensor in Faherenheit"))

View File

@ -3,6 +3,7 @@ package weather
import (
"context"
"errors"
"slices"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel/attribute"
@ -19,6 +20,7 @@ type MetricRecorder struct {
type RecordOpts struct {
Float64Gauge metric.Float64Gauge
Int64Gauge metric.Int64Gauge
Int64Counter metric.Int64Counter
IntVal *int
FloatVal *float64
Attributes []attribute.KeyValue
@ -58,26 +60,39 @@ func (r *MetricRecorder) Record(opts *RecordOpts) {
return
}
r.recordFloat(opts.Float64Gauge, *opts.FloatVal, opts.Attributes...)
} else if opts.Int64Counter != 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 float metric")
return
}
r.recordCounter(opts.Int64Counter, *opts.IntVal, 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
return slices.Contains(o.Station.KeepMetrics, o.Field)
}
for _, f := range o.Station.DropMetrics {
if f == o.Field {
return false
return !slices.Contains(o.Station.DropMetrics, o.Field)
}
func (r *MetricRecorder) recordCounter(
m metric.Int64Counter, value int, attributes ...attribute.KeyValue,
) {
// Prepare metric attributes
options := make([]metric.AddOption, 0, len(attributes))
if len(attributes) > 0 {
options = append(options, metric.WithAttributes(attributes...))
}
}
return true
val := int64(value)
m.Add(r.ctx, val, options...)
}
func (r *MetricRecorder) recordInt(

View File

@ -5,6 +5,7 @@ import (
"crypto/tls"
"fmt"
"sync"
"time"
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/otel"
"go.opentelemetry.io/otel/attribute"
@ -20,6 +21,7 @@ import (
)
const (
DEF_TTL = "24h"
DEF_RETAIN = 120
UPDATES_KEY = "weatherUpdates"
NAME = "redis recorder"
@ -27,6 +29,7 @@ const (
type RedisRecorder struct {
baseCtx context.Context
keyTTL time.Duration
tracer trace.Tracer
redis *redis.Client
config *config.AmbientLocalExporterConfig
@ -42,8 +45,11 @@ func (r *RedisRecorder) Ping(ctx context.Context) error {
}
func (r *RedisRecorder) Init(ctx context.Context, opts *recorders.RecorderOpts) {
r.baseCtx = opts.BaseCtx
r.log = zerolog.Ctx(r.baseCtx)
if opts.AppConfig.RecorderConfig.RedisConfig == nil {
panic("refusing to init redis recorder with no redisConfig")
r.log.Panic().Msg("refusing to init redis recorder with no redisConfig")
}
if opts.RetainLast < 1 {
@ -53,8 +59,18 @@ func (r *RedisRecorder) Init(ctx context.Context, opts *recorders.RecorderOpts)
r.config = opts.AppConfig
r.keep = opts.RetainLast
r.RWMutex = &sync.RWMutex{}
r.baseCtx = opts.BaseCtx
r.log = zerolog.Ctx(r.baseCtx)
keyTTL := opts.AppConfig.RecorderConfig.RedisConfig.RedisKeyTTL
if keyTTL == "" {
keyTTL = DEF_TTL
}
var err error
r.keyTTL, err = time.ParseDuration(keyTTL)
if err != nil {
r.log.Panic().Str("redisKeyTTL", keyTTL).Err(err).
Msg("invalid redis key ttl provided")
}
r.tracer = otel.GetTracer(r.baseCtx, "redisRecorder")
ctx, span := r.tracer.Start(ctx, "redisRecorder.init", trace.WithAttributes(
@ -62,6 +78,7 @@ func (r *RedisRecorder) Init(ctx context.Context, opts *recorders.RecorderOpts)
attribute.Int("retainLast", opts.RetainLast),
attribute.Int("redisPort", opts.AppConfig.RecorderConfig.RedisConfig.RedisPort),
attribute.Bool("tls", opts.AppConfig.RecorderConfig.RedisConfig.RedisTLS),
attribute.String("keyTTL", r.keyTTL.String()),
))
defer span.End()

View File

@ -48,6 +48,7 @@ func (r *RedisRecorder) set(ctx context.Context, data []byte) error {
pipe.LPush(ctx, r.Key(), data)
pipe.LTrim(ctx, r.Key(), 0, int64(r.keep)-1)
count = pipe.LLen(ctx, r.Key())
pipe.Expire(ctx, r.Key(), r.keyTTL)
return nil
})
if err != nil {

View File

@ -9,48 +9,52 @@ import (
// Stable intermediate struct containing superset of fields
// between AWN and Wunderground style updates from Ambient devices
type WeatherUpdate struct {
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
DateUTC *time.Time `json:"dateUTC,omitempty"`
StationConfig *config.WeatherStation `json:"stationConfig,omitempty"`
StationID *string `json:"stationID,omitempty"`
StationType *string `json:"stationType,omitempty"`
TempOutdoorF *float64 `json:"tempOutdoorF,omitempty"`
TempIndoorF *float64 `json:"tempIndoorF,omitempty"`
HumidityOudoor *int `json:"humidityOudoor,omitempty"`
HumidityIndoor *int `json:"humidityIndoor,omitempty"`
WindSpeedMPH *float64 `json:"windSpeedMPH,omitempty"`
WindGustMPH *float64 `json:"windGustMPH,omitempty"`
MaxDailyGust *float64 `json:"maxDailyGust,omitempty"`
WindDir *int `json:"windDir,omitempty"`
WindDirAvg10m *int `json:"windDirAvg10M,omitempty"`
UV *int `json:"uv,omitempty"`
SolarRadiation *float64 `json:"solarRadiation,omitempty"`
HourlyRainIn *float64 `json:"hourlyRainIn,omitempty"`
EventRainIn *float64 `json:"eventRainIn,omitempty"`
DailyRainIn *float64 `json:"dailyRainIn,omitempty"`
WeeklyRainIn *float64 `json:"weeklyRainIn,omitempty"`
MonthlyRainIn *float64 `json:"monthlyRainIn,omitempty"`
YearlyRainIn *float64 `json:"yearlyRainIn,omitempty"`
TotalRainIn *float64 `json:"totalRainIn,omitempty"`
Batteries []BatteryStatus `json:"batteries,omitempty"`
BaromRelativeIn *float64 `json:"baromRelativeIn,omitempty"`
BaromAbsoluteIn *float64 `json:"baromAbsoluteIn,omitempty"`
// These fields may be calculated
// if not otherwise set
DewPointF *float64
WindChillF *float64
DewPointF *float64 `json:"dewPointF,omitempty"`
WindChillF *float64 `json:"windChillF,omitempty"`
// 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]
LightningLastTime *int `json:"lightningLastTime,omitempty"` // Last detection time
}
type TempHumiditySensor struct {
Name string
TempF *float64
Humidity *int
Name string `json:"name,omitempty"`
TempF *float64 `json:"tempF,omitempty"`
Humidity *int `json:"humidity,omitempty"`
}
type BatteryStatus struct {
Component string
Status *int
Component string `json:"component,omitempty"`
Status *int `json:"status,omitempty"`
}
// CHORE: Maintain this, used to check against
@ -84,6 +88,9 @@ const (
FieldWindChillF = "WindChillF"
FieldSensorTempF = "SensorTempF"
FieldSensorHumidity = "SensorHumidity"
FieldLightningDay = "LightningDay"
FieldLightningDistance = "LightningDistance"
FieldLightningLastTime = "LightningLastTime"
)
func (u *WeatherUpdate) GetStationName() string {

View File

@ -5,12 +5,20 @@ import "google/protobuf/timestamp.proto";
option go_package = "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather";
message CountWeatherUpdatesRequest {
GetWeatherOpts opts = 1;
}
message CountWeatherUpdatesResponse {
int32 count = 1;
}
message GetWeatherRequest {
GetWeatherOpts opts = 1;
optional int32 limit = 2;
}
message GetWeatherResponse{
message GetWeatherResponse {
google.protobuf.Timestamp last_updated = 1;
repeated WeatherUpdate weather_updates = 2;
}
@ -49,6 +57,9 @@ message WeatherUpdate {
optional double wind_chill_f = 26;
repeated TempHumiditySensor temp_humidity_sensors = 27;
google.protobuf.Timestamp update_timestamp = 28;
optional int32 lightning_day = 29;
optional int32 lightning_distance = 30;
optional google.protobuf.Timestamp lightning_last_time = 31;
}
// Represents a temperature and humidity sensor

View File

@ -10,4 +10,7 @@ service AmbientLocalWeatherService {
rpc GetWeather(GetWeatherRequest) returns (GetWeatherResponse) {
option (google.api.http) = {get: "/v1/weather"};
}
rpc CountWeatherUpdates(CountWeatherUpdatesRequest) returns (CountWeatherUpdatesResponse) {
option (google.api.http) = {get: "/v1/count"};
}
}