1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-21 04:32:23 +01:00

Ensure components only powerdown after teardown (#9044)

This commit is contained in:
J. Nick Koston
2025-06-10 23:21:22 -05:00
committed by GitHub
parent ad37f103fa
commit 0e27ac281f
9 changed files with 22 additions and 5 deletions

View File

@@ -169,6 +169,7 @@ void Application::safe_reboot() {
ESP_LOGI(TAG, "Rebooting safely");
run_safe_shutdown_hooks();
teardown_components(TEARDOWN_TIMEOUT_REBOOT_MS);
run_powerdown_hooks();
arch_restart();
}
@@ -181,6 +182,12 @@ void Application::run_safe_shutdown_hooks() {
}
}
void Application::run_powerdown_hooks() {
for (auto it = this->components_.rbegin(); it != this->components_.rend(); ++it) {
(*it)->on_powerdown();
}
}
void Application::teardown_components(uint32_t timeout_ms) {
uint32_t start_time = millis();