psieg / Lightpack

Lightpack and Prismatik open repository
GNU General Public License v3.0
1.57k stars 188 forks source link

Philips Hue Support #204

Open TJ-91 opened 5 years ago

TJ-91 commented 5 years ago

For personal use I've written some code which will sync the Philips Hue behind me with the average color of the screen. Maybe someone here wants to use or improve it and possibly get it far enough to merge into the psieg/Lightpack repo.

I think there are some inherent problems to scale this up to multiple Philips Hue bulbs. Like increased latency because the Philips Hue system can't handle too many requests. I only have one bulb in this room, so I will not (can not) implement support for more than one bulb anyway.

However I've read something about a new API which is faster and also handles simultaniously setting multiple bulbs better. I'm not sure where and how to access this API, though.

My code is here: https://github.com/TJ-91/Lightpack/tree/ftr_sync_philips_hue

The settings have to be done in the profile in a new chapter "[HueLights]" where at least the "URL" value has to be set:

[HueLights] URL=http://**ip_to_hue_bridge**/api/**user**/lights/**light_number**/state

(replace the bold words with your actual values)

Since the Philips Hue system only allows for roughly 10 requests per second, it will lag behind a little but it's decent imo.

Also the CPU consumption of Prismatik has gone up a bit. I'd be happy for some advice since I'm really not experienced in Qt. It took some time to figure out how to do the threading thing for the HueWorker class. However since I've replaced the "busy-wait-loop" with a more reasonable approach of slots and signals that thread likely is unnecessary now.

So currently it's more or less in a state of "it works well enough for me" and some design decisions are based on what's convenient and not what's the best design.

yebo29 commented 5 years ago

Another option is to turn off lights whenever you enable the light pack

psieg commented 5 years ago

Thanks! I don't have one though, so I won't try this or take ownership. Anyone interested in this please let me know.

Yaro96 commented 3 years ago

Thanks! I don't have one though, so I won't try this or take ownership. Anyone interested in this please let me know.

I agree that it would be a nice feature inside Prismatik, philips have it's own app but running two screen capturing software at the same time is not ideal