Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/fix Decentlab devices #845

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@
"rssi",
"sap flow",
"salinity",
"size",
"smart valve",
"smoke",
"snr",
Expand Down
97 changes: 97 additions & 0 deletions vendor/decentlab/dl-cws2-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
uplinkDecoder:
fileName: dl-cws2.js
examples:
- description: Example 1
input:
fPort: 1
bytes: [0x02, 0x58, 0xc0, 0x00, 0x07, 0x46, 0x76, 0xfa, 0x0a, 0x81, 0xc9, 0x81, 0x3f, 0xa6, 0xd8, 0x81, 0x37, 0x80, 0x25, 0x81, 0x30, 0x0b, 0x91]
output:
data:
air_humidity:
displayName: Air humidity
unit: '%'
value: 99.44
air_humidity_radiation_shield:
displayName: Air humidity (radiation shield)
unit: '%'
value: 97.67299916075379
air_temperature:
displayName: Air temperature
unit: "\xB0C"
value: 3.19
air_temperature_radiation_shield:
displayName: Air temperature (radiation shield)
unit: "\xB0C"
value: 3.167391470206759
angle:
displayName: Angle
unit: "\xB0"
value: 37
battery_voltage:
displayName: Battery voltage
unit: V
value: 2.961
device_id: 22720
dew_point:
displayName: Dew point
unit: "\xB0C"
value: 3.11
protocol_version: 2
sensor_temperature:
displayName: Sensor temperature
unit: "\xB0C"
value: 3.04
surface_temperature:
displayName: Surface temperature
unit: "\xB0C"
value: 4.57
- description: Example 2
input:
fPort: 1
bytes: [0x02, 0x58, 0xc0, 0x00, 0x04, 0x0b, 0x91]
output:
data:
battery_voltage:
displayName: Battery voltage
unit: V
value: 2.961
device_id: 22720
protocol_version: 2

downlinkEncoder:
fileName: dl-downlink-codec.js
examples:
- description: Set period 3600 seconds and save
input:
data:
command: set period + save
parameter: 3600
output:
bytes: [0, 2, 14, 16, 72, 164]
fPort: 1
- description: Set ADR off
input:
data:
command: set adr off
output:
bytes: [0, 7, 0, 0, 229, 177]
fPort: 1

downlinkDecoder:
fileName: dl-downlink-codec.js
examples:
- description: Set period 600 seconds
input:
fPort: 1
bytes: [0x00, 0x01, 0x02, 0x58, 0x7E, 0x51]
output:
data:
command: set period
parameter: 600
- description: Reset
input:
fPort: 1
bytes: [0xFE, 0xFE, 0x00, 0x00, 0x3C, 0x50]
output:
data:
command: reset
109 changes: 109 additions & 0 deletions vendor/decentlab/dl-cws2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

/* https://www.decentlab.com/products/high-precision-winter-road-maintenance-sensor-with-radiation-shield-for-lorawan */

var decentlab_decoder = {
PROTOCOL_VERSION: 2,
SENSORS: [
{length: 2,
values: [{name: 'air_temperature_radiation_shield',
displayName: 'Air temperature (radiation shield)',
convert: function (x) { return 175 * x[0] / 65535 - 45; },
unit: '°C'},
{name: 'air_humidity_radiation_shield',
displayName: 'Air humidity (radiation shield)',
convert: function (x) { return 100 * x[1] / 65535; },
unit: '%'}]},
{length: 6,
values: [{name: 'surface_temperature',
displayName: 'Surface temperature',
convert: function (x) { return (x[0] - 32768) / 100; },
unit: '°C'},
{name: 'air_temperature',
displayName: 'Air temperature',
convert: function (x) { return (x[1] - 32768) / 100; },
unit: '°C'},
{name: 'air_humidity',
displayName: 'Air humidity',
convert: function (x) { return (x[2] - 32768) / 100; },
unit: '%'},
{name: 'dew_point',
displayName: 'Dew point',
convert: function (x) { return (x[3] - 32768) / 100; },
unit: '°C'},
{name: 'angle',
displayName: 'Angle',
convert: function (x) { return (x[4] - 32768); },
unit: '°'},
{name: 'sensor_temperature',
displayName: 'Sensor temperature',
convert: function (x) { return (x[5] - 32768) / 100; },
unit: '°C'}]},
{length: 1,
values: [{name: 'battery_voltage',
displayName: 'Battery voltage',
convert: function (x) { return x[0] / 1000; },
unit: 'V'}]}
],

read_int: function (bytes, pos) {
return (bytes[pos] << 8) + bytes[pos + 1];
},

decode: function (msg) {
var bytes = msg;
var i, j;
if (typeof msg === 'string') {
bytes = [];
for (i = 0; i < msg.length; i += 2) {
bytes.push(parseInt(msg.substring(i, i + 2), 16));
}
}

var version = bytes[0];
if (version != this.PROTOCOL_VERSION) {
return {error: "protocol version " + version + " doesn't match v2"};
}

var deviceId = this.read_int(bytes, 1);
var flags = this.read_int(bytes, 3);
var result = {'protocol_version': version, 'device_id': deviceId};
// decode payload
var pos = 5;
for (i = 0; i < this.SENSORS.length; i++, flags >>= 1) {
if ((flags & 1) !== 1)
continue;

var sensor = this.SENSORS[i];
var x = [];
// convert data to 16-bit integer array
for (j = 0; j < sensor.length; j++) {
x.push(this.read_int(bytes, pos));
pos += 2;
}

// decode sensor values
for (j = 0; j < sensor.values.length; j++) {
var value = sensor.values[j];
if ('convert' in value) {
result[value.name] = {displayName: value.displayName,
value: value.convert.bind(this)(x)};
if ('unit' in value)
result[value.name]['unit'] = value.unit;
}
}
}
return result;
}
};

