some more attributes
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
2024-11-11 17:19:04 +01:00
parent b6a7447cb3
commit abc0ad0825

View File

@ -19,7 +19,7 @@ type Z2MHandler struct {
dbh *database.DatabaseHandle
}
func parse(T any, payload string, variables *map[string]database.VariableType, attributes *map[string]interface{}) error {
func parse(T any, payload string, variables *map[string]database.VariableType) error {
observationType := reflect.TypeOf(T)
observation := reflect.New(observationType).Interface()
@ -44,7 +44,6 @@ func parse(T any, payload string, variables *map[string]database.VariableType, a
}
}
(*attributes)["Status"] = "ok"
return nil
}
@ -90,12 +89,15 @@ func (self *Z2MHandler) Handle(message handler.MessageT) {
measurement.Attributes = make(map[string]interface{})
err3 := parse(T,
message.Payload,
&(measurement.Values),
&(measurement.Attributes))
&(measurement.Values))
if err3 != nil {
self.Lost("Model parser failed", err3, message)
return
}
measurement.Attributes["Status"] = "ok"
measurement.Attributes["DeviceId"] = deviceId
measurement.Attributes["DeviceModel"] = device.DeviceType.ModelIdentifier
log.Printf("Prepared measurement item: %s", measurement)
self.dbh.StoreMeasurement(&measurement)
self.S()