From 6d1cec6112bfadbc1e6e2090bee49bdce744052b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 16 Sep 2025 10:51:39 -0500 Subject: [PATCH 1/2] review --- esphome/core/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index 571ce9375f..2aa0fd7193 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -698,7 +698,7 @@ class EsphomeCore: def platformio_cache_dir(self) -> str: """Get the PlatformIO cache directory path.""" # Check if running in Docker/HA addon with custom cache dir - if cache_dir := os.environ.get("PLATFORMIO_CACHE_DIR"): + if (cache_dir := os.environ.get("PLATFORMIO_CACHE_DIR")) and cache_dir.strip(): return cache_dir # Default PlatformIO cache location return os.path.expanduser("~/.platformio/.cache") From cb733962251d198d2926e8771c2791fbaab3b699 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 16 Sep 2025 10:51:50 -0500 Subject: [PATCH 2/2] review --- tests/unit_tests/test_core.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unit_tests/test_core.py b/tests/unit_tests/test_core.py index b36bc8f4c0..4677140ad2 100644 --- a/tests/unit_tests/test_core.py +++ b/tests/unit_tests/test_core.py @@ -687,6 +687,14 @@ class TestEsphomeCore: expected = os.path.expanduser("~/.platformio/.cache") assert target.platformio_cache_dir == expected + def test_platformio_cache_dir_whitespace_env_var(self): + """Test platformio_cache_dir with whitespace-only env var falls back to default.""" + target = core.EsphomeCore() + + with patch.dict(os.environ, {"PLATFORMIO_CACHE_DIR": " "}): + expected = os.path.expanduser("~/.platformio/.cache") + assert target.platformio_cache_dir == expected + def test_platformio_cache_dir_docker_addon_path(self): """Test platformio_cache_dir in Docker/HA addon environment.""" target = core.EsphomeCore()