From 2a268a35eb592721d96b4103ae908827de51c92a Mon Sep 17 00:00:00 2001 From: Callum Macdonald Date: Wed, 6 Nov 2019 13:11:05 +0100 Subject: [PATCH] Add `lampIndex` to `Lamp`. #7 --- src/hue-interfaces.ts | 1 + src/hue-node.ts | 2 +- src/hue-test-constants.ts | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hue-interfaces.ts b/src/hue-interfaces.ts index 03cd564..2d9f587 100644 --- a/src/hue-interfaces.ts +++ b/src/hue-interfaces.ts @@ -383,6 +383,7 @@ export namespace States { } export interface Lamp { + lampIndex: number; state: States.LampState; type: string; name: string; diff --git a/src/hue-node.ts b/src/hue-node.ts index 008b7ce..6618a93 100644 --- a/src/hue-node.ts +++ b/src/hue-node.ts @@ -585,7 +585,7 @@ export class Hue extends HueBridge { public async getLamps(): Promise { const url = this.buildLampCompositeURL(); const { data } = await this.get(url); - return Object.keys(data).map(k => data[k]); + return Object.keys(data).map(k => ({...data[k], lampIndex: parseInt(k)})); } /** diff --git a/src/hue-test-constants.ts b/src/hue-test-constants.ts index 864edf9..35deca2 100644 --- a/src/hue-test-constants.ts +++ b/src/hue-test-constants.ts @@ -47,6 +47,7 @@ export const no_brightness: any = 1; export const lamp_response: any = { '1': { + lampIndex: 1, state: { on: true, bri: 144, @@ -75,6 +76,7 @@ export const lamp_response: any = { } }, '2': { + lampIndex: 2, state: { on: false, bri: 0,