mirror of
https://github.com/esphome/esphome.git
synced 2025-10-03 18:42:23 +01:00
Merge remote-tracking branch 'upstream/dev' into integration
This commit is contained in:
@@ -1173,7 +1173,9 @@ def parse_args(argv):
|
|||||||
"configuration", help="Your YAML configuration file(s).", nargs="+"
|
"configuration", help="Your YAML configuration file(s).", nargs="+"
|
||||||
)
|
)
|
||||||
|
|
||||||
parser_clean_all = subparsers.add_parser("clean-all", help="Clean all files.")
|
parser_clean_all = subparsers.add_parser(
|
||||||
|
"clean-all", help="Clean all build and platform files."
|
||||||
|
)
|
||||||
parser_clean_all.add_argument(
|
parser_clean_all.add_argument(
|
||||||
"configuration", help="Your YAML configuration directory.", nargs="*"
|
"configuration", help="Your YAML configuration directory.", nargs="*"
|
||||||
)
|
)
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "cover.h"
|
#include "cover.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace cover {
|
namespace cover {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "valve.h"
|
#include "valve.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace valve {
|
namespace valve {
|
||||||
|
@@ -242,7 +242,6 @@ void VoiceAssistant::loop() {
|
|||||||
msg.flags = flags;
|
msg.flags = flags;
|
||||||
msg.audio_settings = audio_settings;
|
msg.audio_settings = audio_settings;
|
||||||
msg.set_wake_word_phrase(StringRef(this->wake_word_));
|
msg.set_wake_word_phrase(StringRef(this->wake_word_));
|
||||||
this->wake_word_ = "";
|
|
||||||
|
|
||||||
// Reset media player state tracking
|
// Reset media player state tracking
|
||||||
#ifdef USE_MEDIA_PLAYER
|
#ifdef USE_MEDIA_PLAYER
|
||||||
|
@@ -340,10 +340,15 @@ def clean_all(configuration: list[str]):
|
|||||||
|
|
||||||
# Clean entire build dir
|
# Clean entire build dir
|
||||||
for dir in configuration:
|
for dir in configuration:
|
||||||
buid_dir = Path(dir) / ".esphome"
|
build_dir = Path(dir) / ".esphome"
|
||||||
if buid_dir.is_dir():
|
if build_dir.is_dir():
|
||||||
_LOGGER.info("Deleting %s", buid_dir)
|
_LOGGER.info("Cleaning %s", build_dir)
|
||||||
shutil.rmtree(buid_dir)
|
# Don't remove storage as it will cause the dashboard to regenerate all configs
|
||||||
|
for item in build_dir.iterdir():
|
||||||
|
if item.is_file():
|
||||||
|
item.unlink()
|
||||||
|
elif item.name != "storage" and item.is_dir():
|
||||||
|
shutil.rmtree(item)
|
||||||
|
|
||||||
# Clean PlatformIO project files
|
# Clean PlatformIO project files
|
||||||
try:
|
try:
|
||||||
|
@@ -12,7 +12,7 @@ platformio==6.1.18 # When updating platformio, also update /docker/Dockerfile
|
|||||||
esptool==5.1.0
|
esptool==5.1.0
|
||||||
click==8.1.7
|
click==8.1.7
|
||||||
esphome-dashboard==20250904.0
|
esphome-dashboard==20250904.0
|
||||||
aioesphomeapi==41.10.0
|
aioesphomeapi==41.11.0
|
||||||
zeroconf==0.147.2
|
zeroconf==0.147.2
|
||||||
puremagic==1.30
|
puremagic==1.30
|
||||||
ruamel.yaml==0.18.15 # dashboard_import
|
ruamel.yaml==0.18.15 # dashboard_import
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
1
tests/components/analog_threshold/test.nrf52-mcumgr.yaml
Normal file
1
tests/components/analog_threshold/test.nrf52-mcumgr.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
1
tests/components/bang_bang/test.nrf52-adafruit.yaml
Normal file
1
tests/components/bang_bang/test.nrf52-adafruit.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
1
tests/components/bang_bang/test.nrf52-mcumgr.yaml
Normal file
1
tests/components/bang_bang/test.nrf52-mcumgr.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
1
tests/components/restart/test.nrf52-adafruit.yaml
Normal file
1
tests/components/restart/test.nrf52-adafruit.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
1
tests/components/restart/test.nrf52-mcumgr.yaml
Normal file
1
tests/components/restart/test.nrf52-mcumgr.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
1
tests/components/script/test.nrf52-adafruit.yaml
Normal file
1
tests/components/script/test.nrf52-adafruit.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
1
tests/components/script/test.nrf52-mcumgr.yaml
Normal file
1
tests/components/script/test.nrf52-mcumgr.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
1
tests/components/sprinkler/test.nrf52-adafruit.yaml
Normal file
1
tests/components/sprinkler/test.nrf52-adafruit.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
1
tests/components/sprinkler/test.nrf52-mcumgr.yaml
Normal file
1
tests/components/sprinkler/test.nrf52-mcumgr.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
@@ -341,6 +341,7 @@ datetime:
|
|||||||
|
|
||||||
time:
|
time:
|
||||||
- platform: sntp # Required for datetime
|
- platform: sntp # Required for datetime
|
||||||
|
id: sntp_time
|
||||||
|
|
||||||
wifi: # Required for sntp time
|
wifi: # Required for sntp time
|
||||||
ap:
|
ap:
|
||||||
|
6
tests/components/template/test.nrf52-adafruit.yaml
Normal file
6
tests/components/template/test.nrf52-adafruit.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
packages: !include common.yaml
|
||||||
|
|
||||||
|
time:
|
||||||
|
- id: !remove sntp_time
|
||||||
|
|
||||||
|
wifi: !remove
|
6
tests/components/template/test.nrf52-mcumgr.yaml
Normal file
6
tests/components/template/test.nrf52-mcumgr.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
packages: !include common.yaml
|
||||||
|
|
||||||
|
time:
|
||||||
|
- id: !remove sntp_time
|
||||||
|
|
||||||
|
wifi: !remove
|
1
tests/components/thermostat/test.nrf52-adafruit.yaml
Normal file
1
tests/components/thermostat/test.nrf52-adafruit.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
1
tests/components/thermostat/test.nrf52-mcumgr.yaml
Normal file
1
tests/components/thermostat/test.nrf52-mcumgr.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<<: !include common.yaml
|
@@ -791,16 +791,21 @@ def test_clean_all(
|
|||||||
with caplog.at_level("INFO"):
|
with caplog.at_level("INFO"):
|
||||||
clean_all([str(config1_dir), str(config2_dir)])
|
clean_all([str(config1_dir), str(config2_dir)])
|
||||||
|
|
||||||
# Verify deletions
|
# Verify deletions - .esphome directories remain but contents are cleaned
|
||||||
assert not build_dir1.exists()
|
# The .esphome directory itself is not removed because it may contain storage
|
||||||
assert not build_dir2.exists()
|
assert build_dir1.exists()
|
||||||
|
assert build_dir2.exists()
|
||||||
|
|
||||||
|
# Verify that files in .esphome were removed
|
||||||
|
assert not (build_dir1 / "dummy.txt").exists()
|
||||||
|
assert not (build_dir2 / "dummy.txt").exists()
|
||||||
assert not pio_cache.exists()
|
assert not pio_cache.exists()
|
||||||
assert not pio_packages.exists()
|
assert not pio_packages.exists()
|
||||||
assert not pio_platforms.exists()
|
assert not pio_platforms.exists()
|
||||||
assert not pio_core.exists()
|
assert not pio_core.exists()
|
||||||
|
|
||||||
# Verify logging mentions each
|
# Verify logging mentions each
|
||||||
assert "Deleting" in caplog.text
|
assert "Cleaning" in caplog.text
|
||||||
assert str(build_dir1) in caplog.text
|
assert str(build_dir1) in caplog.text
|
||||||
assert str(build_dir2) in caplog.text
|
assert str(build_dir2) in caplog.text
|
||||||
assert "PlatformIO cache" in caplog.text
|
assert "PlatformIO cache" in caplog.text
|
||||||
@@ -809,6 +814,55 @@ def test_clean_all(
|
|||||||
assert "PlatformIO core" in caplog.text
|
assert "PlatformIO core" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
|
@patch("esphome.writer.CORE")
|
||||||
|
def test_clean_all_preserves_storage(
|
||||||
|
mock_core: MagicMock,
|
||||||
|
tmp_path: Path,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
) -> None:
|
||||||
|
"""Test clean_all preserves storage directory."""
|
||||||
|
# Create build directory with storage subdirectory
|
||||||
|
config_dir = tmp_path / "config"
|
||||||
|
config_dir.mkdir()
|
||||||
|
|
||||||
|
build_dir = config_dir / ".esphome"
|
||||||
|
build_dir.mkdir()
|
||||||
|
(build_dir / "dummy.txt").write_text("x")
|
||||||
|
(build_dir / "other_file.txt").write_text("y")
|
||||||
|
|
||||||
|
# Create storage directory with content
|
||||||
|
storage_dir = build_dir / "storage"
|
||||||
|
storage_dir.mkdir()
|
||||||
|
(storage_dir / "storage.json").write_text('{"test": "data"}')
|
||||||
|
(storage_dir / "other_storage.txt").write_text("storage content")
|
||||||
|
|
||||||
|
# Call clean_all
|
||||||
|
from esphome.writer import clean_all
|
||||||
|
|
||||||
|
with caplog.at_level("INFO"):
|
||||||
|
clean_all([str(config_dir)])
|
||||||
|
|
||||||
|
# Verify .esphome directory still exists
|
||||||
|
assert build_dir.exists()
|
||||||
|
|
||||||
|
# Verify storage directory still exists with its contents
|
||||||
|
assert storage_dir.exists()
|
||||||
|
assert (storage_dir / "storage.json").exists()
|
||||||
|
assert (storage_dir / "other_storage.txt").exists()
|
||||||
|
|
||||||
|
# Verify storage contents are intact
|
||||||
|
assert (storage_dir / "storage.json").read_text() == '{"test": "data"}'
|
||||||
|
assert (storage_dir / "other_storage.txt").read_text() == "storage content"
|
||||||
|
|
||||||
|
# Verify other files were removed
|
||||||
|
assert not (build_dir / "dummy.txt").exists()
|
||||||
|
assert not (build_dir / "other_file.txt").exists()
|
||||||
|
|
||||||
|
# Verify logging mentions deletion
|
||||||
|
assert "Cleaning" in caplog.text
|
||||||
|
assert str(build_dir) in caplog.text
|
||||||
|
|
||||||
|
|
||||||
@patch("esphome.writer.CORE")
|
@patch("esphome.writer.CORE")
|
||||||
def test_clean_all_platformio_not_available(
|
def test_clean_all_platformio_not_available(
|
||||||
mock_core: MagicMock,
|
mock_core: MagicMock,
|
||||||
@@ -834,8 +888,8 @@ def test_clean_all_platformio_not_available(
|
|||||||
):
|
):
|
||||||
clean_all([str(config_dir)])
|
clean_all([str(config_dir)])
|
||||||
|
|
||||||
# Build dir removed, PlatformIO dirs remain
|
# Build dir contents cleaned, PlatformIO dirs remain
|
||||||
assert not build_dir.exists()
|
assert build_dir.exists()
|
||||||
assert pio_cache.exists()
|
assert pio_cache.exists()
|
||||||
|
|
||||||
# No PlatformIO-specific logs
|
# No PlatformIO-specific logs
|
||||||
@@ -867,4 +921,68 @@ def test_clean_all_partial_exists(
|
|||||||
|
|
||||||
clean_all([str(config_dir)])
|
clean_all([str(config_dir)])
|
||||||
|
|
||||||
assert not build_dir.exists()
|
assert build_dir.exists()
|
||||||
|
|
||||||
|
|
||||||
|
@patch("esphome.writer.CORE")
|
||||||
|
def test_clean_all_removes_non_storage_directories(
|
||||||
|
mock_core: MagicMock,
|
||||||
|
tmp_path: Path,
|
||||||
|
caplog: pytest.LogCaptureFixture,
|
||||||
|
) -> None:
|
||||||
|
"""Test clean_all removes directories other than storage."""
|
||||||
|
# Create build directory with various subdirectories
|
||||||
|
config_dir = tmp_path / "config"
|
||||||
|
config_dir.mkdir()
|
||||||
|
|
||||||
|
build_dir = config_dir / ".esphome"
|
||||||
|
build_dir.mkdir()
|
||||||
|
|
||||||
|
# Create files
|
||||||
|
(build_dir / "file1.txt").write_text("content1")
|
||||||
|
(build_dir / "file2.txt").write_text("content2")
|
||||||
|
|
||||||
|
# Create storage directory (should be preserved)
|
||||||
|
storage_dir = build_dir / "storage"
|
||||||
|
storage_dir.mkdir()
|
||||||
|
(storage_dir / "storage.json").write_text('{"test": "data"}')
|
||||||
|
|
||||||
|
# Create other directories (should be removed)
|
||||||
|
cache_dir = build_dir / "cache"
|
||||||
|
cache_dir.mkdir()
|
||||||
|
(cache_dir / "cache_file.txt").write_text("cache content")
|
||||||
|
|
||||||
|
logs_dir = build_dir / "logs"
|
||||||
|
logs_dir.mkdir()
|
||||||
|
(logs_dir / "log1.txt").write_text("log content")
|
||||||
|
|
||||||
|
temp_dir = build_dir / "temp"
|
||||||
|
temp_dir.mkdir()
|
||||||
|
(temp_dir / "temp_file.txt").write_text("temp content")
|
||||||
|
|
||||||
|
# Call clean_all
|
||||||
|
from esphome.writer import clean_all
|
||||||
|
|
||||||
|
with caplog.at_level("INFO"):
|
||||||
|
clean_all([str(config_dir)])
|
||||||
|
|
||||||
|
# Verify .esphome directory still exists
|
||||||
|
assert build_dir.exists()
|
||||||
|
|
||||||
|
# Verify storage directory and its contents are preserved
|
||||||
|
assert storage_dir.exists()
|
||||||
|
assert (storage_dir / "storage.json").exists()
|
||||||
|
assert (storage_dir / "storage.json").read_text() == '{"test": "data"}'
|
||||||
|
|
||||||
|
# Verify files were removed
|
||||||
|
assert not (build_dir / "file1.txt").exists()
|
||||||
|
assert not (build_dir / "file2.txt").exists()
|
||||||
|
|
||||||
|
# Verify non-storage directories were removed
|
||||||
|
assert not cache_dir.exists()
|
||||||
|
assert not logs_dir.exists()
|
||||||
|
assert not temp_dir.exists()
|
||||||
|
|
||||||
|
# Verify logging mentions cleaning
|
||||||
|
assert "Cleaning" in caplog.text
|
||||||
|
assert str(build_dir) in caplog.text
|
||||||
|
Reference in New Issue
Block a user