Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Commit

Permalink
hue light name (fix #90)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Jan 17, 2020
1 parent 37a4328 commit 65b6002
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions nodes/hue-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ module.exports = function (RED) {

const type = zllDevice[epFirst.deviceID];
if (type && device.modelID !== 'lumi.router') {
if (!device.meta.hue) {
if (device.meta.hue) {
device.meta.hue.name = device.meta.name;
} else {
this.debug(`initLight ${device.ieeeAddr} ${device.meta.name} ${device.modelID}`);
const uniqueid = device.ieeeAddr.replace('0x', '').replace(/([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/, '$1:$2:$3:$4:$5:$6:$7:$8') + '-' + (uniqueidSuffix[device.manufacturerName] || '00');

Expand All @@ -248,9 +250,9 @@ module.exports = function (RED) {
8: 'none'
}
};

device.save();
}

device.save();
}
}

Expand Down
2 changes: 1 addition & 1 deletion nodes/hue-light.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$('#lights').html('');
Object.keys(data).forEach(index => {
const device = data[index];
$('#lights').append(`<tr><td>${device.meta.hue.name}</td><td>${device.meta.hue.manufacturername}</td><td>${device.meta.hue.modelid}</td><td>${device.meta.hue.type}</td></tr>`);
$('#lights').append(`<tr><td>${device.meta.name}</td><td>${device.meta.hue.manufacturername}</td><td>${device.meta.hue.modelid}</td><td>${device.meta.hue.type}</td></tr>`);
});
});
}
Expand Down
8 changes: 5 additions & 3 deletions nodes/hue-light.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ module.exports = function (RED) {

const type = zllDevice[epFirst.deviceID];
if (type && device.modelID !== 'lumi.router' && device.type === 'Router') {
if (!device.meta.hue) {
if (device.meta.hue) {
device.meta.hue.name = device.meta.name;
} else {
this.debug(`initLight ${device.ieeeAddr} ${device.meta.name} ${device.modelID}`);
const uniqueid = device.ieeeAddr.replace('0x', '').replace(/([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/, '$1:$2:$3:$4:$5:$6:$7:$8') + '-' + (uniqueidSuffix[device.manufacturerName] || '00');

Expand All @@ -293,9 +295,9 @@ module.exports = function (RED) {
8: 'none'
}
};

device.save();
}

device.save();
}
}

Expand Down

0 comments on commit 65b6002

Please sign in to comment.