andrewshilliday / garage-door-controller

Software to monitor and control garage doors via a raspberry pi
MIT License
327 stars 132 forks source link

Error handling for pushbullet #73

Open crispyjones opened 6 years ago

crispyjones commented 6 years ago

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'

andrewshilliday commented 6 years ago

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

andrewshilliday commented 6 years ago

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.

crispyjones commented 6 years ago

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.