mclarkk / lifxlan

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

`AttributeError: 'Device' object has no attribute 'set_color'` when calling "set_color" on Group object #149

Closed samclane closed 3 years ago

samclane commented 4 years ago

I call the following snippet of code to change the color of a lifxlan.Group object:

            self.target.set_color(color, duration=0 if rapid else float(config["AverageColor"]["duration"]) * 1000,
                                  rapid=rapid)

self.target is a Group that is set by

self.lifx.get_devices_by_group(group_label)

Is there any way to get all LIFX devices on the network, with the most-specific class applied to them (i.e. Light and MultiZoneLight instead of only Device)? I feel like get_devices_by_group is incorrect for my requirements.

mclarkk commented 4 years ago

It should be automatically making them the most specific class. I'm guessing the list of known products is out of date and you have a newer product in there that is being constructed as a Device. I just ran a test and I have a Candle that shows up as "Device" for that reason. Can you print out the following info for each light, determine which one is being cast as Device, and let me know what kind of product it is, just so I can double-check it gets added?

for d in target.devices:
    print("{}: {}".format(d.get_label(), type(d)))

I'm going through a backlog of issues and pull requests right now, so someone might already have submitted an update to the products list. Could be a quick fix!

samclane commented 4 years ago

I'm still getting the error.

Here's the result of target.devices:

Lamp: <class 'lifxlan.light.Light'>
Nightstand : <class 'lifxlan.light.Light'>
Window: <class 'lifxlan.device.Device'>

Window is a LIFX Beam

samclane commented 4 years ago

The issue is the Beam isn't part of the lights list in devices.py

I made a PR here: https://github.com/mclarkk/lifxlan/pull/150

mclarkk commented 3 years ago

Fixed with #153.