[notify.pushover] Fix 'NoneType' error on data retrieval (#2352)

* Fix 'NoneType' error on data retrieval

* Reduce code for empty dict as the default
This commit is contained in:
Dale Higgs 2016-06-22 10:54:44 -05:00 committed by Paulus Schoutsen
parent a564fe8286
commit d7b006600e

View file

@ -51,10 +51,11 @@ class PushoverNotificationService(BaseNotificationService):
"""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, {}))
# Make a copy and use empty dict if necessary
data = dict(kwargs.get(ATTR_DATA) or {})
data['title'] = kwargs.get(ATTR_TITLE)
target = kwargs.get(ATTR_TARGET)
if target is not None:
data['device'] = target