mirror of
				https://github.com/brianshea2/meshmap.net.git
				synced 2025-03-05 21:00:01 -08:00 
			
		
		
		
	collect and display rain over last hour metric (#34)
This commit is contained in:
		
							parent
							
								
									b9cdcc3abc
								
							
						
					
					
						commit
						caf9e2a2dd
					
				|  | @ -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() | ||||
| 		} | ||||
|  |  | |||
|  | @ -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() | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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' : '') + | ||||
|                               `</td></tr>`                                                                         : ''} | ||||
|       ${radiation          ? `<tr><th>Radiation</th><td>${radiation.toFixed(2)} µR/h</td></tr>`                    : ''} | ||||
|       ${rainfall           ? `<tr><th>Rainfall</th><td>${rainfall.toFixed(1)} mm/24h</td></tr>`                    : ''} | ||||
|       ${rainfall1 || rainfall24 ? `<tr><th>Rainfall</th><td>` + | ||||
|                               (rainfall1 ? `${rainfall1.toFixed(2)} mm/h` : '') + | ||||
|                               (rainfall1 && rainfall24 ? ', ' : '') + | ||||
|                               (rainfall24 ? `${rainfall24.toFixed(2)} mm/24h` : '') + | ||||
|                               `</td></tr>`                                                                         : ''} | ||||
|       ${altitude           ? `<tr><th>Altitude</th><td>${altitude.toLocaleString()} m above MSL</td></tr>`         : ''} | ||||
|       ${precision && precisionMargins[precision-1] ? `<tr><th>Location precision</th><td>` + | ||||
|                              `±${precisionMargins[precision-1].toLocaleString()} m (orange circle)</td></tr>` : ''} | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue