mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +00:00
Catch a gntp networkerror (#2099)
This commit is contained in:
parent
8d34b76d51
commit
a565cc4b73
@ -41,8 +41,9 @@ class GNTPNotificationService(BaseNotificationService):
|
|||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
def __init__(self, app_name, app_icon, hostname, password, port):
|
def __init__(self, app_name, app_icon, hostname, password, port):
|
||||||
"""Initialize the service."""
|
"""Initialize the service."""
|
||||||
from gntp import notifier
|
import gntp.notifier
|
||||||
self.gntp = notifier.GrowlNotifier(
|
import gntp.errors
|
||||||
|
self.gntp = gntp.notifier.GrowlNotifier(
|
||||||
applicationName=app_name,
|
applicationName=app_name,
|
||||||
notifications=["Notification"],
|
notifications=["Notification"],
|
||||||
applicationIcon=app_icon,
|
applicationIcon=app_icon,
|
||||||
@ -50,7 +51,11 @@ class GNTPNotificationService(BaseNotificationService):
|
|||||||
password=password,
|
password=password,
|
||||||
port=port
|
port=port
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
self.gntp.register()
|
self.gntp.register()
|
||||||
|
except gntp.errors.NetworkError:
|
||||||
|
_LOGGER.error('Unable to register with the GNTP host.')
|
||||||
|
return
|
||||||
|
|
||||||
def send_message(self, message="", **kwargs):
|
def send_message(self, message="", **kwargs):
|
||||||
"""Send a message to a user."""
|
"""Send a message to a user."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user