Cache unifi device_tracker properties that never change (#122683)

This commit is contained in:
J. Nick Koston 2024-07-27 03:14:40 -05:00 committed by GitHub
parent 13c320902e
commit 1a5706a693
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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