Compare commits

...

34 Commits

Author SHA1 Message Date
4debe45592 fix new ci, 7
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-02-04 16:04:59 +01:00
71773968c9 fix new ci, 6
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-02-04 16:02:52 +01:00
574e2886f5 fix new ci, 5
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-04 15:42:02 +01:00
e25693fb84 fix new ci, 4
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-04 15:11:49 +01:00
ff49d285dc fix new ci, 3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-04 15:10:14 +01:00
8c3977162b fix new ci, 2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-04 15:07:31 +01:00
b99b47ca40 fix new ci, 1
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-04 15:05:53 +01:00
c40805b4cb change Dockerfile, introduce separate build step
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-02-04 15:01:49 +01:00
a2eb38b414 sbon, 6
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-03 17:30:05 +01:00
64cf45e22f sbon, 5
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-02-03 17:27:19 +01:00
9310a86687 sbon, 4
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-02-03 17:24:07 +01:00
f4b404e2b1 sbon, 3
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-02-03 17:20:18 +01:00
29148a13f4 sbon, 2
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-02-03 17:18:44 +01:00
0356e9dcee sbon
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-02-03 17:14:11 +01:00
a5b981357d enable license scanning, 2
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-03 16:51:16 +01:00
57bbc6135e enable license scanning
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-03 16:43:46 +01:00
d704f7ba5e python module updated too
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-03 14:38:14 +01:00
d0567a48f1 update modules
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-03 14:35:44 +01:00
ee22996433 sbom in ci, 3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2025-02-03 14:26:07 +01:00
4130befdbf sbom in ci, 2
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2025-02-03 14:23:45 +01:00
77c5df0697 sbom in ci 2025-02-03 14:21:41 +01:00
d4ee4c49de new database
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-01-09 16:18:53 +01:00
ae938d10b9 debug
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-01-09 14:53:12 +01:00
799ef9e00b Merge branch 'main' of gitea.hottis.de:wn/universal-data-ingest
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2025-01-09 14:49:24 +01:00
311e732841 debug 2025-01-09 14:49:15 +01:00
51e482e94e fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-12-13 10:27:02 +01:00
a1b98d3438 more debugging
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-12-13 10:02:32 +01:00
166c414af1 more debugging for database issue
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-12-12 23:23:32 +01:00
cedb1dfa5a more debugging for database issue
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-12-12 23:21:09 +01:00
a21fae4f8a view
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-12-04 13:17:06 +01:00
1b6ac5d762 gy21, fix
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-12-04 12:52:03 +01:00
95831d5e47 gy21
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-12-04 12:49:49 +01:00
c3dce9faab disable debugging code
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2024-11-15 11:26:26 +01:00
c332373691 disable debugging code
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/tag/woodpecker Pipeline failed
2024-11-15 11:24:26 +01:00
20 changed files with 157 additions and 37 deletions

View File

@ -1,5 +1,50 @@
steps:
build:
image: golang:1.22.5-alpine3.20
commands:
- GOPATH=/woodpecker/go
- cd src/udi
- go mod tidy
- go build -a -installsuffix nocgo -o udi main.go
- cp udi ../..
scan:
image: quay.io/wollud1969/woodpecker-helper:0.5.1
environment:
TRIVY_TOKEN:
from_secret: trivy_token
TRIVY_URL:
from_secret: trivy_url
DTRACK_API_KEY:
from_secret: dtrack_api_key
DTRACK_API_URL:
from_secret: dtrack_api_url
commands:
- export GOPATH=/woodpecker/go # the export is required, otherwise trivy will not consider the variable
- HOME=/home/`id -nu`
- TAG="${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
- |
trivy fs \
--server $TRIVY_URL \
--token $TRIVY_TOKEN \
--format cyclonedx \
--scanners license \
--output /tmp/sbom.xml \
.
- cat /tmp/sbom.xml
- |
curl -X "POST" \
-H "Content-Type: multipart/form-data" \
-H "X-Api-Key: $DTRACK_API_KEY" \
-F "autoCreate=true" \
-F "projectName=$CI_REPO" \
-F "projectVersion=$TAG" \
-F "bom=@/tmp/sbom.xml"\
"$DTRACK_API_URL/api/v1/bom"
when:
- event: [push, tag]
dockerize:
image: plugins/kaniko
settings:
repo: ${FORGE_NAME}/${CI_REPO}
@ -15,14 +60,14 @@ steps:
- event: [push, tag]
deploy:
image: portainer/kubectl-shell:latest
secrets:
- source: kube_config
target: KUBE_CONFIG_CONTENT
- source: encryption_key
target: ENCRYPTION_KEY
- source: secrets_checksum
target: MD5_CHECKSUM
image: quay.io/wollud1969/woodpecker-helper:0.5.1
environment:
KUBE_CONFIG_CONTENT:
from_secret: kube_config
ENCRYPTION_KEY:
from_secret: encryption_key
MD5_CHECKSUM:
from_secret: secrets_checksum
commands:
- export IMAGE_TAG=$CI_COMMIT_TAG
- printf "$KUBE_CONFIG_CONTENT" > /tmp/kubeconfig

