From 0ef7781bb34f0b7f636942e16a0e638acdf597c5 Mon Sep 17 00:00:00 2001 From: optimusprimespace <62800678+optimusprimespace@users.noreply.github.com> Date: Sun, 28 Apr 2024 21:22:14 +0200 Subject: [PATCH 1/9] [hm3301] Updated the AQI based on the airnow document (#6004) --- esphome/components/hm3301/aqi_calculator.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/esphome/components/hm3301/aqi_calculator.h b/esphome/components/hm3301/aqi_calculator.h index 6c830f9bad..c1b47826a2 100644 --- a/esphome/components/hm3301/aqi_calculator.h +++ b/esphome/components/hm3301/aqi_calculator.h @@ -1,6 +1,7 @@ #pragma once #include "abstract_aqi_calculator.h" +// https://www.airnow.gov/sites/default/files/2020-05/aqi-technical-assistance-document-sept2018.pdf namespace esphome { namespace hm3301 { @@ -15,14 +16,16 @@ class AQICalculator : public AbstractAQICalculator { } protected: - static const int AMOUNT_OF_LEVELS = 6; + static const int AMOUNT_OF_LEVELS = 7; - int index_grid_[AMOUNT_OF_LEVELS][2] = {{0, 51}, {51, 100}, {101, 150}, {151, 200}, {201, 300}, {301, 500}}; + int index_grid_[AMOUNT_OF_LEVELS][2] = {{0, 50}, {51, 100}, {101, 150}, {151, 200}, + {201, 300}, {301, 400}, {401, 500}}; - int pm2_5_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 12}, {13, 35}, {36, 55}, {56, 150}, {151, 250}, {251, 500}}; + int pm2_5_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 12}, {13, 35}, {36, 55}, {56, 150}, + {151, 250}, {251, 350}, {351, 500}}; - int pm10_0_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 54}, {55, 154}, {155, 254}, - {255, 354}, {355, 424}, {425, 604}}; + int pm10_0_calculation_grid_[AMOUNT_OF_LEVELS][2] = {{0, 54}, {55, 154}, {155, 254}, {255, 354}, + {355, 424}, {425, 504}, {505, 604}}; int calculate_index_(uint16_t value, int array[AMOUNT_OF_LEVELS][2]) { int grid_index = get_grid_index_(value, array); From a700ae481d24ab9cb7c8ffb1b018967a25523823 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 29 Apr 2024 07:33:52 +1200 Subject: [PATCH 2/9] Fix command line substitutions without any yaml substitutions (#6644) --- esphome/components/substitutions/__init__.py | 2 +- esphome/config.py | 4 ++-- script/test_build_components | 4 ++-- tests/test_build_components/build_components_base.bk72xx.yaml | 4 ---- .../build_components_base.esp32-ard.yaml | 4 ---- .../build_components_base.esp32-c3-ard.yaml | 4 ---- .../build_components_base.esp32-c3-idf.yaml | 4 ---- .../build_components_base.esp32-idf.yaml | 4 ---- .../build_components_base.esp32-s2-ard.yaml | 4 ---- .../build_components_base.esp32-s2-idf.yaml | 4 ---- .../build_components_base.esp32-s3-ard.yaml | 4 ---- .../build_components_base.esp32-s3-idf.yaml | 4 ---- .../test_build_components/build_components_base.esp8266.yaml | 4 ---- tests/test_build_components/build_components_base.host.yaml | 4 ---- tests/test_build_components/build_components_base.rp2040.yaml | 4 ---- 15 files changed, 5 insertions(+), 53 deletions(-) diff --git a/esphome/components/substitutions/__init__.py b/esphome/components/substitutions/__init__.py index ef368015b1..2d3a79ccae 100644 --- a/esphome/components/substitutions/__init__.py +++ b/esphome/components/substitutions/__init__.py @@ -116,7 +116,7 @@ def do_substitution_pass(config, command_line_substitutions, ignore_missing=Fals if CONF_SUBSTITUTIONS not in config and not command_line_substitutions: return - substitutions = config[CONF_SUBSTITUTIONS] + substitutions = config.get(CONF_SUBSTITUTIONS) if substitutions is None: substitutions = command_line_substitutions elif command_line_substitutions: diff --git a/esphome/config.py b/esphome/config.py index 1f6867eb59..73aa7077e0 100644 --- a/esphome/config.py +++ b/esphome/config.py @@ -756,11 +756,11 @@ def validate_config( CORE.raw_config = config # 1. Load substitutions - if CONF_SUBSTITUTIONS in config: + if CONF_SUBSTITUTIONS in config or command_line_substitutions: from esphome.components import substitutions result[CONF_SUBSTITUTIONS] = { - **config[CONF_SUBSTITUTIONS], + **config.get(CONF_SUBSTITUTIONS, {}), **command_line_substitutions, } result.add_output_path([CONF_SUBSTITUTIONS], CONF_SUBSTITUTIONS) diff --git a/script/test_build_components b/script/test_build_components index 2396353198..4d91256572 100755 --- a/script/test_build_components +++ b/script/test_build_components @@ -37,9 +37,9 @@ start_esphome() { # Start esphome process echo "> [$target_component] [$test_name] [$target_platform]" - echo "esphome -s component_name $target_component -s test_name $test_name -s target_platform $target_platform $esphome_command $component_test_file" + echo "esphome -s component_name $target_component -s component_dir ../../components/$target_component -s test_name $test_name -s target_platform $target_platform $esphome_command $component_test_file" # TODO: Validate escape of Command line substitution value - esphome -s component_name $target_component -s test_name $test_name -s target_platform $target_platform $esphome_command $component_test_file + esphome -s component_name $target_component -s component_dir ../../components/$target_component -s test_name $test_name -s target_platform $target_platform $esphome_command $component_test_file } # Find all test yaml files. diff --git a/tests/test_build_components/build_components_base.bk72xx.yaml b/tests/test_build_components/build_components_base.bk72xx.yaml index d74cc651eb..9fd9431826 100644 --- a/tests/test_build_components/build_components_base.bk72xx.yaml +++ b/tests/test_build_components/build_components_base.bk72xx.yaml @@ -12,8 +12,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.esp32-ard.yaml b/tests/test_build_components/build_components_base.esp32-ard.yaml index e345adcafc..31b7067acc 100644 --- a/tests/test_build_components/build_components_base.esp32-ard.yaml +++ b/tests/test_build_components/build_components_base.esp32-ard.yaml @@ -14,8 +14,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.esp32-c3-ard.yaml b/tests/test_build_components/build_components_base.esp32-c3-ard.yaml index 136ee62d4b..8aad447693 100644 --- a/tests/test_build_components/build_components_base.esp32-c3-ard.yaml +++ b/tests/test_build_components/build_components_base.esp32-c3-ard.yaml @@ -14,8 +14,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.esp32-c3-idf.yaml b/tests/test_build_components/build_components_base.esp32-c3-idf.yaml index 4e809dd7ce..18584497f4 100644 --- a/tests/test_build_components/build_components_base.esp32-c3-idf.yaml +++ b/tests/test_build_components/build_components_base.esp32-c3-idf.yaml @@ -14,8 +14,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.esp32-idf.yaml b/tests/test_build_components/build_components_base.esp32-idf.yaml index 3c4532a958..a62a995e68 100644 --- a/tests/test_build_components/build_components_base.esp32-idf.yaml +++ b/tests/test_build_components/build_components_base.esp32-idf.yaml @@ -14,8 +14,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.esp32-s2-ard.yaml b/tests/test_build_components/build_components_base.esp32-s2-ard.yaml index db62cdff6a..b8f2639127 100644 --- a/tests/test_build_components/build_components_base.esp32-s2-ard.yaml +++ b/tests/test_build_components/build_components_base.esp32-s2-ard.yaml @@ -15,8 +15,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.esp32-s2-idf.yaml b/tests/test_build_components/build_components_base.esp32-s2-idf.yaml index 19fb657d8b..62f0f4f7bc 100644 --- a/tests/test_build_components/build_components_base.esp32-s2-idf.yaml +++ b/tests/test_build_components/build_components_base.esp32-s2-idf.yaml @@ -15,8 +15,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.esp32-s3-ard.yaml b/tests/test_build_components/build_components_base.esp32-s3-ard.yaml index 39e12de08c..25cad038b6 100644 --- a/tests/test_build_components/build_components_base.esp32-s3-ard.yaml +++ b/tests/test_build_components/build_components_base.esp32-s3-ard.yaml @@ -15,8 +15,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.esp32-s3-idf.yaml b/tests/test_build_components/build_components_base.esp32-s3-idf.yaml index 95c73f917e..b1d08fcdf8 100644 --- a/tests/test_build_components/build_components_base.esp32-s3-idf.yaml +++ b/tests/test_build_components/build_components_base.esp32-s3-idf.yaml @@ -15,8 +15,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.esp8266.yaml b/tests/test_build_components/build_components_base.esp8266.yaml index 0019298ef0..ecf9acd2ba 100644 --- a/tests/test_build_components/build_components_base.esp8266.yaml +++ b/tests/test_build_components/build_components_base.esp8266.yaml @@ -12,8 +12,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.host.yaml b/tests/test_build_components/build_components_base.host.yaml index ec7570d99a..5492cfddd2 100644 --- a/tests/test_build_components/build_components_base.host.yaml +++ b/tests/test_build_components/build_components_base.host.yaml @@ -12,8 +12,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" diff --git a/tests/test_build_components/build_components_base.rp2040.yaml b/tests/test_build_components/build_components_base.rp2040.yaml index cb1cb6359b..335642374b 100644 --- a/tests/test_build_components/build_components_base.rp2040.yaml +++ b/tests/test_build_components/build_components_base.rp2040.yaml @@ -15,8 +15,4 @@ packages: component_under_test: !include file: $component_test_file vars: - component_name: $component_name - test_name: $test_name - target_platform: $target_platform component_test_file: $component_test_file - component_dir: "../../components/$component_name" From 8334934e0825884946f0e6a18b461d015c080c54 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sun, 28 Apr 2024 14:44:40 -0500 Subject: [PATCH 3/9] Allow platform dependencies (#6623) --- esphome/config.py | 28 +++++++++++++++++++++++++--- script/list-components.py | 8 ++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/esphome/config.py b/esphome/config.py index 73aa7077e0..36a81f677b 100644 --- a/esphome/config.py +++ b/esphome/config.py @@ -374,7 +374,10 @@ class LoadValidationStep(ConfigValidationStep): path + [CONF_ID], ) continue - result.add_str_error("No platform specified! See 'platform' key.", path) + result.add_str_error( + f"'{self.domain}' requires a 'platform' key but it was not specified.", + path, + ) continue # Remove temp output path and construct new one result.remove_output_path(path, p_domain) @@ -449,9 +452,28 @@ class MetadataValidationStep(ConfigValidationStep): success = True for dependency in self.comp.dependencies: - if dependency not in result: + dependency_parts = dependency.split(".") + if len(dependency_parts) > 2: result.add_str_error( - f"Component {self.domain} requires component {dependency}", + "Dependencies must be specified as a single component or in component.platform format only", + self.path, + ) + return + component_dep = dependency_parts[0] + platform_dep = dependency_parts[-1] + if component_dep not in result: + result.add_str_error( + f"Component {self.domain} requires component {component_dep}", + self.path, + ) + success = False + elif component_dep != platform_dep and ( + not isinstance(platform_list := result.get(component_dep), list) + or not any(CONF_PLATFORM in p for p in platform_list) + or not any(p[CONF_PLATFORM] == platform_dep for p in platform_list) + ): + result.add_str_error( + f"Component {self.domain} requires 'platform: {platform_dep}' in component '{component_dep}'", self.path, ) success = False diff --git a/script/list-components.py b/script/list-components.py index 8e2d47c6b3..5b5fa5811f 100755 --- a/script/list-components.py +++ b/script/list-components.py @@ -69,7 +69,9 @@ def create_components_graph(): sys.exit(1) for dependency in comp.dependencies: - add_item_to_components_graph(components_graph, dependency, name) + add_item_to_components_graph( + components_graph, dependency.split(".")[0], name + ) for target_config in TARGET_CONFIGURATIONS: CORE.data[KEY_CORE] = target_config @@ -87,7 +89,9 @@ def create_components_graph(): add_item_to_components_graph(components_graph, platform_name, name) for dependency in platform.dependencies: - add_item_to_components_graph(components_graph, dependency, name) + add_item_to_components_graph( + components_graph, dependency.split(".")[0], name + ) for target_config in TARGET_CONFIGURATIONS: CORE.data[KEY_CORE] = target_config From 5142d294f5204819fd6b5a858971b11a463620c3 Mon Sep 17 00:00:00 2001 From: Lucas Hartmann Date: Sun, 28 Apr 2024 16:47:15 -0300 Subject: [PATCH 4/9] [light] Add transition_length to strobe effect. (#6595) --- esphome/components/light/base_light_effects.h | 3 ++- esphome/components/light/effects.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/esphome/components/light/base_light_effects.h b/esphome/components/light/base_light_effects.h index c62ca43ca1..f7829a3f44 100644 --- a/esphome/components/light/base_light_effects.h +++ b/esphome/components/light/base_light_effects.h @@ -150,6 +150,7 @@ class AutomationLightEffect : public LightEffect { struct StrobeLightEffectColor { LightColorValues color; uint32_t duration; + uint32_t transition_length; }; class StrobeLightEffect : public LightEffect { @@ -174,7 +175,7 @@ class StrobeLightEffect : public LightEffect { } call.set_publish(false); call.set_save(false); - call.set_transition_length_if_supported(0); + call.set_transition_length_if_supported(this->colors_[this->at_color_].transition_length); call.perform(); this->last_switch_ = now; } diff --git a/esphome/components/light/effects.py b/esphome/components/light/effects.py index 5093ace949..be50f63321 100644 --- a/esphome/components/light/effects.py +++ b/esphome/components/light/effects.py @@ -266,6 +266,9 @@ async def random_effect_to_code(config, effect_id): cv.Required( CONF_DURATION ): cv.positive_time_period_milliseconds, + cv.Optional( + CONF_TRANSITION_LENGTH, default="0s" + ): cv.positive_time_period_milliseconds, } ), cv.has_at_least_one_key( @@ -310,6 +313,7 @@ async def strobe_effect_to_code(config, effect_id): ), ), ("duration", color[CONF_DURATION]), + ("transition_length", color[CONF_TRANSITION_LENGTH]), ) ) cg.add(var.set_colors(colors)) From 8b6a35845250deee6021fcd993467023f35d7f49 Mon Sep 17 00:00:00 2001 From: chiahsing Date: Mon, 29 Apr 2024 03:49:27 +0800 Subject: [PATCH 5/9] Fixed the issue that graph draws out of the boundary. (#6651) --- esphome/components/graph/graph.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/esphome/components/graph/graph.cpp b/esphome/components/graph/graph.cpp index 1178af911d..09f7557714 100644 --- a/esphome/components/graph/graph.cpp +++ b/esphome/components/graph/graph.cpp @@ -177,22 +177,26 @@ void Graph::draw(Display *buff, uint16_t x_offset, uint16_t y_offset, Color colo bool b = (trace->get_line_type() & bit) == bit; if (b) { int16_t y = (int16_t) roundf((this->height_ - 1) * (1.0 - v)) - thick / 2 + y_offset; + auto draw_pixel_at = [&buff, c, y_offset, this](int16_t x, int16_t y) { + if (y >= y_offset && y < y_offset + this->height_) + buff->draw_pixel_at(x, y, c); + }; if (!continuous || !has_prev || !prev_b || (abs(y - prev_y) <= thick)) { for (int16_t t = 0; t < thick; t++) { - buff->draw_pixel_at(x, y + t, c); + draw_pixel_at(x, y + t); } } else { int16_t mid_y = (y + prev_y + thick) / 2; if (y > prev_y) { for (int16_t t = prev_y + thick; t <= mid_y; t++) - buff->draw_pixel_at(x + 1, t, c); + draw_pixel_at(x + 1, t); for (int16_t t = mid_y + 1; t < y + thick; t++) - buff->draw_pixel_at(x, t, c); + draw_pixel_at(x, t); } else { for (int16_t t = prev_y - 1; t >= mid_y; t--) - buff->draw_pixel_at(x + 1, t, c); + draw_pixel_at(x + 1, t); for (int16_t t = mid_y - 1; t >= y; t--) - buff->draw_pixel_at(x, t, c); + draw_pixel_at(x, t); } } prev_y = y; From 9ea442f3286ecb62b72f93133afb9f9a69d44fa2 Mon Sep 17 00:00:00 2001 From: Ulrich Date: Sun, 28 Apr 2024 21:56:13 +0200 Subject: [PATCH 6/9] Fix upload command. MQTT user and password is missing from configuration. #5093 (#5766) Co-authored-by: ulrich Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index dcd2dddb4b..b461dda4e7 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -768,7 +768,9 @@ def parse_args(argv): ) parser_upload = subparsers.add_parser( - "upload", help="Validate the configuration and upload the latest binary." + "upload", + help="Validate the configuration and upload the latest binary.", + parents=[mqtt_options], ) parser_upload.add_argument( "configuration", help="Your YAML configuration file(s).", nargs="+" From e7c1ddb4525031c90df0e76414cae81577d9d953 Mon Sep 17 00:00:00 2001 From: Matt Quigley Date: Sun, 28 Apr 2024 14:57:11 -0500 Subject: [PATCH 7/9] patch esphome cli to skip mqtt based device discovery if --device option is specified (#6371) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index b461dda4e7..54c1aa112a 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -343,9 +343,10 @@ def upload_program(config, args, host): password = ota_conf.get(CONF_PASSWORD, "") if ( - not is_ip_address(CORE.address) + not is_ip_address(CORE.address) # pylint: disable=too-many-boolean-expressions and (get_port_type(host) == "MQTT" or config[CONF_MDNS][CONF_DISABLED]) and CONF_MQTT in config + and (not args.device or args.device == "MQTT") ): from esphome import mqtt From 80a0b5b1b109b424b85b5b00d5af84cec482c7bd Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 29 Apr 2024 12:10:12 +1200 Subject: [PATCH 8/9] [i2s_audio.microphone] Fixing adc bug (#6654) --- .../microphone/i2s_audio_microphone.cpp | 65 +++++++++++++++++-- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp b/esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp index 602d537bcb..1475df0975 100644 --- a/esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +++ b/esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp @@ -61,28 +61,57 @@ void I2SAudioMicrophone::start_() { .bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT, }; + esp_err_t err; + #if SOC_I2S_SUPPORTS_ADC if (this->adc_) { config.mode = (i2s_mode_t) (config.mode | I2S_MODE_ADC_BUILT_IN); - i2s_driver_install(this->parent_->get_port(), &config, 0, nullptr); + err = i2s_driver_install(this->parent_->get_port(), &config, 0, nullptr); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Error installing I2S driver: %s", esp_err_to_name(err)); + this->status_set_error(); + return; + } + + err = i2s_set_adc_mode(ADC_UNIT_1, this->adc_channel_); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Error setting ADC mode: %s", esp_err_to_name(err)); + this->status_set_error(); + return; + } + err = i2s_adc_enable(this->parent_->get_port()); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Error enabling ADC: %s", esp_err_to_name(err)); + this->status_set_error(); + return; + } - i2s_set_adc_mode(ADC_UNIT_1, this->adc_channel_); - i2s_adc_enable(this->parent_->get_port()); } else #endif { if (this->pdm_) config.mode = (i2s_mode_t) (config.mode | I2S_MODE_PDM); - i2s_driver_install(this->parent_->get_port(), &config, 0, nullptr); + err = i2s_driver_install(this->parent_->get_port(), &config, 0, nullptr); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Error installing I2S driver: %s", esp_err_to_name(err)); + this->status_set_error(); + return; + } i2s_pin_config_t pin_config = this->parent_->get_pin_config(); pin_config.data_in_num = this->din_pin_; - i2s_set_pin(this->parent_->get_port(), &pin_config); + err = i2s_set_pin(this->parent_->get_port(), &pin_config); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Error setting I2S pin: %s", esp_err_to_name(err)); + this->status_set_error(); + return; + } } this->state_ = microphone::STATE_RUNNING; this->high_freq_.start(); + this->status_clear_error(); } void I2SAudioMicrophone::stop() { @@ -96,11 +125,33 @@ void I2SAudioMicrophone::stop() { } void I2SAudioMicrophone::stop_() { - i2s_stop(this->parent_->get_port()); - i2s_driver_uninstall(this->parent_->get_port()); + esp_err_t err; +#if SOC_I2S_SUPPORTS_ADC + if (this->adc_) { + err = i2s_adc_disable(this->parent_->get_port()); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Error disabling ADC: %s", esp_err_to_name(err)); + this->status_set_error(); + return; + } + } +#endif + err = i2s_stop(this->parent_->get_port()); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Error stopping I2S microphone: %s", esp_err_to_name(err)); + this->status_set_error(); + return; + } + err = i2s_driver_uninstall(this->parent_->get_port()); + if (err != ESP_OK) { + ESP_LOGW(TAG, "Error uninstalling I2S driver: %s", esp_err_to_name(err)); + this->status_set_error(); + return; + } this->parent_->unlock(); this->state_ = microphone::STATE_STOPPED; this->high_freq_.stop(); + this->status_clear_error(); } size_t I2SAudioMicrophone::read(int16_t *buf, size_t len) { From c007593f729d96c34566d6c36a5fb9b817cbc692 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:53:08 +1000 Subject: [PATCH 9/9] Fix for #4866 - inconsistent arguments (#6639) --- esphome/components/binary_sensor/automation.cpp | 6 +++--- esphome/core/helpers.cpp | 2 +- tests/components/host/test.host.yaml | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 tests/components/host/test.host.yaml diff --git a/esphome/components/binary_sensor/automation.cpp b/esphome/components/binary_sensor/automation.cpp index bfec882e07..7ac201b2db 100644 --- a/esphome/components/binary_sensor/automation.cpp +++ b/esphome/components/binary_sensor/automation.cpp @@ -51,15 +51,15 @@ void binary_sensor::MultiClickTrigger::on_state_(bool state) { MultiClickTriggerEvent evt = this->timing_[*this->at_index_]; if (evt.max_length != 4294967294UL) { - ESP_LOGV(TAG, "A i=%u min=%" PRIu32 " max=%" PRIu32, *this->at_index_, evt.min_length, evt.max_length); // NOLINT + ESP_LOGV(TAG, "A i=%zu min=%" PRIu32 " max=%" PRIu32, *this->at_index_, evt.min_length, evt.max_length); // NOLINT this->schedule_is_valid_(evt.min_length); this->schedule_is_not_valid_(evt.max_length); } else if (*this->at_index_ + 1 != this->timing_.size()) { - ESP_LOGV(TAG, "B i=%u min=%" PRIu32, *this->at_index_, evt.min_length); // NOLINT + ESP_LOGV(TAG, "B i=%zu min=%" PRIu32, *this->at_index_, evt.min_length); // NOLINT this->cancel_timeout("is_not_valid"); this->schedule_is_valid_(evt.min_length); } else { - ESP_LOGV(TAG, "C i=%u min=%" PRIu32, *this->at_index_, evt.min_length); // NOLINT + ESP_LOGV(TAG, "C i=%zu min=%" PRIu32, *this->at_index_, evt.min_length); // NOLINT this->is_valid_ = false; this->cancel_timeout("is_not_valid"); this->set_timeout("trigger", evt.min_length, [this]() { this->trigger_(); }); diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index 4368576301..fdc0eed774 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -437,7 +437,7 @@ static inline bool is_base64(char c) { return (isalnum(c) || (c == '+') || (c == std::string base64_encode(const std::vector &buf) { return base64_encode(buf.data(), buf.size()); } -std::string base64_encode(const char *buf, unsigned int buf_len) { +std::string base64_encode(const uint8_t *buf, size_t buf_len) { std::string ret; int i = 0; int j = 0; diff --git a/tests/components/host/test.host.yaml b/tests/components/host/test.host.yaml new file mode 100644 index 0000000000..3d14c190a6 --- /dev/null +++ b/tests/components/host/test.host.yaml @@ -0,0 +1,15 @@ +time: + - platform: sntp + id: esptime + timezone: Australia/Sydney + +logger: + level: VERBOSE + logs: + lvgl: INFO + display: DEBUG + sensor: INFO + vnc: DEBUG + +host: + mac_address: "62:23:45:AF:B3:DD"