From 909a06566efece7ed6074256384f3ed96c6566cf Mon Sep 17 00:00:00 2001 From: Philip Rosenberg-Watt Date: Sat, 17 Feb 2018 22:13:05 -0700 Subject: [PATCH] Fail gracefully with unreachable LaMetric (#12451) Accounts with multiple LaMetric devices at unreachable IPs (for example at a different location, on a different/unroutable subnet, etc.) may cause the notify.lametric service to fail. This update wraps the message sending routine in a try/except clause and outputs log messages indicating the problem. Fixes #12450 --- homeassistant/components/notify/lametric.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/notify/lametric.py b/homeassistant/components/notify/lametric.py index 2f967dcdda4..f4c9c391408 100644 --- a/homeassistant/components/notify/lametric.py +++ b/homeassistant/components/notify/lametric.py @@ -93,6 +93,11 @@ class LaMetricNotificationService(BaseNotificationService): devices = lmn.get_devices() for dev in devices: if targets is None or dev["name"] in targets: - lmn.set_device(dev) - lmn.send_notification(model, lifetime=self._lifetime) - _LOGGER.debug("Sent notification to LaMetric %s", dev["name"]) + try: + lmn.set_device(dev) + lmn.send_notification(model, lifetime=self._lifetime) + _LOGGER.debug("Sent notification to LaMetric %s", + dev["name"]) + except OSError: + _LOGGER.warning("Cannot connect to LaMetric %s", + dev["name"])