From c677489535be5d44efaf6baa01a96f2dddd4a1af Mon Sep 17 00:00:00 2001 From: "J.P. Hutchins" <34154542+JPHutchins@users.noreply.github.com> Date: Wed, 21 Oct 2020 02:02:44 -0700 Subject: [PATCH] Handle Fritz exception and log warning (#42145) --- homeassistant/components/fritz/device_tracker.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/fritz/device_tracker.py b/homeassistant/components/fritz/device_tracker.py index 908cfd98a6ee..6eb23d4b85e6 100644 --- a/homeassistant/components/fritz/device_tracker.py +++ b/homeassistant/components/fritz/device_tracker.py @@ -1,6 +1,7 @@ """Support for FRITZ!Box routers.""" import logging +from fritzconnection.core import exceptions as fritzexceptions from fritzconnection.lib.fritzhosts import FritzHosts import voluptuous as vol @@ -81,7 +82,15 @@ class FritzBoxScanner(DeviceScanner): def get_extra_attributes(self, device): """Return the attributes (ip, mac) of the given device or None if is not known.""" - ip_device = self.fritz_box.get_specific_host_entry(device).get("NewIPAddress") + ip_device = None + try: + ip_device = self.fritz_box.get_specific_host_entry(device).get( + "NewIPAddress" + ) + except fritzexceptions.FritzLookUpError as fritz_lookup_error: + _LOGGER.warning( + "Host entry for %s not found: %s", device, fritz_lookup_error + ) if not ip_device: return {}