Skip to content

Commit

Permalink
Fix registration of new devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
BewhiskeredBard committed Feb 10, 2020
1 parent ca0aedc commit 6d0120d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/scoutPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,19 @@ export class ScoutPlatform implements Platform {
this.cachedAccessories.delete(accessory.UUID);
} else {
this.homebridge.logger.info(`Creating new accessory [${accessory.UUID}].`);

newAccessories.push(accessory);
}

accessoryFactory.configureAccessory(accessory);
}
}

this.homebridge.logger.info(`Registering new accessories [${[...this.cachedAccessories.values()].join(", ")}].`);
this.homebridge.logger.info(`Registering new accessories [${[...newAccessories.map(accessory => accessory.UUID)].join(", ")}].`);

this.homebridge.api.registerPlatformAccessories(ScoutPlatform.PLUGIN_NAME, ScoutPlatform.PLATFORM_NAME, newAccessories);

this.homebridge.logger.info(`Removing old cached accessories [${[...this.cachedAccessories.values()].join(", ")}].`);
this.homebridge.logger.info(`Removing old cached accessories [${[...this.cachedAccessories.keys()].join(", ")}].`);

this.homebridge.api.unregisterPlatformAccessories(ScoutPlatform.PLUGIN_NAME, ScoutPlatform.PLATFORM_NAME, [...this.cachedAccessories.values()]);

Expand Down

0 comments on commit 6d0120d

Please sign in to comment.