fix(db): push data with partial mapping
Signed-off-by: Klagarge <remi@heredero.ch>
This commit is contained in:
@@ -122,25 +122,29 @@ func main() {
|
||||
campus, campusOk := mapping.GetCampus(gatewayID)
|
||||
room, roomOk := mapping.GetRoom(nodeID)
|
||||
|
||||
if !campusOk {
|
||||
log.Printf("[Main] No mapping found for gateway=%s, dropping datapoint\n", gatewayID)
|
||||
return
|
||||
}
|
||||
|
||||
if !roomOk {
|
||||
log.Printf("[Main] No mapping found for gateway=%s, dropping datapoint\n", gatewayID)
|
||||
return
|
||||
}
|
||||
|
||||
batteryLevel := dp.GetValues().Battery
|
||||
log.Printf("[Main] Received gateway=%s node=%s -> campus=%s room=%s (Battery %d%%)\n", gatewayID, nodeID, campus, room, batteryLevel)
|
||||
|
||||
// Re-create the datapoint with campus/room tags for Influx
|
||||
influxTags := []point.Topic{
|
||||
var influxTags []point.Topic
|
||||
|
||||
if !campusOk {
|
||||
log.Printf("[Main] No mapping found for gateway=%s\n", gatewayID)
|
||||
influxTags = []point.Topic{
|
||||
{Subject: "node", Content: nodeID},
|
||||
}
|
||||
} else if !roomOk {
|
||||
log.Printf("[Main] No mapping found for gateway=%s\n", gatewayID)
|
||||
influxTags = []point.Topic{
|
||||
{Subject: "campus", Content: campus},
|
||||
{Subject: "node", Content: nodeID},
|
||||
}
|
||||
} else {
|
||||
influxTags = []point.Topic{
|
||||
{Subject: "campus", Content: campus},
|
||||
{Subject: "room", Content: room},
|
||||
{Subject: "node", Content: nodeID},
|
||||
}
|
||||
}
|
||||
|
||||
// If CO2PPM value is present and over 1000000000 delete the field
|
||||
values := dp.GetValues()
|
||||
|
||||
Reference in New Issue
Block a user