PhilipsHue / HueSDK

Philips Hue Software Development Kit
98 stars 39 forks source link

PHSGroup doesn't have sensorIdentifiers property to get sensors associated with a room #15

Closed vmorris1959 closed 6 years ago

vmorris1959 commented 6 years ago

Using the Phillips Hue app you can assign sensors to rooms (represented in the SDK by PHSGroup) but the SDK offers no way to know where the sensors are currently assign to.

I suggest adding a property sensorIdentifiers to get the ids of the sensors in the same way it has lightIdentifiers for lights.

Am I missing anything here? Any ideas?

jhvdb87 commented 6 years ago

The app keeps that information internally. On bridge level there is no link between a group and a sensor. A Group only contains lights.

vmorris1959 commented 6 years ago

If the Phillips Hue app keeps that info internally, how come when opening the native Home app it knows what rooms the sensors belong to?

jhvdb87 commented 6 years ago

You are right indeed, my assumption was wrong. After doing some research: the app is using resource links for that. The resource link (which is a resource on the bridge) contains all the resources that have a relation with each other. By going through all the resource links the app can figure out all the relations between the groups/scenes/schedules/sensors

vmorris1959 commented 6 years ago

The following code: let links = mybridge.bridgeState.getDevicesOf(.resourceLink) returns an empty array, that means Phillips Hue app is not using those resource links.

jhvdb87 commented 6 years ago

You're using the wrong method: myBridge.bridgeState.getResources should be used instead. A resource link is a resource, not a device.

vmorris1959 commented 6 years ago

That's true, my bad. getResources does return some links. Thanks.