fix multiple alarms
This commit is contained in:
+2
-1
@@ -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)
|
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")
|
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)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
func getDevAlias(deveui string) string {
|
||||||
res := deveui
|
res := deveui
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user