mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 12:44:07 -08:00
⚡ 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. * ⚡ Small improvemenets to (#1299) Co-authored-by: Robert Kaelin <robertkaelin@users.noreply.github.com>
This commit is contained in:
parent
9c479abc35
commit
1c615b615f
|
@ -77,9 +77,23 @@ export class PhilipsHue implements INodeType {
|
||||||
'GET',
|
'GET',
|
||||||
`/bridge/${user}/lights`,
|
`/bridge/${user}/lights`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const groups = await philipsHueApiRequest.call(
|
||||||
|
this,
|
||||||
|
'GET',
|
||||||
|
`/bridge/${user}/groups`,
|
||||||
|
);
|
||||||
|
|
||||||
for (const light of Object.keys(lights)) {
|
for (const light of Object.keys(lights)) {
|
||||||
const lightName = lights[light].name;
|
let lightName = lights[light].name;
|
||||||
const lightId = light;
|
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({
|
returnData.push({
|
||||||
name: lightName,
|
name: lightName,
|
||||||
value: lightId,
|
value: lightId,
|
||||||
|
|
Loading…
Reference in a new issue