Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sms support to pushbullet notification #32347

Merged
merged 5 commits into from Mar 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions homeassistant/components/pushbullet/notify.py
Expand Up @@ -95,10 +95,18 @@ def send_message(self, message=None, **kwargs):
# 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:
Expand All @@ -120,7 +128,7 @@ def send_message(self, message=None, **kwargs):
_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:
Expand All @@ -133,7 +141,10 @@ def _push_data(self, message, title, data, pusher, email=None):
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):
Expand Down