From a21dab334c48da775189085d7206fe88ecdaa3a5 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 21 Jun 2024 13:09:00 +1200 Subject: [PATCH 01/10] [core] Fix package merging with lists of primitives (#6952) --- esphome/config_helpers.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/esphome/config_helpers.py b/esphome/config_helpers.py index b5e0b26143..54242bc259 100644 --- a/esphome/config_helpers.py +++ b/esphome/config_helpers.py @@ -58,17 +58,21 @@ def merge_config(full_old, full_new): ids = { v_id: i for i, v in enumerate(res) - if (v_id := v.get(CONF_ID)) and isinstance(v_id, str) + if isinstance(v, dict) + and (v_id := v.get(CONF_ID)) + and isinstance(v_id, str) } extend_ids = { v_id.value: i for i, v in enumerate(res) - if (v_id := v.get(CONF_ID)) and isinstance(v_id, Extend) + if isinstance(v, dict) + and (v_id := v.get(CONF_ID)) + and isinstance(v_id, Extend) } ids_to_delete = [] for v in new: - if new_id := v.get(CONF_ID): + if isinstance(v, dict) and (new_id := v.get(CONF_ID)): if isinstance(new_id, Extend): new_id = new_id.value if new_id in ids: From 7dbc20b776c56c6cce910e25fe6f12871e9d9b47 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:59:52 +1200 Subject: [PATCH 02/10] [update] Set entity_category to config & Publish state to logs (#6954) --- esphome/components/update/__init__.py | 5 ++++ esphome/components/update/update_entity.cpp | 26 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/esphome/components/update/__init__.py b/esphome/components/update/__init__.py index ea1cf778b6..20a9373a06 100644 --- a/esphome/components/update/__init__.py +++ b/esphome/components/update/__init__.py @@ -4,11 +4,13 @@ import esphome.config_validation as cv import esphome.codegen as cg from esphome.const import ( CONF_DEVICE_CLASS, + CONF_ENTITY_CATEGORY, CONF_ID, CONF_MQTT_ID, CONF_WEB_SERVER_ID, DEVICE_CLASS_EMPTY, DEVICE_CLASS_FIRMWARE, + ENTITY_CATEGORY_CONFIG, ) from esphome.core import CORE, coroutine_with_priority from esphome.cpp_helpers import setup_entity @@ -41,6 +43,9 @@ UPDATE_SCHEMA = ( cv.Optional(CONF_ON_UPDATE_AVAILABLE): automation.validate_automation( single=True ), + cv.Optional( + CONF_ENTITY_CATEGORY, default=ENTITY_CATEGORY_CONFIG + ): cv.entity_category, } ) ) diff --git a/esphome/components/update/update_entity.cpp b/esphome/components/update/update_entity.cpp index 501cb6635f..ed9a0480d8 100644 --- a/esphome/components/update/update_entity.cpp +++ b/esphome/components/update/update_entity.cpp @@ -1,9 +1,35 @@ #include "update_entity.h" +#include "esphome/core/log.h" + namespace esphome { namespace update { +static const char *const TAG = "update"; + void UpdateEntity::publish_state() { + ESP_LOGD(TAG, "'%s' - Publishing:", this->name_.c_str()); + ESP_LOGD(TAG, " Current Version: %s", this->update_info_.current_version.c_str()); + + if (!this->update_info_.md5.empty()) { + ESP_LOGD(TAG, " Latest Version: %s", this->update_info_.latest_version.c_str()); + } + if (!this->update_info_.firmware_url.empty()) { + ESP_LOGD(TAG, " Firmware URL: %s", this->update_info_.firmware_url.c_str()); + } + + ESP_LOGD(TAG, " Title: %s", this->update_info_.title.c_str()); + if (!this->update_info_.summary.empty()) { + ESP_LOGD(TAG, " Summary: %s", this->update_info_.summary.c_str()); + } + if (!this->update_info_.release_url.empty()) { + ESP_LOGD(TAG, " Release URL: %s", this->update_info_.release_url.c_str()); + } + + if (this->update_info_.has_progress) { + ESP_LOGD(TAG, " Progress: %.0f%%", this->update_info_.progress); + } + this->has_state_ = true; this->state_callback_.call(); } From ae2962259ec004777ecfb96cd409bba85b56e0d4 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Fri, 21 Jun 2024 17:18:43 -0400 Subject: [PATCH 03/10] Fix infinite loop in http_request for ESP-IDF. (#6963) --- esphome/components/http_request/http_request_idf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/http_request/http_request_idf.cpp b/esphome/components/http_request/http_request_idf.cpp index 138e0438f4..d6fac7a133 100644 --- a/esphome/components/http_request/http_request_idf.cpp +++ b/esphome/components/http_request/http_request_idf.cpp @@ -90,7 +90,7 @@ std::shared_ptr HttpRequestIDF::start(std::string url, std::strin int write_left = body_len; int write_index = 0; const char *buf = body.c_str(); - while (body_len > 0) { + while (write_left > 0) { int written = esp_http_client_write(client, buf + write_index, write_left); if (written < 0) { err = ESP_FAIL; From 96d63de292eba3fa4c6c820faf1b482e0fff205e Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Fri, 21 Jun 2024 17:28:11 -0400 Subject: [PATCH 04/10] ESP-IDF 4.x expects seconds for esp_task_wdt_init(), not milliseconds. (#6964) --- esphome/components/http_request/watchdog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/http_request/watchdog.cpp b/esphome/components/http_request/watchdog.cpp index e609feb4dd..a8519c59ed 100644 --- a/esphome/components/http_request/watchdog.cpp +++ b/esphome/components/http_request/watchdog.cpp @@ -46,7 +46,7 @@ void WatchdogManager::set_timeout_(uint32_t timeout_ms) { }; esp_task_wdt_reconfigure(&wdt_config); #else - esp_task_wdt_init(timeout_ms, true); + esp_task_wdt_init(timeout_ms / 1000, true); #endif // ESP_IDF_VERSION_MAJOR #endif // USE_ESP32 From 0d3cf5cb7809e13de16c5edb75c0437705efa4ce Mon Sep 17 00:00:00 2001 From: Samuel Sieb Date: Sat, 22 Jun 2024 04:57:27 -0700 Subject: [PATCH 05/10] Onewire (#6967) * retry scan * setup pin and log retries * fix retries * remove retries --------- Co-authored-by: Samuel Sieb --- esphome/components/gpio/one_wire/gpio_one_wire.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/gpio/one_wire/gpio_one_wire.cpp b/esphome/components/gpio/one_wire/gpio_one_wire.cpp index 34c2cf3c29..b4e69e975a 100644 --- a/esphome/components/gpio/one_wire/gpio_one_wire.cpp +++ b/esphome/components/gpio/one_wire/gpio_one_wire.cpp @@ -9,6 +9,10 @@ static const char *const TAG = "gpio.one_wire"; void GPIOOneWireBus::setup() { ESP_LOGCONFIG(TAG, "Setting up 1-wire bus..."); + this->t_pin_->setup(); + // clear bus with 480µs high, otherwise initial reset in search might fail + this->t_pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP); + delayMicroseconds(480); this->search(); } From e39961f7f1c329ae70422ded669b548c43226d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Poczkodi?= Date: Mon, 24 Jun 2024 06:32:20 +0200 Subject: [PATCH 06/10] [http_request] memory leak fix (#6973) --- esphome/components/http_request/http_request.h | 1 + 1 file changed, 1 insertion(+) diff --git a/esphome/components/http_request/http_request.h b/esphome/components/http_request/http_request.h index df6bc7dea7..6281adddb6 100644 --- a/esphome/components/http_request/http_request.h +++ b/esphome/components/http_request/http_request.h @@ -149,6 +149,7 @@ template class HttpRequestSendAction : public Action { } response_body.reserve(read_index); response_body.assign((char *) buf, read_index); + allocator.deallocate(buf, max_length); } } From 5bd5b777a6ff949f539b9e58ed537b223e40020e Mon Sep 17 00:00:00 2001 From: Brian Kaufman Date: Sun, 23 Jun 2024 21:54:30 -0700 Subject: [PATCH 07/10] Await cg.get_variable in Update component (#6974) --- esphome/components/update/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/update/__init__.py b/esphome/components/update/__init__.py index 20a9373a06..45bf082fa4 100644 --- a/esphome/components/update/__init__.py +++ b/esphome/components/update/__init__.py @@ -69,7 +69,7 @@ async def setup_update_core_(var, config): await mqtt.register_mqtt_component(mqtt_, config) if web_server_id_config := config.get(CONF_WEB_SERVER_ID): - web_server_ = cg.get_variable(web_server_id_config) + web_server_ = await cg.get_variable(web_server_id_config) web_server.add_entity_to_sorting_list(web_server_, var, config) From c5aae8ee254f3e16ed204912457637ba62743818 Mon Sep 17 00:00:00 2001 From: Samuel Sieb Date: Mon, 24 Jun 2024 04:21:28 -0700 Subject: [PATCH 08/10] fix potential hang (#6976) Co-authored-by: Samuel Sieb --- esphome/components/gpio/one_wire/gpio_one_wire.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/components/gpio/one_wire/gpio_one_wire.cpp b/esphome/components/gpio/one_wire/gpio_one_wire.cpp index b4e69e975a..36eaf2160a 100644 --- a/esphome/components/gpio/one_wire/gpio_one_wire.cpp +++ b/esphome/components/gpio/one_wire/gpio_one_wire.cpp @@ -94,13 +94,15 @@ bool HOT IRAM_ATTR GPIOOneWireBus::read_bit_() { // measure from start value directly, to get best accurate timing no matter // how long pin_mode/delayMicroseconds took - delayMicroseconds(12 - (micros() - start)); + uint32_t now = micros(); + if (now - start < 12) + delayMicroseconds(12 - (now - start)); // sample bus to read bit from peer bool r = pin_.digital_read(); // read slot is at least 60µs; get as close to 60µs to spend less time with interrupts locked - uint32_t now = micros(); + now = micros(); if (now - start < 60) delayMicroseconds(60 - (now - start)); From a6e1ef2dd144dff244800fa00624285c8bd6e70e Mon Sep 17 00:00:00 2001 From: Sergey Dudanov Date: Tue, 25 Jun 2024 00:04:58 +0400 Subject: [PATCH 09/10] [midea] fix fan speed compatibility with some models (#6978) --- esphome/components/midea/climate.py | 2 +- platformio.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/midea/climate.py b/esphome/components/midea/climate.py index 83540a061a..e5612796a3 100644 --- a/esphome/components/midea/climate.py +++ b/esphome/components/midea/climate.py @@ -293,4 +293,4 @@ async def to_code(config): if CONF_HUMIDITY_SETPOINT in config: sens = await sensor.new_sensor(config[CONF_HUMIDITY_SETPOINT]) cg.add(var.set_humidity_setpoint_sensor(sens)) - cg.add_library("dudanov/MideaUART", "1.1.8") + cg.add_library("dudanov/MideaUART", "1.1.9") diff --git a/platformio.ini b/platformio.ini index 6b34b2f05d..14e9ea9fc6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -64,7 +64,7 @@ lib_deps = freekode/TM1651@1.0.1 ; tm1651 glmnet/Dsmr@0.7 ; dsmr rweather/Crypto@0.4.0 ; dsmr - dudanov/MideaUART@1.1.8 ; midea + dudanov/MideaUART@1.1.9 ; midea tonia/HeatpumpIR@1.0.23 ; heatpumpir build_flags = ${common.build_flags} From 09a947beaa45b45f71dbfb3aac06de2b138abebf Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 25 Jun 2024 08:57:38 +1200 Subject: [PATCH 10/10] Bump version to 2024.6.2 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 3b3bdd1a17..cde917ca98 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2024.6.1" +__version__ = "2024.6.2" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = (