From ec7b99022cc9c9d16cd78604ffe0da6233e0bcfe Mon Sep 17 00:00:00 2001 From: G Johansson Date: Fri, 29 Dec 2023 12:04:15 +0000 Subject: [PATCH] Handle no permission for disks in Systemmonitor --- homeassistant/components/systemmonitor/util.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/systemmonitor/util.py b/homeassistant/components/systemmonitor/util.py index 27c4c4496341a1..142bdbb3ad6a54 100644 --- a/homeassistant/components/systemmonitor/util.py +++ b/homeassistant/components/systemmonitor/util.py @@ -18,7 +18,13 @@ def get_all_disk_mounts() -> list[str]: # ENOENT, pop-up a Windows GUI error for a non-ready # partition or just hang. continue - usage = psutil.disk_usage(part.mountpoint) + try: + usage = psutil.disk_usage(part.mountpoint) + except PermissionError: + _LOGGER.debug( + "No permission for running user to access %s", part.mountpoint + ) + continue if usage.total > 0 and part.device != "": disks.append(part.mountpoint) _LOGGER.debug("Adding disks: %s", ", ".join(disks))