Skip to content

Commit

Permalink
mappedModel is null
Browse files Browse the repository at this point in the history
  • Loading branch information
arteck authored Aug 4, 2023
1 parent c683333 commit 91bad2e
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,29 +469,33 @@ class Zigbee extends utils.Adapter {

let voltage = 0;
let battKey = false;

if (mappedModel.meta !== undefined && mappedModel.meta !== null && mappedModel.meta.battery !== undefined) {
const isVoltage = entity.mapped.meta.battery.hasOwnProperty('voltageToPercentage');

if (isVoltage) {
const keys = Object.keys(message.data);

for (const key of keys) {
const value = message.data[key];

this.log.debug(`--> BatteryValue ${safeJsonStringify(value)} from battery search`);

if (value != undefined && value[1] != undefined) {
if (key == 65282 && value[1][1] != undefined) {
voltage = value[1][1].elmVal;
battKey = true;
break;

if (mappedModel != null && mappedModel != undefined) {
if (mappedModel.meta !== undefined && mappedModel.meta !== null) {
if (mappedModel.meta.battery !== undefined) {
const isVoltage = entity.mapped.meta.battery.hasOwnProperty('voltageToPercentage');

if (isVoltage) {
const keys = Object.keys(message.data);

for (const key of keys) {
const value = message.data[key];

this.log.debug(`--> BatteryValue ${safeJsonStringify(value)} from battery search`);

if (value != undefined && value[1] != undefined) {
if (key == 65282 && value[1][1] != undefined) {
voltage = value[1][1].elmVal;
battKey = true;
break;
}
if (key == 65281) {
voltage = value[1];
battKey = true;
break;
}
}
}
if (key == 65281) {
voltage = value[1];
battKey = true;
break;
}
}
}
}
Expand Down

0 comments on commit 91bad2e

Please sign in to comment.