ColorExtractor Palette Support

I’ve recently started playing around with the ColorExtractor service, wondering if we could get palette support if passing multiple light entities?

The underlying Python Library, color-thief, appears to support this natively.

Hey, author of the service here, glad your liking it :slight_smile:

How do you see the pallette being used? Passing a number of lights in and having the pallette count match the number of lights, then apply each color to each light?

2 Likes

Exactly. I would bet there are people who would prefer more control, but that’d be perfect.

Hey, me again!

I’ve got a PR in to add this functionality.

It allows passing a list of lights into the service call, and color_extractor will call the get_palette method of ColorThief and then apply the resulting colors out to the lights given. If an image lacks the palette range (I test on a 1x1 pixel with 3 lights), it will only apply the number of colors retrieved from the image to that number of lights. In my example, only the first light will have the 1x1 color applied, the others are left as they were.

The component is currently on my repo (link to file), if you could copy that __init__.py into custom_components/color_extractor/__init__.py to test it locally :slight_smile:

Let me know if it meets the mark or not.

1 Like

I actually have no ability to test it locally at the moment :joy:. The other half of this is getting proper support for my LIFX Tile(s). At the moment all 5 tiles (with their 64 individual zones each) all appear as a single light under Home Assistant.

Edit: Though it looks like the LIFX Beam use zones in their single light entity. Would it be possible to have ColorExtractor pull the number of zones out of a light entity? (I think if it’s a single light entity and has to pull out zones there should be a variable the user sets in the data template as to use the zones. [true/false])
Maybe Home Assistant supports calling a specific light zone like this: entity_id.0 entity_id.1 etc? I’m not sure and I’m unable to test.

Hmmm, not sure I’d like to mke it to specific for that integration. If theres a generic zone per light entity, then we could look at that.

1 Like

Hello, I have tried copying the init.py file into the custom_components map, but the whole color extractor stopped working after that. What am I doing wrong?

I would like to use the color extractor to extract a color palette as described in this thread, and apply it to multiple lights in the room.
I am able to test it locally right now.

Thanks!

The PR is from 2021, it would be a surprise if it was still working. But it would be cool to have.