Skip to content

Commit

Permalink
Altered the data structure of normalized output
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-quandify committed Sep 20, 2024
1 parent 3a4de2b commit 9b374ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"type": "object",
"properties": {
"leak": {
"type": "boolean",
"type": ["boolean", "string"],
"description": "Leak detected"
}
},
Expand Down
11 changes: 6 additions & 5 deletions vendor/quandify/cubicmeter-1-1-uplink.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function decodeUplink(input) {

return {
data: {
fport: input.fPort,
fPort: input.fPort,
length: input.bytes.length,
hexBytes: toHexString(input.bytes),
type: getPacketType(input.fPort),
Expand Down Expand Up @@ -118,14 +118,15 @@ function normalizeUplink(input) {
min: input.data.decoded.waterTemperatureMin, // °C
max: input.data.decoded.waterTemperatureMax, // °C
},
leak: input.data.decoded.leak_state > 2, // Boolean
volume: {
leak: parseLeakState(input.data.decoded.leak_state), // String
},
metering: {
water: {
total: input.data.decoded.totalVolume, // L
},
},
battery: input.data.decoded.batteryRecovered / 1000, // V
},
warnings: [parseBatteryStatus(input.data.decoded.batteryRecovered), parseLeakState(input.data.decoded.leak_state)].filter((item) => item),
errors: [parseErrorCode(input.data.decoded.errorCode)].filter((item) => item),
warnings: [parseErrorCode(input.data.decoded.errorCode), parseBatteryStatus(input.data.decoded.batteryRecovered)].filter((item) => item),
};
}

0 comments on commit 9b374ee

Please sign in to comment.