Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
799ef9e00b | |||
311e732841 | |||
51e482e94e
|
|||
a1b98d3438
|
|||
166c414af1
|
|||
cedb1dfa5a
|
|||
a21fae4f8a
|
|||
1b6ac5d762
|
|||
95831d5e47
|
@ -10,6 +10,8 @@ if [ "$MD5_CHECKSUM" = "" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo $ENCRYPTION_KEY
|
||||
|
||||
SECRETS_CIPHERTEXT_FILE=secrets.enc
|
||||
SECRETS_PLAINTEXT_FILE=/tmp/secrets
|
||||
TMP_FILE=`mktemp`
|
||||
|
@ -118,3 +118,14 @@ create or replace view router_v as
|
||||
cast(values->'wan-out'->>'value' as int) as wanOutOctetsPerSeconds
|
||||
from measurements
|
||||
where application = 'SNMP' and device = '172.16.3.1';
|
||||
|
||||
create or replace view lora_sht21_v as
|
||||
select time,
|
||||
cast(values->'Humidity'->>'value' as float) as humidity,
|
||||
cast(values->'Temperature'->>'value' as float) as temperature,
|
||||
m.device as device,
|
||||
d.attributes->>'Label' as label
|
||||
from measurements m, devices d
|
||||
where m.application = 'de-hottis-app01' and
|
||||
m.attributes->>'DeviceType' = 'hottis-gy21' and
|
||||
m.device = d.label;
|
||||
|
@ -25,7 +25,7 @@ func NewDatabaseHandle() *DatabaseHandle {
|
||||
} else {
|
||||
db.dbh = conn
|
||||
db.initialized = true
|
||||
//log.Println("Database connection opened")
|
||||
log.Println("Database connection opened")
|
||||
}
|
||||
return &db
|
||||
}
|
||||
@ -44,7 +44,7 @@ func (self *DatabaseHandle) StoreMeasurement(measurement *Measurement) {
|
||||
return
|
||||
}
|
||||
|
||||
//log.Println("Successfully stored measurement")
|
||||
log.Println("Successfully stored measurement")
|
||||
counter.S("Stored")
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
t.Id = id
|
||||
|
||||
t.dbh = database.NewDatabaseHandle()
|
||||
log.Printf("Handler DT1T %d initialized", id)
|
||||
t.ready = true
|
||||
return t
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
}
|
||||
t.Id = id
|
||||
t.dbh = database.NewDatabaseHandle()
|
||||
log.Printf("Handler Locative %d initialized", id)
|
||||
return t
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package mbgw3
|
||||
|
||||
import (
|
||||
"time"
|
||||
"log"
|
||||
"strconv"
|
||||
"encoding/json"
|
||||
"udi/config"
|
||||
@ -31,6 +32,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
}
|
||||
t.Id = id
|
||||
t.dbh = database.NewDatabaseHandle()
|
||||
log.Printf("Handler MBGW3 %d initialized", id)
|
||||
return t
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package pv
|
||||
import (
|
||||
"reflect"
|
||||
"time"
|
||||
"log"
|
||||
"encoding/json"
|
||||
"udi/config"
|
||||
"udi/handlers/handler"
|
||||
@ -41,6 +42,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
}
|
||||
t.Id = id
|
||||
t.dbh = database.NewDatabaseHandle()
|
||||
log.Printf("Handler PV %d initialized", id)
|
||||
return t
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package snmp
|
||||
|
||||
import (
|
||||
"time"
|
||||
// "log"
|
||||
"log"
|
||||
"encoding/json"
|
||||
"udi/config"
|
||||
"udi/handlers/handler"
|
||||
@ -33,6 +33,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
}
|
||||
t.Id = id
|
||||
t.dbh = database.NewDatabaseHandle()
|
||||
log.Printf("Handler SNMP %d initialized", id)
|
||||
return t
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
t.Id = id
|
||||
t.ready = true
|
||||
t.dbh = database.NewDatabaseHandle()
|
||||
log.Printf("Handler SVEJ %d initialized", id)
|
||||
return t
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
t.Id = id
|
||||
t.ready = true
|
||||
t.dbh = database.NewDatabaseHandle()
|
||||
log.Printf("Handler SVER %d initialized", id)
|
||||
return t
|
||||
}
|
||||
|
||||
|
55
src/udi/handlers/ttn/models/hottisGy21/hottisGY21.go
Normal file
55
src/udi/handlers/ttn/models/hottisGy21/hottisGY21.go
Normal file
@ -0,0 +1,55 @@
|
||||
package hottisGy21
|
||||
|
||||
import (
|
||||
//"log"
|
||||
"fmt"
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"udi/database"
|
||||
)
|
||||
|
||||
type hottisGy21Values struct {
|
||||
Connected uint8
|
||||
Status uint8
|
||||
RawHumidity uint16
|
||||
RawTemperature uint16
|
||||
}
|
||||
|
||||
|
||||
func Parse(fPort int, _ []byte, frmPayload string, variables *map[string]database.VariableType, attributes *map[string]interface{}, _ *database.Device) error {
|
||||
if fPort != 2 {
|
||||
return fmt.Errorf("Unexpected fPort %d", fPort)
|
||||
}
|
||||
|
||||
b, err := base64.StdEncoding.DecodeString(frmPayload)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to base64-decode payload: %v", err)
|
||||
}
|
||||
|
||||
var values hottisGy21Values
|
||||
err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &values)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to cast into struct: %v", err)
|
||||
}
|
||||
var temperature float32 = -46.85 + 175.72 * (float32(values.RawTemperature) / 65536.0)
|
||||
var humidity float32 = -6 + 125 * (float32(values.RawHumidity) / 65536.0);
|
||||
|
||||
// log.Printf("CO2: %f, Temp: %f, Hum: %f, Status: %d", co2concentration, temperature, humidity, values.Status)
|
||||
|
||||
(*variables)["Humidity"] = database.VariableType {
|
||||
Label: "Humidity",
|
||||
Variable: "Humidity",
|
||||
Unit: "%",
|
||||
Value: humidity,
|
||||
}
|
||||
(*variables)["Temperature"] = database.VariableType {
|
||||
Label: "Temperature",
|
||||
Variable: "Temperature",
|
||||
Unit: "°C",
|
||||
Value: temperature,
|
||||
}
|
||||
|
||||
(*attributes)["Status"] = values.Status
|
||||
return nil
|
||||
}
|
@ -2,7 +2,7 @@ package ttn
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
//"log"
|
||||
"log"
|
||||
"time"
|
||||
"encoding/json"
|
||||
"udi/config"
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"udi/handlers/ttn/models/draginoLsn50"
|
||||
"udi/handlers/ttn/models/rawPayloadPrinter"
|
||||
"udi/handlers/ttn/models/hottisScd30"
|
||||
"udi/handlers/ttn/models/hottisGy21"
|
||||
"udi/handlers/ttn/models/hottisThreeWayThermometer"
|
||||
"udi/database"
|
||||
)
|
||||
@ -85,6 +86,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
}
|
||||
t.Id = id
|
||||
t.dbh = database.NewDatabaseHandle()
|
||||
log.Printf("Handler TTN %d initialized", id)
|
||||
return t
|
||||
}
|
||||
|
||||
@ -153,6 +155,8 @@ func (self *TTNHandler) Handle(message handler.MessageT) {
|
||||
parser = rawPayloadPrinter.Parse
|
||||
case "hottis-scd30":
|
||||
parser = hottisScd30.Parse
|
||||
case "hottis-gy21":
|
||||
parser = hottisGy21.Parse
|
||||
case "hottis-threeway-thermometer":
|
||||
parser = hottisThreeWayThermometer.Parse
|
||||
default:
|
||||
|
@ -55,6 +55,7 @@ func New(id string, config config.HandlerConfigT) handler.Handler {
|
||||
}
|
||||
t.Id = id
|
||||
t.dbh = database.NewDatabaseHandle()
|
||||
log.Printf("Handler Z2M %d initialized", id)
|
||||
return t
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user