I have a problem, I need help. I want to use PushBullet
in python but I got error.
Here my code:
from pushbullet import PushBullet
from pushbullet import device
apik="myapikey"
pb=PushBullet(apik)
de=pb.devices[0]
success, push = de.push_note("adsadasd","asdasdasd asd asd")
I get this error:
Traceback (most recent call last):
File "gggg.py", line 6, in <module>
de = pb.devices[0]
IndexError: list index out of range
How can I solve this problem?
It means that you don't have registered device.
Using for
loop, you can push for multiple devices, and will not raise exception even though there's no device.
A possible cause of this is wrong api key specified.
from pushbullet import PushBullet
from pushbullet import device
apik = "myapikey"
pb = PushBullet(apik)
for de in pb.devices:
success, push = de.push_note("adsadasd","asdasdasd asd asd")
If you want to push only to the first device, make sure that there is at least one device:
...
pb = PushBullet(apik)
if pb.devices:
db = pb.devices[0]:
success, push = de.push_note("adsadasd","asdasdasd asd asd")