support sensor name mapping
All checks were successful
Build and Publish / release (push) Successful in 4m6s
All checks were successful
Build and Publish / release (push) Successful in 4m6s
This commit is contained in:
@ -10,6 +10,7 @@ import (
|
||||
|
||||
// Attempts to complete missing fields that may not
|
||||
// be set by a specific provider, such as DewPoint and WindChill
|
||||
// TODO: Add span
|
||||
func (u *WeatherUpdate) Enrich(weatherStations ...*config.WeatherStation) {
|
||||
if u == nil {
|
||||
return
|
||||
@ -49,6 +50,24 @@ func (u *WeatherUpdate) Enrich(weatherStations ...*config.WeatherStation) {
|
||||
}
|
||||
}
|
||||
|
||||
// Swaps sensor and component names based on
|
||||
// user provided configuration
|
||||
func (u *WeatherUpdate) MapSensors() {
|
||||
if u.StationConfig == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Map sensor battery components
|
||||
for i, batt := range u.Batteries {
|
||||
u.Batteries[i].Component = u.StationConfig.MapSensor(batt.Component)
|
||||
}
|
||||
|
||||
// Map other sensors
|
||||
for _, th := range u.TempHumiditySensors {
|
||||
th.Name = u.StationConfig.MapSensor(th.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func CalculateDewPoint(tempF, humidity float64) float64 {
|
||||
// Convert temperature from Fahrenheit to Celsius
|
||||
tempC := (tempF - 32) * 5 / 9
|
||||
|
Reference in New Issue
Block a user