diff --git a/homeassistant/components/notify/pushover.py b/homeassistant/components/notify/pushover.py index b202f38fa7ce0..304d771f92a15 100644 --- a/homeassistant/components/notify/pushover.py +++ b/homeassistant/components/notify/pushover.py @@ -7,7 +7,7 @@ import logging from homeassistant.components.notify import ( - ATTR_TITLE, DOMAIN, BaseNotificationService) + ATTR_TITLE, ATTR_TARGET, ATTR_DATA, DOMAIN, BaseNotificationService) from homeassistant.const import CONF_API_KEY from homeassistant.helpers import validate_config @@ -51,7 +51,17 @@ def send_message(self, message="", **kwargs): """Send a message to a user.""" from pushover import RequestError + # Make a copy and use empty dict as default value (thanks @balloob) + data = dict(kwargs.get(ATTR_DATA, {})) + + data['title'] = kwargs.get(ATTR_TITLE) + target = kwargs.get(ATTR_TARGET) + if target is not None: + data['device'] = target + try: - self.pushover.send_message(message, title=kwargs.get(ATTR_TITLE)) + self.pushover.send_message(message, **data) + except ValueError as val_err: + _LOGGER.error(str(val_err)) except RequestError: _LOGGER.exception("Could not send pushover notification")