From 9b374eeddb88414bd32be40abb273f81f5f6fb82 Mon Sep 17 00:00:00 2001 From: Peter Eriksson Date: Fri, 20 Sep 2024 10:43:37 +0200 Subject: [PATCH] Altered the data structure of normalized output --- lib/payload.json | 2 +- vendor/quandify/cubicmeter-1-1-uplink.js | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/payload.json b/lib/payload.json index e13714211e..7971c43742 100644 --- a/lib/payload.json +++ b/lib/payload.json @@ -152,7 +152,7 @@ "type": "object", "properties": { "leak": { - "type": "boolean", + "type": ["boolean", "string"], "description": "Leak detected" } }, diff --git a/vendor/quandify/cubicmeter-1-1-uplink.js b/vendor/quandify/cubicmeter-1-1-uplink.js index f1c87454db..e933ccb4c2 100644 --- a/vendor/quandify/cubicmeter-1-1-uplink.js +++ b/vendor/quandify/cubicmeter-1-1-uplink.js @@ -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), @@ -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), }; }