diff --git a/homeassistant/helpers/system_info.py b/homeassistant/helpers/system_info.py index ec8badaddc3..69e03904caa 100644 --- a/homeassistant/helpers/system_info.py +++ b/homeassistant/helpers/system_info.py @@ -15,9 +15,12 @@ from homeassistant.loader import bind_hass from homeassistant.util.package import is_docker_env, is_virtual_env from .importlib import async_import_module +from .singleton import singleton _LOGGER = logging.getLogger(__name__) +_DATA_MAC_VER = "system_info_mac_ver" + @cache def is_official_image() -> bool: @@ -25,6 +28,12 @@ def is_official_image() -> bool: return os.path.isfile("/OFFICIAL_IMAGE") +@singleton(_DATA_MAC_VER) +async def async_get_mac_ver(hass: HomeAssistant) -> str: + """Return the macOS version.""" + return (await hass.async_add_executor_job(platform.mac_ver))[0] + + # Cache the result of getuser() because it can call getpwuid() which # can do blocking I/O to look up the username in /etc/passwd. cached_get_user = cache(getuser) @@ -65,7 +74,7 @@ async def async_get_system_info(hass: HomeAssistant) -> dict[str, Any]: info_object["user"] = None if platform.system() == "Darwin": - info_object["os_version"] = platform.mac_ver()[0] + info_object["os_version"] = await async_get_mac_ver(hass) elif platform.system() == "Linux": info_object["docker"] = is_docker_env()