Add sms support to pushbullet notification (#32347)

* add sms support

* fix formating

* fix formating

* fix whitespace

* fix format
pull/32378/head
Sébastien RAMAGE 2020-03-01 15:07:14 +01:00 committed by GitHub
parent e9206b26ad
commit 7a7fdc5de6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -95,10 +95,18 @@ class PushBulletNotificationService(BaseNotificationService):
# Target is email, send directly, don't use a target object.
# This also seems to work to send to all devices in own account.
if ttype == "email":
self._push_data(message, title, data, self.pushbullet, tname)
self._push_data(message, title, data, self.pushbullet, email=tname)
_LOGGER.info("Sent notification to email %s", tname)
continue
# Target is sms, send directly, don't use a target object.
if ttype == "sms":
self._push_data(
message, title, data, self.pushbullet, phonenumber=tname
)
_LOGGER.info("Sent sms notification to %s", tname)
continue
# Refresh if name not found. While awaiting periodic refresh
# solution in component, poor mans refresh.
if ttype not in self.pbtargets:
@ -120,7 +128,7 @@ class PushBulletNotificationService(BaseNotificationService):
_LOGGER.error("No such target: %s/%s", ttype, tname)
continue
def _push_data(self, message, title, data, pusher, email=None):
def _push_data(self, message, title, data, pusher, email=None, phonenumber=None):
"""Create the message content."""
if data is None:
@ -133,7 +141,10 @@ class PushBulletNotificationService(BaseNotificationService):
email_kwargs = {}
if email:
email_kwargs["email"] = email
if url:
if phonenumber:
device = pusher.devices[0]
pusher.push_sms(device, phonenumber, message)
elif url:
pusher.push_link(title, url, body=message, **email_kwargs)
elif filepath:
if not self.hass.config.is_allowed_path(filepath):