From 5fdf76f55fcac6622b719792e48c8e46a30b776a Mon Sep 17 00:00:00 2001 From: Just Jam Date: Mon, 9 Dec 2024 14:36:27 +0000 Subject: [PATCH] Added check for duplicate UUIDs --- src/platform.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/platform.ts b/src/platform.ts index 17669c1..cba04a2 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -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); @@ -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)}`); @@ -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); } } }