still sensor labels
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
2024-07-31 16:50:54 +02:00
parent 6f9327fdd6
commit f2f16c811a

View File

@ -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)