From ccd157dc26cb3b514a6708bb162b1ca9c7b87783 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Sun, 4 Aug 2024 23:03:40 +0200 Subject: [PATCH] Use coordinator setup method in filesize (#123139) --- homeassistant/components/filesize/coordinator.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/filesize/coordinator.py b/homeassistant/components/filesize/coordinator.py index 37fba19fb4e..c0dbb14555e 100644 --- a/homeassistant/components/filesize/coordinator.py +++ b/homeassistant/components/filesize/coordinator.py @@ -46,14 +46,15 @@ class FileSizeCoordinator(DataUpdateCoordinator[dict[str, int | float | datetime def _update(self) -> os.stat_result: """Fetch file information.""" - if not hasattr(self, "path"): - self.path = self._get_full_path() - try: return self.path.stat() except OSError as error: raise UpdateFailed(f"Can not retrieve file statistics {error}") from error + async def _async_setup(self) -> None: + """Set up path.""" + self.path = await self.hass.async_add_executor_job(self._get_full_path) + async def _async_update_data(self) -> dict[str, float | int | datetime]: """Fetch file information.""" statinfo = await self.hass.async_add_executor_job(self._update)