From 653318479ac10b1790aac46227b92f4308492136 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 27 Feb 2025 17:56:55 +0000 Subject: [PATCH 1/5] Fix end_of_scan_ not being called while disconnecting (#8328) --- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp index 5fff9dbcad..760aac628a 100644 --- a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +++ b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp @@ -176,9 +176,9 @@ void ESP32BLETracker::loop() { https://github.com/espressif/esp-idf/issues/6688 */ - if (!connecting && !disconnecting && xSemaphoreTake(this->scan_end_lock_, 0L)) { + if (!connecting && xSemaphoreTake(this->scan_end_lock_, 0L)) { if (this->scan_continuous_) { - if (!promote_to_connecting && !this->scan_start_failed_ && !this->scan_set_param_failed_) { + if (!disconnecting && !promote_to_connecting && !this->scan_start_failed_ && !this->scan_set_param_failed_) { this->start_scan_(false); } else { // We didn't start the scan, so we need to release the lock From 19d938ce48454d19ca231e3dd708c47fad1a2a7d Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Thu, 27 Feb 2025 16:43:51 -0600 Subject: [PATCH 2/5] [audio] Determine http timeout based on duration since last successful read (#8341) --- esphome/components/audio/audio_reader.cpp | 14 +++++++------- esphome/components/audio/audio_reader.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/esphome/components/audio/audio_reader.cpp b/esphome/components/audio/audio_reader.cpp index b93e4e74ea..90b73a1f46 100644 --- a/esphome/components/audio/audio_reader.cpp +++ b/esphome/components/audio/audio_reader.cpp @@ -15,6 +15,8 @@ namespace audio { static const uint32_t READ_WRITE_TIMEOUT_MS = 20; +static const uint32_t CONNECTION_TIMEOUT_MS = 5000; + // The number of times the http read times out with no data before throwing an error static const uint32_t ERROR_COUNT_NO_DATA_READ_TIMEOUT = 100; @@ -97,7 +99,7 @@ esp_err_t AudioReader::start(const std::string &uri, AudioFileType &file_type) { client_config.user_data = this; client_config.buffer_size = HTTP_STREAM_BUFFER_SIZE; client_config.keep_alive_enable = true; - client_config.timeout_ms = 5000; // Shouldn't trigger watchdog resets if caller runs in a task + client_config.timeout_ms = CONNECTION_TIMEOUT_MS; // Shouldn't trigger watchdog resets if caller runs in a task #if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE if (uri.find("https:") != std::string::npos) { @@ -189,7 +191,7 @@ esp_err_t AudioReader::start(const std::string &uri, AudioFileType &file_type) { file_type = this->audio_file_type_; } - this->no_data_read_count_ = 0; + this->last_data_read_ms_ = millis(); this->output_transfer_buffer_ = AudioSinkTransferBuffer::create(this->buffer_size_); if (this->output_transfer_buffer_ == nullptr) { @@ -271,8 +273,7 @@ AudioReaderState AudioReader::http_read_() { if (received_len > 0) { this->output_transfer_buffer_->increase_buffer_length(received_len); - - this->no_data_read_count_ = 0; + this->last_data_read_ms_ = millis(); } else if (received_len < 0) { // HTTP read error this->cleanup_connection_(); @@ -280,12 +281,11 @@ AudioReaderState AudioReader::http_read_() { } else { if (bytes_to_read > 0) { // Read timed out - ++this->no_data_read_count_; - if (this->no_data_read_count_ >= ERROR_COUNT_NO_DATA_READ_TIMEOUT) { - // Timed out with no data read too many times, so the http read has failed + if ((millis() - this->last_data_read_ms_) > CONNECTION_TIMEOUT_MS) { this->cleanup_connection_(); return AudioReaderState::FAILED; } + delay(READ_WRITE_TIMEOUT_MS); } } diff --git a/esphome/components/audio/audio_reader.h b/esphome/components/audio/audio_reader.h index 90113e6dda..3fdc3c3ff2 100644 --- a/esphome/components/audio/audio_reader.h +++ b/esphome/components/audio/audio_reader.h @@ -71,7 +71,7 @@ class AudioReader { void cleanup_connection_(); size_t buffer_size_; - uint32_t no_data_read_count_; + uint32_t last_data_read_ms_; esp_http_client_handle_t client_{nullptr}; From 903d033e0f11f58ed9da8c5160de606fc1c385fb Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 2 Mar 2025 19:35:32 -0700 Subject: [PATCH 3/5] Bump aioesphomeapi to 29.3.2 (#8353) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 44e7669fdb..2aef8b34f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ platformio==6.1.16 # When updating platformio, also update Dockerfile esptool==4.7.0 click==8.1.7 esphome-dashboard==20250212.0 -aioesphomeapi==29.1.1 +aioesphomeapi==29.3.2 zeroconf==0.145.1 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import From db666e44a7756f50d60202ac84019bc9a338eab6 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 3 Mar 2025 15:35:52 +1300 Subject: [PATCH 4/5] [ltr390] Move calculation to allow dynamic setting of gain and resolution (#8343) --- esphome/components/ltr390/ltr390.cpp | 14 +++++++------- esphome/components/ltr390/ltr390.h | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/esphome/components/ltr390/ltr390.cpp b/esphome/components/ltr390/ltr390.cpp index 198d15ebd8..84b2eba2de 100644 --- a/esphome/components/ltr390/ltr390.cpp +++ b/esphome/components/ltr390/ltr390.cpp @@ -1,7 +1,7 @@ #include "ltr390.h" +#include #include "esphome/core/hal.h" #include "esphome/core/log.h" -#include namespace esphome { namespace ltr390 { @@ -91,7 +91,12 @@ void LTR390Component::read_uvs_() { uint32_t uv = *val; if (this->uvi_sensor_ != nullptr) { - this->uvi_sensor_->publish_state((uv / this->sensitivity_uv_) * this->wfac_); + // Set sensitivity by linearly scaling against known value in the datasheet + float gain_scale_uv = GAINVALUES[this->gain_uv_] / GAIN_MAX; + float intg_scale_uv = (RESOLUTIONVALUE[this->res_uv_] * 100) / INTG_MAX; + float sensitivity_uv = SENSITIVITY_MAX * gain_scale_uv * intg_scale_uv; + + this->uvi_sensor_->publish_state((uv / sensitivity_uv) * this->wfac_); } if (this->uv_sensor_ != nullptr) { @@ -166,11 +171,6 @@ void LTR390Component::setup() { return; } - // Set sensitivity by linearly scaling against known value in the datasheet - float gain_scale_uv = GAINVALUES[this->gain_uv_] / GAIN_MAX; - float intg_scale_uv = (RESOLUTIONVALUE[this->res_uv_] * 100) / INTG_MAX; - this->sensitivity_uv_ = SENSITIVITY_MAX * gain_scale_uv * intg_scale_uv; - // Set sensor read state this->reading_ = false; diff --git a/esphome/components/ltr390/ltr390.h b/esphome/components/ltr390/ltr390.h index 24afd3c411..7359cbd336 100644 --- a/esphome/components/ltr390/ltr390.h +++ b/esphome/components/ltr390/ltr390.h @@ -77,7 +77,6 @@ class LTR390Component : public PollingComponent, public i2c::I2CDevice { LTR390GAIN gain_uv_; LTR390RESOLUTION res_als_; LTR390RESOLUTION res_uv_; - float sensitivity_uv_; float wfac_; sensor::Sensor *light_sensor_{nullptr}; From 7b8e68c73a93f5c85c1c5515bcc4c646d60d726a Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 3 Mar 2025 17:15:40 +1300 Subject: [PATCH 5/5] Bump version to 2025.2.2 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 8230be7d57..cc26600860 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.1" +__version__ = "2025.2.2" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = (