Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
79d6422379
|
|||
532e12a9a6
|
|||
a5856f08ab
|
|||
d970151aca
|
|||
72757b5ae7
|
|||
7a350e0bc7
|
|||
1dbe656681
|
|||
b5f0c0d86f
|
@ -1,4 +1,4 @@
|
||||
FROM golang:1.21-alpine as builder
|
||||
FROM golang:1.22.5-alpine3.20 as builder
|
||||
|
||||
RUN mkdir -p /go/src
|
||||
COPY ./src/ /go/src
|
||||
|
@ -73,6 +73,7 @@ create or replace view co2_v as
|
||||
cast(m.values->'CO2concentration'->>'value' as float) as co2concentration,
|
||||
cast(m.values->'Humidity'->>'value' as float) as humidity,
|
||||
cast(m.values->'Temperature'->>'value' as float) as temperature,
|
||||
cast(m.values->'Brightness'->>'value' as int) as brightness,
|
||||
m.device as device,
|
||||
d.attributes->>'Label' as label
|
||||
from measurements m, devices d
|
||||
|
23
queries/saerbeck.sql
Normal file
23
queries/saerbeck.sql
Normal file
@ -0,0 +1,23 @@
|
||||
create or replace view badesee_temperature_v as
|
||||
select time,
|
||||
cast(values->'Temp_Red'->>'value' as float) as Temp1,
|
||||
cast(values->'Temp_White'->>'value' as float) as Temp2,
|
||||
cast(values->'Temp_Black'->>'value' as float) as Temp3,
|
||||
cast(values->'Battery'->>'value' as float) as battery,
|
||||
attributes->>'Status' as status,
|
||||
device
|
||||
from measurements
|
||||
where application = 'de-hottis-saerbeck-monitoring' and
|
||||
device = 'eui-a84041318187ec13';
|
||||
|
||||
create or replace view cubecell_threeway_temperature_v as
|
||||
select time,
|
||||
cast(values->'Temperature1'->>'value' as float) as Temp1,
|
||||
cast(values->'Temperature2'->>'value' as float) as Temp2,
|
||||
cast(values->'Temperature3'->>'value' as float) as Temp3,
|
||||
device
|
||||
from measurements
|
||||
where application = 'de-hottis-saerbeck-monitoring' and
|
||||
device = 'eui-70b3d57ed0068fa4';
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"mqtt": {
|
||||
"broker": "ssl://eu1.cloud.thethings.network:8883",
|
||||
"username": "de-hottis-lora-test1@ttn",
|
||||
"username": "de-hottis-saerbeck-monitoring@ttn",
|
||||
"tlsEnable": "true"
|
||||
},
|
||||
"topicMappings": [
|
||||
|
@ -1,24 +1,25 @@
|
||||
module udi
|
||||
|
||||
go 1.21.3
|
||||
go 1.22.3
|
||||
|
||||
require (
|
||||
github.com/eclipse/paho.mqtt.golang v1.4.3
|
||||
github.com/google/uuid v1.4.0
|
||||
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852
|
||||
gorm.io/driver/postgres v1.5.4
|
||||
gorm.io/gorm v1.25.5
|
||||
gorm.io/driver/postgres v1.5.9
|
||||
gorm.io/gorm v1.25.11
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||
github.com/jackc/pgx/v5 v5.4.3 // indirect
|
||||
github.com/jackc/pgx/v5 v5.5.5 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
golang.org/x/crypto v0.19.0 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/crypto v0.25.0 // indirect
|
||||
golang.org/x/net v0.27.0 // indirect
|
||||
golang.org/x/sync v0.7.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
)
|
||||
|
@ -11,8 +11,10 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY=
|
||||
github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
|
||||
github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw=
|
||||
github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A=
|
||||
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
|
||||
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
@ -26,25 +28,19 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/postgres v1.5.4 h1:Iyrp9Meh3GmbSuyIAGyjkN+n9K+GHX9b9MqsTL4EJCo=
|
||||
gorm.io/driver/postgres v1.5.4/go.mod h1:Bgo89+h0CRcdA33Y6frlaHHVuTdOf87pmyzwW9C/BH0=
|
||||
gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls=
|
||||
gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
gorm.io/driver/postgres v1.5.9 h1:DkegyItji119OlcaLjqN11kHoUgZ/j13E0jkJZgD6A8=
|
||||
gorm.io/driver/postgres v1.5.9/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI=
|
||||
gorm.io/gorm v1.25.11 h1:/Wfyg1B/je1hnDx3sMkX+gAlxrlZpn6X0BXRlwXlvHg=
|
||||
gorm.io/gorm v1.25.11/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
|
@ -20,9 +20,9 @@ type message struct {
|
||||
ALARM_status string `json:"ALARM_status"`
|
||||
Bat float32 `json:"BatV"`
|
||||
Work_mode string `json:"Work_mode"`
|
||||
Temp_Black string `json:"Temp_Black"`
|
||||
Temp_Red string `json:"Temp_Red"`
|
||||
Temp_White string `json:"Temp_White"`
|
||||
Temp_Black float32 `json:"Temp_Black"`
|
||||
Temp_Red float32 `json:"Temp_Red"`
|
||||
Temp_White float32 `json:"Temp_White"`
|
||||
}
|
||||
|
||||
func Parse(fPort int, decodedPayload []byte, _ string, variables *map[string]database.VariableType, attributes *map[string]interface{}, device *database.Device) error {
|
||||
|
@ -14,6 +14,7 @@ type hottisScd30Values struct {
|
||||
CO2Conc int32
|
||||
Temp int32
|
||||
Hum int32
|
||||
Bri int32
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +36,7 @@ func Parse(fPort int, _ []byte, frmPayload string, variables *map[string]databas
|
||||
var co2concentration float32 = float32(values.CO2Conc) / 100;
|
||||
var temperature float32 = float32(values.Temp) / 100;
|
||||
var humidity float32 = float32(values.Hum) / 100;
|
||||
|
||||
// log.Printf("CO2: %f, Temp: %f, Hum: %f, Status: %d", co2concentration, temperature, humidity, values.Status)
|
||||
|
||||
(*variables)["CO2concentration"] = database.VariableType {
|
||||
@ -55,6 +57,12 @@ func Parse(fPort int, _ []byte, frmPayload string, variables *map[string]databas
|
||||
Unit: "%",
|
||||
Value: humidity,
|
||||
}
|
||||
(*variables)["Brightness"] = database.VariableType {
|
||||
Label: "Brightness",
|
||||
Variable: "Brightness",
|
||||
Unit: "",
|
||||
Value: values.Bri,
|
||||
}
|
||||
|
||||
(*attributes)["Status"] = values.Status
|
||||
return nil
|
||||
|
@ -0,0 +1,74 @@
|
||||
package hottisThreeWayThermometer
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"udi/database"
|
||||
)
|
||||
|
||||
type hottisThreeWayThermometerValues struct {
|
||||
Status uint8
|
||||
// Battery uint16
|
||||
SensorAddress1 uint64
|
||||
Value1 int32
|
||||
SensorAddress2 uint64
|
||||
Value2 int32
|
||||
SensorAddress3 uint64
|
||||
Value3 int32
|
||||
}
|
||||
|
||||
|
||||
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 hottisThreeWayThermometerValues
|
||||
err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &values)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unable to cast into struct: %v", err)
|
||||
}
|
||||
|
||||
var value1 float32 = float32(values.Value1) / 128.0
|
||||
var value2 float32 = float32(values.Value2) / 128.0
|
||||
var value3 float32 = float32(values.Value3) / 128.0
|
||||
|
||||
//log.Printf("Status: %d, Battery: %d", values.Status, values.Battery);
|
||||
log.Printf("Status: %d", values.Status);
|
||||
log.Printf("Sensor1: Addr: %d, Value: %f", values.SensorAddress1, value1);
|
||||
log.Printf("Sensor2: Addr: %d, Value: %f", values.SensorAddress2, value2);
|
||||
log.Printf("Sensor3: Addr: %d, Value: %f", values.SensorAddress3, value3);
|
||||
|
||||
(*variables)["Temperature1"] = database.VariableType {
|
||||
Label: "Temperature1",
|
||||
Variable: "Temperature",
|
||||
Unit: "°C",
|
||||
Value: value1,
|
||||
}
|
||||
(*variables)["Temperature2"] = database.VariableType {
|
||||
Label: "Temperature2",
|
||||
Variable: "Temperature",
|
||||
Unit: "°C",
|
||||
Value: value2,
|
||||
}
|
||||
(*variables)["Temperature3"] = database.VariableType {
|
||||
Label: "Temperature3",
|
||||
Variable: "Temperature",
|
||||
Unit: "°C",
|
||||
Value: value3,
|
||||
}
|
||||
|
||||
(*attributes)["Status"] = values.Status
|
||||
(*attributes)["SensorAddress1"] = values.SensorAddress1
|
||||
(*attributes)["SensorAddress2"] = values.SensorAddress2
|
||||
(*attributes)["SensorAddress3"] = values.SensorAddress3
|
||||
return nil
|
||||
}
|
@ -14,6 +14,7 @@ import (
|
||||
"udi/handlers/ttn/models/draginoLsn50"
|
||||
"udi/handlers/ttn/models/rawPayloadPrinter"
|
||||
"udi/handlers/ttn/models/hottisScd30"
|
||||
"udi/handlers/ttn/models/hottisThreeWayThermometer"
|
||||
"udi/database"
|
||||
)
|
||||
|
||||
@ -152,6 +153,8 @@ func (self *TTNHandler) Handle(message handler.MessageT) {
|
||||
parser = rawPayloadPrinter.Parse
|
||||
case "hottis-scd30":
|
||||
parser = hottisScd30.Parse
|
||||
case "hottis-threeway-thermometer":
|
||||
parser = hottisThreeWayThermometer.Parse
|
||||
default:
|
||||
self.Lost(fmt.Sprintf("No parser found for %s", device.DeviceType.ModelIdentifier), nil, message)
|
||||
return
|
||||
|
Reference in New Issue
Block a user