diff --git a/src/udi/handlers/ttn/models/hottisThreeWayThermometer/hottisThreeWayThermometer.go b/src/udi/handlers/ttn/models/hottisThreeWayThermometer/hottisThreeWayThermometer.go index bddb2d4..1f6ddb8 100644 --- a/src/udi/handlers/ttn/models/hottisThreeWayThermometer/hottisThreeWayThermometer.go +++ b/src/udi/handlers/ttn/models/hottisThreeWayThermometer/hottisThreeWayThermometer.go @@ -7,7 +7,6 @@ import ( "strconv" "encoding/base64" "encoding/binary" - "encoding/json" "udi/database" ) @@ -22,9 +21,9 @@ type hottisThreeWayThermometerValues struct { Value3 int32 } -func getSensorName(sensorsMap *map[string]string, sensorAddress uint64) string { +func getSensorName(sensorsMap *map[string]interface{}, sensorAddress uint64) string { key := strconv.FormatUint(sensorAddress, 10) - if sensorName, exists := (*sensorsMap)[key]; exists { + if sensorName, exists := (*sensorsMap)[key].(string); exists { return sensorName } return "Sensor" + key @@ -32,15 +31,7 @@ func getSensorName(sensorsMap *map[string]string, sensorAddress uint64) string { func Parse(fPort int, _ []byte, frmPayload string, variables *map[string]database.VariableType, attributes *map[string]interface{}, device *database.Device) error { deviceAttrs := (*device).Attributes - sensorsMap := make(map[string]string) - sensorsJSON, ok := deviceAttrs["Sensors"].(string) - if !ok { - return fmt.Errorf("Unable to load sensor map from attributes") - } - errJ := json.Unmarshal([]byte(sensorsJSON), &sensorsMap) - if errJ != nil { - return fmt.Errorf("Unable to parse sensor map: %v", errJ) - } + sensorsMap := deviceAttrs["Sensors"].(map[string]interface{}) if fPort != 2 { return fmt.Errorf("Unexpected fPort %d", fPort)