Pushbullet tweaks

This commit is contained in:
Paulus Schoutsen 2015-11-28 15:41:30 -08:00
parent e84ef2d2d7
commit ef394b8af7

View File

@ -100,7 +100,7 @@ class PushBulletNotificationService(BaseNotificationService):
# This also seems works to send to all devices in own account # This also seems works to send to all devices in own account
if ttype == 'email': if ttype == 'email':
self.pushbullet.push_note(title, message, email=tname) self.pushbullet.push_note(title, message, email=tname)
_LOGGER.info('Sent notification to self') _LOGGER.info('Sent notification to email %s', tname)
continue continue
# Refresh if name not found. While awaiting periodic refresh # Refresh if name not found. While awaiting periodic refresh
@ -108,18 +108,21 @@ class PushBulletNotificationService(BaseNotificationService):
if ttype not in self.pbtargets: if ttype not in self.pbtargets:
_LOGGER.error('Invalid target syntax: %s', target) _LOGGER.error('Invalid target syntax: %s', target)
continue continue
if tname.lower() not in self.pbtargets[ttype] and not refreshed:
tname = tname.lower()
if tname not in self.pbtargets[ttype] and not refreshed:
self.refresh() self.refresh()
refreshed = True refreshed = True
# Attempt push_note on a dict value. Keys are types & target # Attempt push_note on a dict value. Keys are types & target
# name. Dict pbtargets has all *actual* targets. # name. Dict pbtargets has all *actual* targets.
try: try:
self.pbtargets[ttype][tname.lower()].push_note(title, message) self.pbtargets[ttype][tname].push_note(title, message)
_LOGGER.info('Sent notification to %s/%s', ttype, tname)
except KeyError: except KeyError:
_LOGGER.error('No such target: %s/%s', ttype, tname) _LOGGER.error('No such target: %s/%s', ttype, tname)
continue continue
except self.pushbullet.errors.PushError: except self.pushbullet.errors.PushError:
_LOGGER.error('Notify failed to: %s/%s', ttype, tname) _LOGGER.error('Notify failed to: %s/%s', ttype, tname)
continue continue
_LOGGER.info('Sent notification to %s/%s', ttype, tname)