peter-murray / node-hue-api

Node.js Library for interacting with the Philips Hue Bridge and Lights
Apache License 2.0
1.19k stars 145 forks source link

Property name confusion on groups #124

Closed SimonHoiberg closed 5 years ago

SimonHoiberg commented 5 years ago

Hi

First of all, really cool project!

It's seems that there is a possible confusion between the property name 'action' and 'lastAction' when getting groups.

According to the docs, a group object derived with getGroup(id) should return an object with the property name 'lastAction', whereas groups() should return a list of objects with the property name 'action' instead.

I'm using Typescript, and when I use getGroup(id) I'm receiving an object which implements ILightGroup that looks like the following:

interface ILightGroup {
     id: string,
     name: string,
     type: LightGroupType,
     class?: RoomType,
     action?: { // <- this is where it get's confusing
         on: boolean,
         bri: number,
         hue: number,
         sat: number,
         xy: [number, number],
         ct: number,
         effect: LightEffect,
         colormode: ColorMode
     },
     lights?: string[]
 }

However, when debugging, I verify that the object in fact does have the property name 'lastAction', just as the documentation specifies. My linter will complain about not owning a property named 'lastAction', and refuse to compile.

peter-murray commented 5 years ago

Hi,

Can you please tell me what is providing the TypeScript definitions for you? I did not provide direct support for TypeScript in the original version of the library so I suspect it may be in something that I don't directly provide.

In the JavaScript, I return what the bridge provides, so this has changed in the last year in their API and I suspect that this is the source of the problem you are facing.

I am updating the library to remove a lot of the outdated dependencies and transition to more up to date JavaScript practices (like Classes and native Promises). This will be released user a version 3 in the coming month or so.

peter-murray commented 5 years ago

Closing issue due to no further response