From 17204baac0168b6a6dd2f6ad87968cd83717f7de Mon Sep 17 00:00:00 2001 From: Samuel Sieb Date: Sun, 23 Jun 2024 15:22:08 -0700 Subject: [PATCH 1/4] allow template parameters (#6972) --- esphome/components/script/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/script/__init__.py b/esphome/components/script/__init__.py index 483357f85b..16b1d4c54e 100644 --- a/esphome/components/script/__init__.py +++ b/esphome/components/script/__init__.py @@ -88,7 +88,7 @@ def validate_parameter_name(value): raise cv.Invalid(f"Script's parameter name cannot be {CONF_ID}") -ALLOWED_PARAM_TYPE_CHARSET = set("abcdefghijklmnopqrstuvwxyz0123456789_:*&[]") +ALLOWED_PARAM_TYPE_CHARSET = set("abcdefghijklmnopqrstuvwxyz0123456789_:*&[]<>") def validate_parameter_type(value): From 0f49b58e0a727284c055246188a4ce9fee687eae 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 2/4] [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 7ee1406f64a04807bf1737cbd407f978744004ab Mon Sep 17 00:00:00 2001 From: Brian Kaufman Date: Sun, 23 Jun 2024 21:54:30 -0700 Subject: [PATCH 3/4] 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 f7af51b92c9d3fee019f2ff5abda5880cf18061e Mon Sep 17 00:00:00 2001 From: Sergey Dudanov Date: Mon, 24 Jun 2024 10:22:07 +0400 Subject: [PATCH 4/4] [haier] climate ID auto generation (#6949) --- esphome/components/haier/binary_sensor/__init__.py | 8 ++++---- esphome/components/haier/button/__init__.py | 2 +- esphome/components/haier/climate.py | 11 +++-------- esphome/components/haier/sensor/__init__.py | 10 +++++----- esphome/components/haier/text_sensor/__init__.py | 8 ++++---- tests/components/haier/test.esp32-c3-ard.yaml | 4 ---- tests/components/haier/test.esp32-c3-idf.yaml | 4 ---- tests/components/haier/test.esp32-idf.yaml | 4 ---- tests/components/haier/test.esp8266-ard.yaml | 4 ---- tests/components/haier/test.rp2040-ard.yaml | 4 ---- 10 files changed, 17 insertions(+), 42 deletions(-) diff --git a/esphome/components/haier/binary_sensor/__init__.py b/esphome/components/haier/binary_sensor/__init__.py index 8e9d5ec578..3a4935b22d 100644 --- a/esphome/components/haier/binary_sensor/__init__.py +++ b/esphome/components/haier/binary_sensor/__init__.py @@ -56,7 +56,7 @@ SENSOR_TYPES = { CONFIG_SCHEMA = cv.Schema( { - cv.Required(CONF_HAIER_ID): cv.use_id(HonClimate), + cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate), } ).extend({cv.Optional(type): schema for type, schema in SENSOR_TYPES.items()}) @@ -64,8 +64,8 @@ CONFIG_SCHEMA = cv.Schema( async def to_code(config): paren = await cg.get_variable(config[CONF_HAIER_ID]) - for type, _ in SENSOR_TYPES.items(): - if conf := config.get(type): + for type_ in SENSOR_TYPES: + if conf := config.get(type_): sens = await binary_sensor.new_binary_sensor(conf) - binary_sensor_type = getattr(BinarySensorTypeEnum, type.upper()) + binary_sensor_type = getattr(BinarySensorTypeEnum, type_.upper()) cg.add(paren.set_sub_binary_sensor(binary_sensor_type, sens)) diff --git a/esphome/components/haier/button/__init__.py b/esphome/components/haier/button/__init__.py index efe6180aaf..745ad95fb6 100644 --- a/esphome/components/haier/button/__init__.py +++ b/esphome/components/haier/button/__init__.py @@ -21,7 +21,7 @@ ICON_SPRAY_BOTTLE = "mdi:spray-bottle" CONFIG_SCHEMA = cv.Schema( { - cv.Required(CONF_HAIER_ID): cv.use_id(HonClimate), + cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate), cv.Optional(CONF_SELF_CLEANING): button.button_schema( SelfCleaningButton, icon=ICON_SPRAY_BOTTLE, diff --git a/esphome/components/haier/climate.py b/esphome/components/haier/climate.py index 1562708a4f..3dcb35708c 100644 --- a/esphome/components/haier/climate.py +++ b/esphome/components/haier/climate.py @@ -183,7 +183,6 @@ BASE_CONFIG_SCHEMA = ( cv.Optional( CONF_SUPPORTED_SWING_MODES, default=[ - "OFF", "VERTICAL", "HORIZONTAL", "BOTH", @@ -211,7 +210,7 @@ CONFIG_SCHEMA = cv.All( ): cv.boolean, cv.Optional( CONF_SUPPORTED_PRESETS, - default=list(["BOOST", "COMFORT"]), # No AWAY by default + default=["BOOST", "COMFORT"], # No AWAY by default ): cv.ensure_list( cv.enum(SUPPORTED_CLIMATE_PRESETS_SMARTAIR2_OPTIONS, upper=True) ), @@ -231,7 +230,7 @@ CONFIG_SCHEMA = cv.All( ): cv.int_range(min=PROTOCOL_CONTROL_PACKET_SIZE, max=50), cv.Optional( CONF_SUPPORTED_PRESETS, - default=list(["BOOST", "ECO", "SLEEP"]), # No AWAY by default + default=["BOOST", "ECO", "SLEEP"], # No AWAY by default ): cv.ensure_list( cv.enum(SUPPORTED_CLIMATE_PRESETS_HON_OPTIONS, upper=True) ), @@ -427,11 +426,7 @@ def _final_validate(config): "No logger component found, logging for Haier protocol is disabled" ) cg.add_build_flag("-DHAIER_LOG_LEVEL=0") - if ( - (CONF_WIFI_SIGNAL in config) - and (config[CONF_WIFI_SIGNAL]) - and CONF_WIFI not in full_config - ): + if config.get(CONF_WIFI_SIGNAL) and CONF_WIFI not in full_config: raise cv.Invalid( f"No WiFi configured, if you want to use haier climate without WiFi add {CONF_WIFI_SIGNAL}: false to climate configuration" ) diff --git a/esphome/components/haier/sensor/__init__.py b/esphome/components/haier/sensor/__init__.py index b2717631e0..23c1d6f008 100644 --- a/esphome/components/haier/sensor/__init__.py +++ b/esphome/components/haier/sensor/__init__.py @@ -137,16 +137,16 @@ SENSOR_TYPES = { CONFIG_SCHEMA = cv.Schema( { - cv.Required(CONF_HAIER_ID): cv.use_id(HonClimate), + cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate), } -).extend({cv.Optional(type): schema for type, schema in SENSOR_TYPES.items()}) +).extend({cv.Optional(type_): schema for type_, schema in SENSOR_TYPES.items()}) async def to_code(config): paren = await cg.get_variable(config[CONF_HAIER_ID]) - for type, _ in SENSOR_TYPES.items(): - if conf := config.get(type): + for type_ in SENSOR_TYPES: + if conf := config.get(type_): sens = await sensor.new_sensor(conf) - sensor_type = getattr(SensorTypeEnum, type.upper()) + sensor_type = getattr(SensorTypeEnum, type_.upper()) cg.add(paren.set_sub_sensor(sensor_type, sens)) diff --git a/esphome/components/haier/text_sensor/__init__.py b/esphome/components/haier/text_sensor/__init__.py index 528b70d83e..d28c5a8c0e 100644 --- a/esphome/components/haier/text_sensor/__init__.py +++ b/esphome/components/haier/text_sensor/__init__.py @@ -39,7 +39,7 @@ TEXT_SENSOR_TYPES = { CONFIG_SCHEMA = cv.Schema( { - cv.Required(CONF_HAIER_ID): cv.use_id(HonClimate), + cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate), } ).extend({cv.Optional(type): schema for type, schema in TEXT_SENSOR_TYPES.items()}) @@ -47,8 +47,8 @@ CONFIG_SCHEMA = cv.Schema( async def to_code(config): paren = await cg.get_variable(config[CONF_HAIER_ID]) - for type, _ in TEXT_SENSOR_TYPES.items(): - if conf := config.get(type): + for type_ in TEXT_SENSOR_TYPES: + if conf := config.get(type_): sens = await text_sensor.new_text_sensor(conf) - text_sensor_type = getattr(TextSensorTypeEnum, type.upper()) + text_sensor_type = getattr(TextSensorTypeEnum, type_.upper()) cg.add(paren.set_sub_text_sensor(text_sensor_type, sens)) diff --git a/tests/components/haier/test.esp32-c3-ard.yaml b/tests/components/haier/test.esp32-c3-ard.yaml index fed573bd1d..0053220669 100644 --- a/tests/components/haier/test.esp32-c3-ard.yaml +++ b/tests/components/haier/test.esp32-c3-ard.yaml @@ -54,7 +54,6 @@ climate: sensor: - platform: haier - haier_id: haier_ac outdoor_temperature: name: Haier outdoor temperature humidity: @@ -80,7 +79,6 @@ sensor: binary_sensor: - platform: haier - haier_id: haier_ac compressor_status: name: Haier Outdoor Compressor Status defrost_status: @@ -96,7 +94,6 @@ binary_sensor: button: - platform: haier - haier_id: haier_ac self_cleaning: name: Haier start self cleaning steri_cleaning: @@ -104,7 +101,6 @@ button: text_sensor: - platform: haier - haier_id: haier_ac appliance_name: name: Haier appliance name cleaning_status: diff --git a/tests/components/haier/test.esp32-c3-idf.yaml b/tests/components/haier/test.esp32-c3-idf.yaml index fed573bd1d..0053220669 100644 --- a/tests/components/haier/test.esp32-c3-idf.yaml +++ b/tests/components/haier/test.esp32-c3-idf.yaml @@ -54,7 +54,6 @@ climate: sensor: - platform: haier - haier_id: haier_ac outdoor_temperature: name: Haier outdoor temperature humidity: @@ -80,7 +79,6 @@ sensor: binary_sensor: - platform: haier - haier_id: haier_ac compressor_status: name: Haier Outdoor Compressor Status defrost_status: @@ -96,7 +94,6 @@ binary_sensor: button: - platform: haier - haier_id: haier_ac self_cleaning: name: Haier start self cleaning steri_cleaning: @@ -104,7 +101,6 @@ button: text_sensor: - platform: haier - haier_id: haier_ac appliance_name: name: Haier appliance name cleaning_status: diff --git a/tests/components/haier/test.esp32-idf.yaml b/tests/components/haier/test.esp32-idf.yaml index efff532d25..54e384f3ce 100644 --- a/tests/components/haier/test.esp32-idf.yaml +++ b/tests/components/haier/test.esp32-idf.yaml @@ -54,7 +54,6 @@ climate: sensor: - platform: haier - haier_id: haier_ac outdoor_temperature: name: Haier outdoor temperature humidity: @@ -80,7 +79,6 @@ sensor: binary_sensor: - platform: haier - haier_id: haier_ac compressor_status: name: Haier Outdoor Compressor Status defrost_status: @@ -96,7 +94,6 @@ binary_sensor: button: - platform: haier - haier_id: haier_ac self_cleaning: name: Haier start self cleaning steri_cleaning: @@ -104,7 +101,6 @@ button: text_sensor: - platform: haier - haier_id: haier_ac appliance_name: name: Haier appliance name cleaning_status: diff --git a/tests/components/haier/test.esp8266-ard.yaml b/tests/components/haier/test.esp8266-ard.yaml index fed573bd1d..0053220669 100644 --- a/tests/components/haier/test.esp8266-ard.yaml +++ b/tests/components/haier/test.esp8266-ard.yaml @@ -54,7 +54,6 @@ climate: sensor: - platform: haier - haier_id: haier_ac outdoor_temperature: name: Haier outdoor temperature humidity: @@ -80,7 +79,6 @@ sensor: binary_sensor: - platform: haier - haier_id: haier_ac compressor_status: name: Haier Outdoor Compressor Status defrost_status: @@ -96,7 +94,6 @@ binary_sensor: button: - platform: haier - haier_id: haier_ac self_cleaning: name: Haier start self cleaning steri_cleaning: @@ -104,7 +101,6 @@ button: text_sensor: - platform: haier - haier_id: haier_ac appliance_name: name: Haier appliance name cleaning_status: diff --git a/tests/components/haier/test.rp2040-ard.yaml b/tests/components/haier/test.rp2040-ard.yaml index fed573bd1d..0053220669 100644 --- a/tests/components/haier/test.rp2040-ard.yaml +++ b/tests/components/haier/test.rp2040-ard.yaml @@ -54,7 +54,6 @@ climate: sensor: - platform: haier - haier_id: haier_ac outdoor_temperature: name: Haier outdoor temperature humidity: @@ -80,7 +79,6 @@ sensor: binary_sensor: - platform: haier - haier_id: haier_ac compressor_status: name: Haier Outdoor Compressor Status defrost_status: @@ -96,7 +94,6 @@ binary_sensor: button: - platform: haier - haier_id: haier_ac self_cleaning: name: Haier start self cleaning steri_cleaning: @@ -104,7 +101,6 @@ button: text_sensor: - platform: haier - haier_id: haier_ac appliance_name: name: Haier appliance name cleaning_status: