drop some obsolete instances

This commit is contained in:
2026-02-04 13:01:42 +01:00
parent a78c6952f0
commit 01acf835a8
3 changed files with 68 additions and 126 deletions

View File

@@ -1,21 +0,0 @@
{
"mqtt": {
"broker": "ssl://eu1.cloud.thethings.network:8883",
"username": "com-passavant-geiger-poc@ttn",
"tlsEnable": "true"
},
"topicMappings": [
{
"topics": [ "v3/com-passavant-geiger-poc@ttn/devices/#" ],
"handler": "TTN",
"id": "TTN0",
"config": {
"attributes": {
}
}
}
],
"archiver": {
"dir": "/archive"
}
}

View File

@@ -1,22 +0,0 @@
{
"mqtt": {
"broker": "ssl://eu1.cloud.thethings.network:8883",
"username": "de-hottis-app01@ttn",
"password": "ENV",
"tlsEnable": "true"
},
"topicMappings": [
{
"topics": [ "v3/#" ],
"handler": "TTN",
"id": "TTN0",
"config": {
"attributes": {
}
}
}
],
"archiver": {
"dir": "/archive"
}
}

View File

@@ -1,16 +1,15 @@
package mbgw3 package mbgw3
import ( import (
"time" "encoding/json"
"log" "log"
"strconv" "strconv"
"encoding/json" "time"
"udi/config" "udi/config"
"udi/handlers/handler"
"udi/database" "udi/database"
"udi/handlers/handler"
) )
type Mbgw3Handler struct { type Mbgw3Handler struct {
handler.CommonHandler handler.CommonHandler
dbh *database.DatabaseHandle dbh *database.DatabaseHandle
@@ -26,10 +25,8 @@ type Observation struct {
Values map[string]string Values map[string]string
} }
func New(id string, config config.HandlerConfigT) handler.Handler { func New(id string, config config.HandlerConfigT) handler.Handler {
t := &Mbgw3Handler { t := &Mbgw3Handler{}
}
t.Id = id t.Id = id
t.dbh = database.NewDatabaseHandle() t.dbh = database.NewDatabaseHandle()
log.Printf("Handler MBGW3 %d initialized", id) log.Printf("Handler MBGW3 %d initialized", id)
@@ -73,23 +70,13 @@ func (self *Mbgw3Handler) Handle(message handler.MessageT) {
measurement.Attributes["Status"] = observation.Status measurement.Attributes["Status"] = observation.Status
measurement.Values = make(map[string]database.VariableType) measurement.Values = make(map[string]database.VariableType)
unitMap := map[string]string { "Energy": "Wh", "Power": "W", "Voltage": "V", "Current": "A", "Volume": "m3" } unitMap := map[string]string{"Energy": "Wh", "Power": "W", "Voltage": "V", "Current": "A", "Volume": "m3"}
keyCount := make(map[string]int)
for k, v := range observation.Values { for k, v := range observation.Values {
unit, exists := unitMap[k] unit, exists := unitMap[k]
if ! exists { if !exists {
unit = "Unmapped Unit" unit = "Unmapped Unit"
} }
measurement.Values[k] = database.VariableType{
// Check if key already exists and create unique key if needed
keyCount[k]++
uniqueKey := k
if keyCount[k] > 1 {
uniqueKey = k + strconv.Itoa(keyCount[k])
}
measurement.Values[uniqueKey] = database.VariableType {
Label: "", Label: "",
Variable: k, Variable: k,
Unit: unit, Unit: unit,
@@ -102,5 +89,3 @@ func (self *Mbgw3Handler) Handle(message handler.MessageT) {
self.dbh.StoreMeasurement(&measurement) self.dbh.StoreMeasurement(&measurement)
self.S() self.S()
} }