Skip to content

Commit

Permalink
Extend normalized payload (#800)
Browse files Browse the repository at this point in the history
* GN & tbms100

* add status

* add em300-th

* add lht65

* add lsn50-v2

* add ws301

* add ers

* add tbdw100

* change battVolt & add elsys, dragino

* add vicki

* add lw001-bgpro beginning

* add to lw001-bgpro

* add laird

* add strips

* add tektelic

* add lwl03a & change status

* align all devices same format

* update decodeUplink

* rename doorStatus & add ers-co2

* update lwl03a

* add feedback

* change motion to object

* motion fixes

* air location

* change to contactState

* Close to closed

* add ternary operator

* Update door state once more

* revert air to object

---------

Co-authored-by: Johan Stokking <[email protected]>
  • Loading branch information
LDannijs and johanstokking authored Sep 17, 2024
1 parent 473777a commit 76f4658
Show file tree
Hide file tree
Showing 42 changed files with 1,049 additions and 56 deletions.
59 changes: 59 additions & 0 deletions lib/payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
"format": "date-time",
"description": "Date and time of the measurement (RFC3339)"
},
"battery": {
"type": "number",
"description": "Voltage (V)",
"minimum": 0
},
"soil": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -99,6 +104,11 @@
"air": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": ["indoor", "outdoor"],
"description": "Specifies whether the measurement was taken indoors or outdoors."
},
"temperature": {
"description": "Air temperature (°C)",
"$ref": "#/definitions/temperature"
Expand Down Expand Up @@ -137,6 +147,55 @@
}
},
"additionalProperties": false
},
"water": {
"type": "object",
"properties": {
"leak": {
"type": "boolean",
"description": "Leak detected"
}
},
"additionalProperties": false
},
"action": {
"type": "object",
"properties": {
"motion": {
"type": "object",
"properties": {
"detected": {
"type": "boolean",
"description": "Motion detected"
},
"count": {
"type": "number",
"description": "Number of motion events (count)"
}
},
"additionalProperties": false
},
"contactState": {
"type": "string",
"description": "State of a contact sensor",
"enum": ["OPEN", "CLOSED"]
}
},
"additionalProperties": false
},
"position": {
"type": "object",
"properties": {
"latitude": {
"type": "number",
"description": "Horizontal distance from equator (°)"
},
"longitude": {
"type": "number",
"description": "Vertical distance from prime meridian (°)"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down
8 changes: 8 additions & 0 deletions vendor/browan/tbdw100-codec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ uplinkDecoder:
status: 0
temperatureBoard: 21
time: 0
normalizedOutput:
data:
- action:
motion:
detected: false
air:
temperature: 21
battery: 3.6
- description: Unknown FPort
input:
fPort: 42
Expand Down
16 changes: 16 additions & 0 deletions vendor/browan/tbdw100.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,19 @@ function decodeUplink(input) {
};
}
}

function normalizeUplink(input) {
return {
data: {
action: {
motion: {
detected: input.data.status > 0,
}
},
air: {
temperature: input.data.temperatureBoard,
},
battery: input.data.battery,
}
};
}
8 changes: 8 additions & 0 deletions vendor/browan/tbms100-codec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ uplinkDecoder:
status: 1
temperatureBoard: 20
time: 4
normalizedOutput:
data:
- action:
motion:
detected: true
air:
temperature: 20
battery: 3.6
- description: Unknown FPort
input:
fPort: 42
Expand Down
16 changes: 16 additions & 0 deletions vendor/browan/tbms100.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,19 @@ function decodeUplink(input) {
};
}
}

function normalizeUplink(input) {
return {
data: {
action: {
motion: {
detected: input.data.status > 0,
}
},
air: {
temperature: input.data.temperatureBoard,
},
battery: input.data.battery,
},
};
}
1 change: 1 addition & 0 deletions vendor/dragino/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ endDevices:
- sw3l
- lht52
- trackerd
- lwl03a
19 changes: 19 additions & 0 deletions vendor/dragino/lht52-codec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@ uplinkDecoder:
bytes: [0x0B, 0x88, 0x01, 0x00, 0x25, 0x00, 0x01]
output:
data: { 'Bat_mV': 1, 'Firmware_Version': '8801', 'Freq_Band': 0, 'Sensor_Model': 11, 'Sub_Band': 37 }
normalizedOutput:
data:
- battery: 1

- description: Temperature & Humidity
input:
fPort: 2
bytes: [0x08, 0xCD, 0x02, 0x20, 0x7F, 0xFF, 0x01, 0x61, 0xCD, 0x4E, 0xDD]
output:
data: { 'Ext': 1, 'Hum_SHT': 54.4, 'Systimestamp': 1640845021, 'TempC_DS': 327.67, 'TempC_SHT': 22.53 }
normalizedOutput:
data:
- air:
location: 'indoor'
temperature: 22.53
relativeHumidity: 54.4
- air:
location: 'outdoor'
temperature: 327.67

- description: Unknown FPort
input:
Expand Down
33 changes: 32 additions & 1 deletion vendor/dragino/lht52.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,35 @@ function decodeUplink(input) {
errors: ["unknown FPort"]
}
}
}
}

