From cfe5d73d8b195846486181598e427f8f893231f9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 19:03:41 +0000 Subject: [PATCH 1/4] Initial plan From b057793c25f37d8a76781637f5e095425c8ea082 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 19:06:25 +0000 Subject: [PATCH 2/4] fix: use aiofiles for non-blocking file writes (v1.2.6) Co-authored-by: Geek-MD <25725990+Geek-MD@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ custom_components/advanced_downloader/__init__.py | 5 +++-- custom_components/advanced_downloader/manifest.json | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f28cd17..4bd0e30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- +## [1.2.6] - 2026-03-18 + +### Fixed +- **Blocking `open()` call inside the event loop:** replaced the synchronous `open(tmp_path, "wb")` used during chunk-writing with `aiofiles.open()` so that file I/O is no longer performed on the event-loop thread. This resolves the `homeassistant.util.loop` warning *"Detected blocking call to open … inside the event loop"*. `aiofiles>=23.1.0` has been added as a runtime requirement. + +--- + ## [1.2.5] - 2026-03-11 ### Changed @@ -236,6 +243,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Service `media_downloader.download_file` with optional subdirectories, custom filenames, overwrite control, and per-download timeout. - Events: `media_downloader_download_started`, `media_downloader_download_completed` (with `success` and `error` fields). +[1.2.6]: https://github.com/Geek-MD/Advanced_Downloader/compare/v1.2.5...v1.2.6 [1.2.5]: https://github.com/Geek-MD/Advanced_Downloader/compare/v1.2.4...v1.2.5 [1.2.4]: https://github.com/Geek-MD/Advanced_Downloader/compare/v1.2.3...v1.2.4 [1.2.3]: https://github.com/Geek-MD/Advanced_Downloader/compare/v1.2.2...v1.2.3 diff --git a/custom_components/advanced_downloader/__init__.py b/custom_components/advanced_downloader/__init__.py index 78d14d7..7bb597c 100644 --- a/custom_components/advanced_downloader/__init__.py +++ b/custom_components/advanced_downloader/__init__.py @@ -4,6 +4,7 @@ import os import sys +import aiofiles import aiohttp import logging from pathlib import Path @@ -186,10 +187,10 @@ async def _async_download(call: ServiceCall) -> None: async with session.get(url) as resp: if resp.status != 200: raise HomeAssistantError(f"HTTP error {resp.status}: {url}") - with open(tmp_path, "wb") as f: + async with aiofiles.open(tmp_path, "wb") as f: async for chunk in resp.content.iter_chunked(1024 * 64): if chunk: - f.write(chunk) + await f.write(chunk) if dest_path.exists() and not do_overwrite: raise HomeAssistantError(f"File exists and overwrite is False: {dest_path}") diff --git a/custom_components/advanced_downloader/manifest.json b/custom_components/advanced_downloader/manifest.json index 1d9db59..a713a33 100644 --- a/custom_components/advanced_downloader/manifest.json +++ b/custom_components/advanced_downloader/manifest.json @@ -8,6 +8,6 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/Geek-MD/Advanced_Downloader/issues", "quality_scale": "legacy", - "requirements": [], - "version": "1.2.5" + "requirements": ["aiofiles>=23.1.0"], + "version": "1.2.6" } From e43d682d837888defd80e2e2a475a3b16639afc1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 19:15:28 +0000 Subject: [PATCH 3/4] fix: add types-aiofiles to requirements.txt to resolve mypy import-untyped error Co-authored-by: Geek-MD <25725990+Geek-MD@users.noreply.github.com> --- =23.1.0 | 0 requirements.txt | 1 + 2 files changed, 1 insertion(+) create mode 100644 =23.1.0 diff --git a/=23.1.0 b/=23.1.0 new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt index 5272d71..9e6b192 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ mypy==1.10.0 ruff==0.14.3 pytest==8.3.2 voluptuous==0.15.2 +types-aiofiles>=23.1.0 From 3bb8feed23bb65242b4e66e795aa7d4b49a2a3ec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 18 Mar 2026 19:15:43 +0000 Subject: [PATCH 4/4] chore: remove stray =23.1.0 file accidentally created during dev Co-authored-by: Geek-MD <25725990+Geek-MD@users.noreply.github.com> --- =23.1.0 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 =23.1.0 diff --git a/=23.1.0 b/=23.1.0 deleted file mode 100644 index e69de29..0000000