function decodeUplink(input) {
var res = decentlab_decoder.decode(input.bytes);
if (res.error) {
return {
errors: [res.error],
};
}
return {
data: res,
};
}
Binary file added vendor/decentlab/dl-cws2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions vendor/decentlab/dl-cws2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: DL-CWS2 - High-Precision Winter Road Maintenance Sensor with Radiation Shield
description: The Decentlab DL-CWS2 includes a high-precision infrared pyrometer, temperature, humidity and dew point sensors. It is suitable for use in road weather information systems, winter road maintenance, frost alarming, ice alerting, and smart agriculture.

hardwareVersions:
- version: '1'
numeric: 1

firmwareVersions:
- version: 1.5.7
numeric: 157
hardwareVersions:
- '1'
profiles:
EU863-870:
id: profile-eu868
lorawanCertified: true
codec: dl-cws2-codec
AS923:
id: profile-as923
lorawanCertified: false
codec: dl-cws2-codec
US902-928:
id: profile-us915
lorawanCertified: true
codec: dl-cws2-codec
AU915-928:
id: profile-au915
lorawanCertified: false
codec: dl-cws2-codec

sensors:
- surface temperature
- tilt
- temperature
- humidity
- dew point
- battery

dimensions:
length: 135
width: 81
height: 70

weight: 3300

battery:
replaceable: true
type: 2 C alkaline

operatingConditions:
temperature:
min: -20
max: 50
relativeHumidity:
min: 0
max: 1.0

ipCode: IP67

keyProvisioning:
- custom
keySecurity: none

productURL: https://www.decentlab.com/high-precision-winter-road-maintenance-sensor-with-radiation-shield-for-lorawan
dataSheetURL: https://cdn.decentlab.com/download/datasheets/Decentlab-DL-CWS2-datasheet.pdf
photos:
main: dl-cws.png

compliances:
safety:
- body: IEC
norm: EN
standard: 62368-1
radioEquipment:
- body: ETSI
norm: EN
standard: 301 489-1
version: 2.2.0
- body: ETSI
norm: EN
standard: 301 489-3
version: 2.1.1
- body: ETSI
norm: EN
standard: 300 220-1
version: 3.1.1
- body: ETSI
norm: EN
standard: 300 220-2
version: 3.1.1
- body: IEC
norm: EN
standard: 62479:2010
2 changes: 1 addition & 1 deletion vendor/decentlab/dl-dws.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: DL-DWS - Weighing Scale
description: The Decentlab DL-DWS is a WEIGHING SCALE FOR LoRaWAN® that comes with a vibrating wire for weight sensor. Suitable for applications such as logistics, inventory, and weighing.
description: The Decentlab DL-DWS is a weighing scale for LoRaWAN® that comes with a 'vibrating wire for weight' sensor. Suitable for applications such as logistics, inventory, and weighing.

hardwareVersions:
- version: '1'
Expand Down
69 changes: 69 additions & 0 deletions vendor/decentlab/dl-ifd-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
uplinkDecoder:
fileName: dl-ifd.js
examples:
- description: Example 1
input:
fPort: 1
bytes: [0x02, 0x56, 0xdc, 0x00, 0x03, 0x02, 0xbc, 0x0c, 0x48]
output:
data:
battery_voltage:
displayName: Battery voltage
unit: V
value: 3.144
device_id: 22236
fruit_size:
displayName: Fruit size
unit: mm
value: 7
protocol_version: 2
- description: Example 2
input:
fPort: 1
bytes: [0x02, 0x56, 0xdc, 0x00, 0x02, 0x0c, 0x48]
output:
data:
battery_voltage:
displayName: Battery voltage
unit: V
value: 3.144
device_id: 22236
protocol_version: 2

downlinkEncoder:
fileName: dl-downlink-codec.js
examples:
- description: Set period 3600 seconds and save
input:
data:
command: set period + save
parameter: 3600
output:
bytes: [0, 2, 14, 16, 72, 164]
fPort: 1
- description: Set ADR off
input:
data:
command: set adr off
output:
bytes: [0, 7, 0, 0, 229, 177]
fPort: 1

downlinkDecoder:
fileName: dl-downlink-codec.js
examples:
- description: Set period 600 seconds
input:
fPort: 1
bytes: [0x00, 0x01, 0x02, 0x58, 0x7E, 0x51]
output:
data:
command: set period
parameter: 600
- description: Reset
input:
fPort: 1
bytes: [0xFE, 0xFE, 0x00, 0x00, 0x3C, 0x50]
output:
data:
command: reset
Loading
Loading