From 94b63d7bc2675b02b3f869018de7a842a69edb00 Mon Sep 17 00:00:00 2001 From: acshef Date: Fri, 17 May 2024 22:17:09 -0600 Subject: [PATCH 01/16] Add device_class to valve core config (#6765) --- esphome/components/valve/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/esphome/components/valve/__init__.py b/esphome/components/valve/__init__.py index 22d617cc36..13c2947438 100644 --- a/esphome/components/valve/__init__.py +++ b/esphome/components/valve/__init__.py @@ -14,6 +14,8 @@ from esphome.const import ( CONF_STATE, CONF_STOP, CONF_TRIGGER_ID, + DEVICE_CLASS_GAS, + DEVICE_CLASS_WATER, ) from esphome.core import CORE, coroutine_with_priority from esphome.cpp_helpers import setup_entity @@ -22,6 +24,11 @@ IS_PLATFORM_COMPONENT = True CODEOWNERS = ["@esphome/core"] +DEVICE_CLASSES = [ + DEVICE_CLASS_GAS, + DEVICE_CLASS_WATER, +] + valve_ns = cg.esphome_ns.namespace("valve") Valve = valve_ns.class_("Valve", cg.EntityBase) @@ -65,6 +72,7 @@ VALVE_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(cv.MQTT_COMMAND_COMPONENT_SCHEMA).ex { cv.GenerateID(): cv.declare_id(Valve), cv.OnlyWith(CONF_MQTT_ID, "mqtt"): cv.declare_id(mqtt.MQTTValveComponent), + cv.Optional(CONF_DEVICE_CLASS): cv.one_of(*DEVICE_CLASSES, lower=True), cv.Optional(CONF_POSITION_COMMAND_TOPIC): cv.All( cv.requires_component("mqtt"), cv.subscribe_topic ), From 1164cb86106bc44cf57ab280e379499fe03f440b Mon Sep 17 00:00:00 2001 From: esphomebot Date: Sat, 18 May 2024 19:15:52 +1200 Subject: [PATCH 02/16] Synchronise Device Classes from Home Assistant (#6768) --- esphome/components/valve/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/components/valve/__init__.py b/esphome/components/valve/__init__.py index 13c2947438..ea6bfc6055 100644 --- a/esphome/components/valve/__init__.py +++ b/esphome/components/valve/__init__.py @@ -14,6 +14,7 @@ from esphome.const import ( CONF_STATE, CONF_STOP, CONF_TRIGGER_ID, + DEVICE_CLASS_EMPTY, DEVICE_CLASS_GAS, DEVICE_CLASS_WATER, ) @@ -25,6 +26,7 @@ IS_PLATFORM_COMPONENT = True CODEOWNERS = ["@esphome/core"] DEVICE_CLASSES = [ + DEVICE_CLASS_EMPTY, DEVICE_CLASS_GAS, DEVICE_CLASS_WATER, ] From 70e0925f9abaab0aa0cc13646b1115cdce230a98 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sun, 19 May 2024 01:31:36 +0200 Subject: [PATCH 03/16] Fix pip3 install (#6771) --- script/setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/setup b/script/setup index 71573a9352..1a18a6a9ea 100755 --- a/script/setup +++ b/script/setup @@ -20,7 +20,7 @@ fi pip3 install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt -r requirements_dev.txt pip3 install setuptools wheel -pip3 install -e --config-settings editable_mode=compat ".[dev,test,displays]" +pip3 install -e ".[dev,test,displays]" --config-settings editable_mode=compat pre-commit install From 4469ba402498e6b8e20b6fc89873f70f61a1a21e Mon Sep 17 00:00:00 2001 From: tomaszduda23 Date: Sun, 19 May 2024 01:47:23 +0200 Subject: [PATCH 04/16] [tests] make test_build_components work with venv without installing esphome (#6761) --- script/test_build_components | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script/test_build_components b/script/test_build_components index 4d91256572..f82dd5c3b6 100755 --- a/script/test_build_components +++ b/script/test_build_components @@ -37,9 +37,10 @@ start_esphome() { # Start esphome process echo "> [$target_component] [$test_name] [$target_platform]" - 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" + set -x # TODO: Validate escape of Command line substitution value - 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 + python -m 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 + { set +x; } 2>/dev/null } # Find all test yaml files. From ba73187c1bf20ac0c9d823a5ff8d8aa5f8a07e03 Mon Sep 17 00:00:00 2001 From: tomaszduda23 Date: Sun, 19 May 2024 22:11:27 +0200 Subject: [PATCH 05/16] separate deep_sleep component for each platform in different file (#6762) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- .../deep_sleep/deep_sleep_component.cpp | 115 ++---------------- .../deep_sleep/deep_sleep_component.h | 4 + .../deep_sleep/deep_sleep_esp32.cpp | 104 ++++++++++++++++ .../deep_sleep/deep_sleep_esp8266.cpp | 23 ++++ 4 files changed, 143 insertions(+), 103 deletions(-) create mode 100644 esphome/components/deep_sleep/deep_sleep_esp32.cpp create mode 100644 esphome/components/deep_sleep/deep_sleep_esp8266.cpp diff --git a/esphome/components/deep_sleep/deep_sleep_component.cpp b/esphome/components/deep_sleep/deep_sleep_component.cpp index 97fdf11366..1e7637f3e5 100644 --- a/esphome/components/deep_sleep/deep_sleep_component.cpp +++ b/esphome/components/deep_sleep/deep_sleep_component.cpp @@ -1,12 +1,7 @@ #include "deep_sleep_component.h" -#include #include "esphome/core/application.h" #include "esphome/core/log.h" -#ifdef USE_ESP8266 -#include -#endif - namespace esphome { namespace deep_sleep { @@ -14,25 +9,6 @@ static const char *const TAG = "deep_sleep"; bool global_has_deep_sleep = false; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) -optional DeepSleepComponent::get_run_duration_() const { -#ifdef USE_ESP32 - if (this->wakeup_cause_to_run_duration_.has_value()) { - esp_sleep_wakeup_cause_t wakeup_cause = esp_sleep_get_wakeup_cause(); - switch (wakeup_cause) { - case ESP_SLEEP_WAKEUP_EXT0: - case ESP_SLEEP_WAKEUP_EXT1: - case ESP_SLEEP_WAKEUP_GPIO: - return this->wakeup_cause_to_run_duration_->gpio_cause; - case ESP_SLEEP_WAKEUP_TOUCHPAD: - return this->wakeup_cause_to_run_duration_->touch_cause; - default: - return this->wakeup_cause_to_run_duration_->default_cause; - } - } -#endif - return this->run_duration_; -} - void DeepSleepComponent::setup() { ESP_LOGCONFIG(TAG, "Setting up Deep Sleep..."); global_has_deep_sleep = true; @@ -45,6 +21,7 @@ void DeepSleepComponent::setup() { ESP_LOGD(TAG, "Not scheduling Deep Sleep, as no run duration is configured."); } } + void DeepSleepComponent::dump_config() { ESP_LOGCONFIG(TAG, "Setting up Deep Sleep..."); if (this->sleep_duration_.has_value()) { @@ -54,65 +31,31 @@ void DeepSleepComponent::dump_config() { if (this->run_duration_.has_value()) { ESP_LOGCONFIG(TAG, " Run Duration: %" PRIu32 " ms", *this->run_duration_); } -#ifdef USE_ESP32 - if (wakeup_pin_ != nullptr) { - LOG_PIN(" Wakeup Pin: ", this->wakeup_pin_); - } - if (this->wakeup_cause_to_run_duration_.has_value()) { - ESP_LOGCONFIG(TAG, " Default Wakeup Run Duration: %" PRIu32 " ms", - this->wakeup_cause_to_run_duration_->default_cause); - ESP_LOGCONFIG(TAG, " Touch Wakeup Run Duration: %" PRIu32 " ms", this->wakeup_cause_to_run_duration_->touch_cause); - ESP_LOGCONFIG(TAG, " GPIO Wakeup Run Duration: %" PRIu32 " ms", this->wakeup_cause_to_run_duration_->gpio_cause); - } -#endif + this->dump_config_platform_(); } + void DeepSleepComponent::loop() { if (this->next_enter_deep_sleep_) this->begin_sleep(); } + float DeepSleepComponent::get_loop_priority() const { return -100.0f; // run after everything else is ready } + void DeepSleepComponent::set_sleep_duration(uint32_t time_ms) { this->sleep_duration_ = uint64_t(time_ms) * 1000; } -#if defined(USE_ESP32) -void DeepSleepComponent::set_wakeup_pin_mode(WakeupPinMode wakeup_pin_mode) { - this->wakeup_pin_mode_ = wakeup_pin_mode; -} -#endif - -#if defined(USE_ESP32) -#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) - -void DeepSleepComponent::set_ext1_wakeup(Ext1Wakeup ext1_wakeup) { this->ext1_wakeup_ = ext1_wakeup; } - -void DeepSleepComponent::set_touch_wakeup(bool touch_wakeup) { this->touch_wakeup_ = touch_wakeup; } - -#endif - -void DeepSleepComponent::set_run_duration(WakeupCauseToRunDuration wakeup_cause_to_run_duration) { - wakeup_cause_to_run_duration_ = wakeup_cause_to_run_duration; -} - -#endif void DeepSleepComponent::set_run_duration(uint32_t time_ms) { this->run_duration_ = time_ms; } + void DeepSleepComponent::begin_sleep(bool manual) { if (this->prevent_ && !manual) { this->next_enter_deep_sleep_ = true; return; } -#ifdef USE_ESP32 - if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_KEEP_AWAKE && this->wakeup_pin_ != nullptr && - !this->sleep_duration_.has_value() && this->wakeup_pin_->digital_read()) { - // Defer deep sleep until inactive - if (!this->next_enter_deep_sleep_) { - this->status_set_warning(); - ESP_LOGW(TAG, "Waiting for pin_ to switch state to enter deep sleep..."); - } - this->next_enter_deep_sleep_ = true; + + if (!this->prepare_to_sleep_()) { return; } -#endif ESP_LOGI(TAG, "Beginning Deep Sleep"); if (this->sleep_duration_.has_value()) { @@ -120,47 +63,13 @@ void DeepSleepComponent::begin_sleep(bool manual) { } App.run_safe_shutdown_hooks(); -#if defined(USE_ESP32) -#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) - if (this->sleep_duration_.has_value()) - esp_sleep_enable_timer_wakeup(*this->sleep_duration_); - if (this->wakeup_pin_ != nullptr) { - bool level = !this->wakeup_pin_->is_inverted(); - if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_INVERT_WAKEUP && this->wakeup_pin_->digital_read()) { - level = !level; - } - esp_sleep_enable_ext0_wakeup(gpio_num_t(this->wakeup_pin_->get_pin()), level); - } - if (this->ext1_wakeup_.has_value()) { - esp_sleep_enable_ext1_wakeup(this->ext1_wakeup_->mask, this->ext1_wakeup_->wakeup_mode); - } - - if (this->touch_wakeup_.has_value() && *(this->touch_wakeup_)) { - esp_sleep_enable_touchpad_wakeup(); - esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); - } -#endif -#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) - if (this->sleep_duration_.has_value()) - esp_sleep_enable_timer_wakeup(*this->sleep_duration_); - if (this->wakeup_pin_ != nullptr) { - bool level = !this->wakeup_pin_->is_inverted(); - if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_INVERT_WAKEUP && this->wakeup_pin_->digital_read()) { - level = !level; - } - esp_deep_sleep_enable_gpio_wakeup(1 << this->wakeup_pin_->get_pin(), - static_cast(level)); - } -#endif - esp_deep_sleep_start(); -#endif - -#ifdef USE_ESP8266 - ESP.deepSleep(*this->sleep_duration_); // NOLINT(readability-static-accessed-through-instance) -#endif + this->deep_sleep_(); } + float DeepSleepComponent::get_setup_priority() const { return setup_priority::LATE; } + void DeepSleepComponent::prevent_deep_sleep() { this->prevent_ = true; } + void DeepSleepComponent::allow_deep_sleep() { this->prevent_ = false; } } // namespace deep_sleep diff --git a/esphome/components/deep_sleep/deep_sleep_component.h b/esphome/components/deep_sleep/deep_sleep_component.h index e97d8300c4..be56b529ba 100644 --- a/esphome/components/deep_sleep/deep_sleep_component.h +++ b/esphome/components/deep_sleep/deep_sleep_component.h @@ -106,6 +106,10 @@ class DeepSleepComponent : public Component { // duration before entering deep sleep. optional get_run_duration_() const; + void dump_config_platform_(); + bool prepare_to_sleep_(); + void deep_sleep_(); + optional sleep_duration_; #ifdef USE_ESP32 InternalGPIOPin *wakeup_pin_; diff --git a/esphome/components/deep_sleep/deep_sleep_esp32.cpp b/esphome/components/deep_sleep/deep_sleep_esp32.cpp new file mode 100644 index 0000000000..d54046bc11 --- /dev/null +++ b/esphome/components/deep_sleep/deep_sleep_esp32.cpp @@ -0,0 +1,104 @@ +#ifdef USE_ESP32 +#include "deep_sleep_component.h" +#include "esphome/core/log.h" + +namespace esphome { +namespace deep_sleep { + +static const char *const TAG = "deep_sleep"; + +optional DeepSleepComponent::get_run_duration_() const { + if (this->wakeup_cause_to_run_duration_.has_value()) { + esp_sleep_wakeup_cause_t wakeup_cause = esp_sleep_get_wakeup_cause(); + switch (wakeup_cause) { + case ESP_SLEEP_WAKEUP_EXT0: + case ESP_SLEEP_WAKEUP_EXT1: + case ESP_SLEEP_WAKEUP_GPIO: + return this->wakeup_cause_to_run_duration_->gpio_cause; + case ESP_SLEEP_WAKEUP_TOUCHPAD: + return this->wakeup_cause_to_run_duration_->touch_cause; + default: + return this->wakeup_cause_to_run_duration_->default_cause; + } + } + return this->run_duration_; +} + +void DeepSleepComponent::set_wakeup_pin_mode(WakeupPinMode wakeup_pin_mode) { + this->wakeup_pin_mode_ = wakeup_pin_mode; +} + +#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) +void DeepSleepComponent::set_ext1_wakeup(Ext1Wakeup ext1_wakeup) { this->ext1_wakeup_ = ext1_wakeup; } + +void DeepSleepComponent::set_touch_wakeup(bool touch_wakeup) { this->touch_wakeup_ = touch_wakeup; } +#endif + +void DeepSleepComponent::set_run_duration(WakeupCauseToRunDuration wakeup_cause_to_run_duration) { + wakeup_cause_to_run_duration_ = wakeup_cause_to_run_duration; +} + +void DeepSleepComponent::dump_config_platform_() { + if (wakeup_pin_ != nullptr) { + LOG_PIN(" Wakeup Pin: ", this->wakeup_pin_); + } + if (this->wakeup_cause_to_run_duration_.has_value()) { + ESP_LOGCONFIG(TAG, " Default Wakeup Run Duration: %" PRIu32 " ms", + this->wakeup_cause_to_run_duration_->default_cause); + ESP_LOGCONFIG(TAG, " Touch Wakeup Run Duration: %" PRIu32 " ms", this->wakeup_cause_to_run_duration_->touch_cause); + ESP_LOGCONFIG(TAG, " GPIO Wakeup Run Duration: %" PRIu32 " ms", this->wakeup_cause_to_run_duration_->gpio_cause); + } +} + +bool DeepSleepComponent::prepare_to_sleep_() { + if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_KEEP_AWAKE && this->wakeup_pin_ != nullptr && + !this->sleep_duration_.has_value() && this->wakeup_pin_->digital_read()) { + // Defer deep sleep until inactive + if (!this->next_enter_deep_sleep_) { + this->status_set_warning(); + ESP_LOGW(TAG, "Waiting for pin_ to switch state to enter deep sleep..."); + } + this->next_enter_deep_sleep_ = true; + return false; + } + return true; +} + +void DeepSleepComponent::deep_sleep_() { +#if !defined(USE_ESP32_VARIANT_ESP32C3) && !defined(USE_ESP32_VARIANT_ESP32C6) + if (this->sleep_duration_.has_value()) + esp_sleep_enable_timer_wakeup(*this->sleep_duration_); + if (this->wakeup_pin_ != nullptr) { + bool level = !this->wakeup_pin_->is_inverted(); + if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_INVERT_WAKEUP && this->wakeup_pin_->digital_read()) { + level = !level; + } + esp_sleep_enable_ext0_wakeup(gpio_num_t(this->wakeup_pin_->get_pin()), level); + } + if (this->ext1_wakeup_.has_value()) { + esp_sleep_enable_ext1_wakeup(this->ext1_wakeup_->mask, this->ext1_wakeup_->wakeup_mode); + } + + if (this->touch_wakeup_.has_value() && *(this->touch_wakeup_)) { + esp_sleep_enable_touchpad_wakeup(); + esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); + } +#endif +#if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) + if (this->sleep_duration_.has_value()) + esp_sleep_enable_timer_wakeup(*this->sleep_duration_); + if (this->wakeup_pin_ != nullptr) { + bool level = !this->wakeup_pin_->is_inverted(); + if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_INVERT_WAKEUP && this->wakeup_pin_->digital_read()) { + level = !level; + } + esp_deep_sleep_enable_gpio_wakeup(1 << this->wakeup_pin_->get_pin(), + static_cast(level)); + } +#endif + esp_deep_sleep_start(); +} + +} // namespace deep_sleep +} // namespace esphome +#endif diff --git a/esphome/components/deep_sleep/deep_sleep_esp8266.cpp b/esphome/components/deep_sleep/deep_sleep_esp8266.cpp new file mode 100644 index 0000000000..54d2aa993d --- /dev/null +++ b/esphome/components/deep_sleep/deep_sleep_esp8266.cpp @@ -0,0 +1,23 @@ +#ifdef USE_ESP8266 +#include "deep_sleep_component.h" + +#include + +namespace esphome { +namespace deep_sleep { + +static const char *const TAG = "deep_sleep"; + +optional DeepSleepComponent::get_run_duration_() const { return this->run_duration_; } + +void DeepSleepComponent::dump_config_platform_() {} + +bool DeepSleepComponent::prepare_to_sleep_() { return true; } + +void DeepSleepComponent::deep_sleep_() { + ESP.deepSleep(*this->sleep_duration_); // NOLINT(readability-static-accessed-through-instance) +} + +} // namespace deep_sleep +} // namespace esphome +#endif From a85d37a1cfae47d77c05e4deac830e5811af8066 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 08:12:32 +1200 Subject: [PATCH 06/16] Bump actions/checkout from 4.1.5 to 4.1.6 (#6764) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-api-proto.yml | 2 +- .github/workflows/ci-docker.yml | 2 +- .github/workflows/ci.yml | 32 +++++++++++------------ .github/workflows/release.yml | 8 +++--- .github/workflows/sync-device-classes.yml | 4 +-- .github/workflows/yaml-lint.yml | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci-api-proto.yml b/.github/workflows/ci-api-proto.yml index 448d0fd10f..1628464061 100644 --- a/.github/workflows/ci-api-proto.yml +++ b/.github/workflows/ci-api-proto.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Set up Python uses: actions/setup-python@v5.1.0 with: diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 72a16233fb..dd5c051cfb 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -40,7 +40,7 @@ jobs: arch: [amd64, armv7, aarch64] build_type: ["ha-addon", "docker", "lint"] steps: - - uses: actions/checkout@v4.1.5 + - uses: actions/checkout@v4.1.6 - name: Set up Python uses: actions/setup-python@v5.1.0 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba0a8a363c..2b3c80cb35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: cache-key: ${{ steps.cache-key.outputs.key }} steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Generate cache-key id: cache-key run: echo key="${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}" >> $GITHUB_OUTPUT @@ -66,7 +66,7 @@ jobs: - common steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -87,7 +87,7 @@ jobs: - common steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -108,7 +108,7 @@ jobs: - common steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -129,7 +129,7 @@ jobs: - common steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -150,7 +150,7 @@ jobs: - common steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -199,7 +199,7 @@ jobs: - common steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -229,7 +229,7 @@ jobs: - common steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -254,7 +254,7 @@ jobs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Find all YAML test files id: set-matrix run: echo "matrix=$(ls tests/test*.yaml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT @@ -271,7 +271,7 @@ jobs: file: ${{ fromJson(needs.compile-tests-list.outputs.matrix) }} steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -303,7 +303,7 @@ jobs: file: ${{ fromJson(needs.compile-tests-list.outputs.matrix) }} steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -358,7 +358,7 @@ jobs: steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -410,7 +410,7 @@ jobs: count: ${{ steps.list-components.outputs.count }} steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 with: # Fetch enough history so `git merge-base refs/remotes/origin/dev HEAD` works. fetch-depth: 500 @@ -458,7 +458,7 @@ jobs: run: sudo apt-get install libsodium-dev - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: @@ -484,7 +484,7 @@ jobs: matrix: ${{ steps.split.outputs.components }} steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Split components into 20 groups id: split run: | @@ -512,7 +512,7 @@ jobs: run: sudo apt-get install libsodium-dev - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Restore Python uses: ./.github/actions/restore-python with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c1c502394a..47dc217bf7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: tag: ${{ steps.tag.outputs.tag }} branch_build: ${{ steps.tag.outputs.branch_build }} steps: - - uses: actions/checkout@v4.1.5 + - uses: actions/checkout@v4.1.6 - name: Get tag id: tag # yamllint disable rule:line-length @@ -51,7 +51,7 @@ jobs: contents: read id-token: write steps: - - uses: actions/checkout@v4.1.5 + - uses: actions/checkout@v4.1.6 - name: Set up Python uses: actions/setup-python@v5.1.0 with: @@ -83,7 +83,7 @@ jobs: - linux/arm/v7 - linux/arm64 steps: - - uses: actions/checkout@v4.1.5 + - uses: actions/checkout@v4.1.6 - name: Set up Python uses: actions/setup-python@v5.1.0 with: @@ -174,7 +174,7 @@ jobs: - ghcr - dockerhub steps: - - uses: actions/checkout@v4.1.5 + - uses: actions/checkout@v4.1.6 - name: Download digests uses: actions/download-artifact@v4.1.7 diff --git a/.github/workflows/sync-device-classes.yml b/.github/workflows/sync-device-classes.yml index 7d67999b77..9a8c9d1753 100644 --- a/.github/workflows/sync-device-classes.yml +++ b/.github/workflows/sync-device-classes.yml @@ -13,10 +13,10 @@ jobs: if: github.repository == 'esphome/esphome' steps: - name: Checkout - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Checkout Home Assistant - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 with: repository: home-assistant/core path: lib/home-assistant diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml index 761247529b..f009643629 100644 --- a/.github/workflows/yaml-lint.yml +++ b/.github/workflows/yaml-lint.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code from GitHub - uses: actions/checkout@v4.1.5 + uses: actions/checkout@v4.1.6 - name: Run yamllint uses: frenck/action-yamllint@v1.5.0 with: From 080f8bc86ed215dd12a1f6dc8d0b2bfa80302df2 Mon Sep 17 00:00:00 2001 From: Markus <974709+Links2004@users.noreply.github.com> Date: Sun, 19 May 2024 22:33:20 +0200 Subject: [PATCH 07/16] Fix Upload from Dashboard with MQTT discovery. (#6774) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index 9930119c86..f3c4ff3e23 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -351,7 +351,7 @@ def upload_program(config, args, host): 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") + and (not args.device or args.device in ("MQTT", "OTA")) ): from esphome import mqtt From 91e7a44c3172cddddc93804e04206a962384e2ab Mon Sep 17 00:00:00 2001 From: Markus <974709+Links2004@users.noreply.github.com> Date: Mon, 20 May 2024 01:52:14 +0200 Subject: [PATCH 08/16] Fix MQTT dashboard discovery (Exception in MqttStatusThread). (#6775) --- esphome/dashboard/status/mqtt.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/dashboard/status/mqtt.py b/esphome/dashboard/status/mqtt.py index 8c35dd2535..0e53c21679 100644 --- a/esphome/dashboard/status/mqtt.py +++ b/esphome/dashboard/status/mqtt.py @@ -18,7 +18,7 @@ class MqttStatusThread(threading.Thread): """Run the status thread.""" dashboard = DASHBOARD entries = dashboard.entries - current_entries = entries.all() + current_entries = entries.async_all() config = mqtt.config_from_env() topic = "esphome/discover/#" @@ -33,7 +33,7 @@ class MqttStatusThread(threading.Thread): return for entry in current_entries: if entry.name == data["name"]: - entries.set_state(entry, EntryState.ONLINE) + entries.async_set_state(entry, EntryState.ONLINE) return def on_connect(client, userdata, flags, return_code): @@ -53,11 +53,11 @@ class MqttStatusThread(threading.Thread): client.loop_start() while not dashboard.stop_event.wait(2): - current_entries = entries.all() + current_entries = entries.async_all() # will be set to true on on_message for entry in current_entries: if entry.no_mdns: - entries.set_state(entry, EntryState.OFFLINE) + entries.async_set_state(entry, EntryState.OFFLINE) client.publish("esphome/discover", None, retain=False) dashboard.mqtt_ping_request.wait() From b9bb3cd4bec794f155357e1688831456df77734d Mon Sep 17 00:00:00 2001 From: fodfodfod <94200657+fodfodfod@users.noreply.github.com> Date: Sun, 19 May 2024 20:42:30 -0400 Subject: [PATCH 09/16] add rp2040 support to the wizard (#6239) --- esphome/wizard.py | 115 ++++++++++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 51 deletions(-) diff --git a/esphome/wizard.py b/esphome/wizard.py index 9680ade044..f8911ae844 100644 --- a/esphome/wizard.py +++ b/esphome/wizard.py @@ -277,6 +277,7 @@ def wizard(path): from esphome.components.esp32 import boards as esp32_boards from esphome.components.esp8266 import boards as esp8266_boards from esphome.components.rtl87xx import boards as rtl87xx_boards + from esphome.components.rp2040 import boards as rp2040_boards if not path.endswith(".yaml") and not path.endswith(".yml"): safe_print( @@ -343,7 +344,7 @@ def wizard(path): "firmwares for it." ) - wizard_platforms = ["ESP32", "ESP8266", "BK72XX", "RTL87XX"] + wizard_platforms = ["ESP32", "ESP8266", "BK72XX", "RTL87XX", "RP2040"] safe_print( "Please choose one of the supported microcontrollers " "(Use ESP8266 for Sonoff devices)." @@ -373,6 +374,10 @@ def wizard(path): board_link = ( "http://docs.platformio.org/en/latest/platforms/espressif8266.html#boards" ) + elif platform == "RP2040": + board_link = ( + "https://www.raspberrypi.com/documentation/microcontrollers/rp2040.html" + ) elif platform in ["BK72XX", "RTL87XX"]: board_link = "https://docs.libretiny.eu/docs/status/supported/" else: @@ -397,6 +402,10 @@ def wizard(path): elif platform == "RTL87XX": safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'wr3')}\".") boards_list = rtl87xx_boards.BOARDS.items() + elif platform == "RP2040": + safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'rpipicow')}\".") + boards_list = rp2040_boards.BOARDS.items() + else: raise NotImplementedError("Unknown platform!") @@ -423,60 +432,64 @@ def wizard(path): safe_print() sleep(1) - safe_print_step(3, WIFI_BIG) - safe_print("In this step, I'm going to create the configuration for WiFi.") - safe_print() - sleep(1) - safe_print( - f"First, what's the {color(Fore.GREEN, 'SSID')} (the name) of the WiFi network {name} should connect to?" - ) - sleep(1.5) - safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'Abraham Linksys')}\".") - while True: - ssid = safe_input(color(Fore.BOLD_WHITE, "(ssid): ")) - try: - ssid = cv.ssid(ssid) - break - except vol.Invalid: - safe_print( - color( - Fore.RED, - f'Unfortunately, "{ssid}" doesn\'t seem to be a valid SSID. Please try again.', + # Do not create wifi if the board does not support it + if board not in ["rpipico"]: + safe_print_step(3, WIFI_BIG) + safe_print("In this step, I'm going to create the configuration for WiFi.") + safe_print() + sleep(1) + safe_print( + f"First, what's the {color(Fore.GREEN, 'SSID')} (the name) of the WiFi network {name} should connect to?" + ) + sleep(1.5) + safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'Abraham Linksys')}\".") + while True: + ssid = safe_input(color(Fore.BOLD_WHITE, "(ssid): ")) + try: + ssid = cv.ssid(ssid) + break + except vol.Invalid: + safe_print( + color( + Fore.RED, + f'Unfortunately, "{ssid}" doesn\'t seem to be a valid SSID. Please try again.', + ) ) - ) - safe_print() - sleep(1) + safe_print() + sleep(1) - safe_print( - f'Thank you very much! You\'ve just chosen "{color(Fore.CYAN, ssid)}" as your SSID.' - ) - safe_print() - sleep(0.75) + safe_print( + f'Thank you very much! You\'ve just chosen "{color(Fore.CYAN, ssid)}" as your SSID.' + ) + safe_print() + sleep(0.75) - safe_print( - f"Now please state the {color(Fore.GREEN, 'password')} of the WiFi network so that I can connect to it (Leave empty for no password)" - ) - safe_print() - safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'PASSWORD42')}\"") - sleep(0.5) - psk = safe_input(color(Fore.BOLD_WHITE, "(PSK): ")) - safe_print( - "Perfect! WiFi is now set up (you can create static IPs and so on later)." - ) - sleep(1.5) + safe_print( + f"Now please state the {color(Fore.GREEN, 'password')} of the WiFi network so that I can connect to it (Leave empty for no password)" + ) + safe_print() + safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'PASSWORD42')}\"") + sleep(0.5) + psk = safe_input(color(Fore.BOLD_WHITE, "(PSK): ")) + safe_print( + "Perfect! WiFi is now set up (you can create static IPs and so on later)." + ) + sleep(1.5) - safe_print_step(4, OTA_BIG) - safe_print( - "Almost there! ESPHome can automatically upload custom firmwares over WiFi " - "(over the air) and integrates into Home Assistant with a native API." - ) - safe_print( - f"This can be insecure if you do not trust the WiFi network. Do you want to set a {color(Fore.GREEN, 'password')} for connecting to this ESP?" - ) - safe_print() - sleep(0.25) - safe_print("Press ENTER for no password") - password = safe_input(color(Fore.BOLD_WHITE, "(password): ")) + safe_print_step(4, OTA_BIG) + safe_print( + "Almost there! ESPHome can automatically upload custom firmwares over WiFi " + "(over the air) and integrates into Home Assistant with a native API." + ) + safe_print( + f"This can be insecure if you do not trust the WiFi network. Do you want to set a {color(Fore.GREEN, 'password')} for connecting to this ESP?" + ) + safe_print() + sleep(0.25) + safe_print("Press ENTER for no password") + password = safe_input(color(Fore.BOLD_WHITE, "(password): ")) + else: + ssid, password, psk = "", "", "" if not wizard_write( path=path, From 840f69ffe673401f5b1434dbf23213a51489d569 Mon Sep 17 00:00:00 2001 From: acshef Date: Fri, 17 May 2024 22:17:09 -0600 Subject: [PATCH 10/16] Add device_class to valve core config (#6765) --- esphome/components/valve/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/esphome/components/valve/__init__.py b/esphome/components/valve/__init__.py index 22d617cc36..13c2947438 100644 --- a/esphome/components/valve/__init__.py +++ b/esphome/components/valve/__init__.py @@ -14,6 +14,8 @@ from esphome.const import ( CONF_STATE, CONF_STOP, CONF_TRIGGER_ID, + DEVICE_CLASS_GAS, + DEVICE_CLASS_WATER, ) from esphome.core import CORE, coroutine_with_priority from esphome.cpp_helpers import setup_entity @@ -22,6 +24,11 @@ IS_PLATFORM_COMPONENT = True CODEOWNERS = ["@esphome/core"] +DEVICE_CLASSES = [ + DEVICE_CLASS_GAS, + DEVICE_CLASS_WATER, +] + valve_ns = cg.esphome_ns.namespace("valve") Valve = valve_ns.class_("Valve", cg.EntityBase) @@ -65,6 +72,7 @@ VALVE_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(cv.MQTT_COMMAND_COMPONENT_SCHEMA).ex { cv.GenerateID(): cv.declare_id(Valve), cv.OnlyWith(CONF_MQTT_ID, "mqtt"): cv.declare_id(mqtt.MQTTValveComponent), + cv.Optional(CONF_DEVICE_CLASS): cv.one_of(*DEVICE_CLASSES, lower=True), cv.Optional(CONF_POSITION_COMMAND_TOPIC): cv.All( cv.requires_component("mqtt"), cv.subscribe_topic ), From 4fc2f2284afd663d6e5649a959ed312dc96c5a38 Mon Sep 17 00:00:00 2001 From: esphomebot Date: Sat, 18 May 2024 19:15:52 +1200 Subject: [PATCH 11/16] Synchronise Device Classes from Home Assistant (#6768) --- esphome/components/valve/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/components/valve/__init__.py b/esphome/components/valve/__init__.py index 13c2947438..ea6bfc6055 100644 --- a/esphome/components/valve/__init__.py +++ b/esphome/components/valve/__init__.py @@ -14,6 +14,7 @@ from esphome.const import ( CONF_STATE, CONF_STOP, CONF_TRIGGER_ID, + DEVICE_CLASS_EMPTY, DEVICE_CLASS_GAS, DEVICE_CLASS_WATER, ) @@ -25,6 +26,7 @@ IS_PLATFORM_COMPONENT = True CODEOWNERS = ["@esphome/core"] DEVICE_CLASSES = [ + DEVICE_CLASS_EMPTY, DEVICE_CLASS_GAS, DEVICE_CLASS_WATER, ] From 7452879fb1a85c4bd1795b44d08c4853595ae97e Mon Sep 17 00:00:00 2001 From: Markus <974709+Links2004@users.noreply.github.com> Date: Sun, 19 May 2024 22:33:20 +0200 Subject: [PATCH 12/16] Fix Upload from Dashboard with MQTT discovery. (#6774) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index 54c1aa112a..1d316a97ee 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -346,7 +346,7 @@ def upload_program(config, args, host): 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") + and (not args.device or args.device in ("MQTT", "OTA")) ): from esphome import mqtt From ec6d86c8f5a57ca652449ed9b91b5e975d23f882 Mon Sep 17 00:00:00 2001 From: Markus <974709+Links2004@users.noreply.github.com> Date: Mon, 20 May 2024 01:52:14 +0200 Subject: [PATCH 13/16] Fix MQTT dashboard discovery (Exception in MqttStatusThread). (#6775) --- esphome/dashboard/status/mqtt.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/dashboard/status/mqtt.py b/esphome/dashboard/status/mqtt.py index 8c35dd2535..0e53c21679 100644 --- a/esphome/dashboard/status/mqtt.py +++ b/esphome/dashboard/status/mqtt.py @@ -18,7 +18,7 @@ class MqttStatusThread(threading.Thread): """Run the status thread.""" dashboard = DASHBOARD entries = dashboard.entries - current_entries = entries.all() + current_entries = entries.async_all() config = mqtt.config_from_env() topic = "esphome/discover/#" @@ -33,7 +33,7 @@ class MqttStatusThread(threading.Thread): return for entry in current_entries: if entry.name == data["name"]: - entries.set_state(entry, EntryState.ONLINE) + entries.async_set_state(entry, EntryState.ONLINE) return def on_connect(client, userdata, flags, return_code): @@ -53,11 +53,11 @@ class MqttStatusThread(threading.Thread): client.loop_start() while not dashboard.stop_event.wait(2): - current_entries = entries.all() + current_entries = entries.async_all() # will be set to true on on_message for entry in current_entries: if entry.no_mdns: - entries.set_state(entry, EntryState.OFFLINE) + entries.async_set_state(entry, EntryState.OFFLINE) client.publish("esphome/discover", None, retain=False) dashboard.mqtt_ping_request.wait() From d2d3db4b8c2a29db046eb3478199c9917a28904d Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 20 May 2024 17:14:17 +1200 Subject: [PATCH 14/16] Bump version to 2024.5.1 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 9871ea704f..9d2b8b78ea 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2024.5.0" +__version__ = "2024.5.1" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From 25ee24299a220c231baf37d50156ee35d78e561c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 20 May 2024 01:49:00 -1000 Subject: [PATCH 15/16] Revert "Fix MQTT dashboard discovery (Exception in MqttStatusThread)." (#6782) --- esphome/dashboard/status/mqtt.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/dashboard/status/mqtt.py b/esphome/dashboard/status/mqtt.py index 0e53c21679..8c35dd2535 100644 --- a/esphome/dashboard/status/mqtt.py +++ b/esphome/dashboard/status/mqtt.py @@ -18,7 +18,7 @@ class MqttStatusThread(threading.Thread): """Run the status thread.""" dashboard = DASHBOARD entries = dashboard.entries - current_entries = entries.async_all() + current_entries = entries.all() config = mqtt.config_from_env() topic = "esphome/discover/#" @@ -33,7 +33,7 @@ class MqttStatusThread(threading.Thread): return for entry in current_entries: if entry.name == data["name"]: - entries.async_set_state(entry, EntryState.ONLINE) + entries.set_state(entry, EntryState.ONLINE) return def on_connect(client, userdata, flags, return_code): @@ -53,11 +53,11 @@ class MqttStatusThread(threading.Thread): client.loop_start() while not dashboard.stop_event.wait(2): - current_entries = entries.async_all() + current_entries = entries.all() # will be set to true on on_message for entry in current_entries: if entry.no_mdns: - entries.async_set_state(entry, EntryState.OFFLINE) + entries.set_state(entry, EntryState.OFFLINE) client.publish("esphome/discover", None, retain=False) dashboard.mqtt_ping_request.wait() From 59b1e9c1b024191a666b98e97fe60da18de0d4e8 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 20 May 2024 01:52:24 -1000 Subject: [PATCH 16/16] Fix DashboardEntries.all() call (#6783) --- esphome/dashboard/entries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/dashboard/entries.py b/esphome/dashboard/entries.py index cd318ba8a7..7a9bff4ec1 100644 --- a/esphome/dashboard/entries.py +++ b/esphome/dashboard/entries.py @@ -103,7 +103,7 @@ class DashboardEntries: def all(self) -> list[DashboardEntry]: """Return all entries.""" - return asyncio.run_coroutine_threadsafe(self._async_all, self._loop).result() + return asyncio.run_coroutine_threadsafe(self._async_all(), self._loop).result() def async_all(self) -> list[DashboardEntry]: """Return all entries."""