From 1c615b615f0423793a36ceac465565eb8cec3bd3 Mon Sep 17 00:00:00 2001 From: Ricardo Espinoza Date: Thu, 7 Jan 2021 01:58:08 -0500 Subject: [PATCH] :zap: Add Room/Group Name to Light Name (#1303) * Hue Node: Add Room/Group Name to Light Name To easier identify lights in the dropdown it is useful to know to which group (room) they belong. While lights can be added to multiple zones, they can only ever belong to one room. * :zap: Small improvemenets to (#1299) Co-authored-by: Robert Kaelin --- .../nodes/PhilipsHue/PhilipsHue.node.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts b/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts index cbd8321586..908790a5cf 100644 --- a/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts +++ b/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts @@ -77,9 +77,23 @@ export class PhilipsHue implements INodeType { 'GET', `/bridge/${user}/lights`, ); + + const groups = await philipsHueApiRequest.call( + this, + 'GET', + `/bridge/${user}/groups`, + ); + for (const light of Object.keys(lights)) { - const lightName = lights[light].name; + let lightName = lights[light].name; const lightId = light; + + for (const groupId of Object.keys(groups)) { + if(groups[groupId].type === 'Room' && groups[groupId].lights.includes(lightId)) { + lightName = `${groups[groupId].name}: ${lightName}`; + } + } + returnData.push({ name: lightName, value: lightId,