mclarkk / lifxlan

Python library for accessing LIFX devices locally using the official LIFX LAN protocol.
MIT License
503 stars 115 forks source link

What about get_label for Groups object #130

Closed henryruhs closed 4 years ago

henryruhs commented 5 years ago

Hello,

it would be great to have a similar API for Group object like we have in the Light object. I need to get the current group label while iterating over a list but there is no way to get this accept this dirty hack:

...
for group in groups:
    group_name = get_group_name(group)
...

def get_group_name(group):
    for device in group.get_device_list():
        return device.get_group_label()

Something like that would be great:

group.get_label()
mclarkk commented 4 years ago

There seems to be some confusion here about two different uses of the term "Group."

LIFX group: The lights themselves have a group that is assigned to them through the LIFX app, such as "Office" or "Bedroom." Devices can only belong to one group. device.get_group_label() returns the group name according to the LIFX app.

lifxlan Group: lifxlan provides a generic Group class that allows you to collect an arbitrary set of LIFX devices together and operate on them in parallel.

The problem with group.get_label(): The devices in a lifxlan Group may belong to different LIFX app groups. For example, if you make a lifxlan Group out of all of your multizone lights, device.get_group_label() might return "Bedroom" for one and "Kitchen" for the other...so what should group.get_label() return?

The semantics of the two groups are different, and it does not make sense for a lifxlan Group to derive its name from the LIFX group label of member devices. How to name a lifxlan Group is application-dependent and should be left to the user.

henryruhs commented 4 years ago

The devices in a lifxlan Group may belong to different LIFX app groups

Thank you for the explanation. What about returning a List with the names, so group.get_labels() returns ["Bedroom", "Kitchen"]`.