Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistenly assign Broadlink.devices keys with macAddress.toString('hex') #22

Merged
merged 5 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ rm4DeviceTypes[parseInt(0x6070, 16)] = "Broadlink RM4 Mini C";
rm4DeviceTypes[parseInt(0x62be, 16)] = "Broadlink RM4 Mini C";
rm4DeviceTypes[parseInt(0x610f, 16)] = "Broadlink RM4 Mini C";
rm4DeviceTypes[parseInt(0x6539, 16)] = "Broadlink RM4 Mini C";
rm4DeviceTypes[parseInt(0x520d, 16)] = "Broadlink RM4 Mini C";
rm4DeviceTypes[parseInt(0x648d, 16)] = "Broadlink RM4 Mini S";
rm4DeviceTypes[parseInt(0x5216, 16)] = "Broadlink RM4 Mini";
rm4DeviceTypes[parseInt(0x520c, 16)] = "Broadlink RM4 Mini";
rm4DeviceTypes[parseInt(0x2225, 16)] = 'Manual RM4 Device';

// RM4 Devices (with RF support)
Expand All @@ -55,6 +57,7 @@ rm4PlusDeviceTypes[parseInt(0x6026, 16)] = "Broadlink RM4 Pro";
rm4PlusDeviceTypes[parseInt(0x61a2, 16)] = "Broadlink RM4 Pro";
rm4PlusDeviceTypes[parseInt(0x649b, 16)] = "Broadlink RM4 Pro";
rm4PlusDeviceTypes[parseInt(0x653c, 16)] = "Broadlink RM4 Pro";
rm4PlusDeviceTypes[parseInt(0x520b, 16)] = "Broadlink RM4 Pro";
rm4PlusDeviceTypes[parseInt(0x6184, 16)] = "Broadlink RM4C Pro";
rm4PlusDeviceTypes[parseInt(0x2227, 16)] = 'Manual RM4 Pro Device';

Expand Down Expand Up @@ -214,7 +217,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 @@ -228,7 +231,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 @@ -249,7 +252,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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kiwicam-broadlinkjs-rm",
"version": "0.9.17",
"version": "0.9.19",
"description": "A Node.JS fork of broadlinkjs specifically intended for interacting with RM devices in homebridge-broadlink-rm",
"main": "index.js",
"scripts": {
Expand Down