andrewshilliday/garage-door-controller

Error handling for pushbullet

Opened this issue · 3 comments

Lots of garage door open/closes this month and I hit the 500 limit on pushbullet API pushes. This causes the following errors and the garage door status is stuck open. The toggle function still works (garage opens and shuts) but without feedback.

[1] 2423
pi@raspberrypi:~/garage-door-controller $ {"error":{"code":"pushbullet_pro_required","type":"invalid_request","message":"Pushbullet Pro is required to make this call.","cat":""},"error_code":"pushbullet_pro_required"}
Unhandled error in Deferred:
Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1192, in run
self.mainLoop()
File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1201, in mainLoop
self.runUntilCurrent()
File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 824, in runUntilCurrent
call.func(*call.args, **call.kw)
File "/usr/lib/python2.7/dist-packages/twisted/internet/task.py", line 218, in call
d = defer.maybeDeferred(self.f, *self.a, **self.kw)
--- ---
File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 139, in maybeDeferred
result = f(*args, **kw)
File "controller.py", line 134, in status_check
self.send_pushbullet(door, title, message)
File "controller.py", line 185, in send_pushbullet
door.pb_iden = json.loads(response)['iden']
exceptions.KeyError: 'iden'

Looks like we need some error handling around the notification code... I'll take a look

I've updated the code. Please pull down the latest version and try again. The pushbullet operation should still error (because you've used all your pushes), but the rest of the controller should still behave as intended.

Please let me know if it doesn't take care of it. I haven't had a chance to test out the change.

Thanks for taking a look. I hit the limit again about a week ago with your update applied. There are no errors on the console. I don't see anything in syslog, just a line that the garage state was toggled, but nothing else. The other behavior remains the same, the garage status always shows open, but still functions.