mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add additional Pushover parameters (#2309)
* Add additional Pushover parameters Add support for more Pushover parameters: target (device), sound, url, url_title, priority, timestamp * Remove data dictionary reference https://github.com/home-assistant/home-assistant/pull/2309#discussion_r67603127
This commit is contained in:
parent
5efa076080
commit
6fa095f4a7
@ -7,7 +7,7 @@ https://home-assistant.io/components/notify.pushover/
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.notify import (
|
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.const import CONF_API_KEY
|
||||||
from homeassistant.helpers import validate_config
|
from homeassistant.helpers import validate_config
|
||||||
|
|
||||||
@ -51,7 +51,17 @@ class PushoverNotificationService(BaseNotificationService):
|
|||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
from pushover import RequestError
|
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:
|
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:
|
except RequestError:
|
||||||
_LOGGER.exception("Could not send pushover notification")
|
_LOGGER.exception("Could not send pushover notification")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user