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
This commit is contained in:
Philip Rosenberg-Watt 2018-02-17 22:13:05 -07:00 committed by Paulus Schoutsen
parent 8840c227d2
commit 909a06566e

View File

@ -93,6 +93,11 @@ class LaMetricNotificationService(BaseNotificationService):
devices = lmn.get_devices()
for dev in devices:
if targets is None or dev["name"] in targets:
try:
lmn.set_device(dev)
lmn.send_notification(model, lifetime=self._lifetime)
_LOGGER.debug("Sent notification to LaMetric %s", dev["name"])
_LOGGER.debug("Sent notification to LaMetric %s",
dev["name"])
except OSError:
_LOGGER.warning("Cannot connect to LaMetric %s",
dev["name"])