Skip to content

Commit

Permalink
Added check for duplicate UUIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
justjam2013 committed Dec 9, 2024
1 parent 9a65c2c commit 5fdf76f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ export class VirtualAccessoryPlatform implements DynamicPlatformPlugin {
configuredDevices,
): AccessoryConfiguration[] {
const accessoryConfigurations: AccessoryConfiguration[] = [];
const accessoryUUIDs: string[] = [];

for (const configuredDevice of configuredDevices) {
// Deserialize accessory configuration
const configuration: Configuration = new Configuration(this.log);
Expand All @@ -171,6 +173,9 @@ export class VirtualAccessoryPlatform implements DynamicPlatformPlugin {
if (accessoryConfiguration === undefined) {
this.log.error(`Error deserializing: ${JSON.stringify(configuredDevice)}`);
this.log.info('Skipping accessory until configuration is fixed');
} else if (accessoryUUIDs.includes(accessoryConfiguration.accessoryID)) {
this.log.error(`Found accessory with duplicate ID: ${JSON.stringify(configuredDevice)}`);
this.log.info('Skipping accessory until configuration is fixed');
} else {
this.log.debug(`Deserialized accessory: ${JSON.stringify(configuredDevice)}`);

Expand All @@ -183,6 +188,8 @@ export class VirtualAccessoryPlatform implements DynamicPlatformPlugin {
} else {
this.log.debug(`Configuration is valid: ${JSON.stringify(accessoryConfiguration)}`);
accessoryConfigurations.push(accessoryConfiguration);

accessoryUUIDs.push(accessoryConfiguration.accessoryID);
}
}
}
Expand Down

0 comments on commit 5fdf76f

Please sign in to comment.