View File

@ -1,15 +1,8 @@
FROM golang:1.22.5-alpine3.20 as builder
RUN mkdir -p /go/src
COPY ./src/ /go/src
WORKDIR /go/src/udi
RUN go build -a -installsuffix nocgo -o udi main.go
FROM scratch
ENV UDI_CONF ""
COPY --from=builder /go/src/udi ./
COPY udi ./
ENTRYPOINT ["./udi"]

View File

@ -10,6 +10,7 @@ if [ "$MD5_CHECKSUM" = "" ]; then
exit 1
fi
SECRETS_CIPHERTEXT_FILE=secrets.enc
SECRETS_PLAINTEXT_FILE=/tmp/secrets
TMP_FILE=`mktemp`
@ -37,7 +38,7 @@ if [ "$MD5_CHECKSUM" != "$CALCULATED_CHECKSUM" ]; then
exit 1
fi
# cat $TMP_FILE
#cat $TMP_FILE
mv $TMP_FILE $SECRETS_PLAINTEXT_FILE

View File

@ -58,7 +58,7 @@ for NAMESPACE_DIR in `find $INSTANCES_DIR -type d -mindepth 1 -maxdepth 1`; do
NEW_UDI_DB_PASSWORD="${!PASSWORD_VARIABLE}"
DATABASE_VARIABLE=$VARIABLE_PREFIX"_PGDATABASE"
NEW_UDI_DB_DATABASE="${!DATABASE_VARIABLE}"
NEW_UDI_DB_HOST=timescaledb.database.svc.cluster.local
NEW_UDI_DB_HOST=database.database1.svc.cluster.local
kubectl create secret generic $INSTANCE-udi-db-cred \
--dry-run=client \

View File

@ -1,2 +1,2 @@
loguru==0.7.2
loguru==0.7.3
psycopg2==2.9.9

View File

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

View File

@ -41,3 +41,4 @@ create or replace view cubecell_threeway_battery_v as
from measurements
where application = 'de-hottis-saerbeck-monitoring' and
device = 'eui-70b3d57ed0068fa4';

View File

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

View File

@ -18,8 +18,8 @@ require (
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.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
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/text v0.21.0 // indirect
)

View File

@ -28,14 +28,14 @@ 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.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=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
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=

View File

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

View File

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

View File

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

View File

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

View File

@ -33,11 +33,12 @@ 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
}
func (self *SnmpHandler) Handle(message handler.MessageT) {
# log.Printf("Handler SNMP %d processing %s -> %s", self.Id, message.Topic, message.Payload)
// log.Printf("Handler SNMP %d processing %s -> %s", self.Id, message.Topic, message.Payload)
var observation observation_t
err := json.Unmarshal([]byte(message.Payload), &observation)
@ -66,7 +67,7 @@ func (self *SnmpHandler) Handle(message handler.MessageT) {
}
}
# log.Printf("Prepared measurement item: %s", measurement)
// log.Printf("Prepared measurement item: %s", measurement)
self.dbh.StoreMeasurement(&measurement)
self.S()

View File

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

View File

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

View 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
}

View File

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

View File

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