From 5be1eacde9873863605c383589644d935f685a17 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Wed, 7 Apr 2021 12:08:22 +0200 Subject: [PATCH] Set AsusWRT mac_address and ip_address properties (#48764) --- .../components/asuswrt/device_tracker.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/asuswrt/device_tracker.py b/homeassistant/components/asuswrt/device_tracker.py index bd86dd21edd..0db5dba0b17 100644 --- a/homeassistant/components/asuswrt/device_tracker.py +++ b/homeassistant/components/asuswrt/device_tracker.py @@ -81,16 +81,23 @@ class AsusWrtDevice(ScannerEntity): @property def extra_state_attributes(self) -> dict[str, any]: """Return the attributes.""" - attrs = { - "mac": self._device.mac, - "ip_address": self._device.ip_address, - } + attrs = {} if self._device.last_activity: attrs["last_time_reachable"] = self._device.last_activity.isoformat( timespec="seconds" ) return attrs + @property + def ip_address(self) -> str: + """Return the primary ip address of the device.""" + return self._device.ip_address + + @property + def mac_address(self) -> str: + """Return the mac address of the device.""" + return self._device.mac + @property def device_info(self) -> dict[str, any]: """Return the device information."""