From 1a5706a693786f70d4a2a0b2d0c84aa642066e31 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 27 Jul 2024 03:14:40 -0500 Subject: [PATCH] Cache unifi device_tracker properties that never change (#122683) --- homeassistant/components/unifi/device_tracker.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/unifi/device_tracker.py b/homeassistant/components/unifi/device_tracker.py index a1014bfd184..800730f3b49 100644 --- a/homeassistant/components/unifi/device_tracker.py +++ b/homeassistant/components/unifi/device_tracker.py @@ -5,6 +5,7 @@ from __future__ import annotations from collections.abc import Callable, Mapping from dataclasses import dataclass from datetime import timedelta +from functools import cached_property import logging from typing import Any @@ -261,17 +262,17 @@ class UnifiScannerEntity(UnifiEntity[HandlerT, ApiItemT], ScannerEntity): """Return the primary ip address of the device.""" return self.entity_description.ip_address_fn(self.hub.api, self._obj_id) - @property + @cached_property def mac_address(self) -> str: """Return the mac address of the device.""" return self._obj_id - @property + @cached_property def source_type(self) -> SourceType: """Return the source type, eg gps or router, of the device.""" return SourceType.ROUTER - @property + @cached_property def unique_id(self) -> str: """Return a unique ID.""" return self._attr_unique_id