50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
package grpc
|
|
|
|
import (
|
|
"k8s.io/utils/ptr"
|
|
|
|
pb "gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/api/v1alpha1/weather"
|
|
"gitea.libretechconsulting.com/rmcguire/ambient-local-exporter/pkg/weather"
|
|
)
|
|
|
|
func UpdatesToPbUpdates(u []*weather.WeatherUpdate) []*pb.WeatherUpdate {
|
|
updates := make([]*pb.WeatherUpdate, len(u))
|
|
for i, update := range u {
|
|
updates[i] = UpdateToPbUpdate(update)
|
|
}
|
|
return updates
|
|
}
|
|
|
|
// TODO: Finish Implementing
|
|
func UpdateToPbUpdate(u *weather.WeatherUpdate) *pb.WeatherUpdate {
|
|
return &pb.WeatherUpdate{
|
|
StationName: u.StationConfig.Name,
|
|
StationType: *u.StationType,
|
|
StationId: *u.StationID,
|
|
TempOutdoorF: u.TempOutdoorF,
|
|
TempIndoorF: u.TempIndoorF,
|
|
HumidityOutdoor: ptr.To(int32(*u.HumidityOudoor)),
|
|
HumidityIndoor: ptr.To(int32(*u.HumidityIndoor)),
|
|
WindSpeedMph: new(float64),
|
|
WindGustMph: new(float64),
|
|
MaxDailyGust: new(float64),
|
|
WindDir: new(int32),
|
|
WindDirAvg_10M: new(int32),
|
|
Uv: new(int32),
|
|
SolarRadiation: new(float64),
|
|
HourlyRainIn: new(float64),
|
|
EventRainIn: new(float64),
|
|
DailyRainIn: new(float64),
|
|
WeeklyRainIn: new(float64),
|
|
MonthlyRainIn: new(float64),
|
|
YearlyRainIn: new(float64),
|
|
TotalRainIn: new(float64),
|
|
Batteries: []*pb.BatteryStatus{},
|
|
BaromRelativeIn: new(float64),
|
|
BaromAbsoluteIn: new(float64),
|
|
DewPointF: new(float64),
|
|
WindChillF: new(float64),
|
|
TempHumiditySensors: []*pb.TempHumiditySensor{},
|
|
}
|
|
}
|