From db91c543dac8a4f8972c405947197fa91976152a Mon Sep 17 00:00:00 2001 From: kyleboyer Date: Wed, 31 Jul 2024 22:11:01 -0500 Subject: [PATCH] Format and compare MAC Address the same across config vs discovery --- package-lock.json | 4 ++-- package.json | 2 +- src/platform.ts | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 27c3f66..c1eb218 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebridge-blaq", - "version": "0.2.24", + "version": "0.2.25", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "homebridge-blaq", - "version": "0.2.24", + "version": "0.2.25", "funding": [ { "type": "github", diff --git a/package.json b/package.json index ffc37ab..b93bfc8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "private": false, "displayName": "Konnected BlaQ", "name": "homebridge-blaq", - "version": "0.2.24", + "version": "0.2.25", "description": "Control and view your garage door(s) remotely with real-time updates using Konnected's BlaQ hardware", "license": "Apache-2.0", "type": "module", diff --git a/src/platform.ts b/src/platform.ts index c2a60d2..d2c0e47 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -56,13 +56,14 @@ export class BlaQHomebridgePluginPlatform implements DynamicPlatformPlugin { } getDeviceKey(device: ConfigDevice) { - if(device.mac && this.hubs[device.mac]) { - return device.mac; + const correctedMAC = formatMAC(device.mac); + if(correctedMAC && this.hubs[correctedMAC]) { + return correctedMAC; } if(this.hubs[device.host]) { return device.host; } - return device.mac || device.host; + return correctedMAC || device.host; } possiblyRegisterNewDevice(device: ConfigDevice){ @@ -119,9 +120,9 @@ export class BlaQHomebridgePluginPlatform implements DynamicPlatformPlugin { accessory: PlatformAccessory; } { this.logger.info(`Running registerDiscovered callback for ${model} #${serialnumber}...`); - + const correctedMAC = formatMAC(configDevice.mac); // TODO: This would be the spot to add a UUID override to enable the user to transparently replace a device - const uuid = this.api.hap.uuid.generate(configDevice.mac || serialnumber); + const uuid = this.api.hap.uuid.generate(correctedMAC || serialnumber); // see if an accessory with the same uuid has already been registered and restored from // the cached devices we stored in the `configureAccessory` method above