mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Only lookup hostname/ip_address/mac_address once in device_tracker (#96984)
This commit is contained in:
parent
b504665b56
commit
28ff173f16
@ -405,13 +405,13 @@ class ScannerEntity(BaseTrackerEntity):
|
|||||||
@property
|
@property
|
||||||
def state_attributes(self) -> dict[str, StateType]:
|
def state_attributes(self) -> dict[str, StateType]:
|
||||||
"""Return the device state attributes."""
|
"""Return the device state attributes."""
|
||||||
attr: dict[str, StateType] = {}
|
attr = super().state_attributes
|
||||||
attr.update(super().state_attributes)
|
|
||||||
if self.ip_address:
|
if ip_address := self.ip_address:
|
||||||
attr[ATTR_IP] = self.ip_address
|
attr[ATTR_IP] = ip_address
|
||||||
if self.mac_address is not None:
|
if (mac_address := self.mac_address) is not None:
|
||||||
attr[ATTR_MAC] = self.mac_address
|
attr[ATTR_MAC] = mac_address
|
||||||
if self.hostname is not None:
|
if (hostname := self.hostname) is not None:
|
||||||
attr[ATTR_HOST_NAME] = self.hostname
|
attr[ATTR_HOST_NAME] = hostname
|
||||||
|
|
||||||
return attr
|
return attr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user