From 23272b047d50759df7de3ddd30181df7b472f87c Mon Sep 17 00:00:00 2001 From: Cameron <32912464+kiwi-cam@users.noreply.github.com> Date: Fri, 22 Jul 2022 08:05:55 +1200 Subject: [PATCH 1/4] v0.9.18 (#20) * Adds support for 0x520b and 0x520c Devices --- index.js | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 6c9f498..09c075d 100644 --- a/index.js +++ b/index.js @@ -46,6 +46,7 @@ rm4DeviceTypes[parseInt(0x610f, 16)] = "Broadlink RM4 Mini C"; rm4DeviceTypes[parseInt(0x6539, 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) @@ -55,6 +56,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'; diff --git a/package.json b/package.json index e672ee6..3ace2c1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kiwicam-broadlinkjs-rm", - "version": "0.9.17", + "version": "0.9.18", "description": "A Node.JS fork of broadlinkjs specifically intended for interacting with RM devices in homebridge-broadlink-rm", "main": "index.js", "scripts": { From a8f16f139eb384da1e5e8cd934f5cbd055c16bb0 Mon Sep 17 00:00:00 2001 From: Kiwi Cam <32912464+kiwi-cam@users.noreply.github.com> Date: Wed, 26 Jul 2023 08:20:40 +1200 Subject: [PATCH 2/4] Adding support for 520d devices --- index.js | 1 + package.json | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 09c075d..b6de9b8 100644 --- a/index.js +++ b/index.js @@ -44,6 +44,7 @@ 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"; diff --git a/package.json b/package.json index 3ace2c1..63ef7fe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "kiwicam-broadlinkjs-rm", - "version": "0.9.18", - "description": "A Node.JS fork of broadlinkjs specifically intended for interacting with RM devices in homebridge-broadlink-rm", + "version": "0.9.1999999999scription": "A Node.JS fork of broadlinkjs specifically intended for interacting with RM devices in homebridge-broadlink-rm", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" From 2ecff93e749a1a062216b568ceadcb9d1f1e5c17 Mon Sep 17 00:00:00 2001 From: Kiwi Cam <32912464+kiwi-cam@users.noreply.github.com> Date: Wed, 26 Jul 2023 08:24:35 +1200 Subject: [PATCH 3/4] Adding support for 520d devices --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 63ef7fe..5a9b6cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "kiwicam-broadlinkjs-rm", - "version": "0.9.1999999999scription": "A Node.JS fork of broadlinkjs specifically intended for interacting with RM devices in homebridge-broadlink-rm", + "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": { "test": "echo \"Error: no test specified\" && exit 1" From e162a2ee1b6b3c1aa48a1c199e8da60c5db18a35 Mon Sep 17 00:00:00 2001 From: Octavi Font Date: Sun, 3 Mar 2024 16:40:28 +0100 Subject: [PATCH 4/4] Consistenly assign the key on Broadlink.devices with macAddress.toString('hex') Otherwise, Broadlink.addDevice check always fail to match any existing devices. Moreover, String(macAddress) can return clashing string values, even if the buffer values are different, so it is not a safe function to have unique keys from the buffer value. --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b6de9b8..83b8839 100644 --- a/index.js +++ b/index.js @@ -217,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' && @@ -231,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; @@ -252,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', () => {