From 9324ad3f9b9f065dd7013dcd872884835fc1a3dd Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 7 Mar 2019 20:05:40 +0100 Subject: [PATCH] Create a device if it doesn't exist --- platypush/backend/pushbullet/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/platypush/backend/pushbullet/__init__.py b/platypush/backend/pushbullet/__init__.py index 2c79db6c9..f54e30e56 100644 --- a/platypush/backend/pushbullet/__init__.py +++ b/platypush/backend/pushbullet/__init__.py @@ -55,7 +55,11 @@ class PushbulletBackend(Backend): self.pb = Pushbullet(token) self.pb_device_id = self.get_device_id() self.listener = None - self.device = self.pb.get_device(self.device_name) + + try: + self.device = self.pb.get_device(self.device_name) + except: + self.device = self.pb.new_device(self.device_name) def _get_latest_push(self):