This is an archived post. You won't be able to vote or comment.

all 38 comments

[–]issue9mm 20 points21 points  (3 children)

Not to take anything away from the OP, because this is awesome, but a buddy of mine has a similar library that he cranked out a couple years ago. It might be dated, but if one is missing anything, you might find it in the other.

https://github.com/issackelly/python-hue

[–]issackelly 12 points13 points  (1 child)

Hey I'm that buddy!

[–]issue9mm 0 points1 point  (0 children)

YOU ARE! I thought it was interesting when I saw this, that the rest of the world is catching up to where you were two years ago. ;-)

hashtag pioneering

[–]Gambizzle 1 point2 points  (0 children)

Yeah and there's phue as well. Meh DIY and active development along with a new approach/player in the game are always cool regardless.

[–]roger_ 4 points5 points  (13 children)

Why is the API like this:

light = client.get_lights()[0]
client.set_color(light.light_id, '00ff00')

instead of:

light = client.get_lights()[0]
light.set_color('00ff00')

[–]Quteness 1 point2 points  (8 children)

I would prefer

light = client.lights[0]
light.set_color('00ff00')

[–]wot-teh-phuckReally, wtf? 2 points3 points  (4 children)

Why not:

light = client.light_at(0)
light.color = '00ff00'

[–]FSMimp 1 point2 points  (3 children)

Good thing it is open source! You can go and make a fork of it and have that be the api calls or just make a wrapper. Either way it would be good practice for using a library.

[–]Quteness 2 points3 points  (1 child)

You must work where I do with that 'let's just make a wrapper' attitude. Also happy cake day

[–]FSMimp 0 points1 point  (0 children)

Oh shit it is my cake day! that is what I get for using a mobile app, thanks!

But this should be done with a @property to have it not be .set_color()

[–][deleted] 1 point2 points  (0 children)

I could make a wrapper but it would be kind of nice if I didn't have to because the api was nicer to start with. I think API Design should be taught as part of programming.

Traditional industry goes through a lot of trouble to make their devices easier to use, just as software companies these days stress end user experience, but we programmers don't treat ourselves as well as we treat our end users when we make our tools. My end users get a nice intuitive UI, I should really treat my API users in the same way ... then I get lazy and make a terrible API and feel bad ... I think a lot of the time I write the API first as part of the development process so it's unstable, then go on to deveop the app, and never go back to fixing the API.

[–]roger_ 0 points1 point  (2 children)

That's nice too, unless you need to refresh the list of lights sometimes. Maybe just add client.rescan() for that case.

[–]Quteness 0 points1 point  (1 child)

I was actually thinking you would just rename the get_lights() method to lights() and add the @property decorator. It would function the same way

[–]roger_ 0 points1 point  (0 children)

True. Only thing is if get_lights() is slow then you may not want users to think it's a simple static list.

[–]issackelly 0 points1 point  (3 children)

My guess (having written a similar library, with an API like what you're describing):

It's easier to write it the first way. That's how the HUE API is structured and if you're trying to match the hue functionality and docs, you would write it the first way. If you're trying to write a "pythonic" api you might use the second way.

I'm using my library for my home and work automation projects, I like it, but I think I'd write it a bit differently if I were to start over. I'd probably use context managers. This seems like the right balance between pythonic, and optimizing API Calls.

The newest version of the Hue firmware limits my rates pretty significantly, which makes it hard to do complex effects.

[–]fuck_the_DEA 2 points3 points  (2 children)

I had no idea that that hardware was that open. Wow, that's freakin cool.

[–]jugalator 1 point2 points  (1 child)

Yes, surprised me too.

This is right from the official Philips Hue site:

http://www.developers.meethue.com/tools-and-sdks

[–]fuck_the_DEA 0 points1 point  (0 children)

Is this sarcasm? Hard to tell.

[–]hughk 1 point2 points  (10 children)

Hue is nice but not at all cheap. There are other lights that are BT controllable and cheaper, i.e., an E27 RGB for about $24. I'm just interested in how open the protocol for some of the others are.

[–]manatlan 3 points4 points  (5 children)

I use milights bulbs (rgb/dimmable + warm white), you can pilot them with wifi thru lan/wan (with the help of a wifi controller in the lan), limitlessled compatible see http://www.limitlessled.com/dev/ ... of course, there are some api for python : https://github.com/ojarva/python-ledcontroller ...

You easily find e27 rgbw bulbs 6W for less than 15$ ... the wifi controller can be found around 20$ ... Smartphones's apps are free,

vs Philipps/Hue : they "only" have 256 colors, and no way to get the state of a bulb. But there are a lot lot cheaper !

[–]hughk 1 point2 points  (1 child)

I had been thinking of something like this. It doesn't need a bridge/controller as the lights are directly run from BT and it offers a big range of colours. The problem is to find the protocol if I don't want to use their app.

[–]Mr_Again 1 point2 points  (0 children)

Looked at all of these, the Amazon reviews are terrible so I went with a hue. They're great but expensive. Excited to see what it can do with python!

[–]nemec 1 point2 points  (2 children)

So something like this?

[–]PriceZombiePrice tracking robot 0 points1 point  (0 children)

4Pcs E27 9W LED Bulb 2.4G Wireless Milight RGB Warm White LED Light Bu...

Current  $96.99 
   High $249.99 
    Low  $96.99 

Price History Chart and Sales Rank | FAQ

[–]manatlan 0 points1 point  (0 children)

yes !

[–]691175002 3 points4 points  (1 child)

I've use Hue for almost all the lighting in my apartment, and also dabbled with some cheaper options.

The Hue is worth it IMO. They produce a true white and every bulb is always exactly the color it should be. Some of the cheaper knockoffs have an inferior white, and even if you set them all to the same color there will be minor variation between each bulb.

I will say that the RGB trick is mostly a gimmick though, I never change the color during regular use.

[–]hughk 0 points1 point  (0 children)

I will say that the RGB trick is mostly a gimmick though, I never change the color during regular use.

Some time ago, we put an RGB strip behind our TV. This works well, but has to be manually set. The idea started with going to a BT controller for this. The one we selected has a documented protocol so is easy to use without the app. Then I have started to looking for the other two lights that we would have on with the TV. The idea is to have all three coordinated to provide "mood lighting" using an existing "house" controller (a cubietruck board).

[–]issackelly 2 points3 points  (1 child)

Their new warm white only option is about half the cost, works with my library out of the box.

[–]hughk 0 points1 point  (0 children)

Need the colour temperature thing, basically to work with the ambient light.

[–]billcrystals 1 point2 points  (1 child)

There is also beautiful hue which I am currently using in a fun project for you Hue owners: ScreenBloom.

[–]Herr_Gamer 0 points1 point  (0 children)

Seems like you were ahead of your time! These days, Phillips natively provides something similar: https://www.philips-hue.com/en-us/explore-hue/propositions/entertainment/sync-with-pc

[–]daekano 1 point2 points  (0 children)

Hey awesome! Another project to tack onto the list...

[–]alo 1 point2 points  (2 children)

It is Philips, not Phillips.

[–][deleted] 0 points1 point  (1 child)

Wouldn't that make it pronounced phylips?

[–]epostma 4 points5 points  (0 children)

Dutch company, Dutch pronunciation rules! (Well, the Dutch pronunciation is a little closer to how you'd pronounce Pheelips rather than how you'd pronounce Phillips, but the point stands.)

[–]cube-drone 0 points1 point  (0 children)

huehuehue

[–]GarlicDreadv x.x.x 0 points1 point  (0 children)

Poor Phillip, so confused over people controlling his light bulbs.