implement lightning_time in grpc
This commit is contained in:
parent
82ae3e4ba4
commit
15dd74d6ab
@ -298,6 +298,7 @@ type WeatherUpdate struct {
|
|||||||
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"`
|
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"`
|
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
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@ -542,6 +543,13 @@ func (x *WeatherUpdate) GetLightningDistance() int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *WeatherUpdate) GetLightningLastTime() *timestamppb.Timestamp {
|
||||||
|
if x != nil {
|
||||||
|
return x.LightningLastTime
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// 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"`
|
||||||
@ -676,7 +684,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\"\x85\x0e\n" +
|
"\r_station_type\"\xee\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" +
|
||||||
@ -711,7 +719,8 @@ const file_weather_weather_proto_rawDesc = "" +
|
|||||||
"\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\x0fupdateTimestamp\x12(\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" +
|
"\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" +
|
"\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" +
|
"\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" +
|
||||||
@ -735,7 +744,8 @@ const file_weather_weather_proto_rawDesc = "" +
|
|||||||
"\f_dew_point_fB\x0f\n" +
|
"\f_dew_point_fB\x0f\n" +
|
||||||
"\r_wind_chill_fB\x10\n" +
|
"\r_wind_chill_fB\x10\n" +
|
||||||
"\x0e_lightning_dayB\x15\n" +
|
"\x0e_lightning_dayB\x15\n" +
|
||||||
"\x13_lightning_distance\"}\n" +
|
"\x13_lightning_distanceB\x16\n" +
|
||||||
|
"\x14_lightning_last_time\"}\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" +
|
||||||
@ -779,11 +789,12 @@ var file_weather_weather_proto_depIdxs = []int32{
|
|||||||
7, // 4: ambient.weather.WeatherUpdate.batteries:type_name -> ambient.weather.BatteryStatus
|
7, // 4: ambient.weather.WeatherUpdate.batteries:type_name -> ambient.weather.BatteryStatus
|
||||||
6, // 5: ambient.weather.WeatherUpdate.temp_humidity_sensors:type_name -> ambient.weather.TempHumiditySensor
|
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, // 6: ambient.weather.WeatherUpdate.update_timestamp:type_name -> google.protobuf.Timestamp
|
||||||
7, // [7:7] is the sub-list for method output_type
|
8, // 7: ambient.weather.WeatherUpdate.lightning_last_time:type_name -> google.protobuf.Timestamp
|
||||||
7, // [7:7] is the sub-list for method input_type
|
8, // [8:8] is the sub-list for method output_type
|
||||||
7, // [7:7] is the sub-list for extension type_name
|
8, // [8:8] is the sub-list for method input_type
|
||||||
7, // [7:7] is the sub-list for extension extendee
|
8, // [8:8] is the sub-list for extension type_name
|
||||||
0, // [0:7] is the sub-list for field 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() }
|
func init() { file_weather_weather_proto_init() }
|
||||||
|
@ -316,6 +316,10 @@
|
|||||||
"lightningDistance": {
|
"lightningDistance": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int32"
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"lightningLastTime": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ func UpdateToPbUpdate(u *weather.WeatherUpdate) *pb.WeatherUpdate {
|
|||||||
UpdateTimestamp: timestamppb.New(*u.DateUTC),
|
UpdateTimestamp: timestamppb.New(*u.DateUTC),
|
||||||
LightningDay: util.Int32ptr(u.LightningDay),
|
LightningDay: util.Int32ptr(u.LightningDay),
|
||||||
LightningDistance: util.Int32ptr(u.LightningDistance),
|
LightningDistance: util.Int32ptr(u.LightningDistance),
|
||||||
|
LightningLastTime: util.TimestampFromIntPtr(u.LightningLastTime),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ func MapAwnUpdate(awnUpdate *AmbientWeatherUpdate) *weather.WeatherUpdate {
|
|||||||
},
|
},
|
||||||
LightningDay: awnUpdate.LightningDay,
|
LightningDay: awnUpdate.LightningDay,
|
||||||
LightningDistance: awnUpdate.LightningDistance,
|
LightningDistance: awnUpdate.LightningDistance,
|
||||||
LightningTime: awnUpdate.LightningTime,
|
LightningLastTime: awnUpdate.LightningLastTime,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ 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" description:"count of lightning detections"`
|
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"`
|
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"`
|
LightningLastTime *int `json:"lightning_time,omitempty" schema:"lightning_time" description:"last lightning detection time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AmbientTempHumiditySensors struct {
|
type AmbientTempHumiditySensors struct {
|
||||||
|
@ -5,8 +5,10 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
|
"time"
|
||||||
|
|
||||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
|
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
|
||||||
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
"k8s.io/utils/ptr"
|
"k8s.io/utils/ptr"
|
||||||
|
|
||||||
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
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))
|
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
|
// Generates a hash that will be consistent
|
||||||
// across all running replicas
|
// across all running replicas
|
||||||
func GetAppHash(conf *config.AppConfig) string {
|
func GetAppHash(conf *config.AppConfig) string {
|
||||||
|
@ -82,7 +82,7 @@ func (wm *WeatherMetrics) Update(u *WeatherUpdate) {
|
|||||||
|
|
||||||
wm.recorder.Record(&RecordOpts{Int64Gauge: wm.LightningLastDistance, IntVal: u.LightningDistance, Field: FieldLightningDistance, 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.LightningCountDay, IntVal: u.LightningDay, Field: FieldLightningDay, Attributes: attributes, Station: u.StationConfig})
|
||||||
wm.recorder.Record(&RecordOpts{Int64Gauge: wm.LightningLastTime, IntVal: u.LightningTime, Field: FieldLightningLastTime, 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.RecordBatteries(u, attributes)
|
||||||
wm.RecordTempHumiditySensors(u, attributes)
|
wm.RecordTempHumiditySensors(u, attributes)
|
||||||
|
@ -43,7 +43,7 @@ type WeatherUpdate struct {
|
|||||||
// Lightning Data
|
// Lightning Data
|
||||||
LightningDay *int `json:"lightningDay,omitempty"` // Count of detections
|
LightningDay *int `json:"lightningDay,omitempty"` // Count of detections
|
||||||
LightningDistance *int `json:"lightningDistance,omitempty"` // Last detection distance [kilometers]
|
LightningDistance *int `json:"lightningDistance,omitempty"` // Last detection distance [kilometers]
|
||||||
LightningTime *int `json:"lightningTime,omitempty"` // Last detection time
|
LightningLastTime *int `json:"lightningLastTime,omitempty"` // Last detection time
|
||||||
}
|
}
|
||||||
|
|
||||||
type TempHumiditySensor struct {
|
type TempHumiditySensor struct {
|
||||||
|
@ -59,6 +59,7 @@ message WeatherUpdate {
|
|||||||
google.protobuf.Timestamp update_timestamp = 28;
|
google.protobuf.Timestamp update_timestamp = 28;
|
||||||
optional int32 lightning_day = 29;
|
optional int32 lightning_day = 29;
|
||||||
optional int32 lightning_distance = 30;
|
optional int32 lightning_distance = 30;
|
||||||
|
optional google.protobuf.Timestamp lightning_last_time = 31;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Represents a temperature and humidity sensor
|
// Represents a temperature and humidity sensor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user