From ad34f9b27b72e141859b3aeeb059c1f03ff18fcd Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Thu, 7 Dec 2023 15:14:22 +0100 Subject: [PATCH] confgi --- .gitignore | 1 - queries/hottis.sql | 8 +++ src/udi/config-iot-cluster.json | 105 ++++++++++++++++++++++++++++++ src/udi/config-iot.json | 105 ++++++++++++++++++++++++++++++ src/udi/config-iot2.json | 25 +++++++ src/udi/config-ttn.json | 29 +++++++++ src/udi/handlers/ttn/example.json | 84 ++++++++++++++++++++++++ 7 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 src/udi/config-iot-cluster.json create mode 100644 src/udi/config-iot.json create mode 100644 src/udi/config-iot2.json create mode 100644 src/udi/config-ttn.json create mode 100644 src/udi/handlers/ttn/example.json diff --git a/.gitignore b/.gitignore index 2e962ac..c87032e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -config-*.json src/udi/udi src/udi/migrate_schema tmp/ diff --git a/queries/hottis.sql b/queries/hottis.sql index 7021bd7..8190389 100644 --- a/queries/hottis.sql +++ b/queries/hottis.sql @@ -37,3 +37,11 @@ create or replace view gas_v as from measurements where application = 'Gas' and attributes->>'Status' = 'Ok'; + +create or replace view temperature_v as + select time, + cast(values->'Value'->>'value' as float) as temperature, + device + from measurements + where application in ('Temperature Multisensor', 'Temperature Shelly Plus HT'); + diff --git a/src/udi/config-iot-cluster.json b/src/udi/config-iot-cluster.json new file mode 100644 index 0000000..faa9593 --- /dev/null +++ b/src/udi/config-iot-cluster.json @@ -0,0 +1,105 @@ +{ + "mqtt": { + "broker": "mqtt://emqx01-anonymous-cluster-internal.broker.svc.cluster.local:1883", + "tlsEnable": "false" + }, + "topicMappings": [ + { + "topics": [ "IoT/PV/Values" ], + "handler": "PV", + "id": "PV", + "config": { + "databaseConnStr": "", + "attributes": { + } + } + }, + { + "topics": [ "IoT/MBGW3/Measurement" ], + "handler": "MBGW3", + "id": "MBGW3", + "config": { + "databaseConnStr": "", + "attributes": { + } + } + }, + { + "topics": [ "IoT/OneWireGW/Bus 1/#" ], + "handler": "SVER", + "id": "SVER0", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Temperature Heating", + "payloadRegex": "(\\d+(\\.\\d+)?)\\s*([^0-9\\s]\\S*)", + "deviceFrom": "topic", + "devicePart": "3", + "valueFrom": "payload", + "valuePart": "1", + "unitFrom": "payload", + "unitPart": "3" + } + } + }, + { + "topics": [ "NR/Multisensor/+/Temperatur" ], + "handler": "SVEJ", + "id": "SVEJ0", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Temperature Multisensor", + "deviceSelector": "T:2", + "valueSelector": "J:$.CurrentTemperature", + "unitSelector": "C:°C" + } + } + }, + { + "topics": [ "NR/Multisensor/+/Feuchte" ], + "handler": "SVEJ", + "id": "SVEJ1", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Humidity Multisensor", + "deviceSelector": "T:2", + "valueSelector": "J:$.CurrentRelativeHumidity", + "unitSelector": "C:%" + } + } + }, + { + "topics": [ "shellyplusht/+/status/temperature:0" ], + "handler": "SVEJ", + "id": "SVEJ2", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Temperature Shelly Plus HT", + "deviceSelector": "T:1", + "valueSelector": "J:$.tC", + "unitSelector": "C:°C" + } + } + }, + { + "topics": [ "shellyplusht/+/status/humidity:0" ], + "handler": "SVEJ", + "id": "SVE4", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Humidity Shelly Plus HT", + "deviceSelector": "T:1", + "valueSelector": "J:$.rh", + "unitSelector": "C:%" + } + } + } + ], + "archiver": { + "dir": "/archive" + } +} diff --git a/src/udi/config-iot.json b/src/udi/config-iot.json new file mode 100644 index 0000000..ddbf5b1 --- /dev/null +++ b/src/udi/config-iot.json @@ -0,0 +1,105 @@ +{ + "mqtt": { + "broker": "mqtt://172.23.1.102:1883", + "tlsEnable": "false" + }, + "topicMappings": [ + { + "topics": [ "IoT/PV/Values" ], + "handler": "PV", + "id": "PV", + "config": { + "databaseConnStr": "", + "attributes": { + } + } + }, + { + "topics": [ "IoT/MBGW3/Measurement" ], + "handler": "MBGW3", + "id": "MBGW3", + "config": { + "databaseConnStr": "", + "attributes": { + } + } + }, + { + "topics": [ "IoT/OneWireGW/Bus 1/#" ], + "handler": "SVER", + "id": "SVER0", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Temperature Heating", + "payloadRegex": "(\\d+(\\.\\d+)?)\\s*([^0-9\\s]\\S*)", + "deviceFrom": "topic", + "devicePart": "3", + "valueFrom": "payload", + "valuePart": "1", + "unitFrom": "payload", + "unitPart": "3" + } + } + }, + { + "topics": [ "NR/Multisensor/+/Temperatur" ], + "handler": "SVEJ", + "id": "SVEJ0", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Temperature Multisensor", + "deviceSelector": "T:2", + "valueSelector": "J:$.CurrentTemperature", + "unitSelector": "C:°C" + } + } + }, + { + "topics": [ "NR/Multisensor/+/Feuchte" ], + "handler": "SVEJ", + "id": "SVEJ1", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Humidity Multisensor", + "deviceSelector": "T:2", + "valueSelector": "J:$.CurrentRelativeHumidity", + "unitSelector": "C:%" + } + } + }, + { + "topics": [ "shellyplusht/+/status/temperature:0" ], + "handler": "SVEJ", + "id": "SVEJ2", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Temperature Shelly Plus HT", + "deviceSelector": "T:1", + "valueSelector": "J:$.tC", + "unitSelector": "C:°C" + } + } + }, + { + "topics": [ "shellyplusht/+/status/humidity:0" ], + "handler": "SVEJ", + "id": "SVE4", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Humidity Shelly Plus HT", + "deviceSelector": "T:1", + "valueSelector": "J:$.rh", + "unitSelector": "C:%" + } + } + } + ], + "archiver": { + "dir": "./tmp/udi" + } +} diff --git a/src/udi/config-iot2.json b/src/udi/config-iot2.json new file mode 100644 index 0000000..6acca73 --- /dev/null +++ b/src/udi/config-iot2.json @@ -0,0 +1,25 @@ +{ + "mqtt": { + "broker": "mqtt://172.23.1.102:1883", + "tlsEnable": "false" + }, + "topicMappings": [ + { + "topics": [ "shellyplusht/+/status/temperature:0" ], + "handler": "SVEJ", + "id": "SVE3", + "config": { + "databaseConnStr": "", + "attributes": { + "application": "Temperature Shelly Plus HT", + "deviceSelector": "T:1", + "valueSelector": "J:$.tC", + "unitSelector": "C:°C" + } + } + } + ], + "archiver": { + "dir": "./tmp/udi" + } +} diff --git a/src/udi/config-ttn.json b/src/udi/config-ttn.json new file mode 100644 index 0000000..66f2a9e --- /dev/null +++ b/src/udi/config-ttn.json @@ -0,0 +1,29 @@ +{ + "mqtt": { + "broker": "mqtt://172.23.1.102:1883", + "tlsEnable": "false" + }, + "topicMappings": [ + { + "topics": [ "v3/de-hottis-level-monitoring@ttn/devices/+/up" ], + "handler": "TTN" + } + ], + "handlers": [ + { + "name": "TTN", + "databaseConnStr": "", + "attributes": { + } + }, + { + "name": "IoT", + "databaseConnStr": "", + "attributes": { + } + } + ], + "archiver": { + "dir": "./tmp/udi" + } +} diff --git a/src/udi/handlers/ttn/example.json b/src/udi/handlers/ttn/example.json new file mode 100644 index 0000000..691008a --- /dev/null +++ b/src/udi/handlers/ttn/example.json @@ -0,0 +1,84 @@ +{ + "end_device_ids": { + "device_id": "eui-a840419641867eb5", + "application_ids": { + "application_id": "de-hottis-level-monitoring" + }, + "dev_eui": "A840419641867EB5", + "join_eui": "A840410000000101", + "dev_addr": "260B91F9" + }, + "correlation_ids": [ + "gs:uplink:01HH1R112BNDQQ52N9FVV0TKPW" + ], + "received_at": "2023-12-07T08:59:05.369293395Z", + "uplink_message": { + "session_key_id": "AYa9JUhNJp00t+hKqkQUog==", + "f_port": 2, + "f_cnt": 25665, + "frm_payload": "DAoAaQDJAA==", + "decoded_payload": { + "Bat": 3.082, + "DALARM_count": 0, + "Distance_alarm": 0, + "Interrupt_alarm": 0, + "dis1": 105, + "dis2": 201 + }, + "rx_metadata": [ + { + "gateway_ids": { + "gateway_id": "eui-00005813d35e3021", + "eui": "00005813D35E3021" + }, + "timestamp": 1141271036, + "rssi": -100, + "channel_rssi": -100, + "snr": 7.3, + "location": { + "latitude": 52.17065267448476, + "longitude": 7.629437184774199, + "source": "SOURCE_REGISTRY" + }, + "uplink_token": "CiIKIAoUZXVpLTAwMDA1ODEzZDM1ZTMwMjESCAAAWBPTXjAhEPzTmaAEGgsI2ZLGqwYQnfLnTSDggLjIm5IF", + "channel_index": 6, + "received_at": "2023-12-07T08:59:05.163182877Z" + } + ], + "settings": { + "data_rate": { + "lora": { + "bandwidth": 125000, + "spreading_factor": 7, + "coding_rate": "4/5" + } + }, + "frequency": "868300000", + "timestamp": 1141271036 + }, + "received_at": "2023-12-07T08:59:05.163964824Z", + "consumed_airtime": "0.056576s", + "locations": { + "user": { + "latitude": 52.1707216912195, + "longitude": 7.63066603211241, + "altitude": 39, + "source": "SOURCE_REGISTRY" + } + }, + "version_ids": { + "brand_id": "dragino", + "model_id": "lmds200", + "hardware_version": "_unknown_hw_version_", + "firmware_version": "1.0", + "band_id": "EU_863_870" + }, + "network_ids": { + "net_id": "000013", + "ns_id": "EC656E0000000181", + "tenant_id": "ttn", + "cluster_id": "eu1", + "cluster_address": "eu1.cloud.thethings.network" + } + } +}