Skip to content

Commit

Permalink
Ignore zigbee model casing. Koenkk#518
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Jul 15, 2019
1 parent d967f82 commit ab1ff3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const fromZigbee = require('./converters/fromZigbee');
const byZigbeeModel = new Map();
for (const device of devices) {
for (const zigbeeModel of device.zigbeeModel) {
byZigbeeModel.set(zigbeeModel, device);
byZigbeeModel.set(zigbeeModel.toLowerCase(), device);
}
}

Expand All @@ -18,6 +18,8 @@ module.exports = {
return null;
}

model = model.toLowerCase();

let device = byZigbeeModel.get(model);

if (!device) {
Expand Down
4 changes: 2 additions & 2 deletions test/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ devices.forEach((device) => {

// Check for duplicate zigbee model ids
device.zigbeeModel.forEach((m) => {
if (foundZigbeeModels.includes(m)) {
if (foundZigbeeModels.includes(m.toLowerCase())) {
assert.fail(`Duplicate zigbee model ${m}`);
}
});

// Check for duplicate model ids
assert(!foundModels.includes(device.model), `Duplicate model ${device.model}`);

foundZigbeeModels = foundZigbeeModels.concat(device.zigbeeModel);
foundZigbeeModels = foundZigbeeModels.concat(device.zigbeeModel.map((z) => z.toLowerCase()));
foundModels.push(device.model);
});

0 comments on commit ab1ff3c

Please sign in to comment.