Only lookup hostname/ip_address/mac_address once in device_tracker (#96984)
This commit is contained in:
parent
b504665b56
commit
28ff173f16
1 changed files with 8 additions and 8 deletions
|
@ -405,13 +405,13 @@ class ScannerEntity(BaseTrackerEntity):
|
|||
@property
|
||||
def state_attributes(self) -> dict[str, StateType]:
|
||||
"""Return the device state attributes."""
|
||||
attr: dict[str, StateType] = {}
|
||||
attr.update(super().state_attributes)
|
||||
if self.ip_address:
|
||||
attr[ATTR_IP] = self.ip_address
|
||||
if self.mac_address is not None:
|
||||
attr[ATTR_MAC] = self.mac_address
|
||||
if self.hostname is not None:
|
||||
attr[ATTR_HOST_NAME] = self.hostname
|
||||
attr = super().state_attributes
|
||||
|
||||
if ip_address := self.ip_address:
|
||||
attr[ATTR_IP] = ip_address
|
||||
if (mac_address := self.mac_address) is not None:
|
||||
attr[ATTR_MAC] = mac_address
|
||||
if (hostname := self.hostname) is not None:
|
||||
attr[ATTR_HOST_NAME] = hostname
|
||||
|
||||
return attr
|
||||
|
|
Loading…
Add table
Reference in a new issue