Skip to content

Commit

Permalink
Prevent plugins crash when didnt find any accesory in the config
Browse files Browse the repository at this point in the history
  • Loading branch information
dwaan committed Jan 8, 2022
1 parent 9e6aa22 commit 7769cd4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 36 deletions.
26 changes: 0 additions & 26 deletions config-sample.json

This file was deleted.

22 changes: 13 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@ broadlinkPlatform.prototype = {
var foundAccessories = this.config.accessories;
var myAccessories = [];

for (var i = 0; i < foundAccessories.length; i++) {
if (foundAccessories[i].type == "MP") {
for (var a = 1; a <= 4; a++) {
foundAccessories[i].sname = "S" + a;
if(foundAccessories) {
for (var i = 0; i < foundAccessories.length; i++) {
if (foundAccessories[i].type == "MP") {
for (var a = 1; a <= 4; a++) {
foundAccessories[i].sname = "S" + a;
var accessory = new BroadlinkAccessory(this.log, foundAccessories[i]);
myAccessories.push(accessory);
this.log('Created ' + accessory.name + ' ' + accessory.sname + ' Accessory');
}
} else {
var accessory = new BroadlinkAccessory(this.log, foundAccessories[i]);
myAccessories.push(accessory);
this.log('Created ' + accessory.name + ' ' + accessory.sname + ' Accessory');
this.log('Created ' + accessory.name + ' Accessory');
}
} else {
var accessory = new BroadlinkAccessory(this.log, foundAccessories[i]);
myAccessories.push(accessory);
this.log('Created ' + accessory.name + ' Accessory');
}
} else {
this.log('No accesories found in your config");
}
callback(myAccessories);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-broadlink-platform-outlet",
"version": "0.1.5",
"version": "0.1.6",
"description": "Homebridge plugin for Broadlink SP2/3 & MP1",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 7769cd4

Please sign in to comment.