diff --git a/homeassistant/components/systemmonitor/sensor.py b/homeassistant/components/systemmonitor/sensor.py index 2a5f5a7b22b4ee..dea7d371b4b978 100644 --- a/homeassistant/components/systemmonitor/sensor.py +++ b/homeassistant/components/systemmonitor/sensor.py @@ -262,6 +262,7 @@ def _update_sensors() -> None: _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()