diff --git a/cmd/meshobserv/meshobserv.go b/cmd/meshobserv/meshobserv.go index 5a38e00..26aba0d 100644 --- a/cmd/meshobserv/meshobserv.go +++ b/cmd/meshobserv/meshobserv.go @@ -112,11 +112,12 @@ func handleMessage(from uint32, topic string, portNum generated.PortNum, payload windSpeed := envMetrics.GetWindSpeed() windGust := envMetrics.GetWindGust() radiation := envMetrics.GetRadiation() - rainfall := envMetrics.GetRainfall_24H() + rainfall1 := envMetrics.GetRainfall_1H() + rainfall24 := envMetrics.GetRainfall_24H() log.Printf( - "[msg] %v (%v) %s: EnvironmentMetrics{temp: %v; hum: %v; pres: %v; lux: %v; wind: %v @ %v G %v; rad: %v; rain: %v}", + "[msg] %v (%v) %s: EnvironmentMetrics{temp: %v; hum: %v; pres: %v; lux: %v; wind: %v @ %v G %v; rad: %v; rain: %v %v}", from, topic, portNum, temperature, relativeHumidity, barometricPressure, lux, - windDirection, windSpeed, windGust, radiation, rainfall, + windDirection, windSpeed, windGust, radiation, rainfall1, rainfall24, ) NodesMutex.Lock() if Nodes[from] == nil { @@ -131,7 +132,8 @@ func handleMessage(from uint32, topic string, portNum generated.PortNum, payload windSpeed, windGust, radiation, - rainfall, + rainfall1, + rainfall24, ) NodesMutex.Unlock() } diff --git a/internal/meshtastic/node.go b/internal/meshtastic/node.go index 945e9b6..12a2a8f 100644 --- a/internal/meshtastic/node.go +++ b/internal/meshtastic/node.go @@ -59,7 +59,8 @@ type Node struct { WindSpeed float32 `json:"windSpeed,omitempty"` WindGust float32 `json:"windGust,omitempty"` Radiation float32 `json:"radiation,omitempty"` - Rainfall float32 `json:"rainfall,omitempty"` + Rainfall1 float32 `json:"rainfall1,omitempty"` + Rainfall24 float32 `json:"rainfall24,omitempty"` LastEnvironmentMetrics int64 `json:"lastEnvironmentMetrics,omitempty"` // NeighborInfo Neighbors map[uint32]*NeighborInfo `json:"neighbors,omitempty"` @@ -91,7 +92,8 @@ func (node *Node) ClearEnvironmentMetrics() { node.WindSpeed = 0 node.WindGust = 0 node.Radiation = 0 - node.Rainfall = 0 + node.Rainfall1 = 0 + node.Rainfall24 = 0 node.LastEnvironmentMetrics = 0 } @@ -175,7 +177,7 @@ func (node *Node) UpdateDeviceMetrics(batteryLevel uint32, voltage, chUtil, airU node.LastDeviceMetrics = time.Now().Unix() } -func (node *Node) UpdateEnvironmentMetrics(temperature, relativeHumidity, barometricPressure, lux float32, windDirection uint32, windSpeed, windGust, radiation, rainfall float32) { +func (node *Node) UpdateEnvironmentMetrics(temperature, relativeHumidity, barometricPressure, lux float32, windDirection uint32, windSpeed, windGust, radiation, rainfall1, rainfall24 float32) { node.Temperature = cleanFloat(temperature) node.RelativeHumidity = cleanFloat(relativeHumidity) node.BarometricPressure = cleanFloat(barometricPressure) @@ -184,7 +186,8 @@ func (node *Node) UpdateEnvironmentMetrics(temperature, relativeHumidity, barome node.WindSpeed = cleanFloat(windSpeed) node.WindGust = cleanFloat(windGust) node.Radiation = cleanFloat(radiation) - node.Rainfall = cleanFloat(rainfall) + node.Rainfall1 = cleanFloat(rainfall1) + node.Rainfall24 = cleanFloat(rainfall24) node.LastEnvironmentMetrics = time.Now().Unix() } diff --git a/website/index.html b/website/index.html index 4423a8e..fe7118f 100644 --- a/website/index.html +++ b/website/index.html @@ -216,7 +216,8 @@ fwVersion, region, modemPreset, hasDefaultCh, onlineLocalNodes, latitude, longitude, altitude, precision, batteryLevel, voltage, chUtil, airUtilTx, uptime, - temperature, relativeHumidity, barometricPressure, lux, windDirection, windSpeed, windGust, radiation, rainfall, + temperature, relativeHumidity, barometricPressure, lux, + windDirection, windSpeed, windGust, radiation, rainfall1, rainfall24, neighbors, seenBy } = node const id = `!${Number(nodeNum).toString(16)}` @@ -259,7 +260,11 @@ (windSpeed ? ' km/h' : '') + `` : ''} ${radiation ? `Radiation${radiation.toFixed(2)} µR/h` : ''} - ${rainfall ? `Rainfall${rainfall.toFixed(1)} mm/24h` : ''} + ${rainfall1 || rainfall24 ? `Rainfall` + + (rainfall1 ? `${rainfall1.toFixed(2)} mm/h` : '') + + (rainfall1 && rainfall24 ? ', ' : '') + + (rainfall24 ? `${rainfall24.toFixed(2)} mm/24h` : '') + + `` : ''} ${altitude ? `Altitude${altitude.toLocaleString()} m above MSL` : ''} ${precision && precisionMargins[precision-1] ? `Location precision` + `±${precisionMargins[precision-1].toLocaleString()} m (orange circle)` : ''}