diff --git a/lorahandler.go b/lorahandler.go index 18c6ad2..4216269 100644 --- a/lorahandler.go +++ b/lorahandler.go @@ -204,7 +204,8 @@ func WriteDatapoint(mytime int64, deveui string, devaddr string, v uint8, h uint alertLogMap[deveui] = fmt.Sprintf("alert,deveui=%s reason=\"swarmalarm\",w=%di,w_loss=%di %d\n",deveui,w_gram,w_loss,mytime*60*1000*1000*1000) location, _ := time.LoadLocation("Europe/Zurich") alertMap[deveui] = fmt.Sprintf("*** Schwarmalarm ***\n%s\n%s\nGewichtsverlust: %d g",getDevAlias(deveui),time.Unix(mytime*60,0).In(location).Format("02.01.2006 15:04"),w_loss) - + // alte Werte loeschen + deleteValues(deveui) } } } diff --git a/persistence.go b/persistence.go index f9ff1f3..21d6335 100644 --- a/persistence.go +++ b/persistence.go @@ -121,6 +121,17 @@ func addValue(deveui string, value uint16) { } } +func deleteValues(deveui string) { + conn := globalPool.Get() + defer conn.Close() + + _, err := conn.Do("LTRIM", lastvaluesPrefix + deveui, 1, 0) + + if err != nil { + return + } +} + func getDevAlias(deveui string) string { res := deveui