function normalizeUplink(input) {
var data = [];

if (input.data.TempC_SHT) {
data.push({
air: {
location: "indoor",
temperature: input.data.TempC_SHT,
relativeHumidity: input.data.Hum_SHT,
}
});
}

if (input.data.TempC_DS) {
data.push({
air: {
location: "outdoor",
temperature: input.data.TempC_DS
}
});
}

if (input.data.Bat_mV) {
data.push({
battery: input.data.Bat_mV
});
}

return { data: data };
}
10 changes: 10 additions & 0 deletions vendor/dragino/lht65-codec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ uplinkDecoder:
bytes: [0xCB, 0xF6, 0x0B, 0x0D, 0x03, 0x76, 0x01, 0x0A, 0xDD, 0x7F, 0xFF]
output:
data: { 'BatV': 3.062, 'Bat_status': 3, 'Ext_sensor': 'Temperature Sensor', 'Hum_SHT': 88.6, 'TempC_DS': 27.81, 'TempC_SHT': 28.29 }
normalizedOutput:
data:
- air:
location: 'indoor'
temperature: 28.29
relativeHumidity: 88.6
- air:
location: 'outdoor'
temperature: 27.81
battery: 3.062

- description: Unknown FPort
input:
Expand Down
23 changes: 22 additions & 1 deletion vendor/dragino/lht65.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,25 @@ default:

}

}
}

function normalizeUplink(input) {
return {
data: [
{
air: {
location: "indoor",
temperature: input.data.TempC_SHT,
relativeHumidity: input.data.Hum_SHT,
}
},
{
air: {
location: "outdoor",
temperature: input.data.TempC_DS,
},
battery: input.data.BatV
}
]
};
}
10 changes: 9 additions & 1 deletion vendor/dragino/lse01-codec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ uplinkDecoder:
bytes: [0xCE, 0x29, 0x00, 0xF1, 0x07, 0xA5, 0x09, 0x9B, 0x6E, 0x28, 0x90]
output:
data: { 'Bat': 3.625, 'TempC_DS18B20': '24.1', 'conduct_SOIL': 28200, 'temp_SOIL': '24.59', 'water_SOIL': '19.57' }

normalizedOutput:
data:
- air:
temperature: 24.1
soil:
temperature: 24.59
moisture: 19.57
ec: 28.2
battery: 3.625
- description: Unknown FPort
input:
fPort: 42
Expand Down
18 changes: 17 additions & 1 deletion vendor/dragino/lse01.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,20 @@ switch (input.fPort) {
errors: ["unknown FPort"]
}
}
}
}

function normalizeUplink(input) {
return {
data: {
air: {
temperature: Number(input.data.TempC_DS18B20),
},
soil: {
temperature: Number(input.data.temp_SOIL),
moisture: Number(input.data.water_SOIL),
ec: input.data.conduct_SOIL / 1000,
},
battery: input.data.Bat,
}
};
}
8 changes: 8 additions & 0 deletions vendor/dragino/lsn50-v2-codec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ uplinkDecoder:
bytes: [0x0B, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x02, 0x05]
output:
data: { 'ADC_CH0V': 0, 'BatV': 2.9, 'Digital_IStatus': 'L', 'Door_status': 'OPEN', 'EXTI_Trigger': 'FALSE', 'Hum_SHT': 51.7, 'TempC1': 0, 'TempC_SHT': 25.2, 'Work_mode': 'IIC' }
normalizedOutput:
data:
- air:
temperature: 25.2
relativeHumidity: 51.7
action:
contactState: 'OPEN'
battery: 2.9

- description: Unknown FPort
input:
Expand Down
17 changes: 16 additions & 1 deletion vendor/dragino/lsn50-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,19 @@ default:
errors: ["unknown FPort"]
}
}
}
}

function normalizeUplink(input) {
return {
data: {
air: {
temperature: input.data.TempC_SHT,
relativeHumidity: input.data.Hum_SHT,
},
action: {
contactState: input.data.Door_status === "CLOSE" ? "CLOSED" : input.data.Door_status === "OPEN" ? "OPEN" : undefined
},
battery: input.data.BatV,
}
};
}
9 changes: 8 additions & 1 deletion vendor/dragino/lsn50v2-s31-codec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ uplinkDecoder:
bytes: [0x0B, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x02, 0x05]
output:
data: { 'ADC_CH0V': 0, 'BatV': 2.9, 'Digital_IStatus': 'L', 'Door_status': 'OPEN', 'EXTI_Trigger': 'FALSE', 'Hum_SHT': 51.7, 'TempC1': 0, 'TempC_SHT': 25.2, 'Work_mode': 'IIC' }

normalizedOutput:
data:
- air:
temperature: 25.2
relativeHumidity: 51.7
action:
contactState: 'OPEN'
battery: 2.9
- description: Unknown FPort
input:
fPort: 42
Expand Down
17 changes: 16 additions & 1 deletion vendor/dragino/lsn50v2-s31.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,19 @@ default:
errors: ["unknown FPort"]
}
}
}
}

function normalizeUplink(input) {
return {
data: {
air: {
temperature: input.data.TempC_SHT,
relativeHumidity: input.data.Hum_SHT
},
action: {
contactState: input.data.Door_status === "CLOSE" ? "CLOSED" : input.data.Door_status === "OPEN" ? "OPEN" : undefined
},
battery: input.data.BatV,
}
};
}
13 changes: 13 additions & 0 deletions vendor/dragino/lwl03a-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
uplinkDecoder:
fileName: lwl03a.js
examples:
- description: Distance Detection
input:
fPort: 2
bytes: [0x01, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x0A, 0x63, 0x5C, 0xD2, 0xF2]
output:
data: { 'TDC': 'NO', 'ALARM': 'FALSE', 'WATER_LEAK_STATUS': 'LEAK', 'WATER_LEAK_TIMES': 10, 'LAST_WATER_LEAK_DURATION': 10, 'TIME': '2022-10-29 07:14:58' }
normalizedOutput:
data:
- water:
leak: true
Loading

0 comments on commit 76f4658

Please sign in to comment.