rooi / homebridge-lightwaverf

LightwaveRF plugin for HomeBridge
9 stars 7 forks source link

Duplicate names and the 12 character limit #1

Closed metalshark closed 8 years ago

metalshark commented 8 years ago

I am receiving the following error:

[LightWaveRF] Initializing platform accessory 'Lights'... [LightWaveRF] Initializing platform accessory 'Lights'... /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:164 throw new Error("Cannot add a bridged Accessory with the same UUID as another bridged Accessory: " + existing.UUID); ^

Error: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: ...

I am assuming this is because I have two rooms (Lounge and Bedroom) with LightWaveRF and the naming works on a Room > Device scheme due to the 12 character limit when naming devices on LightWaveRF. So I can't call one device on https://lightwaverfhost.co.uk/manager/index.php "Lounge Lights" because that's too long. Therefore I have two rooms and the device name "Lights" is duplicated.

rooi commented 8 years ago

Hi,

This may be caused by the following line in index.js:

.setCharacteristic(Characteristic.SerialNumber, "A1S2NASF88EW" + this.roomId + this.deviceId)//this.device.uniqueid)

Could you try to add some console.log statements that print the this.roomId and this.deviceId? Furthermore could you perhaps try to change the A1S2NASF88EW part?

Thanks!

metalshark commented 8 years ago

Thanks Rooi,

I'll have a look this weekend and report back (hopefully with a patch).

On Friday, 22 January 2016, rooi notifications@github.com wrote:

Hi,

This may be caused by the following line in index.js:

.setCharacteristic(Characteristic.SerialNumber, "A1S2NASF88EW" + this.roomId + this.deviceId)//this.device.uniqueid)

Could you try to add some console.log statements that print the this.roomId and this.deviceId? Furthermore could you perhaps try to change the A1S2NASF88EW part?

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/rooi/homebridge-lightwaverf/issues/1#issuecomment-173830687 .

metalshark commented 8 years ago

Can't see the problem as the Serial Number should be unique:

[LightWaveRF] Initializing platform accessory 'Lights'... this.roomId = 2 this.deviceId = 1 this.device = [object Object] this.device.uniqueId = undefined "A1S2NASF88EW" + this.roomId + this.deviceId = "A1S2NASF88EW21" [LightWaveRF] Initializing platform accessory 'Lights'... this.roomId = 6 this.deviceId = 1 this.device = [object Object] this.device.uniqueId = undefined "A1S2NASF88EW" + this.roomId + this.deviceId = "A1S2NASF88EW61" /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:175 throw new Error("Cannot add a bridged Accessory with the same UUID as another bridged Accessory: " + existing.UUID);

Changing the prefix:

[LightWaveRF] Initializing platform accessory 'Lights'... this.roomId = 2 this.deviceId = 1 this.device = [object Object] this.device.uniqueId = undefined "BobTheBuilder" + this.roomId + this.deviceId = "BobTheBuilder21" [LightWaveRF] Initializing platform accessory 'Lights'... this.roomId = 6 this.deviceId = 1 this.device = [object Object] this.device.uniqueId = undefined "BobTheBuilder" + this.roomId + this.deviceId = "BobTheBuilder61" /usr/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:175 throw new Error("Cannot add a bridged Accessory with the same UUID as another bridged Accessory: " + existing.UUID);

rooi commented 8 years ago

Hi, thanks for testing!

I think I've found the cause and a fix for this. Could you try changing the following line:

this.name = device.deviceName;

into:

this.name = device. roomName + " " + device.deviceName;

Or something like it. I checked HAP-NodeJS and homebridge and it seems to create the uuid from the this.name so this has to be unique.

Thanks!

metalshark commented 8 years ago

Thanks Rooi!

That change works perfectly.

On 24 January 2016 at 08:11, rooi notifications@github.com wrote:

Hi, thanks for testing!

I think I've found the cause and a fix for this. Could you try changing the following line:

this.name = device.deviceName;

into:

this.name = device. roomName + " " + device.deviceName;

Or something like it. I checked HAP-NodeJS and homebridge and it seems to create the uuid from the this.name so this has to be unique.

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/rooi/homebridge-lightwaverf/issues/1#issuecomment-174266227 .

rooi commented 8 years ago

Cool, I've added it to the repos and published a new version.

Thanks!