fbacker / broadlink-mqtt-bridge

Bridge Broadlink RM Devices with MQTT and API for e.g. OpenHAB
41 stars 14 forks source link

Failure to discover multiple RM Mini #13

Closed jamminc closed 5 years ago

jamminc commented 5 years ago

I have 2 RM Mini running on the same network. I can run and discover each RM mini individually and use it without any problem. However, when I plug both of them on at the same time, only one will be discovered.

update: I have gotten a RM Pro from a friend... I can discover 2 devices, One pro and one mini... but never 2 mini at the same time...

jamminc commented 5 years ago

After tracing the code for about an hour, I have resolved the issue.. just a minor error in the onMessage function in broadlinkjs-rm, instead of passing in the key, macAddress (which is a byte array) was passed into the addDevice function. If the macAdress was drastically different, it was fine, unfortunately for me, the 2 mini was bought at the same time, and only the last 2 digit is different, which cause the function to think it is a duplication and did not add it in.

I have changed it in my RPI and is working fine now. I am overseas for the next month or so.. let me know if you need me to pull and update... Will do it when I get home then. In the meantime, I will mark this issue as close.

  // Ignore if we already know about this device
    const key = macAddress.toString('hex');
    if (this.devices[key]) return;

    const deviceType = message[0x34] | message[0x35] << 8;

    // Create a Device instance
    this.addDevice(host, **key**, deviceType);