From 99bc911f7ff9ec1af9036549957d38b6094a37b3 Mon Sep 17 00:00:00 2001 From: Aaron David Schneider Date: Wed, 1 Jan 2020 22:03:38 +0100 Subject: [PATCH] Add attributes to fritz device_tracker (#30350) * add attributes to device_tracker * fix pylint * requested changes * docstring updated --- homeassistant/components/fritz/device_tracker.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/homeassistant/components/fritz/device_tracker.py b/homeassistant/components/fritz/device_tracker.py index ab4deec96f7..d16fcbb3a1e 100644 --- a/homeassistant/components/fritz/device_tracker.py +++ b/homeassistant/components/fritz/device_tracker.py @@ -79,6 +79,14 @@ class FritzBoxScanner(DeviceScanner): return None return ret + 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") + + if not ip_device: + return None + return {"ip": ip_device, "mac": device} + def _update_info(self): """Retrieve latest information from the FRITZ!Box.""" if not self.success_init: