Added check for empty accessories list

This commit is contained in:
Serge Wagener 2022-03-18 08:23:38 +01:00
parent c8d117a894
commit d07d621e45

View File

@ -75,7 +75,8 @@ export class SmartHomeNGPlatform implements StaticPlatformPlugin {
// convert all configured accessory keys to lowercase to tolerate user case errors // convert all configured accessory keys to lowercase to tolerate user case errors
const accessories = JSON.parse(JSON.stringify(uncapitalizeKeys(this.config.accessories))); const accessories = JSON.parse(JSON.stringify(uncapitalizeKeys(this.config.accessories)));
this.log.debug(accessories);
if (Object.keys(accessories).length > 0) {
for (const accessory of accessories) { for (const accessory of accessories) {
if (!accessory.manufacturer) { if (!accessory.manufacturer) {
accessory.manufacturer = 'SmartHomeNG'; accessory.manufacturer = 'SmartHomeNG';
@ -167,6 +168,8 @@ export class SmartHomeNGPlatform implements StaticPlatformPlugin {
this.log.warn('Ignoring accessory (no type given): ' + accessory); this.log.warn('Ignoring accessory (no type given): ' + accessory);
} }
} }
}
callback(devices); callback(devices);
this.log.debug('Finished building accessories list'); this.log.debug('Finished building accessories list');
} }