python-hue icon indicating copy to clipboard operation
python-hue copied to clipboard

Support Python 3

Open PanderMusubi opened this issue 10 years ago • 4 comments

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?

PanderMusubi avatar Jan 24 '15 23:01 PanderMusubi

Unauthorized user is interesting. I haven't seen that before. Potentially newer firmware is more strict on possible usernames. I made that up before there was an official API. The newest version of the API docs seem to suggest this: http://www.developers.meethue.com/documentation/configuration-api#41

I'd prefer to remove the print statement or change it to a logging statement. The client identifier looks right to me.

If you can change this to a pull request (feel free to add yourself to the contributors) I'd be happy to merge it; Otherwise it will wait until I've got time, maybe a couple weeks.

Thank you for using and contributing!

issackelly avatar Jan 25 '15 00:01 issackelly

The Android apps I use there is no such thing as a username for Philips hue.

I am willing to wait for you to fix it.

PanderMusubi avatar Jan 25 '15 00:01 PanderMusubi

Ah, I need http://www.developers.meethue.com/documentation/getting-started to create a user

PanderMusubi avatar Jan 25 '15 17:01 PanderMusubi

Yeah. Username is a misnomer, it's more like a unique User Agent, or a client name. This is why in my original version i based it on the fqdn.

issackelly avatar Jan 26 '15 01:01 issackelly