Skip to content

Commit 11b8fd9

Browse files
authored
Update LHT65N.js
1 parent 8015bbb commit 11b8fd9

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

LoRaWAN/decoders/Dragino/LHT65N.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,29 @@ function decodeUplink(input) {
1616
switch (input.fPort) {
1717
case 2:
1818
if (Ext == 0x09) {
19-
data.TempC_DS = parseFloat(((((bytes[0] << 24) >> 16) | bytes[1]) / 100).toFixed(2));
19+
data.TempC_External = parseFloat(((((bytes[0] << 24) >> 16) | bytes[1]) / 100).toFixed(2));
2020
data.Bat_status = bytes[4] >> 6;
2121
} else {
2222
data.BatV = (((bytes[0] << 8) | bytes[1]) & 0x3fff) / 1000;
2323
data.Bat_status = bytes[0] >> 6;
2424
}
25+
switch (data.Bat_status) {
26+
case 0:
27+
data.Bat_level = "Very low";
28+
break;
29+
case 1:
30+
data.Bat_level = "Low";
31+
break;
32+
case 2:
33+
data.Bat_level = "OK";
34+
break;
35+
default:
36+
data.Bat_level = "Good";
37+
}
2538

2639
if (Ext != 0x0f) {
27-
data.TempC_SHT = parseFloat(((((bytes[2] << 24) >> 16) | bytes[3]) / 100).toFixed(2));
28-
data.Hum_SHT = parseFloat(((((bytes[4] << 8) | bytes[5]) & 0xfff) / 10).toFixed(1));
40+
data.TempC_Internal = parseFloat(((((bytes[2] << 24) >> 16) | bytes[3]) / 100).toFixed(2));
41+
data.Hum_Internal = parseFloat(((((bytes[4] << 8) | bytes[5]) & 0xfff) / 10).toFixed(1));
2942
}
3043
if (Connect == '1') {
3144
data.No_connect = 'Sensor no connection';
@@ -35,7 +48,7 @@ function decodeUplink(input) {
3548
data.Ext_sensor = 'No external sensor';
3649
} else if (Ext == '1') {
3750
data.Ext_sensor = 'Temperature Sensor';
38-
data.TempC_DS = parseFloat(((((bytes[7] << 24) >> 16) | bytes[8]) / 100).toFixed(2));
51+
data.TempC_External = parseFloat(((((bytes[7] << 24) >> 16) | bytes[8]) / 100).toFixed(2));
3952
} else if (Ext == '4') {
4053
data.Work_mode = 'Interrupt Sensor send';
4154
data.Exti_pin_level = bytes[7] ? 'High' : 'Low';
@@ -78,21 +91,21 @@ function decodeUplink(input) {
7891
function normalizeUplink(input) {
7992
var data = [];
8093

81-
if (input.data.TempC_SHT) {
94+
if (input.data.TempC_Internal) {
8295
data.push({
8396
air: {
8497
location: 'indoor',
85-
temperature: input.data.TempC_SHT,
86-
relativeHumidity: input.data.Hum_SHT,
98+
temperature: input.data.TempC_Internal,
99+
relativeHumidity: input.data.Hum_Internal,
87100
},
88101
});
89102
}
90103

91-
if (input.data.TempC_DS) {
104+
if (input.data.TempC_External) {
92105
var val = {
93106
air: {
94107
location: 'outdoor',
95-
temperature: input.data.TempC_DS,
108+
temperature: input.data.TempC_External,
96109
},
97110
};
98111
if (input.data.BatV) {

0 commit comments

Comments
 (0)