Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in get_light_objects #29

Closed
cchaz003 opened this issue Jul 12, 2014 · 6 comments
Closed

Error in get_light_objects #29

cchaz003 opened this issue Jul 12, 2014 · 6 comments

Comments

@cchaz003
Copy link

Whenever I try to run the get_light_objects method I get the following error:

Traceback (most recent call last):
  File "random_colors.py", line 14, in <module>
    lights = b.get_light_objects()
  File "/Users/abcd/abcd/Hue/Python/examples/phue.py", line 562, in get_light_objects
    self.lights_by_id[int(light)] = Light(self, int(light))
TypeError: int() argument must be a string or a number, not 'dict'

The error started appearing for me about 2 or 3 weeks ago. I noticed it after a base station update (maybe the problem?) but I dont think there was an API change. I dont think its my code either since I get this error while running the examples as well (the error above came from the "random_colors.py" example).

Any idea why this started happening?

@cchaz003
Copy link
Author

I think I've figured it out. I'm not totally sure what happened to make it stop working but giving the bridge a username as part of the bridge init (which in phue.py says is optional, and is not used in examples). In the past whenever there was an update I would just get an error telling me to push the button and then it would work, this time I actually had to put in the username. Did some API change or is this just my computers being weird?

@natcl
Copy link
Member

natcl commented Jul 13, 2014

It's probably because your api key got deleted in the bridge after the update.
you should be getting an error message however.... I'll look into it.
Does it work now without providing a username ?

lecaude.com
studioimaginaire.com

Le 2014-07-12 à 03:18, Charlie notifications@github.com a écrit :

I think I've figured it out. I'm not totally sure what happened to make it stop working but giving the bridge a username as part of the bridge init (which in phue.py says is optional, and is not used in examples). In the past whenever there was an update I would just get an error telling me to push the button and then it would work, this time I actually had to put in the username. Did some API change or is this just my computers being weird?


Reply to this email directly or view it on GitHub.

@cchaz003
Copy link
Author

I actually changed the bridge init method because I didnt want to go though and change all my scripts.

# def __init__(self, ip=None, username=None):
    def __init__(self, ip=None, username="newdeveloper"):

when I change back to username=None, I get the error above. I remember throwing in some prints to debug what might be the problem (wish I had logged them!) and remember seeing somewhere that it was trying to interact with the bridge using some seemingly random username (along the lines of /api/asd6sdf6876sdf/...). I dont know if this helps at all but it would explain the error above since it a random username would be invalid. I actually figured out it was a username issue originally by printing the light object from the error above (before crashing) and got this output:

{u'error': {u'type': 1, u'description': u'unauthorized user', u'address': u'/lights'}}

I dont know if that helps at all... I'm not much of a python developer, I mostly work with AVR micros so this is mostly just me fumbling around.

@natcl natcl closed this as completed Feb 10, 2015
@alexfromapex
Copy link

alexfromapex commented May 20, 2016

Having this same issue, after not running my script for a long time

debug info:

>>> b.get_api()
[{u'error': {u'type': 1, u'description': u'unauthorized user', u'address': u'/'}}]

@natcl
Copy link
Member

natcl commented May 20, 2016

Perhaps your API key isn't valid anymore. Try deleting the .python_hue file and doing the registration/button push again

@alexfromapex
Copy link

alexfromapex commented May 20, 2016

That worked, thanks! I just had to push the button again too. Otherwise, I got this error:

Traceback (most recent call last): File "<pyshell#4>", line 1, in <module> b = phue.Bridge('192.168.1.76') File "C:\Python27\lib\site-packages\phue.py", line 427, in __init__ self.connect() File "C:\Python27\lib\site-packages\phue.py", line 551, in connect self.register_app() File "C:\Python27\lib\site-packages\phue.py", line 519, in register_app 'The link button has not been pressed in the last 30 seconds.') PhueRegistrationException

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants