Closed babincc closed 1 year ago
Added in update 1.2.0
Now, instead of
// Figure out which group is the one you want
// Get network from example 3
Relative myRelative = myHueNetwork
.rooms
.first
.services
.firstWhere((service) =>
service.type == ResourceType.groupedLight);
// Get the group whose ID was just found
GroupedLight myGroupedLight = myHueNetwork.groupedLights.firstWhere(
(groupedLight) => groupedLight.id == myRelative.id,
);
// Toggle the on/off state
myGroupedLight.on.isOn = !myGroupedLight.on.isOn;
// PUT the new state
myBridge.put(myGroupedLight);
you can instead do
// Get the grouped light from the room
GroupedLight myGroupedLight = myHueNetwork!.rooms.first.servicesAsResources
.firstWhere((resource) => resource is GroupedLight) as GroupedLight;
// Toggle the on/off state
myGroupedLight.on.isOn = !myGroupedLight.on.isOn;
// PUT the new state
myBridge!.put(myGroupedLight);
Right now, the HueNetwork object just contains a bunch of objects. They aren't really connected in any simple way. Putting them together is clunky and leaves room for error. There needs to be a simple way to connect objects.
Example:
Rather than doing all of this to get a GroupedLight from a Room:
It should look something more like this: