Skip to content

Commit

Permalink
Fix: ensure MAC addresses are correctly found.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjdhjd committed Apr 3, 2023
1 parent 7aa4645 commit 07f3c81
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/protect-mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ export class ProtectMqtt {

// We've been unable to even attempt to connect. It's likely we have a configuration issue - we're done here.
if(!this.mqtt) {

return;
}

// Notify the user when we connect to the broker.
this.mqtt.on("connect", () => {

this.isConnected = true;

// Magic incantation to redact passwords.
Expand Down Expand Up @@ -195,6 +197,7 @@ export class ProtectMqtt {

// No accessory, we're done.
if(!accessory) {

return null;
}

Expand All @@ -204,7 +207,7 @@ export class ProtectMqtt {
// Check to see if it's really a Protect device...if it is, use it's MAC address.
if((typeof accessory !== "string") && ("mac" in accessory.context)) {

mac = this.nvr.configuredDevices[accessory.UUID]?.ufp.mac;
mac = accessory.context.mac as string;
}

const expandedTopic = this.config.mqttTopic + "/" + mac + "/" + topic;
Expand Down

0 comments on commit 07f3c81

Please sign in to comment.