google / python-laurel

Python control of C by GE Bluetooth lightbulbs
Apache License 2.0
59 stars 18 forks source link

Laurel object is not subscriptable #3

Open JAbelP opened 4 years ago

JAbelP commented 4 years ago

the code I have on my Rasberry pi 3 I am running it on python3 as bluepy would not install on python 2.7

import laurel

devices = laurel.laurel("myUserName","myPassword")

devices[0].set_power(False)

The error I get is Traceback (most recent call last): File" devices[0]/set_power(False) TyoeError: 'laurel' object is not subscriptable

jcconnell commented 4 years ago

Try devices.devices[0].name.

shannb2012 commented 4 years ago

I keep getting this error on MacOS Catalina

devices = laurel.laurel("username", "password") Traceback (most recent call last): File "", line 1, in File "/Users/shannonbrown/Desktop/lights/python-laurel/laurel/init.py", line 100, in init id = int(bulb['deviceID'][-3:]) TypeError: 'int' object is not subscriptable devices = laurel.laurel("username", "password") Traceback (most recent call last): File "", line 1, in File "/Users/shannonbrown/Desktop/lights/python-laurel/laurel/init.py", line 100, in init id = int(bulb['deviceID'][-3:]) TypeError: 'int' object is not subscriptable devices = laurel.laurel("username", "password") Traceback (most recent call last): File "", line 1, in File "/Users/shannonbrown/Desktop/lights/python-laurel/laurel/init.py", line 100, in init id = int(bulb['deviceID'][-3:]) TypeError: 'int' object is not subscriptable

tleibert commented 4 years ago

I went in and changed this line in the laurel.__init__ from id = int(bulb['deviceID'])[-3:]) to id = int(bulb['deviceID']) and it resolved the error. I dug some more and it seems that bulb['deviceID') is already an int, explaining why you can't subscript it.