Giter VIP home page Giter VIP logo

python-hue's Introduction

Python-Hue

Python client for the Philips Hue lighting system. I figured out almost all of this by monitoring the traffic on my router. I then found https://github.com/alistairg/IndigoHue/blob/master/Hue.indigoPlugin/Contents/Server%20Plugin/plugin.py which gave some clues about RGB support and the magic strings (select, lselect) to send alerts.

Sample Usage is not docs:

from hue import Hue;
h = Hue(); # Initialize the class
h.station_ip = "192.168.1.222"  # Your base station IP
h.get_state(); # Authenticate, bootstrap your lighting system
l = h.lights.get('l3') # get bulb #3
l.bri(0) # Dimmest
l.bri(255) # Brightest
l.rgb(120, 120, 0) # [0-255 rgb values]
l.rgb("#9af703") # Hex string
l.on()
l.off()
l.toggle()
l.alert() # short alert
l.alert("lselect") # long alert
l.setState({"bri": 220, "alert": "select"}) # Complex send

Have fun! Let me know how you're using it.

python-hue's People

Contributors

davoclavo avatar issackelly avatar mrdek11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-hue's Issues

How to install and use the code

I am a total newbie with python. i have python27 installed and have tried various ways to talk to the hues with no luck. i would like to try this out. how do i install and run it? great work BTW

method toggle()

Hi,

toggle method did't work fine (on my installation).

I did this change, and now works fine:

158 #if self.state["on"]:
if self.state and self.state.get('state', None) and self.state["state"].get("on", None):
self.off()

( self.state is a dict. There's the key 'state', and there you can find the 'on' value )

In [46]: light.state
Out[46]:
{
u'modelid': u'...',
(...)
u'state': {u'alert': u'none',
u'bri': 220,
u'colormode': u'xy',
u'ct': 500,
u'effect': u'none',
u'hue': 47103,
u'on': False,
u'reachable': True,
u'sat': 254,
u'xy': [0.2693, 0.2419]},
(...)
}

Group support

Hey, I got my Hue today and I simply love the clean implementation of this client. It's great, but it's missing group support like phue does. I'm not a python genius and I haven't been able to convert the archaic httplib requests to the new requests lib. Care to help out?

Thanks!
Dennis

Support Python 3

Please support Python 3

What needs changing is

-    client_identifier = hashlib.md5("ph-%s" % socket.getfqdn()).hexdigest()
+    client_identifier = hashlib.md5(("ph-%s" % socket.getfqdn()).encode('utf-8')).hexdigest()

and

-        print red, green, blue
+        print('%s %s %s' % (red, green, blue))

Furthermore, I get

INFO:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.9
DEBUG:urllib3.connectionpool:"GET /api/0cc11252a92919daa1dc118aeb84d6e9 HTTP/1.1" 200 None
DEBUG:hue:<Response [200]>
DEBUG:hue:b'[{"error":{"type":1,"address":"/","description":"unauthorized user"}}]'

How can I fix that?

suggestion for color temperature methods

Just a suggestion to help complete the python hue interface:

Add methods to set the color temperature, ct, and cct

def ct(self, ct):

set color temp in mired scale

return self.set_state({"ct": ct})

def cct(self, cct):

set color temp in degrees kelvin

return self.ct(1000000 / cct)

off doesn't work...

I appreciate your work on the python hue interface.

I noticed that your off() method does not work (at least for my gateway).

This updated method fixes the problem:

def off(self):
return self.set_state({"on": False})

Changes to Whitelist username creation

Hi Issac,

I work for Philips Hue Developer Support. In case you were not aware, in a few months time we will be changing the way usernames are created on the bridge (for security reasons). Custom whitelist usernames will no longer be allowed and the bridge randomly generated username must be used instead. Please see below link for more information:
http://www.developers.meethue.com/documentation/important-whitelist-changes

Am not sure if you are still actively maintaining this library but if so it looks like it may affect you also, as you appear to be passing in the username when creating (i.e. POSTing) a new username on the bridge (hue.py line 74). This should be removed and the randomly generated bridge username should be retrieved from the bridge response. Apologies for the inconvenience.

Thanks
Steve

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.