Skip to content

Commit

Permalink
Simplified device discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
lprhodes committed Mar 22, 2018
1 parent 18303be commit 45d6106
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
15 changes: 1 addition & 14 deletions helpers/getDevice.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,8 @@ const manualDevices = {};

let discovering = false;

const discoverDevices = (count = 0) => {
discovering = true;

if (count >= 5) {
discovering = false;

return;
}

const discoverDevices = () => {
broadlink.discover();
count++;

setTimeout(() => {
discoverDevices(count);
}, 5 * 1000)
}

broadlink.on('deviceReady', (device) => {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ module.exports = (homebridge) => {

homebridge.registerPlatform("homebridge-broadlink-rm", "BroadlinkRM", BroadlinkRMPlatform);

discoverDevices();
discoverDevices(0, true);
}

0 comments on commit 45d6106

Please sign in to comment.