kershner / screenBloom

Fake Ambilight for Philips Hue via Python
http://www.screenbloom.com
329 stars 48 forks source link

[Question]: Get Average color from API endpoint #76

Closed DanielSSilva closed 6 years ago

DanielSSilva commented 6 years ago

Hello there! I'm quite new to this and i'm not a python developer. I saw that there's an API, but I haven't found an enpoint to get the average color. Is there any? My idea is, since i own a raspberry pi and some ws2812 lights I was thinking on developing a script that polls the webAPI to get the average color and set the lights with that matching color. Any way to make this happening? Thanks!

DanielSSilva commented 6 years ago

Also, I've just installed the software and it looks like I need to have a philips and pair it with the screenBloom. Since I don't own one and I just want the average color, is there any way to skip this step?

kershner commented 6 years ago

Hey there, this is an interesting idea and would be pretty easy to implement. I will add it to my ever expanding todo list.

In the meantime, here's a link to the image averaging function: https://github.com/kershner/screenBloom/blob/master/app/modules/img_proc.py#L17

It takes in a PIL image, which should make things pretty easy to just drop into your project. Let me know if you have any questions or issues with implementing it!

DanielSSilva commented 6 years ago

Well, I do believe that it would be really easy to implement. The hard part is already done (calculate the average color). If I knew a little bit about python I could fork your project, add that endpoint a do a PR, but unfortunately it would take me more time to do so than it would take you to implement it :D . But either way I think that I will need to learn about creating/using APIs in python, since the code for the led stripe is written in Python

DanielSSilva commented 6 years ago

FYI I got it working (although it's not as I would like to).

I've got two main "problems" now: 1st - The led strip only accepts INT, so I need to cast from float to int (which is the first step to lose "precision") 2nd - the color transition are not smooth, even without limiting the API request ( maybe it's due to limitation of being a intranet request (there's always some delay) and the time to send the info to the led strip)

Anyway I'm pretty happy for being able to develop this part so quickly. Thank you very much for your help!

kershner commented 6 years ago

Awesome, glad to hear how it turned out. Just let me know if you ever have any additional questions!

DanielSSilva commented 6 years ago

Do you have any logic to avoid the delay? I know that there are several factors influencing my solution, such as the time that the pi takes to set the leds, the request/response to the api... Your solution does make the transitions smoothly. I'm wondering if you have any logic for the delays. I have some ideas to avoid the delays