PhilipsHue / PhilipsHueSDK-Java-MultiPlatform-Android

The Software Development Kit for Philips Hue Java Mulfi-Platform and Android (beta)
273 stars 214 forks source link

Get groups does not exists in sdk #10

Closed aujinj closed 9 years ago

aujinj commented 9 years ago

Here are few calls are missing in SDK.

Get all groups from the bridge Get a group from the bridge List lights from the group

Thank you.

SteveyO commented 9 years ago

Hi there, In the SDK we have a cache, which is populated every heartbeat, or every time the bridge is updated. So every SDK 'get' call retrieves the data from the cache This is done to prevent flooding the bridge with many http requests.

So:- To get all Groups from the bridge:- PHBridge bridge = phHueSDK.getSelectedBridge(); List allGroups= bridge.getResourceCache().getAllGroups();

To get a group, we have: getResourceCache().getGroups() This returns a map, with the Group Identifier being the Key, so if you know the Group identifier, you can use this to get a particular group.

To get the lights from the group you can call the getLightIdentifiers() method (on the group) to return the light ids which from part of the group.

Hope this helps Steve