Skip to content

Commit

Permalink
Consistenly assign Broadlink.devices keys with macAddress.toString('h…
Browse files Browse the repository at this point in the history
…ex') (#22)

* Consistenly assign the key on Broadlink.devices with macAddress.toString('hex')

---------

Co-authored-by: Cameron <32912464+kiwi-cam@users.noreply.github.com>
Co-authored-by: Octavi Font <octavi@octavifs.com>
  • Loading branch information
3 people committed Jul 5, 2024
1 parent 430d954 commit fb25648
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Broadlink extends EventEmitter {
addDevice (host, macAddress, deviceType) {
const { log, debug } = this;

if (this.devices[macAddress]) return;
if (this.devices[macAddress.toString('hex')]) return;

const isHostObjectValid = (
typeof host === 'object' &&
Expand All @@ -237,7 +237,7 @@ class Broadlink extends EventEmitter {

// Mark is at not supported by default so we don't try to
// create this device again.
this.devices[macAddress] = 'Not Supported';
this.devices[macAddress.toString('hex')] = 'Not Supported';

// Ignore devices that don't support infrared or RF.
if (unsupportedDeviceTypes[parseInt(deviceType, 16)]) return null;
Expand All @@ -258,7 +258,7 @@ class Broadlink extends EventEmitter {
device.log = log;
device.debug = debug;

this.devices[macAddress] = device;
this.devices[macAddress.toString('hex')] = device;

// Authenticate the device and let others know when it's ready.
device.on('deviceReady', () => {
Expand Down

0 comments on commit fb25648

Please sign in to comment.