mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix systemmonitor IP address look-up logic (#48740)
This commit is contained in:
parent
fb1444c414
commit
030e9d314d
@ -262,6 +262,7 @@ async def async_setup_sensor_registry_updates(
|
||||
_swap_memory.cache_clear()
|
||||
_virtual_memory.cache_clear()
|
||||
_net_io_counters.cache_clear()
|
||||
_net_if_addrs.cache_clear()
|
||||
_getloadavg.cache_clear()
|
||||
|
||||
async def _async_update_data(*_: Any) -> None:
|
||||
@ -439,7 +440,7 @@ def _update(
|
||||
else:
|
||||
state = None
|
||||
elif type_ in ["ipv4_address", "ipv6_address"]:
|
||||
addresses = _net_io_counters()
|
||||
addresses = _net_if_addrs()
|
||||
if data.argument in addresses:
|
||||
for addr in addresses[data.argument]:
|
||||
if addr.family == IF_ADDRS_FAMILY[type_]:
|
||||
@ -484,6 +485,11 @@ def _net_io_counters() -> Any:
|
||||
return psutil.net_io_counters(pernic=True)
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def _net_if_addrs() -> Any:
|
||||
return psutil.net_if_addrs()
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def _getloadavg() -> tuple[float, float, float]:
|
||||
return os.getloadavg()
|
||||
|
Loading…
x
Reference in New Issue
Block a user