From 853e4d87fab1fecb9b7646736045384271d598af Mon Sep 17 00:00:00 2001 From: G Johansson Date: Fri, 29 Dec 2023 13:21:36 +0100 Subject: [PATCH] Handle no permission for disks in Systemmonitor (#106653) --- 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 2baacb9d16f..25b8aa2eb1d 100644 --- a/homeassistant/components/systemmonitor/util.py +++ b/homeassistant/components/systemmonitor/util.py @@ -18,7 +18,13 @@ def get_all_disk_mounts() -> set[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.add(part.mountpoint) _LOGGER.debug("Adding disks: %s", ", ".join(disks))