Better battery status parsing.

This commit is contained in:
Koen Kanters
2018-04-15 01:26:04 +02:00
parent 8356fda183
commit fa61d17f0b
+10 -5
View File
@@ -29,11 +29,16 @@ const parsers = [
cid: 'genBasic',
attribute: true,
parse: (msg, publish) => {
if (msg.data.data['65282']) {
const voltage = msg.data.data['65282']['1'].elmVal;
if (voltage) {
return {battery: toPercentage(voltage, battery.min, battery.max)}
}
let voltage = null;
if (msg.data.data['65281']) {
voltage = msg.data.data['65281']['1'];
} else if (msg.data.data['65282']) {
voltage = msg.data.data['65282']['1'].elmVal;
}
if (voltage) {
return {battery: toPercentage(voltage, battery.min, battery.max)}
}
}
},