Skip to content

Commit

Permalink
Format and compare MAC Address the same across config vs discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleBoyer committed Aug 1, 2024
1 parent 5eb731d commit db91c54
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 6 additions & 5 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit db91c54

Please sign in to comment.