From 1dfd15e607f76827f00ddb969bd83d6d65532f8d Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:55:29 +1300 Subject: [PATCH 001/194] Bump version to 2025.1.0-dev --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 4d3818cb23..08cc907fdf 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2024.12.0-dev" +__version__ = "2025.1.0-dev" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From ba63d266d823170fbd19761f97ca6539418795ed Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Wed, 11 Dec 2024 23:37:22 -0500 Subject: [PATCH 002/194] [const] Add RMT CONF variables to const.py (#7953) Co-authored-by: Jonathan Swoboda --- esphome/components/remote_receiver/__init__.py | 13 ++++++------- esphome/const.py | 4 ++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/esphome/components/remote_receiver/__init__.py b/esphome/components/remote_receiver/__init__.py index e5085bb33c..d3f61977c6 100644 --- a/esphome/components/remote_receiver/__init__.py +++ b/esphome/components/remote_receiver/__init__.py @@ -1,24 +1,23 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins -from esphome.components import remote_base, esp32_rmt +import esphome.codegen as cg +from esphome.components import esp32_rmt, remote_base +import esphome.config_validation as cv from esphome.const import ( CONF_BUFFER_SIZE, + CONF_CLOCK_DIVIDER, CONF_DUMP, CONF_FILTER, CONF_ID, CONF_IDLE, + CONF_MEMORY_BLOCKS, CONF_PIN, + CONF_RMT_CHANNEL, CONF_TOLERANCE, CONF_TYPE, - CONF_MEMORY_BLOCKS, - CONF_RMT_CHANNEL, CONF_VALUE, ) from esphome.core import CORE, TimePeriod -CONF_CLOCK_DIVIDER = "clock_divider" - AUTO_LOAD = ["remote_base"] remote_receiver_ns = cg.esphome_ns.namespace("remote_receiver") remote_base_ns = cg.esphome_ns.namespace("remote_base") diff --git a/esphome/const.py b/esphome/const.py index 08cc907fdf..0f41dc1aec 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -131,7 +131,9 @@ CONF_CLIENT_CERTIFICATE = "client_certificate" CONF_CLIENT_CERTIFICATE_KEY = "client_certificate_key" CONF_CLIENT_ID = "client_id" CONF_CLK_PIN = "clk_pin" +CONF_CLOCK_DIVIDER = "clock_divider" CONF_CLOCK_PIN = "clock_pin" +CONF_CLOCK_RESOLUTION = "clock_resolution" CONF_CLOSE_ACTION = "close_action" CONF_CLOSE_DURATION = "close_duration" CONF_CLOSE_ENDSTOP = "close_endstop" @@ -739,6 +741,7 @@ CONF_RGB_ORDER = "rgb_order" CONF_RGBW = "rgbw" CONF_RISING_EDGE = "rising_edge" CONF_RMT_CHANNEL = "rmt_channel" +CONF_RMT_SYMBOLS = "rmt_symbols" CONF_ROTATION = "rotation" CONF_ROW = "row" CONF_RS_PIN = "rs_pin" @@ -918,6 +921,7 @@ CONF_UPDATE_ON_BOOT = "update_on_boot" CONF_URL = "url" CONF_USE_ABBREVIATIONS = "use_abbreviations" CONF_USE_ADDRESS = "use_address" +CONF_USE_DMA = "use_dma" CONF_USE_FAHRENHEIT = "use_fahrenheit" CONF_USERNAME = "username" CONF_UUID = "uuid" From 42bc960a36b32c5bdda326bf3eca80733ae38a6d Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 12 Dec 2024 22:37:51 +1300 Subject: [PATCH 003/194] [sgp30] Set default update interval to 60s (#7952) --- esphome/components/sgp30/sensor.py | 19 +++++++++---------- esphome/components/sgp30/sgp30.cpp | 8 ++------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/esphome/components/sgp30/sensor.py b/esphome/components/sgp30/sensor.py index 13e859cc09..8c92f55ef7 100644 --- a/esphome/components/sgp30/sensor.py +++ b/esphome/components/sgp30/sensor.py @@ -1,23 +1,22 @@ import esphome.codegen as cg +from esphome.components import i2c, sensirion_common, sensor import esphome.config_validation as cv -from esphome.components import i2c, sensor, sensirion_common - from esphome.const import ( - CONF_COMPENSATION, - CONF_ID, CONF_BASELINE, + CONF_COMPENSATION, CONF_ECO2, + CONF_ID, CONF_STORE_BASELINE, CONF_TEMPERATURE_SOURCE, CONF_TVOC, - ICON_RADIATOR, DEVICE_CLASS_CARBON_DIOXIDE, DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS, - STATE_CLASS_MEASUREMENT, - UNIT_PARTS_PER_MILLION, - UNIT_PARTS_PER_BILLION, - ICON_MOLECULE_CO2, ENTITY_CATEGORY_DIAGNOSTIC, + ICON_MOLECULE_CO2, + ICON_RADIATOR, + STATE_CLASS_MEASUREMENT, + UNIT_PARTS_PER_BILLION, + UNIT_PARTS_PER_MILLION, ) DEPENDENCIES = ["i2c"] @@ -77,7 +76,7 @@ CONFIG_SCHEMA = ( ), } ) - .extend(cv.polling_component_schema("1s")) + .extend(cv.polling_component_schema("60s")) .extend(i2c.i2c_device_schema(0x58)) ) diff --git a/esphome/components/sgp30/sgp30.cpp b/esphome/components/sgp30/sgp30.cpp index 261604b992..77e9ef9820 100644 --- a/esphome/components/sgp30/sgp30.cpp +++ b/esphome/components/sgp30/sgp30.cpp @@ -1,8 +1,8 @@ #include "sgp30.h" +#include +#include "esphome/core/application.h" #include "esphome/core/hal.h" #include "esphome/core/log.h" -#include "esphome/core/application.h" -#include namespace esphome { namespace sgp30 { @@ -295,10 +295,6 @@ void SGP30Component::update() { if (this->tvoc_sensor_ != nullptr) this->tvoc_sensor_->publish_state(tvoc); - if (this->get_update_interval() != 1000) { - ESP_LOGW(TAG, "Update interval for SGP30 sensor must be set to 1s for optimized readout"); - } - this->status_clear_warning(); this->send_env_data_(); this->read_iaq_baseline_(); From c187cb547cd2c7a1223d399ea4c99aec1d386c73 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:45:10 -0500 Subject: [PATCH 004/194] [core] Move delay_microseconds_safe to iram (#7957) Co-authored-by: Jonathan Swoboda --- esphome/core/helpers.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index 4e8caeae99..b11615204e 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -767,7 +767,8 @@ bool mac_address_is_valid(const uint8_t *mac) { return !(is_all_zeros || is_all_ones); } -void delay_microseconds_safe(uint32_t us) { // avoids CPU locks that could trigger WDT or affect WiFi/BT stability +void IRAM_ATTR HOT delay_microseconds_safe(uint32_t us) { + // avoids CPU locks that could trigger WDT or affect WiFi/BT stability uint32_t start = micros(); const uint32_t lag = 5000; // microseconds, specifies the maximum time for a CPU busy-loop. From 88742e03995145e572e0feed57c3c22a7ce196fc Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 13 Dec 2024 22:16:11 +0100 Subject: [PATCH 005/194] [rotary_encoder] Fix volatile increment/decrement deprecation warnings (#7958) --- esphome/components/rotary_encoder/rotary_encoder.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/esphome/components/rotary_encoder/rotary_encoder.cpp b/esphome/components/rotary_encoder/rotary_encoder.cpp index e9a0eac3f5..f8e5357a6e 100644 --- a/esphome/components/rotary_encoder/rotary_encoder.cpp +++ b/esphome/components/rotary_encoder/rotary_encoder.cpp @@ -93,13 +93,17 @@ void IRAM_ATTR HOT RotaryEncoderSensorStore::gpio_intr(RotaryEncoderSensorStore int8_t rotation_dir = 0; uint16_t new_state = STATE_LOOKUP_TABLE[input_state]; if ((new_state & arg->resolution & STATE_HAS_INCREMENTED) != 0) { - if (arg->counter < arg->max_value) - arg->counter++; + if (arg->counter < arg->max_value) { + auto x = arg->counter + 1; + arg->counter = x; + } rotation_dir = 1; } if ((new_state & arg->resolution & STATE_HAS_DECREMENTED) != 0) { - if (arg->counter > arg->min_value) - arg->counter--; + if (arg->counter > arg->min_value) { + auto x = arg->counter - 1; + arg->counter = x; + } rotation_dir = -1; } From ce7ff15c8ad9f3dd3ba4110428ffc42ae0f901dd Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Fri, 13 Dec 2024 22:21:54 +0100 Subject: [PATCH 006/194] [pulse_counter] Fix volatile increment/decrement deprecation warnings (#7954) --- .../pulse_counter/pulse_counter_sensor.cpp | 23 +++++++++++-------- .../pulse_counter/pulse_counter_sensor.h | 8 +++---- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/esphome/components/pulse_counter/pulse_counter_sensor.cpp b/esphome/components/pulse_counter/pulse_counter_sensor.cpp index bd3e4fcbef..2bc80c352c 100644 --- a/esphome/components/pulse_counter/pulse_counter_sensor.cpp +++ b/esphome/components/pulse_counter/pulse_counter_sensor.cpp @@ -13,9 +13,9 @@ PulseCounterStorageBase *get_storage(bool hw_pcnt) { return (hw_pcnt ? (PulseCounterStorageBase *) (new HwPulseCounterStorage) : (PulseCounterStorageBase *) (new BasicPulseCounterStorage)); } -#else +#else // HAS_PCNT PulseCounterStorageBase *get_storage(bool) { return new BasicPulseCounterStorage; } -#endif +#endif // HAS_PCNT void IRAM_ATTR BasicPulseCounterStorage::gpio_intr(BasicPulseCounterStorage *arg) { const uint32_t now = micros(); @@ -28,14 +28,17 @@ void IRAM_ATTR BasicPulseCounterStorage::gpio_intr(BasicPulseCounterStorage *arg switch (mode) { case PULSE_COUNTER_DISABLE: break; - case PULSE_COUNTER_INCREMENT: - arg->counter++; - break; - case PULSE_COUNTER_DECREMENT: - arg->counter--; - break; + case PULSE_COUNTER_INCREMENT: { + auto x = arg->counter + 1; + arg->counter = x; + } break; + case PULSE_COUNTER_DECREMENT: { + auto x = arg->counter - 1; + arg->counter = x; + } break; } } + bool BasicPulseCounterStorage::pulse_counter_setup(InternalGPIOPin *pin) { this->pin = pin; this->pin->setup(); @@ -43,6 +46,7 @@ bool BasicPulseCounterStorage::pulse_counter_setup(InternalGPIOPin *pin) { this->pin->attach_interrupt(BasicPulseCounterStorage::gpio_intr, this, gpio::INTERRUPT_ANY_EDGE); return true; } + pulse_counter_t BasicPulseCounterStorage::read_raw_value() { pulse_counter_t counter = this->counter; pulse_counter_t ret = counter - this->last_value; @@ -141,6 +145,7 @@ bool HwPulseCounterStorage::pulse_counter_setup(InternalGPIOPin *pin) { } return true; } + pulse_counter_t HwPulseCounterStorage::read_raw_value() { pulse_counter_t counter; pcnt_get_counter_value(this->pcnt_unit, &counter); @@ -148,7 +153,7 @@ pulse_counter_t HwPulseCounterStorage::read_raw_value() { this->last_value = counter; return ret; } -#endif +#endif // HAS_PCNT void PulseCounterSensor::setup() { ESP_LOGCONFIG(TAG, "Setting up pulse counter '%s'...", this->name_.c_str()); diff --git a/esphome/components/pulse_counter/pulse_counter_sensor.h b/esphome/components/pulse_counter/pulse_counter_sensor.h index fc3d8711d1..cea9fa7bf9 100644 --- a/esphome/components/pulse_counter/pulse_counter_sensor.h +++ b/esphome/components/pulse_counter/pulse_counter_sensor.h @@ -9,7 +9,7 @@ #if defined(USE_ESP32) && !defined(USE_ESP32_VARIANT_ESP32C3) #include #define HAS_PCNT -#endif +#endif // defined(USE_ESP32) && !defined(USE_ESP32_VARIANT_ESP32C3) namespace esphome { namespace pulse_counter { @@ -22,9 +22,9 @@ enum PulseCounterCountMode { #ifdef HAS_PCNT using pulse_counter_t = int16_t; -#else +#else // HAS_PCNT using pulse_counter_t = int32_t; -#endif +#endif // HAS_PCNT struct PulseCounterStorageBase { virtual bool pulse_counter_setup(InternalGPIOPin *pin) = 0; @@ -57,7 +57,7 @@ struct HwPulseCounterStorage : public PulseCounterStorageBase { pcnt_unit_t pcnt_unit; pcnt_channel_t pcnt_channel; }; -#endif +#endif // HAS_PCNT PulseCounterStorageBase *get_storage(bool hw_pcnt = false); From 7f2ca800c1312f8b864f17949ab35339a55ac4f6 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Sat, 14 Dec 2024 00:17:58 -0500 Subject: [PATCH 007/194] [i2s_audio] Bugfix: Correctly set ring buffer size (#7959) --- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp b/esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp index d2a582c2cc..46f1b00d05 100644 --- a/esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +++ b/esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp @@ -247,7 +247,7 @@ void I2SAudioSpeaker::speaker_task(void *params) { // Ensure ring buffer is at least as large as the total size of the DMA buffers const size_t ring_buffer_size = - std::min((uint32_t) dma_buffers_size, this_speaker->buffer_duration_ms_ * bytes_per_ms); + std::max((uint32_t) dma_buffers_size, this_speaker->buffer_duration_ms_ * bytes_per_ms); if (this_speaker->send_esp_err_to_event_group_(this_speaker->allocate_buffers_(dma_buffers_size, ring_buffer_size))) { // Failed to allocate buffers From 5877c57a3572138de2873262a0204759a2704149 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sat, 14 Dec 2024 19:55:04 +0100 Subject: [PATCH 008/194] [adc] Restore missing LIBRETINY code in a separated file (#7955) --- .../components/adc/adc_sensor_libretiny.cpp | 48 +++++++++++++++++++ tests/components/adc/test.bk72xx-ard.yaml | 4 ++ 2 files changed, 52 insertions(+) create mode 100644 esphome/components/adc/adc_sensor_libretiny.cpp create mode 100644 tests/components/adc/test.bk72xx-ard.yaml diff --git a/esphome/components/adc/adc_sensor_libretiny.cpp b/esphome/components/adc/adc_sensor_libretiny.cpp new file mode 100644 index 0000000000..cd04477b3f --- /dev/null +++ b/esphome/components/adc/adc_sensor_libretiny.cpp @@ -0,0 +1,48 @@ +#ifdef USE_LIBRETINY + +#include "adc_sensor.h" +#include "esphome/core/log.h" + +namespace esphome { +namespace adc { + +static const char *const TAG = "adc.libretiny"; + +void ADCSensor::setup() { + ESP_LOGCONFIG(TAG, "Setting up ADC '%s'...", this->get_name().c_str()); +#ifndef USE_ADC_SENSOR_VCC + this->pin_->setup(); +#endif // !USE_ADC_SENSOR_VCC +} + +void ADCSensor::dump_config() { + LOG_SENSOR("", "ADC Sensor", this); +#ifdef USE_ADC_SENSOR_VCC + ESP_LOGCONFIG(TAG, " Pin: VCC"); +#else // USE_ADC_SENSOR_VCC + LOG_PIN(" Pin: ", this->pin_); +#endif // USE_ADC_SENSOR_VCC + ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_); + LOG_UPDATE_INTERVAL(this); +} + +float ADCSensor::sample() { + uint32_t raw = 0; + if (this->output_raw_) { + for (uint8_t sample = 0; sample < this->sample_count_; sample++) { + raw += analogRead(this->pin_->get_pin()); // NOLINT + } + raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) + return raw; + } + for (uint8_t sample = 0; sample < this->sample_count_; sample++) { + raw += analogReadVoltage(this->pin_->get_pin()); // NOLINT + } + raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) + return raw / 1000.0f; +} + +} // namespace adc +} // namespace esphome + +#endif // USE_LIBRETINY diff --git a/tests/components/adc/test.bk72xx-ard.yaml b/tests/components/adc/test.bk72xx-ard.yaml new file mode 100644 index 0000000000..491d0af3b9 --- /dev/null +++ b/tests/components/adc/test.bk72xx-ard.yaml @@ -0,0 +1,4 @@ +sensor: + - platform: adc + pin: P23 + name: Basic ADC Test From df4224e779a2173ca63e75ea7ed8f294e540a2f1 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 15 Dec 2024 19:30:47 +0100 Subject: [PATCH 009/194] [nextion] Publishes `is_connected()` (#7961) --- esphome/components/nextion/nextion.cpp | 2 +- esphome/components/nextion/nextion.h | 21 +++++++++++++++++++-- tests/components/nextion/common.yaml | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/esphome/components/nextion/nextion.cpp b/esphome/components/nextion/nextion.cpp index 50a5834347..0b3ded07ae 100644 --- a/esphome/components/nextion/nextion.cpp +++ b/esphome/components/nextion/nextion.cpp @@ -40,7 +40,7 @@ bool Nextion::send_command_(const std::string &command) { } bool Nextion::check_connect_() { - if (this->get_is_connected_()) + if (this->is_connected_) return true; // Check if the handshake should be skipped for the Nextion connection diff --git a/esphome/components/nextion/nextion.h b/esphome/components/nextion/nextion.h index f539c79718..800bdaaa74 100644 --- a/esphome/components/nextion/nextion.h +++ b/esphome/components/nextion/nextion.h @@ -1217,6 +1217,25 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe */ bool is_updating() override; + /** + * @brief Check if the Nextion display is successfully connected. + * + * This method returns whether a successful connection has been established with + * the Nextion display. A connection is considered established when: + * + * - The initial handshake with the display is completed successfully, or + * - The handshake is skipped via skip_connection_handshake_ flag + * + * The connection status is particularly useful when: + * - Troubleshooting communication issues + * - Ensuring the display is ready before sending commands + * - Implementing connection-dependent behaviors + * + * @return true if the Nextion display is connected and ready to receive commands + * @return false if the display is not yet connected or connection was lost + */ + bool is_connected() { return this->is_connected_; } + protected: std::deque nextion_queue_; std::deque waveform_queue_; @@ -1315,8 +1334,6 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe #endif // USE_NEXTION_TFT_UPLOAD - bool get_is_connected_() { return this->is_connected_; } - bool check_connect_(); std::vector touch_; diff --git a/tests/components/nextion/common.yaml b/tests/components/nextion/common.yaml index e84cd08422..73fc8484c0 100644 --- a/tests/components/nextion/common.yaml +++ b/tests/components/nextion/common.yaml @@ -1,5 +1,7 @@ esphome: on_boot: + - lambda: 'ESP_LOGD("display","is_connected(): %s", YESNO(id(main_lcd).is_connected()));' + # Binary sensor publish action tests - binary_sensor.nextion.publish: id: r0_sensor From ea06740b46564d4f87963f72de477defb2d62c1d Mon Sep 17 00:00:00 2001 From: luar123 <49960470+luar123@users.noreply.github.com> Date: Sun, 15 Dec 2024 22:59:54 +0100 Subject: [PATCH 010/194] Fix adc channel for ESP32-H2 (#7964) --- esphome/components/adc/__init__.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/esphome/components/adc/__init__.py b/esphome/components/adc/__init__.py index 11b0ba2389..d8d21523b9 100644 --- a/esphome/components/adc/__init__.py +++ b/esphome/components/adc/__init__.py @@ -1,11 +1,6 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins -from esphome.const import CONF_ANALOG, CONF_INPUT, CONF_NUMBER - -from esphome.core import CORE +import esphome.codegen as cg from esphome.components.esp32 import get_esp32_variant -from esphome.const import PLATFORM_ESP8266 from esphome.components.esp32.const import ( VARIANT_ESP32, VARIANT_ESP32C2, @@ -15,6 +10,9 @@ from esphome.components.esp32.const import ( VARIANT_ESP32S2, VARIANT_ESP32S3, ) +import esphome.config_validation as cv +from esphome.const import CONF_ANALOG, CONF_INPUT, CONF_NUMBER, PLATFORM_ESP8266 +from esphome.core import CORE CODEOWNERS = ["@esphome/core"] @@ -102,11 +100,11 @@ ESP32_VARIANT_ADC1_PIN_TO_CHANNEL = { 6: adc1_channel_t.ADC1_CHANNEL_6, }, VARIANT_ESP32H2: { - 0: adc1_channel_t.ADC1_CHANNEL_0, - 1: adc1_channel_t.ADC1_CHANNEL_1, - 2: adc1_channel_t.ADC1_CHANNEL_2, - 3: adc1_channel_t.ADC1_CHANNEL_3, - 4: adc1_channel_t.ADC1_CHANNEL_4, + 1: adc1_channel_t.ADC1_CHANNEL_0, + 2: adc1_channel_t.ADC1_CHANNEL_1, + 3: adc1_channel_t.ADC1_CHANNEL_2, + 4: adc1_channel_t.ADC1_CHANNEL_3, + 5: adc1_channel_t.ADC1_CHANNEL_4, }, } From 9816c27031e096ee63036ab3c402f615f6d4da68 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Sun, 15 Dec 2024 23:00:44 +0100 Subject: [PATCH 011/194] [nextion] Remove `_internal` from non-protected functions (#7656) --- esphome/components/nextion/display.py | 10 +- esphome/components/nextion/nextion.cpp | 8 - esphome/components/nextion/nextion.h | 148 ++++++++---------- .../components/nextion/nextion_commands.cpp | 20 +-- 4 files changed, 84 insertions(+), 102 deletions(-) diff --git a/esphome/components/nextion/display.py b/esphome/components/nextion/display.py index 6f284376af..f6bd863d42 100644 --- a/esphome/components/nextion/display.py +++ b/esphome/components/nextion/display.py @@ -119,17 +119,17 @@ async def to_code(config): cg.add_library("ESP8266HTTPClient", None) if CONF_TOUCH_SLEEP_TIMEOUT in config: - cg.add(var.set_touch_sleep_timeout_internal(config[CONF_TOUCH_SLEEP_TIMEOUT])) + cg.add(var.set_touch_sleep_timeout(config[CONF_TOUCH_SLEEP_TIMEOUT])) if CONF_WAKE_UP_PAGE in config: - cg.add(var.set_wake_up_page_internal(config[CONF_WAKE_UP_PAGE])) + cg.add(var.set_wake_up_page(config[CONF_WAKE_UP_PAGE])) if CONF_START_UP_PAGE in config: - cg.add(var.set_start_up_page_internal(config[CONF_START_UP_PAGE])) + cg.add(var.set_start_up_page(config[CONF_START_UP_PAGE])) - cg.add(var.set_auto_wake_on_touch_internal(config[CONF_AUTO_WAKE_ON_TOUCH])) + cg.add(var.set_auto_wake_on_touch(config[CONF_AUTO_WAKE_ON_TOUCH])) - cg.add(var.set_exit_reparse_on_start_internal(config[CONF_EXIT_REPARSE_ON_START])) + cg.add(var.set_exit_reparse_on_start(config[CONF_EXIT_REPARSE_ON_START])) cg.add(var.set_skip_connection_handshake(config[CONF_SKIP_CONNECTION_HANDSHAKE])) diff --git a/esphome/components/nextion/nextion.cpp b/esphome/components/nextion/nextion.cpp index 0b3ded07ae..e5df13c64e 100644 --- a/esphome/components/nextion/nextion.cpp +++ b/esphome/components/nextion/nextion.cpp @@ -280,14 +280,6 @@ void Nextion::loop() { this->goto_page(this->start_up_page_); } - // This could probably be removed from the loop area, as those are redundant. - this->set_auto_wake_on_touch(this->auto_wake_on_touch_); - this->set_exit_reparse_on_start(this->exit_reparse_on_start_); - - if (this->touch_sleep_timeout_ != 0) { - this->set_touch_sleep_timeout(this->touch_sleep_timeout_); - } - if (this->wake_up_page_ != -1) { this->set_wake_up_page(this->wake_up_page_); } diff --git a/esphome/components/nextion/nextion.h b/esphome/components/nextion/nextion.h index 800bdaaa74..c293f80aee 100644 --- a/esphome/components/nextion/nextion.h +++ b/esphome/components/nextion/nextion.h @@ -856,76 +856,6 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe */ void set_backlight_brightness(float brightness); - /** - * Set the touch sleep timeout of the display. - * @param timeout Timeout in seconds. - * - * Example: - * ```cpp - * it.set_touch_sleep_timeout(30); - * ``` - * - * After 30 seconds the display will go to sleep. Note: the display will only wakeup by a restart or by setting up - * `thup`. - */ - void set_touch_sleep_timeout(uint16_t timeout); - - /** - * Sets which page Nextion loads when exiting sleep mode. Note this can be set even when Nextion is in sleep mode. - * @param page_id The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to - * wakes up to current page. - * - * Example: - * ```cpp - * it.set_wake_up_page(2); - * ``` - * - * The display will wake up to page 2. - */ - void set_wake_up_page(uint8_t page_id = 255); - - /** - * Sets which page Nextion loads when connecting to ESPHome. - * @param page_id The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to - * wakes up to current page. - * - * Example: - * ```cpp - * it.set_start_up_page(2); - * ``` - * - * The display will go to page 2 when it establishes a connection to ESPHome. - */ - void set_start_up_page(uint8_t page_id = 255); - - /** - * Sets if Nextion should auto-wake from sleep when touch press occurs. - * @param auto_wake True or false. When auto_wake is true and Nextion is in sleep mode, - * the first touch will only trigger the auto wake mode and not trigger a Touch Event. - * - * Example: - * ```cpp - * it.set_auto_wake_on_touch(true); - * ``` - * - * The display will wake up by touch. - */ - void set_auto_wake_on_touch(bool auto_wake); - - /** - * Sets if Nextion should exit the active reparse mode before the "connect" command is sent - * @param exit_reparse True or false. When exit_reparse is true, the exit reparse command - * will be sent before requesting the connection from Nextion. - * - * Example: - * ```cpp - * it.set_exit_reparse_on_start(true); - * ``` - * - * The display will be requested to leave active reparse mode before setup. - */ - void set_exit_reparse_on_start(bool exit_reparse); - /** * Sets whether the Nextion display should skip the connection handshake process. * @param skip_handshake True or false. When skip_connection_handshake is true, @@ -1172,15 +1102,75 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe void update_components_by_prefix(const std::string &prefix); - void set_touch_sleep_timeout_internal(uint32_t touch_sleep_timeout) { - this->touch_sleep_timeout_ = touch_sleep_timeout; - } - void set_wake_up_page_internal(uint8_t wake_up_page) { this->wake_up_page_ = wake_up_page; } - void set_start_up_page_internal(uint8_t start_up_page) { this->start_up_page_ = start_up_page; } - void set_auto_wake_on_touch_internal(bool auto_wake_on_touch) { this->auto_wake_on_touch_ = auto_wake_on_touch; } - void set_exit_reparse_on_start_internal(bool exit_reparse_on_start) { - this->exit_reparse_on_start_ = exit_reparse_on_start; - } + /** + * Set the touch sleep timeout of the display. + * @param timeout Timeout in seconds. + * + * Example: + * ```cpp + * it.set_touch_sleep_timeout(30); + * ``` + * + * After 30 seconds the display will go to sleep. Note: the display will only wakeup by a restart or by setting up + * `thup`. + */ + void set_touch_sleep_timeout(uint32_t touch_sleep_timeout); + + /** + * Sets which page Nextion loads when exiting sleep mode. Note this can be set even when Nextion is in sleep mode. + * @param wake_up_page The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to + * wakes up to current page. + * + * Example: + * ```cpp + * it.set_wake_up_page(2); + * ``` + * + * The display will wake up to page 2. + */ + void set_wake_up_page(uint8_t wake_up_page = 255); + + /** + * Sets which page Nextion loads when connecting to ESPHome. + * @param start_up_page The page id, from 0 to the lage page in Nextion. Set 255 (not set to any existing page) to + * wakes up to current page. + * + * Example: + * ```cpp + * it.set_start_up_page(2); + * ``` + * + * The display will go to page 2 when it establishes a connection to ESPHome. + */ + void set_start_up_page(uint8_t start_up_page = 255) { this->start_up_page_ = start_up_page; } + + /** + * Sets if Nextion should auto-wake from sleep when touch press occurs. + * @param auto_wake_on_touch True or false. When auto_wake is true and Nextion is in sleep mode, + * the first touch will only trigger the auto wake mode and not trigger a Touch Event. + * + * Example: + * ```cpp + * it.set_auto_wake_on_touch(true); + * ``` + * + * The display will wake up by touch. + */ + void set_auto_wake_on_touch(bool auto_wake_on_touch); + + /** + * Sets if Nextion should exit the active reparse mode before the "connect" command is sent + * @param exit_reparse_on_start True or false. When exit_reparse_on_start is true, the exit reparse command + * will be sent before requesting the connection from Nextion. + * + * Example: + * ```cpp + * it.set_exit_reparse_on_start(true); + * ``` + * + * The display will be requested to leave active reparse mode before setup. + */ + void set_exit_reparse_on_start(bool exit_reparse_on_start) { this->exit_reparse_on_start_ = exit_reparse_on_start; } /** * @brief Retrieves the number of commands pending in the Nextion command queue. diff --git a/esphome/components/nextion/nextion_commands.cpp b/esphome/components/nextion/nextion_commands.cpp index 398e9dd502..e3172c8c1b 100644 --- a/esphome/components/nextion/nextion_commands.cpp +++ b/esphome/components/nextion/nextion_commands.cpp @@ -10,19 +10,19 @@ static const char *const TAG = "nextion"; // Sleep safe commands void Nextion::soft_reset() { this->send_command_("rest"); } -void Nextion::set_wake_up_page(uint8_t page_id) { - this->add_no_result_to_queue_with_set_internal_("wake_up_page", "wup", page_id, true); +void Nextion::set_wake_up_page(uint8_t wake_up_page) { + this->wake_up_page_ = wake_up_page; + this->add_no_result_to_queue_with_set_internal_("wake_up_page", "wup", wake_up_page, true); } -void Nextion::set_start_up_page(uint8_t page_id) { this->start_up_page_ = page_id; } - -void Nextion::set_touch_sleep_timeout(uint16_t timeout) { - if (timeout < 3) { +void Nextion::set_touch_sleep_timeout(uint32_t touch_sleep_timeout) { + if (touch_sleep_timeout < 3) { ESP_LOGD(TAG, "Sleep timeout out of bounds, range 3-65535"); return; } - this->add_no_result_to_queue_with_set_internal_("touch_sleep_timeout", "thsp", timeout, true); + this->touch_sleep_timeout_ = touch_sleep_timeout; + this->add_no_result_to_queue_with_set_internal_("touch_sleep_timeout", "thsp", touch_sleep_timeout, true); } void Nextion::sleep(bool sleep) { @@ -54,7 +54,6 @@ bool Nextion::set_protocol_reparse_mode(bool active_mode) { this->ignore_is_setup_ = false; return all_commands_sent; } -void Nextion::set_exit_reparse_on_start(bool exit_reparse) { this->exit_reparse_on_start_ = exit_reparse; } // Set Colors - Background void Nextion::set_component_background_color(const char *component, uint16_t color) { @@ -191,8 +190,9 @@ void Nextion::set_backlight_brightness(float brightness) { this->add_no_result_to_queue_with_printf_("backlight_brightness", "dim=%d", static_cast(brightness * 100)); } -void Nextion::set_auto_wake_on_touch(bool auto_wake) { - this->add_no_result_to_queue_with_set("auto_wake_on_touch", "thup", auto_wake ? 1 : 0); +void Nextion::set_auto_wake_on_touch(bool auto_wake_on_touch) { + this->auto_wake_on_touch_ = auto_wake_on_touch; + this->add_no_result_to_queue_with_set("auto_wake_on_touch", "thup", auto_wake_on_touch ? 1 : 0); } // General Component From a6957b9d3b5edba89b357ff59850ce965afd9e57 Mon Sep 17 00:00:00 2001 From: Oleg Tarasov Date: Mon, 16 Dec 2024 02:04:26 +0300 Subject: [PATCH 012/194] [opentherm] Message ordering, on-the-fly message editing, code improvements (#7903) --- esphome/components/opentherm/__init__.py | 80 ++++++- esphome/components/opentherm/automation.h | 25 +++ esphome/components/opentherm/const.py | 1 + esphome/components/opentherm/generate.py | 47 +++- esphome/components/opentherm/hub.cpp | 202 +++++++++++------- esphome/components/opentherm/hub.h | 46 ++-- esphome/components/opentherm/opentherm.cpp | 74 ++++--- esphome/components/opentherm/opentherm.h | 33 ++- .../components/opentherm/opentherm_macros.h | 11 + esphome/components/opentherm/schema.py | 79 ++++++- esphome/components/opentherm/validate.py | 9 +- tests/components/opentherm/common.yaml | 13 ++ 12 files changed, 475 insertions(+), 145 deletions(-) create mode 100644 esphome/components/opentherm/automation.h diff --git a/esphome/components/opentherm/__init__.py b/esphome/components/opentherm/__init__.py index 81cd78af08..42b476eb87 100644 --- a/esphome/components/opentherm/__init__.py +++ b/esphome/components/opentherm/__init__.py @@ -1,10 +1,12 @@ from typing import Any +import logging +from esphome import automation import esphome.codegen as cg import esphome.config_validation as cv from esphome import pins from esphome.components import sensor -from esphome.const import CONF_ID, PLATFORM_ESP32, PLATFORM_ESP8266 +from esphome.const import CONF_ID, PLATFORM_ESP32, PLATFORM_ESP8266, CONF_TRIGGER_ID from . import const, schema, validate, generate CODEOWNERS = ["@olegtarasov"] @@ -20,7 +22,21 @@ CONF_CH2_ACTIVE = "ch2_active" CONF_SUMMER_MODE_ACTIVE = "summer_mode_active" CONF_DHW_BLOCK = "dhw_block" CONF_SYNC_MODE = "sync_mode" -CONF_OPENTHERM_VERSION = "opentherm_version" +CONF_OPENTHERM_VERSION = "opentherm_version" # Deprecated, will be removed +CONF_BEFORE_SEND = "before_send" +CONF_BEFORE_PROCESS_RESPONSE = "before_process_response" + +# Triggers +BeforeSendTrigger = generate.opentherm_ns.class_( + "BeforeSendTrigger", + automation.Trigger.template(generate.OpenthermData.operator("ref")), +) +BeforeProcessResponseTrigger = generate.opentherm_ns.class_( + "BeforeProcessResponseTrigger", + automation.Trigger.template(generate.OpenthermData.operator("ref")), +) + +_LOGGER = logging.getLogger(__name__) CONFIG_SCHEMA = cv.All( cv.Schema( @@ -36,7 +52,19 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_SUMMER_MODE_ACTIVE, False): cv.boolean, cv.Optional(CONF_DHW_BLOCK, False): cv.boolean, cv.Optional(CONF_SYNC_MODE, False): cv.boolean, - cv.Optional(CONF_OPENTHERM_VERSION): cv.positive_float, + cv.Optional(CONF_OPENTHERM_VERSION): cv.positive_float, # Deprecated + cv.Optional(CONF_BEFORE_SEND): automation.validate_automation( + { + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(BeforeSendTrigger), + } + ), + cv.Optional(CONF_BEFORE_PROCESS_RESPONSE): automation.validate_automation( + { + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( + BeforeProcessResponseTrigger + ), + } + ), } ) .extend( @@ -44,6 +72,11 @@ CONFIG_SCHEMA = cv.All( schema.INPUTS, (lambda _: cv.use_id(sensor.Sensor)) ) ) + .extend( + validate.create_entities_schema( + schema.SETTINGS, (lambda s: s.validation_schema) + ) + ) .extend(cv.COMPONENT_SCHEMA), cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266]), ) @@ -60,18 +93,33 @@ async def to_code(config: dict[str, Any]) -> None: out_pin = await cg.gpio_pin_expression(config[CONF_OUT_PIN]) cg.add(var.set_out_pin(out_pin)) - non_sensors = {CONF_ID, CONF_IN_PIN, CONF_OUT_PIN} + non_sensors = { + CONF_ID, + CONF_IN_PIN, + CONF_OUT_PIN, + CONF_BEFORE_SEND, + CONF_BEFORE_PROCESS_RESPONSE, + } input_sensors = [] + settings = [] for key, value in config.items(): if key in non_sensors: continue if key in schema.INPUTS: input_sensor = await cg.get_variable(value) - cg.add( - getattr(var, f"set_{key}_{const.INPUT_SENSOR.lower()}")(input_sensor) - ) + cg.add(getattr(var, f"set_{key}_{const.INPUT_SENSOR}")(input_sensor)) input_sensors.append(key) + elif key in schema.SETTINGS: + if value == schema.SETTINGS[key].default_value: + continue + cg.add(getattr(var, f"set_{key}_{const.SETTING}")(value)) + settings.append(key) else: + if key == CONF_OPENTHERM_VERSION: + _LOGGER.warning( + "opentherm_version is deprecated and will be removed in esphome 2025.2.0\n" + "Please change to 'opentherm_version_controller'." + ) cg.add(getattr(var, f"set_{key}")(value)) if len(input_sensors) > 0: @@ -81,3 +129,21 @@ async def to_code(config: dict[str, Any]) -> None: ) generate.define_readers(const.INPUT_SENSOR, input_sensors) generate.add_messages(var, input_sensors, schema.INPUTS) + + if len(settings) > 0: + generate.define_has_settings(settings, schema.SETTINGS) + generate.define_message_handler(const.SETTING, settings, schema.SETTINGS) + generate.define_setting_readers(const.SETTING, settings) + generate.add_messages(var, settings, schema.SETTINGS) + + for conf in config.get(CONF_BEFORE_SEND, []): + trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) + await automation.build_automation( + trigger, [(generate.OpenthermData.operator("ref"), "x")], conf + ) + + for conf in config.get(CONF_BEFORE_PROCESS_RESPONSE, []): + trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) + await automation.build_automation( + trigger, [(generate.OpenthermData.operator("ref"), "x")], conf + ) diff --git a/esphome/components/opentherm/automation.h b/esphome/components/opentherm/automation.h new file mode 100644 index 0000000000..acbe33ac8f --- /dev/null +++ b/esphome/components/opentherm/automation.h @@ -0,0 +1,25 @@ +#pragma once + +#include "esphome/core/automation.h" +#include "hub.h" +#include "opentherm.h" + +namespace esphome { +namespace opentherm { + +class BeforeSendTrigger : public Trigger { + public: + BeforeSendTrigger(OpenthermHub *hub) { + hub->add_on_before_send_callback([this](OpenthermData &x) { this->trigger(x); }); + } +}; + +class BeforeProcessResponseTrigger : public Trigger { + public: + BeforeProcessResponseTrigger(OpenthermHub *hub) { + hub->add_on_before_process_response_callback([this](OpenthermData &x) { this->trigger(x); }); + } +}; + +} // namespace opentherm +} // namespace esphome diff --git a/esphome/components/opentherm/const.py b/esphome/components/opentherm/const.py index a113331585..51ad84ce46 100644 --- a/esphome/components/opentherm/const.py +++ b/esphome/components/opentherm/const.py @@ -9,3 +9,4 @@ SWITCH = "switch" NUMBER = "number" OUTPUT = "output" INPUT_SENSOR = "input_sensor" +SETTING = "setting" diff --git a/esphome/components/opentherm/generate.py b/esphome/components/opentherm/generate.py index 9716cab093..6b6a0255a8 100644 --- a/esphome/components/opentherm/generate.py +++ b/esphome/components/opentherm/generate.py @@ -1,13 +1,14 @@ from collections.abc import Awaitable -from typing import Any, Callable +from typing import Any, Callable, Optional import esphome.codegen as cg from esphome.const import CONF_ID from . import const -from .schema import TSchema +from .schema import TSchema, SettingSchema opentherm_ns = cg.esphome_ns.namespace("opentherm") OpenthermHub = opentherm_ns.class_("OpenthermHub", cg.Component) +OpenthermData = opentherm_ns.class_("OpenthermData") def define_has_component(component_type: str, keys: list[str]) -> None: @@ -21,6 +22,24 @@ def define_has_component(component_type: str, keys: list[str]) -> None: cg.add_define(f"OPENTHERM_HAS_{component_type.upper()}_{key}") +# We need a separate set of macros for settings because there are different backing field types we need to take +# into account +def define_has_settings(keys: list[str], schemas: dict[str, SettingSchema]) -> None: + cg.add_define( + "OPENTHERM_SETTING_LIST(F, sep)", + cg.RawExpression( + " sep ".join( + map( + lambda key: f"F({schemas[key].backing_type}, {key}_setting, {schemas[key].default_value})", + keys, + ) + ) + ), + ) + for key in keys: + cg.add_define(f"OPENTHERM_HAS_SETTING_{key}") + + def define_message_handler( component_type: str, keys: list[str], schemas: dict[str, TSchema] ) -> None: @@ -74,16 +93,30 @@ def define_readers(component_type: str, keys: list[str]) -> None: ) -def add_messages(hub: cg.MockObj, keys: list[str], schemas: dict[str, TSchema]): - messages: set[tuple[str, bool]] = set() +def define_setting_readers(component_type: str, keys: list[str]) -> None: for key in keys: - messages.add((schemas[key].message, schemas[key].keep_updated)) - for msg, keep_updated in messages: + cg.add_define( + f"OPENTHERM_READ_{key}", + cg.RawExpression(f"this->{key}_{component_type.lower()}"), + ) + + +def add_messages(hub: cg.MockObj, keys: list[str], schemas: dict[str, TSchema]): + messages: dict[str, tuple[bool, Optional[int]]] = {} + for key in keys: + messages[schemas[key].message] = ( + schemas[key].keep_updated, + schemas[key].order if hasattr(schemas[key], "order") else None, + ) + for msg, (keep_updated, order) in messages.items(): msg_expr = cg.RawExpression(f"esphome::opentherm::MessageId::{msg}") if keep_updated: cg.add(hub.add_repeating_message(msg_expr)) else: - cg.add(hub.add_initial_message(msg_expr)) + if order is not None: + cg.add(hub.add_initial_message(msg_expr, order)) + else: + cg.add(hub.add_initial_message(msg_expr)) def add_property_set(var: cg.MockObj, config_key: str, config: dict[str, Any]) -> None: diff --git a/esphome/components/opentherm/hub.cpp b/esphome/components/opentherm/hub.cpp index aac2966ed1..97adf71752 100644 --- a/esphome/components/opentherm/hub.cpp +++ b/esphome/components/opentherm/hub.cpp @@ -63,7 +63,7 @@ void write_f88(const float value, OpenthermData &data) { data.f88(value); } OpenthermData OpenthermHub::build_request_(MessageId request_id) const { OpenthermData data; data.type = 0; - data.id = 0; + data.id = request_id; data.valueHB = 0; data.valueLB = 0; @@ -82,28 +82,13 @@ OpenthermData OpenthermHub::build_request_(MessageId request_id) const { // NOLINTEND data.type = MessageType::READ_DATA; - data.id = MessageId::STATUS; data.valueHB = ch_enabled | (dhw_enabled << 1) | (cooling_enabled << 2) | (otc_enabled << 3) | (ch2_enabled << 4) | (summer_mode_is_active << 5) | (dhw_blocked << 6); return data; } - // Another special case is OpenTherm version number which is configured at hub level as a constant - if (request_id == MessageId::OT_VERSION_CONTROLLER) { - data.type = MessageType::WRITE_DATA; - data.id = MessageId::OT_VERSION_CONTROLLER; - data.f88(this->opentherm_version_); - - return data; - } - -// Disable incomplete switch statement warnings, because the cases in each -// switch are generated based on the configured sensors and inputs. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wswitch" - - // Next, we start with the write requests from switches and other inputs, + // Next, we start with write requests from switches and other inputs, // because we would want to write that data if it is available, rather than // request a read for that type (in the case that both read and write are // supported). @@ -116,14 +101,23 @@ OpenthermData OpenthermHub::build_request_(MessageId request_id) const { OPENTHERM_MESSAGE_WRITE_POSTSCRIPT, ) OPENTHERM_INPUT_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_WRITE_MESSAGE, OPENTHERM_MESSAGE_WRITE_ENTITY, , OPENTHERM_MESSAGE_WRITE_POSTSCRIPT, ) + OPENTHERM_SETTING_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_WRITE_MESSAGE, OPENTHERM_MESSAGE_WRITE_SETTING, , + OPENTHERM_MESSAGE_WRITE_POSTSCRIPT, ) + default: + break; } // Finally, handle the simple read requests, which only change with the message id. - switch (request_id) { OPENTHERM_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_READ_MESSAGE, OPENTHERM_IGNORE, , , ) } + switch (request_id) { + OPENTHERM_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_READ_MESSAGE, OPENTHERM_IGNORE, , , ) + default: + break; + } switch (request_id) { OPENTHERM_BINARY_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_READ_MESSAGE, OPENTHERM_IGNORE, , , ) + default: + break; } -#pragma GCC diagnostic pop // And if we get here, a message was requested which somehow wasn't handled. // This shouldn't happen due to the way the defines are configured, so we @@ -163,19 +157,37 @@ void OpenthermHub::setup() { // communicate at least once every second. Sending the status request is // good practice anyway. this->add_repeating_message(MessageId::STATUS); - - // Also ensure that we start communication with the STATUS message - this->initial_messages_.insert(this->initial_messages_.begin(), MessageId::STATUS); - - if (this->opentherm_version_ > 0.0f) { - this->initial_messages_.insert(this->initial_messages_.begin(), MessageId::OT_VERSION_CONTROLLER); - } - - this->current_message_iterator_ = this->initial_messages_.begin(); + this->write_initial_messages_(this->messages_); + this->message_iterator_ = this->messages_.begin(); } void OpenthermHub::on_shutdown() { this->opentherm_->stop(); } +// Disabling clang-tidy for this particular line since it keeps removing the trailing underscore (bug?) +void OpenthermHub::write_initial_messages_(std::vector &target) { // NOLINT + std::vector> sorted; + std::copy_if(this->configured_messages_.begin(), this->configured_messages_.end(), std::back_inserter(sorted), + [](const std::pair &pair) { return pair.second < REPEATING_MESSAGE_ORDER; }); + std::sort(sorted.begin(), sorted.end(), + [](const std::pair &a, const std::pair &b) { + return a.second < b.second; + }); + + target.clear(); + std::transform(sorted.begin(), sorted.end(), std::back_inserter(target), + [](const std::pair &pair) { return pair.first; }); +} + +// Disabling clang-tidy for this particular line since it keeps removing the trailing underscore (bug?) +void OpenthermHub::write_repeating_messages_(std::vector &target) { // NOLINT + target.clear(); + for (auto const &pair : this->configured_messages_) { + if (pair.second == REPEATING_MESSAGE_ORDER) { + target.push_back(pair.first); + } + } +} + void OpenthermHub::loop() { if (this->sync_mode_) { this->sync_loop_(); @@ -184,29 +196,18 @@ void OpenthermHub::loop() { auto cur_time = millis(); auto const cur_mode = this->opentherm_->get_mode(); + + if (this->handle_error_(cur_mode)) { + return; + } + switch (cur_mode) { case OperationMode::WRITE: case OperationMode::READ: case OperationMode::LISTEN: - if (!this->check_timings_(cur_time)) { - break; - } - this->last_mode_ = cur_mode; - break; - case OperationMode::ERROR_PROTOCOL: - if (this->last_mode_ == OperationMode::WRITE) { - this->handle_protocol_write_error_(); - } else if (this->last_mode_ == OperationMode::READ) { - this->handle_protocol_read_error_(); - } - - this->stop_opentherm_(); - break; - case OperationMode::ERROR_TIMEOUT: - this->handle_timeout_error_(); - this->stop_opentherm_(); break; case OperationMode::IDLE: + this->check_timings_(cur_time); if (this->should_skip_loop_(cur_time)) { break; } @@ -219,6 +220,28 @@ void OpenthermHub::loop() { case OperationMode::RECEIVED: this->read_response_(); break; + default: + break; + } + this->last_mode_ = cur_mode; +} + +bool OpenthermHub::handle_error_(OperationMode mode) { + switch (mode) { + case OperationMode::ERROR_PROTOCOL: + // Protocol error can happen only while reading boiler response. + this->handle_protocol_error_(); + return true; + case OperationMode::ERROR_TIMEOUT: + // Timeout error might happen while we wait for device to respond. + this->handle_timeout_error_(); + return true; + case OperationMode::ERROR_TIMER: + // Timer error can happen only on ESP32. + this->handle_timer_error_(); + return true; + default: + return false; } } @@ -237,16 +260,20 @@ void OpenthermHub::sync_loop_() { } this->start_conversation_(); + // There may be a timer error at this point + if (this->handle_error_(this->opentherm_->get_mode())) { + return; + } + // Spin while message is being sent to device if (!this->spin_wait_(1150, [&] { return this->opentherm_->is_active(); })) { ESP_LOGE(TAG, "Hub timeout triggered during send"); this->stop_opentherm_(); return; } - if (this->opentherm_->is_error()) { - this->handle_protocol_write_error_(); - this->stop_opentherm_(); + // Check for errors and ensure we are in the right state (message sent successfully) + if (this->handle_error_(this->opentherm_->get_mode())) { return; } else if (!this->opentherm_->is_sent()) { ESP_LOGW(TAG, "Unexpected state after sending request: %s", @@ -257,19 +284,20 @@ void OpenthermHub::sync_loop_() { // Listen for the response this->opentherm_->listen(); + // There may be a timer error at this point + if (this->handle_error_(this->opentherm_->get_mode())) { + return; + } + + // Spin while response is being received if (!this->spin_wait_(1150, [&] { return this->opentherm_->is_active(); })) { ESP_LOGE(TAG, "Hub timeout triggered during receive"); this->stop_opentherm_(); return; } - if (this->opentherm_->is_timeout()) { - this->handle_timeout_error_(); - this->stop_opentherm_(); - return; - } else if (this->opentherm_->is_protocol_error()) { - this->handle_protocol_read_error_(); - this->stop_opentherm_(); + // Check for errors and ensure we are in the right state (message received successfully) + if (this->handle_error_(this->opentherm_->get_mode())) { return; } else if (!this->opentherm_->has_message()) { ESP_LOGW(TAG, "Unexpected state after receiving response: %s", @@ -281,17 +309,13 @@ void OpenthermHub::sync_loop_() { this->read_response_(); } -bool OpenthermHub::check_timings_(uint32_t cur_time) { +void OpenthermHub::check_timings_(uint32_t cur_time) { if (this->last_conversation_start_ > 0 && (cur_time - this->last_conversation_start_) > 1150) { ESP_LOGW(TAG, "%d ms elapsed since the start of the last convo, but 1150 ms are allowed at maximum. Look at other " "components that might slow the loop down.", (int) (cur_time - this->last_conversation_start_)); - this->stop_opentherm_(); - return false; } - - return true; } bool OpenthermHub::should_skip_loop_(uint32_t cur_time) const { @@ -304,14 +328,17 @@ bool OpenthermHub::should_skip_loop_(uint32_t cur_time) const { } void OpenthermHub::start_conversation_() { - if (this->sending_initial_ && this->current_message_iterator_ == this->initial_messages_.end()) { - this->sending_initial_ = false; - this->current_message_iterator_ = this->repeating_messages_.begin(); - } else if (this->current_message_iterator_ == this->repeating_messages_.end()) { - this->current_message_iterator_ = this->repeating_messages_.begin(); + if (this->message_iterator_ == this->messages_.end()) { + if (this->sending_initial_) { + this->sending_initial_ = false; + this->write_repeating_messages_(this->messages_); + } + this->message_iterator_ = this->messages_.begin(); } - auto request = this->build_request_(*this->current_message_iterator_); + auto request = this->build_request_(*this->message_iterator_); + + this->before_send_callback_.call(request); ESP_LOGD(TAG, "Sending request with id %d (%s)", request.id, this->opentherm_->message_id_to_str((MessageId) request.id)); @@ -331,37 +358,48 @@ void OpenthermHub::read_response_() { this->stop_opentherm_(); + this->before_process_response_callback_.call(response); this->process_response(response); - this->current_message_iterator_++; + this->message_iterator_++; } void OpenthermHub::stop_opentherm_() { this->opentherm_->stop(); this->last_conversation_end_ = millis(); } -void OpenthermHub::handle_protocol_write_error_() { - ESP_LOGW(TAG, "Error while sending request: %s", - this->opentherm_->operation_mode_to_str(this->opentherm_->get_mode())); - this->opentherm_->debug_data(this->last_request_); -} -void OpenthermHub::handle_protocol_read_error_() { + +void OpenthermHub::handle_protocol_error_() { OpenThermError error; this->opentherm_->get_protocol_error(error); ESP_LOGW(TAG, "Protocol error occured while receiving response: %s", - this->opentherm_->protocol_error_to_to_str(error.error_type)); + this->opentherm_->protocol_error_to_str(error.error_type)); this->opentherm_->debug_error(error); -} -void OpenthermHub::handle_timeout_error_() { - ESP_LOGW(TAG, "Receive response timed out at a protocol level"); this->stop_opentherm_(); } +void OpenthermHub::handle_timeout_error_() { + ESP_LOGW(TAG, "Timeout while waiting for response from device"); + this->stop_opentherm_(); +} + +void OpenthermHub::handle_timer_error_() { + this->opentherm_->report_and_reset_timer_error(); + this->stop_opentherm_(); + // Timer error is critical, there is no point in retrying. + this->mark_failed(); +} + void OpenthermHub::dump_config() { + std::vector initial_messages; + std::vector repeating_messages; + this->write_initial_messages_(initial_messages); + this->write_repeating_messages_(repeating_messages); + ESP_LOGCONFIG(TAG, "OpenTherm:"); LOG_PIN(" In: ", this->in_pin_); LOG_PIN(" Out: ", this->out_pin_); - ESP_LOGCONFIG(TAG, " Sync mode: %d", this->sync_mode_); + ESP_LOGCONFIG(TAG, " Sync mode: %s", YESNO(this->sync_mode_)); ESP_LOGCONFIG(TAG, " Sensors: %s", SHOW(OPENTHERM_SENSOR_LIST(ID, ))); ESP_LOGCONFIG(TAG, " Binary sensors: %s", SHOW(OPENTHERM_BINARY_SENSOR_LIST(ID, ))); ESP_LOGCONFIG(TAG, " Switches: %s", SHOW(OPENTHERM_SWITCH_LIST(ID, ))); @@ -369,12 +407,12 @@ void OpenthermHub::dump_config() { ESP_LOGCONFIG(TAG, " Outputs: %s", SHOW(OPENTHERM_OUTPUT_LIST(ID, ))); ESP_LOGCONFIG(TAG, " Numbers: %s", SHOW(OPENTHERM_NUMBER_LIST(ID, ))); ESP_LOGCONFIG(TAG, " Initial requests:"); - for (auto type : this->initial_messages_) { - ESP_LOGCONFIG(TAG, " - %d (%s)", type, this->opentherm_->message_id_to_str((type))); + for (auto type : initial_messages) { + ESP_LOGCONFIG(TAG, " - %d (%s)", type, this->opentherm_->message_id_to_str(type)); } ESP_LOGCONFIG(TAG, " Repeating requests:"); - for (auto type : this->repeating_messages_) { - ESP_LOGCONFIG(TAG, " - %d (%s)", type, this->opentherm_->message_id_to_str((type))); + for (auto type : repeating_messages) { + ESP_LOGCONFIG(TAG, " - %d (%s)", type, this->opentherm_->message_id_to_str(type)); } } diff --git a/esphome/components/opentherm/hub.h b/esphome/components/opentherm/hub.h index 1f536653e8..80fd268820 100644 --- a/esphome/components/opentherm/hub.h +++ b/esphome/components/opentherm/hub.h @@ -38,6 +38,9 @@ namespace esphome { namespace opentherm { +static const uint8_t REPEATING_MESSAGE_ORDER = 255; +static const uint8_t INITIAL_UNORDERED_MESSAGE_ORDER = 254; + // OpenTherm component for ESPHome class OpenthermHub : public Component { protected: @@ -58,15 +61,12 @@ class OpenthermHub : public Component { OPENTHERM_INPUT_SENSOR_LIST(OPENTHERM_DECLARE_INPUT_SENSOR, ) - // The set of initial messages to send on starting communication with the boiler - std::vector initial_messages_; - // and the repeating messages which are sent repeatedly to update various sensors - // and boiler parameters (like the setpoint). - std::vector repeating_messages_; - // Indicates if we are still working on the initial requests or not + OPENTHERM_SETTING_LIST(OPENTHERM_DECLARE_SETTING, ) + bool sending_initial_ = true; - // Index for the current request in one of the _requests sets. - std::vector::const_iterator current_message_iterator_; + std::unordered_map configured_messages_; + std::vector messages_; + std::vector::const_iterator message_iterator_; uint32_t last_conversation_start_ = 0; uint32_t last_conversation_end_ = 0; @@ -78,20 +78,25 @@ class OpenthermHub : public Component { // Very likely to happen while using Dallas temperature sensors. bool sync_mode_ = false; - float opentherm_version_ = 0.0f; + CallbackManager before_send_callback_; + CallbackManager before_process_response_callback_; // Create OpenTherm messages based on the message id OpenthermData build_request_(MessageId request_id) const; - void handle_protocol_write_error_(); - void handle_protocol_read_error_(); + bool handle_error_(OperationMode mode); + void handle_protocol_error_(); void handle_timeout_error_(); + void handle_timer_error_(); void stop_opentherm_(); void start_conversation_(); void read_response_(); - bool check_timings_(uint32_t cur_time); + void check_timings_(uint32_t cur_time); bool should_skip_loop_(uint32_t cur_time) const; void sync_loop_(); + void write_initial_messages_(std::vector &target); + void write_repeating_messages_(std::vector &target); + template bool spin_wait_(uint32_t timeout, F func) { auto start_time = millis(); while (func()) { @@ -127,13 +132,18 @@ class OpenthermHub : public Component { OPENTHERM_INPUT_SENSOR_LIST(OPENTHERM_SET_INPUT_SENSOR, ) + OPENTHERM_SETTING_LIST(OPENTHERM_SET_SETTING, ) + // Add a request to the vector of initial requests - void add_initial_message(MessageId message_id) { this->initial_messages_.push_back(message_id); } + void add_initial_message(MessageId message_id) { + this->configured_messages_[message_id] = INITIAL_UNORDERED_MESSAGE_ORDER; + } + void add_initial_message(MessageId message_id, uint8_t order) { this->configured_messages_[message_id] = order; } // Add a request to the set of repeating requests. Note that a large number of repeating // requests will slow down communication with the boiler. Each request may take up to 1 second, // so with all sensors enabled, it may take about half a minute before a change in setpoint // will be processed. - void add_repeating_message(MessageId message_id) { this->repeating_messages_.push_back(message_id); } + void add_repeating_message(MessageId message_id) { this->configured_messages_[message_id] = REPEATING_MESSAGE_ORDER; } // There are seven status variables, which can either be set as a simple variable, // or using a switch. ch_enable and dhw_enable default to true, the others to false. @@ -149,7 +159,13 @@ class OpenthermHub : public Component { void set_summer_mode_active(bool value) { this->summer_mode_active = value; } void set_dhw_block(bool value) { this->dhw_block = value; } void set_sync_mode(bool sync_mode) { this->sync_mode_ = sync_mode; } - void set_opentherm_version(float value) { this->opentherm_version_ = value; } + + void add_on_before_send_callback(std::function &&callback) { + this->before_send_callback_.add(std::move(callback)); + } + void add_on_before_process_response_callback(std::function &&callback) { + this->before_process_response_callback_.add(std::move(callback)); + } float get_setup_priority() const override { return setup_priority::HARDWARE; } diff --git a/esphome/components/opentherm/opentherm.cpp b/esphome/components/opentherm/opentherm.cpp index 62ab1d3860..49482316ee 100644 --- a/esphome/components/opentherm/opentherm.cpp +++ b/esphome/components/opentherm/opentherm.cpp @@ -52,7 +52,9 @@ bool OpenTherm::initialize() { OpenTherm::instance = this; #endif this->in_pin_->pin_mode(gpio::FLAG_INPUT); + this->in_pin_->setup(); this->out_pin_->pin_mode(gpio::FLAG_OUTPUT); + this->out_pin_->setup(); this->out_pin_->digital_write(true); #if defined(ESP32) || defined(USE_ESP_IDF) @@ -182,7 +184,7 @@ bool IRAM_ATTR OpenTherm::timer_isr(OpenTherm *arg) { } arg->capture_ = 1; // reset counter } else if (arg->capture_ > 0xFF) { - // no change for too long, invalid mancheter encoding + // no change for too long, invalid manchester encoding arg->mode_ = OperationMode::ERROR_PROTOCOL; arg->error_type_ = ProtocolErrorType::NO_CHANGE_TOO_LONG; arg->stop_timer_(); @@ -312,21 +314,31 @@ bool OpenTherm::init_esp32_timer_() { } void IRAM_ATTR OpenTherm::start_esp32_timer_(uint64_t alarm_value) { - esp_err_t result; + // We will report timer errors outside of interrupt handler + this->timer_error_ = ESP_OK; + this->timer_error_type_ = TimerErrorType::NO_TIMER_ERROR; - result = timer_set_alarm_value(this->timer_group_, this->timer_idx_, alarm_value); - if (result != ESP_OK) { - const auto *error = esp_err_to_name(result); - ESP_LOGE(TAG, "Failed to set alarm value. Error: %s", error); + this->timer_error_ = timer_set_alarm_value(this->timer_group_, this->timer_idx_, alarm_value); + if (this->timer_error_ != ESP_OK) { + this->timer_error_type_ = TimerErrorType::SET_ALARM_VALUE_ERROR; + return; + } + this->timer_error_ = timer_start(this->timer_group_, this->timer_idx_); + if (this->timer_error_ != ESP_OK) { + this->timer_error_type_ = TimerErrorType::TIMER_START_ERROR; + } +} + +void OpenTherm::report_and_reset_timer_error() { + if (this->timer_error_ == ESP_OK) { return; } - result = timer_start(this->timer_group_, this->timer_idx_); - if (result != ESP_OK) { - const auto *error = esp_err_to_name(result); - ESP_LOGE(TAG, "Failed to start the timer. Error: %s", error); - return; - } + ESP_LOGE(TAG, "Error occured while manipulating timer (%s): %s", this->timer_error_to_str(this->timer_error_type_), + esp_err_to_name(this->timer_error_)); + + this->timer_error_ = ESP_OK; + this->timer_error_type_ = NO_TIMER_ERROR; } // 5 kHz timer_ @@ -343,21 +355,18 @@ void IRAM_ATTR OpenTherm::start_write_timer_() { void IRAM_ATTR OpenTherm::stop_timer_() { InterruptLock const lock; + // We will report timer errors outside of interrupt handler + this->timer_error_ = ESP_OK; + this->timer_error_type_ = TimerErrorType::NO_TIMER_ERROR; - esp_err_t result; - - result = timer_pause(this->timer_group_, this->timer_idx_); - if (result != ESP_OK) { - const auto *error = esp_err_to_name(result); - ESP_LOGE(TAG, "Failed to pause the timer. Error: %s", error); + this->timer_error_ = timer_pause(this->timer_group_, this->timer_idx_); + if (this->timer_error_ != ESP_OK) { + this->timer_error_type_ = TimerErrorType::TIMER_PAUSE_ERROR; return; } - - result = timer_set_counter_value(this->timer_group_, this->timer_idx_, 0); - if (result != ESP_OK) { - const auto *error = esp_err_to_name(result); - ESP_LOGE(TAG, "Failed to set timer counter to 0 after pausing. Error: %s", error); - return; + this->timer_error_ = timer_set_counter_value(this->timer_group_, this->timer_idx_, 0); + if (this->timer_error_ != ESP_OK) { + this->timer_error_type_ = TimerErrorType::SET_COUNTER_VALUE_ERROR; } } @@ -386,6 +395,9 @@ void IRAM_ATTR OpenTherm::stop_timer_() { timer1_detachInterrupt(); } +// There is nothing to report on ESP8266 +void OpenTherm::report_and_reset_timer_error() {} + #endif // END ESP8266 // https://stackoverflow.com/questions/21617970/how-to-check-if-value-has-even-parity-of-bits-or-odd @@ -412,11 +424,12 @@ const char *OpenTherm::operation_mode_to_str(OperationMode mode) { TO_STRING_MEMBER(SENT) TO_STRING_MEMBER(ERROR_PROTOCOL) TO_STRING_MEMBER(ERROR_TIMEOUT) + TO_STRING_MEMBER(ERROR_TIMER) default: return ""; } } -const char *OpenTherm::protocol_error_to_to_str(ProtocolErrorType error_type) { +const char *OpenTherm::protocol_error_to_str(ProtocolErrorType error_type) { switch (error_type) { TO_STRING_MEMBER(NO_ERROR) TO_STRING_MEMBER(NO_TRANSITION) @@ -427,6 +440,17 @@ const char *OpenTherm::protocol_error_to_to_str(ProtocolErrorType error_type) { return ""; } } +const char *OpenTherm::timer_error_to_str(TimerErrorType error_type) { + switch (error_type) { + TO_STRING_MEMBER(NO_TIMER_ERROR) + TO_STRING_MEMBER(SET_ALARM_VALUE_ERROR) + TO_STRING_MEMBER(TIMER_START_ERROR) + TO_STRING_MEMBER(TIMER_PAUSE_ERROR) + TO_STRING_MEMBER(SET_COUNTER_VALUE_ERROR) + default: + return ""; + } +} const char *OpenTherm::message_type_to_str(MessageType message_type) { switch (message_type) { TO_STRING_MEMBER(READ_DATA) diff --git a/esphome/components/opentherm/opentherm.h b/esphome/components/opentherm/opentherm.h index 3be0191c63..4280832d09 100644 --- a/esphome/components/opentherm/opentherm.h +++ b/esphome/components/opentherm/opentherm.h @@ -36,11 +36,12 @@ enum OperationMode { READ = 2, // reading 32-bit data frame RECEIVED = 3, // data frame received with valid start and stop bit - WRITE = 4, // writing data with timer_ + WRITE = 4, // writing data to output SENT = 5, // all data written to output - ERROR_PROTOCOL = 8, // manchester protocol data transfer error - ERROR_TIMEOUT = 9 // read timeout + ERROR_PROTOCOL = 8, // protocol error, can happed only during READ + ERROR_TIMEOUT = 9, // timeout while waiting for response from device, only during LISTEN + ERROR_TIMER = 10 // error operating the ESP32 timer }; enum ProtocolErrorType { @@ -51,6 +52,14 @@ enum ProtocolErrorType { NO_CHANGE_TOO_LONG = 4, // No level change for too much timer ticks }; +enum TimerErrorType { + NO_TIMER_ERROR = 0, // No error + SET_ALARM_VALUE_ERROR = 1, // No transition in the middle of the bit + TIMER_START_ERROR = 2, // Stop bit wasn't present when expected + TIMER_PAUSE_ERROR = 3, // Parity check didn't pass + SET_COUNTER_VALUE_ERROR = 4, // No level change for too much timer ticks +}; + enum MessageType { READ_DATA = 0, READ_ACK = 4, @@ -299,7 +308,9 @@ class OpenTherm { * * @return true if last listen() or send() operation ends up with an error. */ - bool is_error() { return mode_ == OperationMode::ERROR_TIMEOUT || mode_ == OperationMode::ERROR_PROTOCOL; } + bool is_error() { + return mode_ == OperationMode::ERROR_TIMEOUT || mode_ == OperationMode::ERROR_PROTOCOL || mode_ == ERROR_TIMER; + } /** * Indicates whether last listen() or send() operation ends up with a *timeout* error @@ -313,14 +324,22 @@ class OpenTherm { */ bool is_protocol_error() { return mode_ == OperationMode::ERROR_PROTOCOL; } + /** + * Indicates whether start_esp32_timer_() or stop_timer_() had an error. Only relevant when used on ESP32. + * @return true if there was an error. + */ + bool is_timer_error() { return mode_ == OperationMode::ERROR_TIMER; } + bool is_active() { return mode_ == LISTEN || mode_ == READ || mode_ == WRITE; } OperationMode get_mode() { return mode_; } void debug_data(OpenthermData &data); void debug_error(OpenThermError &error) const; + void report_and_reset_timer_error(); - const char *protocol_error_to_to_str(ProtocolErrorType error_type); + const char *protocol_error_to_str(ProtocolErrorType error_type); + const char *timer_error_to_str(TimerErrorType error_type); const char *message_type_to_str(MessageType message_type); const char *operation_mode_to_str(OperationMode mode); const char *message_id_to_str(MessageId id); @@ -349,10 +368,12 @@ class OpenTherm { uint32_t data_; uint8_t bit_pos_; int32_t timeout_counter_; // <0 no timeout - int32_t device_timeout_; #if defined(ESP32) || defined(USE_ESP_IDF) + esp_err_t timer_error_ = ESP_OK; + TimerErrorType timer_error_type_ = TimerErrorType::NO_TIMER_ERROR; + bool init_esp32_timer_(); void start_esp32_timer_(uint64_t alarm_value); #endif diff --git a/esphome/components/opentherm/opentherm_macros.h b/esphome/components/opentherm/opentherm_macros.h index 8aaec0b48a..398c64aa8f 100644 --- a/esphome/components/opentherm/opentherm_macros.h +++ b/esphome/components/opentherm/opentherm_macros.h @@ -28,6 +28,9 @@ namespace opentherm { #ifndef OPENTHERM_INPUT_SENSOR_LIST #define OPENTHERM_INPUT_SENSOR_LIST(F, sep) #endif +#ifndef OPENTHERM_SETTING_LIST +#define OPENTHERM_SETTING_LIST(F, sep) +#endif // Use macros to create fields for every entity specified in the ESPHome configuration #define OPENTHERM_DECLARE_SENSOR(entity) sensor::Sensor *entity; @@ -36,6 +39,7 @@ namespace opentherm { #define OPENTHERM_DECLARE_NUMBER(entity) OpenthermNumber *entity; #define OPENTHERM_DECLARE_OUTPUT(entity) OpenthermOutput *entity; #define OPENTHERM_DECLARE_INPUT_SENSOR(entity) sensor::Sensor *entity; +#define OPENTHERM_DECLARE_SETTING(type, entity, def) type entity = def; // Setter macros #define OPENTHERM_SET_SENSOR(entity) \ @@ -56,6 +60,9 @@ namespace opentherm { #define OPENTHERM_SET_INPUT_SENSOR(entity) \ void set_##entity(sensor::Sensor *sensor) { this->entity = sensor; } +#define OPENTHERM_SET_SETTING(type, entity, def) \ + void set_##entity(type value) { this->entity = value; } + // ===== hub.cpp macros ===== // *_MESSAGE_HANDLERS are generated in defines.h and look like this: @@ -85,6 +92,9 @@ namespace opentherm { #ifndef OPENTHERM_INPUT_SENSOR_MESSAGE_HANDLERS #define OPENTHERM_INPUT_SENSOR_MESSAGE_HANDLERS(MESSAGE, ENTITY, entity_sep, postscript, msg_sep) #endif +#ifndef OPENTHERM_SETTING_MESSAGE_HANDLERS +#define OPENTHERM_SETTING_MESSAGE_HANDLERS(MESSAGE, ENTITY, entity_sep, postscript, msg_sep) +#endif // Write data request builders #define OPENTHERM_MESSAGE_WRITE_MESSAGE(msg) \ @@ -92,6 +102,7 @@ namespace opentherm { data.type = MessageType::WRITE_DATA; \ data.id = request_id; #define OPENTHERM_MESSAGE_WRITE_ENTITY(key, msg_data) message_data::write_##msg_data(this->key->state, data); +#define OPENTHERM_MESSAGE_WRITE_SETTING(key, msg_data) message_data::write_##msg_data(this->key, data); #define OPENTHERM_MESSAGE_WRITE_POSTSCRIPT \ return data; \ } diff --git a/esphome/components/opentherm/schema.py b/esphome/components/opentherm/schema.py index fe0f2a77a3..a58de8e2da 100644 --- a/esphome/components/opentherm/schema.py +++ b/esphome/components/opentherm/schema.py @@ -2,8 +2,9 @@ # inputs of the OpenTherm component. from dataclasses import dataclass -from typing import Optional, TypeVar +from typing import Optional, TypeVar, Any +import esphome.config_validation as cv from esphome.const import ( UNIT_CELSIUS, UNIT_EMPTY, @@ -64,6 +65,7 @@ class SensorSchema(EntitySchema): icon: Optional[str] = None device_class: Optional[str] = None disabled_by_default: bool = False + order: Optional[int] = None SENSORS: dict[str, SensorSchema] = { @@ -399,6 +401,7 @@ SENSORS: dict[str, SensorSchema] = { message="OT_VERSION_DEVICE", keep_updated=False, message_data="f88", + order=2, ), "device_type": SensorSchema( description="Device product type", @@ -409,6 +412,7 @@ SENSORS: dict[str, SensorSchema] = { message="VERSION_DEVICE", keep_updated=False, message_data="u8_hb", + order=0, ), "device_version": SensorSchema( description="Device product version", @@ -419,6 +423,7 @@ SENSORS: dict[str, SensorSchema] = { message="VERSION_DEVICE", keep_updated=False, message_data="u8_lb", + order=0, ), "device_id": SensorSchema( description="Device ID code", @@ -429,6 +434,7 @@ SENSORS: dict[str, SensorSchema] = { message="DEVICE_CONFIG", keep_updated=False, message_data="u8_lb", + order=4, ), "otc_hc_ratio_ub": SensorSchema( description="OTC heat curve ratio upper bound", @@ -457,6 +463,7 @@ SENSORS: dict[str, SensorSchema] = { class BinarySensorSchema(EntitySchema): icon: Optional[str] = None device_class: Optional[str] = None + order: Optional[int] = None BINARY_SENSORS: dict[str, BinarySensorSchema] = { @@ -525,48 +532,56 @@ BINARY_SENSORS: dict[str, BinarySensorSchema] = { message="DEVICE_CONFIG", keep_updated=False, message_data="flag8_hb_0", + order=4, ), "control_type_on_off": BinarySensorSchema( description="Configuration: Control type is on/off", message="DEVICE_CONFIG", keep_updated=False, message_data="flag8_hb_1", + order=4, ), "cooling_supported": BinarySensorSchema( description="Configuration: Cooling supported", message="DEVICE_CONFIG", keep_updated=False, message_data="flag8_hb_2", + order=4, ), "dhw_storage_tank": BinarySensorSchema( description="Configuration: DHW storage tank", message="DEVICE_CONFIG", keep_updated=False, message_data="flag8_hb_3", + order=4, ), "controller_pump_control_allowed": BinarySensorSchema( description="Configuration: Controller pump control allowed", message="DEVICE_CONFIG", keep_updated=False, message_data="flag8_hb_4", + order=4, ), "ch2_present": BinarySensorSchema( description="Configuration: CH2 present", message="DEVICE_CONFIG", keep_updated=False, message_data="flag8_hb_5", + order=4, ), "water_filling": BinarySensorSchema( description="Configuration: Remote water filling", message="DEVICE_CONFIG", keep_updated=False, message_data="flag8_hb_6", + order=4, ), "heat_mode": BinarySensorSchema( description="Configuration: Heating or cooling", message="DEVICE_CONFIG", keep_updated=False, message_data="flag8_hb_7", + order=4, ), "dhw_setpoint_transfer_enabled": BinarySensorSchema( description="Remote boiler parameters: DHW setpoint transfer enabled", @@ -812,3 +827,65 @@ INPUTS: dict[str, InputSchema] = { auto_max_value=AutoConfigure(message="OTC_CURVE_BOUNDS", message_data="u8_hb"), ), } + + +@dataclass +class SettingSchema(EntitySchema): + backing_type: str + validation_schema: cv.Schema + default_value: Any + order: Optional[int] = None + + +SETTINGS: dict[str, SettingSchema] = { + "controller_product_type": SettingSchema( + description="Controller product type", + message="VERSION_CONTROLLER", + keep_updated=False, + message_data="u8_hb", + backing_type="uint8_t", + validation_schema=cv.int_range(min=0, max=255), + default_value=0, + order=1, + ), + "controller_product_version": SettingSchema( + description="Controller product version", + message="VERSION_CONTROLLER", + keep_updated=False, + message_data="u8_lb", + backing_type="uint8_t", + validation_schema=cv.int_range(min=0, max=255), + default_value=0, + order=1, + ), + "opentherm_version_controller": SettingSchema( + description="Version of OpenTherm implemented by controller", + message="OT_VERSION_CONTROLLER", + keep_updated=False, + message_data="f88", + backing_type="float", + validation_schema=cv.positive_float, + default_value=0, + order=3, + ), + "controller_configuration": SettingSchema( + description="Controller configuration", + message="CONTROLLER_CONFIG", + keep_updated=False, + message_data="u8_hb", + backing_type="uint8_t", + validation_schema=cv.int_range(min=0, max=255), + default_value=0, + order=5, + ), + "controller_id": SettingSchema( + description="Controller ID code", + message="CONTROLLER_CONFIG", + keep_updated=False, + message_data="u8_lb", + backing_type="uint8_t", + validation_schema=cv.int_range(min=0, max=255), + default_value=0, + order=5, + ), +} diff --git a/esphome/components/opentherm/validate.py b/esphome/components/opentherm/validate.py index d4507672a5..055cbfa827 100644 --- a/esphome/components/opentherm/validate.py +++ b/esphome/components/opentherm/validate.py @@ -9,12 +9,17 @@ from .schema import TSchema def create_entities_schema( - entities: dict[str, schema.EntitySchema], + entities: dict[str, TSchema], get_entity_validation_schema: Callable[[TSchema], cv.Schema], ) -> Schema: entity_schema = {} for key, entity in entities.items(): - entity_schema[cv.Optional(key)] = get_entity_validation_schema(entity) + schema_key = ( + cv.Optional(key, entity.default_value) + if hasattr(entity, "default_value") + else cv.Optional(key) + ) + entity_schema[schema_key] = get_entity_validation_schema(entity) return cv.Schema(entity_schema) diff --git a/tests/components/opentherm/common.yaml b/tests/components/opentherm/common.yaml index 744580f18b..5edacc6f17 100644 --- a/tests/components/opentherm/common.yaml +++ b/tests/components/opentherm/common.yaml @@ -16,6 +16,19 @@ opentherm: summer_mode_active: true dhw_block: true sync_mode: true + controller_product_type: 63 + controller_product_version: 1 + opentherm_version_controller: 2.2 + controller_id: 1 + controller_configuration: 1 + before_send: + then: + - lambda: |- + ESP_LOGW("OT", ">> Sending message %d", x.id); + before_process_response: + then: + - lambda: |- + ESP_LOGW("OT", "<< Processing response %d", x.id); output: - platform: opentherm From e04743e38196f59eb4e23b59756be6d71ed154c1 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 16 Dec 2024 00:12:45 +0100 Subject: [PATCH 013/194] [debug] Detailed reset reason (#7729) Co-authored-by: Ramil Valitov --- esphome/components/debug/debug_esp32.cpp | 201 ++++++++++++++--------- 1 file changed, 127 insertions(+), 74 deletions(-) diff --git a/esphome/components/debug/debug_esp32.cpp b/esphome/components/debug/debug_esp32.cpp index cb4330f422..5f7b9cdbb0 100644 --- a/esphome/components/debug/debug_esp32.cpp +++ b/esphome/components/debug/debug_esp32.cpp @@ -30,109 +30,162 @@ static const char *const TAG = "debug"; std::string DebugComponent::get_reset_reason_() { std::string reset_reason; - switch (rtc_get_reset_reason(0)) { - case POWERON_RESET: - reset_reason = "Power On Reset"; + switch (esp_reset_reason()) { + case ESP_RST_POWERON: + reset_reason = "Reset due to power-on event"; break; + case ESP_RST_EXT: + reset_reason = "Reset by external pin"; + break; + case ESP_RST_SW: + reset_reason = "Software reset via esp_restart"; + break; + case ESP_RST_PANIC: + reset_reason = "Software reset due to exception/panic"; + break; + case ESP_RST_INT_WDT: + reset_reason = "Reset (software or hardware) due to interrupt watchdog"; + break; + case ESP_RST_TASK_WDT: + reset_reason = "Reset due to task watchdog"; + break; + case ESP_RST_WDT: + reset_reason = "Reset due to other watchdogs"; + break; + case ESP_RST_DEEPSLEEP: + reset_reason = "Reset after exiting deep sleep mode"; + break; + case ESP_RST_BROWNOUT: + reset_reason = "Brownout reset (software or hardware)"; + break; + case ESP_RST_SDIO: + reset_reason = "Reset over SDIO"; + break; +#ifdef USE_ESP32_VARIANT_ESP32 +#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 4)) + case ESP_RST_USB: + reset_reason = "Reset by USB peripheral"; + break; + case ESP_RST_JTAG: + reset_reason = "Reset by JTAG"; + break; + case ESP_RST_EFUSE: + reset_reason = "Reset due to efuse error"; + break; + case ESP_RST_PWR_GLITCH: + reset_reason = "Reset due to power glitch detected"; + break; + case ESP_RST_CPU_LOCKUP: + reset_reason = "Reset due to CPU lock up (double exception)"; + break; +#endif // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 4) +#endif // USE_ESP32_VARIANT_ESP32 + default: // Includes ESP_RST_UNKNOWN + switch (rtc_get_reset_reason(0)) { + case POWERON_RESET: + reset_reason = "Power On Reset"; + break; #if defined(USE_ESP32_VARIANT_ESP32) - case SW_RESET: + case SW_RESET: #elif defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || \ defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32C6) - case RTC_SW_SYS_RESET: + case RTC_SW_SYS_RESET: #endif - reset_reason = "Software Reset Digital Core"; - break; + reset_reason = "Software Reset Digital Core"; + break; #if defined(USE_ESP32_VARIANT_ESP32) - case OWDT_RESET: - reset_reason = "Watch Dog Reset Digital Core"; - break; + case OWDT_RESET: + reset_reason = "Watch Dog Reset Digital Core"; + break; #endif - case DEEPSLEEP_RESET: - reset_reason = "Deep Sleep Reset Digital Core"; - break; + case DEEPSLEEP_RESET: + reset_reason = "Deep Sleep Reset Digital Core"; + break; #if defined(USE_ESP32_VARIANT_ESP32) - case SDIO_RESET: - reset_reason = "SLC Module Reset Digital Core"; - break; + case SDIO_RESET: + reset_reason = "SLC Module Reset Digital Core"; + break; #endif - case TG0WDT_SYS_RESET: - reset_reason = "Timer Group 0 Watch Dog Reset Digital Core"; - break; - case TG1WDT_SYS_RESET: - reset_reason = "Timer Group 1 Watch Dog Reset Digital Core"; - break; - case RTCWDT_SYS_RESET: - reset_reason = "RTC Watch Dog Reset Digital Core"; - break; + case TG0WDT_SYS_RESET: + reset_reason = "Timer Group 0 Watch Dog Reset Digital Core"; + break; + case TG1WDT_SYS_RESET: + reset_reason = "Timer Group 1 Watch Dog Reset Digital Core"; + break; + case RTCWDT_SYS_RESET: + reset_reason = "RTC Watch Dog Reset Digital Core"; + break; #if !defined(USE_ESP32_VARIANT_ESP32C6) && !defined(USE_ESP32_VARIANT_ESP32H2) - case INTRUSION_RESET: - reset_reason = "Intrusion Reset CPU"; - break; + case INTRUSION_RESET: + reset_reason = "Intrusion Reset CPU"; + break; #endif #if defined(USE_ESP32_VARIANT_ESP32) - case TGWDT_CPU_RESET: - reset_reason = "Timer Group Reset CPU"; - break; + case TGWDT_CPU_RESET: + reset_reason = "Timer Group Reset CPU"; + break; #elif defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || \ defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32C6) - case TG0WDT_CPU_RESET: - reset_reason = "Timer Group 0 Reset CPU"; - break; + case TG0WDT_CPU_RESET: + reset_reason = "Timer Group 0 Reset CPU"; + break; #endif #if defined(USE_ESP32_VARIANT_ESP32) - case SW_CPU_RESET: + case SW_CPU_RESET: #elif defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || \ defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32C6) - case RTC_SW_CPU_RESET: + case RTC_SW_CPU_RESET: #endif - reset_reason = "Software Reset CPU"; - break; - case RTCWDT_CPU_RESET: - reset_reason = "RTC Watch Dog Reset CPU"; - break; + reset_reason = "Software Reset CPU"; + break; + case RTCWDT_CPU_RESET: + reset_reason = "RTC Watch Dog Reset CPU"; + break; #if defined(USE_ESP32_VARIANT_ESP32) - case EXT_CPU_RESET: - reset_reason = "External CPU Reset"; - break; + case EXT_CPU_RESET: + reset_reason = "External CPU Reset"; + break; #endif - case RTCWDT_BROWN_OUT_RESET: - reset_reason = "Voltage Unstable Reset"; - break; - case RTCWDT_RTC_RESET: - reset_reason = "RTC Watch Dog Reset Digital Core And RTC Module"; - break; + case RTCWDT_BROWN_OUT_RESET: + reset_reason = "Voltage Unstable Reset"; + break; + case RTCWDT_RTC_RESET: + reset_reason = "RTC Watch Dog Reset Digital Core And RTC Module"; + break; #if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || \ defined(USE_ESP32_VARIANT_ESP32C6) - case TG1WDT_CPU_RESET: - reset_reason = "Timer Group 1 Reset CPU"; - break; - case SUPER_WDT_RESET: - reset_reason = "Super Watchdog Reset Digital Core And RTC Module"; - break; - case EFUSE_RESET: - reset_reason = "eFuse Reset Digital Core"; - break; + case TG1WDT_CPU_RESET: + reset_reason = "Timer Group 1 Reset CPU"; + break; + case SUPER_WDT_RESET: + reset_reason = "Super Watchdog Reset Digital Core And RTC Module"; + break; + case EFUSE_RESET: + reset_reason = "eFuse Reset Digital Core"; + break; #endif #if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) - case GLITCH_RTC_RESET: - reset_reason = "Glitch Reset Digital Core And RTC Module"; - break; + case GLITCH_RTC_RESET: + reset_reason = "Glitch Reset Digital Core And RTC Module"; + break; #endif #if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32C6) - case USB_UART_CHIP_RESET: - reset_reason = "USB UART Reset Digital Core"; - break; - case USB_JTAG_CHIP_RESET: - reset_reason = "USB JTAG Reset Digital Core"; - break; + case USB_UART_CHIP_RESET: + reset_reason = "USB UART Reset Digital Core"; + break; + case USB_JTAG_CHIP_RESET: + reset_reason = "USB JTAG Reset Digital Core"; + break; #endif #if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32S3) - case POWER_GLITCH_RESET: - reset_reason = "Power Glitch Reset Digital Core And RTC Module"; - break; + case POWER_GLITCH_RESET: + reset_reason = "Power Glitch Reset Digital Core And RTC Module"; + break; #endif - default: - reset_reason = "Unknown Reset Reason"; + default: + reset_reason = "Unknown Reset Reason"; + } + break; } ESP_LOGD(TAG, "Reset Reason: %s", reset_reason.c_str()); return reset_reason; @@ -294,4 +347,4 @@ void DebugComponent::update_platform_() { } // namespace debug } // namespace esphome -#endif +#endif // USE_ESP32 From 1a89aa8fbfb5828f6c3bbf72343b72b8ce581187 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 16 Dec 2024 18:52:34 +1300 Subject: [PATCH 014/194] [uart] Use ``SOC_UART_NUM`` as number of uarts instead of ``UART_NUM_MAX`` (#7967) --- esphome/components/uart/uart_component_esp32_arduino.cpp | 4 ++-- esphome/components/uart/uart_component_esp_idf.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/components/uart/uart_component_esp32_arduino.cpp b/esphome/components/uart/uart_component_esp32_arduino.cpp index 793c1d52f4..b241c03de4 100644 --- a/esphome/components/uart/uart_component_esp32_arduino.cpp +++ b/esphome/components/uart/uart_component_esp32_arduino.cpp @@ -1,9 +1,9 @@ #ifdef USE_ESP32_FRAMEWORK_ARDUINO +#include "uart_component_esp32_arduino.h" #include "esphome/core/application.h" #include "esphome/core/defines.h" #include "esphome/core/helpers.h" #include "esphome/core/log.h" -#include "uart_component_esp32_arduino.h" #ifdef USE_LOGGER #include "esphome/components/logger/logger.h" @@ -118,7 +118,7 @@ void ESP32ArduinoUARTComponent::setup() { } #endif // USE_LOGGER - if (next_uart_num >= UART_NUM_MAX) { + if (next_uart_num >= SOC_UART_NUM) { ESP_LOGW(TAG, "Maximum number of UART components created already."); this->mark_failed(); return; diff --git a/esphome/components/uart/uart_component_esp_idf.cpp b/esphome/components/uart/uart_component_esp_idf.cpp index 6999dfb619..122d4105c8 100644 --- a/esphome/components/uart/uart_component_esp_idf.cpp +++ b/esphome/components/uart/uart_component_esp_idf.cpp @@ -1,11 +1,11 @@ #ifdef USE_ESP_IDF #include "uart_component_esp_idf.h" +#include #include "esphome/core/application.h" #include "esphome/core/defines.h" #include "esphome/core/helpers.h" #include "esphome/core/log.h" -#include #ifdef USE_LOGGER #include "esphome/components/logger/logger.h" @@ -84,7 +84,7 @@ void IDFUARTComponent::setup() { } #endif // USE_LOGGER - if (next_uart_num >= UART_NUM_MAX) { + if (next_uart_num >= SOC_UART_NUM) { ESP_LOGW(TAG, "Maximum number of UART components created already."); this->mark_failed(); return; From 663e18310dbd46f96281fb554e2ad2aa495b22d8 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:58:42 +1300 Subject: [PATCH 015/194] [ci] Dont run main ci suite on docker files (#7966) --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ce4159da0..a344b177ae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,7 @@ on: - ".github/workflows/ci.yml" - "!.yamllint" - "!.github/dependabot.yml" + - "!docker/**" merge_group: permissions: From 9f6c64afa64155435f7191862d42896cb57839c9 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Tue, 17 Dec 2024 12:07:43 +1100 Subject: [PATCH 016/194] [font] cleanly handle font file format exception (Bugfix) (#7970) --- esphome/components/font/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/esphome/components/font/__init__.py b/esphome/components/font/__init__.py index c397ba8306..e2051298fe 100644 --- a/esphome/components/font/__init__.py +++ b/esphome/components/font/__init__.py @@ -51,8 +51,11 @@ CONF_IGNORE_MISSING_GLYPHS = "ignore_missing_glyphs" # Cache loaded freetype fonts class FontCache(dict): def __missing__(self, key): - res = self[key] = freetype.Face(key) - return res + try: + res = self[key] = freetype.Face(key) + return res + except freetype.FT_Exception as e: + raise cv.Invalid(f"Could not load Font file {key}: {e}") from e FONT_CACHE = FontCache() From 3d56397e5881baf38d6afa108659af50fbad4e18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:09:09 +1300 Subject: [PATCH 017/194] Bump docker/setup-buildx-action from 3.7.1 to 3.8.0 in the docker-actions group (#7969) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-docker.yml | 2 +- .github/workflows/release.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 435a58498e..cf7b08f3d4 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -46,7 +46,7 @@ jobs: with: python-version: "3.9" - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.7.1 + uses: docker/setup-buildx-action@v3.8.0 - name: Set up QEMU uses: docker/setup-qemu-action@v3.2.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a4e4305207..6cd86854b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -90,7 +90,7 @@ jobs: python-version: "3.9" - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.7.1 + uses: docker/setup-buildx-action@v3.8.0 - name: Set up QEMU if: matrix.platform != 'linux/amd64' uses: docker/setup-qemu-action@v3.2.0 @@ -184,7 +184,7 @@ jobs: merge-multiple: true - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.7.1 + uses: docker/setup-buildx-action@v3.8.0 - name: Log in to docker hub if: matrix.registry == 'dockerhub' From 759df7ae6c98e6ea656bcd0f56662204c0f6a963 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:26:16 +1300 Subject: [PATCH 018/194] [dashboard] Accept basic auth header (#7965) --- esphome/dashboard/web_server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/esphome/dashboard/web_server.py b/esphome/dashboard/web_server.py index 0fed8e9c53..67712da9b6 100644 --- a/esphome/dashboard/web_server.py +++ b/esphome/dashboard/web_server.py @@ -108,6 +108,12 @@ def is_authenticated(handler: BaseHandler) -> bool: return True if settings.using_auth: + if auth_header := handler.request.headers.get("Authorization"): + assert isinstance(auth_header, str) + if auth_header.startswith("Basic "): + auth_decoded = base64.b64decode(auth_header[6:]).decode() + username, password = auth_decoded.split(":", 1) + return settings.check_password(username, password) return handler.get_secure_cookie(AUTH_COOKIE_NAME) == COOKIE_AUTHENTICATED_YES return True From 54fbf5184ed985a9b30d4a7688dcc3656c96fb8f Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:32:52 +1300 Subject: [PATCH 019/194] Bump esphome-dashboard to 20241217.1 (#7971) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7bc1c895df..d96004c8ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ pyserial==3.5 platformio==6.1.16 # When updating platformio, also update Dockerfile esptool==4.7.0 click==8.1.7 -esphome-dashboard==20241120.0 +esphome-dashboard==20241217.1 aioesphomeapi==24.6.2 zeroconf==0.132.2 puremagic==1.27 From ccc9fd4a3f30472a11071622963d1284aa3016fe Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 18 Dec 2024 07:10:38 +1300 Subject: [PATCH 020/194] [esp32_ble] Use RAMAllocator to avoid panic abort from ``new`` (#7936) --- esphome/components/esp32_ble/ble.cpp | 33 ++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/esphome/components/esp32_ble/ble.cpp b/esphome/components/esp32_ble/ble.cpp index d7dcf93f86..b10e454c21 100644 --- a/esphome/components/esp32_ble/ble.cpp +++ b/esphome/components/esp32_ble/ble.cpp @@ -27,6 +27,9 @@ namespace esp32_ble { static const char *const TAG = "esp32_ble"; +static RAMAllocator EVENT_ALLOCATOR( // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + RAMAllocator::ALLOW_FAILURE | RAMAllocator::ALLOC_INTERNAL); + void ESP32BLE::setup() { global_ble = this; ESP_LOGCONFIG(TAG, "Setting up BLE..."); @@ -322,7 +325,8 @@ void ESP32BLE::loop() { default: break; } - delete ble_event; // NOLINT(cppcoreguidelines-owning-memory) + ble_event->~BLEEvent(); + EVENT_ALLOCATOR.deallocate(ble_event, 1); ble_event = this->ble_events_.pop(); } if (this->advertising_ != nullptr) { @@ -331,9 +335,14 @@ void ESP32BLE::loop() { } void ESP32BLE::gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) { - BLEEvent *new_event = new BLEEvent(event, param); // NOLINT(cppcoreguidelines-owning-memory) + BLEEvent *new_event = EVENT_ALLOCATOR.allocate(1); + if (new_event == nullptr) { + // Memory too fragmented to allocate new event. Can only drop it until memory comes back + return; + } + new (new_event) BLEEvent(event, param); global_ble->ble_events_.push(new_event); -} // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) +} // NOLINT(clang-analyzer-unix.Malloc) void ESP32BLE::real_gap_event_handler_(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) { ESP_LOGV(TAG, "(BLE) gap_event_handler - %d", event); @@ -344,9 +353,14 @@ void ESP32BLE::real_gap_event_handler_(esp_gap_ble_cb_event_t event, esp_ble_gap void ESP32BLE::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) { - BLEEvent *new_event = new BLEEvent(event, gatts_if, param); // NOLINT(cppcoreguidelines-owning-memory) + BLEEvent *new_event = EVENT_ALLOCATOR.allocate(1); + if (new_event == nullptr) { + // Memory too fragmented to allocate new event. Can only drop it until memory comes back + return; + } + new (new_event) BLEEvent(event, gatts_if, param); global_ble->ble_events_.push(new_event); -} // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) +} // NOLINT(clang-analyzer-unix.Malloc) void ESP32BLE::real_gatts_event_handler_(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) { @@ -358,9 +372,14 @@ void ESP32BLE::real_gatts_event_handler_(esp_gatts_cb_event_t event, esp_gatt_if void ESP32BLE::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) { - BLEEvent *new_event = new BLEEvent(event, gattc_if, param); // NOLINT(cppcoreguidelines-owning-memory) + BLEEvent *new_event = EVENT_ALLOCATOR.allocate(1); + if (new_event == nullptr) { + // Memory too fragmented to allocate new event. Can only drop it until memory comes back + return; + } + new (new_event) BLEEvent(event, gattc_if, param); global_ble->ble_events_.push(new_event); -} // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) +} // NOLINT(clang-analyzer-unix.Malloc) void ESP32BLE::real_gattc_event_handler_(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) { From 7554e954fe4a50ba8514c301f1bffd73ae62223a Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:12:14 -0500 Subject: [PATCH 021/194] [core] Add c6 and h2 to split default (#7974) Co-authored-by: Jonathan Swoboda --- esphome/config_validation.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/esphome/config_validation.py b/esphome/config_validation.py index ebfb2631c3..38fd677a2a 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -1660,6 +1660,12 @@ class SplitDefault(Optional): esp32_c3=vol.UNDEFINED, esp32_c3_arduino=vol.UNDEFINED, esp32_c3_idf=vol.UNDEFINED, + esp32_c6=vol.UNDEFINED, + esp32_c6_arduino=vol.UNDEFINED, + esp32_c6_idf=vol.UNDEFINED, + esp32_h2=vol.UNDEFINED, + esp32_h2_arduino=vol.UNDEFINED, + esp32_h2_idf=vol.UNDEFINED, rp2040=vol.UNDEFINED, bk72xx=vol.UNDEFINED, rtl87xx=vol.UNDEFINED, @@ -1691,6 +1697,18 @@ class SplitDefault(Optional): self._esp32_c3_idf_default = vol.default_factory( _get_priority_default(esp32_c3_idf, esp32_c3, esp32_idf, esp32) ) + self._esp32_c6_arduino_default = vol.default_factory( + _get_priority_default(esp32_c6_arduino, esp32_c6, esp32_arduino, esp32) + ) + self._esp32_c6_idf_default = vol.default_factory( + _get_priority_default(esp32_c6_idf, esp32_c6, esp32_idf, esp32) + ) + self._esp32_h2_arduino_default = vol.default_factory( + _get_priority_default(esp32_h2_arduino, esp32_h2, esp32_arduino, esp32) + ) + self._esp32_h2_idf_default = vol.default_factory( + _get_priority_default(esp32_h2_idf, esp32_h2, esp32_idf, esp32) + ) self._rp2040_default = vol.default_factory(rp2040) self._bk72xx_default = vol.default_factory(bk72xx) self._rtl87xx_default = vol.default_factory(rtl87xx) @@ -1704,6 +1722,8 @@ class SplitDefault(Optional): from esphome.components.esp32 import get_esp32_variant from esphome.components.esp32.const import ( VARIANT_ESP32C3, + VARIANT_ESP32C6, + VARIANT_ESP32H2, VARIANT_ESP32S2, VARIANT_ESP32S3, ) @@ -1724,6 +1744,16 @@ class SplitDefault(Optional): return self._esp32_c3_arduino_default if CORE.using_esp_idf: return self._esp32_c3_idf_default + elif variant == VARIANT_ESP32C6: + if CORE.using_arduino: + return self._esp32_c6_arduino_default + if CORE.using_esp_idf: + return self._esp32_c6_idf_default + elif variant == VARIANT_ESP32H2: + if CORE.using_arduino: + return self._esp32_h2_arduino_default + if CORE.using_esp_idf: + return self._esp32_h2_idf_default else: if CORE.using_arduino: return self._esp32_arduino_default From a9d883b65a94d609e4851ee23bb34760f648e808 Mon Sep 17 00:00:00 2001 From: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> Date: Wed, 18 Dec 2024 01:47:43 +0100 Subject: [PATCH 022/194] [midea] Add Fahrenheit support to `midea_ac.follow_me` action (#7762) --- esphome/components/midea/ac_automations.h | 4 +- esphome/components/midea/air_conditioner.cpp | 12 +++--- esphome/components/midea/air_conditioner.h | 2 +- esphome/components/midea/climate.py | 6 ++- esphome/components/midea/ir_transmitter.h | 41 +++++++++++++++++--- 5 files changed, 51 insertions(+), 14 deletions(-) diff --git a/esphome/components/midea/ac_automations.h b/esphome/components/midea/ac_automations.h index 5084fd1eec..e6fffa2511 100644 --- a/esphome/components/midea/ac_automations.h +++ b/esphome/components/midea/ac_automations.h @@ -19,10 +19,12 @@ template class MideaActionBase : public Action { template class FollowMeAction : public MideaActionBase { TEMPLATABLE_VALUE(float, temperature) + TEMPLATABLE_VALUE(bool, use_fahrenheit) TEMPLATABLE_VALUE(bool, beeper) void play(Ts... x) override { - this->parent_->do_follow_me(this->temperature_.value(x...), this->beeper_.value(x...)); + this->parent_->do_follow_me(this->temperature_.value(x...), this->use_fahrenheit_.value(x...), + this->beeper_.value(x...)); } }; diff --git a/esphome/components/midea/air_conditioner.cpp b/esphome/components/midea/air_conditioner.cpp index a823680d03..247aea0488 100644 --- a/esphome/components/midea/air_conditioner.cpp +++ b/esphome/components/midea/air_conditioner.cpp @@ -1,6 +1,7 @@ #ifdef USE_ARDUINO #include "esphome/core/log.h" +#include "esphome/core/helpers.h" #include "air_conditioner.h" #include "ac_adapter.h" #include @@ -121,7 +122,7 @@ void AirConditioner::dump_config() { /* ACTIONS */ -void AirConditioner::do_follow_me(float temperature, bool beeper) { +void AirConditioner::do_follow_me(float temperature, bool use_fahrenheit, bool beeper) { #ifdef USE_REMOTE_TRANSMITTER // Check if temperature is finite (not NaN or infinite) if (!std::isfinite(temperature)) { @@ -131,13 +132,14 @@ void AirConditioner::do_follow_me(float temperature, bool beeper) { // Round and convert temperature to long, then clamp and convert it to uint8_t uint8_t temp_uint8 = - static_cast(std::max(0L, std::min(static_cast(UINT8_MAX), std::lroundf(temperature)))); + static_cast(esphome::clamp(std::lroundf(temperature), 0L, static_cast(UINT8_MAX))); - ESP_LOGD(Constants::TAG, "Follow me action called with temperature: %f °C, rounded to: %u °C", temperature, - temp_uint8); + char temp_symbol = use_fahrenheit ? 'F' : 'C'; + ESP_LOGD(Constants::TAG, "Follow me action called with temperature: %.5f °%c, rounded to: %u °%c", temperature, + temp_symbol, temp_uint8, temp_symbol); // Create and transmit the data - IrFollowMeData data(temp_uint8, beeper); + IrFollowMeData data(temp_uint8, use_fahrenheit, beeper); this->transmitter_.transmit(data); #else ESP_LOGW(Constants::TAG, "Action needs remote_transmitter component"); diff --git a/esphome/components/midea/air_conditioner.h b/esphome/components/midea/air_conditioner.h index d809aa78f6..e70bd34e71 100644 --- a/esphome/components/midea/air_conditioner.h +++ b/esphome/components/midea/air_conditioner.h @@ -32,7 +32,7 @@ class AirConditioner : public ApplianceBase, /* ### ACTIONS ### */ /* ############### */ - void do_follow_me(float temperature, bool beeper = false); + void do_follow_me(float temperature, bool use_fahrenheit, bool beeper = false); void do_display_toggle(); void do_swing_step(); void do_beeper_on() { this->set_beeper_feedback(true); } diff --git a/esphome/components/midea/climate.py b/esphome/components/midea/climate.py index e5612796a3..b7fef5e1ab 100644 --- a/esphome/components/midea/climate.py +++ b/esphome/components/midea/climate.py @@ -18,6 +18,7 @@ from esphome.const import ( CONF_SUPPORTED_SWING_MODES, CONF_TIMEOUT, CONF_TEMPERATURE, + CONF_USE_FAHRENHEIT, DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY, @@ -172,11 +173,10 @@ MIDEA_ACTION_BASE_SCHEMA = cv.Schema( ) # FollowMe action -MIDEA_FOLLOW_ME_MIN = 0 -MIDEA_FOLLOW_ME_MAX = 37 MIDEA_FOLLOW_ME_SCHEMA = cv.Schema( { cv.Required(CONF_TEMPERATURE): cv.templatable(cv.temperature), + cv.Optional(CONF_USE_FAHRENHEIT, default=False): cv.templatable(cv.boolean), cv.Optional(CONF_BEEPER, default=False): cv.templatable(cv.boolean), } ) @@ -186,6 +186,8 @@ MIDEA_FOLLOW_ME_SCHEMA = cv.Schema( async def follow_me_to_code(var, config, args): template_ = await cg.templatable(config[CONF_BEEPER], args, cg.bool_) cg.add(var.set_beeper(template_)) + template_ = await cg.templatable(config[CONF_USE_FAHRENHEIT], args, cg.bool_) + cg.add(var.set_use_fahrenheit(template_)) template_ = await cg.templatable(config[CONF_TEMPERATURE], args, cg.float_) cg.add(var.set_temperature(template_)) diff --git a/esphome/components/midea/ir_transmitter.h b/esphome/components/midea/ir_transmitter.h index a8b89f9b7b..eba8fc87f7 100644 --- a/esphome/components/midea/ir_transmitter.h +++ b/esphome/components/midea/ir_transmitter.h @@ -16,22 +16,53 @@ class IrFollowMeData : public IrData { IrFollowMeData() : IrData({MIDEA_TYPE_FOLLOW_ME, 0x82, 0x48, 0x7F, 0x1F}) {} // Copy from Base IrFollowMeData(const IrData &data) : IrData(data) {} - // Direct from temperature and beeper values + // Direct from temperature in celsius and beeper values IrFollowMeData(uint8_t temp, bool beeper = false) : IrFollowMeData() { - this->set_temp(temp); + this->set_temp(temp, false); + this->set_beeper(beeper); + } + // Direct from temperature, fahrenheit and beeper values + IrFollowMeData(uint8_t temp, bool fahrenheit, bool beeper) : IrFollowMeData() { + this->set_temp(temp, fahrenheit); this->set_beeper(beeper); } /* TEMPERATURE */ - uint8_t temp() const { return this->get_value_(4) - 1; } - void set_temp(uint8_t val) { this->set_value_(4, std::min(MAX_TEMP, val) + 1); } + uint8_t temp() const { + if (this->fahrenheit()) { + return this->get_value_(4) + 31; + } + return this->get_value_(4) - 1; + } + void set_temp(uint8_t val, bool fahrenheit = false) { + this->set_fahrenheit(fahrenheit); + if (this->fahrenheit()) { + // see https://github.com/esphome/feature-requests/issues/1627#issuecomment-1365639966 + val = esphome::clamp(val, MIN_TEMP_F, MAX_TEMP_F) - 31; + } else { + val = esphome::clamp(val, MIN_TEMP_C, MAX_TEMP_C) + 1; + } + this->set_value_(4, val); + } /* BEEPER */ bool beeper() const { return this->get_value_(3, 128); } void set_beeper(bool val) { this->set_mask_(3, val, 128); } + /* FAHRENHEIT */ + bool fahrenheit() const { return this->get_value_(2, 32); } + void set_fahrenheit(bool val) { this->set_mask_(2, val, 32); } + protected: - static const uint8_t MAX_TEMP = 37; + static const uint8_t MIN_TEMP_C = 0; + static const uint8_t MAX_TEMP_C = 37; + + // see + // https://github.com/crankyoldgit/IRremoteESP8266/blob/9bdf8abcb465268c5409db99dc83a26df64c7445/src/ir_Midea.h#L116 + static const uint8_t MIN_TEMP_F = 32; + // see + // https://github.com/crankyoldgit/IRremoteESP8266/blob/9bdf8abcb465268c5409db99dc83a26df64c7445/src/ir_Midea.h#L117 + static const uint8_t MAX_TEMP_F = 99; }; class IrSpecialData : public IrData { From 61499dbdd829102f46937bf7a11d2bfa1dd43598 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Wed, 18 Dec 2024 21:07:07 -0500 Subject: [PATCH 023/194] [core] Bugfix: Implement ring buffer with xRingbuffer (#7973) --- esphome/core/ring_buffer.cpp | 90 +++++++++++++++++++++++++++++------- esphome/core/ring_buffer.h | 13 ++++-- 2 files changed, 82 insertions(+), 21 deletions(-) diff --git a/esphome/core/ring_buffer.cpp b/esphome/core/ring_buffer.cpp index 6152ada314..f779531263 100644 --- a/esphome/core/ring_buffer.cpp +++ b/esphome/core/ring_buffer.cpp @@ -13,8 +13,8 @@ static const char *const TAG = "ring_buffer"; RingBuffer::~RingBuffer() { if (this->handle_ != nullptr) { - vStreamBufferDelete(this->handle_); - ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + vRingbufferDelete(this->handle_); + RAMAllocator allocator(RAMAllocator::ALLOW_FAILURE); allocator.deallocate(this->storage_, this->size_); } } @@ -22,26 +22,49 @@ RingBuffer::~RingBuffer() { std::unique_ptr RingBuffer::create(size_t len) { std::unique_ptr rb = make_unique(); - rb->size_ = len + 1; + rb->size_ = len; - ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + RAMAllocator allocator(RAMAllocator::ALLOW_FAILURE); rb->storage_ = allocator.allocate(rb->size_); if (rb->storage_ == nullptr) { return nullptr; } - rb->handle_ = xStreamBufferCreateStatic(rb->size_, 1, rb->storage_, &rb->structure_); + rb->handle_ = xRingbufferCreateStatic(rb->size_, RINGBUF_TYPE_BYTEBUF, rb->storage_, &rb->structure_); ESP_LOGD(TAG, "Created ring buffer with size %u", len); + return rb; } size_t RingBuffer::read(void *data, size_t len, TickType_t ticks_to_wait) { - if (ticks_to_wait > 0) - xStreamBufferSetTriggerLevel(this->handle_, len); + size_t bytes_read = 0; - size_t bytes_read = xStreamBufferReceive(this->handle_, data, len, ticks_to_wait); + void *buffer_data = xRingbufferReceiveUpTo(this->handle_, &bytes_read, ticks_to_wait, len); - xStreamBufferSetTriggerLevel(this->handle_, 1); + if (buffer_data == nullptr) { + return 0; + } + + std::memcpy(data, buffer_data, bytes_read); + + vRingbufferReturnItem(this->handle_, buffer_data); + + if (bytes_read < len) { + // Data may have wrapped around, so read a second time to receive the remainder + size_t follow_up_bytes_read = 0; + size_t bytes_remaining = len - bytes_read; + + buffer_data = xRingbufferReceiveUpTo(this->handle_, &follow_up_bytes_read, 0, bytes_remaining); + + if (buffer_data == nullptr) { + return bytes_read; + } + + std::memcpy((void *) ((uint8_t *) (data) + bytes_read), buffer_data, follow_up_bytes_read); + + vRingbufferReturnItem(this->handle_, buffer_data); + bytes_read += follow_up_bytes_read; + } return bytes_read; } @@ -49,22 +72,55 @@ size_t RingBuffer::read(void *data, size_t len, TickType_t ticks_to_wait) { size_t RingBuffer::write(const void *data, size_t len) { size_t free = this->free(); if (free < len) { - size_t needed = len - free; - uint8_t discard[needed]; - xStreamBufferReceive(this->handle_, discard, needed, 0); + // Free enough space in the ring buffer to fit the new data + this->discard_bytes_(len - free); } - return xStreamBufferSend(this->handle_, data, len, 0); + return this->write_without_replacement(data, len, 0); } size_t RingBuffer::write_without_replacement(const void *data, size_t len, TickType_t ticks_to_wait) { - return xStreamBufferSend(this->handle_, data, len, ticks_to_wait); + if (!xRingbufferSend(this->handle_, data, len, ticks_to_wait)) { + // Couldn't fit all the data, so only write what will fit + size_t free = std::min(this->free(), len); + if (xRingbufferSend(this->handle_, data, free, 0)) { + return free; + } + return 0; + } + return len; } -size_t RingBuffer::available() const { return xStreamBufferBytesAvailable(this->handle_); } +size_t RingBuffer::available() const { + UBaseType_t ux_items_waiting = 0; + vRingbufferGetInfo(this->handle_, nullptr, nullptr, nullptr, nullptr, &ux_items_waiting); + return ux_items_waiting; +} -size_t RingBuffer::free() const { return xStreamBufferSpacesAvailable(this->handle_); } +size_t RingBuffer::free() const { return xRingbufferGetCurFreeSize(this->handle_); } -BaseType_t RingBuffer::reset() { return xStreamBufferReset(this->handle_); } +BaseType_t RingBuffer::reset() { + // Discards all the available data + return this->discard_bytes_(this->available()); +} + +bool RingBuffer::discard_bytes_(size_t discard_bytes) { + size_t bytes_read = 0; + + void *buffer_data = xRingbufferReceiveUpTo(this->handle_, &bytes_read, 0, discard_bytes); + if (buffer_data != nullptr) + vRingbufferReturnItem(this->handle_, buffer_data); + + if (bytes_read < discard_bytes) { + size_t wrapped_bytes_read = 0; + buffer_data = xRingbufferReceiveUpTo(this->handle_, &wrapped_bytes_read, 0, discard_bytes - bytes_read); + if (buffer_data != nullptr) { + vRingbufferReturnItem(this->handle_, buffer_data); + bytes_read += wrapped_bytes_read; + } + } + + return (bytes_read == discard_bytes); +} } // namespace esphome diff --git a/esphome/core/ring_buffer.h b/esphome/core/ring_buffer.h index aade1b5f49..bad96d3181 100644 --- a/esphome/core/ring_buffer.h +++ b/esphome/core/ring_buffer.h @@ -3,7 +3,7 @@ #ifdef USE_ESP32 #include -#include +#include #include #include @@ -82,9 +82,14 @@ class RingBuffer { static std::unique_ptr create(size_t len); protected: - StreamBufferHandle_t handle_; - StaticStreamBuffer_t structure_; - uint8_t *storage_; + /// @brief Discards data from the ring buffer. + /// @param discard_bytes amount of bytes to discard + /// @return True if all bytes were successfully discarded, false otherwise + bool discard_bytes_(size_t discard_bytes); + + RingbufHandle_t handle_{nullptr}; + StaticRingbuffer_t structure_; + uint8_t *storage_{nullptr}; size_t size_{0}; }; From 265b6ec44526392bc94df55d37b1e6b047518627 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Wed, 18 Dec 2024 21:31:22 -0500 Subject: [PATCH 024/194] [esp32_rmt] Updates for IDF 5+ (#7770) Co-authored-by: Jonathan Swoboda Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Keith Burzinski --- esphome/components/esp32_rmt/__init__.py | 31 +++- .../esp32_rmt_led_strip/led_strip.cpp | 78 ++++++++- .../esp32_rmt_led_strip/led_strip.h | 24 ++- .../components/esp32_rmt_led_strip/light.py | 35 +++- .../components/remote_base/remote_base.cpp | 2 +- esphome/components/remote_base/remote_base.h | 20 ++- .../components/remote_receiver/__init__.py | 70 ++++++-- .../remote_receiver/remote_receiver.h | 39 ++++- .../remote_receiver/remote_receiver_esp32.cpp | 145 +++++++++++++++- .../components/remote_transmitter/__init__.py | 56 ++++++- .../remote_transmitter/remote_transmitter.h | 22 ++- .../remote_transmitter_esp32.cpp | 110 +++++++++++- .../test.esp32-c3-idf.yaml | 2 - .../esp32_rmt_led_strip/test.esp32-idf.yaml | 2 - .../remote_receiver/common-actions.yaml | 144 ++++++++++++++++ .../remote_receiver/esp32-common-ard.yaml | 14 ++ .../remote_receiver/esp32-common-idf.yaml | 18 ++ .../remote_receiver/esp32-common.yaml | 157 ------------------ .../remote_receiver/test.esp32-ard.yaml | 2 +- .../remote_receiver/test.esp32-c3-ard.yaml | 2 +- .../remote_receiver/test.esp32-c3-idf.yaml | 8 +- .../remote_receiver/test.esp32-idf.yaml | 8 +- .../remote_receiver/test.esp32-s3-idf.yaml | 8 +- .../remote_receiver/test.esp8266-ard.yaml | 145 +--------------- .../remote_transmitter/esp32-common-ard.yaml | 8 + .../remote_transmitter/esp32-common-idf.yaml | 11 ++ .../remote_transmitter/esp32-common.yaml | 8 - .../remote_transmitter/test.esp32-ard.yaml | 2 +- .../remote_transmitter/test.esp32-c3-ard.yaml | 2 +- .../remote_transmitter/test.esp32-c3-idf.yaml | 7 +- .../remote_transmitter/test.esp32-idf.yaml | 7 +- .../remote_transmitter/test.esp32-s3-idf.yaml | 7 +- .../remote_transmitter/test.esp8266-ard.yaml | 2 +- 33 files changed, 817 insertions(+), 379 deletions(-) create mode 100644 tests/components/remote_receiver/common-actions.yaml create mode 100644 tests/components/remote_receiver/esp32-common-ard.yaml create mode 100644 tests/components/remote_receiver/esp32-common-idf.yaml delete mode 100644 tests/components/remote_receiver/esp32-common.yaml create mode 100644 tests/components/remote_transmitter/esp32-common-ard.yaml create mode 100644 tests/components/remote_transmitter/esp32-common-idf.yaml delete mode 100644 tests/components/remote_transmitter/esp32-common.yaml diff --git a/esphome/components/esp32_rmt/__init__.py b/esphome/components/esp32_rmt/__init__.py index bda240680b..171c335727 100644 --- a/esphome/components/esp32_rmt/__init__.py +++ b/esphome/components/esp32_rmt/__init__.py @@ -1,7 +1,8 @@ -import esphome.config_validation as cv import esphome.codegen as cg - from esphome.components import esp32 +import esphome.config_validation as cv +from esphome.const import KEY_CORE, KEY_FRAMEWORK_VERSION +from esphome.core import CORE CODEOWNERS = ["@jesserockz"] @@ -36,8 +37,32 @@ RMT_CHANNEL_ENUMS = { } -def validate_rmt_channel(*, tx: bool): +def use_new_rmt_driver(): + framework_version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] + if CORE.using_esp_idf and framework_version >= cv.Version(5, 0, 0): + return True + return False + +def validate_clock_resolution(): + def _validator(value): + cv.only_on_esp32(value) + value = cv.int_(value) + variant = esp32.get_esp32_variant() + if variant == esp32.const.VARIANT_ESP32H2 and value > 32000000: + raise cv.Invalid( + f"ESP32 variant {variant} has a max clock_resolution of 32000000." + ) + if value > 80000000: + raise cv.Invalid( + f"ESP32 variant {variant} has a max clock_resolution of 80000000." + ) + return value + + return _validator + + +def validate_rmt_channel(*, tx: bool): rmt_channels = RMT_TX_CHANNELS if tx else RMT_RX_CHANNELS def _validator(value): diff --git a/esphome/components/esp32_rmt_led_strip/led_strip.cpp b/esphome/components/esp32_rmt_led_strip/led_strip.cpp index c2209f7a6c..8ee890ec10 100644 --- a/esphome/components/esp32_rmt_led_strip/led_strip.cpp +++ b/esphome/components/esp32_rmt_led_strip/led_strip.cpp @@ -1,5 +1,5 @@ -#include #include "led_strip.h" +#include #ifdef USE_ESP32 @@ -13,9 +13,13 @@ namespace esp32_rmt_led_strip { static const char *const TAG = "esp32_rmt_led_strip"; +#ifdef USE_ESP32_VARIANT_ESP32H2 +static const uint32_t RMT_CLK_FREQ = 32000000; +static const uint8_t RMT_CLK_DIV = 1; +#else static const uint32_t RMT_CLK_FREQ = 80000000; - static const uint8_t RMT_CLK_DIV = 2; +#endif void ESP32RMTLEDStripLightOutput::setup() { ESP_LOGCONFIG(TAG, "Setting up ESP32 LED Strip..."); @@ -37,9 +41,48 @@ void ESP32RMTLEDStripLightOutput::setup() { return; } +#if ESP_IDF_VERSION_MAJOR >= 5 + RAMAllocator rmt_allocator(this->use_psram_ ? 0 : RAMAllocator::ALLOC_INTERNAL); + + // 8 bits per byte, 1 rmt_symbol_word_t per bit + 1 rmt_symbol_word_t for reset + this->rmt_buf_ = rmt_allocator.allocate(buffer_size * 8 + 1); + + rmt_tx_channel_config_t channel; + memset(&channel, 0, sizeof(channel)); + channel.clk_src = RMT_CLK_SRC_DEFAULT; + channel.resolution_hz = RMT_CLK_FREQ / RMT_CLK_DIV; + channel.gpio_num = gpio_num_t(this->pin_); + channel.mem_block_symbols = this->rmt_symbols_; + channel.trans_queue_depth = 1; + channel.flags.io_loop_back = 0; + channel.flags.io_od_mode = 0; + channel.flags.invert_out = 0; + channel.flags.with_dma = 0; + channel.intr_priority = 0; + if (rmt_new_tx_channel(&channel, &this->channel_) != ESP_OK) { + ESP_LOGE(TAG, "Channel creation failed"); + this->mark_failed(); + return; + } + + rmt_copy_encoder_config_t encoder; + memset(&encoder, 0, sizeof(encoder)); + if (rmt_new_copy_encoder(&encoder, &this->encoder_) != ESP_OK) { + ESP_LOGE(TAG, "Encoder creation failed"); + this->mark_failed(); + return; + } + + if (rmt_enable(this->channel_) != ESP_OK) { + ESP_LOGE(TAG, "Enabling channel failed"); + this->mark_failed(); + return; + } +#else RAMAllocator rmt_allocator(this->use_psram_ ? 0 : RAMAllocator::ALLOC_INTERNAL); - this->rmt_buf_ = rmt_allocator.allocate(buffer_size * 8 + - 1); // 8 bits per byte, 1 rmt_item32_t per bit + 1 rmt_item32_t for reset + + // 8 bits per byte, 1 rmt_item32_t per bit + 1 rmt_item32_t for reset + this->rmt_buf_ = rmt_allocator.allocate(buffer_size * 8 + 1); rmt_config_t config; memset(&config, 0, sizeof(config)); @@ -64,6 +107,7 @@ void ESP32RMTLEDStripLightOutput::setup() { this->mark_failed(); return; } +#endif } void ESP32RMTLEDStripLightOutput::set_led_params(uint32_t bit0_high, uint32_t bit0_low, uint32_t bit1_high, @@ -100,7 +144,12 @@ void ESP32RMTLEDStripLightOutput::write_state(light::LightState *state) { ESP_LOGVV(TAG, "Writing RGB values to bus..."); - if (rmt_wait_tx_done(this->channel_, pdMS_TO_TICKS(1000)) != ESP_OK) { +#if ESP_IDF_VERSION_MAJOR >= 5 + esp_err_t error = rmt_tx_wait_all_done(this->channel_, 1000); +#else + esp_err_t error = rmt_wait_tx_done(this->channel_, pdMS_TO_TICKS(1000)); +#endif + if (error != ESP_OK) { ESP_LOGE(TAG, "RMT TX timeout"); this->status_set_warning(); return; @@ -112,7 +161,11 @@ void ESP32RMTLEDStripLightOutput::write_state(light::LightState *state) { size_t size = 0; size_t len = 0; uint8_t *psrc = this->buf_; +#if ESP_IDF_VERSION_MAJOR >= 5 + rmt_symbol_word_t *pdest = this->rmt_buf_; +#else rmt_item32_t *pdest = this->rmt_buf_; +#endif while (size < buffer_size) { uint8_t b = *psrc; for (int i = 0; i < 8; i++) { @@ -130,7 +183,16 @@ void ESP32RMTLEDStripLightOutput::write_state(light::LightState *state) { len++; } - if (rmt_write_items(this->channel_, this->rmt_buf_, len, false) != ESP_OK) { +#if ESP_IDF_VERSION_MAJOR >= 5 + rmt_transmit_config_t config; + memset(&config, 0, sizeof(config)); + config.loop_count = 0; + config.flags.eot_level = 0; + error = rmt_transmit(this->channel_, this->encoder_, this->rmt_buf_, len * sizeof(rmt_symbol_word_t), &config); +#else + error = rmt_write_items(this->channel_, this->rmt_buf_, len, false); +#endif + if (error != ESP_OK) { ESP_LOGE(TAG, "RMT TX error"); this->status_set_warning(); return; @@ -186,7 +248,11 @@ light::ESPColorView ESP32RMTLEDStripLightOutput::get_view_internal(int32_t index void ESP32RMTLEDStripLightOutput::dump_config() { ESP_LOGCONFIG(TAG, "ESP32 RMT LED Strip:"); ESP_LOGCONFIG(TAG, " Pin: %u", this->pin_); +#if ESP_IDF_VERSION_MAJOR >= 5 + ESP_LOGCONFIG(TAG, " RMT Symbols: %" PRIu32, this->rmt_symbols_); +#else ESP_LOGCONFIG(TAG, " Channel: %u", this->channel_); +#endif const char *rgb_order; switch (this->rgb_order_) { case ORDER_RGB: diff --git a/esphome/components/esp32_rmt_led_strip/led_strip.h b/esphome/components/esp32_rmt_led_strip/led_strip.h index d21bd86e75..fe49b9a2f3 100644 --- a/esphome/components/esp32_rmt_led_strip/led_strip.h +++ b/esphome/components/esp32_rmt_led_strip/led_strip.h @@ -9,8 +9,14 @@ #include "esphome/core/helpers.h" #include -#include #include +#include + +#if ESP_IDF_VERSION_MAJOR >= 5 +#include +#else +#include +#endif namespace esphome { namespace esp32_rmt_led_strip { @@ -54,7 +60,11 @@ class ESP32RMTLEDStripLightOutput : public light::AddressableLight { uint32_t reset_time_high, uint32_t reset_time_low); void set_rgb_order(RGBOrder rgb_order) { this->rgb_order_ = rgb_order; } +#if ESP_IDF_VERSION_MAJOR >= 5 + void set_rmt_symbols(uint32_t rmt_symbols) { this->rmt_symbols_ = rmt_symbols; } +#else void set_rmt_channel(rmt_channel_t channel) { this->channel_ = channel; } +#endif void clear_effect_data() override { for (int i = 0; i < this->size(); i++) @@ -70,7 +80,17 @@ class ESP32RMTLEDStripLightOutput : public light::AddressableLight { uint8_t *buf_{nullptr}; uint8_t *effect_data_{nullptr}; +#if ESP_IDF_VERSION_MAJOR >= 5 + rmt_channel_handle_t channel_{nullptr}; + rmt_encoder_handle_t encoder_{nullptr}; + rmt_symbol_word_t *rmt_buf_{nullptr}; + rmt_symbol_word_t bit0_, bit1_, reset_; + uint32_t rmt_symbols_; +#else rmt_item32_t *rmt_buf_{nullptr}; + rmt_item32_t bit0_, bit1_, reset_; + rmt_channel_t channel_{RMT_CHANNEL_0}; +#endif uint8_t pin_; uint16_t num_leds_; @@ -78,9 +98,7 @@ class ESP32RMTLEDStripLightOutput : public light::AddressableLight { bool is_wrgb_; bool use_psram_; - rmt_item32_t bit0_, bit1_, reset_; RGBOrder rgb_order_; - rmt_channel_t channel_; uint32_t last_refresh_{0}; optional max_refresh_rate_{}; diff --git a/esphome/components/esp32_rmt_led_strip/light.py b/esphome/components/esp32_rmt_led_strip/light.py index 976f70e858..67a0e31461 100644 --- a/esphome/components/esp32_rmt_led_strip/light.py +++ b/esphome/components/esp32_rmt_led_strip/light.py @@ -13,6 +13,7 @@ from esphome.const import ( CONF_PIN, CONF_RGB_ORDER, CONF_RMT_CHANNEL, + CONF_RMT_SYMBOLS, ) CODEOWNERS = ["@jesserockz"] @@ -23,8 +24,6 @@ ESP32RMTLEDStripLightOutput = esp32_rmt_led_strip_ns.class_( "ESP32RMTLEDStripLightOutput", light.AddressableLight ) -rmt_channel_t = cg.global_ns.enum("rmt_channel_t") - RGBOrder = esp32_rmt_led_strip_ns.enum("RGBOrder") RGB_ORDERS = { @@ -65,6 +64,13 @@ CONF_RESET_HIGH = "reset_high" CONF_RESET_LOW = "reset_low" +def final_validation(config): + if not esp32_rmt.use_new_rmt_driver() and CONF_RMT_CHANNEL not in config: + raise cv.Invalid("rmt_channel is a required option.") + + +FINAL_VALIDATE_SCHEMA = final_validation + CONFIG_SCHEMA = cv.All( light.ADDRESSABLE_LIGHT_SCHEMA.extend( { @@ -72,7 +78,18 @@ CONFIG_SCHEMA = cv.All( cv.Required(CONF_PIN): pins.internal_gpio_output_pin_number, cv.Required(CONF_NUM_LEDS): cv.positive_not_null_int, cv.Required(CONF_RGB_ORDER): cv.enum(RGB_ORDERS, upper=True), - cv.Required(CONF_RMT_CHANNEL): esp32_rmt.validate_rmt_channel(tx=True), + cv.Optional(CONF_RMT_CHANNEL): cv.All( + cv.only_with_arduino, esp32_rmt.validate_rmt_channel(tx=True) + ), + cv.SplitDefault( + CONF_RMT_SYMBOLS, + esp32_idf=64, + esp32_s2_idf=64, + esp32_s3_idf=48, + esp32_c3_idf=48, + esp32_c6_idf=48, + esp32_h2_idf=48, + ): cv.All(cv.only_with_esp_idf, cv.int_range(min=2)), cv.Optional(CONF_MAX_REFRESH_RATE): cv.positive_time_period_microseconds, cv.Optional(CONF_CHIPSET): cv.one_of(*CHIPSETS, upper=True), cv.Optional(CONF_IS_RGBW, default=False): cv.boolean, @@ -148,8 +165,12 @@ async def to_code(config): cg.add(var.set_is_wrgb(config[CONF_IS_WRGB])) cg.add(var.set_use_psram(config[CONF_USE_PSRAM])) - cg.add( - var.set_rmt_channel( - getattr(rmt_channel_t, f"RMT_CHANNEL_{config[CONF_RMT_CHANNEL]}") + if esp32_rmt.use_new_rmt_driver(): + cg.add(var.set_rmt_symbols(config[CONF_RMT_SYMBOLS])) + else: + rmt_channel_t = cg.global_ns.enum("rmt_channel_t") + cg.add( + var.set_rmt_channel( + getattr(rmt_channel_t, f"RMT_CHANNEL_{config[CONF_RMT_CHANNEL]}") + ) ) - ) diff --git a/esphome/components/remote_base/remote_base.cpp b/esphome/components/remote_base/remote_base.cpp index fdfd0b43cc..5dff2c6a38 100644 --- a/esphome/components/remote_base/remote_base.cpp +++ b/esphome/components/remote_base/remote_base.cpp @@ -8,7 +8,7 @@ namespace remote_base { static const char *const TAG = "remote_base"; -#ifdef USE_ESP32 +#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 5 RemoteRMTChannel::RemoteRMTChannel(uint8_t mem_block_num) : mem_block_num_(mem_block_num) { static rmt_channel_t next_rmt_channel = RMT_CHANNEL_0; this->channel_ = next_rmt_channel; diff --git a/esphome/components/remote_base/remote_base.h b/esphome/components/remote_base/remote_base.h index c31127735a..70691177ef 100644 --- a/esphome/components/remote_base/remote_base.h +++ b/esphome/components/remote_base/remote_base.h @@ -8,7 +8,7 @@ #include "esphome/core/component.h" #include "esphome/core/hal.h" -#ifdef USE_ESP32 +#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 5 #include #endif @@ -112,25 +112,43 @@ class RemoteComponentBase { #ifdef USE_ESP32 class RemoteRMTChannel { public: +#if ESP_IDF_VERSION_MAJOR >= 5 + void set_clock_resolution(uint32_t clock_resolution) { this->clock_resolution_ = clock_resolution; } + void set_rmt_symbols(uint32_t rmt_symbols) { this->rmt_symbols_ = rmt_symbols; } +#else explicit RemoteRMTChannel(uint8_t mem_block_num = 1); explicit RemoteRMTChannel(rmt_channel_t channel, uint8_t mem_block_num = 1); void config_rmt(rmt_config_t &rmt); void set_clock_divider(uint8_t clock_divider) { this->clock_divider_ = clock_divider; } +#endif protected: uint32_t from_microseconds_(uint32_t us) { +#if ESP_IDF_VERSION_MAJOR >= 5 + const uint32_t ticks_per_ten_us = this->clock_resolution_ / 100000u; +#else const uint32_t ticks_per_ten_us = 80000000u / this->clock_divider_ / 100000u; +#endif return us * ticks_per_ten_us / 10; } uint32_t to_microseconds_(uint32_t ticks) { +#if ESP_IDF_VERSION_MAJOR >= 5 + const uint32_t ticks_per_ten_us = this->clock_resolution_ / 100000u; +#else const uint32_t ticks_per_ten_us = 80000000u / this->clock_divider_ / 100000u; +#endif return (ticks * 10) / ticks_per_ten_us; } RemoteComponentBase *remote_base_; +#if ESP_IDF_VERSION_MAJOR >= 5 + uint32_t clock_resolution_{1000000}; + uint32_t rmt_symbols_; +#else rmt_channel_t channel_{RMT_CHANNEL_0}; uint8_t mem_block_num_; uint8_t clock_divider_{80}; +#endif }; #endif diff --git a/esphome/components/remote_receiver/__init__.py b/esphome/components/remote_receiver/__init__.py index d3f61977c6..b01443a974 100644 --- a/esphome/components/remote_receiver/__init__.py +++ b/esphome/components/remote_receiver/__init__.py @@ -1,10 +1,11 @@ from esphome import pins import esphome.codegen as cg -from esphome.components import esp32_rmt, remote_base +from esphome.components import esp32, esp32_rmt, remote_base import esphome.config_validation as cv from esphome.const import ( CONF_BUFFER_SIZE, CONF_CLOCK_DIVIDER, + CONF_CLOCK_RESOLUTION, CONF_DUMP, CONF_FILTER, CONF_ID, @@ -12,12 +13,17 @@ from esphome.const import ( CONF_MEMORY_BLOCKS, CONF_PIN, CONF_RMT_CHANNEL, + CONF_RMT_SYMBOLS, CONF_TOLERANCE, CONF_TYPE, + CONF_USE_DMA, CONF_VALUE, ) from esphome.core import CORE, TimePeriod +CONF_FILTER_SYMBOLS = "filter_symbols" +CONF_RECEIVE_SYMBOLS = "receive_symbols" + AUTO_LOAD = ["remote_base"] remote_receiver_ns = cg.esphome_ns.namespace("remote_receiver") remote_base_ns = cg.esphome_ns.namespace("remote_base") @@ -97,15 +103,43 @@ CONFIG_SCHEMA = remote_base.validate_triggers( cv.positive_time_period_microseconds, cv.Range(max=TimePeriod(microseconds=4294967295)), ), - cv.SplitDefault(CONF_CLOCK_DIVIDER, esp32=80): cv.All( - cv.only_on_esp32, cv.Range(min=1, max=255) + cv.SplitDefault(CONF_CLOCK_DIVIDER, esp32_arduino=80): cv.All( + cv.only_on_esp32, + cv.only_with_arduino, + cv.int_range(min=1, max=255), + ), + cv.Optional(CONF_CLOCK_RESOLUTION): cv.All( + cv.only_on_esp32, + cv.only_with_esp_idf, + esp32_rmt.validate_clock_resolution(), ), cv.Optional(CONF_IDLE, default="10ms"): cv.All( cv.positive_time_period_microseconds, cv.Range(max=TimePeriod(microseconds=4294967295)), ), - cv.Optional(CONF_MEMORY_BLOCKS, default=3): cv.Range(min=1, max=8), - cv.Optional(CONF_RMT_CHANNEL): esp32_rmt.validate_rmt_channel(tx=False), + cv.SplitDefault(CONF_MEMORY_BLOCKS, esp32_arduino=3): cv.All( + cv.only_with_arduino, cv.int_range(min=1, max=8) + ), + cv.Optional(CONF_RMT_CHANNEL): cv.All( + cv.only_with_arduino, esp32_rmt.validate_rmt_channel(tx=False) + ), + cv.SplitDefault( + CONF_RMT_SYMBOLS, + esp32_idf=192, + esp32_s2_idf=192, + esp32_s3_idf=192, + esp32_c3_idf=96, + esp32_c6_idf=96, + esp32_h2_idf=96, + ): cv.All(cv.only_with_esp_idf, cv.int_range(min=2)), + cv.Optional(CONF_FILTER_SYMBOLS): cv.All( + cv.only_with_esp_idf, cv.int_range(min=0) + ), + cv.SplitDefault( + CONF_RECEIVE_SYMBOLS, + esp32_idf=192, + ): cv.All(cv.only_with_esp_idf, cv.int_range(min=2)), + cv.Optional(CONF_USE_DMA): cv.All(cv.only_with_esp_idf, cv.boolean), } ).extend(cv.COMPONENT_SCHEMA) ) @@ -114,13 +148,27 @@ CONFIG_SCHEMA = remote_base.validate_triggers( async def to_code(config): pin = await cg.gpio_pin_expression(config[CONF_PIN]) if CORE.is_esp32: - if (rmt_channel := config.get(CONF_RMT_CHANNEL, None)) is not None: - var = cg.new_Pvariable( - config[CONF_ID], pin, rmt_channel, config[CONF_MEMORY_BLOCKS] - ) + if esp32_rmt.use_new_rmt_driver(): + var = cg.new_Pvariable(config[CONF_ID], pin) + cg.add(var.set_rmt_symbols(config[CONF_RMT_SYMBOLS])) + cg.add(var.set_receive_symbols(config[CONF_RECEIVE_SYMBOLS])) + if CONF_USE_DMA in config: + cg.add(var.set_with_dma(config[CONF_USE_DMA])) + if CONF_CLOCK_RESOLUTION in config: + cg.add(var.set_clock_resolution(config[CONF_CLOCK_RESOLUTION])) + if CONF_FILTER_SYMBOLS in config: + cg.add(var.set_filter_symbols(config[CONF_FILTER_SYMBOLS])) + if CORE.using_esp_idf: + esp32.add_idf_sdkconfig_option("CONFIG_RMT_RECV_FUNC_IN_IRAM", True) + esp32.add_idf_sdkconfig_option("CONFIG_RMT_ISR_IRAM_SAFE", True) else: - var = cg.new_Pvariable(config[CONF_ID], pin, config[CONF_MEMORY_BLOCKS]) - cg.add(var.set_clock_divider(config[CONF_CLOCK_DIVIDER])) + if (rmt_channel := config.get(CONF_RMT_CHANNEL, None)) is not None: + var = cg.new_Pvariable( + config[CONF_ID], pin, rmt_channel, config[CONF_MEMORY_BLOCKS] + ) + else: + var = cg.new_Pvariable(config[CONF_ID], pin, config[CONF_MEMORY_BLOCKS]) + cg.add(var.set_clock_divider(config[CONF_CLOCK_DIVIDER])) else: var = cg.new_Pvariable(config[CONF_ID], pin) diff --git a/esphome/components/remote_receiver/remote_receiver.h b/esphome/components/remote_receiver/remote_receiver.h index 773f8cf636..8d19d5490f 100644 --- a/esphome/components/remote_receiver/remote_receiver.h +++ b/esphome/components/remote_receiver/remote_receiver.h @@ -5,6 +5,10 @@ #include +#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5 +#include +#endif + namespace esphome { namespace remote_receiver { @@ -25,6 +29,21 @@ struct RemoteReceiverComponentStore { uint32_t filter_us{10}; ISRInternalGPIOPin pin; }; +#elif defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5 +struct RemoteReceiverComponentStore { + /// Stores RMT symbols and rx done event data + volatile uint8_t *buffer{nullptr}; + /// The position last written to + volatile uint32_t buffer_write{0}; + /// The position last read from + volatile uint32_t buffer_read{0}; + bool overflow{false}; + uint32_t buffer_size{1000}; + uint32_t receive_size{0}; + uint32_t filter_symbols{0}; + esp_err_t error{ESP_OK}; + rmt_receive_config_t config; +}; #endif class RemoteReceiverComponent : public remote_base::RemoteReceiverBase, @@ -33,9 +52,10 @@ class RemoteReceiverComponent : public remote_base::RemoteReceiverBase, , public remote_base::RemoteRMTChannel #endif + { public: -#ifdef USE_ESP32 +#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 5 RemoteReceiverComponent(InternalGPIOPin *pin, uint8_t mem_block_num = 1) : RemoteReceiverBase(pin), remote_base::RemoteRMTChannel(mem_block_num) {} @@ -49,19 +69,32 @@ class RemoteReceiverComponent : public remote_base::RemoteReceiverBase, void loop() override; float get_setup_priority() const override { return setup_priority::DATA; } +#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5 + void set_filter_symbols(uint32_t filter_symbols) { this->filter_symbols_ = filter_symbols; } + void set_receive_symbols(uint32_t receive_symbols) { this->receive_symbols_ = receive_symbols; } + void set_with_dma(bool with_dma) { this->with_dma_ = with_dma; } +#endif void set_buffer_size(uint32_t buffer_size) { this->buffer_size_ = buffer_size; } void set_filter_us(uint32_t filter_us) { this->filter_us_ = filter_us; } void set_idle_us(uint32_t idle_us) { this->idle_us_ = idle_us; } protected: #ifdef USE_ESP32 - void decode_rmt_(rmt_item32_t *item, size_t len); +#if ESP_IDF_VERSION_MAJOR >= 5 + void decode_rmt_(rmt_symbol_word_t *item, size_t item_count); + rmt_channel_handle_t channel_{NULL}; + uint32_t filter_symbols_{0}; + uint32_t receive_symbols_{0}; + bool with_dma_{false}; +#else + void decode_rmt_(rmt_item32_t *item, size_t item_count); RingbufHandle_t ringbuf_; +#endif esp_err_t error_code_{ESP_OK}; std::string error_string_{""}; #endif -#if defined(USE_ESP8266) || defined(USE_LIBRETINY) +#if defined(USE_ESP8266) || defined(USE_LIBRETINY) || (defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5) RemoteReceiverComponentStore store_; HighFrequencyLoopRequester high_freq_; #endif diff --git a/esphome/components/remote_receiver/remote_receiver_esp32.cpp b/esphome/components/remote_receiver/remote_receiver_esp32.cpp index 91295871e2..48b84d61d4 100644 --- a/esphome/components/remote_receiver/remote_receiver_esp32.cpp +++ b/esphome/components/remote_receiver/remote_receiver_esp32.cpp @@ -2,15 +2,104 @@ #include "esphome/core/log.h" #ifdef USE_ESP32 -#include namespace esphome { namespace remote_receiver { static const char *const TAG = "remote_receiver.esp32"; +#ifdef USE_ESP32_VARIANT_ESP32H2 +static const uint32_t RMT_CLK_FREQ = 32000000; +#else +static const uint32_t RMT_CLK_FREQ = 80000000; +#endif + +#if ESP_IDF_VERSION_MAJOR >= 5 +static bool IRAM_ATTR HOT rmt_callback(rmt_channel_handle_t channel, const rmt_rx_done_event_data_t *event, void *arg) { + RemoteReceiverComponentStore *store = (RemoteReceiverComponentStore *) arg; + rmt_rx_done_event_data_t *event_buffer = (rmt_rx_done_event_data_t *) (store->buffer + store->buffer_write); + uint32_t event_size = sizeof(rmt_rx_done_event_data_t); + uint32_t next_write = store->buffer_write + event_size + event->num_symbols * sizeof(rmt_symbol_word_t); + if (next_write + event_size + store->receive_size > store->buffer_size) { + next_write = 0; + } + if (store->buffer_read - next_write < event_size + store->receive_size) { + next_write = store->buffer_write; + store->overflow = true; + } + if (event->num_symbols <= store->filter_symbols) { + next_write = store->buffer_write; + } + store->error = + rmt_receive(channel, (uint8_t *) store->buffer + next_write + event_size, store->receive_size, &store->config); + event_buffer->num_symbols = event->num_symbols; + event_buffer->received_symbols = event->received_symbols; + store->buffer_write = next_write; + return false; +} +#endif void RemoteReceiverComponent::setup() { ESP_LOGCONFIG(TAG, "Setting up Remote Receiver..."); +#if ESP_IDF_VERSION_MAJOR >= 5 + rmt_rx_channel_config_t channel; + memset(&channel, 0, sizeof(channel)); + channel.clk_src = RMT_CLK_SRC_DEFAULT; + channel.resolution_hz = this->clock_resolution_; + channel.mem_block_symbols = rmt_symbols_; + channel.gpio_num = gpio_num_t(this->pin_->get_pin()); + channel.intr_priority = 0; + channel.flags.invert_in = 0; + channel.flags.with_dma = this->with_dma_; + channel.flags.io_loop_back = 0; + esp_err_t error = rmt_new_rx_channel(&channel, &this->channel_); + if (error != ESP_OK) { + this->error_code_ = error; + if (error == ESP_ERR_NOT_FOUND) { + this->error_string_ = "out of RMT symbol memory"; + } else { + this->error_string_ = "in rmt_new_rx_channel"; + } + this->mark_failed(); + return; + } + error = rmt_enable(this->channel_); + if (error != ESP_OK) { + this->error_code_ = error; + this->error_string_ = "in rmt_enable"; + this->mark_failed(); + return; + } + + rmt_rx_event_callbacks_t callbacks; + memset(&callbacks, 0, sizeof(callbacks)); + callbacks.on_recv_done = rmt_callback; + error = rmt_rx_register_event_callbacks(this->channel_, &callbacks, &this->store_); + if (error != ESP_OK) { + this->error_code_ = error; + this->error_string_ = "in rmt_rx_register_event_callbacks"; + this->mark_failed(); + return; + } + + uint32_t event_size = sizeof(rmt_rx_done_event_data_t); + uint32_t max_filter_ns = 255u * 1000 / (RMT_CLK_FREQ / 1000000); + uint32_t max_idle_ns = 65535u * 1000; + memset(&this->store_.config, 0, sizeof(this->store_.config)); + this->store_.config.signal_range_min_ns = std::min(this->filter_us_ * 1000, max_filter_ns); + this->store_.config.signal_range_max_ns = std::min(this->idle_us_ * 1000, max_idle_ns); + this->store_.filter_symbols = this->filter_symbols_; + this->store_.receive_size = this->receive_symbols_ * sizeof(rmt_symbol_word_t); + this->store_.buffer_size = std::max((event_size + this->store_.receive_size) * 2, this->buffer_size_); + this->store_.buffer = new uint8_t[this->buffer_size_]; + error = rmt_receive(this->channel_, (uint8_t *) this->store_.buffer + event_size, this->store_.receive_size, + &this->store_.config); + if (error != ESP_OK) { + this->error_code_ = error; + this->error_string_ = "in rmt_receive"; + this->mark_failed(); + return; + } +#else this->pin_->setup(); rmt_config_t rmt{}; this->config_rmt(rmt); @@ -59,7 +148,9 @@ void RemoteReceiverComponent::setup() { this->mark_failed(); return; } +#endif } + void RemoteReceiverComponent::dump_config() { ESP_LOGCONFIG(TAG, "Remote Receiver:"); LOG_PIN(" Pin: ", this->pin_); @@ -67,9 +158,16 @@ void RemoteReceiverComponent::dump_config() { ESP_LOGW(TAG, "Remote Receiver Signal starts with a HIGH value. Usually this means you have to " "invert the signal using 'inverted: True' in the pin schema!"); } +#if ESP_IDF_VERSION_MAJOR >= 5 + ESP_LOGCONFIG(TAG, " Clock resolution: %" PRIu32 " hz", this->clock_resolution_); + ESP_LOGCONFIG(TAG, " RMT symbols: %" PRIu32, this->rmt_symbols_); + ESP_LOGCONFIG(TAG, " Filter symbols: %" PRIu32, this->filter_symbols_); + ESP_LOGCONFIG(TAG, " Receive symbols: %" PRIu32, this->receive_symbols_); +#else ESP_LOGCONFIG(TAG, " Channel: %d", this->channel_); ESP_LOGCONFIG(TAG, " RMT memory blocks: %d", this->mem_block_num_); ESP_LOGCONFIG(TAG, " Clock divider: %u", this->clock_divider_); +#endif ESP_LOGCONFIG(TAG, " Tolerance: %" PRIu32 "%s", this->tolerance_, (this->tolerance_mode_ == remote_base::TOLERANCE_MODE_TIME) ? " us" : "%"); ESP_LOGCONFIG(TAG, " Filter out pulses shorter than: %" PRIu32 " us", this->filter_us_); @@ -81,10 +179,38 @@ void RemoteReceiverComponent::dump_config() { } void RemoteReceiverComponent::loop() { +#if ESP_IDF_VERSION_MAJOR >= 5 + if (this->store_.error != ESP_OK) { + ESP_LOGE(TAG, "Receive error"); + this->error_code_ = this->store_.error; + this->error_string_ = "in rmt_callback"; + this->mark_failed(); + } + if (this->store_.overflow) { + ESP_LOGW(TAG, "Buffer overflow"); + this->store_.overflow = false; + } + uint32_t buffer_write = this->store_.buffer_write; + while (this->store_.buffer_read != buffer_write) { + rmt_rx_done_event_data_t *event = (rmt_rx_done_event_data_t *) (this->store_.buffer + this->store_.buffer_read); + uint32_t event_size = sizeof(rmt_rx_done_event_data_t); + uint32_t next_read = this->store_.buffer_read + event_size + event->num_symbols * sizeof(rmt_symbol_word_t); + if (next_read + event_size + this->store_.receive_size > this->store_.buffer_size) { + next_read = 0; + } + this->decode_rmt_(event->received_symbols, event->num_symbols); + this->store_.buffer_read = next_read; + + if (!this->temp_.empty()) { + this->temp_.push_back(-this->idle_us_); + this->call_listeners_dumpers_(); + } + } +#else size_t len = 0; auto *item = (rmt_item32_t *) xRingbufferReceive(this->ringbuf_, &len, 0); if (item != nullptr) { - this->decode_rmt_(item, len); + this->decode_rmt_(item, len / sizeof(rmt_item32_t)); vRingbufferReturnItem(this->ringbuf_, item); if (this->temp_.empty()) @@ -93,13 +219,18 @@ void RemoteReceiverComponent::loop() { this->temp_.push_back(-this->idle_us_); this->call_listeners_dumpers_(); } +#endif } -void RemoteReceiverComponent::decode_rmt_(rmt_item32_t *item, size_t len) { + +#if ESP_IDF_VERSION_MAJOR >= 5 +void RemoteReceiverComponent::decode_rmt_(rmt_symbol_word_t *item, size_t item_count) { +#else +void RemoteReceiverComponent::decode_rmt_(rmt_item32_t *item, size_t item_count) { +#endif bool prev_level = false; uint32_t prev_length = 0; this->temp_.clear(); int32_t multiplier = this->pin_->is_inverted() ? -1 : 1; - size_t item_count = len / sizeof(rmt_item32_t); uint32_t filter_ticks = this->from_microseconds_(this->filter_us_); ESP_LOGVV(TAG, "START:"); @@ -124,7 +255,8 @@ void RemoteReceiverComponent::decode_rmt_(rmt_item32_t *item, size_t len) { this->temp_.reserve(item_count * 2); // each RMT item has 2 pulses for (size_t i = 0; i < item_count; i++) { if (item[i].duration0 == 0u) { - // Do nothing + // EOF, sometimes garbage follows, break early + break; } else if ((bool(item[i].level0) == prev_level) || (item[i].duration0 < filter_ticks)) { prev_length += item[i].duration0; } else { @@ -140,7 +272,8 @@ void RemoteReceiverComponent::decode_rmt_(rmt_item32_t *item, size_t len) { } if (item[i].duration1 == 0u) { - // Do nothing + // EOF, sometimes garbage follows, break early + break; } else if ((bool(item[i].level1) == prev_level) || (item[i].duration1 < filter_ticks)) { prev_length += item[i].duration1; } else { diff --git a/esphome/components/remote_transmitter/__init__.py b/esphome/components/remote_transmitter/__init__.py index f979939739..ea29751671 100644 --- a/esphome/components/remote_transmitter/__init__.py +++ b/esphome/components/remote_transmitter/__init__.py @@ -2,12 +2,23 @@ from esphome import automation, pins import esphome.codegen as cg from esphome.components import esp32_rmt, remote_base import esphome.config_validation as cv -from esphome.const import CONF_CARRIER_DUTY_PERCENT, CONF_ID, CONF_PIN, CONF_RMT_CHANNEL +from esphome.const import ( + CONF_CARRIER_DUTY_PERCENT, + CONF_CLOCK_DIVIDER, + CONF_CLOCK_RESOLUTION, + CONF_ID, + CONF_PIN, + CONF_RMT_CHANNEL, + CONF_RMT_SYMBOLS, + CONF_USE_DMA, +) +from esphome.core import CORE AUTO_LOAD = ["remote_base"] CONF_ON_TRANSMIT = "on_transmit" CONF_ON_COMPLETE = "on_complete" +CONF_ONE_WIRE = "one_wire" remote_transmitter_ns = cg.esphome_ns.namespace("remote_transmitter") RemoteTransmitterComponent = remote_transmitter_ns.class_( @@ -22,7 +33,28 @@ CONFIG_SCHEMA = cv.Schema( cv.Required(CONF_CARRIER_DUTY_PERCENT): cv.All( cv.percentage_int, cv.Range(min=1, max=100) ), - cv.Optional(CONF_RMT_CHANNEL): esp32_rmt.validate_rmt_channel(tx=True), + cv.Optional(CONF_CLOCK_RESOLUTION): cv.All( + cv.only_on_esp32, + cv.only_with_esp_idf, + esp32_rmt.validate_clock_resolution(), + ), + cv.Optional(CONF_CLOCK_DIVIDER): cv.All( + cv.only_on_esp32, cv.only_with_arduino, cv.int_range(min=1, max=255) + ), + cv.Optional(CONF_ONE_WIRE): cv.All(cv.only_with_esp_idf, cv.boolean), + cv.Optional(CONF_USE_DMA): cv.All(cv.only_with_esp_idf, cv.boolean), + cv.SplitDefault( + CONF_RMT_SYMBOLS, + esp32_idf=64, + esp32_s2_idf=64, + esp32_s3_idf=48, + esp32_c3_idf=48, + esp32_c6_idf=48, + esp32_h2_idf=48, + ): cv.All(cv.only_with_esp_idf, cv.int_range(min=2)), + cv.Optional(CONF_RMT_CHANNEL): cv.All( + cv.only_with_arduino, esp32_rmt.validate_rmt_channel(tx=True) + ), cv.Optional(CONF_ON_TRANSMIT): automation.validate_automation(single=True), cv.Optional(CONF_ON_COMPLETE): automation.validate_automation(single=True), } @@ -31,8 +63,24 @@ CONFIG_SCHEMA = cv.Schema( async def to_code(config): pin = await cg.gpio_pin_expression(config[CONF_PIN]) - if (rmt_channel := config.get(CONF_RMT_CHANNEL, None)) is not None: - var = cg.new_Pvariable(config[CONF_ID], pin, rmt_channel) + if CORE.is_esp32: + if esp32_rmt.use_new_rmt_driver(): + var = cg.new_Pvariable(config[CONF_ID], pin) + cg.add(var.set_rmt_symbols(config[CONF_RMT_SYMBOLS])) + if CONF_CLOCK_RESOLUTION in config: + cg.add(var.set_clock_resolution(config[CONF_CLOCK_RESOLUTION])) + if CONF_USE_DMA in config: + cg.add(var.set_with_dma(config[CONF_USE_DMA])) + if CONF_ONE_WIRE in config: + cg.add(var.set_one_wire(config[CONF_ONE_WIRE])) + else: + if (rmt_channel := config.get(CONF_RMT_CHANNEL, None)) is not None: + var = cg.new_Pvariable(config[CONF_ID], pin, rmt_channel) + else: + var = cg.new_Pvariable(config[CONF_ID], pin) + if CONF_CLOCK_DIVIDER in config: + cg.add(var.set_clock_divider(config[CONF_CLOCK_DIVIDER])) + else: var = cg.new_Pvariable(config[CONF_ID], pin) await cg.register_component(var, config) diff --git a/esphome/components/remote_transmitter/remote_transmitter.h b/esphome/components/remote_transmitter/remote_transmitter.h index 4abe687d23..20b98d5488 100644 --- a/esphome/components/remote_transmitter/remote_transmitter.h +++ b/esphome/components/remote_transmitter/remote_transmitter.h @@ -5,6 +5,10 @@ #include +#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5 +#include +#endif + namespace esphome { namespace remote_transmitter { @@ -16,7 +20,7 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase, #endif { public: -#ifdef USE_ESP32 +#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR < 5 RemoteTransmitterComponent(InternalGPIOPin *pin, uint8_t mem_block_num = 1) : remote_base::RemoteTransmitterBase(pin), remote_base::RemoteRMTChannel(mem_block_num) {} @@ -29,10 +33,16 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase, void dump_config() override; - float get_setup_priority() const override { return setup_priority::DATA; } + // transmitter setup must run after receiver setup to allow the same GPIO to be used by both + float get_setup_priority() const override { return setup_priority::DATA - 1; } void set_carrier_duty_percent(uint8_t carrier_duty_percent) { this->carrier_duty_percent_ = carrier_duty_percent; } +#if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5 + void set_with_dma(bool with_dma) { this->with_dma_ = with_dma; } + void set_one_wire(bool one_wire) { this->one_wire_ = one_wire; } +#endif + Trigger<> *get_transmit_trigger() const { return this->transmit_trigger_; }; Trigger<> *get_complete_trigger() const { return this->complete_trigger_; }; @@ -54,7 +64,15 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase, uint32_t current_carrier_frequency_{38000}; bool initialized_{false}; +#if ESP_IDF_VERSION_MAJOR >= 5 + std::vector rmt_temp_; + bool with_dma_{false}; + bool one_wire_{false}; + rmt_channel_handle_t channel_{NULL}; + rmt_encoder_handle_t encoder_{NULL}; +#else std::vector rmt_temp_; +#endif esp_err_t error_code_{ESP_OK}; std::string error_string_{""}; bool inverted_{false}; diff --git a/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp b/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp index bce2408723..efb1735bfd 100644 --- a/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp +++ b/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp @@ -9,13 +9,22 @@ namespace remote_transmitter { static const char *const TAG = "remote_transmitter"; -void RemoteTransmitterComponent::setup() { this->configure_rmt_(); } +void RemoteTransmitterComponent::setup() { + ESP_LOGCONFIG(TAG, "Setting up Remote Transmitter..."); + this->configure_rmt_(); +} void RemoteTransmitterComponent::dump_config() { - ESP_LOGCONFIG(TAG, "Remote Transmitter..."); + ESP_LOGCONFIG(TAG, "Remote Transmitter:"); +#if ESP_IDF_VERSION_MAJOR >= 5 + ESP_LOGCONFIG(TAG, " One wire: %s", this->one_wire_ ? "true" : "false"); + ESP_LOGCONFIG(TAG, " Clock resolution: %" PRIu32 " hz", this->clock_resolution_); + ESP_LOGCONFIG(TAG, " RMT symbols: %" PRIu32, this->rmt_symbols_); +#else ESP_LOGCONFIG(TAG, " Channel: %d", this->channel_); ESP_LOGCONFIG(TAG, " RMT memory blocks: %d", this->mem_block_num_); ESP_LOGCONFIG(TAG, " Clock divider: %u", this->clock_divider_); +#endif LOG_PIN(" Pin: ", this->pin_); if (this->current_carrier_frequency_ != 0 && this->carrier_duty_percent_ != 100) { @@ -29,6 +38,72 @@ void RemoteTransmitterComponent::dump_config() { } void RemoteTransmitterComponent::configure_rmt_() { +#if ESP_IDF_VERSION_MAJOR >= 5 + esp_err_t error; + + if (!this->initialized_) { + rmt_tx_channel_config_t channel; + memset(&channel, 0, sizeof(channel)); + channel.clk_src = RMT_CLK_SRC_DEFAULT; + channel.resolution_hz = this->clock_resolution_; + channel.gpio_num = gpio_num_t(this->pin_->get_pin()); + channel.mem_block_symbols = this->rmt_symbols_; + channel.trans_queue_depth = 1; + channel.flags.io_loop_back = this->one_wire_; + channel.flags.io_od_mode = this->one_wire_; + channel.flags.invert_out = 0; + channel.flags.with_dma = this->with_dma_; + channel.intr_priority = 0; + error = rmt_new_tx_channel(&channel, &this->channel_); + if (error != ESP_OK) { + this->error_code_ = error; + if (error == ESP_ERR_NOT_FOUND) { + this->error_string_ = "out of RMT symbol memory"; + } else { + this->error_string_ = "in rmt_new_tx_channel"; + } + this->mark_failed(); + return; + } + + rmt_copy_encoder_config_t encoder; + memset(&encoder, 0, sizeof(encoder)); + error = rmt_new_copy_encoder(&encoder, &this->encoder_); + if (error != ESP_OK) { + this->error_code_ = error; + this->error_string_ = "in rmt_new_copy_encoder"; + this->mark_failed(); + return; + } + + error = rmt_enable(this->channel_); + if (error != ESP_OK) { + this->error_code_ = error; + this->error_string_ = "in rmt_enable"; + this->mark_failed(); + return; + } + this->initialized_ = true; + } + + if (this->current_carrier_frequency_ == 0 || this->carrier_duty_percent_ == 100) { + error = rmt_apply_carrier(this->channel_, nullptr); + } else { + rmt_carrier_config_t carrier; + memset(&carrier, 0, sizeof(carrier)); + carrier.frequency_hz = this->current_carrier_frequency_; + carrier.duty_cycle = (float) this->carrier_duty_percent_ / 100.0f; + carrier.flags.polarity_active_low = this->inverted_; + carrier.flags.always_on = 1; + error = rmt_apply_carrier(this->channel_, &carrier); + } + if (error != ESP_OK) { + this->error_code_ = error; + this->error_string_ = "in rmt_apply_carrier"; + this->mark_failed(); + return; + } +#else rmt_config_t c{}; this->config_rmt(c); @@ -76,6 +151,7 @@ void RemoteTransmitterComponent::configure_rmt_() { } this->initialized_ = true; } +#endif } void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t send_wait) { @@ -90,7 +166,11 @@ void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t sen this->rmt_temp_.clear(); this->rmt_temp_.reserve((this->temp_.get_data().size() + 1) / 2); uint32_t rmt_i = 0; +#if ESP_IDF_VERSION_MAJOR >= 5 + rmt_symbol_word_t rmt_item; +#else rmt_item32_t rmt_item; +#endif for (int32_t val : this->temp_.get_data()) { bool level = val >= 0; @@ -125,6 +205,31 @@ void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t sen return; } this->transmit_trigger_->trigger(); +#if ESP_IDF_VERSION_MAJOR >= 5 + for (uint32_t i = 0; i < send_times; i++) { + rmt_transmit_config_t config; + memset(&config, 0, sizeof(config)); + config.loop_count = 0; + config.flags.eot_level = this->inverted_; + esp_err_t error = rmt_transmit(this->channel_, this->encoder_, this->rmt_temp_.data(), + this->rmt_temp_.size() * sizeof(rmt_symbol_word_t), &config); + if (error != ESP_OK) { + ESP_LOGW(TAG, "rmt_transmit failed: %s", esp_err_to_name(error)); + this->status_set_warning(); + } else { + this->status_clear_warning(); + } + error = rmt_tx_wait_all_done(this->channel_, -1); + if (error != ESP_OK) { + ESP_LOGW(TAG, "rmt_tx_wait_all_done failed: %s", esp_err_to_name(error)); + this->status_set_warning(); + } else { + this->status_clear_warning(); + } + if (i + 1 < send_times) + delayMicroseconds(send_wait); + } +#else for (uint32_t i = 0; i < send_times; i++) { esp_err_t error = rmt_write_items(this->channel_, this->rmt_temp_.data(), this->rmt_temp_.size(), true); if (error != ESP_OK) { @@ -136,6 +241,7 @@ void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t sen if (i + 1 < send_times) delayMicroseconds(send_wait); } +#endif this->complete_trigger_->trigger(); } diff --git a/tests/components/esp32_rmt_led_strip/test.esp32-c3-idf.yaml b/tests/components/esp32_rmt_led_strip/test.esp32-c3-idf.yaml index 8d04d3370b..93318d0581 100644 --- a/tests/components/esp32_rmt_led_strip/test.esp32-c3-idf.yaml +++ b/tests/components/esp32_rmt_led_strip/test.esp32-c3-idf.yaml @@ -3,14 +3,12 @@ light: id: led_strip pin: 4 num_leds: 60 - rmt_channel: 0 rgb_order: GRB chipset: ws2812 - platform: esp32_rmt_led_strip id: led_strip2 pin: 5 num_leds: 60 - rmt_channel: 1 rgb_order: RGB bit0_high: 100µs bit0_low: 100µs diff --git a/tests/components/esp32_rmt_led_strip/test.esp32-idf.yaml b/tests/components/esp32_rmt_led_strip/test.esp32-idf.yaml index 6e1763b339..228af17189 100644 --- a/tests/components/esp32_rmt_led_strip/test.esp32-idf.yaml +++ b/tests/components/esp32_rmt_led_strip/test.esp32-idf.yaml @@ -3,14 +3,12 @@ light: id: led_strip pin: 13 num_leds: 60 - rmt_channel: 6 rgb_order: GRB chipset: ws2812 - platform: esp32_rmt_led_strip id: led_strip2 pin: 14 num_leds: 60 - rmt_channel: 2 rgb_order: RGB bit0_high: 100µs bit0_low: 100µs diff --git a/tests/components/remote_receiver/common-actions.yaml b/tests/components/remote_receiver/common-actions.yaml new file mode 100644 index 0000000000..23589aed22 --- /dev/null +++ b/tests/components/remote_receiver/common-actions.yaml @@ -0,0 +1,144 @@ +on_abbwelcome: + then: + - logger.log: + format: "on_abbwelcome: %u" + args: ["x.data()[0]"] +on_aeha: + then: + - logger.log: + format: "on_aeha: %u %u" + args: ["x.address", "x.data.front()"] +on_byronsx: + then: + - logger.log: + format: "on_byronsx: %u %u" + args: ["x.address", "x.command"] +on_canalsat: + then: + - logger.log: + format: "on_canalsat: %u %u" + args: ["x.address", "x.command"] +# on_canalsatld: +# then: +# - logger.log: +# format: "on_canalsatld: %u %u" +# args: ["x.address", "x.command"] +on_coolix: + then: + - logger.log: + format: "on_coolix: %lu %lu" + args: ["long(x.first)", "long(x.second)"] +on_dish: + then: + - logger.log: + format: "on_dish: %u %u" + args: ["x.address", "x.command"] +on_dooya: + then: + - logger.log: + format: "on_dooya: %u %u %u" + args: ["x.channel", "x.button", "x.check"] +on_drayton: + then: + - logger.log: + format: "on_drayton: %u %u %u" + args: ["x.address", "x.channel", "x.command"] +on_jvc: + then: + - logger.log: + format: "on_jvc: %lu" + args: ["long(x.data)"] +on_keeloq: + then: + - logger.log: + format: "on_keeloq: %lu %lu %u" + args: ["long(x.encrypted)", "long(x.address)", "x.command"] +on_haier: + then: + - logger.log: + format: "on_haier: %u" + args: ["x.data.front()"] +on_lg: + then: + - logger.log: + format: "on_lg: %lu %u" + args: ["long(x.data)", "x.nbits"] +on_magiquest: + then: + - logger.log: + format: "on_magiquest: %u %lu" + args: ["x.magnitude", "long(x.wand_id)"] +on_midea: + then: + - logger.log: + format: "on_midea: %u %u" + args: ["x.size()", "x.data()[0]"] +on_nec: + then: + - logger.log: + format: "on_nec: %u %u" + args: ["x.address", "x.command"] +on_nexa: + then: + - logger.log: + format: "on_nexa: %lu %u %u %u %u" + args: ["long(x.device)", "x.group", "x.state", "x.channel", "x.level"] +on_panasonic: + then: + - logger.log: + format: "on_panasonic: %u %lu" + args: ["x.address", "long(x.command)"] +on_pioneer: + then: + - logger.log: + format: "on_pioneer: %u %u" + args: ["x.rc_code_1", "x.rc_code_2"] +on_pronto: + then: + - logger.log: + format: "on_pronto: %s" + args: ["x.data.c_str()"] +on_raw: + then: + - logger.log: + format: "on_raw: %lu" + args: ["long(x.front())"] +on_rc5: + then: + - logger.log: + format: "on_rc5: %u %u" + args: ["x.address", "x.command"] +on_rc6: + then: + - logger.log: + format: "on_rc6: %u %u" + args: ["x.address", "x.command"] +on_rc_switch: + then: + - logger.log: + format: "on_rc_switch: %llu %u" + args: ["x.code", "x.protocol"] +on_samsung: + then: + - logger.log: + format: "on_samsung: %llu %u" + args: ["x.data", "x.nbits"] +on_samsung36: + then: + - logger.log: + format: "on_samsung36: %u %lu" + args: ["x.address", "long(x.command)"] +on_sony: + then: + - logger.log: + format: "on_sony: %lu %u" + args: ["long(x.data)", "x.nbits"] +on_toshiba_ac: + then: + - logger.log: + format: "on_toshiba_ac: %llu %llu" + args: ["x.rc_code_1", "x.rc_code_2"] +on_mirage: + then: + - lambda: |- + ESP_LOGD("mirage", "Mirage data: %s", format_hex(x.data).c_str()); diff --git a/tests/components/remote_receiver/esp32-common-ard.yaml b/tests/components/remote_receiver/esp32-common-ard.yaml new file mode 100644 index 0000000000..e331a35307 --- /dev/null +++ b/tests/components/remote_receiver/esp32-common-ard.yaml @@ -0,0 +1,14 @@ +remote_receiver: + - id: rcvr + pin: ${pin} + rmt_channel: ${rmt_channel} + dump: all + tolerance: 25% + <<: !include common-actions.yaml + +binary_sensor: + - platform: remote_receiver + name: Panasonic Remote Input + panasonic: + address: 0x4004 + command: 0x100BCBD diff --git a/tests/components/remote_receiver/esp32-common-idf.yaml b/tests/components/remote_receiver/esp32-common-idf.yaml new file mode 100644 index 0000000000..b314880f8a --- /dev/null +++ b/tests/components/remote_receiver/esp32-common-idf.yaml @@ -0,0 +1,18 @@ +remote_receiver: + - id: rcvr + pin: ${pin} + dump: all + tolerance: 25% + clock_resolution: ${clock_resolution} + filter_symbols: ${filter_symbols} + receive_symbols: ${receive_symbols} + rmt_symbols: ${rmt_symbols} + use_dma: ${use_dma} + <<: !include common-actions.yaml + +binary_sensor: + - platform: remote_receiver + name: Panasonic Remote Input + panasonic: + address: 0x4004 + command: 0x100BCBD diff --git a/tests/components/remote_receiver/esp32-common.yaml b/tests/components/remote_receiver/esp32-common.yaml deleted file mode 100644 index 7e5d2cce32..0000000000 --- a/tests/components/remote_receiver/esp32-common.yaml +++ /dev/null @@ -1,157 +0,0 @@ -remote_receiver: - id: rcvr - pin: ${pin} - rmt_channel: ${rmt_channel} - dump: all - tolerance: 25% - on_abbwelcome: - then: - - logger.log: - format: "on_abbwelcome: %u" - args: ["x.data()[0]"] - on_aeha: - then: - - logger.log: - format: "on_aeha: %u %u" - args: ["x.address", "x.data.front()"] - on_byronsx: - then: - - logger.log: - format: "on_byronsx: %u %u" - args: ["x.address", "x.command"] - on_canalsat: - then: - - logger.log: - format: "on_canalsat: %u %u" - args: ["x.address", "x.command"] - # on_canalsatld: - # then: - # - logger.log: - # format: "on_canalsatld: %u %u" - # args: ["x.address", "x.command"] - on_coolix: - then: - - logger.log: - format: "on_coolix: %lu %lu" - args: ["long(x.first)", "long(x.second)"] - on_dish: - then: - - logger.log: - format: "on_dish: %u %u" - args: ["x.address", "x.command"] - on_dooya: - then: - - logger.log: - format: "on_dooya: %u %u %u" - args: ["x.channel", "x.button", "x.check"] - on_drayton: - then: - - logger.log: - format: "on_drayton: %u %u %u" - args: ["x.address", "x.channel", "x.command"] - on_jvc: - then: - - logger.log: - format: "on_jvc: %lu" - args: ["long(x.data)"] - on_keeloq: - then: - - logger.log: - format: "on_keeloq: %lu %lu %u" - args: ["long(x.encrypted)", "long(x.address)", "x.command"] - on_haier: - then: - - logger.log: - format: "on_haier: %u" - args: ["x.data.front()"] - on_lg: - then: - - logger.log: - format: "on_lg: %lu %u" - args: ["long(x.data)", "x.nbits"] - on_magiquest: - then: - - logger.log: - format: "on_magiquest: %u %lu" - args: ["x.magnitude", "long(x.wand_id)"] - on_midea: - then: - - logger.log: - format: "on_midea: %u %u" - args: ["x.size()", "x.data()[0]"] - on_nec: - then: - - logger.log: - format: "on_nec: %u %u" - args: ["x.address", "x.command"] - on_nexa: - then: - - logger.log: - format: "on_nexa: %lu %u %u %u %u" - args: ["long(x.device)", "x.group", "x.state", "x.channel", "x.level"] - on_panasonic: - then: - - logger.log: - format: "on_panasonic: %u %lu" - args: ["x.address", "long(x.command)"] - on_pioneer: - then: - - logger.log: - format: "on_pioneer: %u %u" - args: ["x.rc_code_1", "x.rc_code_2"] - on_pronto: - then: - - logger.log: - format: "on_pronto: %s" - args: ["x.data.c_str()"] - on_raw: - then: - - logger.log: - format: "on_raw: %lu" - args: ["long(x.front())"] - on_rc5: - then: - - logger.log: - format: "on_rc5: %u %u" - args: ["x.address", "x.command"] - on_rc6: - then: - - logger.log: - format: "on_rc6: %u %u" - args: ["x.address", "x.command"] - on_rc_switch: - then: - - logger.log: - format: "on_rc_switch: %llu %u" - args: ["x.code", "x.protocol"] - on_samsung: - then: - - logger.log: - format: "on_samsung: %llu %u" - args: ["x.data", "x.nbits"] - on_samsung36: - then: - - logger.log: - format: "on_samsung36: %u %lu" - args: ["x.address", "long(x.command)"] - on_sony: - then: - - logger.log: - format: "on_sony: %lu %u" - args: ["long(x.data)", "x.nbits"] - on_toshiba_ac: - then: - - logger.log: - format: "on_toshiba_ac: %llu %llu" - args: ["x.rc_code_1", "x.rc_code_2"] - on_mirage: - then: - - lambda: |- - ESP_LOGD("mirage", "Mirage data: %s", format_hex(x.data).c_str()); - -binary_sensor: - - platform: remote_receiver - name: Panasonic Remote Input - panasonic: - address: 0x4004 - command: 0x100BCBD diff --git a/tests/components/remote_receiver/test.esp32-ard.yaml b/tests/components/remote_receiver/test.esp32-ard.yaml index 16d276958a..5d29187206 100644 --- a/tests/components/remote_receiver/test.esp32-ard.yaml +++ b/tests/components/remote_receiver/test.esp32-ard.yaml @@ -3,4 +3,4 @@ substitutions: rmt_channel: "2" packages: - common: !include esp32-common.yaml + common: !include esp32-common-ard.yaml diff --git a/tests/components/remote_receiver/test.esp32-c3-ard.yaml b/tests/components/remote_receiver/test.esp32-c3-ard.yaml index 16d276958a..5d29187206 100644 --- a/tests/components/remote_receiver/test.esp32-c3-ard.yaml +++ b/tests/components/remote_receiver/test.esp32-c3-ard.yaml @@ -3,4 +3,4 @@ substitutions: rmt_channel: "2" packages: - common: !include esp32-common.yaml + common: !include esp32-common-ard.yaml diff --git a/tests/components/remote_receiver/test.esp32-c3-idf.yaml b/tests/components/remote_receiver/test.esp32-c3-idf.yaml index 16d276958a..495bb293c3 100644 --- a/tests/components/remote_receiver/test.esp32-c3-idf.yaml +++ b/tests/components/remote_receiver/test.esp32-c3-idf.yaml @@ -1,6 +1,10 @@ substitutions: pin: GPIO2 - rmt_channel: "2" + clock_resolution: "2000000" + filter_symbols: "2" + receive_symbols: "4" + rmt_symbols: "64" + use_dma: "true" packages: - common: !include esp32-common.yaml + common: !include esp32-common-idf.yaml diff --git a/tests/components/remote_receiver/test.esp32-idf.yaml b/tests/components/remote_receiver/test.esp32-idf.yaml index 16d276958a..495bb293c3 100644 --- a/tests/components/remote_receiver/test.esp32-idf.yaml +++ b/tests/components/remote_receiver/test.esp32-idf.yaml @@ -1,6 +1,10 @@ substitutions: pin: GPIO2 - rmt_channel: "2" + clock_resolution: "2000000" + filter_symbols: "2" + receive_symbols: "4" + rmt_symbols: "64" + use_dma: "true" packages: - common: !include esp32-common.yaml + common: !include esp32-common-idf.yaml diff --git a/tests/components/remote_receiver/test.esp32-s3-idf.yaml b/tests/components/remote_receiver/test.esp32-s3-idf.yaml index 265ecda771..e678ba456d 100644 --- a/tests/components/remote_receiver/test.esp32-s3-idf.yaml +++ b/tests/components/remote_receiver/test.esp32-s3-idf.yaml @@ -1,6 +1,10 @@ substitutions: pin: GPIO38 - rmt_channel: "5" + clock_resolution: "2000000" + filter_symbols: "2" + receive_symbols: "4" + rmt_symbols: "64" + use_dma: "true" packages: - common: !include esp32-common.yaml + common: !include esp32-common-idf.yaml diff --git a/tests/components/remote_receiver/test.esp8266-ard.yaml b/tests/components/remote_receiver/test.esp8266-ard.yaml index 27d36d4a16..c9784ae003 100644 --- a/tests/components/remote_receiver/test.esp8266-ard.yaml +++ b/tests/components/remote_receiver/test.esp8266-ard.yaml @@ -2,150 +2,7 @@ remote_receiver: id: rcvr pin: GPIO5 dump: all - on_abbwelcome: - then: - - logger.log: - format: "on_abbwelcome: %u" - args: ["x.data()[0]"] - on_aeha: - then: - - logger.log: - format: "on_aeha: %u %u" - args: ["x.address", "x.data.front()"] - on_byronsx: - then: - - logger.log: - format: "on_byronsx: %u %u" - args: ["x.address", "x.command"] - on_canalsat: - then: - - logger.log: - format: "on_canalsat: %u %u" - args: ["x.address", "x.command"] - # on_canalsatld: - # then: - # - logger.log: - # format: "on_canalsatld: %u %u" - # args: ["x.address", "x.command"] - on_coolix: - then: - - logger.log: - format: "on_coolix: %u %u" - args: ["x.first", "x.second"] - on_dish: - then: - - logger.log: - format: "on_dish: %u %u" - args: ["x.address", "x.command"] - on_dooya: - then: - - logger.log: - format: "on_dooya: %u %u %u" - args: ["x.channel", "x.button", "x.check"] - on_drayton: - then: - - logger.log: - format: "on_drayton: %u %u %u" - args: ["x.address", "x.channel", "x.command"] - on_jvc: - then: - - logger.log: - format: "on_jvc: %u" - args: ["x.data"] - on_keeloq: - then: - - logger.log: - format: "on_keeloq: %u %u %u" - args: ["x.encrypted", "x.address", "x.command"] - on_haier: - then: - - logger.log: - format: "on_haier: %u" - args: ["x.data.front()"] - on_lg: - then: - - logger.log: - format: "on_lg: %u %u" - args: ["x.data", "x.nbits"] - on_magiquest: - then: - - logger.log: - format: "on_magiquest: %u %u" - args: ["x.magnitude", "x.wand_id"] - on_midea: - then: - - logger.log: - format: "on_midea: %u %u" - args: ["x.size()", "x.data()[0]"] - on_nec: - then: - - logger.log: - format: "on_nec: %u %u" - args: ["x.address", "x.command"] - on_nexa: - then: - - logger.log: - format: "on_nexa: %u %u %u %u %u" - args: ["x.device", "x.group", "x.state", "x.channel", "x.level"] - on_panasonic: - then: - - logger.log: - format: "on_panasonic: %u %u" - args: ["x.address", "x.command"] - on_pioneer: - then: - - logger.log: - format: "on_pioneer: %u %u" - args: ["x.rc_code_1", "x.rc_code_2"] - on_pronto: - then: - - logger.log: - format: "on_pronto: %s" - args: ["x.data.c_str()"] - on_raw: - then: - - logger.log: - format: "on_raw: %u" - args: ["x.front()"] - on_rc5: - then: - - logger.log: - format: "on_rc5: %u %u" - args: ["x.address", "x.command"] - on_rc6: - then: - - logger.log: - format: "on_rc6: %u %u" - args: ["x.address", "x.command"] - on_rc_switch: - then: - - logger.log: - format: "on_rc_switch: %llu %u" - args: ["x.code", "x.protocol"] - on_samsung: - then: - - logger.log: - format: "on_samsung: %llu %u" - args: ["x.data", "x.nbits"] - on_samsung36: - then: - - logger.log: - format: "on_samsung36: %u %u" - args: ["x.address", "x.command"] - on_sony: - then: - - logger.log: - format: "on_sony: %u %u" - args: ["x.data", "x.nbits"] - on_toshiba_ac: - then: - - logger.log: - format: "on_toshiba_ac: %llu %llu" - args: ["x.rc_code_1", "x.rc_code_2"] - on_mirage: - then: - - lambda: |- - ESP_LOGD("mirage", "Mirage data: %s", format_hex(x.data).c_str()); + <<: !include common-actions.yaml binary_sensor: - platform: remote_receiver diff --git a/tests/components/remote_transmitter/esp32-common-ard.yaml b/tests/components/remote_transmitter/esp32-common-ard.yaml new file mode 100644 index 0000000000..420cea326d --- /dev/null +++ b/tests/components/remote_transmitter/esp32-common-ard.yaml @@ -0,0 +1,8 @@ +remote_transmitter: + - id: xmitr + pin: ${pin} + rmt_channel: ${rmt_channel} + carrier_duty_percent: 50% + +packages: + buttons: !include common-buttons.yaml diff --git a/tests/components/remote_transmitter/esp32-common-idf.yaml b/tests/components/remote_transmitter/esp32-common-idf.yaml new file mode 100644 index 0000000000..3b8b5e2aef --- /dev/null +++ b/tests/components/remote_transmitter/esp32-common-idf.yaml @@ -0,0 +1,11 @@ +remote_transmitter: + - id: xmitr + pin: ${pin} + carrier_duty_percent: 50% + clock_resolution: ${clock_resolution} + one_wire: ${one_wire} + rmt_symbols: ${rmt_symbols} + use_dma: ${use_dma} + +packages: + buttons: !include common-buttons.yaml diff --git a/tests/components/remote_transmitter/esp32-common.yaml b/tests/components/remote_transmitter/esp32-common.yaml deleted file mode 100644 index 3f3cd3f8c7..0000000000 --- a/tests/components/remote_transmitter/esp32-common.yaml +++ /dev/null @@ -1,8 +0,0 @@ -remote_transmitter: - id: rcvr - pin: ${pin} - rmt_channel: ${rmt_channel} - carrier_duty_percent: 50% - -packages: - buttons: !include common-buttons.yaml diff --git a/tests/components/remote_transmitter/test.esp32-ard.yaml b/tests/components/remote_transmitter/test.esp32-ard.yaml index 16d276958a..5d29187206 100644 --- a/tests/components/remote_transmitter/test.esp32-ard.yaml +++ b/tests/components/remote_transmitter/test.esp32-ard.yaml @@ -3,4 +3,4 @@ substitutions: rmt_channel: "2" packages: - common: !include esp32-common.yaml + common: !include esp32-common-ard.yaml diff --git a/tests/components/remote_transmitter/test.esp32-c3-ard.yaml b/tests/components/remote_transmitter/test.esp32-c3-ard.yaml index 3e2dc88e5a..c755b11563 100644 --- a/tests/components/remote_transmitter/test.esp32-c3-ard.yaml +++ b/tests/components/remote_transmitter/test.esp32-c3-ard.yaml @@ -3,4 +3,4 @@ substitutions: rmt_channel: "1" packages: - common: !include esp32-common.yaml + common: !include esp32-common-ard.yaml diff --git a/tests/components/remote_transmitter/test.esp32-c3-idf.yaml b/tests/components/remote_transmitter/test.esp32-c3-idf.yaml index 3e2dc88e5a..1a27f29dac 100644 --- a/tests/components/remote_transmitter/test.esp32-c3-idf.yaml +++ b/tests/components/remote_transmitter/test.esp32-c3-idf.yaml @@ -1,6 +1,9 @@ substitutions: pin: GPIO2 - rmt_channel: "1" + clock_resolution: "2000000" + one_wire: "true" + rmt_symbols: "64" + use_dma: "true" packages: - common: !include esp32-common.yaml + common: !include esp32-common-idf.yaml diff --git a/tests/components/remote_transmitter/test.esp32-idf.yaml b/tests/components/remote_transmitter/test.esp32-idf.yaml index 16d276958a..1a27f29dac 100644 --- a/tests/components/remote_transmitter/test.esp32-idf.yaml +++ b/tests/components/remote_transmitter/test.esp32-idf.yaml @@ -1,6 +1,9 @@ substitutions: pin: GPIO2 - rmt_channel: "2" + clock_resolution: "2000000" + one_wire: "true" + rmt_symbols: "64" + use_dma: "true" packages: - common: !include esp32-common.yaml + common: !include esp32-common-idf.yaml diff --git a/tests/components/remote_transmitter/test.esp32-s3-idf.yaml b/tests/components/remote_transmitter/test.esp32-s3-idf.yaml index 31851dc54c..25bdbd4772 100644 --- a/tests/components/remote_transmitter/test.esp32-s3-idf.yaml +++ b/tests/components/remote_transmitter/test.esp32-s3-idf.yaml @@ -1,6 +1,9 @@ substitutions: pin: GPIO38 - rmt_channel: "3" + clock_resolution: "2000000" + one_wire: "true" + rmt_symbols: "64" + use_dma: "true" packages: - common: !include esp32-common.yaml + common: !include esp32-common-idf.yaml diff --git a/tests/components/remote_transmitter/test.esp8266-ard.yaml b/tests/components/remote_transmitter/test.esp8266-ard.yaml index de494485f4..19759360f4 100644 --- a/tests/components/remote_transmitter/test.esp8266-ard.yaml +++ b/tests/components/remote_transmitter/test.esp8266-ard.yaml @@ -1,5 +1,5 @@ remote_transmitter: - id: trns + id: xmitr pin: GPIO5 carrier_duty_percent: 50% From ac631711ab47019f31b31f9dbb5bf9062a899251 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:30:23 +1100 Subject: [PATCH 025/194] [qspi_dbi] Bugfix and new features (#7979) --- esphome/components/lvgl/__init__.py | 6 +- esphome/components/qspi_dbi/__init__.py | 3 + esphome/components/qspi_dbi/display.py | 123 ++++++----- esphome/components/qspi_dbi/models.py | 247 ++++++++++++++++++++++- esphome/components/qspi_dbi/qspi_dbi.cpp | 25 +-- esphome/components/qspi_dbi/qspi_dbi.h | 4 +- 6 files changed, 339 insertions(+), 69 deletions(-) diff --git a/esphome/components/lvgl/__init__.py b/esphome/components/lvgl/__init__.py index 8fdd03f647..b858e8df01 100644 --- a/esphome/components/lvgl/__init__.py +++ b/esphome/components/lvgl/__init__.py @@ -23,7 +23,7 @@ from esphome.helpers import write_file_if_changed from . import defines as df, helpers, lv_validation as lvalid from .automation import disp_update, focused_widgets, update_to_code -from .defines import add_define +from .defines import CONF_DRAW_ROUNDING, add_define from .encoders import ( ENCODERS_CONFIG, encoders_to_code, @@ -205,6 +205,10 @@ def final_validation(configs): raise cv.Invalid( "Using auto_clear_enabled: true in display config not compatible with LVGL" ) + if draw_rounding := display.get(CONF_DRAW_ROUNDING): + config[CONF_DRAW_ROUNDING] = max( + draw_rounding, config[CONF_DRAW_ROUNDING] + ) buffer_frac = config[CONF_BUFFER_SIZE] if CORE.is_esp32 and buffer_frac > 0.5 and "psram" not in global_config: LOGGER.warning("buffer_size: may need to be reduced without PSRAM") diff --git a/esphome/components/qspi_dbi/__init__.py b/esphome/components/qspi_dbi/__init__.py index c58ce8a01e..a4b833f6d7 100644 --- a/esphome/components/qspi_dbi/__init__.py +++ b/esphome/components/qspi_dbi/__init__.py @@ -1 +1,4 @@ CODEOWNERS = ["@clydebarrow"] + +CONF_DRAW_FROM_ORIGIN = "draw_from_origin" +CONF_DRAW_ROUNDING = "draw_rounding" diff --git a/esphome/components/qspi_dbi/display.py b/esphome/components/qspi_dbi/display.py index 71ae31f182..ab6dd66cf2 100644 --- a/esphome/components/qspi_dbi/display.py +++ b/esphome/components/qspi_dbi/display.py @@ -24,6 +24,7 @@ from esphome.const import ( ) from esphome.core import TimePeriod +from . import CONF_DRAW_FROM_ORIGIN, CONF_DRAW_ROUNDING from .models import DriverChip DEPENDENCIES = ["spi"] @@ -41,7 +42,6 @@ COLOR_ORDERS = { } DATA_PIN_SCHEMA = pins.internal_gpio_output_pin_schema -CONF_DRAW_FROM_ORIGIN = "draw_from_origin" DELAY_FLAG = 0xFF @@ -78,56 +78,81 @@ def _validate(config): return config -CONFIG_SCHEMA = cv.All( - display.FULL_DISPLAY_SCHEMA.extend( - cv.Schema( - { - cv.GenerateID(): cv.declare_id(QSPI_DBI), - cv.Required(CONF_MODEL): cv.one_of( - *DriverChip.chips.keys(), upper=True - ), - cv.Optional(CONF_INIT_SEQUENCE): cv.ensure_list(map_sequence), - cv.Required(CONF_DIMENSIONS): cv.Any( - cv.dimensions, - cv.Schema( - { - cv.Required(CONF_WIDTH): validate_dimension, - cv.Required(CONF_HEIGHT): validate_dimension, - cv.Optional( - CONF_OFFSET_HEIGHT, default=0 - ): validate_dimension, - cv.Optional( - CONF_OFFSET_WIDTH, default=0 - ): validate_dimension, - } - ), - ), - cv.Optional(CONF_TRANSFORM): cv.Schema( +def power_of_two(value): + value = cv.int_range(1, 128)(value) + if value & (value - 1) != 0: + raise cv.Invalid("value must be a power of two") + return value + + +BASE_SCHEMA = display.FULL_DISPLAY_SCHEMA.extend( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(QSPI_DBI), + cv.Optional(CONF_INIT_SEQUENCE): cv.ensure_list(map_sequence), + cv.Required(CONF_DIMENSIONS): cv.Any( + cv.dimensions, + cv.Schema( { - cv.Optional(CONF_MIRROR_X, default=False): cv.boolean, - cv.Optional(CONF_MIRROR_Y, default=False): cv.boolean, - cv.Optional(CONF_SWAP_XY, default=False): cv.boolean, + cv.Required(CONF_WIDTH): validate_dimension, + cv.Required(CONF_HEIGHT): validate_dimension, + cv.Optional(CONF_OFFSET_HEIGHT, default=0): validate_dimension, + cv.Optional(CONF_OFFSET_WIDTH, default=0): validate_dimension, } ), - cv.Optional(CONF_COLOR_ORDER, default="RGB"): cv.enum( - COLOR_ORDERS, upper=True - ), - cv.Optional(CONF_INVERT_COLORS, default=False): cv.boolean, - cv.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema, - cv.Optional(CONF_ENABLE_PIN): pins.gpio_output_pin_schema, - cv.Optional(CONF_BRIGHTNESS, default=0xD0): cv.int_range( - 0, 0xFF, min_included=True, max_included=True - ), - cv.Optional(CONF_DRAW_FROM_ORIGIN, default=False): cv.boolean, - } - ).extend( - spi.spi_device_schema( - cs_pin_required=False, - default_mode="MODE0", - default_data_rate=10e6, - quad=True, - ) + ), + cv.Optional(CONF_DRAW_FROM_ORIGIN, default=False): cv.boolean, + cv.Optional(CONF_RESET_PIN): pins.gpio_output_pin_schema, + cv.Optional(CONF_ENABLE_PIN): pins.gpio_output_pin_schema, + cv.Optional(CONF_BRIGHTNESS, default=0xD0): cv.int_range( + 0, 0xFF, min_included=True, max_included=True + ), + } + ).extend( + spi.spi_device_schema( + cs_pin_required=False, + default_mode="MODE0", + default_data_rate=10e6, + quad=True, ) + ) +) + + +def model_property(name, defaults, fallback): + return cv.Optional(name, default=defaults.get(name, fallback)) + + +def model_schema(defaults): + transform = cv.Schema( + { + cv.Optional(CONF_MIRROR_X, default=False): cv.boolean, + cv.Optional(CONF_MIRROR_Y, default=False): cv.boolean, + } + ) + if defaults.get(CONF_SWAP_XY, True): + transform = transform.extend( + { + cv.Optional(CONF_SWAP_XY, default=False): cv.boolean, + } + ) + return BASE_SCHEMA.extend( + { + model_property(CONF_INVERT_COLORS, defaults, False): cv.boolean, + model_property(CONF_COLOR_ORDER, defaults, "RGB"): cv.enum( + COLOR_ORDERS, upper=True + ), + model_property(CONF_DRAW_ROUNDING, defaults, 2): power_of_two, + cv.Optional(CONF_TRANSFORM): transform, + } + ) + + +CONFIG_SCHEMA = cv.All( + cv.typed_schema( + {k.upper(): model_schema(v.defaults) for k, v in DriverChip.chips.items()}, + upper=True, + key=CONF_MODEL, ), cv.only_with_esp_idf, ) @@ -152,6 +177,7 @@ async def to_code(config): cg.add(var.set_brightness(config[CONF_BRIGHTNESS])) cg.add(var.set_model(config[CONF_MODEL])) cg.add(var.set_draw_from_origin(config[CONF_DRAW_FROM_ORIGIN])) + cg.add(var.set_draw_rounding(config[CONF_DRAW_ROUNDING])) if enable_pin := config.get(CONF_ENABLE_PIN): enable = await cg.gpio_pin_expression(enable_pin) cg.add(var.set_enable_pin(enable)) @@ -163,7 +189,8 @@ async def to_code(config): if transform := config.get(CONF_TRANSFORM): cg.add(var.set_mirror_x(transform[CONF_MIRROR_X])) cg.add(var.set_mirror_y(transform[CONF_MIRROR_Y])) - cg.add(var.set_swap_xy(transform[CONF_SWAP_XY])) + # swap_xy is not implemented for some chips + cg.add(var.set_swap_xy(transform.get(CONF_SWAP_XY, False))) if CONF_DIMENSIONS in config: dimensions = config[CONF_DIMENSIONS] diff --git a/esphome/components/qspi_dbi/models.py b/esphome/components/qspi_dbi/models.py index c1fe434853..7ae1a10ec0 100644 --- a/esphome/components/qspi_dbi/models.py +++ b/esphome/components/qspi_dbi/models.py @@ -1,5 +1,10 @@ # Commands +from esphome.const import CONF_INVERT_COLORS, CONF_SWAP_XY + +from . import CONF_DRAW_ROUNDING + SW_RESET_CMD = 0x01 +SLEEP_IN = 0x10 SLEEP_OUT = 0x11 NORON = 0x13 INVERT_OFF = 0x20 @@ -24,11 +29,12 @@ PAGESEL = 0xFE class DriverChip: chips = {} - def __init__(self, name: str): + def __init__(self, name: str, defaults=None): name = name.upper() self.name = name self.chips[name] = self self.initsequence = [] + self.defaults = defaults or {} def cmd(self, c, *args): """ @@ -59,9 +65,246 @@ chip.cmd(TEON, 0x00) chip.cmd(PIXFMT, 0x55) chip.cmd(NORON) -chip = DriverChip("AXS15231") +chip = DriverChip("AXS15231", {CONF_DRAW_ROUNDING: 8, CONF_SWAP_XY: False}) chip.cmd(0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A, 0xA5) chip.cmd(0xC1, 0x33) chip.cmd(0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) +chip = DriverChip( + "JC4832W535", + { + CONF_DRAW_ROUNDING: 8, + CONF_SWAP_XY: False, + }, +) +chip.cmd(DISPLAY_OFF) +chip.delay(20) +chip.cmd(SLEEP_IN) +chip.delay(80) +chip.cmd(SLEEP_OUT) +chip.cmd(INVERT_OFF) +# A magic sequence to enable the windowed drawing mode +chip.cmd(0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A, 0xA5) +chip.cmd(0xC1, 0x33) +chip.cmd(0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) + +chip = DriverChip("JC3636W518", {CONF_INVERT_COLORS: True}) +chip.cmd(0xF0, 0x08) +chip.cmd(0xF2, 0x08) +chip.cmd(0x9B, 0x51) +chip.cmd(0x86, 0x53) +chip.cmd(0xF2, 0x80) +chip.cmd(0xF0, 0x00) +chip.cmd(0xF0, 0x01) +chip.cmd(0xF1, 0x01) +chip.cmd(0xB0, 0x54) +chip.cmd(0xB1, 0x3F) +chip.cmd(0xB2, 0x2A) +chip.cmd(0xB4, 0x46) +chip.cmd(0xB5, 0x34) +chip.cmd(0xB6, 0xD5) +chip.cmd(0xB7, 0x30) +chip.cmd(0xBA, 0x00) +chip.cmd(0xBB, 0x08) +chip.cmd(0xBC, 0x08) +chip.cmd(0xBD, 0x00) +chip.cmd(0xC0, 0x80) +chip.cmd(0xC1, 0x10) +chip.cmd(0xC2, 0x37) +chip.cmd(0xC3, 0x80) +chip.cmd(0xC4, 0x10) +chip.cmd(0xC5, 0x37) +chip.cmd(0xC6, 0xA9) +chip.cmd(0xC7, 0x41) +chip.cmd(0xC8, 0x51) +chip.cmd(0xC9, 0xA9) +chip.cmd(0xCA, 0x41) +chip.cmd(0xCB, 0x51) +chip.cmd(0xD0, 0x91) +chip.cmd(0xD1, 0x68) +chip.cmd(0xD2, 0x69) +chip.cmd(0xF5, 0x00, 0xA5) +chip.cmd(0xDD, 0x3F) +chip.cmd(0xDE, 0x3F) +chip.cmd(0xF1, 0x10) +chip.cmd(0xF0, 0x00) +chip.cmd(0xF0, 0x02) +chip.cmd( + 0xE0, + 0x70, + 0x09, + 0x12, + 0x0C, + 0x0B, + 0x27, + 0x38, + 0x54, + 0x4E, + 0x19, + 0x15, + 0x15, + 0x2C, + 0x2F, +) +chip.cmd( + 0xE1, + 0x70, + 0x08, + 0x11, + 0x0C, + 0x0B, + 0x27, + 0x38, + 0x43, + 0x4C, + 0x18, + 0x14, + 0x14, + 0x2B, + 0x2D, +) +chip.cmd(0xF0, 0x10) +chip.cmd(0xF3, 0x10) +chip.cmd(0xE0, 0x08) +chip.cmd(0xE1, 0x00) +chip.cmd(0xE2, 0x00) +chip.cmd(0xE3, 0x00) +chip.cmd(0xE4, 0xE0) +chip.cmd(0xE5, 0x06) +chip.cmd(0xE6, 0x21) +chip.cmd(0xE7, 0x00) +chip.cmd(0xE8, 0x05) +chip.cmd(0xE9, 0x82) +chip.cmd(0xEA, 0xDF) +chip.cmd(0xEB, 0x89) +chip.cmd(0xEC, 0x20) +chip.cmd(0xED, 0x14) +chip.cmd(0xEE, 0xFF) +chip.cmd(0xEF, 0x00) +chip.cmd(0xF8, 0xFF) +chip.cmd(0xF9, 0x00) +chip.cmd(0xFA, 0x00) +chip.cmd(0xFB, 0x30) +chip.cmd(0xFC, 0x00) +chip.cmd(0xFD, 0x00) +chip.cmd(0xFE, 0x00) +chip.cmd(0xFF, 0x00) +chip.cmd(0x60, 0x42) +chip.cmd(0x61, 0xE0) +chip.cmd(0x62, 0x40) +chip.cmd(0x63, 0x40) +chip.cmd(0x64, 0x02) +chip.cmd(0x65, 0x00) +chip.cmd(0x66, 0x40) +chip.cmd(0x67, 0x03) +chip.cmd(0x68, 0x00) +chip.cmd(0x69, 0x00) +chip.cmd(0x6A, 0x00) +chip.cmd(0x6B, 0x00) +chip.cmd(0x70, 0x42) +chip.cmd(0x71, 0xE0) +chip.cmd(0x72, 0x40) +chip.cmd(0x73, 0x40) +chip.cmd(0x74, 0x02) +chip.cmd(0x75, 0x00) +chip.cmd(0x76, 0x40) +chip.cmd(0x77, 0x03) +chip.cmd(0x78, 0x00) +chip.cmd(0x79, 0x00) +chip.cmd(0x7A, 0x00) +chip.cmd(0x7B, 0x00) +chip.cmd(0x80, 0x48) +chip.cmd(0x81, 0x00) +chip.cmd(0x82, 0x05) +chip.cmd(0x83, 0x02) +chip.cmd(0x84, 0xDD) +chip.cmd(0x85, 0x00) +chip.cmd(0x86, 0x00) +chip.cmd(0x87, 0x00) +chip.cmd(0x88, 0x48) +chip.cmd(0x89, 0x00) +chip.cmd(0x8A, 0x07) +chip.cmd(0x8B, 0x02) +chip.cmd(0x8C, 0xDF) +chip.cmd(0x8D, 0x00) +chip.cmd(0x8E, 0x00) +chip.cmd(0x8F, 0x00) +chip.cmd(0x90, 0x48) +chip.cmd(0x91, 0x00) +chip.cmd(0x92, 0x09) +chip.cmd(0x93, 0x02) +chip.cmd(0x94, 0xE1) +chip.cmd(0x95, 0x00) +chip.cmd(0x96, 0x00) +chip.cmd(0x97, 0x00) +chip.cmd(0x98, 0x48) +chip.cmd(0x99, 0x00) +chip.cmd(0x9A, 0x0B) +chip.cmd(0x9B, 0x02) +chip.cmd(0x9C, 0xE3) +chip.cmd(0x9D, 0x00) +chip.cmd(0x9E, 0x00) +chip.cmd(0x9F, 0x00) +chip.cmd(0xA0, 0x48) +chip.cmd(0xA1, 0x00) +chip.cmd(0xA2, 0x04) +chip.cmd(0xA3, 0x02) +chip.cmd(0xA4, 0xDC) +chip.cmd(0xA5, 0x00) +chip.cmd(0xA6, 0x00) +chip.cmd(0xA7, 0x00) +chip.cmd(0xA8, 0x48) +chip.cmd(0xA9, 0x00) +chip.cmd(0xAA, 0x06) +chip.cmd(0xAB, 0x02) +chip.cmd(0xAC, 0xDE) +chip.cmd(0xAD, 0x00) +chip.cmd(0xAE, 0x00) +chip.cmd(0xAF, 0x00) +chip.cmd(0xB0, 0x48) +chip.cmd(0xB1, 0x00) +chip.cmd(0xB2, 0x08) +chip.cmd(0xB3, 0x02) +chip.cmd(0xB4, 0xE0) +chip.cmd(0xB5, 0x00) +chip.cmd(0xB6, 0x00) +chip.cmd(0xB7, 0x00) +chip.cmd(0xB8, 0x48) +chip.cmd(0xB9, 0x00) +chip.cmd(0xBA, 0x0A) +chip.cmd(0xBB, 0x02) +chip.cmd(0xBC, 0xE2) +chip.cmd(0xBD, 0x00) +chip.cmd(0xBE, 0x00) +chip.cmd(0xBF, 0x00) +chip.cmd(0xC0, 0x12) +chip.cmd(0xC1, 0xAA) +chip.cmd(0xC2, 0x65) +chip.cmd(0xC3, 0x74) +chip.cmd(0xC4, 0x47) +chip.cmd(0xC5, 0x56) +chip.cmd(0xC6, 0x00) +chip.cmd(0xC7, 0x88) +chip.cmd(0xC8, 0x99) +chip.cmd(0xC9, 0x33) +chip.cmd(0xD0, 0x21) +chip.cmd(0xD1, 0xAA) +chip.cmd(0xD2, 0x65) +chip.cmd(0xD3, 0x74) +chip.cmd(0xD4, 0x47) +chip.cmd(0xD5, 0x56) +chip.cmd(0xD6, 0x00) +chip.cmd(0xD7, 0x88) +chip.cmd(0xD8, 0x99) +chip.cmd(0xD9, 0x33) +chip.cmd(0xF3, 0x01) +chip.cmd(0xF0, 0x00) +chip.cmd(0xF0, 0x01) +chip.cmd(0xF1, 0x01) +chip.cmd(0xA0, 0x0B) +chip.cmd(0xA3, 0x2A) +chip.cmd(0xA5, 0xC3) +chip.cmd(PIXFMT, 0x55) + + DriverChip("Custom") diff --git a/esphome/components/qspi_dbi/qspi_dbi.cpp b/esphome/components/qspi_dbi/qspi_dbi.cpp index f8fd5dd374..380c93c400 100644 --- a/esphome/components/qspi_dbi/qspi_dbi.cpp +++ b/esphome/components/qspi_dbi/qspi_dbi.cpp @@ -33,19 +33,12 @@ void QspiDbi::update() { this->do_update_(); if (this->buffer_ == nullptr || this->x_low_ > this->x_high_ || this->y_low_ > this->y_high_) return; - // Start addresses and widths/heights must be divisible by 2 (CASET/RASET restriction in datasheet) - if (this->x_low_ % 2 == 1) { - this->x_low_--; - } - if (this->x_high_ % 2 == 0) { - this->x_high_++; - } - if (this->y_low_ % 2 == 1) { - this->y_low_--; - } - if (this->y_high_ % 2 == 0) { - this->y_high_++; - } + // Some chips require that the drawing window be aligned on certain boundaries + auto dr = this->draw_rounding_; + this->x_low_ = this->x_low_ / dr * dr; + this->y_low_ = this->y_low_ / dr * dr; + this->x_high_ = (this->x_high_ + dr) / dr * dr - 1; + this->y_high_ = (this->y_high_ + dr) / dr * dr - 1; if (this->draw_from_origin_) { this->x_low_ = 0; this->y_low_ = 0; @@ -175,10 +168,9 @@ void QspiDbi::write_to_display_(int x_start, int y_start, int w, int h, const ui this->write_cmd_addr_data(8, 0x32, 24, 0x2C00, ptr, w * h * 2, 4); } else { auto stride = x_offset + w + x_pad; - uint16_t cmd = 0x2C00; + this->write_cmd_addr_data(8, 0x32, 24, 0x2C00, nullptr, 0, 4); for (int y = 0; y != h; y++) { - this->write_cmd_addr_data(8, 0x32, 24, cmd, ptr + ((y + y_offset) * stride + x_offset) * 2, w * 2, 4); - cmd = 0x3C00; + this->write_cmd_addr_data(0, 0, 0, 0, ptr + ((y + y_offset) * stride + x_offset) * 2, w * 2, 4); } } this->disable(); @@ -220,6 +212,7 @@ void QspiDbi::dump_config() { ESP_LOGCONFIG("", "Model: %s", this->model_); ESP_LOGCONFIG(TAG, " Height: %u", this->height_); ESP_LOGCONFIG(TAG, " Width: %u", this->width_); + ESP_LOGCONFIG(TAG, " Draw rounding: %u", this->draw_rounding_); LOG_PIN(" CS Pin: ", this->cs_); LOG_PIN(" Reset Pin: ", this->reset_pin_); ESP_LOGCONFIG(TAG, " SPI Data rate: %dMHz", (unsigned) (this->data_rate_ / 1000000)); diff --git a/esphome/components/qspi_dbi/qspi_dbi.h b/esphome/components/qspi_dbi/qspi_dbi.h index ebb65a8a05..2c555f115e 100644 --- a/esphome/components/qspi_dbi/qspi_dbi.h +++ b/esphome/components/qspi_dbi/qspi_dbi.h @@ -4,12 +4,10 @@ #pragma once #ifdef USE_ESP_IDF -#include "esphome/core/component.h" #include "esphome/components/spi/spi.h" #include "esphome/components/display/display.h" #include "esphome/components/display/display_buffer.h" #include "esphome/components/display/display_color_utils.h" -#include "esp_lcd_panel_ops.h" #include "esp_lcd_panel_rgb.h" @@ -105,6 +103,7 @@ class QspiDbi : public display::DisplayBuffer, int get_height_internal() override { return this->height_; } bool can_proceed() override { return this->setup_complete_; } void add_init_sequence(const std::vector &sequence) { this->init_sequences_.push_back(sequence); } + void set_draw_rounding(unsigned rounding) { this->draw_rounding_ = rounding; } protected: void check_buffer_() { @@ -161,6 +160,7 @@ class QspiDbi : public display::DisplayBuffer, bool mirror_x_{}; bool mirror_y_{}; bool draw_from_origin_{false}; + unsigned draw_rounding_{2}; uint8_t brightness_{0xD0}; const char *model_{"Unknown"}; std::vector> init_sequences_{}; From b33b4481ea031c19280e3148148be40d99484f56 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:40:08 +1100 Subject: [PATCH 026/194] [helpers] Provide calls to get free heap and largest available block. (#7978) --- esphome/components/json/json_util.cpp | 34 ++-------- .../components/online_image/online_image.cpp | 10 +-- esphome/core/helpers.h | 63 ++++++++++++++++--- 3 files changed, 61 insertions(+), 46 deletions(-) diff --git a/esphome/components/json/json_util.cpp b/esphome/components/json/json_util.cpp index 89ec13fe5b..87b1cc6d2d 100644 --- a/esphome/components/json/json_util.cpp +++ b/esphome/components/json/json_util.cpp @@ -1,38 +1,20 @@ #include "json_util.h" #include "esphome/core/log.h" -#ifdef USE_ESP8266 -#include -#endif -#ifdef USE_ESP32 -#include -#endif -#ifdef USE_RP2040 -#include -#endif - namespace esphome { namespace json { static const char *const TAG = "json"; static std::vector global_json_build_buffer; // NOLINT +static const auto ALLOCATOR = RAMAllocator(RAMAllocator::ALLOC_INTERNAL); std::string build_json(const json_build_t &f) { // Here we are allocating up to 5kb of memory, // with the heap size minus 2kb to be safe if less than 5kb // as we can not have a true dynamic sized document. // The excess memory is freed below with `shrinkToFit()` -#ifdef USE_ESP8266 - const size_t free_heap = ESP.getMaxFreeBlockSize(); // NOLINT(readability-static-accessed-through-instance) -#elif defined(USE_ESP32) - const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT); -#elif defined(USE_RP2040) - const size_t free_heap = rp2040.getFreeHeap(); -#elif defined(USE_LIBRETINY) - const size_t free_heap = lt_heap_get_free(); -#endif - + auto free_heap = ALLOCATOR.get_max_free_block_size(); size_t request_size = std::min(free_heap, (size_t) 512); while (true) { ESP_LOGV(TAG, "Attempting to allocate %u bytes for JSON serialization", request_size); @@ -67,20 +49,12 @@ bool parse_json(const std::string &data, const json_parse_t &f) { // with the heap size minus 2kb to be safe if less than that // as we can not have a true dynamic sized document. // The excess memory is freed below with `shrinkToFit()` -#ifdef USE_ESP8266 - const size_t free_heap = ESP.getMaxFreeBlockSize(); // NOLINT(readability-static-accessed-through-instance) -#elif defined(USE_ESP32) - const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT); -#elif defined(USE_RP2040) - const size_t free_heap = rp2040.getFreeHeap(); -#elif defined(USE_LIBRETINY) - const size_t free_heap = lt_heap_get_free(); -#endif + auto free_heap = ALLOCATOR.get_max_free_block_size(); size_t request_size = std::min(free_heap, (size_t) (data.size() * 1.5)); while (true) { DynamicJsonDocument json_document(request_size); if (json_document.capacity() == 0) { - ESP_LOGE(TAG, "Could not allocate memory for JSON document! Requested %u bytes, free heap: %u", request_size, + ESP_LOGE(TAG, "Could not allocate memory for JSON document! Requested %zu bytes, free heap: %zu", request_size, free_heap); return false; } diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index 1786809dfa..8c4669cba5 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -80,15 +80,7 @@ bool OnlineImage::resize_(int width_in, int height_in) { this->width_ = width; ESP_LOGD(TAG, "New size: (%d, %d)", width, height); } else { -#if defined(USE_ESP8266) - // NOLINTNEXTLINE(readability-static-accessed-through-instance) - int max_block = ESP.getMaxFreeBlockSize(); -#elif defined(USE_ESP32) - int max_block = heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL); -#else - int max_block = -1; -#endif - ESP_LOGE(TAG, "allocation failed. Biggest block in heap: %d Bytes", max_block); + ESP_LOGE(TAG, "allocation failed. Biggest block in heap: %zu Bytes", this->allocator_.get_max_free_block_size()); this->end_connection_(); return false; } diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index fcbd8d8683..c823439fb3 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -11,6 +11,14 @@ #include "esphome/core/optional.h" +#ifdef USE_ESP8266 +#include +#endif + +#ifdef USE_RP2040 +#include +#endif + #ifdef USE_ESP32 #include #endif @@ -684,20 +692,23 @@ template class RAMAllocator { }; RAMAllocator() = default; - RAMAllocator(uint8_t flags) : flags_{flags} {} + RAMAllocator(uint8_t flags) { + // default is both external and internal + flags &= ALLOC_INTERNAL | ALLOC_EXTERNAL; + if (flags != 0) + this->flags_ = flags; + } template constexpr RAMAllocator(const RAMAllocator &other) : flags_{other.flags_} {} T *allocate(size_t n) { size_t size = n * sizeof(T); T *ptr = nullptr; #ifdef USE_ESP32 - // External allocation by default or if explicitely requested - if ((this->flags_ & Flags::ALLOC_EXTERNAL) || ((this->flags_ & Flags::ALLOC_INTERNAL) == 0)) { + if (this->flags_ & Flags::ALLOC_EXTERNAL) { ptr = static_cast(heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)); } - // Fallback to internal allocation if explicitely requested or no flag is specified - if (ptr == nullptr && ((this->flags_ & Flags::ALLOC_INTERNAL) || (this->flags_ & Flags::ALLOC_EXTERNAL) == 0)) { - ptr = static_cast(malloc(size)); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc) + if (ptr == nullptr && this->flags_ & Flags::ALLOC_INTERNAL) { + ptr = static_cast(heap_caps_malloc(size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); } #else // Ignore ALLOC_EXTERNAL/ALLOC_INTERNAL flags if external allocation is not supported @@ -710,8 +721,46 @@ template class RAMAllocator { free(p); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc) } + /** + * Return the total heap space available via this allocator + */ + size_t get_free_heap_size() const { +#ifdef USE_ESP8266 + return ESP.getFreeHeap(); // NOLINT(readability-static-accessed-through-instance) +#elif defined(USE_ESP32) + auto max_internal = + this->flags_ & ALLOC_INTERNAL ? heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL) : 0; + auto max_external = + this->flags_ & ALLOC_EXTERNAL ? heap_caps_get_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM) : 0; + return max_internal + max_external; +#elif defined(USE_RP2040) + return ::rp2040.getFreeHeap(); +#elif defined(USE_LIBRETINY) + return lt_heap_get_free(); +#else + return 100000; +#endif + } + + /** + * Return the maximum size block this allocator could allocate. This may be an approximation on some platforms + */ + size_t get_max_free_block_size() const { +#ifdef USE_ESP8266 + return ESP.getMaxFreeBlockSize(); // NOLINT(readability-static-accessed-through-instance) +#elif defined(USE_ESP32) + auto max_internal = + this->flags_ & ALLOC_INTERNAL ? heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL) : 0; + auto max_external = + this->flags_ & ALLOC_EXTERNAL ? heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM) : 0; + return std::max(max_internal, max_external); +#else + return this->get_free_heap_size(); +#endif + } + private: - uint8_t flags_{Flags::ALLOW_FAILURE}; + uint8_t flags_{ALLOC_INTERNAL | ALLOC_EXTERNAL}; }; template using ExternalRAMAllocator = RAMAllocator; From 7da07303c934287837797a40b05526460a6734aa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:42:29 +1300 Subject: [PATCH 027/194] Bump actions/upload-artifact from 4.4.3 to 4.5.0 (#7981) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6cd86854b2..0304cd2304 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -141,7 +141,7 @@ jobs: echo name=$(cat /tmp/platform) >> $GITHUB_OUTPUT - name: Upload digests - uses: actions/upload-artifact@v4.4.3 + uses: actions/upload-artifact@v4.5.0 with: name: digests-${{ steps.sanitize.outputs.name }} path: /tmp/digests From f33b4a714ecd4e43d9f2f27f457d1dc8bad70a29 Mon Sep 17 00:00:00 2001 From: tomaszduda23 Date: Fri, 20 Dec 2024 01:45:40 +0100 Subject: [PATCH 028/194] [esp32_ble] do not skip events if queue is blocked (#7960) --- esphome/components/esp32_ble/queue.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/components/esp32_ble/queue.h b/esphome/components/esp32_ble/queue.h index 5b31b97ae2..c98477e121 100644 --- a/esphome/components/esp32_ble/queue.h +++ b/esphome/components/esp32_ble/queue.h @@ -26,10 +26,10 @@ template class Queue { void push(T *element) { if (element == nullptr) return; - if (xSemaphoreTake(m_, 5L / portTICK_PERIOD_MS)) { - q_.push(element); - xSemaphoreGive(m_); - } + // It is not called from main loop. Thus it won't block main thread. + xSemaphoreTake(m_, portMAX_DELAY); + q_.push(element); + xSemaphoreGive(m_); } T *pop() { From ba2edbc18909953e0de22ee95e57726d476e8f05 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Fri, 20 Dec 2024 01:28:08 -0600 Subject: [PATCH 029/194] [esp32] Fix flash size warning when using IDF (#7983) --- esphome/components/esp32/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/esphome/components/esp32/__init__.py b/esphome/components/esp32/__init__.py index b0bde75451..98db45831a 100644 --- a/esphome/components/esp32/__init__.py +++ b/esphome/components/esp32/__init__.py @@ -602,6 +602,9 @@ async def to_code(config): cg.add_platformio_option( "platform_packages", ["espressif/toolchain-esp32ulp@2.35.0-20220830"] ) + add_idf_sdkconfig_option( + f"CONFIG_ESPTOOLPY_FLASHSIZE_{config[CONF_FLASH_SIZE]}", True + ) add_idf_sdkconfig_option("CONFIG_PARTITION_TABLE_SINGLE_APP", False) add_idf_sdkconfig_option("CONFIG_PARTITION_TABLE_CUSTOM", True) add_idf_sdkconfig_option( From f3cb179f54e7b86133e9707b6ad5dcd41eeda989 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Fri, 20 Dec 2024 14:16:18 -0600 Subject: [PATCH 030/194] [esp32_ble] Fix for Improv (#7984) --- esphome/components/esp32_ble/ble_advertising.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/esp32_ble/ble_advertising.cpp b/esphome/components/esp32_ble/ble_advertising.cpp index 92b7c60368..1d340c76d9 100644 --- a/esphome/components/esp32_ble/ble_advertising.cpp +++ b/esphome/components/esp32_ble/ble_advertising.cpp @@ -83,7 +83,7 @@ esp_err_t BLEAdvertising::services_advertisement_() { esp_err_t err; this->advertising_data_.set_scan_rsp = false; - this->advertising_data_.include_name = true; + this->advertising_data_.include_name = !this->scan_response_; this->advertising_data_.include_txpower = !this->scan_response_; err = esp_ble_gap_config_adv_data(&this->advertising_data_); if (err != ESP_OK) { From 45beea68eb5c8c5b663b979515e37a0cffedc65c Mon Sep 17 00:00:00 2001 From: tomaszduda23 Date: Mon, 23 Dec 2024 06:49:04 +0100 Subject: [PATCH 031/194] [ble_client, bluetooth_proxy, esp32_ble_client, esp32_ble_tracker] fix ble proxy stop working (#7901) Co-authored-by: J. Nick Koston --- esphome/components/ble_client/ble_client.cpp | 3 +- .../bluetooth_proxy/bluetooth_connection.cpp | 5 ++ .../bluetooth_proxy/bluetooth_connection.h | 1 + .../esp32_ble_client/ble_client_base.cpp | 46 +++++++++++++++++++ .../esp32_ble_client/ble_client_base.h | 2 + .../esp32_ble_tracker/esp32_ble_tracker.cpp | 43 +++++++++++++---- .../esp32_ble_tracker/esp32_ble_tracker.h | 12 +++-- 7 files changed, 96 insertions(+), 16 deletions(-) diff --git a/esphome/components/ble_client/ble_client.cpp b/esphome/components/ble_client/ble_client.cpp index 19cf2bc1f3..5cf096c9d4 100644 --- a/esphome/components/ble_client/ble_client.cpp +++ b/esphome/components/ble_client/ble_client.cpp @@ -25,8 +25,7 @@ void BLEClient::loop() { void BLEClient::dump_config() { ESP_LOGCONFIG(TAG, "BLE Client:"); - ESP_LOGCONFIG(TAG, " Address: %s", this->address_str().c_str()); - ESP_LOGCONFIG(TAG, " Auto-Connect: %s", TRUEFALSE(this->auto_connect_)); + BLEClientBase::dump_config(); } bool BLEClient::parse_device(const espbt::ESPBTDevice &device) { diff --git a/esphome/components/bluetooth_proxy/bluetooth_connection.cpp b/esphome/components/bluetooth_proxy/bluetooth_connection.cpp index 543752853e..b63f7ccde9 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_connection.cpp +++ b/esphome/components/bluetooth_proxy/bluetooth_connection.cpp @@ -13,6 +13,11 @@ namespace bluetooth_proxy { static const char *const TAG = "bluetooth_proxy.connection"; +void BluetoothConnection::dump_config() { + ESP_LOGCONFIG(TAG, "BLE Connection:"); + BLEClientBase::dump_config(); +} + bool BluetoothConnection::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) { if (!BLEClientBase::gattc_event_handler(event, gattc_if, param)) diff --git a/esphome/components/bluetooth_proxy/bluetooth_connection.h b/esphome/components/bluetooth_proxy/bluetooth_connection.h index e6ab3cbccc..fd83f8dd00 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_connection.h +++ b/esphome/components/bluetooth_proxy/bluetooth_connection.h @@ -11,6 +11,7 @@ class BluetoothProxy; class BluetoothConnection : public esp32_ble_client::BLEClientBase { public: + void dump_config() override; bool gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override; void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override; diff --git a/esphome/components/esp32_ble_client/ble_client_base.cpp b/esphome/components/esp32_ble_client/ble_client_base.cpp index 98e7792792..53c430350c 100644 --- a/esphome/components/esp32_ble_client/ble_client_base.cpp +++ b/esphome/components/esp32_ble_client/ble_client_base.cpp @@ -44,6 +44,50 @@ void BLEClientBase::loop() { float BLEClientBase::get_setup_priority() const { return setup_priority::AFTER_BLUETOOTH; } +void BLEClientBase::dump_config() { + ESP_LOGCONFIG(TAG, " Address: %s", this->address_str().c_str()); + ESP_LOGCONFIG(TAG, " Auto-Connect: %s", TRUEFALSE(this->auto_connect_)); + std::string state_name; + switch (this->state()) { + case espbt::ClientState::INIT: + state_name = "INIT"; + break; + case espbt::ClientState::DISCONNECTING: + state_name = "DISCONNECTING"; + break; + case espbt::ClientState::IDLE: + state_name = "IDLE"; + break; + case espbt::ClientState::SEARCHING: + state_name = "SEARCHING"; + break; + case espbt::ClientState::DISCOVERED: + state_name = "DISCOVERED"; + break; + case espbt::ClientState::READY_TO_CONNECT: + state_name = "READY_TO_CONNECT"; + break; + case espbt::ClientState::CONNECTING: + state_name = "CONNECTING"; + break; + case espbt::ClientState::CONNECTED: + state_name = "CONNECTED"; + break; + case espbt::ClientState::ESTABLISHED: + state_name = "ESTABLISHED"; + break; + default: + state_name = "UNKNOWN_STATE"; + break; + } + ESP_LOGCONFIG(TAG, " State: %s", state_name.c_str()); + if (this->status_ == ESP_GATT_NO_RESOURCES) { + ESP_LOGE(TAG, " Failed due to no resources. Try to reduce number of BLE clients in config."); + } else if (this->status_ != ESP_GATT_OK) { + ESP_LOGW(TAG, " Failed due to error code %d", this->status_); + } +} + bool BLEClientBase::parse_device(const espbt::ESPBTDevice &device) { if (!this->auto_connect_) return false; @@ -129,6 +173,8 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_ } else { ESP_LOGE(TAG, "[%d] [%s] gattc app registration failed id=%d code=%d", this->connection_index_, this->address_str_.c_str(), param->reg.app_id, param->reg.status); + this->status_ = param->reg.status; + this->mark_failed(); } break; } diff --git a/esphome/components/esp32_ble_client/ble_client_base.h b/esphome/components/esp32_ble_client/ble_client_base.h index fca66c0b3c..84c35c4633 100644 --- a/esphome/components/esp32_ble_client/ble_client_base.h +++ b/esphome/components/esp32_ble_client/ble_client_base.h @@ -26,6 +26,7 @@ class BLEClientBase : public espbt::ESPBTClient, public Component { void setup() override; void loop() override; float get_setup_priority() const override; + void dump_config() override; void run_later(std::function &&f); // NOLINT bool parse_device(const espbt::ESPBTDevice &device) override; @@ -103,6 +104,7 @@ class BLEClientBase : public espbt::ESPBTClient, public Component { bool paired_{false}; espbt::ConnectionType connection_type_{espbt::ConnectionType::V1}; std::vector services_; + esp_gatt_status_t status_{ESP_GATT_OK}; void log_event_(const char *name); }; diff --git a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp index 6d051e3d4a..5fff9dbcad 100644 --- a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +++ b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp @@ -58,7 +58,6 @@ void ESP32BLETracker::setup() { global_esp32_ble_tracker = this; this->scan_result_lock_ = xSemaphoreCreateMutex(); this->scan_end_lock_ = xSemaphoreCreateMutex(); - this->scanner_idle_ = true; #ifdef USE_OTA ota::get_global_ota_callback()->add_on_state_callback( @@ -107,6 +106,15 @@ void ESP32BLETracker::loop() { break; } } + if (connecting != connecting_ || discovered != discovered_ || searching != searching_ || + disconnecting != disconnecting_) { + connecting_ = connecting; + discovered_ = discovered; + searching_ = searching; + disconnecting_ = disconnecting; + ESP_LOGD(TAG, "connecting: %d, discovered: %d, searching: %d, disconnecting: %d", connecting_, discovered_, + searching_, disconnecting_); + } bool promote_to_connecting = discovered && !searching && !connecting; if (!this->scanner_idle_) { @@ -183,8 +191,9 @@ void ESP32BLETracker::loop() { } if (this->scan_start_failed_ || this->scan_set_param_failed_) { - if (this->scan_start_fail_count_ == 255) { - ESP_LOGE(TAG, "ESP-IDF BLE scan could not restart after 255 attempts, rebooting to restore BLE stack..."); + if (this->scan_start_fail_count_ == std::numeric_limits::max()) { + ESP_LOGE(TAG, "ESP-IDF BLE scan could not restart after %d attempts, rebooting to restore BLE stack...", + std::numeric_limits::max()); App.reboot(); } if (xSemaphoreTake(this->scan_end_lock_, 0L)) { @@ -282,6 +291,12 @@ void ESP32BLETracker::start_scan_(bool first) { this->scan_params_.scan_interval = this->scan_interval_; this->scan_params_.scan_window = this->scan_window_; + // Start timeout before scan is started. Otherwise scan never starts if any error. + this->set_timeout("scan", this->scan_duration_ * 2000, []() { + ESP_LOGE(TAG, "ESP-IDF BLE scan never terminated, rebooting to restore BLE stack..."); + App.reboot(); + }); + esp_err_t err = esp_ble_gap_set_scan_params(&this->scan_params_); if (err != ESP_OK) { ESP_LOGE(TAG, "esp_ble_gap_set_scan_params failed: %d", err); @@ -293,11 +308,6 @@ void ESP32BLETracker::start_scan_(bool first) { return; } this->scanner_idle_ = false; - - this->set_timeout("scan", this->scan_duration_ * 2000, []() { - ESP_LOGE(TAG, "ESP-IDF BLE scan never terminated, rebooting to restore BLE stack..."); - App.reboot(); - }); } void ESP32BLETracker::end_of_scan_() { @@ -371,6 +381,7 @@ void ESP32BLETracker::gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_ga } void ESP32BLETracker::gap_scan_set_param_complete_(const esp_ble_gap_cb_param_t::ble_scan_param_cmpl_evt_param ¶m) { + ESP_LOGV(TAG, "gap_scan_set_param_complete - status %d", param.status); if (param.status == ESP_BT_STATUS_DONE) { this->scan_set_param_failed_ = ESP_BT_STATUS_SUCCESS; } else { @@ -379,20 +390,25 @@ void ESP32BLETracker::gap_scan_set_param_complete_(const esp_ble_gap_cb_param_t: } void ESP32BLETracker::gap_scan_start_complete_(const esp_ble_gap_cb_param_t::ble_scan_start_cmpl_evt_param ¶m) { + ESP_LOGV(TAG, "gap_scan_start_complete - status %d", param.status); this->scan_start_failed_ = param.status; if (param.status == ESP_BT_STATUS_SUCCESS) { this->scan_start_fail_count_ = 0; } else { - this->scan_start_fail_count_++; + if (this->scan_start_fail_count_ != std::numeric_limits::max()) { + this->scan_start_fail_count_++; + } xSemaphoreGive(this->scan_end_lock_); } } void ESP32BLETracker::gap_scan_stop_complete_(const esp_ble_gap_cb_param_t::ble_scan_stop_cmpl_evt_param ¶m) { + ESP_LOGV(TAG, "gap_scan_stop_complete - status %d", param.status); xSemaphoreGive(this->scan_end_lock_); } void ESP32BLETracker::gap_scan_result_(const esp_ble_gap_cb_param_t::ble_scan_result_evt_param ¶m) { + ESP_LOGV(TAG, "gap_scan_result - event %d", param.search_evt); if (param.search_evt == ESP_GAP_SEARCH_INQ_RES_EVT) { if (xSemaphoreTake(this->scan_result_lock_, 0L)) { if (this->scan_result_index_ < ESP32BLETracker::SCAN_RESULT_BUFFER_SIZE) { @@ -663,7 +679,14 @@ void ESP32BLETracker::dump_config() { ESP_LOGCONFIG(TAG, " Scan Interval: %.1f ms", this->scan_interval_ * 0.625f); ESP_LOGCONFIG(TAG, " Scan Window: %.1f ms", this->scan_window_ * 0.625f); ESP_LOGCONFIG(TAG, " Scan Type: %s", this->scan_active_ ? "ACTIVE" : "PASSIVE"); - ESP_LOGCONFIG(TAG, " Continuous Scanning: %s", this->scan_continuous_ ? "True" : "False"); + ESP_LOGCONFIG(TAG, " Continuous Scanning: %s", YESNO(this->scan_continuous_)); + ESP_LOGCONFIG(TAG, " Scanner Idle: %s", YESNO(this->scanner_idle_)); + ESP_LOGCONFIG(TAG, " Scan End: %s", YESNO(xSemaphoreGetMutexHolder(this->scan_end_lock_) == nullptr)); + ESP_LOGCONFIG(TAG, " Connecting: %d, discovered: %d, searching: %d, disconnecting: %d", connecting_, discovered_, + searching_, disconnecting_); + if (this->scan_start_fail_count_) { + ESP_LOGCONFIG(TAG, " Scan Start Fail Count: %d", this->scan_start_fail_count_); + } } void ESP32BLETracker::print_bt_device_info(const ESPBTDevice &device) { diff --git a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.h b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.h index 2fc5da829d..52b091619e 100644 --- a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +++ b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.h @@ -178,7 +178,7 @@ class ESPBTClient : public ESPBTDeviceListener { int app_id; protected: - ClientState state_; + ClientState state_{ClientState::INIT}; }; class ESP32BLETracker : public Component, @@ -229,7 +229,7 @@ class ESP32BLETracker : public Component, /// Called when a `ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT` event is received. void gap_scan_stop_complete_(const esp_ble_gap_cb_param_t::ble_scan_stop_cmpl_evt_param ¶m); - int app_id_; + int app_id_{0}; /// Vector of addresses that have already been printed in print_bt_device_info std::vector already_discovered_; @@ -242,10 +242,10 @@ class ESP32BLETracker : public Component, uint32_t scan_duration_; uint32_t scan_interval_; uint32_t scan_window_; - uint8_t scan_start_fail_count_; + uint8_t scan_start_fail_count_{0}; bool scan_continuous_; bool scan_active_; - bool scanner_idle_; + bool scanner_idle_{true}; bool ble_was_disabled_{true}; bool raw_advertisements_{false}; bool parse_advertisements_{false}; @@ -260,6 +260,10 @@ class ESP32BLETracker : public Component, esp_ble_gap_cb_param_t::ble_scan_result_evt_param *scan_result_buffer_; esp_bt_status_t scan_start_failed_{ESP_BT_STATUS_SUCCESS}; esp_bt_status_t scan_set_param_failed_{ESP_BT_STATUS_SUCCESS}; + int connecting_{0}; + int discovered_{0}; + int searching_{0}; + int disconnecting_{0}; }; // NOLINTNEXTLINE From 387bde665e3ae5d4b8d5a68299abd6032c4291b8 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Tue, 24 Dec 2024 04:15:40 -0500 Subject: [PATCH 032/194] [esp32_rmt] IDF 5+ update fixes (#8002) Co-authored-by: Jonathan Swoboda Co-authored-by: Keith Burzinski --- .../remote_receiver/remote_receiver_esp32.cpp | 8 ++--- .../components/remote_transmitter/__init__.py | 9 +++++ .../remote_transmitter/remote_transmitter.h | 3 ++ .../remote_transmitter_esp32.cpp | 34 ++++++++++++++++--- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/esphome/components/remote_receiver/remote_receiver_esp32.cpp b/esphome/components/remote_receiver/remote_receiver_esp32.cpp index 48b84d61d4..8a36971e36 100644 --- a/esphome/components/remote_receiver/remote_receiver_esp32.cpp +++ b/esphome/components/remote_receiver/remote_receiver_esp32.cpp @@ -154,16 +154,16 @@ void RemoteReceiverComponent::setup() { void RemoteReceiverComponent::dump_config() { ESP_LOGCONFIG(TAG, "Remote Receiver:"); LOG_PIN(" Pin: ", this->pin_); - if (this->pin_->digital_read()) { - ESP_LOGW(TAG, "Remote Receiver Signal starts with a HIGH value. Usually this means you have to " - "invert the signal using 'inverted: True' in the pin schema!"); - } #if ESP_IDF_VERSION_MAJOR >= 5 ESP_LOGCONFIG(TAG, " Clock resolution: %" PRIu32 " hz", this->clock_resolution_); ESP_LOGCONFIG(TAG, " RMT symbols: %" PRIu32, this->rmt_symbols_); ESP_LOGCONFIG(TAG, " Filter symbols: %" PRIu32, this->filter_symbols_); ESP_LOGCONFIG(TAG, " Receive symbols: %" PRIu32, this->receive_symbols_); #else + if (this->pin_->digital_read()) { + ESP_LOGW(TAG, "Remote Receiver Signal starts with a HIGH value. Usually this means you have to " + "invert the signal using 'inverted: True' in the pin schema!"); + } ESP_LOGCONFIG(TAG, " Channel: %d", this->channel_); ESP_LOGCONFIG(TAG, " RMT memory blocks: %d", this->mem_block_num_); ESP_LOGCONFIG(TAG, " Clock divider: %u", this->clock_divider_); diff --git a/esphome/components/remote_transmitter/__init__.py b/esphome/components/remote_transmitter/__init__.py index ea29751671..e3462fb246 100644 --- a/esphome/components/remote_transmitter/__init__.py +++ b/esphome/components/remote_transmitter/__init__.py @@ -7,6 +7,7 @@ from esphome.const import ( CONF_CLOCK_DIVIDER, CONF_CLOCK_RESOLUTION, CONF_ID, + CONF_INVERTED, CONF_PIN, CONF_RMT_CHANNEL, CONF_RMT_SYMBOLS, @@ -16,6 +17,7 @@ from esphome.core import CORE AUTO_LOAD = ["remote_base"] +CONF_EOT_LEVEL = "eot_level" CONF_ON_TRANSMIT = "on_transmit" CONF_ON_COMPLETE = "on_complete" CONF_ONE_WIRE = "one_wire" @@ -41,6 +43,7 @@ CONFIG_SCHEMA = cv.Schema( cv.Optional(CONF_CLOCK_DIVIDER): cv.All( cv.only_on_esp32, cv.only_with_arduino, cv.int_range(min=1, max=255) ), + cv.Optional(CONF_EOT_LEVEL): cv.All(cv.only_with_esp_idf, cv.boolean), cv.Optional(CONF_ONE_WIRE): cv.All(cv.only_with_esp_idf, cv.boolean), cv.Optional(CONF_USE_DMA): cv.All(cv.only_with_esp_idf, cv.boolean), cv.SplitDefault( @@ -73,6 +76,12 @@ async def to_code(config): cg.add(var.set_with_dma(config[CONF_USE_DMA])) if CONF_ONE_WIRE in config: cg.add(var.set_one_wire(config[CONF_ONE_WIRE])) + if CONF_EOT_LEVEL in config: + cg.add(var.set_eot_level(config[CONF_EOT_LEVEL])) + elif CONF_ONE_WIRE in config and config[CONF_ONE_WIRE]: + cg.add(var.set_eot_level(True)) + elif CONF_INVERTED in config[CONF_PIN] and config[CONF_PIN][CONF_INVERTED]: + cg.add(var.set_eot_level(True)) else: if (rmt_channel := config.get(CONF_RMT_CHANNEL, None)) is not None: var = cg.new_Pvariable(config[CONF_ID], pin, rmt_channel) diff --git a/esphome/components/remote_transmitter/remote_transmitter.h b/esphome/components/remote_transmitter/remote_transmitter.h index 20b98d5488..fd1d182063 100644 --- a/esphome/components/remote_transmitter/remote_transmitter.h +++ b/esphome/components/remote_transmitter/remote_transmitter.h @@ -41,6 +41,8 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase, #if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5 void set_with_dma(bool with_dma) { this->with_dma_ = with_dma; } void set_one_wire(bool one_wire) { this->one_wire_ = one_wire; } + void set_eot_level(bool eot_level) { this->eot_level_ = eot_level; } + void digital_write(bool value); #endif Trigger<> *get_transmit_trigger() const { return this->transmit_trigger_; }; @@ -68,6 +70,7 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase, std::vector rmt_temp_; bool with_dma_{false}; bool one_wire_{false}; + bool eot_level_{false}; rmt_channel_handle_t channel_{NULL}; rmt_encoder_handle_t encoder_{NULL}; #else diff --git a/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp b/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp index efb1735bfd..cd7f366373 100644 --- a/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp +++ b/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp @@ -11,6 +11,7 @@ static const char *const TAG = "remote_transmitter"; void RemoteTransmitterComponent::setup() { ESP_LOGCONFIG(TAG, "Setting up Remote Transmitter..."); + this->inverted_ = this->pin_->is_inverted(); this->configure_rmt_(); } @@ -37,6 +38,31 @@ void RemoteTransmitterComponent::dump_config() { } } +#if ESP_IDF_VERSION_MAJOR >= 5 +void RemoteTransmitterComponent::digital_write(bool value) { + rmt_symbol_word_t symbol = { + .duration0 = 1, + .level0 = value, + .duration1 = 0, + .level1 = value, + }; + rmt_transmit_config_t config; + memset(&config, 0, sizeof(config)); + config.loop_count = 0; + config.flags.eot_level = value; + esp_err_t error = rmt_transmit(this->channel_, this->encoder_, &symbol, sizeof(symbol), &config); + if (error != ESP_OK) { + ESP_LOGW(TAG, "rmt_transmit failed: %s", esp_err_to_name(error)); + this->status_set_warning(); + } + error = rmt_tx_wait_all_done(this->channel_, -1); + if (error != ESP_OK) { + ESP_LOGW(TAG, "rmt_tx_wait_all_done failed: %s", esp_err_to_name(error)); + this->status_set_warning(); + } +} +#endif + void RemoteTransmitterComponent::configure_rmt_() { #if ESP_IDF_VERSION_MAJOR >= 5 esp_err_t error; @@ -83,6 +109,7 @@ void RemoteTransmitterComponent::configure_rmt_() { this->mark_failed(); return; } + this->digital_write(this->one_wire_ || this->inverted_); this->initialized_ = true; } @@ -120,13 +147,12 @@ void RemoteTransmitterComponent::configure_rmt_() { } c.tx_config.idle_output_en = true; - if (!this->pin_->is_inverted()) { + if (!this->inverted_) { c.tx_config.carrier_level = RMT_CARRIER_LEVEL_HIGH; c.tx_config.idle_level = RMT_IDLE_LEVEL_LOW; } else { c.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW; c.tx_config.idle_level = RMT_IDLE_LEVEL_HIGH; - this->inverted_ = true; } esp_err_t error = rmt_config(&c); @@ -210,7 +236,7 @@ void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t sen rmt_transmit_config_t config; memset(&config, 0, sizeof(config)); config.loop_count = 0; - config.flags.eot_level = this->inverted_; + config.flags.eot_level = this->eot_level_; esp_err_t error = rmt_transmit(this->channel_, this->encoder_, this->rmt_temp_.data(), this->rmt_temp_.size() * sizeof(rmt_symbol_word_t), &config); if (error != ESP_OK) { @@ -223,8 +249,6 @@ void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t sen if (error != ESP_OK) { ESP_LOGW(TAG, "rmt_tx_wait_all_done failed: %s", esp_err_to_name(error)); this->status_set_warning(); - } else { - this->status_clear_warning(); } if (i + 1 < send_times) delayMicroseconds(send_wait); From dc5b4087486c8d707c7b89379c7bf8bdd367c86a Mon Sep 17 00:00:00 2001 From: Peter Zich Date: Sun, 5 Jan 2025 17:50:35 -0800 Subject: [PATCH 033/194] Initialize esp32_rmt_led_strip buffer (#8036) --- esphome/components/esp32_rmt_led_strip/led_strip.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/esphome/components/esp32_rmt_led_strip/led_strip.cpp b/esphome/components/esp32_rmt_led_strip/led_strip.cpp index 8ee890ec10..4e8c862c23 100644 --- a/esphome/components/esp32_rmt_led_strip/led_strip.cpp +++ b/esphome/components/esp32_rmt_led_strip/led_strip.cpp @@ -33,6 +33,7 @@ void ESP32RMTLEDStripLightOutput::setup() { this->mark_failed(); return; } + memset(this->buf_, 0, buffer_size); this->effect_data_ = allocator.allocate(this->num_leds_); if (this->effect_data_ == nullptr) { From a0615a92f0124b4ee863e8d0f95f39d49c0d2a6e Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 9 Jan 2025 07:25:10 +1100 Subject: [PATCH 034/194] [addressable_light] Remove rmt channel from idf tests (#7987) --- tests/components/addressable_light/test.esp32-c3-idf.yaml | 1 - tests/components/addressable_light/test.esp32-idf.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/components/addressable_light/test.esp32-c3-idf.yaml b/tests/components/addressable_light/test.esp32-c3-idf.yaml index f587113fac..7b3516345d 100644 --- a/tests/components/addressable_light/test.esp32-c3-idf.yaml +++ b/tests/components/addressable_light/test.esp32-c3-idf.yaml @@ -6,7 +6,6 @@ light: rgb_order: GRB num_leds: 256 pin: 2 - rmt_channel: 0 display: - platform: addressable_light diff --git a/tests/components/addressable_light/test.esp32-idf.yaml b/tests/components/addressable_light/test.esp32-idf.yaml index f587113fac..7b3516345d 100644 --- a/tests/components/addressable_light/test.esp32-idf.yaml +++ b/tests/components/addressable_light/test.esp32-idf.yaml @@ -6,7 +6,6 @@ light: rgb_order: GRB num_leds: 256 pin: 2 - rmt_channel: 0 display: - platform: addressable_light From 5e72b7196bee468a75a3b8b9cb6312de0eb2f04e Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 9 Jan 2025 08:14:08 +1100 Subject: [PATCH 035/194] Remove rmt channel from idf tests (#8054) --- tests/components/e131/test.esp32-c3-idf.yaml | 1 - tests/components/e131/test.esp32-idf.yaml | 1 - tests/components/partition/test.esp32-c3-idf.yaml | 1 - tests/components/partition/test.esp32-idf.yaml | 1 - 4 files changed, 4 deletions(-) diff --git a/tests/components/e131/test.esp32-c3-idf.yaml b/tests/components/e131/test.esp32-c3-idf.yaml index 25304cd3b4..a27e62c1fb 100644 --- a/tests/components/e131/test.esp32-c3-idf.yaml +++ b/tests/components/e131/test.esp32-c3-idf.yaml @@ -12,7 +12,6 @@ light: rgb_order: GRB num_leds: 256 pin: 2 - rmt_channel: 0 effects: - e131: universe: 1 diff --git a/tests/components/e131/test.esp32-idf.yaml b/tests/components/e131/test.esp32-idf.yaml index 25304cd3b4..a27e62c1fb 100644 --- a/tests/components/e131/test.esp32-idf.yaml +++ b/tests/components/e131/test.esp32-idf.yaml @@ -12,7 +12,6 @@ light: rgb_order: GRB num_leds: 256 pin: 2 - rmt_channel: 0 effects: - e131: universe: 1 diff --git a/tests/components/partition/test.esp32-c3-idf.yaml b/tests/components/partition/test.esp32-c3-idf.yaml index 77cfc5ad44..397e1b0642 100644 --- a/tests/components/partition/test.esp32-c3-idf.yaml +++ b/tests/components/partition/test.esp32-c3-idf.yaml @@ -6,7 +6,6 @@ light: rgb_order: GRB num_leds: 256 pin: 2 - rmt_channel: 0 - platform: partition name: Partition Light segments: diff --git a/tests/components/partition/test.esp32-idf.yaml b/tests/components/partition/test.esp32-idf.yaml index 77cfc5ad44..397e1b0642 100644 --- a/tests/components/partition/test.esp32-idf.yaml +++ b/tests/components/partition/test.esp32-idf.yaml @@ -6,7 +6,6 @@ light: rgb_order: GRB num_leds: 256 pin: 2 - rmt_channel: 0 - platform: partition name: Partition Light segments: From 78543e1e159c7043ce51336924747e6067125e10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samu=20N=C3=A9meth?= Date: Wed, 8 Jan 2025 23:37:52 +0100 Subject: [PATCH 036/194] Fixed comment typo in light_color_values.h (#8050) Co-authored-by: Keith Burzinski --- esphome/components/light/light_color_values.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/light/light_color_values.h b/esphome/components/light/light_color_values.h index bad180ce6d..ca32b9c571 100644 --- a/esphome/components/light/light_color_values.h +++ b/esphome/components/light/light_color_values.h @@ -36,7 +36,7 @@ inline static uint8_t to_uint8_scale(float x) { return static_cast(roun * range as set in the traits, so the output needs to do this. * * For COLD_WARM_WHITE capability: - * - cold_white, warm_white: The brightness of the cald and warm white channels of the light. + * - cold_white, warm_white: The brightness of the light's cold and warm white channels. * * All values (except color temperature) are represented using floats in the range 0.0 (off) to 1.0 (on), and are * automatically clamped to this range. Properties not used in the current color mode can still have (invalid) values From a498fb5dcfa3d5999f87817d2b728dbb4972aad9 Mon Sep 17 00:00:00 2001 From: Peter Zich Date: Wed, 8 Jan 2025 22:47:30 -0800 Subject: [PATCH 037/194] Fix braceless else statements (#7799) --- esphome/components/climate_ir/climate_ir.cpp | 3 +- esphome/components/coolix/coolix.cpp | 3 +- .../dfrobot_sen0395/dfrobot_sen0395.cpp | 3 +- esphome/components/dht/dht.cpp | 3 +- esphome/components/display/display.cpp | 3 +- esphome/components/display/rect.cpp | 3 +- .../esp32_improv/esp32_improv_component.cpp | 2 +- esphome/components/gcja5/gcja5.cpp | 3 +- esphome/components/haier/haier_base.cpp | 3 +- esphome/components/haier/hon_climate.cpp | 3 +- esphome/components/heatpumpir/heatpumpir.cpp | 3 +- .../microphone/i2s_audio_microphone.cpp | 12 ++++---- .../micronova/switch/micronova_switch.cpp | 6 ++-- esphome/components/toshiba/toshiba.cpp | 3 +- esphome/components/tuya/light/tuya_light.cpp | 6 ++-- esphome/components/yashima/yashima.cpp | 3 +- esphome/core/helpers.cpp | 28 ++++++++++--------- 17 files changed, 55 insertions(+), 35 deletions(-) diff --git a/esphome/components/climate_ir/climate_ir.cpp b/esphome/components/climate_ir/climate_ir.cpp index 76adfb42bb..8175383627 100644 --- a/esphome/components/climate_ir/climate_ir.cpp +++ b/esphome/components/climate_ir/climate_ir.cpp @@ -37,8 +37,9 @@ void ClimateIR::setup() { this->publish_state(); }); this->current_temperature = this->sensor_->state; - } else + } else { this->current_temperature = NAN; + } // restore set points auto restore = this->restore_state_(); if (restore.has_value()) { diff --git a/esphome/components/coolix/coolix.cpp b/esphome/components/coolix/coolix.cpp index 22b3431c3e..5c6bfd7740 100644 --- a/esphome/components/coolix/coolix.cpp +++ b/esphome/components/coolix/coolix.cpp @@ -131,8 +131,9 @@ bool CoolixClimate::on_coolix(climate::Climate *parent, remote_base::RemoteRecei } else { parent->mode = climate::CLIMATE_MODE_FAN_ONLY; } - } else + } else { parent->mode = climate::CLIMATE_MODE_COOL; + } // Fan Speed if ((remote_state & COOLIX_FAN_AUTO) == COOLIX_FAN_AUTO || parent->mode == climate::CLIMATE_MODE_HEAT_COOL || diff --git a/esphome/components/dfrobot_sen0395/dfrobot_sen0395.cpp b/esphome/components/dfrobot_sen0395/dfrobot_sen0395.cpp index f8ef6c7138..f47025698b 100644 --- a/esphome/components/dfrobot_sen0395/dfrobot_sen0395.cpp +++ b/esphome/components/dfrobot_sen0395/dfrobot_sen0395.cpp @@ -118,8 +118,9 @@ std::unique_ptr CircularCommandQueue::dequeue() { if (front_ == rear_) { front_ = -1; rear_ = -1; - } else + } else { front_ = (front_ + 1) % COMMAND_QUEUE_SIZE; + } return dequeued_cmd; } diff --git a/esphome/components/dht/dht.cpp b/esphome/components/dht/dht.cpp index 3f9f9c57f4..5a18f6f36e 100644 --- a/esphome/components/dht/dht.cpp +++ b/esphome/components/dht/dht.cpp @@ -157,8 +157,9 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r if (bit == 0) { bit = 7; byte++; - } else + } else { bit--; + } } } if (!report_errors && error_code != 0) diff --git a/esphome/components/display/display.cpp b/esphome/components/display/display.cpp index f00c2936a8..202c64ef14 100644 --- a/esphome/components/display/display.cpp +++ b/esphome/components/display/display.cpp @@ -266,8 +266,9 @@ void Display::filled_gauge(int center_x, int center_y, int radius1, int radius2, if (dymax < float(-dxmax) * tan_a) { upd_dxmax = ceil(float(dymax) / tan_a); hline_width = -dxmax - upd_dxmax + 1; - } else + } else { hline_width = 0; + } } if (hline_width > 0) this->horizontal_line(center_x + dxmax, center_y - dymax, hline_width, color); diff --git a/esphome/components/display/rect.cpp b/esphome/components/display/rect.cpp index 34b611191f..49bb7d025f 100644 --- a/esphome/components/display/rect.cpp +++ b/esphome/components/display/rect.cpp @@ -90,8 +90,9 @@ void Rect::info(const std::string &prefix) { if (this->is_set()) { ESP_LOGI(TAG, "%s [%3d,%3d,%3d,%3d] (%3d,%3d)", prefix.c_str(), this->x, this->y, this->w, this->h, this->x2(), this->y2()); - } else + } else { ESP_LOGI(TAG, "%s ** IS NOT SET **", prefix.c_str()); + } } } // namespace display diff --git a/esphome/components/esp32_improv/esp32_improv_component.cpp b/esphome/components/esp32_improv/esp32_improv_component.cpp index d36b50feb0..c67431077c 100644 --- a/esphome/components/esp32_improv/esp32_improv_component.cpp +++ b/esphome/components/esp32_improv/esp32_improv_component.cpp @@ -112,7 +112,7 @@ void ESP32ImprovComponent::loop() { this->set_state_(improv::STATE_AUTHORIZED); } else #else - this->set_state_(improv::STATE_AUTHORIZED); + { this->set_state_(improv::STATE_AUTHORIZED); } #endif { if (!this->check_identify_()) diff --git a/esphome/components/gcja5/gcja5.cpp b/esphome/components/gcja5/gcja5.cpp index 7f980ca0ad..b1db58654b 100644 --- a/esphome/components/gcja5/gcja5.cpp +++ b/esphome/components/gcja5/gcja5.cpp @@ -97,8 +97,9 @@ void GCJA5Component::parse_data_() { if (this->rx_message_[0] != 0x02 || this->rx_message_[31] != 0x03 || !this->calculate_checksum_()) { ESP_LOGVV(TAG, "Discarding bad packet - failed checks."); return; - } else + } else { ESP_LOGVV(TAG, "Good packet found."); + } this->have_good_data_ = true; uint8_t status = this->rx_message_[29]; diff --git a/esphome/components/haier/haier_base.cpp b/esphome/components/haier/haier_base.cpp index ba80c1ca1b..f8c0a7587e 100644 --- a/esphome/components/haier/haier_base.cpp +++ b/esphome/components/haier/haier_base.cpp @@ -342,8 +342,9 @@ bool HaierClimateBase::prepare_pending_action() { this->action_request_.reset(); return false; } - } else + } else { return false; + } } ClimateTraits HaierClimateBase::traits() { return traits_; } diff --git a/esphome/components/haier/hon_climate.cpp b/esphome/components/haier/hon_climate.cpp index c95a87223d..9b59dd0c10 100644 --- a/esphome/components/haier/hon_climate.cpp +++ b/esphome/components/haier/hon_climate.cpp @@ -710,8 +710,9 @@ void HonClimate::process_alarm_message_(const uint8_t *packet, uint8_t size, boo alarm_code++; } active_alarms_[i] = packet[2 + i]; - } else + } else { alarm_code += 8; + } } } else { float alarm_count = 0.0f; diff --git a/esphome/components/heatpumpir/heatpumpir.cpp b/esphome/components/heatpumpir/heatpumpir.cpp index 144dcc9bfa..55f0599cba 100644 --- a/esphome/components/heatpumpir/heatpumpir.cpp +++ b/esphome/components/heatpumpir/heatpumpir.cpp @@ -87,8 +87,9 @@ void HeatpumpIRClimate::setup() { this->publish_state(); }); this->current_temperature = this->sensor_->state; - } else + } else { this->current_temperature = NAN; + } } void HeatpumpIRClimate::transmit_state() { diff --git a/esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp b/esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp index 23689afb91..4dbc9dcdac 100644 --- a/esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +++ b/esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp @@ -25,11 +25,13 @@ void I2SAudioMicrophone::setup() { } } else #endif - if (this->pdm_) { - if (this->parent_->get_port() != I2S_NUM_0) { - ESP_LOGE(TAG, "PDM only works on I2S0!"); - this->mark_failed(); - return; + { + if (this->pdm_) { + if (this->parent_->get_port() != I2S_NUM_0) { + ESP_LOGE(TAG, "PDM only works on I2S0!"); + this->mark_failed(); + return; + } } } } diff --git a/esphome/components/micronova/switch/micronova_switch.cpp b/esphome/components/micronova/switch/micronova_switch.cpp index dcc96102db..28674acd96 100644 --- a/esphome/components/micronova/switch/micronova_switch.cpp +++ b/esphome/components/micronova/switch/micronova_switch.cpp @@ -11,15 +11,17 @@ void MicroNovaSwitch::write_state(bool state) { if (this->micronova_->get_current_stove_state() == 0) { this->micronova_->write_address(this->memory_location_, this->memory_address_, this->memory_data_on_); this->publish_state(true); - } else + } else { ESP_LOGW(TAG, "Unable to turn stove on, invalid state: %d", micronova_->get_current_stove_state()); + } } else { // don't send power-off when status is Off or Final cleaning if (this->micronova_->get_current_stove_state() != 0 && micronova_->get_current_stove_state() != 6) { this->micronova_->write_address(this->memory_location_, this->memory_address_, this->memory_data_off_); this->publish_state(false); - } else + } else { ESP_LOGW(TAG, "Unable to turn stove off, invalid state: %d", micronova_->get_current_stove_state()); + } } this->micronova_->update(); break; diff --git a/esphome/components/toshiba/toshiba.cpp b/esphome/components/toshiba/toshiba.cpp index 33d36d6a69..ff4241a81f 100644 --- a/esphome/components/toshiba/toshiba.cpp +++ b/esphome/components/toshiba/toshiba.cpp @@ -106,8 +106,9 @@ void ToshibaClimate::setup() { this->publish_state(); }); this->current_temperature = this->sensor_->state; - } else + } else { this->current_temperature = NAN; + } // restore set points auto restore = this->restore_state_(); if (restore.has_value()) { diff --git a/esphome/components/tuya/light/tuya_light.cpp b/esphome/components/tuya/light/tuya_light.cpp index 66931767b2..815a089d9f 100644 --- a/esphome/components/tuya/light/tuya_light.cpp +++ b/esphome/components/tuya/light/tuya_light.cpp @@ -120,8 +120,9 @@ light::LightTraits TuyaLight::get_traits() { traits.set_supported_color_modes( {light::ColorMode::RGB_COLOR_TEMPERATURE, light::ColorMode::COLOR_TEMPERATURE}); } - } else + } else { traits.set_supported_color_modes({light::ColorMode::COLOR_TEMPERATURE}); + } traits.set_min_mireds(this->cold_white_temperature_); traits.set_max_mireds(this->warm_white_temperature_); } else if (this->color_id_.has_value()) { @@ -131,8 +132,9 @@ light::LightTraits TuyaLight::get_traits() { } else { traits.set_supported_color_modes({light::ColorMode::RGB_WHITE}); } - } else + } else { traits.set_supported_color_modes({light::ColorMode::RGB}); + } } else if (this->dimmer_id_.has_value()) { traits.set_supported_color_modes({light::ColorMode::BRIGHTNESS}); } else { diff --git a/esphome/components/yashima/yashima.cpp b/esphome/components/yashima/yashima.cpp index 493c689b42..a3cf53ff66 100644 --- a/esphome/components/yashima/yashima.cpp +++ b/esphome/components/yashima/yashima.cpp @@ -104,8 +104,9 @@ void YashimaClimate::setup() { this->publish_state(); }); this->current_temperature = this->sensor_->state; - } else + } else { this->current_temperature = NAN; + } // restore set points auto restore = this->restore_state_(); if (restore.has_value()) { diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index b11615204e..2d2c88b844 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -126,19 +126,21 @@ uint16_t crc16(const uint8_t *data, uint16_t len, uint16_t crc, uint16_t reverse } } else #endif - if (reverse_poly == 0xa001) { - while (len--) { - uint8_t combo = crc ^ (uint8_t) *data++; - crc = (crc >> 8) ^ CRC16_A001_LE_LUT_L[combo & 0x0F] ^ CRC16_A001_LE_LUT_H[combo >> 4]; - } - } else { - while (len--) { - crc ^= *data++; - for (uint8_t i = 0; i < 8; i++) { - if (crc & 0x0001) { - crc = (crc >> 1) ^ reverse_poly; - } else { - crc >>= 1; + { + if (reverse_poly == 0xa001) { + while (len--) { + uint8_t combo = crc ^ (uint8_t) *data++; + crc = (crc >> 8) ^ CRC16_A001_LE_LUT_L[combo & 0x0F] ^ CRC16_A001_LE_LUT_H[combo >> 4]; + } + } else { + while (len--) { + crc ^= *data++; + for (uint8_t i = 0; i < 8; i++) { + if (crc & 0x0001) { + crc = (crc >> 1) ^ reverse_poly; + } else { + crc >>= 1; + } } } } From de603c756500a5fe0dac805d498c3cb870e1b04b Mon Sep 17 00:00:00 2001 From: Jimmy Hedman Date: Fri, 10 Jan 2025 22:10:19 +0100 Subject: [PATCH 038/194] Enable udp to work (on ipv4) when ipv6 is enabled (#8060) Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- esphome/components/udp/udp_component.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/esphome/components/udp/udp_component.cpp b/esphome/components/udp/udp_component.cpp index b8727ec423..e29620fa9a 100644 --- a/esphome/components/udp/udp_component.cpp +++ b/esphome/components/udp/udp_component.cpp @@ -245,13 +245,9 @@ void UDPComponent::setup() { } struct sockaddr_in server {}; - socklen_t sl = socket::set_sockaddr_any((struct sockaddr *) &server, sizeof(server), this->port_); - if (sl == 0) { - ESP_LOGE(TAG, "Socket unable to set sockaddr: errno %d", errno); - this->mark_failed(); - this->status_set_error("Unable to set sockaddr"); - return; - } + server.sin_family = AF_INET; + server.sin_addr.s_addr = ESPHOME_INADDR_ANY; + server.sin_port = htons(this->port_); err = this->listen_socket_->bind((struct sockaddr *) &server, sizeof(server)); if (err != 0) { From 4d7c6b28e1260be7217960ae61b74bc1f903d1ae Mon Sep 17 00:00:00 2001 From: Juan Jose Restrepo <40721479+jotaj91@users.noreply.github.com> Date: Fri, 10 Jan 2025 18:22:30 -0500 Subject: [PATCH 039/194] Update sprinkler.cpp (#7996) --- esphome/components/sprinkler/sprinkler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esphome/components/sprinkler/sprinkler.cpp b/esphome/components/sprinkler/sprinkler.cpp index 5384d29871..3cfb5ccdee 100644 --- a/esphome/components/sprinkler/sprinkler.cpp +++ b/esphome/components/sprinkler/sprinkler.cpp @@ -184,11 +184,13 @@ void SprinklerValveOperator::set_controller(Sprinkler *controller) { void SprinklerValveOperator::set_valve(SprinklerValve *valve) { if (valve != nullptr) { + if (this->state_ != IDLE) { // Only kill if not already idle + this->kill_(); // ensure everything is off before we let go! + } this->state_ = IDLE; // reset state this->run_duration_ = 0; // reset to ensure the valve isn't started without updating it this->start_millis_ = 0; // reset because (new) valve has not been started yet this->stop_millis_ = 0; // reset because (new) valve has not been started yet - this->kill_(); // ensure everything is off before we let go! this->valve_ = valve; // finally, set the pointer to the new valve } } From 4530e4d60fedc3557e2ad52980a1968d0a47ec79 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:40:50 +1100 Subject: [PATCH 040/194] [lvgl] remove default state (#8038) --- esphome/components/lvgl/defines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/lvgl/defines.py b/esphome/components/lvgl/defines.py index 02323f9655..7587c336bb 100644 --- a/esphome/components/lvgl/defines.py +++ b/esphome/components/lvgl/defines.py @@ -215,7 +215,7 @@ LV_LONG_MODES = LvConstant( ) STATES = ( - "default", + # default state not included here "checked", "focused", "focus_key", From 8a98b69a576bf11dd919e990b91b80127db9e486 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:42:03 +1100 Subject: [PATCH 041/194] [lvgl] fix bg_image_src (#8005) Co-authored-by: clydeps --- esphome/components/lvgl/lvgl_esphome.h | 10 ++++++++++ esphome/components/lvgl/widgets/meter.py | 3 ++- esphome/core/defines.h | 1 + tests/components/lvgl/lvgl-package.yaml | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/esphome/components/lvgl/lvgl_esphome.h b/esphome/components/lvgl/lvgl_esphome.h index 56413ad77e..8e89b02db9 100644 --- a/esphome/components/lvgl/lvgl_esphome.h +++ b/esphome/components/lvgl/lvgl_esphome.h @@ -59,6 +59,16 @@ inline void lv_img_set_src(lv_obj_t *obj, esphome::image::Image *image) { inline void lv_disp_set_bg_image(lv_disp_t *disp, esphome::image::Image *image) { lv_disp_set_bg_image(disp, image->get_lv_img_dsc()); } + +inline void lv_obj_set_style_bg_img_src(lv_obj_t *obj, esphome::image::Image *image, lv_style_selector_t selector) { + lv_obj_set_style_bg_img_src(obj, image->get_lv_img_dsc(), selector); +} +#ifdef USE_LVGL_METER +inline lv_meter_indicator_t *lv_meter_add_needle_img(lv_obj_t *obj, lv_meter_scale_t *scale, esphome::image::Image *src, + lv_coord_t pivot_x, lv_coord_t pivot_y) { + return lv_meter_add_needle_img(obj, scale, src->get_lv_img_dsc(), pivot_x, pivot_y); +} +#endif // USE_LVGL_METER #endif // USE_LVGL_IMAGE #ifdef USE_LVGL_ANIMIMG inline void lv_animimg_set_src(lv_obj_t *img, std::vector images) { diff --git a/esphome/components/lvgl/widgets/meter.py b/esphome/components/lvgl/widgets/meter.py index cd61d1c775..29a382f7cf 100644 --- a/esphome/components/lvgl/widgets/meter.py +++ b/esphome/components/lvgl/widgets/meter.py @@ -27,7 +27,7 @@ from ..defines import ( CONF_START_VALUE, CONF_TICKS, ) -from ..helpers import add_lv_use +from ..helpers import add_lv_use, lvgl_components_required from ..lv_validation import ( angle, get_end_value, @@ -182,6 +182,7 @@ class MeterType(WidgetType): async def to_code(self, w: Widget, config): """For a meter object, create and set parameters""" + lvgl_components_required.add(CONF_METER) var = w.obj for scale_conf in config.get(CONF_SCALES, ()): rotation = 90 + (360 - scale_conf[CONF_ANGLE_RANGE]) / 2 diff --git a/esphome/core/defines.h b/esphome/core/defines.h index eb3b20d007..c38a26c6a8 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -49,6 +49,7 @@ #define USE_LVGL_IMAGE #define USE_LVGL_KEY_LISTENER #define USE_LVGL_KEYBOARD +#define USE_LVGL_METER #define USE_LVGL_ROLLER #define USE_LVGL_ROTARY_ENCODER #define USE_LVGL_TOUCHSCREEN diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index b1b89adfe0..68f91884b2 100644 --- a/tests/components/lvgl/lvgl-package.yaml +++ b/tests/components/lvgl/lvgl-package.yaml @@ -132,6 +132,7 @@ lvgl: pages: - id: page1 + bg_image_src: cat_image on_load: - logger.log: page loaded - lvgl.widget.focus: From 0df6a913b3df34c9d6d7229dd802bc22a75db808 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:46:17 +1100 Subject: [PATCH 042/194] [lgvl] disp_bg_image and disp_bg_opa changes (#8025) --- esphome/components/lvgl/automation.py | 16 +++++++++++++--- esphome/components/lvgl/defines.py | 1 + esphome/components/lvgl/schemas.py | 7 +++++-- tests/components/lvgl/lvgl-package.yaml | 3 ++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/esphome/components/lvgl/automation.py b/esphome/components/lvgl/automation.py index c26ae54892..a987cf4097 100644 --- a/esphome/components/lvgl/automation.py +++ b/esphome/components/lvgl/automation.py @@ -10,13 +10,14 @@ from esphome.cpp_types import nullptr from .defines import ( CONF_DISP_BG_COLOR, CONF_DISP_BG_IMAGE, + CONF_DISP_BG_OPA, CONF_EDITING, CONF_FREEZE, CONF_LVGL_ID, CONF_SHOW_SNOW, literal, ) -from .lv_validation import lv_bool, lv_color, lv_image +from .lv_validation import lv_bool, lv_color, lv_image, opacity from .lvcode import ( LVGL_COMP_ARG, UPDATE_EVENT, @@ -119,13 +120,22 @@ async def lvgl_is_idle(config, condition_id, template_arg, args): async def disp_update(disp, config: dict): - if CONF_DISP_BG_COLOR not in config and CONF_DISP_BG_IMAGE not in config: + if ( + CONF_DISP_BG_COLOR not in config + and CONF_DISP_BG_IMAGE not in config + and CONF_DISP_BG_OPA not in config + ): return with LocalVariable("lv_disp_tmp", lv_disp_t, disp) as disp_temp: if (bg_color := config.get(CONF_DISP_BG_COLOR)) is not None: lv.disp_set_bg_color(disp_temp, await lv_color.process(bg_color)) if bg_image := config.get(CONF_DISP_BG_IMAGE): - lv.disp_set_bg_image(disp_temp, await lv_image.process(bg_image)) + if bg_image == "none": + lv.disp_set_bg_image(disp_temp, static_cast("void *", "nullptr")) + else: + lv.disp_set_bg_image(disp_temp, await lv_image.process(bg_image)) + if (bg_opa := config.get(CONF_DISP_BG_OPA)) is not None: + lv.disp_set_bg_opa(disp_temp, await opacity.process(bg_opa)) @automation.register_action( diff --git a/esphome/components/lvgl/defines.py b/esphome/components/lvgl/defines.py index 7587c336bb..733a6bc180 100644 --- a/esphome/components/lvgl/defines.py +++ b/esphome/components/lvgl/defines.py @@ -403,6 +403,7 @@ CONF_COLUMN = "column" CONF_DIGITS = "digits" CONF_DISP_BG_COLOR = "disp_bg_color" CONF_DISP_BG_IMAGE = "disp_bg_image" +CONF_DISP_BG_OPA = "disp_bg_opa" CONF_BODY = "body" CONF_BUTTONS = "buttons" CONF_BYTE_ORDER = "byte_order" diff --git a/esphome/components/lvgl/schemas.py b/esphome/components/lvgl/schemas.py index 3f56b3345f..271dbea19f 100644 --- a/esphome/components/lvgl/schemas.py +++ b/esphome/components/lvgl/schemas.py @@ -19,7 +19,7 @@ from esphome.schema_extractors import SCHEMA_EXTRACT from . import defines as df, lv_validation as lvalid from .defines import CONF_TIME_FORMAT, LV_GRAD_DIR from .helpers import add_lv_use, requires_component, validate_printf -from .lv_validation import lv_color, lv_font, lv_gradient, lv_image +from .lv_validation import lv_color, lv_font, lv_gradient, lv_image, opacity from .lvcode import LvglComponent, lv_event_t_ptr from .types import ( LVEncoderListener, @@ -344,8 +344,11 @@ FLEX_OBJ_SCHEMA = { DISP_BG_SCHEMA = cv.Schema( { - cv.Optional(df.CONF_DISP_BG_IMAGE): lv_image, + cv.Optional(df.CONF_DISP_BG_IMAGE): cv.Any( + cv.one_of("none", lower=True), lv_image + ), cv.Optional(df.CONF_DISP_BG_COLOR): lv_color, + cv.Optional(df.CONF_DISP_BG_OPA): opacity, } ) diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index 68f91884b2..512045d748 100644 --- a/tests/components/lvgl/lvgl-package.yaml +++ b/tests/components/lvgl/lvgl-package.yaml @@ -27,6 +27,7 @@ lvgl: bg_color: light_blue disp_bg_color: color_id disp_bg_image: cat_image + disp_bg_opa: cover theme: obj: border_width: 1 @@ -207,7 +208,7 @@ lvgl: - lvgl.animimg.stop: anim_img - lvgl.update: disp_bg_color: 0xffff00 - disp_bg_image: cat_image + disp_bg_image: none - lvgl.widget.show: message_box - label: text: "Hello shiny day" From f1712cffa8c15037d5f1b23c862c904fac6d7318 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:49:05 +1100 Subject: [PATCH 043/194] [spi_led_strip] Fix priority (#8021) --- esphome/components/spi_led_strip/light.py | 8 +-- .../spi_led_strip/spi_led_strip.cpp | 67 ++++++++++++++++++ .../components/spi_led_strip/spi_led_strip.h | 68 +++---------------- 3 files changed, 78 insertions(+), 65 deletions(-) create mode 100644 esphome/components/spi_led_strip/spi_led_strip.cpp diff --git a/esphome/components/spi_led_strip/light.py b/esphome/components/spi_led_strip/light.py index 78642935de..ca320265a9 100644 --- a/esphome/components/spi_led_strip/light.py +++ b/esphome/components/spi_led_strip/light.py @@ -1,8 +1,7 @@ import esphome.codegen as cg +from esphome.components import light, spi import esphome.config_validation as cv -from esphome.components import light -from esphome.components import spi -from esphome.const import CONF_OUTPUT_ID, CONF_NUM_LEDS +from esphome.const import CONF_NUM_LEDS, CONF_OUTPUT_ID spi_led_strip_ns = cg.esphome_ns.namespace("spi_led_strip") SpiLedStrip = spi_led_strip_ns.class_( @@ -18,8 +17,7 @@ CONFIG_SCHEMA = light.ADDRESSABLE_LIGHT_SCHEMA.extend( async def to_code(config): - var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) - cg.add(var.set_num_leds(config[CONF_NUM_LEDS])) + var = cg.new_Pvariable(config[CONF_OUTPUT_ID], config[CONF_NUM_LEDS]) await light.register_light(var, config) await spi.register_spi_device(var, config) await cg.register_component(var, config) diff --git a/esphome/components/spi_led_strip/spi_led_strip.cpp b/esphome/components/spi_led_strip/spi_led_strip.cpp new file mode 100644 index 0000000000..46243c0686 --- /dev/null +++ b/esphome/components/spi_led_strip/spi_led_strip.cpp @@ -0,0 +1,67 @@ +#include "spi_led_strip.h" + +namespace esphome { +namespace spi_led_strip { + +SpiLedStrip::SpiLedStrip(uint16_t num_leds) { + this->num_leds_ = num_leds; + ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + this->buffer_size_ = num_leds * 4 + 8; + this->buf_ = allocator.allocate(this->buffer_size_); + if (this->buf_ == nullptr) { + ESP_LOGE(TAG, "Failed to allocate buffer of size %u", this->buffer_size_); + return; + } + + this->effect_data_ = allocator.allocate(num_leds); + if (this->effect_data_ == nullptr) { + ESP_LOGE(TAG, "Failed to allocate effect data of size %u", num_leds); + return; + } + memset(this->buf_, 0xFF, this->buffer_size_); + memset(this->buf_, 0, 4); +} +void SpiLedStrip::setup() { + if (this->effect_data_ == nullptr || this->buf_ == nullptr) { + this->mark_failed(); + return; + } + this->spi_setup(); +} +light::LightTraits SpiLedStrip::get_traits() { + auto traits = light::LightTraits(); + traits.set_supported_color_modes({light::ColorMode::RGB}); + return traits; +} +void SpiLedStrip::dump_config() { + esph_log_config(TAG, "SPI LED Strip:"); + esph_log_config(TAG, " LEDs: %d", this->num_leds_); + if (this->data_rate_ >= spi::DATA_RATE_1MHZ) { + esph_log_config(TAG, " Data rate: %uMHz", (unsigned) (this->data_rate_ / 1000000)); + } else { + esph_log_config(TAG, " Data rate: %ukHz", (unsigned) (this->data_rate_ / 1000)); + } +} +void SpiLedStrip::write_state(light::LightState *state) { + if (this->is_failed()) + return; + if (ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE) { + char strbuf[49]; + size_t len = std::min(this->buffer_size_, (size_t) (sizeof(strbuf) - 1) / 3); + memset(strbuf, 0, sizeof(strbuf)); + for (size_t i = 0; i != len; i++) { + sprintf(strbuf + i * 3, "%02X ", this->buf_[i]); + } + esph_log_v(TAG, "write_state: buf = %s", strbuf); + } + this->enable(); + this->write_array(this->buf_, this->buffer_size_); + this->disable(); +} +light::ESPColorView SpiLedStrip::get_view_internal(int32_t index) const { + size_t pos = index * 4 + 5; + return {this->buf_ + pos + 2, this->buf_ + pos + 1, this->buf_ + pos + 0, nullptr, + this->effect_data_ + index, &this->correction_}; +} +} // namespace spi_led_strip +} // namespace esphome diff --git a/esphome/components/spi_led_strip/spi_led_strip.h b/esphome/components/spi_led_strip/spi_led_strip.h index 1b317cdd69..14c5627ac3 100644 --- a/esphome/components/spi_led_strip/spi_led_strip.h +++ b/esphome/components/spi_led_strip/spi_led_strip.h @@ -13,74 +13,22 @@ class SpiLedStrip : public light::AddressableLight, public spi::SPIDevice { public: - void setup() override { this->spi_setup(); } + SpiLedStrip(uint16_t num_leds); + void setup() override; + float get_setup_priority() const override { return setup_priority::IO; } int32_t size() const override { return this->num_leds_; } - light::LightTraits get_traits() override { - auto traits = light::LightTraits(); - traits.set_supported_color_modes({light::ColorMode::RGB}); - return traits; - } - void set_num_leds(uint16_t num_leds) { - this->num_leds_ = num_leds; - ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); - this->buffer_size_ = num_leds * 4 + 8; - this->buf_ = allocator.allocate(this->buffer_size_); - if (this->buf_ == nullptr) { - esph_log_e(TAG, "Failed to allocate buffer of size %u", this->buffer_size_); - this->mark_failed(); - return; - } + light::LightTraits get_traits() override; - this->effect_data_ = allocator.allocate(num_leds); - if (this->effect_data_ == nullptr) { - esph_log_e(TAG, "Failed to allocate effect data of size %u", num_leds); - this->mark_failed(); - return; - } - memset(this->buf_, 0xFF, this->buffer_size_); - memset(this->buf_, 0, 4); - } + void dump_config() override; - void dump_config() override { - esph_log_config(TAG, "SPI LED Strip:"); - esph_log_config(TAG, " LEDs: %d", this->num_leds_); - if (this->data_rate_ >= spi::DATA_RATE_1MHZ) { - esph_log_config(TAG, " Data rate: %uMHz", (unsigned) (this->data_rate_ / 1000000)); - } else { - esph_log_config(TAG, " Data rate: %ukHz", (unsigned) (this->data_rate_ / 1000)); - } - } + void write_state(light::LightState *state) override; - void write_state(light::LightState *state) override { - if (this->is_failed()) - return; - if (ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE) { - char strbuf[49]; - size_t len = std::min(this->buffer_size_, (size_t) (sizeof(strbuf) - 1) / 3); - memset(strbuf, 0, sizeof(strbuf)); - for (size_t i = 0; i != len; i++) { - sprintf(strbuf + i * 3, "%02X ", this->buf_[i]); - } - esph_log_v(TAG, "write_state: buf = %s", strbuf); - } - this->enable(); - this->write_array(this->buf_, this->buffer_size_); - this->disable(); - } - - void clear_effect_data() override { - for (int i = 0; i < this->size(); i++) - this->effect_data_[i] = 0; - } + void clear_effect_data() override { memset(this->effect_data_, 0, this->num_leds_ * sizeof(this->effect_data_[0])); } protected: - light::ESPColorView get_view_internal(int32_t index) const override { - size_t pos = index * 4 + 5; - return {this->buf_ + pos + 2, this->buf_ + pos + 1, this->buf_ + pos + 0, nullptr, - this->effect_data_ + index, &this->correction_}; - } + light::ESPColorView get_view_internal(int32_t index) const override; size_t buffer_size_{}; uint8_t *effect_data_{nullptr}; From bd17ee8e3304b311bfac699ce49e6f16bc91fa1e Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:50:13 +1100 Subject: [PATCH 044/194] [config] Early check for required version (#8000) --- esphome/config.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/esphome/config.py b/esphome/config.py index 7d48569d2d..65e9ac29bc 100644 --- a/esphome/config.py +++ b/esphome/config.py @@ -18,6 +18,7 @@ from esphome.const import ( CONF_ESPHOME, CONF_EXTERNAL_COMPONENTS, CONF_ID, + CONF_MIN_VERSION, CONF_PACKAGES, CONF_PLATFORM, CONF_SUBSTITUTIONS, @@ -839,6 +840,10 @@ def validate_config( # Remove temporary esphome config path again, it will be reloaded later result.remove_output_path([CONF_ESPHOME], CONF_ESPHOME) + # Check version number now to avoid loading components that are not supported + if min_version := config[CONF_ESPHOME].get(CONF_MIN_VERSION): + cv.All(cv.version_number, cv.validate_esphome_version)(min_version) + # First run platform validation steps for key in TARGET_PLATFORMS: if key in config: From 109d737d5d7fbe8d55c2fb3c74179c43e9f8f92a Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:53:26 +1100 Subject: [PATCH 045/194] [lvgl] Implement `lvgl.page.is_showing:` condition (#8055) --- esphome/components/lvgl/automation.py | 15 +++++++-- esphome/components/lvgl/lvgl_esphome.cpp | 3 ++ esphome/components/lvgl/lvgl_esphome.h | 15 ++++++--- esphome/components/lvgl/widgets/page.py | 39 ++++++++++++++++++++++-- tests/components/lvgl/lvgl-package.yaml | 5 +++ 5 files changed, 67 insertions(+), 10 deletions(-) diff --git a/esphome/components/lvgl/automation.py b/esphome/components/lvgl/automation.py index a987cf4097..7db6e1f045 100644 --- a/esphome/components/lvgl/automation.py +++ b/esphome/components/lvgl/automation.py @@ -4,7 +4,7 @@ from esphome import automation import esphome.codegen as cg import esphome.config_validation as cv from esphome.const import CONF_ACTION, CONF_GROUP, CONF_ID, CONF_TIMEOUT -from esphome.cpp_generator import get_variable +from esphome.cpp_generator import TemplateArguments, get_variable from esphome.cpp_types import nullptr from .defines import ( @@ -23,6 +23,7 @@ from .lvcode import ( UPDATE_EVENT, LambdaContext, LocalVariable, + LvglComponent, ReturnStatement, add_line_marks, lv, @@ -93,7 +94,11 @@ async def lvgl_is_paused(config, condition_id, template_arg, args): lvgl = config[CONF_LVGL_ID] async with LambdaContext(LVGL_COMP_ARG, return_type=cg.bool_) as context: lv_add(ReturnStatement(lvgl_comp.is_paused())) - var = cg.new_Pvariable(condition_id, template_arg, await context.get_lambda()) + var = cg.new_Pvariable( + condition_id, + TemplateArguments(LvglComponent, *template_arg), + await context.get_lambda(), + ) await cg.register_parented(var, lvgl) return var @@ -114,7 +119,11 @@ async def lvgl_is_idle(config, condition_id, template_arg, args): timeout = await cg.templatable(config[CONF_TIMEOUT], [], cg.uint32) async with LambdaContext(LVGL_COMP_ARG, return_type=cg.bool_) as context: lv_add(ReturnStatement(lvgl_comp.is_idle(timeout))) - var = cg.new_Pvariable(condition_id, template_arg, await context.get_lambda()) + var = cg.new_Pvariable( + condition_id, + TemplateArguments(LvglComponent, *template_arg), + await context.get_lambda(), + ) await cg.register_parented(var, lvgl) return var diff --git a/esphome/components/lvgl/lvgl_esphome.cpp b/esphome/components/lvgl/lvgl_esphome.cpp index 61bdfe9755..5abeead9d8 100644 --- a/esphome/components/lvgl/lvgl_esphome.cpp +++ b/esphome/components/lvgl/lvgl_esphome.cpp @@ -119,6 +119,7 @@ void LvglComponent::add_event_cb(lv_obj_t *obj, event_callback_t callback, lv_ev } void LvglComponent::add_page(LvPageType *page) { this->pages_.push_back(page); + page->set_parent(this); page->setup(this->pages_.size() - 1); } void LvglComponent::show_page(size_t index, lv_scr_load_anim_t anim, uint32_t time) { @@ -143,6 +144,8 @@ void LvglComponent::show_prev_page(lv_scr_load_anim_t anim, uint32_t time) { } while (this->pages_[this->current_page_]->skip); // skip empty pages() this->show_page(this->current_page_, anim, time); } +size_t LvglComponent::get_current_page() const { return this->current_page_; } +bool LvPageType::is_showing() const { return this->parent_->get_current_page() == this->index; } void LvglComponent::draw_buffer_(const lv_area_t *area, lv_color_t *ptr) { auto width = lv_area_get_width(area); auto height = lv_area_get_height(area); diff --git a/esphome/components/lvgl/lvgl_esphome.h b/esphome/components/lvgl/lvgl_esphome.h index 8e89b02db9..69fa808d53 100644 --- a/esphome/components/lvgl/lvgl_esphome.h +++ b/esphome/components/lvgl/lvgl_esphome.h @@ -94,7 +94,9 @@ class LvCompound { lv_obj_t *obj{}; }; -class LvPageType { +class LvglComponent; + +class LvPageType : public Parented { public: LvPageType(bool skip) : skip(skip) {} @@ -102,6 +104,9 @@ class LvPageType { this->index = index; this->obj = lv_obj_create(nullptr); } + + bool is_showing() const; + lv_obj_t *obj{}; size_t index{}; bool skip; @@ -188,6 +193,7 @@ class LvglComponent : public PollingComponent { void show_next_page(lv_scr_load_anim_t anim, uint32_t time); void show_prev_page(lv_scr_load_anim_t anim, uint32_t time); void set_page_wrap(bool wrap) { this->page_wrap_ = wrap; } + size_t get_current_page() const; void set_focus_mark(lv_group_t *group) { this->focus_marks_[group] = lv_group_get_focused(group); } void restore_focus_mark(lv_group_t *group) { auto *mark = this->focus_marks_[group]; @@ -251,14 +257,13 @@ template class LvglAction : public Action, public Parente std::function action_{}; }; -template class LvglCondition : public Condition, public Parented { +template class LvglCondition : public Condition, public Parented { public: - LvglCondition(std::function &&condition_lambda) - : condition_lambda_(std::move(condition_lambda)) {} + LvglCondition(std::function &&condition_lambda) : condition_lambda_(std::move(condition_lambda)) {} bool check(Ts... x) override { return this->condition_lambda_(this->parent_); } protected: - std::function condition_lambda_{}; + std::function condition_lambda_{}; }; #ifdef USE_LVGL_TOUCHSCREEN diff --git a/esphome/components/lvgl/widgets/page.py b/esphome/components/lvgl/widgets/page.py index a754a9cb9a..23c162e010 100644 --- a/esphome/components/lvgl/widgets/page.py +++ b/esphome/components/lvgl/widgets/page.py @@ -2,6 +2,7 @@ from esphome import automation, codegen as cg from esphome.automation import Trigger import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_PAGES, CONF_TIME, CONF_TRIGGER_ID +from esphome.cpp_generator import MockObj, TemplateArguments from ..defines import ( CONF_ANIMATION, @@ -17,18 +18,28 @@ from ..lvcode import ( EVENT_ARG, LVGL_COMP_ARG, LambdaContext, + ReturnStatement, add_line_marks, lv_add, lvgl_comp, lvgl_static, ) from ..schemas import LVGL_SCHEMA -from ..types import LvglAction, lv_page_t -from . import Widget, WidgetType, add_widgets, get_widgets, set_obj_properties +from ..types import LvglAction, LvglCondition, lv_page_t +from . import ( + Widget, + WidgetType, + add_widgets, + get_widgets, + set_obj_properties, + wait_for_widgets, +) CONF_ON_LOAD = "on_load" CONF_ON_UNLOAD = "on_unload" +PAGE_ARG = "_page" + PAGE_SCHEMA = cv.Schema( { cv.Optional(CONF_SKIP, default=False): lv_bool, @@ -86,6 +97,30 @@ async def page_next_to_code(config, action_id, template_arg, args): return var +@automation.register_condition( + "lvgl.page.is_showing", + LvglCondition, + cv.maybe_simple_value( + cv.Schema({cv.Required(CONF_ID): cv.use_id(lv_page_t)}), + key=CONF_ID, + ), +) +async def page_is_showing_to_code(config, condition_id, template_arg, args): + await wait_for_widgets() + page = await cg.get_variable(config[CONF_ID]) + async with LambdaContext( + [(lv_page_t.operator("ptr"), PAGE_ARG)], return_type=cg.bool_ + ) as context: + lv_add(ReturnStatement(MockObj(PAGE_ARG, "->").is_showing())) + var = cg.new_Pvariable( + condition_id, + TemplateArguments(lv_page_t, *template_arg), + await context.get_lambda(), + ) + await cg.register_parented(var, page) + return var + + @automation.register_action( "lvgl.page.previous", LvglAction, diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index 512045d748..234fd78678 100644 --- a/tests/components/lvgl/lvgl-package.yaml +++ b/tests/components/lvgl/lvgl-package.yaml @@ -138,6 +138,11 @@ lvgl: - logger.log: page loaded - lvgl.widget.focus: action: restore + - if: + condition: + lvgl.page.is_showing: page1 + then: + logger.log: "Yes, page1 showing" on_unload: - logger.log: page unloaded - lvgl.widget.focus: mark From fe80750743e2eeddd1a5631aed30b81c2f252d62 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:56:54 +1100 Subject: [PATCH 046/194] [display] auto_clear_enabled defaults (#7986) --- esphome/components/display/__init__.py | 23 ++++++++++++++++++----- esphome/components/lvgl/__init__.py | 6 +++--- tests/components/lvgl/test.host.yaml | 2 -- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/esphome/components/display/__init__.py b/esphome/components/display/__init__.py index 32a8b3b090..99224df7b3 100644 --- a/esphome/components/display/__init__.py +++ b/esphome/components/display/__init__.py @@ -39,6 +39,7 @@ DisplayOnPageChangeTrigger = display_ns.class_( CONF_ON_PAGE_CHANGE = "on_page_change" CONF_SHOW_TEST_CARD = "show_test_card" +CONF_UNSPECIFIED = "unspecified" DISPLAY_ROTATIONS = { 0: display_ns.DISPLAY_ROTATION_0_DEGREES, @@ -55,16 +56,22 @@ def validate_rotation(value): return cv.enum(DISPLAY_ROTATIONS, int=True)(value) +def validate_auto_clear(value): + if value == CONF_UNSPECIFIED: + return value + return cv.boolean(value) + + BASIC_DISPLAY_SCHEMA = cv.Schema( { - cv.Optional(CONF_LAMBDA): cv.lambda_, + cv.Exclusive(CONF_LAMBDA, CONF_LAMBDA): cv.lambda_, } ).extend(cv.polling_component_schema("1s")) FULL_DISPLAY_SCHEMA = BASIC_DISPLAY_SCHEMA.extend( { cv.Optional(CONF_ROTATION): validate_rotation, - cv.Optional(CONF_PAGES): cv.All( + cv.Exclusive(CONF_PAGES, CONF_LAMBDA): cv.All( cv.ensure_list( { cv.GenerateID(): cv.declare_id(DisplayPage), @@ -82,7 +89,9 @@ FULL_DISPLAY_SCHEMA = BASIC_DISPLAY_SCHEMA.extend( cv.Optional(CONF_TO): cv.use_id(DisplayPage), } ), - cv.Optional(CONF_AUTO_CLEAR_ENABLED, default=True): cv.boolean, + cv.Optional( + CONF_AUTO_CLEAR_ENABLED, default=CONF_UNSPECIFIED + ): validate_auto_clear, cv.Optional(CONF_SHOW_TEST_CARD): cv.boolean, } ) @@ -92,8 +101,12 @@ async def setup_display_core_(var, config): if CONF_ROTATION in config: cg.add(var.set_rotation(DISPLAY_ROTATIONS[config[CONF_ROTATION]])) - if CONF_AUTO_CLEAR_ENABLED in config: - cg.add(var.set_auto_clear(config[CONF_AUTO_CLEAR_ENABLED])) + if auto_clear := config.get(CONF_AUTO_CLEAR_ENABLED): + # Default to true if pages or lambda is specified. Ideally this would be done during validation, but + # the possible schemas are too complex to do this easily. + if auto_clear == CONF_UNSPECIFIED: + auto_clear = CONF_LAMBDA in config or CONF_PAGES in config + cg.add(var.set_auto_clear(auto_clear)) if CONF_PAGES in config: pages = [] diff --git a/esphome/components/lvgl/__init__.py b/esphome/components/lvgl/__init__.py index b858e8df01..c64ffcb5f2 100644 --- a/esphome/components/lvgl/__init__.py +++ b/esphome/components/lvgl/__init__.py @@ -197,11 +197,11 @@ def final_validation(configs): for display_id in config[df.CONF_DISPLAYS]: path = global_config.get_path_for_id(display_id)[:-1] display = global_config.get_config_for_path(path) - if CONF_LAMBDA in display: + if CONF_LAMBDA in display or CONF_PAGES in display: raise cv.Invalid( - "Using lambda: in display config not compatible with LVGL" + "Using lambda: or pages: in display config is not compatible with LVGL" ) - if display[CONF_AUTO_CLEAR_ENABLED]: + if display.get(CONF_AUTO_CLEAR_ENABLED) is True: raise cv.Invalid( "Using auto_clear_enabled: true in display config not compatible with LVGL" ) diff --git a/tests/components/lvgl/test.host.yaml b/tests/components/lvgl/test.host.yaml index 34918cb113..39d9a0ebf3 100644 --- a/tests/components/lvgl/test.host.yaml +++ b/tests/components/lvgl/test.host.yaml @@ -7,7 +7,6 @@ display: height: 320 - platform: sdl id: sdl1 - auto_clear_enabled: false dimensions: width: 480 height: 480 @@ -40,4 +39,3 @@ lvgl: text: Click ME on_click: logger.log: Clicked - From d69926485c6ed33b476aef8994b41ac50b31ece9 Mon Sep 17 00:00:00 2001 From: Jimmy Hedman Date: Sun, 12 Jan 2025 20:12:38 +0100 Subject: [PATCH 047/194] Convert IPAddress to use Pythonmodule ipaddress (#8072) --- esphome/components/ethernet/__init__.py | 20 ++++++------- esphome/components/udp/__init__.py | 2 +- esphome/components/wifi/__init__.py | 12 ++++---- esphome/components/wireguard/__init__.py | 4 +-- esphome/config_validation.py | 33 +++++++++++----------- esphome/core/__init__.py | 10 ------- esphome/yaml_util.py | 4 +-- tests/unit_tests/test_config_validation.py | 30 +++++++++++++++++--- tests/unit_tests/test_core.py | 25 ++-------------- 9 files changed, 65 insertions(+), 75 deletions(-) diff --git a/esphome/components/ethernet/__init__.py b/esphome/components/ethernet/__init__.py index dca37b8dc2..ab760a9b6c 100644 --- a/esphome/components/ethernet/__init__.py +++ b/esphome/components/ethernet/__init__.py @@ -94,11 +94,11 @@ CLK_MODES = { MANUAL_IP_SCHEMA = cv.Schema( { - cv.Required(CONF_STATIC_IP): cv.ipv4, - cv.Required(CONF_GATEWAY): cv.ipv4, - cv.Required(CONF_SUBNET): cv.ipv4, - cv.Optional(CONF_DNS1, default="0.0.0.0"): cv.ipv4, - cv.Optional(CONF_DNS2, default="0.0.0.0"): cv.ipv4, + cv.Required(CONF_STATIC_IP): cv.ipv4address, + cv.Required(CONF_GATEWAY): cv.ipv4address, + cv.Required(CONF_SUBNET): cv.ipv4address, + cv.Optional(CONF_DNS1, default="0.0.0.0"): cv.ipv4address, + cv.Optional(CONF_DNS2, default="0.0.0.0"): cv.ipv4address, } ) @@ -255,11 +255,11 @@ FINAL_VALIDATE_SCHEMA = _final_validate def manual_ip(config): return cg.StructInitializer( ManualIP, - ("static_ip", IPAddress(*config[CONF_STATIC_IP].args)), - ("gateway", IPAddress(*config[CONF_GATEWAY].args)), - ("subnet", IPAddress(*config[CONF_SUBNET].args)), - ("dns1", IPAddress(*config[CONF_DNS1].args)), - ("dns2", IPAddress(*config[CONF_DNS2].args)), + ("static_ip", IPAddress(str(config[CONF_STATIC_IP]))), + ("gateway", IPAddress(str(config[CONF_GATEWAY]))), + ("subnet", IPAddress(str(config[CONF_SUBNET]))), + ("dns1", IPAddress(str(config[CONF_DNS1]))), + ("dns2", IPAddress(str(config[CONF_DNS2]))), ) diff --git a/esphome/components/udp/__init__.py b/esphome/components/udp/__init__.py index ca15be2a80..e189975ade 100644 --- a/esphome/components/udp/__init__.py +++ b/esphome/components/udp/__init__.py @@ -85,7 +85,7 @@ CONFIG_SCHEMA = cv.All( cv.GenerateID(): cv.declare_id(UDPComponent), cv.Optional(CONF_PORT, default=18511): cv.port, cv.Optional(CONF_ADDRESSES, default=["255.255.255.255"]): cv.ensure_list( - cv.ipv4 + cv.ipv4address, ), cv.Optional(CONF_ROLLING_CODE_ENABLE, default=False): cv.boolean, cv.Optional(CONF_PING_PONG_ENABLE, default=False): cv.boolean, diff --git a/esphome/components/wifi/__init__.py b/esphome/components/wifi/__init__.py index ad1a4f5262..582b826de0 100644 --- a/esphome/components/wifi/__init__.py +++ b/esphome/components/wifi/__init__.py @@ -93,16 +93,16 @@ def validate_channel(value): AP_MANUAL_IP_SCHEMA = cv.Schema( { - cv.Required(CONF_STATIC_IP): cv.ipv4, - cv.Required(CONF_GATEWAY): cv.ipv4, - cv.Required(CONF_SUBNET): cv.ipv4, + cv.Required(CONF_STATIC_IP): cv.ipv4address, + cv.Required(CONF_GATEWAY): cv.ipv4address, + cv.Required(CONF_SUBNET): cv.ipv4address, } ) STA_MANUAL_IP_SCHEMA = AP_MANUAL_IP_SCHEMA.extend( { - cv.Optional(CONF_DNS1, default="0.0.0.0"): cv.ipv4, - cv.Optional(CONF_DNS2, default="0.0.0.0"): cv.ipv4, + cv.Optional(CONF_DNS1, default="0.0.0.0"): cv.ipv4address, + cv.Optional(CONF_DNS2, default="0.0.0.0"): cv.ipv4address, } ) @@ -364,7 +364,7 @@ def eap_auth(config): def safe_ip(ip): if ip is None: return IPAddress(0, 0, 0, 0) - return IPAddress(*ip.args) + return IPAddress(str(ip)) def manual_ip(config): diff --git a/esphome/components/wireguard/__init__.py b/esphome/components/wireguard/__init__.py index 5e34a8a19b..fc0e4e0538 100644 --- a/esphome/components/wireguard/__init__.py +++ b/esphome/components/wireguard/__init__.py @@ -67,8 +67,8 @@ CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(): cv.declare_id(Wireguard), cv.GenerateID(CONF_TIME_ID): cv.use_id(time.RealTimeClock), - cv.Required(CONF_ADDRESS): cv.ipv4, - cv.Optional(CONF_NETMASK, default="255.255.255.255"): cv.ipv4, + cv.Required(CONF_ADDRESS): cv.ipv4address, + cv.Optional(CONF_NETMASK, default="255.255.255.255"): cv.ipv4address, cv.Required(CONF_PRIVATE_KEY): _wireguard_key, cv.Required(CONF_PEER_ENDPOINT): cv.string, cv.Required(CONF_PEER_PUBLIC_KEY): _wireguard_key, diff --git a/esphome/config_validation.py b/esphome/config_validation.py index 38fd677a2a..20a0774ccb 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -3,6 +3,7 @@ from contextlib import contextmanager from dataclasses import dataclass from datetime import datetime +from ipaddress import AddressValueError, IPv4Address, ip_address import logging import os import re @@ -67,7 +68,6 @@ from esphome.const import ( from esphome.core import ( CORE, HexInt, - IPAddress, Lambda, TimePeriod, TimePeriodMicroseconds, @@ -1130,7 +1130,7 @@ def domain(value): if re.match(vol.DOMAIN_REGEX, value) is not None: return value try: - return str(ipv4(value)) + return str(ipaddress(value)) except Invalid as err: raise Invalid(f"Invalid domain: {value}") from err @@ -1160,21 +1160,20 @@ def ssid(value): return value -def ipv4(value): - if isinstance(value, list): - parts = value - elif isinstance(value, str): - parts = value.split(".") - elif isinstance(value, IPAddress): - return value - else: - raise Invalid("IPv4 address must consist of either string or integer list") - if len(parts) != 4: - raise Invalid("IPv4 address must consist of four point-separated integers") - parts_ = list(map(int, parts)) - if not all(0 <= x < 256 for x in parts_): - raise Invalid("IPv4 address parts must be in range from 0 to 255") - return IPAddress(*parts_) +def ipv4address(value): + try: + address = IPv4Address(value) + except AddressValueError as exc: + raise Invalid(f"{value} is not a valid IPv4 address") from exc + return address + + +def ipaddress(value): + try: + address = ip_address(value) + except ValueError as exc: + raise Invalid(f"{value} is not a valid IP address") from exc + return address def _valid_topic(value): diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index a97c3b18c9..f26c3da483 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -54,16 +54,6 @@ class HexInt(int): return f"{sign}0x{value:X}" -class IPAddress: - def __init__(self, *args): - if len(args) != 4: - raise ValueError("IPAddress must consist of 4 items") - self.args = args - - def __str__(self): - return ".".join(str(x) for x in self.args) - - class MACAddress: def __init__(self, *parts): if len(parts) != 6: diff --git a/esphome/yaml_util.py b/esphome/yaml_util.py index d67511dfec..b27ce4c3e3 100644 --- a/esphome/yaml_util.py +++ b/esphome/yaml_util.py @@ -4,6 +4,7 @@ import fnmatch import functools import inspect from io import TextIOWrapper +from ipaddress import _BaseAddress import logging import math import os @@ -25,7 +26,6 @@ from esphome.core import ( CORE, DocumentRange, EsphomeError, - IPAddress, Lambda, MACAddress, TimePeriod, @@ -576,7 +576,7 @@ ESPHomeDumper.add_multi_representer(bool, ESPHomeDumper.represent_bool) ESPHomeDumper.add_multi_representer(str, ESPHomeDumper.represent_stringify) ESPHomeDumper.add_multi_representer(int, ESPHomeDumper.represent_int) ESPHomeDumper.add_multi_representer(float, ESPHomeDumper.represent_float) -ESPHomeDumper.add_multi_representer(IPAddress, ESPHomeDumper.represent_stringify) +ESPHomeDumper.add_multi_representer(_BaseAddress, ESPHomeDumper.represent_stringify) ESPHomeDumper.add_multi_representer(MACAddress, ESPHomeDumper.represent_stringify) ESPHomeDumper.add_multi_representer(TimePeriod, ESPHomeDumper.represent_stringify) ESPHomeDumper.add_multi_representer(Lambda, ESPHomeDumper.represent_lambda) diff --git a/tests/unit_tests/test_config_validation.py b/tests/unit_tests/test_config_validation.py index 34f70be2fb..93ae67754a 100644 --- a/tests/unit_tests/test_config_validation.py +++ b/tests/unit_tests/test_config_validation.py @@ -1,12 +1,12 @@ -import pytest import string -from hypothesis import given, example -from hypothesis.strategies import one_of, text, integers, builds +from hypothesis import example, given +from hypothesis.strategies import builds, integers, ip_addresses, one_of, text +import pytest from esphome import config_validation from esphome.config_validation import Invalid -from esphome.core import CORE, Lambda, HexInt +from esphome.core import CORE, HexInt, Lambda def test_check_not_templatable__invalid(): @@ -145,6 +145,28 @@ def test_boolean__invalid(value): config_validation.boolean(value) +@given(value=ip_addresses(v=4).map(str)) +def test_ipv4__valid(value): + config_validation.ipv4address(value) + + +@pytest.mark.parametrize("value", ("127.0.0", "localhost", "")) +def test_ipv4__invalid(value): + with pytest.raises(Invalid, match="is not a valid IPv4 address"): + config_validation.ipv4address(value) + + +@given(value=ip_addresses(v=6).map(str)) +def test_ipv6__valid(value): + config_validation.ipaddress(value) + + +@pytest.mark.parametrize("value", ("127.0.0", "localhost", "", "2001:db8::2::3")) +def test_ipv6__invalid(value): + with pytest.raises(Invalid, match="is not a valid IP address"): + config_validation.ipaddress(value) + + # TODO: ensure_list @given(integers()) def hex_int__valid(value): diff --git a/tests/unit_tests/test_core.py b/tests/unit_tests/test_core.py index 2860486efe..4f2a6453b4 100644 --- a/tests/unit_tests/test_core.py +++ b/tests/unit_tests/test_core.py @@ -1,10 +1,8 @@ -import pytest - from hypothesis import given -from hypothesis.strategies import ip_addresses +import pytest from strategies import mac_addr_strings -from esphome import core, const +from esphome import const, core class TestHexInt: @@ -26,25 +24,6 @@ class TestHexInt: assert actual == expected -class TestIPAddress: - @given(value=ip_addresses(v=4).map(str)) - def test_init__valid(self, value): - core.IPAddress(*value.split(".")) - - @pytest.mark.parametrize("value", ("127.0.0", "localhost", "")) - def test_init__invalid(self, value): - with pytest.raises(ValueError, match="IPAddress must consist of 4 items"): - core.IPAddress(*value.split(".")) - - @given(value=ip_addresses(v=4).map(str)) - def test_str(self, value): - target = core.IPAddress(*value.split(".")) - - actual = str(target) - - assert actual == value - - class TestMACAddress: @given(value=mac_addr_strings()) def test_init__valid(self, value): From 40bee2a854a0cd82872c83d5c81f812199df5495 Mon Sep 17 00:00:00 2001 From: Brian Whicheloe Date: Sun, 12 Jan 2025 11:15:22 -0800 Subject: [PATCH 048/194] Add log level env var (#7604) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/__main__.py | 19 ++++++++++++++++--- esphome/log.py | 12 +++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index dce041e5ac..2a0bd8f2b3 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -758,6 +758,14 @@ def parse_args(argv): options_parser.add_argument( "-q", "--quiet", help="Disable all ESPHome logs.", action="store_true" ) + options_parser.add_argument( + "-l", + "--log-level", + help="Set the log level.", + default=os.getenv("ESPHOME_LOG_LEVEL", "INFO"), + action="store", + choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], + ) options_parser.add_argument( "--dashboard", help=argparse.SUPPRESS, action="store_true" ) @@ -987,11 +995,16 @@ def run_esphome(argv): args = parse_args(argv) CORE.dashboard = args.dashboard + # Override log level if verbose is set + if args.verbose: + args.log_level = "DEBUG" + elif args.quiet: + args.log_level = "CRITICAL" + setup_log( - args.verbose, - args.quiet, + log_level=args.log_level, # Show timestamp for dashboard access logs - args.command == "dashboard", + include_timestamp=args.command == "dashboard", ) if args.command in PRE_CONFIG_ACTIONS: diff --git a/esphome/log.py b/esphome/log.py index 23dc453d32..835cd6b44d 100644 --- a/esphome/log.py +++ b/esphome/log.py @@ -67,20 +67,18 @@ class ESPHomeLogFormatter(logging.Formatter): def setup_log( - debug: bool = False, quiet: bool = False, include_timestamp: bool = False + log_level=logging.INFO, + include_timestamp: bool = False, ) -> None: import colorama colorama.init() - if debug: - log_level = logging.DEBUG + if log_level == logging.DEBUG: CORE.verbose = True - elif quiet: - log_level = logging.CRITICAL + elif log_level == logging.CRITICAL: CORE.quiet = True - else: - log_level = logging.INFO + logging.basicConfig(level=log_level) logging.getLogger("urllib3").setLevel(logging.WARNING) From 731fb1d172f83d15a3f03152477dbd5f482cd19f Mon Sep 17 00:00:00 2001 From: tomaszduda23 Date: Sun, 12 Jan 2025 23:15:39 +0100 Subject: [PATCH 049/194] [spi] relay on KEY_TARGET_PLATFORM as the other platforms does (#8066) --- esphome/components/spi/__init__.py | 6 +----- script/build_codeowners.py | 4 ++-- script/build_language_schema.py | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/esphome/components/spi/__init__.py b/esphome/components/spi/__init__.py index 52afbf365e..3e6d680b89 100644 --- a/esphome/components/spi/__init__.py +++ b/esphome/components/spi/__init__.py @@ -97,11 +97,7 @@ RP_SPI_PINSETS = [ def get_target_platform(): - return ( - CORE.data[KEY_CORE][KEY_TARGET_PLATFORM] - if KEY_TARGET_PLATFORM in CORE.data[KEY_CORE] - else "" - ) + return CORE.data[KEY_CORE][KEY_TARGET_PLATFORM] def get_target_variant(): diff --git a/script/build_codeowners.py b/script/build_codeowners.py index db34ad7702..523fe8ac7f 100755 --- a/script/build_codeowners.py +++ b/script/build_codeowners.py @@ -5,7 +5,7 @@ from pathlib import Path import sys from esphome.config import get_component, get_platform -from esphome.const import KEY_CORE, KEY_TARGET_FRAMEWORK +from esphome.const import KEY_CORE, KEY_TARGET_FRAMEWORK, KEY_TARGET_PLATFORM from esphome.core import CORE from esphome.helpers import write_file_if_changed @@ -39,7 +39,7 @@ parts = [BASE] # Fake some directory so that get_component works CORE.config_path = str(root) -CORE.data[KEY_CORE] = {KEY_TARGET_FRAMEWORK: None} +CORE.data[KEY_CORE] = {KEY_TARGET_FRAMEWORK: None, KEY_TARGET_PLATFORM: None} codeowners = defaultdict(list) diff --git a/script/build_language_schema.py b/script/build_language_schema.py index 2023dc0402..07093e179a 100644 --- a/script/build_language_schema.py +++ b/script/build_language_schema.py @@ -85,12 +85,12 @@ def load_components(): # pylint: disable=wrong-import-position -from esphome.const import CONF_TYPE, KEY_CORE +from esphome.const import CONF_TYPE, KEY_CORE, KEY_TARGET_PLATFORM from esphome.core import CORE # pylint: enable=wrong-import-position -CORE.data[KEY_CORE] = {} +CORE.data[KEY_CORE] = {KEY_TARGET_PLATFORM: None} load_components() # Import esphome after loading components (so schema is tracked) From 7c3942269200e43f81391cc0e63d636ab63b6761 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:54:44 +1300 Subject: [PATCH 050/194] Bump actions/upload-artifact from 4.5.0 to 4.6.0 (#8058) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0304cd2304..e791f666d4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -141,7 +141,7 @@ jobs: echo name=$(cat /tmp/platform) >> $GITHUB_OUTPUT - name: Upload digests - uses: actions/upload-artifact@v4.5.0 + uses: actions/upload-artifact@v4.6.0 with: name: digests-${{ steps.sanitize.outputs.name }} path: /tmp/digests From 571935fb3b97cd031390bb5b7ac4b4da5f62575b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:55:00 +1300 Subject: [PATCH 051/194] Bump peter-evans/create-pull-request from 7.0.5 to 7.0.6 (#8024) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-device-classes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-device-classes.yml b/.github/workflows/sync-device-classes.yml index 7a46d596a1..9160ab4a1b 100644 --- a/.github/workflows/sync-device-classes.yml +++ b/.github/workflows/sync-device-classes.yml @@ -36,7 +36,7 @@ jobs: python ./script/sync-device_class.py - name: Commit changes - uses: peter-evans/create-pull-request@v7.0.5 + uses: peter-evans/create-pull-request@v7.0.6 with: commit-message: "Synchronise Device Classes from Home Assistant" committer: esphomebot From f25f3334d11d5a508aad6cdf5056b4cc33213fe7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:55:37 +1300 Subject: [PATCH 052/194] Bump docker/setup-qemu-action from 3.2.0 to 3.3.0 in the docker-actions group (#8052) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-docker.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index cf7b08f3d4..b994cfaf17 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -48,7 +48,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.8.0 - name: Set up QEMU - uses: docker/setup-qemu-action@v3.2.0 + uses: docker/setup-qemu-action@v3.3.0 - name: Set TAG run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e791f666d4..962bc66e94 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,7 +93,7 @@ jobs: uses: docker/setup-buildx-action@v3.8.0 - name: Set up QEMU if: matrix.platform != 'linux/amd64' - uses: docker/setup-qemu-action@v3.2.0 + uses: docker/setup-qemu-action@v3.3.0 - name: Log in to docker hub uses: docker/login-action@v3.3.0 From 739edce268f83657ce5ef7d823008260a7c424db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 12:55:53 +1300 Subject: [PATCH 053/194] Bump docker/build-push-action from 6.10.0 to 6.11.0 in /.github/actions/build-image (#8053) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/actions/build-image/action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-image/action.yaml b/.github/actions/build-image/action.yaml index cc9894a657..e6b6da4177 100644 --- a/.github/actions/build-image/action.yaml +++ b/.github/actions/build-image/action.yaml @@ -46,7 +46,7 @@ runs: - name: Build and push to ghcr by digest id: build-ghcr - uses: docker/build-push-action@v6.10.0 + uses: docker/build-push-action@v6.11.0 env: DOCKER_BUILD_SUMMARY: false DOCKER_BUILD_RECORD_UPLOAD: false @@ -72,7 +72,7 @@ runs: - name: Build and push to dockerhub by digest id: build-dockerhub - uses: docker/build-push-action@v6.10.0 + uses: docker/build-push-action@v6.11.0 env: DOCKER_BUILD_SUMMARY: false DOCKER_BUILD_RECORD_UPLOAD: false From 4409471cd1c20a43a45bcfddead959c9d58c3419 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 13 Jan 2025 14:32:10 +1300 Subject: [PATCH 054/194] Bump python3-setuptools to 66.1.1-1+deb12u1 (#8074) --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 0bb558d35e..429f5c4a1f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -29,7 +29,7 @@ RUN \ # Use pinned versions so that we get updates with build caching && apt-get install -y --no-install-recommends \ python3-pip=23.0.1+dfsg-1 \ - python3-setuptools=66.1.1-1 \ + python3-setuptools=66.1.1-1+deb12u1 \ python3-venv=3.11.2-1+b1 \ python3-wheel=0.38.4-2 \ iputils-ping=3:20221126-1+deb12u1 \ From fb87a1c0bc565447785f90367f28bb0e74584f49 Mon Sep 17 00:00:00 2001 From: Mischa Siekmann <45062894+gnumpi@users.noreply.github.com> Date: Mon, 13 Jan 2025 02:42:03 +0100 Subject: [PATCH 055/194] Allow CONF_RMT_CHANNEL parameter for IDF 4.X (#8035) --- .../components/esp32_rmt_led_strip/light.py | 54 +++++++++++++++++-- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/esphome/components/esp32_rmt_led_strip/light.py b/esphome/components/esp32_rmt_led_strip/light.py index 67a0e31461..64104bb6de 100644 --- a/esphome/components/esp32_rmt_led_strip/light.py +++ b/esphome/components/esp32_rmt_led_strip/light.py @@ -1,4 +1,5 @@ from dataclasses import dataclass +import logging from esphome import pins import esphome.codegen as cg @@ -15,6 +16,9 @@ from esphome.const import ( CONF_RMT_CHANNEL, CONF_RMT_SYMBOLS, ) +from esphome.core import CORE + +_LOGGER = logging.getLogger(__name__) CODEOWNERS = ["@jesserockz"] DEPENDENCIES = ["esp32"] @@ -64,13 +68,53 @@ CONF_RESET_HIGH = "reset_high" CONF_RESET_LOW = "reset_low" +class OptionalForIDF5(cv.SplitDefault): + @property + def default(self): + if not esp32_rmt.use_new_rmt_driver(): + return cv.UNDEFINED + return super().default + + @default.setter + def default(self, value): + # Ignore default set from vol.Optional + pass + + +def only_with_new_rmt_driver(obj): + if not esp32_rmt.use_new_rmt_driver(): + raise cv.Invalid( + "This feature is only available for the IDF framework version 5." + ) + return obj + + +def not_with_new_rmt_driver(obj): + if esp32_rmt.use_new_rmt_driver(): + raise cv.Invalid( + "This feature is not available for the IDF framework version 5." + ) + return obj + + def final_validation(config): - if not esp32_rmt.use_new_rmt_driver() and CONF_RMT_CHANNEL not in config: - raise cv.Invalid("rmt_channel is a required option.") + if not esp32_rmt.use_new_rmt_driver(): + if CONF_RMT_CHANNEL not in config: + if CORE.using_esp_idf: + raise cv.Invalid( + "rmt_channel is a required option for IDF version < 5." + ) + raise cv.Invalid( + "rmt_channel is a required option for the Arduino framework." + ) + _LOGGER.warning( + "RMT_LED_STRIP support for IDF version < 5 is deprecated and will be removed soon." + ) FINAL_VALIDATE_SCHEMA = final_validation + CONFIG_SCHEMA = cv.All( light.ADDRESSABLE_LIGHT_SCHEMA.extend( { @@ -79,9 +123,9 @@ CONFIG_SCHEMA = cv.All( cv.Required(CONF_NUM_LEDS): cv.positive_not_null_int, cv.Required(CONF_RGB_ORDER): cv.enum(RGB_ORDERS, upper=True), cv.Optional(CONF_RMT_CHANNEL): cv.All( - cv.only_with_arduino, esp32_rmt.validate_rmt_channel(tx=True) + not_with_new_rmt_driver, esp32_rmt.validate_rmt_channel(tx=True) ), - cv.SplitDefault( + OptionalForIDF5( CONF_RMT_SYMBOLS, esp32_idf=64, esp32_s2_idf=64, @@ -89,7 +133,7 @@ CONFIG_SCHEMA = cv.All( esp32_c3_idf=48, esp32_c6_idf=48, esp32_h2_idf=48, - ): cv.All(cv.only_with_esp_idf, cv.int_range(min=2)), + ): cv.All(only_with_new_rmt_driver, cv.int_range(min=2)), cv.Optional(CONF_MAX_REFRESH_RATE): cv.positive_time_period_microseconds, cv.Optional(CONF_CHIPSET): cv.one_of(*CHIPSETS, upper=True), cv.Optional(CONF_IS_RGBW, default=False): cv.boolean, From aac38419915486fff121651bf6a4d063f6f4b312 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:45:35 -0500 Subject: [PATCH 056/194] [esp32] Fix arch_get_cpu_freq_hz (#8047) Co-authored-by: Jonathan Swoboda --- esphome/components/esp32/core.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/esphome/components/esp32/core.cpp b/esphome/components/esp32/core.cpp index 48c8b2b04d..ff8e663ec1 100644 --- a/esphome/components/esp32/core.cpp +++ b/esphome/components/esp32/core.cpp @@ -58,7 +58,11 @@ uint32_t arch_get_cpu_cycle_count() { return esp_cpu_get_cycle_count(); } #else uint32_t arch_get_cpu_cycle_count() { return cpu_hal_get_cycle_count(); } #endif -uint32_t arch_get_cpu_freq_hz() { return rtc_clk_apb_freq_get(); } +uint32_t arch_get_cpu_freq_hz() { + rtc_cpu_freq_config_t config; + rtc_clk_cpu_freq_get_config(&config); + return config.freq_mhz * 1000000U; +} #ifdef USE_ESP_IDF TaskHandle_t loop_task_handle = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) From dd3ffc7f29d8436171af8ce070ab68f7e226d570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=BBbik?= Date: Mon, 13 Jan 2025 03:55:30 +0100 Subject: [PATCH 057/194] Fix Waveshare 7in5bv3bwr image quality in BWR mode (#8043) Co-authored-by: zbikmarc --- .../waveshare_epaper/waveshare_epaper.cpp | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index cb3b19aa1a..fb9e8ff6e5 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -2425,28 +2425,21 @@ void WaveshareEPaper7P5InBV3BWR::init_display_() { this->command(0x01); // 1-0=11: internal power - this->data(0x07); - this->data(0x17); // VGH&VGL - this->data(0x3F); // VSH - this->data(0x26); // VSL - this->data(0x11); // VSHR + this->data(0x07); // VRS_EN=1, VS_EN=1, VG_EN=1 + this->data(0x17); // VGH&VGL ??? VCOM_SLEW=1 but this is fixed, VG_LVL[2:0]=111 => VGH=20V VGL=-20V, it could be 0x07 + this->data(0x3F); // VSH=15V? + this->data(0x26); // VSL=-9.4V? + this->data(0x11); // VSHR=5.8V? // VCOM DC Setting this->command(0x82); - this->data(0x24); // VCOM - - // Booster Setting - this->command(0x06); - this->data(0x27); - this->data(0x27); - this->data(0x2F); - this->data(0x17); + this->data(0x24); // VCOM=-1.9V // POWER ON this->command(0x04); - delay(100); // NOLINT this->wait_until_idle_(); + // COMMAND PANEL SETTING this->command(0x00); this->data(0x0F); // KW-3f KWR-2F BWROTP 0f BWOTP 1f @@ -2457,16 +2450,16 @@ void WaveshareEPaper7P5InBV3BWR::init_display_() { this->data(0x20); this->data(0x01); // gate 480 this->data(0xE0); - // COMMAND ...? - this->command(0x15); - this->data(0x00); + // COMMAND VCOM AND DATA INTERVAL SETTING this->command(0x50); this->data(0x20); this->data(0x00); + // COMMAND TCON SETTING this->command(0x60); this->data(0x22); + // Resolution setting this->command(0x65); this->data(0x00); From 92a8ebe1f8c15db118dac1269eb309b83f0ed9ee Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:56:42 +1100 Subject: [PATCH 058/194] [json] use correct formatting (#8039) --- esphome/components/json/json_util.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/esphome/components/json/json_util.cpp b/esphome/components/json/json_util.cpp index 87b1cc6d2d..d50b2b483c 100644 --- a/esphome/components/json/json_util.cpp +++ b/esphome/components/json/json_util.cpp @@ -17,11 +17,11 @@ std::string build_json(const json_build_t &f) { auto free_heap = ALLOCATOR.get_max_free_block_size(); size_t request_size = std::min(free_heap, (size_t) 512); while (true) { - ESP_LOGV(TAG, "Attempting to allocate %u bytes for JSON serialization", request_size); + ESP_LOGV(TAG, "Attempting to allocate %zu bytes for JSON serialization", request_size); DynamicJsonDocument json_document(request_size); if (json_document.capacity() == 0) { ESP_LOGE(TAG, - "Could not allocate memory for JSON document! Requested %u bytes, largest free heap block: %u bytes", + "Could not allocate memory for JSON document! Requested %zu bytes, largest free heap block: %zu bytes", request_size, free_heap); return "{}"; } @@ -29,7 +29,7 @@ std::string build_json(const json_build_t &f) { f(root); if (json_document.overflowed()) { if (request_size == free_heap) { - ESP_LOGE(TAG, "Could not allocate memory for JSON document! Overflowed largest free heap block: %u bytes", + ESP_LOGE(TAG, "Could not allocate memory for JSON document! Overflowed largest free heap block: %zu bytes", free_heap); return "{}"; } @@ -37,7 +37,7 @@ std::string build_json(const json_build_t &f) { continue; } json_document.shrinkToFit(); - ESP_LOGV(TAG, "Size after shrink %u bytes", json_document.capacity()); + ESP_LOGV(TAG, "Size after shrink %zu bytes", json_document.capacity()); std::string output; serializeJson(json_document, output); return output; From aa87c607173d9ef65e047a5e6b73d7ab4fac649d Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sun, 12 Jan 2025 21:12:54 -0600 Subject: [PATCH 059/194] [nextion] Brightness control tweaks (#8027) --- esphome/components/nextion/automation.h | 17 +++++++++ esphome/components/nextion/display.py | 51 ++++++++++++++++++------- esphome/components/nextion/nextion.cpp | 4 +- esphome/components/nextion/nextion.h | 2 +- tests/components/nextion/common.yaml | 2 + 5 files changed, 61 insertions(+), 15 deletions(-) diff --git a/esphome/components/nextion/automation.h b/esphome/components/nextion/automation.h index 65f1fd0058..c718355af8 100644 --- a/esphome/components/nextion/automation.h +++ b/esphome/components/nextion/automation.h @@ -49,6 +49,23 @@ class TouchTrigger : public Trigger { } }; +template class NextionSetBrightnessAction : public Action { + public: + explicit NextionSetBrightnessAction(Nextion *component) : component_(component) {} + + TEMPLATABLE_VALUE(float, brightness) + + void play(Ts... x) override { + this->component_->set_brightness(this->brightness_.value(x...)); + this->component_->set_backlight_brightness(this->brightness_.value(x...)); + } + + void set_brightness(std::function brightness) { this->brightness_ = brightness; } + + protected: + Nextion *component_; +}; + template class NextionPublishFloatAction : public Action { public: explicit NextionPublishFloatAction(NextionComponent *component) : component_(component) {} diff --git a/esphome/components/nextion/display.py b/esphome/components/nextion/display.py index f6bd863d42..60f26e5234 100644 --- a/esphome/components/nextion/display.py +++ b/esphome/components/nextion/display.py @@ -1,30 +1,30 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation -from esphome.components import display, uart -from esphome.components import esp32 +import esphome.codegen as cg +from esphome.components import display, esp32, uart +import esphome.config_validation as cv from esphome.const import ( + CONF_BRIGHTNESS, CONF_ID, CONF_LAMBDA, - CONF_BRIGHTNESS, - CONF_TRIGGER_ID, CONF_ON_TOUCH, + CONF_TRIGGER_ID, ) from esphome.core import CORE + from . import Nextion, nextion_ns, nextion_ref from .base_component import ( + CONF_AUTO_WAKE_ON_TOUCH, + CONF_EXIT_REPARSE_ON_START, CONF_ON_BUFFER_OVERFLOW, + CONF_ON_PAGE, + CONF_ON_SETUP, CONF_ON_SLEEP, CONF_ON_WAKE, - CONF_ON_SETUP, - CONF_ON_PAGE, + CONF_SKIP_CONNECTION_HANDSHAKE, + CONF_START_UP_PAGE, CONF_TFT_URL, CONF_TOUCH_SLEEP_TIMEOUT, CONF_WAKE_UP_PAGE, - CONF_START_UP_PAGE, - CONF_AUTO_WAKE_ON_TOUCH, - CONF_EXIT_REPARSE_ON_START, - CONF_SKIP_CONNECTION_HANDSHAKE, ) CODEOWNERS = ["@senexcrenshaw", "@edwardtfn"] @@ -32,6 +32,9 @@ CODEOWNERS = ["@senexcrenshaw", "@edwardtfn"] DEPENDENCIES = ["uart"] AUTO_LOAD = ["binary_sensor", "switch", "sensor", "text_sensor"] +NextionSetBrightnessAction = nextion_ns.class_( + "NextionSetBrightnessAction", automation.Action +) SetupTrigger = nextion_ns.class_("SetupTrigger", automation.Trigger.template()) SleepTrigger = nextion_ns.class_("SleepTrigger", automation.Trigger.template()) WakeTrigger = nextion_ns.class_("WakeTrigger", automation.Trigger.template()) @@ -46,7 +49,7 @@ CONFIG_SCHEMA = ( { cv.GenerateID(): cv.declare_id(Nextion), cv.Optional(CONF_TFT_URL): cv.url, - cv.Optional(CONF_BRIGHTNESS, default=1.0): cv.percentage, + cv.Optional(CONF_BRIGHTNESS): cv.percentage, cv.Optional(CONF_ON_SETUP): automation.validate_automation( { cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(SetupTrigger), @@ -92,12 +95,34 @@ CONFIG_SCHEMA = ( ) +@automation.register_action( + "display.nextion.set_brightness", + NextionSetBrightnessAction, + cv.maybe_simple_value( + { + cv.GenerateID(): cv.use_id(Nextion), + cv.Required(CONF_BRIGHTNESS): cv.templatable(cv.percentage), + }, + key=CONF_BRIGHTNESS, + ), +) +async def nextion_set_brightness_to_code(config, action_id, template_arg, args): + paren = await cg.get_variable(config[CONF_ID]) + var = cg.new_Pvariable(action_id, template_arg, paren) + + template_ = await cg.templatable(config[CONF_BRIGHTNESS], args, float) + cg.add(var.set_brightness(template_)) + + return var + + async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await uart.register_uart_device(var, config) if CONF_BRIGHTNESS in config: cg.add(var.set_brightness(config[CONF_BRIGHTNESS])) + if CONF_LAMBDA in config: lambda_ = await cg.process_lambda( config[CONF_LAMBDA], [(nextion_ref, "it")], return_type=cg.void diff --git a/esphome/components/nextion/nextion.cpp b/esphome/components/nextion/nextion.cpp index e5df13c64e..67f08f68f8 100644 --- a/esphome/components/nextion/nextion.cpp +++ b/esphome/components/nextion/nextion.cpp @@ -273,7 +273,9 @@ void Nextion::loop() { this->sent_setup_commands_ = true; this->send_command_("bkcmd=3"); // Always, returns 0x00 to 0x23 result of serial command. - this->set_backlight_brightness(this->brightness_); + if (this->brightness_.has_value()) { + this->set_backlight_brightness(this->brightness_.value()); + } // Check if a startup page has been set and send the command if (this->start_up_page_ != -1) { diff --git a/esphome/components/nextion/nextion.h b/esphome/components/nextion/nextion.h index c293f80aee..b2404e1f0d 100644 --- a/esphome/components/nextion/nextion.h +++ b/esphome/components/nextion/nextion.h @@ -1339,7 +1339,7 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe CallbackManager buffer_overflow_callback_{}; optional writer_; - float brightness_{1.0}; + optional brightness_; std::string device_model_; std::string firmware_version_; diff --git a/tests/components/nextion/common.yaml b/tests/components/nextion/common.yaml index 73fc8484c0..589afcfefb 100644 --- a/tests/components/nextion/common.yaml +++ b/tests/components/nextion/common.yaml @@ -2,6 +2,8 @@ esphome: on_boot: - lambda: 'ESP_LOGD("display","is_connected(): %s", YESNO(id(main_lcd).is_connected()));' + - display.nextion.set_brightness: 80% + # Binary sensor publish action tests - binary_sensor.nextion.publish: id: r0_sensor From f1c0570e3b51062f12c8ebf0fcefeb6fc81e22b7 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 13 Jan 2025 14:21:42 +1100 Subject: [PATCH 060/194] [image] Transparency changes; code refactor (#7908) --- CODEOWNERS | 2 +- esphome/components/animation/__init__.py | 284 +------ esphome/components/animation/animation.cpp | 4 +- esphome/components/animation/animation.h | 3 +- esphome/components/image/__init__.py | 691 +++++++++++------- esphome/components/image/image.cpp | 143 ++-- esphome/components/image/image.h | 39 +- esphome/components/online_image/__init__.py | 118 +-- .../components/online_image/image_decoder.h | 11 +- .../components/online_image/online_image.cpp | 92 +-- .../components/online_image/online_image.h | 3 +- esphome/components/online_image/png_image.h | 1 + script/ci-custom.py | 17 +- tests/components/animation/.gitattributes | 4 + tests/components/animation/anim.apng | Bin 0 -> 12626 bytes tests/components/animation/anim.gif | Bin 0 -> 9735 bytes tests/components/animation/anim.webp | Bin 0 -> 8244 bytes tests/components/animation/common.yaml | 23 + .../components/animation/test.esp32-ard.yaml | 10 +- .../animation/test.esp32-c3-ard.yaml | 11 +- .../animation/test.esp32-c3-idf.yaml | 11 +- .../components/animation/test.esp32-idf.yaml | 11 +- .../animation/test.esp8266-ard.yaml | 11 +- .../components/animation/test.rp2040-ard.yaml | 11 +- tests/components/image/common.yaml | 49 +- tests/components/image/test.host.yaml | 42 +- tests/components/online_image/common.yaml | 41 +- 27 files changed, 845 insertions(+), 787 deletions(-) create mode 100644 tests/components/animation/.gitattributes create mode 100644 tests/components/animation/anim.apng create mode 100644 tests/components/animation/anim.gif create mode 100644 tests/components/animation/anim.webp create mode 100644 tests/components/animation/common.yaml diff --git a/CODEOWNERS b/CODEOWNERS index 404ad35efc..088e350f5d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -302,7 +302,7 @@ esphome/components/noblex/* @AGalfra esphome/components/npi19/* @bakerkj esphome/components/number/* @esphome/core esphome/components/one_wire/* @ssieb -esphome/components/online_image/* @guillempages +esphome/components/online_image/* @clydebarrow @guillempages esphome/components/opentherm/* @olegtarasov esphome/components/ota/* @esphome/core esphome/components/output/* @esphome/core diff --git a/esphome/components/animation/__init__.py b/esphome/components/animation/__init__.py index 21a82649f0..f73b8ef08f 100644 --- a/esphome/components/animation/__init__.py +++ b/esphome/components/animation/__init__.py @@ -1,28 +1,10 @@ import logging -from esphome import automation, core +from esphome import automation import esphome.codegen as cg import esphome.components.image as espImage -from esphome.components.image import ( - CONF_USE_TRANSPARENCY, - LOCAL_SCHEMA, - SOURCE_LOCAL, - SOURCE_WEB, - WEB_SCHEMA, -) import esphome.config_validation as cv -from esphome.const import ( - CONF_FILE, - CONF_ID, - CONF_PATH, - CONF_RAW_DATA_ID, - CONF_REPEAT, - CONF_RESIZE, - CONF_SOURCE, - CONF_TYPE, - CONF_URL, -) -from esphome.core import CORE, HexInt +from esphome.const import CONF_ID, CONF_REPEAT _LOGGER = logging.getLogger(__name__) @@ -30,6 +12,7 @@ AUTO_LOAD = ["image"] CODEOWNERS = ["@syndlex"] DEPENDENCIES = ["display"] MULTI_CONF = True +MULTI_CONF_NO_DEFAULT = True CONF_LOOP = "loop" CONF_START_FRAME = "start_frame" @@ -51,86 +34,19 @@ SetFrameAction = animation_ns.class_( "AnimationSetFrameAction", automation.Action, cg.Parented.template(Animation_) ) -TYPED_FILE_SCHEMA = cv.typed_schema( +CONFIG_SCHEMA = espImage.IMAGE_SCHEMA.extend( { - SOURCE_LOCAL: LOCAL_SCHEMA, - SOURCE_WEB: WEB_SCHEMA, - }, - key=CONF_SOURCE, -) - - -def _file_schema(value): - if isinstance(value, str): - return validate_file_shorthand(value) - return TYPED_FILE_SCHEMA(value) - - -FILE_SCHEMA = cv.Schema(_file_schema) - - -def validate_file_shorthand(value): - value = cv.string_strict(value) - if value.startswith("http://") or value.startswith("https://"): - return FILE_SCHEMA( + cv.Required(CONF_ID): cv.declare_id(Animation_), + cv.Optional(CONF_LOOP): cv.All( { - CONF_SOURCE: SOURCE_WEB, - CONF_URL: value, + cv.Optional(CONF_START_FRAME, default=0): cv.positive_int, + cv.Optional(CONF_END_FRAME): cv.positive_int, + cv.Optional(CONF_REPEAT): cv.positive_int, } - ) - return FILE_SCHEMA( - { - CONF_SOURCE: SOURCE_LOCAL, - CONF_PATH: value, - } - ) - - -def validate_cross_dependencies(config): - """ - Validate fields whose possible values depend on other fields. - For example, validate that explicitly transparent image types - have "use_transparency" set to True. - Also set the default value for those kind of dependent fields. - """ - image_type = config[CONF_TYPE] - is_transparent_type = image_type in ["TRANSPARENT_BINARY", "RGBA"] - # If the use_transparency option was not specified, set the default depending on the image type - if CONF_USE_TRANSPARENCY not in config: - config[CONF_USE_TRANSPARENCY] = is_transparent_type - - if is_transparent_type and not config[CONF_USE_TRANSPARENCY]: - raise cv.Invalid(f"Image type {image_type} must always be transparent.") - - return config - - -ANIMATION_SCHEMA = cv.Schema( - cv.All( - { - cv.Required(CONF_ID): cv.declare_id(Animation_), - cv.Required(CONF_FILE): FILE_SCHEMA, - cv.Optional(CONF_RESIZE): cv.dimensions, - cv.Optional(CONF_TYPE, default="BINARY"): cv.enum( - espImage.IMAGE_TYPE, upper=True - ), - # Not setting default here on purpose; the default depends on the image type, - # and thus will be set in the "validate_cross_dependencies" validator. - cv.Optional(CONF_USE_TRANSPARENCY): cv.boolean, - cv.Optional(CONF_LOOP): cv.All( - { - cv.Optional(CONF_START_FRAME, default=0): cv.positive_int, - cv.Optional(CONF_END_FRAME): cv.positive_int, - cv.Optional(CONF_REPEAT): cv.positive_int, - } - ), - cv.GenerateID(CONF_RAW_DATA_ID): cv.declare_id(cg.uint8), - }, - validate_cross_dependencies, - ) + ), + }, ) -CONFIG_SCHEMA = ANIMATION_SCHEMA NEXT_FRAME_SCHEMA = automation.maybe_simple_id( { @@ -164,180 +80,26 @@ async def animation_action_to_code(config, action_id, template_arg, args): async def to_code(config): - from PIL import Image + ( + prog_arr, + width, + height, + image_type, + trans_value, + frame_count, + ) = await espImage.write_image(config, all_frames=True) - conf_file = config[CONF_FILE] - if conf_file[CONF_SOURCE] == SOURCE_LOCAL: - path = CORE.relative_config_path(conf_file[CONF_PATH]) - elif conf_file[CONF_SOURCE] == SOURCE_WEB: - path = espImage.compute_local_image_path(conf_file).as_posix() - else: - raise core.EsphomeError(f"Unknown animation source: {conf_file[CONF_SOURCE]}") - - try: - image = Image.open(path) - except Exception as e: - raise core.EsphomeError(f"Could not load image file {path}: {e}") - - width, height = image.size - frames = image.n_frames - if CONF_RESIZE in config: - new_width_max, new_height_max = config[CONF_RESIZE] - ratio = min(new_width_max / width, new_height_max / height) - width, height = int(width * ratio), int(height * ratio) - elif width > 500 or height > 500: - _LOGGER.warning( - 'The image "%s" you requested is very big. Please consider' - " using the resize parameter.", - path, - ) - - transparent = config[CONF_USE_TRANSPARENCY] - - if config[CONF_TYPE] == "GRAYSCALE": - data = [0 for _ in range(height * width * frames)] - pos = 0 - for frameIndex in range(frames): - image.seek(frameIndex) - frame = image.convert("LA", dither=Image.Dither.NONE) - if CONF_RESIZE in config: - frame = frame.resize([width, height]) - pixels = list(frame.getdata()) - if len(pixels) != height * width: - raise core.EsphomeError( - f"Unexpected number of pixels in {path} frame {frameIndex}: ({len(pixels)} != {height * width})" - ) - for pix, a in pixels: - if transparent: - if pix == 1: - pix = 0 - if a < 0x80: - pix = 1 - - data[pos] = pix - pos += 1 - - elif config[CONF_TYPE] == "RGBA": - data = [0 for _ in range(height * width * 4 * frames)] - pos = 0 - for frameIndex in range(frames): - image.seek(frameIndex) - frame = image.convert("RGBA") - if CONF_RESIZE in config: - frame = frame.resize([width, height]) - pixels = list(frame.getdata()) - if len(pixels) != height * width: - raise core.EsphomeError( - f"Unexpected number of pixels in {path} frame {frameIndex}: ({len(pixels)} != {height * width})" - ) - for pix in pixels: - data[pos] = pix[0] - pos += 1 - data[pos] = pix[1] - pos += 1 - data[pos] = pix[2] - pos += 1 - data[pos] = pix[3] - pos += 1 - - elif config[CONF_TYPE] == "RGB24": - data = [0 for _ in range(height * width * 3 * frames)] - pos = 0 - for frameIndex in range(frames): - image.seek(frameIndex) - frame = image.convert("RGBA") - if CONF_RESIZE in config: - frame = frame.resize([width, height]) - pixels = list(frame.getdata()) - if len(pixels) != height * width: - raise core.EsphomeError( - f"Unexpected number of pixels in {path} frame {frameIndex}: ({len(pixels)} != {height * width})" - ) - for r, g, b, a in pixels: - if transparent: - if r == 0 and g == 0 and b == 1: - b = 0 - if a < 0x80: - r = 0 - g = 0 - b = 1 - - data[pos] = r - pos += 1 - data[pos] = g - pos += 1 - data[pos] = b - pos += 1 - - elif config[CONF_TYPE] in ["RGB565", "TRANSPARENT_IMAGE"]: - bytes_per_pixel = 3 if transparent else 2 - data = [0 for _ in range(height * width * bytes_per_pixel * frames)] - pos = 0 - for frameIndex in range(frames): - image.seek(frameIndex) - frame = image.convert("RGBA") - if CONF_RESIZE in config: - frame = frame.resize([width, height]) - pixels = list(frame.getdata()) - if len(pixels) != height * width: - raise core.EsphomeError( - f"Unexpected number of pixels in {path} frame {frameIndex}: ({len(pixels)} != {height * width})" - ) - for r, g, b, a in pixels: - R = r >> 3 - G = g >> 2 - B = b >> 3 - rgb = (R << 11) | (G << 5) | B - data[pos] = rgb >> 8 - pos += 1 - data[pos] = rgb & 0xFF - pos += 1 - if transparent: - data[pos] = a - pos += 1 - - elif config[CONF_TYPE] in ["BINARY", "TRANSPARENT_BINARY"]: - width8 = ((width + 7) // 8) * 8 - data = [0 for _ in range((height * width8 // 8) * frames)] - for frameIndex in range(frames): - image.seek(frameIndex) - if transparent: - alpha = image.split()[-1] - has_alpha = alpha.getextrema()[0] < 0xFF - else: - has_alpha = False - frame = image.convert("1", dither=Image.Dither.NONE) - if CONF_RESIZE in config: - frame = frame.resize([width, height]) - if transparent: - alpha = alpha.resize([width, height]) - for x, y in [(i, j) for i in range(width) for j in range(height)]: - if transparent and has_alpha: - if not alpha.getpixel((x, y)): - continue - elif frame.getpixel((x, y)): - continue - - pos = x + y * width8 + (height * width8 * frameIndex) - data[pos // 8] |= 0x80 >> (pos % 8) - else: - raise core.EsphomeError( - f"Animation f{config[CONF_ID]} has not supported type {config[CONF_TYPE]}." - ) - - rhs = [HexInt(x) for x in data] - prog_arr = cg.progmem_array(config[CONF_RAW_DATA_ID], rhs) var = cg.new_Pvariable( config[CONF_ID], prog_arr, width, height, - frames, - espImage.IMAGE_TYPE[config[CONF_TYPE]], + frame_count, + image_type, + trans_value, ) - cg.add(var.set_transparency(transparent)) if loop_config := config.get(CONF_LOOP): start = loop_config[CONF_START_FRAME] - end = loop_config.get(CONF_END_FRAME, frames) + end = loop_config.get(CONF_END_FRAME, frame_count) count = loop_config.get(CONF_REPEAT, -1) cg.add(var.set_loop(start, end, count)) diff --git a/esphome/components/animation/animation.cpp b/esphome/components/animation/animation.cpp index 1375dfe07e..6db6f1a7bd 100644 --- a/esphome/components/animation/animation.cpp +++ b/esphome/components/animation/animation.cpp @@ -6,8 +6,8 @@ namespace esphome { namespace animation { Animation::Animation(const uint8_t *data_start, int width, int height, uint32_t animation_frame_count, - image::ImageType type) - : Image(data_start, width, height, type), + image::ImageType type, image::Transparency transparent) + : Image(data_start, width, height, type, transparent), animation_data_start_(data_start), current_frame_(0), animation_frame_count_(animation_frame_count), diff --git a/esphome/components/animation/animation.h b/esphome/components/animation/animation.h index 272c5153d1..c44e0060af 100644 --- a/esphome/components/animation/animation.h +++ b/esphome/components/animation/animation.h @@ -8,7 +8,8 @@ namespace animation { class Animation : public image::Image { public: - Animation(const uint8_t *data_start, int width, int height, uint32_t animation_frame_count, image::ImageType type); + Animation(const uint8_t *data_start, int width, int height, uint32_t animation_frame_count, image::ImageType type, + image::Transparency transparent); uint32_t get_animation_frame_count() const; int get_current_frame() const; diff --git a/esphome/components/image/__init__.py b/esphome/components/image/__init__.py index 4669a3418a..801b05e160 100644 --- a/esphome/components/image/__init__.py +++ b/esphome/components/image/__init__.py @@ -6,7 +6,7 @@ import logging from pathlib import Path import re -import puremagic +from PIL import Image, UnidentifiedImageError from esphome import core, external_files import esphome.codegen as cg @@ -29,21 +29,236 @@ _LOGGER = logging.getLogger(__name__) DOMAIN = "image" DEPENDENCIES = ["display"] -MULTI_CONF = True -MULTI_CONF_NO_DEFAULT = True image_ns = cg.esphome_ns.namespace("image") ImageType = image_ns.enum("ImageType") + +CONF_OPAQUE = "opaque" +CONF_CHROMA_KEY = "chroma_key" +CONF_ALPHA_CHANNEL = "alpha_channel" +CONF_INVERT_ALPHA = "invert_alpha" + +TRANSPARENCY_TYPES = ( + CONF_OPAQUE, + CONF_CHROMA_KEY, + CONF_ALPHA_CHANNEL, +) + + +def get_image_type_enum(type): + return getattr(ImageType, f"IMAGE_TYPE_{type.upper()}") + + +def get_transparency_enum(transparency): + return getattr(TransparencyType, f"TRANSPARENCY_{transparency.upper()}") + + +class ImageEncoder: + """ + Superclass of image type encoders + """ + + # Control which transparency options are available for a given type + allow_config = {CONF_ALPHA_CHANNEL, CONF_CHROMA_KEY, CONF_OPAQUE} + + # All imageencoder types are valid + @staticmethod + def validate(value): + return value + + def __init__(self, width, height, transparency, dither, invert_alpha): + """ + :param width: The image width in pixels + :param height: The image height in pixels + :param transparency: Transparency type + :param dither: Dither method + :param invert_alpha: True if the alpha channel should be inverted; for monochrome formats inverts the colours. + """ + self.transparency = transparency + self.width = width + self.height = height + self.data = [0 for _ in range(width * height)] + self.dither = dither + self.index = 0 + self.invert_alpha = invert_alpha + + def convert(self, image): + """ + Convert the image format + :param image: Input image + :return: converted image + """ + return image + + def encode(self, pixel): + """ + Encode a single pixel + """ + + def end_row(self): + """ + Marks the end of a pixel row + :return: + """ + + +class ImageBinary(ImageEncoder): + allow_config = {CONF_OPAQUE, CONF_INVERT_ALPHA, CONF_CHROMA_KEY} + + def __init__(self, width, height, transparency, dither, invert_alpha): + self.width8 = (width + 7) // 8 + super().__init__(self.width8, height, transparency, dither, invert_alpha) + self.bitno = 0 + + def convert(self, image): + return image.convert("1", dither=self.dither) + + def encode(self, pixel): + if self.invert_alpha: + pixel = not pixel + if pixel: + self.data[self.index] |= 0x80 >> (self.bitno % 8) + self.bitno += 1 + if self.bitno == 8: + self.bitno = 0 + self.index += 1 + + def end_row(self): + """ + Pad rows to a byte boundary + """ + if self.bitno != 0: + self.bitno = 0 + self.index += 1 + + +class ImageGrayscale(ImageEncoder): + allow_config = {CONF_ALPHA_CHANNEL, CONF_CHROMA_KEY, CONF_INVERT_ALPHA, CONF_OPAQUE} + + def convert(self, image): + return image.convert("LA") + + def encode(self, pixel): + b, a = pixel + if self.transparency == CONF_CHROMA_KEY: + if b == 1: + b = 0 + if a != 0xFF: + b = 1 + if self.invert_alpha: + b ^= 0xFF + if self.transparency == CONF_ALPHA_CHANNEL: + if a != 0xFF: + b = a + self.data[self.index] = b + self.index += 1 + + +class ImageRGB565(ImageEncoder): + def __init__(self, width, height, transparency, dither, invert_alpha): + stride = 3 if transparency == CONF_ALPHA_CHANNEL else 2 + super().__init__( + width * stride, + height, + transparency, + dither, + invert_alpha, + ) + + def convert(self, image): + return image.convert("RGBA") + + def encode(self, pixel): + r, g, b, a = pixel + r = r >> 3 + g = g >> 2 + b = b >> 3 + if self.transparency == CONF_CHROMA_KEY: + if r == 0 and g == 1 and b == 0: + g = 0 + elif a < 128: + r = 0 + g = 1 + b = 0 + rgb = (r << 11) | (g << 5) | b + self.data[self.index] = rgb >> 8 + self.index += 1 + self.data[self.index] = rgb & 0xFF + self.index += 1 + if self.transparency == CONF_ALPHA_CHANNEL: + if self.invert_alpha: + a ^= 0xFF + self.data[self.index] = a + self.index += 1 + + +class ImageRGB(ImageEncoder): + def __init__(self, width, height, transparency, dither, invert_alpha): + stride = 4 if transparency == CONF_ALPHA_CHANNEL else 3 + super().__init__( + width * stride, + height, + transparency, + dither, + invert_alpha, + ) + + def convert(self, image): + return image.convert("RGBA") + + def encode(self, pixel): + r, g, b, a = pixel + if self.transparency == CONF_CHROMA_KEY: + if r == 0 and g == 1 and b == 0: + g = 0 + elif a < 128: + r = 0 + g = 1 + b = 0 + self.data[self.index] = r + self.index += 1 + self.data[self.index] = g + self.index += 1 + self.data[self.index] = b + self.index += 1 + if self.transparency == CONF_ALPHA_CHANNEL: + if self.invert_alpha: + a ^= 0xFF + self.data[self.index] = a + self.index += 1 + + +class ReplaceWith: + """ + Placeholder class to provide feedback on deprecated features + """ + + allow_config = {CONF_ALPHA_CHANNEL, CONF_CHROMA_KEY, CONF_OPAQUE} + + def __init__(self, replace_with): + self.replace_with = replace_with + + def validate(self, value): + raise cv.Invalid( + f"Image type {value} is removed; replace with {self.replace_with}" + ) + + IMAGE_TYPE = { - "BINARY": ImageType.IMAGE_TYPE_BINARY, - "TRANSPARENT_BINARY": ImageType.IMAGE_TYPE_BINARY, - "GRAYSCALE": ImageType.IMAGE_TYPE_GRAYSCALE, - "RGB565": ImageType.IMAGE_TYPE_RGB565, - "RGB24": ImageType.IMAGE_TYPE_RGB24, - "RGBA": ImageType.IMAGE_TYPE_RGBA, + "BINARY": ImageBinary, + "GRAYSCALE": ImageGrayscale, + "RGB565": ImageRGB565, + "RGB": ImageRGB, + "TRANSPARENT_BINARY": ReplaceWith( + "'type: BINARY' and 'use_transparency: chroma_key'" + ), + "RGB24": ReplaceWith("'type: RGB'"), + "RGBA": ReplaceWith("'type: RGB' and 'use_transparency: alpha_channel'"), } +TransparencyType = image_ns.enum("TransparencyType") + CONF_USE_TRANSPARENCY = "use_transparency" # If the MDI file cannot be downloaded within this time, abort. @@ -53,17 +268,11 @@ SOURCE_LOCAL = "local" SOURCE_MDI = "mdi" SOURCE_WEB = "web" - Image_ = image_ns.class_("Image") -def _compute_local_icon_path(value: dict) -> Path: - base_dir = external_files.compute_local_file_dir(DOMAIN) / "mdi" - return base_dir / f"{value[CONF_ICON]}.svg" - - -def compute_local_image_path(value: dict) -> Path: - url = value[CONF_URL] +def compute_local_image_path(value) -> Path: + url = value[CONF_URL] if isinstance(value, dict) else value h = hashlib.new("sha256") h.update(url.encode()) key = h.hexdigest()[:8] @@ -71,30 +280,38 @@ def compute_local_image_path(value: dict) -> Path: return base_dir / key -def download_mdi(value): - validate_cairosvg_installed(value) +def local_path(value): + value = value[CONF_PATH] if isinstance(value, dict) else value + return str(CORE.relative_config_path(value)) - mdi_id = value[CONF_ICON] - path = _compute_local_icon_path(value) + +def download_file(url, path): + external_files.download_content(url, path, IMAGE_DOWNLOAD_TIMEOUT) + return str(path) + + +def download_mdi(value): + mdi_id = value[CONF_ICON] if isinstance(value, dict) else value + base_dir = external_files.compute_local_file_dir(DOMAIN) / "mdi" + path = base_dir / f"{mdi_id}.svg" url = f"https://raw.githubusercontent.com/Templarian/MaterialDesign/master/svg/{mdi_id}.svg" - - external_files.download_content(url, path, IMAGE_DOWNLOAD_TIMEOUT) - - return value + return download_file(url, path) def download_image(value): - url = value[CONF_URL] - path = compute_local_image_path(value) - - external_files.download_content(url, path, IMAGE_DOWNLOAD_TIMEOUT) - - return value + value = value[CONF_URL] if isinstance(value, dict) else value + return download_file(value, compute_local_image_path(value)) -def validate_cairosvg_installed(value): - """Validate that cairosvg is installed""" +def is_svg_file(file): + if not file: + return False + with open(file, "rb") as f: + return " 500 or height > 500): + if not resize and (width > 500 or height > 500): _LOGGER.warning( 'The image "%s" you requested is very big. Please consider' " using the resize parameter.", path, ) - transparent = config[CONF_USE_TRANSPARENCY] - dither = ( Image.Dither.NONE if config[CONF_DITHER] == "NONE" else Image.Dither.FLOYDSTEINBERG ) - if config[CONF_TYPE] == "GRAYSCALE": - image = image.convert("LA", dither=dither) - pixels = list(image.getdata()) - data = [0 for _ in range(height * width)] - pos = 0 - for g, a in pixels: - if transparent: - if g == 1: - g = 0 - if a < 0x80: - g = 1 + type = config[CONF_TYPE] + transparency = config[CONF_USE_TRANSPARENCY] + invert_alpha = config[CONF_INVERT_ALPHA] + frame_count = 1 + if all_frames: + try: + frame_count = image.n_frames + except AttributeError: + pass + if frame_count <= 1: + _LOGGER.warning("Image file %s has no animation frames", path) - data[pos] = g - pos += 1 + total_rows = height * frame_count + encoder = IMAGE_TYPE[type](width, total_rows, transparency, dither, invert_alpha) + for frame_index in range(frame_count): + image.seek(frame_index) + pixels = encoder.convert(image.resize((width, height))).getdata() + for row in range(height): + for col in range(width): + encoder.encode(pixels[row * width + col]) + encoder.end_row() - elif config[CONF_TYPE] == "RGBA": - image = image.convert("RGBA") - pixels = list(image.getdata()) - data = [0 for _ in range(height * width * 4)] - pos = 0 - for r, g, b, a in pixels: - data[pos] = r - pos += 1 - data[pos] = g - pos += 1 - data[pos] = b - pos += 1 - data[pos] = a - pos += 1 - - elif config[CONF_TYPE] == "RGB24": - image = image.convert("RGBA") - pixels = list(image.getdata()) - data = [0 for _ in range(height * width * 3)] - pos = 0 - for r, g, b, a in pixels: - if transparent: - if r == 0 and g == 0 and b == 1: - b = 0 - if a < 0x80: - r = 0 - g = 0 - b = 1 - - data[pos] = r - pos += 1 - data[pos] = g - pos += 1 - data[pos] = b - pos += 1 - - elif config[CONF_TYPE] in ["RGB565"]: - image = image.convert("RGBA") - pixels = list(image.getdata()) - bytes_per_pixel = 3 if transparent else 2 - data = [0 for _ in range(height * width * bytes_per_pixel)] - pos = 0 - for r, g, b, a in pixels: - R = r >> 3 - G = g >> 2 - B = b >> 3 - rgb = (R << 11) | (G << 5) | B - data[pos] = rgb >> 8 - pos += 1 - data[pos] = rgb & 0xFF - pos += 1 - if transparent: - data[pos] = a - pos += 1 - - elif config[CONF_TYPE] in ["BINARY", "TRANSPARENT_BINARY"]: - if transparent: - alpha = image.split()[-1] - has_alpha = alpha.getextrema()[0] < 0xFF - _LOGGER.debug("%s Has alpha: %s", config[CONF_ID], has_alpha) - image = image.convert("1", dither=dither) - width8 = ((width + 7) // 8) * 8 - data = [0 for _ in range(height * width8 // 8)] - for y in range(height): - for x in range(width): - if transparent and has_alpha: - a = alpha.getpixel((x, y)) - if not a: - continue - elif image.getpixel((x, y)): - continue - pos = x + y * width8 - data[pos // 8] |= 0x80 >> (pos % 8) - else: - raise core.EsphomeError( - f"Image f{config[CONF_ID]} has an unsupported type: {config[CONF_TYPE]}." - ) - - rhs = [HexInt(x) for x in data] + rhs = [HexInt(x) for x in encoder.data] prog_arr = cg.progmem_array(config[CONF_RAW_DATA_ID], rhs) - var = cg.new_Pvariable( - config[CONF_ID], prog_arr, width, height, IMAGE_TYPE[config[CONF_TYPE]] - ) - cg.add(var.set_transparency(transparent)) + image_type = get_image_type_enum(type) + trans_value = get_transparency_enum(transparency) + + return prog_arr, width, height, image_type, trans_value, frame_count + + +async def to_code(config): + if isinstance(config, list): + for entry in config: + await to_code(entry) + elif CONF_ID not in config: + for entry in config.values(): + await to_code(entry) + else: + prog_arr, width, height, image_type, trans_value, _ = await write_image(config) + cg.new_Pvariable( + config[CONF_ID], prog_arr, width, height, image_type, trans_value + ) diff --git a/esphome/components/image/image.cpp b/esphome/components/image/image.cpp index ca2f659fb0..e380112050 100644 --- a/esphome/components/image/image.cpp +++ b/esphome/components/image/image.cpp @@ -12,7 +12,7 @@ void Image::draw(int x, int y, display::Display *display, Color color_on, Color for (int img_y = 0; img_y < height_; img_y++) { if (this->get_binary_pixel_(img_x, img_y)) { display->draw_pixel_at(x + img_x, y + img_y, color_on); - } else if (!this->transparent_) { + } else if (!this->transparency_) { display->draw_pixel_at(x + img_x, y + img_y, color_off); } } @@ -39,20 +39,10 @@ void Image::draw(int x, int y, display::Display *display, Color color_on, Color } } break; - case IMAGE_TYPE_RGB24: + case IMAGE_TYPE_RGB: for (int img_x = 0; img_x < width_; img_x++) { for (int img_y = 0; img_y < height_; img_y++) { - auto color = this->get_rgb24_pixel_(img_x, img_y); - if (color.w >= 0x80) { - display->draw_pixel_at(x + img_x, y + img_y, color); - } - } - } - break; - case IMAGE_TYPE_RGBA: - for (int img_x = 0; img_x < width_; img_x++) { - for (int img_y = 0; img_y < height_; img_y++) { - auto color = this->get_rgba_pixel_(img_x, img_y); + auto color = this->get_rgb_pixel_(img_x, img_y); if (color.w >= 0x80) { display->draw_pixel_at(x + img_x, y + img_y, color); } @@ -61,20 +51,20 @@ void Image::draw(int x, int y, display::Display *display, Color color_on, Color break; } } -Color Image::get_pixel(int x, int y, Color color_on, Color color_off) const { +Color Image::get_pixel(int x, int y, const Color color_on, const Color color_off) const { if (x < 0 || x >= this->width_ || y < 0 || y >= this->height_) return color_off; switch (this->type_) { case IMAGE_TYPE_BINARY: - return this->get_binary_pixel_(x, y) ? color_on : color_off; + if (this->get_binary_pixel_(x, y)) + return color_on; + return color_off; case IMAGE_TYPE_GRAYSCALE: return this->get_grayscale_pixel_(x, y); case IMAGE_TYPE_RGB565: return this->get_rgb565_pixel_(x, y); - case IMAGE_TYPE_RGB24: - return this->get_rgb24_pixel_(x, y); - case IMAGE_TYPE_RGBA: - return this->get_rgba_pixel_(x, y); + case IMAGE_TYPE_RGB: + return this->get_rgb_pixel_(x, y); default: return color_off; } @@ -98,23 +88,40 @@ lv_img_dsc_t *Image::get_lv_img_dsc() { this->dsc_.header.cf = LV_IMG_CF_ALPHA_8BIT; break; - case IMAGE_TYPE_RGB24: - this->dsc_.header.cf = LV_IMG_CF_RGB888; + case IMAGE_TYPE_RGB: +#if LV_COLOR_DEPTH == 32 + switch (this->transparent_) { + case TRANSPARENCY_ALPHA_CHANNEL: + this->dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA; + break; + case TRANSPARENCY_CHROMA_KEY: + this->dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED; + break; + default: + this->dsc_.header.cf = LV_IMG_CF_TRUE_COLOR; + break; + } +#else + this->dsc_.header.cf = + this->transparency_ == TRANSPARENCY_ALPHA_CHANNEL ? LV_IMG_CF_RGBA8888 : LV_IMG_CF_RGB888; +#endif break; case IMAGE_TYPE_RGB565: #if LV_COLOR_DEPTH == 16 - this->dsc_.header.cf = this->has_transparency() ? LV_IMG_CF_TRUE_COLOR_ALPHA : LV_IMG_CF_TRUE_COLOR; + switch (this->transparency_) { + case TRANSPARENCY_ALPHA_CHANNEL: + this->dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA; + break; + case TRANSPARENCY_CHROMA_KEY: + this->dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED; + break; + default: + this->dsc_.header.cf = LV_IMG_CF_TRUE_COLOR; + break; + } #else - this->dsc_.header.cf = LV_IMG_CF_RGB565; -#endif - break; - - case IMAGE_TYPE_RGBA: -#if LV_COLOR_DEPTH == 32 - this->dsc_.header.cf = LV_IMG_CF_TRUE_COLOR; -#else - this->dsc_.header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA; + this->dsc_.header.cf = this->transparent_ == TRANSPARENCY_ALPHA_CHANNEL ? LV_IMG_CF_RGB565A8 : LV_IMG_CF_RGB565; #endif break; } @@ -128,51 +135,73 @@ bool Image::get_binary_pixel_(int x, int y) const { const uint32_t pos = x + y * width_8; return progmem_read_byte(this->data_start_ + (pos / 8u)) & (0x80 >> (pos % 8u)); } -Color Image::get_rgba_pixel_(int x, int y) const { - const uint32_t pos = (x + y * this->width_) * 4; - return Color(progmem_read_byte(this->data_start_ + pos + 0), progmem_read_byte(this->data_start_ + pos + 1), - progmem_read_byte(this->data_start_ + pos + 2), progmem_read_byte(this->data_start_ + pos + 3)); -} -Color Image::get_rgb24_pixel_(int x, int y) const { - const uint32_t pos = (x + y * this->width_) * 3; +Color Image::get_rgb_pixel_(int x, int y) const { + const uint32_t pos = (x + y * this->width_) * this->bpp_ / 8; Color color = Color(progmem_read_byte(this->data_start_ + pos + 0), progmem_read_byte(this->data_start_ + pos + 1), - progmem_read_byte(this->data_start_ + pos + 2)); - if (color.b == 1 && color.r == 0 && color.g == 0 && transparent_) { - // (0, 0, 1) has been defined as transparent color for non-alpha images. - // putting blue == 1 as a first condition for performance reasons (least likely value to short-cut the if) - color.w = 0; - } else { - color.w = 0xFF; + progmem_read_byte(this->data_start_ + pos + 2), 0xFF); + + switch (this->transparency_) { + case TRANSPARENCY_CHROMA_KEY: + if (color.g == 1 && color.r == 0 && color.b == 0) { + // (0, 1, 0) has been defined as transparent color for non-alpha images. + color.w = 0; + } + break; + case TRANSPARENCY_ALPHA_CHANNEL: + color.w = progmem_read_byte(this->data_start_ + (pos + 3)); + break; + default: + break; } return color; } Color Image::get_rgb565_pixel_(int x, int y) const { - const uint8_t *pos = this->data_start_; - if (this->transparent_) { - pos += (x + y * this->width_) * 3; - } else { - pos += (x + y * this->width_) * 2; - } + const uint8_t *pos = this->data_start_ + (x + y * this->width_) * this->bpp_ / 8; uint16_t rgb565 = encode_uint16(progmem_read_byte(pos), progmem_read_byte(pos + 1)); auto r = (rgb565 & 0xF800) >> 11; auto g = (rgb565 & 0x07E0) >> 5; auto b = rgb565 & 0x001F; - auto a = this->transparent_ ? progmem_read_byte(pos + 2) : 0xFF; - Color color = Color((r << 3) | (r >> 2), (g << 2) | (g >> 4), (b << 3) | (b >> 2), a); - return color; + auto a = 0xFF; + switch (this->transparency_) { + case TRANSPARENCY_ALPHA_CHANNEL: + a = progmem_read_byte(pos + 2); + break; + case TRANSPARENCY_CHROMA_KEY: + if (rgb565 == 0x0020) + a = 0; + break; + default: + break; + } + return Color((r << 3) | (r >> 2), (g << 2) | (g >> 4), (b << 3) | (b >> 2), a); } Color Image::get_grayscale_pixel_(int x, int y) const { const uint32_t pos = (x + y * this->width_); const uint8_t gray = progmem_read_byte(this->data_start_ + pos); - uint8_t alpha = (gray == 1 && transparent_) ? 0 : 0xFF; + uint8_t alpha = (gray == 1 && this->transparency_ == TRANSPARENCY_CHROMA_KEY) ? 0 : 0xFF; return Color(gray, gray, gray, alpha); } int Image::get_width() const { return this->width_; } int Image::get_height() const { return this->height_; } ImageType Image::get_type() const { return this->type_; } -Image::Image(const uint8_t *data_start, int width, int height, ImageType type) - : width_(width), height_(height), type_(type), data_start_(data_start) {} +Image::Image(const uint8_t *data_start, int width, int height, ImageType type, Transparency transparency) + : width_(width), height_(height), type_(type), data_start_(data_start), transparency_(transparency) { + switch (this->type_) { + case IMAGE_TYPE_BINARY: + this->bpp_ = 1; + break; + case IMAGE_TYPE_GRAYSCALE: + this->bpp_ = 8; + break; + case IMAGE_TYPE_RGB565: + this->bpp_ = transparency == TRANSPARENCY_ALPHA_CHANNEL ? 24 : 16; + break; + case IMAGE_TYPE_RGB: + this->bpp_ = this->transparency_ == TRANSPARENCY_ALPHA_CHANNEL ? 32 : 24; + break; + } +} } // namespace image } // namespace esphome diff --git a/esphome/components/image/image.h b/esphome/components/image/image.h index 40370d18da..4024ab1357 100644 --- a/esphome/components/image/image.h +++ b/esphome/components/image/image.h @@ -12,51 +12,40 @@ namespace image { enum ImageType { IMAGE_TYPE_BINARY = 0, IMAGE_TYPE_GRAYSCALE = 1, - IMAGE_TYPE_RGB24 = 2, + IMAGE_TYPE_RGB = 2, IMAGE_TYPE_RGB565 = 3, - IMAGE_TYPE_RGBA = 4, +}; + +enum Transparency { + TRANSPARENCY_OPAQUE = 0, + TRANSPARENCY_CHROMA_KEY = 1, + TRANSPARENCY_ALPHA_CHANNEL = 2, }; class Image : public display::BaseImage { public: - Image(const uint8_t *data_start, int width, int height, ImageType type); + Image(const uint8_t *data_start, int width, int height, ImageType type, Transparency transparency); Color get_pixel(int x, int y, Color color_on = display::COLOR_ON, Color color_off = display::COLOR_OFF) const; int get_width() const override; int get_height() const override; const uint8_t *get_data_start() const { return this->data_start_; } ImageType get_type() const; - int get_bpp() const { - switch (this->type_) { - case IMAGE_TYPE_BINARY: - return 1; - case IMAGE_TYPE_GRAYSCALE: - return 8; - case IMAGE_TYPE_RGB565: - return this->transparent_ ? 24 : 16; - case IMAGE_TYPE_RGB24: - return 24; - case IMAGE_TYPE_RGBA: - return 32; - } - return 0; - } + int get_bpp() const { return this->bpp_; } /// Return the stride of the image in bytes, that is, the distance in bytes /// between two consecutive rows of pixels. - uint32_t get_width_stride() const { return (this->width_ * this->get_bpp() + 7u) / 8u; } + size_t get_width_stride() const { return (this->width_ * this->get_bpp() + 7u) / 8u; } void draw(int x, int y, display::Display *display, Color color_on, Color color_off) override; - void set_transparency(bool transparent) { transparent_ = transparent; } - bool has_transparency() const { return transparent_; } + bool has_transparency() const { return this->transparency_ != TRANSPARENCY_OPAQUE; } #ifdef USE_LVGL lv_img_dsc_t *get_lv_img_dsc(); #endif protected: bool get_binary_pixel_(int x, int y) const; - Color get_rgb24_pixel_(int x, int y) const; - Color get_rgba_pixel_(int x, int y) const; + Color get_rgb_pixel_(int x, int y) const; Color get_rgb565_pixel_(int x, int y) const; Color get_grayscale_pixel_(int x, int y) const; @@ -64,7 +53,9 @@ class Image : public display::BaseImage { int height_; ImageType type_; const uint8_t *data_start_; - bool transparent_; + Transparency transparency_; + size_t bpp_{}; + size_t stride_{}; #ifdef USE_LVGL lv_img_dsc_t dsc_{}; #endif diff --git a/esphome/components/online_image/__init__.py b/esphome/components/online_image/__init__.py index be1bfb4a00..d1915c7364 100644 --- a/esphome/components/online_image/__init__.py +++ b/esphome/components/online_image/__init__.py @@ -4,14 +4,18 @@ from esphome import automation import esphome.codegen as cg from esphome.components.http_request import CONF_HTTP_REQUEST_ID, HttpRequestComponent from esphome.components.image import ( + CONF_INVERT_ALPHA, CONF_USE_TRANSPARENCY, - IMAGE_TYPE, + IMAGE_SCHEMA, Image_, - validate_cross_dependencies, + get_image_type_enum, + get_transparency_enum, ) import esphome.config_validation as cv from esphome.const import ( CONF_BUFFER_SIZE, + CONF_DITHER, + CONF_FILE, CONF_FORMAT, CONF_ID, CONF_ON_ERROR, @@ -23,7 +27,7 @@ from esphome.const import ( AUTO_LOAD = ["image"] DEPENDENCIES = ["display", "http_request"] -CODEOWNERS = ["@guillempages"] +CODEOWNERS = ["@guillempages", "@clydebarrow"] MULTI_CONF = True CONF_ON_DOWNLOAD_FINISHED = "on_download_finished" @@ -35,9 +39,30 @@ online_image_ns = cg.esphome_ns.namespace("online_image") ImageFormat = online_image_ns.enum("ImageFormat") -FORMAT_PNG = "PNG" -IMAGE_FORMAT = {FORMAT_PNG: ImageFormat.PNG} # Add new supported formats here +class Format: + def __init__(self, image_type): + self.image_type = image_type + + @property + def enum(self): + return getattr(ImageFormat, self.image_type) + + def actions(self): + pass + + +class PNGFormat(Format): + def __init__(self): + super().__init__("PNG") + + def actions(self): + cg.add_define("USE_ONLINE_IMAGE_PNG_SUPPORT") + cg.add_library("pngle", "1.0.2") + + +# New formats can be added here. +IMAGE_FORMATS = {x.image_type: x for x in (PNGFormat(),)} OnlineImage = online_image_ns.class_("OnlineImage", cg.PollingComponent, Image_) @@ -57,48 +82,54 @@ DownloadErrorTrigger = online_image_ns.class_( "DownloadErrorTrigger", automation.Trigger.template() ) -ONLINE_IMAGE_SCHEMA = cv.Schema( - { - cv.Required(CONF_ID): cv.declare_id(OnlineImage), - cv.GenerateID(CONF_HTTP_REQUEST_ID): cv.use_id(HttpRequestComponent), - # - # Common image options - # - cv.Optional(CONF_RESIZE): cv.dimensions, - cv.Optional(CONF_TYPE, default="BINARY"): cv.enum(IMAGE_TYPE, upper=True), - # Not setting default here on purpose; the default depends on the image type, - # and thus will be set in the "validate_cross_dependencies" validator. - cv.Optional(CONF_USE_TRANSPARENCY): cv.boolean, - # - # Online Image specific options - # - cv.Required(CONF_URL): cv.url, - cv.Required(CONF_FORMAT): cv.enum(IMAGE_FORMAT, upper=True), - cv.Optional(CONF_PLACEHOLDER): cv.use_id(Image_), - cv.Optional(CONF_BUFFER_SIZE, default=2048): cv.int_range(256, 65536), - cv.Optional(CONF_ON_DOWNLOAD_FINISHED): automation.validate_automation( - { - cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(DownloadFinishedTrigger), - } - ), - cv.Optional(CONF_ON_ERROR): automation.validate_automation( - { - cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(DownloadErrorTrigger), - } - ), + +def remove_options(*options): + return { + cv.Optional(option): cv.invalid( + f"{option} is an invalid option for online_image" + ) + for option in options } -).extend(cv.polling_component_schema("never")) + + +ONLINE_IMAGE_SCHEMA = ( + IMAGE_SCHEMA.extend(remove_options(CONF_FILE, CONF_INVERT_ALPHA, CONF_DITHER)) + .extend( + { + cv.Required(CONF_ID): cv.declare_id(OnlineImage), + cv.GenerateID(CONF_HTTP_REQUEST_ID): cv.use_id(HttpRequestComponent), + # Online Image specific options + cv.Required(CONF_URL): cv.url, + cv.Required(CONF_FORMAT): cv.one_of(*IMAGE_FORMATS, upper=True), + cv.Optional(CONF_PLACEHOLDER): cv.use_id(Image_), + cv.Optional(CONF_BUFFER_SIZE, default=2048): cv.int_range(256, 65536), + cv.Optional(CONF_ON_DOWNLOAD_FINISHED): automation.validate_automation( + { + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( + DownloadFinishedTrigger + ), + } + ), + cv.Optional(CONF_ON_ERROR): automation.validate_automation( + { + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(DownloadErrorTrigger), + } + ), + } + ) + .extend(cv.polling_component_schema("never")) +) CONFIG_SCHEMA = cv.Schema( cv.All( ONLINE_IMAGE_SCHEMA, - validate_cross_dependencies, cv.require_framework_version( # esp8266 not supported yet; if enabled in the future, minimum version of 2.7.0 is needed # esp8266_arduino=cv.Version(2, 7, 0), esp32_arduino=cv.Version(0, 0, 0), esp_idf=cv.Version(4, 0, 0), rp2040_arduino=cv.Version(0, 0, 0), + host=cv.Version(0, 0, 0), ), ) ) @@ -132,29 +163,26 @@ async def online_image_action_to_code(config, action_id, template_arg, args): async def to_code(config): - format = config[CONF_FORMAT] - if format in [FORMAT_PNG]: - cg.add_define("USE_ONLINE_IMAGE_PNG_SUPPORT") - cg.add_library("pngle", "1.0.2") + image_format = IMAGE_FORMATS[config[CONF_FORMAT]] + image_format.actions() url = config[CONF_URL] width, height = config.get(CONF_RESIZE, (0, 0)) - transparent = config[CONF_USE_TRANSPARENCY] + transparent = get_transparency_enum(config[CONF_USE_TRANSPARENCY]) var = cg.new_Pvariable( config[CONF_ID], url, width, height, - format, - config[CONF_TYPE], + image_format.enum, + get_image_type_enum(config[CONF_TYPE]), + transparent, config[CONF_BUFFER_SIZE], ) await cg.register_component(var, config) await cg.register_parented(var, config[CONF_HTTP_REQUEST_ID]) - cg.add(var.set_transparency(transparent)) - if placeholder_id := config.get(CONF_PLACEHOLDER): placeholder = await cg.get_variable(placeholder_id) cg.add(var.set_placeholder(placeholder)) diff --git a/esphome/components/online_image/image_decoder.h b/esphome/components/online_image/image_decoder.h index 908efab987..cde7f572e3 100644 --- a/esphome/components/online_image/image_decoder.h +++ b/esphome/components/online_image/image_decoder.h @@ -1,5 +1,4 @@ #pragma once -#include "esphome/core/defines.h" #include "esphome/core/color.h" namespace esphome { @@ -23,7 +22,7 @@ class ImageDecoder { /** * @brief Initialize the decoder. * - * @param download_size The total number of bytes that need to be download for the image. + * @param download_size The total number of bytes that need to be downloaded for the image. */ virtual void prepare(uint32_t download_size) { this->download_size_ = download_size; } @@ -38,7 +37,7 @@ class ImageDecoder { * @return int The amount of bytes read. It can be 0 if the buffer does not have enough content to meaningfully * decode anything, or negative in case of a decoding error. */ - virtual int decode(uint8_t *buffer, size_t size); + virtual int decode(uint8_t *buffer, size_t size) = 0; /** * @brief Request the image to be resized once the actual dimensions are known. @@ -50,7 +49,7 @@ class ImageDecoder { void set_size(int width, int height); /** - * @brief Draw a rectangle on the display_buffer using the defined color. + * @brief Fill a rectangle on the display_buffer using the defined color. * Will check the given coordinates for out-of-bounds, and clip the rectangle accordingly. * In case of binary displays, the color will be converted to binary as well. * Called by the callback functions, to be able to access the parent Image class. @@ -59,7 +58,7 @@ class ImageDecoder { * @param y The top-most coordinate of the rectangle. * @param w The width of the rectangle. * @param h The height of the rectangle. - * @param color The color to draw the rectangle with. + * @param color The fill color */ void draw(int x, int y, int w, int h, const Color &color); @@ -67,7 +66,7 @@ class ImageDecoder { protected: OnlineImage *image_; - // Initializing to 1, to ensure it is different than initial "decoded_bytes_". + // Initializing to 1, to ensure it is distinguishable from initial "decoded_bytes_". // Will be overwritten anyway once the download size is known. uint32_t download_size_ = 1; uint32_t decoded_bytes_ = 0; diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index 8c4669cba5..93d070c6a9 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -25,8 +25,8 @@ inline bool is_color_on(const Color &color) { } OnlineImage::OnlineImage(const std::string &url, int width, int height, ImageFormat format, ImageType type, - uint32_t download_buffer_size) - : Image(nullptr, 0, 0, type), + image::Transparency transparency, uint32_t download_buffer_size) + : Image(nullptr, 0, 0, type, transparency), buffer_(nullptr), download_buffer_(download_buffer_size), format_(format), @@ -45,7 +45,7 @@ void OnlineImage::draw(int x, int y, display::Display *display, Color color_on, void OnlineImage::release() { if (this->buffer_) { - ESP_LOGD(TAG, "Deallocating old buffer..."); + ESP_LOGV(TAG, "Deallocating old buffer..."); this->allocator_.deallocate(this->buffer_, this->get_buffer_size_()); this->data_start_ = nullptr; this->buffer_ = nullptr; @@ -70,20 +70,19 @@ bool OnlineImage::resize_(int width_in, int height_in) { if (this->buffer_) { return false; } - auto new_size = this->get_buffer_size_(width, height); - ESP_LOGD(TAG, "Allocating new buffer of %d Bytes...", new_size); - delay_microseconds_safe(2000); + size_t new_size = this->get_buffer_size_(width, height); + ESP_LOGD(TAG, "Allocating new buffer of %zu bytes", new_size); this->buffer_ = this->allocator_.allocate(new_size); - if (this->buffer_) { - this->buffer_width_ = width; - this->buffer_height_ = height; - this->width_ = width; - ESP_LOGD(TAG, "New size: (%d, %d)", width, height); - } else { - ESP_LOGE(TAG, "allocation failed. Biggest block in heap: %zu Bytes", this->allocator_.get_max_free_block_size()); + if (this->buffer_ == nullptr) { + ESP_LOGE(TAG, "allocation of %zu bytes failed. Biggest block in heap: %zu Bytes", new_size, + this->allocator_.get_max_free_block_size()); this->end_connection_(); return false; } + this->buffer_width_ = width; + this->buffer_height_ = height; + this->width_ = width; + ESP_LOGV(TAG, "New size: (%d, %d)", width, height); return true; } @@ -91,9 +90,8 @@ void OnlineImage::update() { if (this->decoder_) { ESP_LOGW(TAG, "Image already being updated."); return; - } else { - ESP_LOGI(TAG, "Updating image"); } + ESP_LOGI(TAG, "Updating image %s", this->url_.c_str()); this->downloader_ = this->parent_->get(this->url_); @@ -142,10 +140,11 @@ void OnlineImage::loop() { return; } if (!this->downloader_ || this->decoder_->is_finished()) { - ESP_LOGD(TAG, "Image fully downloaded"); this->data_start_ = buffer_; this->width_ = buffer_width_; this->height_ = buffer_height_; + ESP_LOGD(TAG, "Image fully downloaded, read %zu bytes, width/height = %d/%d", this->downloader_->get_bytes_read(), + this->width_, this->height_); this->end_connection_(); this->download_finished_callback_.call(); return; @@ -171,6 +170,19 @@ void OnlineImage::loop() { } } +void OnlineImage::map_chroma_key(Color &color) { + if (this->transparency_ == image::TRANSPARENCY_CHROMA_KEY) { + if (color.g == 1 && color.r == 0 && color.b == 0) { + color.g = 0; + } + if (color.w < 0x80) { + color.r = 0; + color.g = this->type_ == ImageType::IMAGE_TYPE_RGB565 ? 4 : 1; + color.b = 0; + } + } +} + void OnlineImage::draw_pixel_(int x, int y, Color color) { if (!this->buffer_) { ESP_LOGE(TAG, "Buffer not allocated!"); @@ -184,57 +196,53 @@ void OnlineImage::draw_pixel_(int x, int y, Color color) { switch (this->type_) { case ImageType::IMAGE_TYPE_BINARY: { const uint32_t width_8 = ((this->width_ + 7u) / 8u) * 8u; - const uint32_t pos = x + y * width_8; - if ((this->has_transparency() && color.w > 127) || is_color_on(color)) { - this->buffer_[pos / 8u] |= (0x80 >> (pos % 8u)); + pos = x + y * width_8; + auto bitno = 0x80 >> (pos % 8u); + pos /= 8u; + auto on = is_color_on(color); + if (this->has_transparency() && color.w < 0x80) + on = false; + if (on) { + this->buffer_[pos] |= bitno; } else { - this->buffer_[pos / 8u] &= ~(0x80 >> (pos % 8u)); + this->buffer_[pos] &= ~bitno; } break; } case ImageType::IMAGE_TYPE_GRAYSCALE: { uint8_t gray = static_cast(0.2125 * color.r + 0.7154 * color.g + 0.0721 * color.b); - if (this->has_transparency()) { + if (this->transparency_ == image::TRANSPARENCY_CHROMA_KEY) { if (gray == 1) { gray = 0; } if (color.w < 0x80) { gray = 1; } + } else if (this->transparency_ == image::TRANSPARENCY_ALPHA_CHANNEL) { + if (color.w != 0xFF) + gray = color.w; } this->buffer_[pos] = gray; break; } case ImageType::IMAGE_TYPE_RGB565: { + this->map_chroma_key(color); uint16_t col565 = display::ColorUtil::color_to_565(color); this->buffer_[pos + 0] = static_cast((col565 >> 8) & 0xFF); this->buffer_[pos + 1] = static_cast(col565 & 0xFF); - if (this->has_transparency()) + if (this->transparency_ == image::TRANSPARENCY_ALPHA_CHANNEL) { this->buffer_[pos + 2] = color.w; - break; - } - case ImageType::IMAGE_TYPE_RGBA: { - this->buffer_[pos + 0] = color.r; - this->buffer_[pos + 1] = color.g; - this->buffer_[pos + 2] = color.b; - this->buffer_[pos + 3] = color.w; - break; - } - case ImageType::IMAGE_TYPE_RGB24: - default: { - if (this->has_transparency()) { - if (color.b == 1 && color.r == 0 && color.g == 0) { - color.b = 0; - } - if (color.w < 0x80) { - color.r = 0; - color.g = 0; - color.b = 1; - } } + break; + } + case ImageType::IMAGE_TYPE_RGB: { + this->map_chroma_key(color); this->buffer_[pos + 0] = color.r; this->buffer_[pos + 1] = color.g; this->buffer_[pos + 2] = color.b; + if (this->transparency_ == image::TRANSPARENCY_ALPHA_CHANNEL) { + this->buffer_[pos + 3] = color.w; + } break; } } diff --git a/esphome/components/online_image/online_image.h b/esphome/components/online_image/online_image.h index 017402a088..e044b4f390 100644 --- a/esphome/components/online_image/online_image.h +++ b/esphome/components/online_image/online_image.h @@ -48,12 +48,13 @@ class OnlineImage : public PollingComponent, * @param buffer_size Size of the buffer used to download the image. */ OnlineImage(const std::string &url, int width, int height, ImageFormat format, image::ImageType type, - uint32_t buffer_size); + image::Transparency transparency, uint32_t buffer_size); void draw(int x, int y, display::Display *display, Color color_on, Color color_off) override; void update() override; void loop() override; + void map_chroma_key(Color &color); /** Set the URL to download the image from. */ void set_url(const std::string &url) { diff --git a/esphome/components/online_image/png_image.h b/esphome/components/online_image/png_image.h index a928276dcc..d82ff93149 100644 --- a/esphome/components/online_image/png_image.h +++ b/esphome/components/online_image/png_image.h @@ -1,6 +1,7 @@ #pragma once #include "image_decoder.h" +#include "esphome/core/defines.h" #ifdef USE_ONLINE_IMAGE_PNG_SUPPORT #include diff --git a/script/ci-custom.py b/script/ci-custom.py index 81e3da311a..d5d3ab88c8 100755 --- a/script/ci-custom.py +++ b/script/ci-custom.py @@ -58,7 +58,19 @@ file_types = ( ) cpp_include = ("*.h", "*.c", "*.cpp", "*.tcc") py_include = ("*.py",) -ignore_types = (".ico", ".png", ".woff", ".woff2", "", ".ttf", ".otf", ".pcf") +ignore_types = ( + ".ico", + ".png", + ".woff", + ".woff2", + "", + ".ttf", + ".otf", + ".pcf", + ".apng", + ".gif", + ".webp", +) LINT_FILE_CHECKS = [] LINT_CONTENT_CHECKS = [] @@ -669,8 +681,7 @@ def main(): ) args = parser.parse_args() - global EXECUTABLE_BIT - EXECUTABLE_BIT = git_ls_files() + EXECUTABLE_BIT.update(git_ls_files()) files = list(EXECUTABLE_BIT.keys()) # Match against re file_name_re = re.compile("|".join(args.files)) diff --git a/tests/components/animation/.gitattributes b/tests/components/animation/.gitattributes new file mode 100644 index 0000000000..ff9fc6f1f1 --- /dev/null +++ b/tests/components/animation/.gitattributes @@ -0,0 +1,4 @@ +*.apng -text +*.webp -text +*.gif -text + diff --git a/tests/components/animation/anim.apng b/tests/components/animation/anim.apng new file mode 100644 index 0000000000000000000000000000000000000000..927af5eb05a94ea8b1cdab493d2bfd8feffb7eac GIT binary patch literal 12626 zcmaL7Wl&sA)HOQz0E4>^Zoz{E8(f1+2*F(jcLL1d7BaX53+@^QCqWV{I0SbH4#6SV z&GWwBt-3$Hx?Od8b@z{b>eSj*XYI8+R$EgU4~H5D007{rswn9GL!18|Am+c>eKSq} zA7Hzy7<>K0{{{*mB7oxG2F24+US8YL+8O}x&+$p>P)Cy`jFur$oQw%0CnuLJOe6Y0 z_=QLV!GVq~5LWlwGXOh)){ltDq(`Ixym-rX$v0tGPmZog)c>lv@I#arFE&d|maYBQ z$K#*%61Yf}x1*G!MTnu_SMJ|--@P^SK$3e*MC95@#yL4mf7V7sU0<;@SP{5Z8E&

N_}*~mQ-&q49+jI&#fYziMoRGMtBp54qp^tYDju55&-i%vgKM*NcE zAk(+<>;`x5 zT~uC>gL%zmb>P^YkOFe2>SX;7Fp8zy`Iv(2!M$L-(# z0kz%#p8a?9KOFwI_@99SpaK9a3VJ92078JOf~>xO&T+1BJ*@%NK$(4Dpj}{x+`J99 z8W`QUpG#J?pM65mkf=$!M2i?l``h++j68@uX|VQcs#R?38Q9<)fC=gx3V*?*PF0yY zSQ`#;IL#sGsz(DLcm=~r>yyxxV)>X%Ec^p7$$#$H zgO}GguUqrStFw*JS2)4DsAZo3p@_|KwdZG2{(b3S8)12DCwxGqYp^TuF|Znc!LWtS zrD9Hjlj0U^kWzy7XK!1m*m|#6oqBZLU;aR$$e>NrK`v?{Hp^-7nDSglX_!}i-cZO} z=bLZqyv0Z@Y+A#GNf!=dc`Ap{_QmEbyI_`04viHYXQh5KwuvdZ49H^i;Z+YF=+^N` z%+jkdWZmDH6l6AbdN%f!?NKUA3APZL#}^^Bpe_YWYo4ws!8yhOpbX@I2y2XxSi=Qp zLwvTKyT=Gf8cN-RvxqWUSX@YDdngv4<~&TH#31$oB5fOi=0;hL>uE*OWL@-)EV(bU_T)T||m+;yzn+KG?tkK?y=i!-?|Dm*JZ zR~c<$$3FpwYgSy{aiOBg&|f5oDwTXu+t~owDjt_OOAZi zzprv1meA3$pCbg%gof9YqdzJxnhkfV_5Tb6gHdkVROOt*8{erN-xG_a<&4sg0SXM*#Y>sphg(D+64 znEZ%h*0f7Qw5a?u1;3w?zL@?RpM zCkMmSTN3EI)Wnr_YD2aa5~9M25V+H3}^6tqU^OFsSAoOAej-Yn%< zR5+5hMXXDy+`wV>ip9T_rh5bX5TG^_B5LnsI1liHDuWP_whSv8g>i>TTRdbDKhZd1 z*&g^TcB^IuOdn%BpXaRmjN_XXX*{KT2^VaizpA{ZvXxs{EjX8Z{yffcPt!~8TfdUF z4%lgtl4wnVEz41y&3X%j#va8u9cmCS60xIC(PJuz?ClX*GkMp6DhpH??L zE2vHtm?3@2Mj2!(I=|J{6I4rabosDO_xHg(v@t^P_)?Oqj(wOqJ&RZ22(9?|h_k#q zL=!p!omn^6x|VOgqN;Qpa~+DJLylpf>j50zr(a|OR@7QoSC;K0x4a|m0Y6;ZiSf0S zqze-03KOj2PoIlGCl@xQX^6Yl%SRv5^VUzpoZS+Q8XTXvE@*>gj_!Nzy+Mf>sdVqU zKEIY_2O#BJ{PD0wOr4O0^vS2j} zOBJUZV^KBrSKhmb?xsMm?(1I0(t>9^r18Fa`Si8G=`dPK+|bzBx7^Y#-Z3wwT-=?8 z6=p%&{+Z`~VQ&$-6-9H!R>^6@6tQvPt7Lb(p73+K7zkO%Q&uqULZREFMnTHT6PWba z?LjR8u?wKfFVdR67zjCf&st1$Zx7uZT2sl((x=zj*XOguy%Q`j?H~2#b2+C9q-z9p z-YeRQAYa6VUdiSz2+jiO37JR7>q0%}J|~_(Db?g_jjOCBn+eHTa*2dQ;e)2(gF2j; z!Nc+spBDRgtI_VumeRLlJU=xf3r`-&A<}j3|D0Nc?TExFrGZy(P&!CIwHaF;cs^Im?L* z&~y2KlQ*slRj~w%VZ&TDV-+rI@;7w2G1Y=r9Q?Em^jhCmQrcU9_%%9cJ7hF7u|8}3 z6;t37y6$27D~2u-erzE>ubUvBJtco6OBv4)qe};~cn(8b*!n=BV#e=-Ld;O1l@qd{>;Hg-;kKgJSu)^5M%OJ@x|48^c(M%jHQx7Z; z)E;KH^tzRnIhz1F={(( zgJp%H0t*pD6+;_+34i}Z;4=h0K>>`bXS;(T*kC}O!2f(R6K`Zpg2sXycb<3`rdz7B z=JHy*#b~A1;D>p6B^Tacjwmw&$U7H^C~NO>8emj6QR0E^S$GrTp26fxqy0}1aLb;g z_T*_nrj+=qyOM`UOkIi{l=C>}j}$T4$EGe2-+&MWv>!Z^JiLNSCfEqoRt93MBn-QE z5Tv2-qnSB)A-wAaWs%%ayR7hGvE;Uef%`yxNQ?U+!8X({;bz9@kEe1l_*XCLS%

m9s*zMUB&9i)Vj-aXg1Rr|O2;S{r^I>B3s zz|%^>Kl#^gf{z)aHz1{GeF6b`w<|Yck3ybz6$J0wY%CXDPDxebWUIu+dCk>Olj563 zM{m*l@$tnpf!jO-6?}+CVSp|fkZw@gycSj_iH>th88{hqaN`~k^XVrJJH@OuL>1!O zF?54D)7y&+ov4H#G1mbQA!)YCu;Om=*Yu60&48w^;ow7ETLWz71I95}^wD|Kn%;o! z78%;U670w;S&GH6;_Q2=CFD{mI5Rq8WtHpKD_OLNl=UHKGms6&!V?yY5%sw|W82te zYTQGkJ&xBYD@Z^?vOOD&fwnVE5%B~Ymm1Mwv?#h=JY_~1YSE}>U&MiY)2*<|db9Sy z8zY`?K*%_*~QZsy0EmGhBtqLB!|drFOS+b3VR0&+UF$m!+NIle@hZ0I_nGha|SDaMF-@+ zRiP3I?9AvyG`?+VDUN>meJGiHYk*G7Ka8Fg@{yc>P5r~ThtbQ|UW(`8TNTQ}?)cXU z{#moSTjeM9pnG-nU2L<2=R`skZuBspAY4>|`$?ke#5Z4QQR@4x9=4O;xQEElFy;yD zu;QpukqOf8GIvjeCSOu5w$A9ct9=dCl<-U(6x^zO$fGe%cxH8yx8R-!A?0U~K6WPk zBKq`G+$OegUQKEx<#m3UAjySH_DEN4$iXJv#>;4X<)<>V*nE=Q6qfSn;4Z^Gqd70L z7q7y?0hsB32qPZeD2Mm$ydIR zRi3=I&P0Dt7sp;CPrGqIT;J|+9kM3p9mGZq7 ze!M5VA9_nHUEkeiE1yTl{4KTXb2Ulnhb6d~eu?*td@+#iA$&!EGE10DhKzWf;c6k)VwU)<^*E2d??dGHkEa544Y9LXrc@C+*J1d-UyZg^69e0O(lB@ zFZ8TQmD3#k$@!B>=V~O;GQyS4Amu_Is0S;R+qHZidC#|fR!brYu_h!E`REe;Er(n2 zixw3M9|eNHzSz>;VyF~Y8($DZBYwgY!|cFRAUQNb$ml;5zl>mP1a%t`y&>-H2<$6n zh_8HETh?_cDXD&^I7@6~XQ66>nXE8J-ozo8<648`NmHfp^w;iA^r!;(zxSNa0 z3Fd=$iSIU`+%oSGMvkA27;($e0Q+@izd^n1ifMZdoUj!cqLT zuU*ssKAw=S$UByDY7uV3tzUJ)tp(^jWzq@yT*1;rT>> zMe2woKrs>CTCntht}@UG(xwFRTx81GgVL7Lm=zUAH?IEF8@IjcdNc2m<3%!F#c9b? zDXE70y=E-S`@|o3zO*pG^EF z>rRDY(a;Y-qepYgN|Vr3QsA(HJ|DWuIucHSmzTh?ME`Z5?1%D!m_r=K91f;8Ob$$& zmpofNwsa-uzDUai@5I&_=@|}~JN3d@YC0%7(P`Lu*n>VBLvOw#jR0856Q2+-!vyS@ z=EtDC>`o*rreRuaATCXoZ{Gd_h`6J^YOB^Pkdr-I`?x#lYW5-f}93P4t;t0C4TZYYWbVK!D0FX(dZ@1 z9XxH5{uf8#DsZBg-T>p|5kM*TzD#VarZCu=l5oYjFtpf}IzY|*7=v%H-!af&PX6<8 z8UF#J?ejBQ;A=`-`@*b-e-6(7>+GQXTmN62o%?C-J^%psgPo1+e|8<}f9}qb7uf*O zk03h&FdF8-k9F=nMhM2%AHrx#ok;GT#%(NJTO6wnE)N%e1I@HiVNEMqP%;P{%qQG@RX&GudC32ZJ}?5E5nO?Qv;1GDn&{9%X53FXpOxgH(o z(WaTO1cvr~Zui8dvGh%P_o@>Qp)?hLqj(3=DtdR@1ECBoH2&u6$l<`(eEelF+{*nFe4~%tu&9X^<7y?w83AaJwS^p~iZ6%a`3C++yEN=O~<3k4q)^@k- zO?jX5YVto@1!Iyfsv=*X9=beww z&aR#*7lXPXs?xPlOud-9wZq^akaxwH9|W&6*0!YUeKIC8__ZH4zVr$A-u+0DCP#5M zr&rvTPar5ElrC>-y1Xd^6K$x&HtPzE?*NLh2Smw4io!D(!~y^}METDGha}Q&Lu7wb zz1vi{X!BVkeZNET-@g3xkTu8G_%!%e$}PWf;;A$$WS{h>u)m7WM3_4(`zOC|JL^<1 zMtTpQtWs%K~-;v6nTA@=)UqqdnXgl1HmNWtL2aN&PE`vyriX1bMp1JUCXTt(c}o&D95M*diG z?)+EGq_4POL*FtwHhsCOKz_=56J$wpO&S{Sbs}olq5!YftXT_s5)w{(bR~q91E=XCkuKig% zb*H{0lqC3gvdJ2X>V);Ot1?1%fCmtSlltelQ2E-_}&HT}~7j z>#TO1EAlSzkN0@Yqa)!TYCnyVA6p-Czy{g>{T`36bytr+bcDt<;4pKycQ+Lir;4@Q z>b4lUyu=3wZz1YT185tM)Ck_3Cm7R3>lbW8e|Vr+<-hp@J*-^hMNx$iBhXp?2WmM{ z_A`kQiU0plLCI{0DyRs49onM~DFxWf=Nph9uu&Z^{7%q|ts!jKtp6L+M!|v@!3!AT z(#EU^G*^TCIN|hMwJTr&r-YM8mXqtE3bJw-%X6qheiVzC=~4_6BhFA9@mNu^m=M)p zv5?6yZ$gz;HWVs8L}@))f>>oe>y0YpEx_XnqKltZ7!5*gvZcH%d|9XkL896cCP1b2 zP#f_$m><1~A$q8S)Evz1yK&8YC<}?Q%0Oe7O(A-*&WxwIVohEh=Ae_CC*+|!7ijY? z&tT5DV4HCTHCfIOH5mrlt9eZwqe0S91qU6x8i26P9IvcEqP~3-7iRX!s^mn;B1K<& zHgze42pXjM!v`nX)z)lm0L6g^H}J^tN(UCY~J9D`h_iC^Gk)>)4{`Jd4D~uDOZO)mOMtYGgs!4MASE|IhG0C^f zDNj6N`}P!^c_{ToTtg_)i$NzKd)~PSGt9|Gss8@wi~_o44wLyvV@ zukJ+qVg6~ziX>J5OPFm(G!VFvY^bYe^-R*|N9mf{*Vm`5Wo;mVdOrb{Tj zaNwdhlC%~geC95U*h!6xj_@Qaxg}0;=@E>{<9zrw1wjhVAE{uvd}Nr!13a(=4E45 z>gaR}%9WtpotO&JdE~dw=jU6)Uck)2+=oV%)pP~Lg-)#QcU%+0zb9{;m~m_`qzkhf z1I%#OTCNdBUFii%9;T$}oeq|VYIPhh?sD5pL8PbWAD6w7e-=|9V|$amtE%5W-_%}7 z{irj$>?|IS>kl>}Y28j>cwbS^Vr;3Zy2r8iUXbfW>}GC_BunKb=he5Q`SHu*iP{-o z(?* z!^}s3P}(@~?Psww$GR2s8SgHe8KUlLv4(h@t9HIUMYEjNv_{N-l;gD9L2WE^7_C1{ z*v)S@Dv`j?*tw57_c!}dfLy`DGU?OxtY%@`A#pw;)5$Zqf2}{iZ)rN8Emtz+vh7ki z9=0@UvBv8Nq3-pXO*?&3fHK)SQGA&Zx3FRFV!N=Wu03bEk@o^hem|&ScEMI@D|d;g%To4H$j0vGgSZ?!Cqa;_3YXHE_0f#3*z#+F(!$kmi8mJRAJu zr}Iz(EkG)mB9u_JD^-^!b12ynIYi~v;IIfEibpMj3W{PEtIG0EaBSeU6dR{ey*hvQ ze3kvR&?n6CL1tZ08NSk#jeg`LkOkj**6hvHp1$)v8(0;4uvX6$crW9x-NBsAW<37? zk?;RCYyU6uom}yj>tACQ{r|{!^#A0$bM-p|vVq-4Nuis`>+9hA)-FH0lbVm2;EEEf zgb4JMMIbBnSIR=hFOb`Hw6Bz8&W!K*Lzsq{zYybL>yU)$>u+M+7Q)asw{XE6l!{5n z<)t9Ueczhr#rw|RKeOhtjIs#0Z^m-6gzW3q%z|o~Z^VPXTQy`-t4kzL5bv}tPmN-4 zg&U4Js7TVEk{}wq8D;s~F{k#5bB7DkX407CSG6MFkB3&LF(j6$3L^X^>q_=gbg?#N z2Fg{rp(82yUR?CdE8nLO0H7;&6r4{GC{2|smQ=6*Lg4e}kZQ6cnO3#Y*^E-scIjCE z`_P%-%GynG@9DQM<0AjO4aXKTh($%nv3lXNgFiBr(gDhD_a5iaAT0s%>dv`Et97zVBbdk2Y+H>u>B1%C!;`zSyvr z&^ek1HR-i%ya_x|ni|0?F5&~y9y+}-WV&YzV@gM5&@e;|ouUN>bEx7=iicZrWtpaa zj@A4rg(4#o{AsxQxqaC6wsaUORw^hoVBq_k*F=!!q(3Mt%bKg>sbiyYL!yY;yQ{Qo z>UT#;7tLw%oWppFzTJvwLD6M@hKl`MM**Uw*e`yXo!gNP_`$1ThV2$aUur?M<7{A; zyjOQm&CAuYkHyt-7tPgjg_5@RP%!NF*pN=b)w07f6wc)RK9!Z`@+lo_QgizEvdGHs znw!Zr23b*na&9_L)aT-Oqa?Ssgo2-ac#wgkL%kDH6( z?E92-iv26x^VO4G_lK$E-3bv_=9bwnGR&DkkR%+j|Kb<=}KMB)z zutYA}Exvn)5HY!UCN!y~jrD9`S2-a`GmIxYjPlpF&?pRA|knJ4AbuO%P5#HR#x&bpMLjg^|8)YHiB z)a&koqYUz%alQNhr9n4VdpIAXDI3l`OTM~WvPzW!ILCu2v9$FQ+@h5!8Z*DAbfgOf z#~$G9WOXK`(&j6hR^@!TDlSgW=Ae->?)_p$*2%uPu`t#4OHJo(ZFT{Y+<7-wWXo?& z9|OrWMRZS#jw0j-wy`r+`(lu!NdWfIGYSE-@)4@}i;b_>Cl+yvxl_w8*pwJm69X|g zc{uMw0hL`Q?4UZjjSDpYZ*8x{%}JSZwHA$QO}!V*rTAVka$C~v4Bj=35fW>yRi_Ma zBf46!SlY174>9B?!ff-$Zry*xmDJSplpQdk2SV@1m1ja;E^_QFKd zG?UEDWbHMR=Q%CSUcSt(lqc8!XgEXlM$PZ-!Mh{+l?7-sC{d60DW0v3j6e+_hRnm8 zVl{b9tHX8dInh#U8E?U&sJ*@Uwz+T8MD;Dl<0sN+fQQ78!g_=xEC&IM-|v%4zfuh3 z`}x+>BK1+Kb!C&hk$$&U4_btyvNhEz>dM?PM zk&YA5rmdv((oxG8d zGJhE`7zgFFqGCHOTrN9z6Bc+T{=oEAnLc^Nlg}>ho*+Wb1Z%KzM6lh+j55L!U6&dY z%%-)+j(F;$e2G|2qeJOAyb(qi1wt8><>2$5oj$@|hE16h)}UFgToM2uRXQN;Ixquq zA@FxUtp4nKd40&G3m@$0lyI>7MFN2dFa9roHylxwFBgG?0C(D6odm28CW=de3Pgi7Oil95_w~SfHhR?Z~;ug z2uLA($_OlQN_;}8f(G72g;jrmf5BzRUc*M)%zsBK2>!)-IHL@Tc|nTDOK>J1Bl6&b z);6yNzMw8GZf`fk_1#}RD$5K$J$d0u&f??Foq{- zOJf4uVRHJk4@+S!!@zr&@iol5GNM4@H6}8_8P@7*dQ5}(@*U#Z0N=K^eN8tGd7(|; zc&oV*XUPnP%9n%UeR6ys8M+|`1l!US2>HeaNGkahCjx%Cou}dlNr<%Q_)rcbz1{e6 zmjMO;c2x|K?!~jA{54aQ|JIQ}B}82cVNx9=dL=w<}{VM@7YgoYtWk__;Mt9vcvL4}3UeTwm_oxVq%Up=q_Z3PgeU|0?7}a06Jf7DO1!{=D7qtxGoP0h=!I$@#0)evTvJ%9B%JN5`dy(q#jkgzADl6m$P+>~x1g?>D z#Q#CifApq-E2Z2OETK7z5^E!cuDRkeKEsAsbxC@uqF&L0=tjdf@AZNClRHOE$c4dD z$;W0QS2k`EhOz_25Jm%#_6EY|duwnwGC2|Ut{(n}+@P^5M#zTDPl{x3W&pBSpX&NP zh5_iyk$Ytv0)-@7`SidZ1d8=!=l2@@nYEs^#DJ*n=K;+hA{M1{0N;#&`CNR}dTC zc=+~!Jo$(tkB(`$xVbZASYjD+QV&<~-nGL0G@gkoRArBbH6_7`bxXKR+3H>jk6fNi zjC{HJKB_Ekg(lPX__49`lSSZ3NDGe*9*vSx1Cj0F)cf-Nr}ra`9hJ@sgkaAmVYYVx z2mKiR9o+kHd|2jVlc;idr+&x77f$s4nHLGvCHh@Nt?;tC~S)t(rVNe zIA%*l0VRTPH~R4YZp<5a#L`UN0mRyyEVqcBU~R6dWQlIgNtk^4kXkdmR4WV*JUbm( zav)e9E4~Q!qk$f|iMZfXU`4f%n5A0Ad+RPQJ?O`3oB%AuFhwdQ3)Us;zpv0%8R zUT)zCb9WTuL(KW~>$owV3Wzzv*^shjjX6p!STndt_#*Y%Yo)BnNux>-$n;FndZ~@ z%MHX)jMMB@?gym>xbFvlr{s;^CPmLf)aXFQAe*V9r67h#&#%3SpNOx!OPCQCcqi{q zUlQ!Uti~IsbN_@dW1%lm^fp*w?CY}g*iIr+gC7LS@EDxo@wfOZ*F)mPrfFh zKhLMwQ|hXKq0WmIy%;HxpX_AwjuB<(GcS(a+JyVtO^>|0ZCn>H8t3Krwv=@2xo1~S zqqSZE4N}Y)QpuntSMH}qTlY^Ky zJs!7}uQ zmg7(R9p1UL!nzC(_myJ~cCPQSr<31fwF2Wvys{YdGAT8A6ar1(QD%8kgtc+x&ktxv z+%c*?sbD#f97aTOzE~1WsNk#W@3(A7e6ZEkPmW*l^4L_GE!;XQ4oN~4Cbdv57RD-! z0Rh#*K4+ejAHAPBvowb78Tx!vH+ddouNxBt9RF1}J2Ldt2=Qptd zkJ4JvV6?fCPN|)awlCrYdd1vPj5{4Sj)(Ku47nOnfHRPBLxPmcXG#ePKkA$MD)}=m zW#4?If6dvV|KkT>xWR)ODe-qb^+Y@3y4FB#q;U&a*hW%mNV@OdF^(;cd?x6${`+2k z&%(8^LAAuA?KX!FUEie8RO6dsGxp;T4PG?oYQBsnX&gEei>VwS4c@@ITQxuAKPMYI zD0#W;bN-|oqX<#aAxk>qQt^}Z1s0& z`|Ye?-R7iX?ZyySN6U8wmE(Wop^DG}}K7byo2xEm2e5X>wH{Wi+*P-Bhi}Lfu0i0dvVzYpf zSUj}ug`}k?Ox;I8{(usd&nA;C;RatLPuqb+Rc{tM(3tt;{ zZbG!cXUQ7pS~uEwa!DdvGiN%+FC{vdx!I3`?_`zwRPHWMj0L<|P6Bd0qxdr^jqz}E zGvk}si7_7KtvB-cx_dgu)blL8m6@cOOMGaZZ5YkK$Lgk5Lg}wWC(@ zZ~#BRN!gCnmIrif@tT;GK@FaTz!3`4<(Va;4C2|B4 zhyf(xIU?ySi4;yG#uJHQBw`GSc%Dd#AdzCoq)Z|)g+$CG5w8)+sbtbs5-Ep7C?yl~ z$w(fFoJ%H^lE@V#(oHhCf=sR<5o-`aHJMyXCe1R zc(7WsDMosGRkihv6tE<;0`O9+v*das9QQE+RN+TM$Y~Qlwa)^~jJ}SJsh+l;qJp9l z8vxksxV^_IyaE6oo<81KgP4WoVKL$eKr!1mfCoyp_NTmdnwS{=^?lF3Tb&2!+_+-v zulxNUTPO~Wr|bcMNLZ_;y_dHShWB9D(BH>v1z*N6ue}TQ7ywWahUL7m31axoir(%| zJhFnF|HR8H*xSrh2fH^e42wDcH*ELcu)T{n+XL%_-8zu;IPQy0Vl}O}6m|4GcmOLU zu)h#E1x$e+&<0{aAM64;Km{lQH7r*F8-Wtogw?=bj9;-W1dPE6Y^*(&dx1dU4P1dU zZ~;C*4%7N#)*Z3Z3DY}bzvCcqWdX2pSo*hPPdONj{!h2KP-@!YGdyZPXb%t<6F3Ggg?26BLKi1gim$f&0AD$VOP_+T& zpArz91yx{cV;BcbVsDn=-KwuI)0Ew_mQ@>VnqgS7=CD{r*fSow#p`TwoI8b2;aQf^ zy_(6cx>LQ8t%sZ4C~N7u=F{m~BabwxVyfF4n>aWnbkovA8tUi9KUBN-wlyryeruPv zV5jwk)IqQt4@1O6Jv4ks#4s5cXA2zeZc>b zrVt)!X!vCy!4NMyn5fI=I(TW1$ihI9p-^QrDt#n7J1)1Kt`#x0zi%g^Dx|oJ-}aWc zbecno>rlE&LGe(AL#&z;{{f*;9YmZ|n|<SlJ^!_le49(tF*mnmBp6hTr3Uv*9|;fop=dnNd1f)6M;o zP%Z5MLSdA~HL2Cf0MIREQrG0YX}6`xHOg^bjnzYLW2J=}XVWKgAD1x3A4ZE%WE!Mh z6363$7RQ_)hPRE4JmNjH?N-j6w!Y8{gM3Vdo5Az4P4Qu|8BwKtg=JNl+);|I`GSKP zH?QDLE;JTOCDhO4+D^3;wQV}UfGY-_460jI_2Noi86H4qU+T!8uF&F=pt`itx0c_@ z-A6InTp+qvunM=;y4RUhRJ7@mr z!&QIrd$TL*;?xIU`-aV5+-s>@x?>Nt2J~6#RBS1UI-t1)98?B%AFJF%?hYQ?k@$1? zV5e|hU%`pCg~2nTlj@`DPkUy2qQhGkzt%Zd1i!c+JXQPFuUYf{t5UyX_qv~Hh>Xq{ zzM7h2iLpNiyh=E5vuf`2&9lps&pF4pvnti)A57jz?ftc2d_x3B5?azcyVTLlZdjhR zm#>*m4ao<>_?(hGzIC{iTfRTDr}9S*;0xxIt0qb-U&A@+k&v_+wz*zjoF<;Aj} z&FhCey*!ZQb%hp8kt)SF2NvLHPuVIvRS|#Mo+->OWF9}`<>6-EEQk(2{TbNqJ|K{X zr^Gxemzs%lH5(X|h|$uHt@QCa-6<++DJ$6XE&9r%E}?ckgT0~c$yzPBeC>70J?S&C z!Er~|E4!+a9(X5Rzbr*69x>2YsZ2a!*pC#x*OtzB9b-RuLy7Xf#ae`wTx^)T@fulY zE7BP@v%yIwl>F$p8&6{Y=`Uo~RwJpJnG_E+dvn)aBX`Z@q~15Z63t}xzHLFtamq&q zpQBqitOZzEA6kZ|U1U{jeY2y#OI}l(bAF;A#~te~G`z*W*yPtv#L#-1%hs=IuUu!6 zGwoTOB6}H+f?|CRyb0nj;(OL%3wt2@42HkW`<5%vFE|z*KA7i*m}$0ETM)yOn$!!7 zvuY?--(yS6dB^EgzaopG|TisA!2ut)OrE)(nc%nXEX|0}|$>c3md;1)s zaF_NTzYP!zcRjt4_9P@DuOnmr_U^?sj+qV{WNlLnGIuc}xP!&1?3^Oqy4G^fojww@ z;%IzI*qY;Ov@>vZ&hWZKV}#%%%7-7h`}$(VxipRNWua&s!Z<{Rv;@8?JcZYhLVXI9 zVIHkQjrR}~^!|eI++k<@*YhU=o*c;HA9dRtXGwE2OAh`0+X+|SNIgz4?1P&NR0z_y zjuR#_-~Nn*n~LSbH`lAyZYC%thcca1TE5UuI6+zIx5D34izr|kUy41$a6^d_5?ABiAJx_PBjZI1w;+5X|Saw$oa#6I3 zCv8^uh1=bjl-d@@EQgO$;yHT^o)``(Wd=$L>sM#IZy8d#w?Jz3im$#pAjI_-bd9}2 z*Km_7FHFD%R)`M-;D45@Z8NKF2mtKWguT&M2p(ZoO9UjW#Mt1fZUwJcS+N0Ntv~<& z=ugG80HbpN1g!Su{Z}1Yt*`r6U1YT`zFIfJatJd9IKfWrb$$Zat&$ZJjJ}+}2+RqL zysRLv|EnJVnC1VZrsDtNrmL5wuU>W~)PQ$PuVRen{>@o2cdRU{*x#J>KhIgCR(1~x z;I$AW1VLgDBnLrTAV>`YdN{BP#`r(BJ>flAlmY{6e;7i*1Of*jupfr^!{7i8m;rDQ zKnF2q3;}Zh9RiR!1RsLIemt;%U<(Mcg1|8VtRZj|hL6C&1^`5O9Zp2LPS`+j0;lo)90mB|R$P))0$FJTWIKom9#4@KZXGypLGL_<&v z1jS+i1~D)cgM(w?e>@TXF8-4q_}^o;${SA;IC0Vch}jO59C@z9)J=lz{*2i&RZopQ z(pSpcla34H<~R6f%=W^^<#o2Ap8B$^mP=@u5qXGih+ZY%|MaJWfH6v`h^%R%73h-u5#dM;`+VE;(ku|7PuOF*C0ipci>_5LkkYdIVJ-uCk>;@@`S<1-8_Jpe z24z>C%*2+J=W^@1MLbpsE-6{BEjUrs{NP2|ogz)av6>FQ((&3pZ^oulhm1ha`pSx6 z_tKY5f>Sp?F~-Xq-uG)%Joq+qulRmDZF70-2+}RxI4E#@Qxmcy)}v~6O0e=eibKCY zKI3%cBvYt*^yIy}oVI`Fbx01WI4Lnmy?XG&Y z8{SxUPnzcpt3-`>^k&B{f!2*3IyxI~y!qO8Z5;f$b z?TyJ&^yBZPlO3K37f&@h?l|rD`NVrRqqdD}rsYSO|JJKpKWt}}&)*K?^xWDRaMQzc zAl}NN?n&^5vkTqn?;GlRJnmha={2@G64=X&Gxq4uI#HqiweXy=?}$r+2&?^W)3Lh~ zcl|fjkLTY!TmLmtaMQv>8T;6_q1zW)mpYqwoCum=4$!vGc@>Im`y9WQQ)&KWujZZC zt*1PKJKybl7(6#%t!|s)>%36h+wXjhp5ZF}{7!~-N5a`9%?=)R_Pn(9g1k4enKKb7 z+Dv#s#``Q@|79wvrM0FtG%QRDzeZJ#VYKI*XR>HA&1GAS)J;E$rb{u;Hir<)r>uly zb5Q3ZamsmmFhXBLv~mF)+nAd8`q$^4YH!Y#5Kz?8zP$#osB?|m+|j9f)Hr~4Ig4@l zd+eZPf`7Mt=~@v)BfHV)WQy|cp|nahXUQ909Ra&X=yc^{Wp8}l26Wzi_#Pk7a>Ko^ zF1^}}BhEw3&{10FnYO@;;+1uh$82~62g*I-!}n9HrnH|M98OAdzl&H4Ed0S-zC^br z=hOA{4RRCn6R7L-ZL&Hpo7c}=sW=^L=rF*uZ)z~5t|fnyb4POY?ZH$gTA;8OPO=kV zr9Cq&P)dE?;-t<>e;u($>+dh5e}5tU|NaXpMuxBmivr=XldW|yQ5q&NV3Hh;v;{}r zhNtYpqlS2@DF@AxgVTY)>BhljPgvtl;`Si$oFecB6W4~5)NY)RTh&Uob-8`>^zN*fge=*EJb#KBD;jre^O-^ zIAwp*=nLqEpESl#Dt(Dlb`fPP(in@J8yC}WwE@rx$=8{NRBZeVjV*fcpd zO?HV(hP5K}MJ~n?*M{F~7;LT$Y%a#{|0JdQ+xB02;D2YE|MP_4fB|+w;P?{4P6#fK zRu#0au+1_xWhbLV&K(bgw6a~=VeEv!$RMP+z0l-_!8L}jYiPkfTLjdb&<$Y%O-M_t zrtD+2OJ~W^mnj}$c*n;QQVQ9QSV)5B+Nhus8paWVqlg&R-TKlT%|kH@< zpAk#nKiJ-=?awJ1AqJE1d_NmQ#e|Cb!cdiwzHlyvMPCFl=vF8PYaGcsI+gyX|Twg;Z=|@~RPD7QCc}d&k ziU%+6GrlXCY;J1lm~!ZF%-1W%yVr%2#eA|GPb13#ht6tCWCJ{p!!$&epSIEE3vjB8 zShHL1%kcFO0%IgQf^X6J`q}xILf(K)jm;Fv(}|&O0zL0-GbvgM5=n~Pflmsvhh*LO z;^MKxfue#8Mp4ct#UY}g85``(*Wxo1hAFyQJBi|N(m6_*gbi|~=av<*69R&j+%3y# zEhi#x3u0A{=TKmt<+6AkN_xNuj;wqhBsf(!sIsJ;&bMbTxP!C2P+lYU6WMg@@g_=1 z!z{Ok{N3d$w@vjOe9Q{1seYu9L(i}4TNCUqYcP8MyAA-C0#C^E%N&NA#b)pG}$BKTpU1b&LAnp;>jxP+{AJ-ha>iSap z!-8UUiOQK0-mMx9E?IF(<0a%<$VFzo?jiThc;4e7lAL?xCKX#v3(IRde+ztfBXFO% zSoOl@#PrS%N9Bh3p3@iDpXR$xp8EXdy=||s&PT=I?jQZZ?2B8v$J&hQKI=<7P##Fz zI$4(&x;NhA%azRXfT6tcvbwGW{~q6a$%0w6J+6937fT9pA`4@9%Cy>7hfI%&36+;^ zKZX)H&x}s_CvV(!i+OO#+Qu8F_={WsL)m?I2U$878QwDqCp(#56Vxu0*V^_g?`gOARJ_&=PY?mKrg%$glGyMraQFXTq% zQRv}Q75oGFvnaj~H}3p!>CUULW#ugPX8!tF{pmp7GMmyzg<5NzUWZEEPsL|G-KKZc zE3~G`?DLUfjoUF}fn6`HOWEAfjY2A3QHl}ioZ-=GrEAtiz3mX67vtY4eU>X?<7L4q zQ|ZU7{U>A0w~6sx;D5Y6tis;_Z_odDL{Tu(_jX!n}Dz>QXKPM+?f6qr%LgZ{| zyq`lie@@-g_4A7QS&Qatad&HW*1wJ>XgCz=7VbWnuMpkdWzEO2waHLl=~AkF-Y2DW zJ?){kL^~ZxVy&~*PKI%E&^AZOSHu^)2%OQC&An>{=N{>$d=K(A%_pC$dvIhd>0;2B zl#m9w#>Ut?t(#@jDP5wn z{5;I0Wh(VUPnntq^xbyQ)Vs@W`r+!4l{hQ8@tbSOTsco_vG=e>po;FfB$oNm0Ixa^ zqt$Qf!1;c|z8%9)o|+I6Jt&G`=1Ht*v+ zM{j6k*2s^#&gKZe9bz;WnFIt)I6Gt%%Tv_$=G0%lqVQJ4bZ7P(cLHzB2(EZ7CBVc? z(Y@p#$B4Xb+FR&TW!lqOtF90}^Y|C-3Hv6+5Ub+qpoKR%d#^}YKBT|!uOXE))vrRYA}yDY|HulQcy%l|Rr;Lb>;OMyFr8@>0Xm^Q`u2M&JS zRP{4Zt``}%9WG%!Cj8j+-Bif|&<^!$b5zofh}mQ{e+b64^zE1_jo+>M$8E0e9{7l~ z)$d&%;ewGjZ9_LWg>CfeMoc=Fxi}8-xTH5Vt?hK!^}cNI^F)Kwa@6eZxTa+e8^1vJ z!^@4e7XJA?j|`4i5;U{DBrQxo>OL-%*7#^*B7Hfz@P45zYt-p<5HER~LNT#>{$AlW za7j8llv_&H(0YdZO5Nq5O&-PUy_QW$X&<`tuJ0P;`@wS=$1%%n*9Z-fzn8c$|W94Y=3}dcPE?sd>A2A&Nj1r78 z#Z``ut1ss;{pts@s1AMa>K@z)@@pMG*7-@J_DRU;k%9GleV-k+sib=P3<&m_X{kMn z@$=3ynsl>T`t<4n)5}|D;$V1SLU5&#lS=2hH)%`VBgR|Z0grHfcASlfn}PN3+_a#s zrJj(SAGW;H8909C=bt&o_rGpWso`JlBkilRT>f>!|KYu(+U=D6@m0Jf7R&wouj&p~ znDSot;*b~n81qcecqZwa?gkYRvZ}6W(@e^}<*$;X(Jju#tcWHz&sCKSObnz;M4#@173tKVQ%mMFr?`xh!ECHtzKnoD$#>-xt6;dbE?} zY0xPbDC?s2c?5rcxR_#<^G;xGMqGuvvT5oqvOQwWshsmfKwiQoB~n-qeXcqq720Bo zOOx5E?s#QdNGMiAA(WS)U_53PGBD6k@!S3dUnE!s;GSfUOf_HvX;7;em||yYtNg+- z?Xdh6QjCS^!o@u!O{CGr7O# ze7Ipky0U5%%RSyp1|RmLPyTxgf-P$=_krZ`8Bx36cU;PUgo2M=eUJn z)~*Z5k^~7`obTHGUcrg(6Aq>_026330RS?_yAUdD)>F|MFaRzD;5|X2neiBy1c#wq zHD`jipBV}MS`tg}B*E4><0D28&RJ|igiv+GH!UIp5$8DOCkf&X&!yBaSWrqbDLy9&CCm)MCd}lGx)ybHt>ag(n9b^P zlFPovTm$4W8JV^fcRYaye-2?x&FFTBC;mUt(T!gJVR+Cf5H;gCNJ%YF9la0o20`hq zNE*BH>rCvW$9Z)KI7qoh6s5Q_qPP{HY_iLN!7dQx&3pwD$gmJ)oCI)UMV-Sry z^&QpLhPmdes~b&tC)o;4`<)m6~}|e)Z%x4te#19_E-j%tv-?*xd=R81R>eN$DyzVa^K~nhf z^aEgCh*<4!`$CLb^1n!b;0&|y3LisAhD3lG49)!d1q5XNwg$l7)>N2q2Q*-kJ(cUY zd|n1HsFChJBGUPB&L$===zG$ehHg19BhMdBzf(*X*NLXjbo-&9a7x) z1Cp}c+>_$L%5fiEtDrj|>6_|Ls|xpNJ?tOfrwwV@iYiy#`dCO(A55Na%Di+m5{^2! z{Ncc2SWufEIv>GaOpA>Utf*yt?f}OZ6M0Un&NUBMc+0p*jCeQ$2EG8e*$a`NoIdnQ z!(?Jj0AC1a1${nAx%}CYR({I0Ox)aXn%;b7hAOtr8=I^WOoNCgF6U^Nc>$eIDH(qRHw{ZdzotA0_R_C zqVw?AZS%_xNV0bqz=j53OXp-nBzL003E*I=!p_v!P%f+!p)blHl*Cz2LWZ%v5*=NE zyRaCc6N3@_6Bstn@9z@vRl*4%yL%bod>&aHzzd&nHDlxWLy(>N5oFfAJ6O z(KvW}-oZE0hoH`P%953v;Zq8L3Id2-h?27w6a;pAUkq>|CK%t3qQOsf6*<-~X?h(I z*ucIO`$b2-3Gs1|H)=L3h8my&9J{P$&aRKc!G$0K+F=(r24p@ zR?lJWev|AjTOs4Xa5wK=@I5zLOvlS=q(HxG5p~KQq@qpFDtSJ>KAWQ>`VQZKYEr}o zYe$^smjhtH$Bnc4xkpTtnj4YTaljYRH;xD(7V9e`gZd|)1DPOb53MBrX;#N*Fvl9O zZR0=8;gvGH%`OPTvIOBUXkF#)VF1;$V%v?7fg?a^_(Ey7CJVoNOe0?svmXwE0&sZ8 zMQ?xu1ptGC844V^xS&8=n6-k1)tM(I9OMrH(BY@FPynd8$HJdHELC&{vt6{=?UGH4 z;)&yq=z&Mn00WMKp8c`eZ9G`<92hjY-b8tUP2=qS*~{5Y;J8t;FKa-f`H~t?<0d*A ztOhJ~$Cr<*e1q;{bNulOKRp4!Y;SdM#2lIHlolD9n^_-U=Q%pyONdquYB_oC=9|zv zKcg4y&MVUo#JG^I`U3{jxj9lfp^@{8`9&Hp{MFGwLx?tKqmgA_R?>mJVbFOcW(E<$ zuoNE?zZr7c`lsci#)LWx*w@iJR~_D|>3DdHeME3M9w9@sR%DLzfiab(LzfS%exV11 zM@)@&Y;M(z4s8JKd)70G;5wG=fw-X%==CoU;8gmI7OF(_Yp@7y@hyflT&b~8ze^t<5o+oYUNM&+e=9I{AWqlyM*)I3u zD}H&n#VY68&*FQ(WV2w=VI}~|0CWO{VVQAaVQxQS8FlB_c$1$v=h^Wr3lM5)!HiG_ z9T)oXZxtoewJm;lzkXdl)JUc64(EvIfHhVCXD?7!WSwUh4x1}S;K;fCs`I1hk(`7B zB*TK8k#ek0e>ePl({f|Pn*$!-0cF)^K?%p%ycQ*j5x+$XfziHY3aP_@LfAY$-KR4h zgVdiRZ;y=DuW6imI;}jVY{w0sy99!FL-u z%%UaS-4V3@l{0}iPF?rGAzk-X`jQIey$+x#mCTU2y&U_`B$7)t()D(#*H?vx;9TiBS1Ga(ERfu=4%ovP;_#0u3TMqpb%_S^3dLdtuO-svvu zP?><>5=+^x(|OBhZ5DNJZNtA}P(elFm81Lc;Fx6lA2RYdtP$mXc;;>ay{8AaNSxH2 ztz_ilsh0=q?*$D>+_2`VN&+m15RMbFGrSMJ;y?^s04T4}*)Smqg+cS;4nLuz`VVk^ zQZLq+X5Rsy#&=NKUsmGY5ssH5+SmyJXuv+$=H~LP%Y?^lEu-7!1kU2hJYS>t)k&{g z(79$9uo(0Q#y{~?5r84lpMRQRhiW{$YR$^isuY*8p$Z?sjceZu@_sT{i;sE+00jK% zS6+4wq-mgDiTKQ3mxcv1$q0br-vXU805Ar>ikCKGaFCN8V6M>7EbRYgmomc7@qbzR zGZyfF`hP49{D-Bp|M~x6X(DV)SJo%f+sB9Fzd1XilvEx$nQCr&d^gaLjktwE*RlCd zTIO=98*JcU`m&9Ly~+or6;oU_SGFf-YObhDY&-08!`TtM-fQgbz91+h}kqIZ8D`7|O;q ztR6XJdvvex)ipP(=;Xfp1*PY1kASg;bkgD+EL$p)WA*~yn^prWfPt%HGge-wI>1sY zXCyUi`$o-XaTXs%hSn>9s&`!ydUp9Z{E;2$%BGRB-F1idu*OZTvBcrm#e0Gtn~Dm9 zG7)Tov=FSKX%~;q0p=;P{OmlcY*<`jXK7yrQ~9VX!TKDc>OY+|UE+d`MWBxvc@B5* zI`%ZUX&f<29!<(*XjcN;Ff~!;SaOItSXPxnFkFZC8v3kgFPxYQVE#+ipgBsek-VWH zrb|_Yx4@t?e9N?T$$ks84KN!k?4_FJcx6dZ<#w z{3}#BhB$pp`~0iRe!rcpQDf1;)fCLB(4lD{q-WL2G_x@^8%dLt$Z$7Vo0{Ztkv8YA z`_mVb@p_Qbq3BATR!vcw%AfDu++5Wl?Z>l|o#9s_Sd6NnmE~?U zPX$#Ig*zcS2y~s;K+$d>n}Ktr@Tqe?^##*lviUZdrgn*&b$0oME~gJNRQ=(sFzl= zo?oNUvs9Hq&zQfTU8o>}6>2Zk7xsF)I*{@=I${@l3ncol#g7IO{T%kj?aTC~eHf$@ zGD-BcS>}wcg{+<>Wl$zsnk4%C$jn+$&&*HQ^p0yOVW9aU+FUf_jK8;QQ^V=%P5l#o zd>|D^GBjIX`>C!1otM%*ud&Ye!hVBtmXzOpXLG}{Lo~x(EYf#hr%2bqF<*n>DR-L$ ztz?zGEyu^PMV4%B*6Hngc&T}^jvxyE?*)dJvi#ePd=vkV_N#X`0%&t-&Q)`i=v!iL z^x?_4{8o`q6~z8LOL=_ubhM=KLr6!5;;7j-kQFt;S^Ud*TjIw7%!bB8$auJdv~>12 z3hhH$c#B|U6*JXuBs?o2wM(c-oZkK!F5_MA6e6&#;*pxKh2mcKUiP&8dv$&e%`65pq&z;PPFDA@;4(f@pqwA*VQ=n0{!% zrTKo6)rxXKx?j}lpBKGQT<&ot^jt4&87C%0zDx>%M+5{b&aQr)4o%vdSqPP<-#D)r ztsf?IN(b-eg+Ztom}1~ww{a1D(fy#?9*_iG6Ff7xz^O}!`lt;jkCCC#HNbcSsjh0(;pH%M_rCIYqRHl3=rFv^ zge7EN&8eE|?9|DrbAB4&uAy&E9|nlIkjnNAvncd=Awo#fztvPJooaXIR&!rsn&EVT zv&p~Nsipc=Iy*UR1S)`7#Ac=z+Oqkx;^d0bb&~*cUiciSw+57bU?%^^^4Rs}(#|ei ztcB-!#`4g46j$BnabQKX(BT)M+X(}#HNHrq)XkvEX0%+py3eecgD)OOE^_}Henfy@G0Jm513U(~<^^3Bl@Ta62BvA+Qt;9? z+Exm!>mgYSG$z!0$Hd1Hwv-?i-x8dZiu_QbYE?>D zRo-JcHt*4r(5({WUdd97h3BCMu3P?M0ypDI`erNU%2atmAWH!G!7%%`rcCT}73%it z6R{&B_4j+5yFYn!pV>5=TBXqz*_JPHp2zSTunWx;lCDH)Rvk=bsjn2SWf3ae419BF zUK;6pT@+m+7M8I*=1zuj#JcV1JMY%?x=S#65R1^ieRSJ36L7y8R3SlG${cw(w!FQ0 zd#k1`OwweatyG8?G3?2&Xz7rGET6%?IxFCA!z?bbrhS0_EoE%ND_BduoHQ%O+H6`F zLU1X<*4F$TB?p$y|4wPwqL^fV*gxFLRJn?IkGxIZX3N&7e&=dT6hS_CK}VbAmqMU8 z#Uy0&);;9z_VG^eCxgYXO7*+S~ETt0J zhLcIU9>O5BU5~z1(WBO_D7F+fO>A0ZWODt3@zFhGMJ2_Rm;MZb%?f(tLDZADY0N)j z0|uw#AVANOqTsl-hEeLb#!;o(ozHss0^G()VW8A@oi-6b2i}2*K^&$%Bast#gZ6Y1 zLYVk?2q`+uL8`uA@LjY)ARUjR;}9}QReVHQB<2>73Dm?+Yk`m!eJa4@4=Id?i|BBq zYiXv!@hu@#MF*OIm#J;-2z7Q@o&M-Lu_QHde*f5=d-5XfQ*vW>lZcKdv?62(cNg1E zCGFkCOM=x44FXin%W&bY*-5P#w`CI}D;lgtWMcby%-xT$C8P}-@5=GR<4XJBe_UKw z^$>?FAifS+>soqs-*^=|@aIavx=+%yzHG zCCrrV1Ins$E2)>Ld+OMO3BgaH?){NLEy6lr{HmC467}?dv@uZk^#*}+A zTDOOZ8Z{oFZ+UP4MxisN?TCBLk?A~~3ZzQHFOn!Sz5PTNW`bc)hS_a`$GGqHe{lMK zB#1GqY-sOI?0h{^Pt>CG8Tc*CjxJEb!kH3AJk?rI6#%Jrk#0EVSZN;HR{4M>Dg1$@ z;og!pE{hd*Vnz@KV-_E;J9H&w$gF1d@K#|cKh1AxrXI(H9n7?c(Kpo7~f5<)Q?SXVCs(0^7FypGVAPUz|!4Lr8m2{WpZi_3SCa zBaKKh#+et-KPF3D=Z-c-mD-j7O*TVB8%wjtZeUE80%;6R381L5%JpP4Mq_5H= z^+@mbMr(QUf@dV@n^PUX92d?j>s*##QbI!l@r@iEw-AFpjZOP&_m7n1#78F? z$M|m?*Hv*{9L1ZIBq&+E7lCJepMSC*ALEO~@^Y<~Phus9!8)4Zr9Q2$ch|=Hdn}8n zZ`iR)+{W=pju!)R1vD*T3oAL&k*CHz_Ry(eZv6uWF33p*ys5P1xIEMDbu}pFa$}M! zBJkR%au~l>){AzE9?Zdd!LQX;B>ino8c?U6tU}?Y70S!9=I^gwSpAi;+C>~0wjHks z{SZQGNy(a*p3lCKBQv>MI56DfM}afIrgrZmUmz&x4#PezbxK7TzhtG{vANGHo06N{ zYAO9m$KB}*>hh9S>wn}Tu3X~BosJjgUtk` zUvXn}u1&qcS`}$GB3-`{b)-+^V{P`%?-&#MGW*oyVzX6O4^P_107>@A#wPhdGPO;6 zB5bXhNNp(&!rhTh^E3;53vQXA@dyOhOD@8ZktsuZYwqR_7CdRa63GgFrHlHPLa zRl~G;-`K)Bjs|zKVafK9kwTvUI;k${`5$nd68{W*gh-lkn#kSJWnoD=s*O>l=z`pr z*s#So;;ksjEqW^@EH`i%Q>4MGcFi&gpJoqdzZ0$)O~Peh_)#*-Oj3Gmo1$k0SBkY8 zKJY?6Yq`z`bErwz0B#9Ch>xb$s1>2lP@@-Aw4Ssd)aMro`3Z}Svob0f>#+PY9YC#u zon|2Qrt^^f3st%O1YbQ4>OHLZ&9N4p6+#-kUh0?-oKRL5t}lwT9{2Ay$}y`zbS*-e9TimO zbmroDm{U^XS@4P^Gh&~~o>5dkUOCk~2IjNg(WW0s1=F(Mbc*KIBA(8HA7$$6dMx6V>pyjO);c$uwH0NQAdM(nH+7D!=^!6q7 z`|DVAEic1wsS&t$IxTemac_RXCZiP6B@Bc%kI^yYEAGjJV0`yJuMl82INHO~5IdDl zHtgF=bJ3n_*{s>Vb9t?P8gk(FfRPe5F+~U0dDW=lkwidh-BKyy#!#1bLC~0Jce-ho z>XTYF=ZXK1&Pxk+qr!Io9z@57qylbAoCqLu-XnczoRAhxLSZp2cB-Q(K((F-NvrK4 zy3o(4S$ZL{O?wI+w#hA9Y>DmLFu?y+8fzI@gRVx`|JjO7%0N&JMiYR$%=N@SC`v6` zIWeB$r>1XaQKx4FMo%S=pQ8M-m!GzjreoB_q5Ss^iob7!`Im9;a!KLrc$9o)umsVA zmv*UBvwloii^M3t+|+7emuqh3_K1daxrx!U`n%}!~rW5;>n zZ>r(6yXcMQ);w~ARsZ1y85eQzH)Dy7dV?)=NAXIocXGjGT4CdyE$LvU)`*C1v`V2o zm@W72WU;4U7Hl6qw?lr>4Y4e+cS10m_rv*mEBSX}!13uS%2?!BK*)8n8+W--1ysol zQW{n@-ilCAuha_K7Dj7Uk&_z=iea+ddE?r8H(4(MX*BY?x?I0c1Sf((`=|-rMJpq@d7}8gI{pKkha7tH(9l4%PjZv7{_F$~#E=(x#cZ?M&`3 z!}OJ^khK!4Qji3CzlrCR{9^kVI9oGwxnTGba{K8mO`<^u$s}Suoz|ygl{E|VbGLx4 z+@#UY$8jk`%lakxq+c=?Qxa%g%t6nd*0a;dQ+L0(Z-YPgjrx=K<18$IMqlVn7gy&^ zjh2V)aFP8omKb8Xqm+$IB!BnmVuuE3Bx$lbQAjio!Lx{-&f6$1yqU>F|6^#YBr|d@FnT z?`19-y=OfyT=9qEDUo9v3=8COm7^1)u3s%AIGN_}^)#CPnA>nG;^c?5_Rfk-I5~@f z%IiP_q5kN0ee@nzmr2uqD)=`CmY(M%$}&k537Wby&fQv!T2Ft@7VxS!eNz%cR&qN% zf3`3w2SY=z%{ZJJWj~sDXjvRyDrk2mct*y{zzgAxygzxZ9yO08P)Nk@#l)xbU1 Date: Sun, 12 Jan 2025 19:23:35 -0800 Subject: [PATCH 061/194] Added VERY_VERBOSE dfplayer printing (#8026) --- esphome/components/dfplayer/dfplayer.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/esphome/components/dfplayer/dfplayer.cpp b/esphome/components/dfplayer/dfplayer.cpp index 98c3e91e46..70bd42e1a5 100644 --- a/esphome/components/dfplayer/dfplayer.cpp +++ b/esphome/components/dfplayer/dfplayer.cpp @@ -159,6 +159,15 @@ void DFPlayer::loop() { } break; case 9: // End byte +#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE + char byte_sequence[100]; + byte_sequence[0] = '\0'; + for (size_t i = 0; i < this->read_pos_ + 1; ++i) { + snprintf(byte_sequence + strlen(byte_sequence), sizeof(byte_sequence) - strlen(byte_sequence), "%02X ", + this->read_buffer_[i]); + } + ESP_LOGVV(TAG, "Received byte sequence: %s", byte_sequence); +#endif if (byte != 0xEF) { ESP_LOGW(TAG, "Expected end byte 0xEF, got %#02x", byte); this->read_pos_ = 0; @@ -238,13 +247,17 @@ void DFPlayer::loop() { this->ack_set_is_playing_ = false; this->ack_reset_is_playing_ = false; break; + case 0x3C: + ESP_LOGV(TAG, "Playback finished (USB drive)"); + this->is_playing_ = false; + this->on_finished_playback_callback_.call(); case 0x3D: - ESP_LOGV(TAG, "Playback finished"); + ESP_LOGV(TAG, "Playback finished (SD card)"); this->is_playing_ = false; this->on_finished_playback_callback_.call(); break; default: - ESP_LOGV(TAG, "Received unknown cmd %#02x arg %#04x", cmd, argument); + ESP_LOGE(TAG, "Received unknown cmd %#02x arg %#04x", cmd, argument); } this->sent_cmd_ = 0; this->read_pos_ = 0; From d8c943972b2a3e68ec126922cd8601fba290b6c0 Mon Sep 17 00:00:00 2001 From: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:05:53 +0100 Subject: [PATCH 062/194] [core] fix comment for crc8 function in helpers.h (#8016) --- esphome/core/helpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index c823439fb3..82b0fe07f8 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -163,7 +163,7 @@ template T remap(U value, U min, U max, T min_out, T max return (value - min) * (max_out - min_out) / (max - min) + min_out; } -/// Calculate a CRC-8 checksum of \p data with size \p len. +/// Calculate a CRC-8 checksum of \p data with size \p len using the CRC-8-Dallas/Maxim polynomial. uint8_t crc8(const uint8_t *data, uint8_t len); /// Calculate a CRC-16 checksum of \p data with size \p len. From aa1879082c67dd893591d854ea8e057e2ad99fa6 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:06:44 +0100 Subject: [PATCH 063/194] [debug] Add framework type to debug info (#8013) --- esphome/components/debug/debug_esp32.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/esphome/components/debug/debug_esp32.cpp b/esphome/components/debug/debug_esp32.cpp index 5f7b9cdbb0..b0631f2b61 100644 --- a/esphome/components/debug/debug_esp32.cpp +++ b/esphome/components/debug/debug_esp32.cpp @@ -276,6 +276,19 @@ void DebugComponent::get_device_info_(std::string &device_info) { device_info += " Cores:" + to_string(info.cores); device_info += " Revision:" + to_string(info.revision); + // Framework detection + device_info += "|Framework: "; +#ifdef USE_ARDUINO + ESP_LOGD(TAG, "Framework: Arduino"); + device_info += "Arduino"; +#elif defined(USE_ESP_IDF) + ESP_LOGD(TAG, "Framework: ESP-IDF"); + device_info += "ESP-IDF"; +#else + ESP_LOGW(TAG, "Framework: UNKNOWN"); + device_info += "UNKNOWN"; +#endif + ESP_LOGD(TAG, "ESP-IDF Version: %s", esp_get_idf_version()); device_info += "|ESP-IDF: "; device_info += esp_get_idf_version(); From fef50afef8bbf333de3d8f0fc3754d231f7bf165 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:08:20 +0100 Subject: [PATCH 064/194] [debug] Add ESP32 partition table logging to `dump_config` (#8012) --- esphome/components/debug/debug_component.cpp | 4 ++++ esphome/components/debug/debug_component.h | 14 ++++++++++++++ esphome/components/debug/debug_esp32.cpp | 14 ++++++++++++++ tests/components/debug/test.esp32-s2-ard.yaml | 1 + tests/components/debug/test.esp32-s2-idf.yaml | 1 + tests/components/debug/test.esp32-s3-ard.yaml | 1 + tests/components/debug/test.esp32-s3-idf.yaml | 1 + 7 files changed, 36 insertions(+) create mode 100644 tests/components/debug/test.esp32-s2-ard.yaml create mode 100644 tests/components/debug/test.esp32-s2-idf.yaml create mode 100644 tests/components/debug/test.esp32-s3-ard.yaml create mode 100644 tests/components/debug/test.esp32-s3-idf.yaml diff --git a/esphome/components/debug/debug_component.cpp b/esphome/components/debug/debug_component.cpp index cbd4249d92..7d25bf5472 100644 --- a/esphome/components/debug/debug_component.cpp +++ b/esphome/components/debug/debug_component.cpp @@ -50,6 +50,10 @@ void DebugComponent::dump_config() { this->reset_reason_->publish_state(get_reset_reason_()); } #endif // USE_TEXT_SENSOR + +#ifdef USE_ESP32 + this->log_partition_info_(); // Log partition information for ESP32 +#endif // USE_ESP32 } void DebugComponent::loop() { diff --git a/esphome/components/debug/debug_component.h b/esphome/components/debug/debug_component.h index 2b54406603..608addb4a3 100644 --- a/esphome/components/debug/debug_component.h +++ b/esphome/components/debug/debug_component.h @@ -55,6 +55,20 @@ class DebugComponent : public PollingComponent { #endif // USE_ESP32 #endif // USE_SENSOR +#ifdef USE_ESP32 + /** + * @brief Logs information about the device's partition table. + * + * This function iterates through the ESP32's partition table and logs details + * about each partition, including its name, type, subtype, starting address, + * and size. The information is useful for diagnosing issues related to flash + * memory or verifying the partition configuration dynamically at runtime. + * + * Only available when compiled for ESP32 platforms. + */ + void log_partition_info_(); +#endif // USE_ESP32 + #ifdef USE_TEXT_SENSOR text_sensor::TextSensor *device_info_{nullptr}; text_sensor::TextSensor *reset_reason_{nullptr}; diff --git a/esphome/components/debug/debug_esp32.cpp b/esphome/components/debug/debug_esp32.cpp index b0631f2b61..69ae7e3678 100644 --- a/esphome/components/debug/debug_esp32.cpp +++ b/esphome/components/debug/debug_esp32.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #if defined(USE_ESP32_VARIANT_ESP32) #include @@ -28,6 +29,19 @@ namespace debug { static const char *const TAG = "debug"; +void DebugComponent::log_partition_info_() { + ESP_LOGCONFIG(TAG, "Partition table:"); + ESP_LOGCONFIG(TAG, " %-12s %-4s %-8s %-10s %-10s", "Name", "Type", "Subtype", "Address", "Size"); + esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL); + while (it != NULL) { + const esp_partition_t *partition = esp_partition_get(it); + ESP_LOGCONFIG(TAG, " %-12s %-4d %-8d 0x%08X 0x%08X", partition->label, partition->type, partition->subtype, + partition->address, partition->size); + it = esp_partition_next(it); + } + esp_partition_iterator_release(it); +} + std::string DebugComponent::get_reset_reason_() { std::string reset_reason; switch (esp_reset_reason()) { diff --git a/tests/components/debug/test.esp32-s2-ard.yaml b/tests/components/debug/test.esp32-s2-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/debug/test.esp32-s2-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/debug/test.esp32-s2-idf.yaml b/tests/components/debug/test.esp32-s2-idf.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/debug/test.esp32-s2-idf.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/debug/test.esp32-s3-ard.yaml b/tests/components/debug/test.esp32-s3-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/debug/test.esp32-s3-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/debug/test.esp32-s3-idf.yaml b/tests/components/debug/test.esp32-s3-idf.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/debug/test.esp32-s3-idf.yaml @@ -0,0 +1 @@ +<<: !include common.yaml From 528d3672b499650185427297cfb7399fedd8fcf4 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:11:48 +0100 Subject: [PATCH 065/194] [psram] Improve total PSRAM display in logs by using rounded KB values (#8008) Co-authored-by: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> --- esphome/components/psram/psram.cpp | 9 ++++++++- tests/components/psram/test.esp32-s2-ard.yaml | 1 + tests/components/psram/test.esp32-s2-idf.yaml | 1 + tests/components/psram/test.esp32-s3-ard.yaml | 1 + tests/components/psram/test.esp32-s3-idf.yaml | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/components/psram/test.esp32-s2-ard.yaml create mode 100644 tests/components/psram/test.esp32-s2-idf.yaml create mode 100644 tests/components/psram/test.esp32-s3-ard.yaml create mode 100644 tests/components/psram/test.esp32-s3-idf.yaml diff --git a/esphome/components/psram/psram.cpp b/esphome/components/psram/psram.cpp index 68d8dfd697..d9a5bd101f 100644 --- a/esphome/components/psram/psram.cpp +++ b/esphome/components/psram/psram.cpp @@ -21,7 +21,14 @@ void PsramComponent::dump_config() { ESP_LOGCONFIG(TAG, " Available: %s", YESNO(available)); #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0) if (available) { - ESP_LOGCONFIG(TAG, " Size: %d KB", heap_caps_get_total_size(MALLOC_CAP_SPIRAM) / 1024); + const size_t psram_total_size_bytes = heap_caps_get_total_size(MALLOC_CAP_SPIRAM); + const float psram_total_size_kb = psram_total_size_bytes / 1024.0f; + + if (abs(std::round(psram_total_size_kb) - psram_total_size_kb) < 0.05f) { + ESP_LOGCONFIG(TAG, " Size: %.0f KB", psram_total_size_kb); + } else { + ESP_LOGCONFIG(TAG, " Size: %zu bytes", psram_total_size_bytes); + } } #endif } diff --git a/tests/components/psram/test.esp32-s2-ard.yaml b/tests/components/psram/test.esp32-s2-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/psram/test.esp32-s2-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/psram/test.esp32-s2-idf.yaml b/tests/components/psram/test.esp32-s2-idf.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/psram/test.esp32-s2-idf.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/psram/test.esp32-s3-ard.yaml b/tests/components/psram/test.esp32-s3-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/psram/test.esp32-s3-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/psram/test.esp32-s3-idf.yaml b/tests/components/psram/test.esp32-s3-idf.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/psram/test.esp32-s3-idf.yaml @@ -0,0 +1 @@ +<<: !include common.yaml From 8fbd512952e516b5b4a64d9592d81cbeb9349c38 Mon Sep 17 00:00:00 2001 From: Douglas <31328123+dougiteixeira@users.noreply.github.com> Date: Mon, 13 Jan 2025 01:16:43 -0300 Subject: [PATCH 066/194] Use ESPHome logo on readme page according to theme (light/dark) (#7992) --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da1b2b3650..8e3d8f71aa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # ESPHome [![Discord Chat](https://img.shields.io/discord/429907082951524364.svg)](https://discord.gg/KhAMKrd) [![GitHub release](https://img.shields.io/github/release/esphome/esphome.svg)](https://GitHub.com/esphome/esphome/releases/) -[![ESPHome Logo](https://esphome.io/_images/logo-text.png)](https://esphome.io/) + + + + ESPHome Logo + + **Documentation:** https://esphome.io/ From 3fa67fad32c9515b1bf876bb7aef02b6d311c1b3 Mon Sep 17 00:00:00 2001 From: Ryan Henderson Date: Sun, 12 Jan 2025 20:17:28 -0800 Subject: [PATCH 067/194] Fix compile errors with pioarduino/platform-espressif32: wifi_component_esp32_arduino.cpp (#7998) --- .../components/wifi/wifi_component_esp32_arduino.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/esphome/components/wifi/wifi_component_esp32_arduino.cpp b/esphome/components/wifi/wifi_component_esp32_arduino.cpp index bc10bbd1e5..76d0b7d96c 100644 --- a/esphome/components/wifi/wifi_component_esp32_arduino.cpp +++ b/esphome/components/wifi/wifi_component_esp32_arduino.cpp @@ -11,6 +11,11 @@ #ifdef USE_WIFI_WPA2_EAP #include #endif + +#ifdef USE_WIFI_AP +#include "dhcpserver/dhcpserver.h" +#endif // USE_WIFI_AP + #include "lwip/apps/sntp.h" #include "lwip/dns.h" #include "lwip/err.h" @@ -638,7 +643,12 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_ } WiFiSTAConnectStatus WiFiComponent::wifi_sta_connect_status_() { - auto status = WiFiClass::status(); +#if USE_ARDUINO_VERSION_CODE < VERSION_CODE(3, 1, 0) + const auto status = WiFiClass::status(); +#else + const auto status = WiFi.status(); +#endif + if (status == WL_CONNECT_FAILED || status == WL_CONNECTION_LOST) { return WiFiSTAConnectStatus::ERROR_CONNECT_FAILED; } From df50e57409d80e8e43c9d0366ad4bbbdd42c07e1 Mon Sep 17 00:00:00 2001 From: Ryan Henderson Date: Sun, 12 Jan 2025 20:18:20 -0800 Subject: [PATCH 068/194] Include esp_mac.h and C++20 str_startswith/str_ends (#7999) --- esphome/core/helpers.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index 2d2c88b844..439bb2ccb0 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -45,7 +45,9 @@ #endif #ifdef USE_ESP32 #include "esp32/rom/crc.h" - +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 2) +#include "esp_mac.h" +#endif #include "esp_efuse.h" #include "esp_efuse_table.h" #endif @@ -261,7 +263,7 @@ bool random_bytes(uint8_t *data, size_t len) { bool str_equals_case_insensitive(const std::string &a, const std::string &b) { return strcasecmp(a.c_str(), b.c_str()) == 0; } -#if ESP_IDF_VERSION_MAJOR >= 5 +#if __cplusplus >= 202002L bool str_startswith(const std::string &str, const std::string &start) { return str.starts_with(start); } bool str_endswith(const std::string &str, const std::string &end) { return str.ends_with(end); } #else From 13909b7994de2c25a62714bfc44c20b4fb845958 Mon Sep 17 00:00:00 2001 From: Ryan Henderson Date: Sun, 12 Jan 2025 20:26:23 -0800 Subject: [PATCH 069/194] [esp32_wifi] Enhance WiFi component with TCPIP core locking. (#7997) --- .../wifi/wifi_component_esp32_arduino.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/esphome/components/wifi/wifi_component_esp32_arduino.cpp b/esphome/components/wifi/wifi_component_esp32_arduino.cpp index 76d0b7d96c..b7a77fcdc9 100644 --- a/esphome/components/wifi/wifi_component_esp32_arduino.cpp +++ b/esphome/components/wifi/wifi_component_esp32_arduino.cpp @@ -20,6 +20,10 @@ #include "lwip/dns.h" #include "lwip/err.h" +#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING +#include "lwip/priv/tcpip_priv.h" +#endif + #include "esphome/core/application.h" #include "esphome/core/hal.h" #include "esphome/core/helpers.h" @@ -291,11 +295,26 @@ bool WiFiComponent::wifi_sta_ip_config_(optional manual_ip) { } if (!manual_ip.has_value()) { +// sntp_servermode_dhcp lwip/sntp.c (Required to lock TCPIP core functionality!) +// https://github.com/esphome/issues/issues/6591 +// https://github.com/espressif/arduino-esp32/issues/10526 +#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING + if (!sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) { + LOCK_TCPIP_CORE(); + } +#endif + // lwIP starts the SNTP client if it gets an SNTP server from DHCP. We don't need the time, and more importantly, // the built-in SNTP client has a memory leak in certain situations. Disable this feature. // https://github.com/esphome/issues/issues/2299 sntp_servermode_dhcp(false); +#ifdef CONFIG_LWIP_TCPIP_CORE_LOCKING + if (sys_thread_tcpip(LWIP_CORE_LOCK_QUERY_HOLDER)) { + UNLOCK_TCPIP_CORE(); + } +#endif + // No manual IP is set; use DHCP client if (dhcp_status != ESP_NETIF_DHCP_STARTED) { err = esp_netif_dhcpc_start(s_sta_netif); From 9874d17613147fd617841d7eae66505a5c024b56 Mon Sep 17 00:00:00 2001 From: NP v/d Spek Date: Mon, 13 Jan 2025 05:29:38 +0100 Subject: [PATCH 070/194] add missing include in base_automation.h (#8001) --- esphome/core/base_automation.h | 1 + 1 file changed, 1 insertion(+) diff --git a/esphome/core/base_automation.h b/esphome/core/base_automation.h index dcf7da2f21..13179b90bb 100644 --- a/esphome/core/base_automation.h +++ b/esphome/core/base_automation.h @@ -2,6 +2,7 @@ #include "esphome/core/automation.h" #include "esphome/core/component.h" +#include "esphome/core/hal.h" #include "esphome/core/defines.h" #include "esphome/core/preferences.h" From 30bb806f26853e00c053f1fc69751a61f105b8ee Mon Sep 17 00:00:00 2001 From: Piotr Szulc Date: Mon, 13 Jan 2025 05:31:01 +0100 Subject: [PATCH 071/194] Fixed libretiny preference wrongly detecting change in the data to store (#7990) --- esphome/components/libretiny/preferences.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/libretiny/preferences.cpp b/esphome/components/libretiny/preferences.cpp index ceeb30baf5..a090f42aa7 100644 --- a/esphome/components/libretiny/preferences.cpp +++ b/esphome/components/libretiny/preferences.cpp @@ -147,7 +147,7 @@ class LibreTinyPreferences : public ESPPreferences { ESP_LOGV(TAG, "fdb_kv_get_obj('%s'): nullptr - the key might not be set yet", to_save.key.c_str()); return true; } - stored_data.data.reserve(kv.value_len); + stored_data.data.resize(kv.value_len); fdb_blob_make(&blob, stored_data.data.data(), kv.value_len); size_t actual_len = fdb_kv_get_blob(db, to_save.key.c_str(), &blob); if (actual_len != kv.value_len) { From b4a2b50ee092abd0eabbbce6db0c8da1d825464e Mon Sep 17 00:00:00 2001 From: Dusan Cervenka Date: Mon, 13 Jan 2025 05:34:07 +0100 Subject: [PATCH 072/194] Fixed topic when mac is used (#7988) --- esphome/components/mqtt/__init__.py | 2 +- esphome/components/mqtt/mqtt_client.cpp | 8 +++++++- esphome/components/mqtt/mqtt_client.h | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/esphome/components/mqtt/__init__.py b/esphome/components/mqtt/__init__.py index 2b0d941220..e1002478a1 100644 --- a/esphome/components/mqtt/__init__.py +++ b/esphome/components/mqtt/__init__.py @@ -373,7 +373,7 @@ async def to_code(config): ) ) - cg.add(var.set_topic_prefix(config[CONF_TOPIC_PREFIX])) + cg.add(var.set_topic_prefix(config[CONF_TOPIC_PREFIX], CORE.name)) if config[CONF_USE_ABBREVIATIONS]: cg.add_define("USE_MQTT_ABBREVIATIONS") diff --git a/esphome/components/mqtt/mqtt_client.cpp b/esphome/components/mqtt/mqtt_client.cpp index c7ace505a8..9afa3a588d 100644 --- a/esphome/components/mqtt/mqtt_client.cpp +++ b/esphome/components/mqtt/mqtt_client.cpp @@ -606,7 +606,13 @@ void MQTTClientComponent::set_log_level(int level) { this->log_level_ = level; } void MQTTClientComponent::set_keep_alive(uint16_t keep_alive_s) { this->mqtt_backend_.set_keep_alive(keep_alive_s); } void MQTTClientComponent::set_log_message_template(MQTTMessage &&message) { this->log_message_ = std::move(message); } const MQTTDiscoveryInfo &MQTTClientComponent::get_discovery_info() const { return this->discovery_info_; } -void MQTTClientComponent::set_topic_prefix(const std::string &topic_prefix) { this->topic_prefix_ = topic_prefix; } +void MQTTClientComponent::set_topic_prefix(const std::string &topic_prefix, const std::string &check_topic_prefix) { + if (App.is_name_add_mac_suffix_enabled() && (topic_prefix == check_topic_prefix)) { + this->topic_prefix_ = str_sanitize(App.get_name()); + } else { + this->topic_prefix_ = topic_prefix; + } +} const std::string &MQTTClientComponent::get_topic_prefix() const { return this->topic_prefix_; } void MQTTClientComponent::set_publish_nan_as_none(bool publish_nan_as_none) { this->publish_nan_as_none_ = publish_nan_as_none; diff --git a/esphome/components/mqtt/mqtt_client.h b/esphome/components/mqtt/mqtt_client.h index 34eac29464..c68b3c62eb 100644 --- a/esphome/components/mqtt/mqtt_client.h +++ b/esphome/components/mqtt/mqtt_client.h @@ -165,7 +165,7 @@ class MQTTClientComponent : public Component { * * @param topic_prefix The topic prefix. The last "/" is appended automatically. */ - void set_topic_prefix(const std::string &topic_prefix); + void set_topic_prefix(const std::string &topic_prefix, const std::string &check_topic_prefix); /// Get the topic prefix of this device, using default if necessary const std::string &get_topic_prefix() const; From f319472066a45c11f4d71e96b39a201f07e7f0dd Mon Sep 17 00:00:00 2001 From: Nate Clark Date: Sun, 12 Jan 2025 23:35:29 -0500 Subject: [PATCH 073/194] web_server: Adds REST API POST endpoints to arm and disarm (#7985) --- esphome/components/web_server/web_server.cpp | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/esphome/components/web_server/web_server.cpp b/esphome/components/web_server/web_server.cpp index 0467023039..ed0cb3db2c 100644 --- a/esphome/components/web_server/web_server.cpp +++ b/esphome/components/web_server/web_server.cpp @@ -1415,6 +1415,30 @@ void WebServer::handle_alarm_control_panel_request(AsyncWebServerRequest *reques request->send(200, "application/json", data.c_str()); return; } + + auto call = obj->make_call(); + if (request->hasParam("code")) { + call.set_code(request->getParam("code")->value().c_str()); + } + + if (match.method == "disarm") { + call.disarm(); + } else if (match.method == "arm_away") { + call.arm_away(); + } else if (match.method == "arm_home") { + call.arm_home(); + } else if (match.method == "arm_night") { + call.arm_night(); + } else if (match.method == "arm_vacation") { + call.arm_vacation(); + } else { + request->send(404); + return; + } + + this->schedule_([call]() mutable { call.perform(); }); + request->send(200); + return; } request->send(404); } @@ -1664,7 +1688,7 @@ bool WebServer::canHandle(AsyncWebServerRequest *request) { #endif #ifdef USE_ALARM_CONTROL_PANEL - if (request->method() == HTTP_GET && match.domain == "alarm_control_panel") + if ((request->method() == HTTP_GET || request->method() == HTTP_POST) && match.domain == "alarm_control_panel") return true; #endif From 6262fb8fcf9538d161d94512a857755c839eb48d Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Tue, 14 Jan 2025 08:32:54 +1100 Subject: [PATCH 074/194] [lvgl] fix tests (#8075) --- tests/components/lvgl/lvgl-package.yaml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index 234fd78678..7c59cfa171 100644 --- a/tests/components/lvgl/lvgl-package.yaml +++ b/tests/components/lvgl/lvgl-package.yaml @@ -795,6 +795,19 @@ lvgl: color: 0xA0A0A0 r_mod: -20 opa: 0% + - id: page3 + widgets: + - keyboard: + id: lv_keyboard + align: bottom_mid + on_value: + then: + - logger.log: + format: "keyboard value %s" + args: [text.c_str()] + - keyboard: + id: lv_keyboard1 + mode: special font: - file: "gfonts://Roboto" @@ -805,10 +818,13 @@ image: - id: cat_image resize: 256x48 file: $component_dir/logo-text.svg + type: RGB565 + use_transparency: alpha_channel - id: dog_image file: $component_dir/logo-text.svg resize: 256x48 - type: TRANSPARENT_BINARY + type: BINARY + use_transparency: chroma_key color: - id: light_blue From bdb1094b477baad40cfcf9d9bc86665c14069a55 Mon Sep 17 00:00:00 2001 From: Stefan Rado <628587+kroimon@users.noreply.github.com> Date: Tue, 14 Jan 2025 04:20:52 +0100 Subject: [PATCH 075/194] Allow external libraries to use ESP_LOGx macros (#8078) --- esphome/components/lvgl/lvgl_esphome.cpp | 20 +++++--------------- esphome/core/log.h | 14 +++++++------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/esphome/components/lvgl/lvgl_esphome.cpp b/esphome/components/lvgl/lvgl_esphome.cpp index 5abeead9d8..a9fe56fb32 100644 --- a/esphome/components/lvgl/lvgl_esphome.cpp +++ b/esphome/components/lvgl/lvgl_esphome.cpp @@ -501,9 +501,7 @@ size_t lv_millis(void) { return esphome::millis(); } void *lv_custom_mem_alloc(size_t size) { auto *ptr = malloc(size); // NOLINT if (ptr == nullptr) { -#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_ERROR - esphome::ESP_LOGE(esphome::lvgl::TAG, "Failed to allocate %zu bytes", size); -#endif + ESP_LOGE(esphome::lvgl::TAG, "Failed to allocate %zu bytes", size); } return ptr; } @@ -520,30 +518,22 @@ void *lv_custom_mem_alloc(size_t size) { ptr = heap_caps_malloc(size, cap_bits); } if (ptr == nullptr) { -#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_ERROR - esphome::ESP_LOGE(esphome::lvgl::TAG, "Failed to allocate %zu bytes", size); -#endif + ESP_LOGE(esphome::lvgl::TAG, "Failed to allocate %zu bytes", size); return nullptr; } -#ifdef ESPHOME_LOG_HAS_VERBOSE - esphome::ESP_LOGV(esphome::lvgl::TAG, "allocate %zu - > %p", size, ptr); -#endif + ESP_LOGV(esphome::lvgl::TAG, "allocate %zu - > %p", size, ptr); return ptr; } void lv_custom_mem_free(void *ptr) { -#ifdef ESPHOME_LOG_HAS_VERBOSE - esphome::ESP_LOGV(esphome::lvgl::TAG, "free %p", ptr); -#endif + ESP_LOGV(esphome::lvgl::TAG, "free %p", ptr); if (ptr == nullptr) return; heap_caps_free(ptr); } void *lv_custom_mem_realloc(void *ptr, size_t size) { -#ifdef ESPHOME_LOG_HAS_VERBOSE - esphome::ESP_LOGV(esphome::lvgl::TAG, "realloc %p: %zu", ptr, size); -#endif + ESP_LOGV(esphome::lvgl::TAG, "realloc %p: %zu", ptr, size); return heap_caps_realloc(ptr, size, cap_bits); } #endif diff --git a/esphome/core/log.h b/esphome/core/log.h index 86af534f98..99a68024c5 100644 --- a/esphome/core/log.h +++ b/esphome/core/log.h @@ -74,7 +74,7 @@ int esp_idf_log_vprintf_(const char *format, va_list args); // NOLINT #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE #define esph_log_vv(tag, format, ...) \ - esp_log_printf_(ESPHOME_LOG_LEVEL_VERY_VERBOSE, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) + ::esphome::esp_log_printf_(ESPHOME_LOG_LEVEL_VERY_VERBOSE, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) #define ESPHOME_LOG_HAS_VERY_VERBOSE #else @@ -83,7 +83,7 @@ int esp_idf_log_vprintf_(const char *format, va_list args); // NOLINT #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE #define esph_log_v(tag, format, ...) \ - esp_log_printf_(ESPHOME_LOG_LEVEL_VERBOSE, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) + ::esphome::esp_log_printf_(ESPHOME_LOG_LEVEL_VERBOSE, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) #define ESPHOME_LOG_HAS_VERBOSE #else @@ -92,9 +92,9 @@ int esp_idf_log_vprintf_(const char *format, va_list args); // NOLINT #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG #define esph_log_d(tag, format, ...) \ - esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) + ::esphome::esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) #define esph_log_config(tag, format, ...) \ - esp_log_printf_(ESPHOME_LOG_LEVEL_CONFIG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) + ::esphome::esp_log_printf_(ESPHOME_LOG_LEVEL_CONFIG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) #define ESPHOME_LOG_HAS_DEBUG #define ESPHOME_LOG_HAS_CONFIG @@ -105,7 +105,7 @@ int esp_idf_log_vprintf_(const char *format, va_list args); // NOLINT #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_INFO #define esph_log_i(tag, format, ...) \ - esp_log_printf_(ESPHOME_LOG_LEVEL_INFO, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) + ::esphome::esp_log_printf_(ESPHOME_LOG_LEVEL_INFO, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) #define ESPHOME_LOG_HAS_INFO #else @@ -114,7 +114,7 @@ int esp_idf_log_vprintf_(const char *format, va_list args); // NOLINT #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_WARN #define esph_log_w(tag, format, ...) \ - esp_log_printf_(ESPHOME_LOG_LEVEL_WARN, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) + ::esphome::esp_log_printf_(ESPHOME_LOG_LEVEL_WARN, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) #define ESPHOME_LOG_HAS_WARN #else @@ -123,7 +123,7 @@ int esp_idf_log_vprintf_(const char *format, va_list args); // NOLINT #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_ERROR #define esph_log_e(tag, format, ...) \ - esp_log_printf_(ESPHOME_LOG_LEVEL_ERROR, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) + ::esphome::esp_log_printf_(ESPHOME_LOG_LEVEL_ERROR, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) #define ESPHOME_LOG_HAS_ERROR #else From fc2b15e307833359f079aec46ceffd30b9398abe Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:27:47 +1100 Subject: [PATCH 076/194] [uptime] Add text_sensor (#8028) --- .../uptime/{sensor.py => sensor/__init__.py} | 6 +-- .../{ => sensor}/uptime_seconds_sensor.cpp | 0 .../{ => sensor}/uptime_seconds_sensor.h | 0 .../{ => sensor}/uptime_timestamp_sensor.cpp | 0 .../{ => sensor}/uptime_timestamp_sensor.h | 0 .../components/uptime/text_sensor/__init__.py | 19 ++++++++ .../uptime/text_sensor/uptime_text_sensor.cpp | 46 +++++++++++++++++++ .../uptime/text_sensor/uptime_text_sensor.h | 25 ++++++++++ tests/components/uptime/common.yaml | 4 ++ 9 files changed, 97 insertions(+), 3 deletions(-) rename esphome/components/uptime/{sensor.py => sensor/__init__.py} (100%) rename esphome/components/uptime/{ => sensor}/uptime_seconds_sensor.cpp (100%) rename esphome/components/uptime/{ => sensor}/uptime_seconds_sensor.h (100%) rename esphome/components/uptime/{ => sensor}/uptime_timestamp_sensor.cpp (100%) rename esphome/components/uptime/{ => sensor}/uptime_timestamp_sensor.h (100%) create mode 100644 esphome/components/uptime/text_sensor/__init__.py create mode 100644 esphome/components/uptime/text_sensor/uptime_text_sensor.cpp create mode 100644 esphome/components/uptime/text_sensor/uptime_text_sensor.h diff --git a/esphome/components/uptime/sensor.py b/esphome/components/uptime/sensor/__init__.py similarity index 100% rename from esphome/components/uptime/sensor.py rename to esphome/components/uptime/sensor/__init__.py index 30220751b6..e2a7aee1a2 100644 --- a/esphome/components/uptime/sensor.py +++ b/esphome/components/uptime/sensor/__init__.py @@ -1,14 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, time +import esphome.config_validation as cv from esphome.const import ( CONF_TIME_ID, + DEVICE_CLASS_DURATION, DEVICE_CLASS_TIMESTAMP, ENTITY_CATEGORY_DIAGNOSTIC, + ICON_TIMER, STATE_CLASS_TOTAL_INCREASING, UNIT_SECOND, - ICON_TIMER, - DEVICE_CLASS_DURATION, ) uptime_ns = cg.esphome_ns.namespace("uptime") diff --git a/esphome/components/uptime/uptime_seconds_sensor.cpp b/esphome/components/uptime/sensor/uptime_seconds_sensor.cpp similarity index 100% rename from esphome/components/uptime/uptime_seconds_sensor.cpp rename to esphome/components/uptime/sensor/uptime_seconds_sensor.cpp diff --git a/esphome/components/uptime/uptime_seconds_sensor.h b/esphome/components/uptime/sensor/uptime_seconds_sensor.h similarity index 100% rename from esphome/components/uptime/uptime_seconds_sensor.h rename to esphome/components/uptime/sensor/uptime_seconds_sensor.h diff --git a/esphome/components/uptime/uptime_timestamp_sensor.cpp b/esphome/components/uptime/sensor/uptime_timestamp_sensor.cpp similarity index 100% rename from esphome/components/uptime/uptime_timestamp_sensor.cpp rename to esphome/components/uptime/sensor/uptime_timestamp_sensor.cpp diff --git a/esphome/components/uptime/uptime_timestamp_sensor.h b/esphome/components/uptime/sensor/uptime_timestamp_sensor.h similarity index 100% rename from esphome/components/uptime/uptime_timestamp_sensor.h rename to esphome/components/uptime/sensor/uptime_timestamp_sensor.h diff --git a/esphome/components/uptime/text_sensor/__init__.py b/esphome/components/uptime/text_sensor/__init__.py new file mode 100644 index 0000000000..996d983e71 --- /dev/null +++ b/esphome/components/uptime/text_sensor/__init__.py @@ -0,0 +1,19 @@ +import esphome.codegen as cg +from esphome.components import text_sensor +import esphome.config_validation as cv +from esphome.const import ENTITY_CATEGORY_DIAGNOSTIC, ICON_TIMER + +uptime_ns = cg.esphome_ns.namespace("uptime") +UptimeTextSensor = uptime_ns.class_( + "UptimeTextSensor", text_sensor.TextSensor, cg.PollingComponent +) +CONFIG_SCHEMA = text_sensor.text_sensor_schema( + UptimeTextSensor, + icon=ICON_TIMER, + entity_category=ENTITY_CATEGORY_DIAGNOSTIC, +).extend(cv.polling_component_schema("60s")) + + +async def to_code(config): + var = await text_sensor.new_text_sensor(config) + await cg.register_component(var, config) diff --git a/esphome/components/uptime/text_sensor/uptime_text_sensor.cpp b/esphome/components/uptime/text_sensor/uptime_text_sensor.cpp new file mode 100644 index 0000000000..0fa5e199f3 --- /dev/null +++ b/esphome/components/uptime/text_sensor/uptime_text_sensor.cpp @@ -0,0 +1,46 @@ +#include "uptime_text_sensor.h" + +#include "esphome/core/hal.h" +#include "esphome/core/helpers.h" +#include "esphome/core/log.h" + +namespace esphome { +namespace uptime { + +static const char *const TAG = "uptime.sensor"; + +void UptimeTextSensor::setup() { this->last_ms_ = millis(); } + +void UptimeTextSensor::update() { + const auto now = millis(); + // get whole seconds since last update. Note that even if the millis count has overflowed between updates, + // the difference will still be correct due to the way twos-complement arithmetic works. + const uint32_t delta = (now - this->last_ms_) / 1000; + if (delta == 0) + return; + // set last_ms_ to the last second boundary + this->last_ms_ = now - (now % 1000); + this->uptime_ += delta; + auto uptime = this->uptime_; + unsigned days = uptime / (24 * 3600); + unsigned seconds = uptime % (24 * 3600); + unsigned hours = seconds / 3600; + seconds %= 3600; + unsigned minutes = seconds / 60; + seconds %= 60; + if (days != 0) { + this->publish_state(str_sprintf("%dd%dh%dm%ds", days, hours, minutes, seconds)); + } else if (hours != 0) { + this->publish_state(str_sprintf("%dh%dm%ds", hours, minutes, seconds)); + } else if (minutes != 0) { + this->publish_state(str_sprintf("%dm%ds", minutes, seconds)); + } else { + this->publish_state(str_sprintf("%ds", seconds)); + } +} + +float UptimeTextSensor::get_setup_priority() const { return setup_priority::HARDWARE; } +void UptimeTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Uptime Text Sensor", this); } + +} // namespace uptime +} // namespace esphome diff --git a/esphome/components/uptime/text_sensor/uptime_text_sensor.h b/esphome/components/uptime/text_sensor/uptime_text_sensor.h new file mode 100644 index 0000000000..4baf1039b6 --- /dev/null +++ b/esphome/components/uptime/text_sensor/uptime_text_sensor.h @@ -0,0 +1,25 @@ +#pragma once + +#include "esphome/core/defines.h" + +#include "esphome/components/text_sensor/text_sensor.h" +#include "esphome/core/component.h" + +namespace esphome { +namespace uptime { + +class UptimeTextSensor : public text_sensor::TextSensor, public PollingComponent { + public: + void update() override; + void dump_config() override; + void setup() override; + + float get_setup_priority() const override; + + protected: + uint64_t uptime_{0}; + uint64_t last_ms_{0}; +}; + +} // namespace uptime +} // namespace esphome diff --git a/tests/components/uptime/common.yaml b/tests/components/uptime/common.yaml index f63f80b050..d78ef8eca9 100644 --- a/tests/components/uptime/common.yaml +++ b/tests/components/uptime/common.yaml @@ -13,3 +13,7 @@ sensor: - platform: uptime name: Uptime Sensor Timestamp type: timestamp + +text_sensor: + - platform: uptime + name: Uptime Text From c3412df169a0fc742b5bf854245d6a07adef836d Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:29:27 +1100 Subject: [PATCH 077/194] [image] Fix mdi images (#8082) --- esphome/components/image/__init__.py | 39 ++++++++++++++++++++++------ esphome/components/image/image.cpp | 35 +++++++++++++++++++++---- 2 files changed, 61 insertions(+), 13 deletions(-) diff --git a/esphome/components/image/__init__.py b/esphome/components/image/__init__.py index 801b05e160..a503e8f471 100644 --- a/esphome/components/image/__init__.py +++ b/esphome/components/image/__init__.py @@ -82,11 +82,13 @@ class ImageEncoder: self.dither = dither self.index = 0 self.invert_alpha = invert_alpha + self.path = "" - def convert(self, image): + def convert(self, image, path): """ Convert the image format :param image: Input image + :param path: Path to the image file :return: converted image """ return image @@ -103,6 +105,16 @@ class ImageEncoder: """ +def is_alpha_only(image: Image): + """ + Check if an image (assumed to be RGBA) is only alpha + """ + # Any alpha data? + if image.split()[-1].getextrema()[0] == 0xFF: + return False + return all(b.getextrema()[1] == 0 for b in image.split()[:-1]) + + class ImageBinary(ImageEncoder): allow_config = {CONF_OPAQUE, CONF_INVERT_ALPHA, CONF_CHROMA_KEY} @@ -111,7 +123,9 @@ class ImageBinary(ImageEncoder): super().__init__(self.width8, height, transparency, dither, invert_alpha) self.bitno = 0 - def convert(self, image): + def convert(self, image, path): + if is_alpha_only(image): + image = image.split()[-1] return image.convert("1", dither=self.dither) def encode(self, pixel): @@ -136,7 +150,16 @@ class ImageBinary(ImageEncoder): class ImageGrayscale(ImageEncoder): allow_config = {CONF_ALPHA_CHANNEL, CONF_CHROMA_KEY, CONF_INVERT_ALPHA, CONF_OPAQUE} - def convert(self, image): + def convert(self, image, path): + if is_alpha_only(image): + if self.transparency != CONF_ALPHA_CHANNEL: + _LOGGER.warning( + "Grayscale image %s is alpha only, but transparency is set to %s", + path, + self.transparency, + ) + self.transparency = CONF_ALPHA_CHANNEL + image = image.split()[-1] return image.convert("LA") def encode(self, pixel): @@ -166,7 +189,7 @@ class ImageRGB565(ImageEncoder): invert_alpha, ) - def convert(self, image): + def convert(self, image, path): return image.convert("RGBA") def encode(self, pixel): @@ -204,7 +227,7 @@ class ImageRGB(ImageEncoder): invert_alpha, ) - def convert(self, image): + def convert(self, image, path): return image.convert("RGBA") def encode(self, pixel): @@ -308,7 +331,7 @@ def is_svg_file(file): if not file: return False with open(file, "rb") as f: - return "get_grayscale_pixel_(img_x, img_y); - if (color.w >= 0x80) { - display->draw_pixel_at(x + img_x, y + img_y, color); + const uint32_t pos = (img_x + img_y * this->width_); + const uint8_t gray = progmem_read_byte(this->data_start_ + pos); + Color color = Color(gray, gray, gray, 0xFF); + switch (this->transparency_) { + case TRANSPARENCY_CHROMA_KEY: + if (gray == 1) { + continue; // skip drawing + } + break; + case TRANSPARENCY_ALPHA_CHANNEL: { + auto on = (float) gray / 255.0f; + auto off = 1.0f - on; + // blend color_on and color_off + color = Color(color_on.r * on + color_off.r * off, color_on.g * on + color_off.g * off, + color_on.b * on + color_off.b * off, 0xFF); + break; + } + default: + break; } + display->draw_pixel_at(x + img_x, y + img_y, color); } } break; @@ -179,8 +196,16 @@ Color Image::get_rgb565_pixel_(int x, int y) const { Color Image::get_grayscale_pixel_(int x, int y) const { const uint32_t pos = (x + y * this->width_); const uint8_t gray = progmem_read_byte(this->data_start_ + pos); - uint8_t alpha = (gray == 1 && this->transparency_ == TRANSPARENCY_CHROMA_KEY) ? 0 : 0xFF; - return Color(gray, gray, gray, alpha); + switch (this->transparency_) { + case TRANSPARENCY_CHROMA_KEY: + if (gray == 1) + return Color(0, 0, 0, 0); + return Color(gray, gray, gray, 0xFF); + case TRANSPARENCY_ALPHA_CHANNEL: + return Color(0, 0, 0, gray); + default: + return Color(gray, gray, gray, 0xFF); + } } int Image::get_width() const { return this->width_; } int Image::get_height() const { return this->height_; } From e8d2ad4ce856ab2e2ae9b156c6f0cbe10f069ddf Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:53:44 +1100 Subject: [PATCH 078/194] [ili9xxx] psram and 8 bit changes (#8084) --- esphome/components/ili9xxx/display.py | 40 ++++++++++++++----- .../components/ili9xxx/ili9xxx_display.cpp | 7 +--- esphome/components/ili9xxx/ili9xxx_display.h | 3 +- tests/components/ili9xxx/test.esp32-ard.yaml | 1 + 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/esphome/components/ili9xxx/display.py b/esphome/components/ili9xxx/display.py index 3c9dd2dab9..e3abb7e98c 100644 --- a/esphome/components/ili9xxx/display.py +++ b/esphome/components/ili9xxx/display.py @@ -1,9 +1,12 @@ +import logging + from esphome import core, pins import esphome.codegen as cg from esphome.components import display, spi from esphome.components.display import validate_rotation import esphome.config_validation as cv from esphome.const import ( + CONF_AUTO_CLEAR_ENABLED, CONF_COLOR_ORDER, CONF_COLOR_PALETTE, CONF_DC_PIN, @@ -27,17 +30,12 @@ from esphome.const import ( CONF_WIDTH, ) from esphome.core import CORE, HexInt +from esphome.final_validate import full_config DEPENDENCIES = ["spi"] - -def AUTO_LOAD(): - if CORE.is_esp32: - return ["psram"] - return [] - - CODEOWNERS = ["@nielsnl68", "@clydebarrow"] +LOGGER = logging.getLogger(__name__) ili9xxx_ns = cg.esphome_ns.namespace("ili9xxx") ILI9XXXDisplay = ili9xxx_ns.class_( @@ -84,7 +82,7 @@ COLOR_ORDERS = { "BGR": ColorOrder.COLOR_ORDER_BGR, } -COLOR_PALETTE = cv.one_of("NONE", "GRAYSCALE", "IMAGE_ADAPTIVE") +COLOR_PALETTE = cv.one_of("NONE", "GRAYSCALE", "IMAGE_ADAPTIVE", "8BIT", upper=True) CONF_LED_PIN = "led_pin" CONF_COLOR_PALETTE_IMAGES = "color_palette_images" @@ -195,9 +193,27 @@ CONFIG_SCHEMA = cv.All( _validate, ) -FINAL_VALIDATE_SCHEMA = spi.final_validate_device_schema( - "ili9xxx", require_miso=False, require_mosi=True -) + +def final_validate(config): + global_config = full_config.get() + # Ideally would calculate buffer size here, but that info is not available on the Python side + needs_buffer = ( + CONF_LAMBDA in config or CONF_PAGES in config or config[CONF_AUTO_CLEAR_ENABLED] + ) + if ( + CORE.is_esp32 + and config[CONF_COLOR_PALETTE] == "NONE" + and "psram" not in global_config + and needs_buffer + ): + LOGGER.info("Consider enabling PSRAM if available for the display buffer") + + return spi.final_validate_device_schema( + "ili9xxx", require_miso=False, require_mosi=True + ) + + +FINAL_VALIDATE_SCHEMA = final_validate async def to_code(config): @@ -283,6 +299,8 @@ async def to_code(config): palette = converted.getpalette() assert len(palette) == 256 * 3 rhs = palette + elif config[CONF_COLOR_PALETTE] == "8BIT": + cg.add(var.set_buffer_color_mode(ILI9XXXColorMode.BITS_8)) else: cg.add(var.set_buffer_color_mode(ILI9XXXColorMode.BITS_16)) diff --git a/esphome/components/ili9xxx/ili9xxx_display.cpp b/esphome/components/ili9xxx/ili9xxx_display.cpp index b9664067a9..f056f0a128 100644 --- a/esphome/components/ili9xxx/ili9xxx_display.cpp +++ b/esphome/components/ili9xxx/ili9xxx_display.cpp @@ -66,12 +66,9 @@ void ILI9XXXDisplay::setup() { void ILI9XXXDisplay::alloc_buffer_() { if (this->buffer_color_mode_ == BITS_16) { this->init_internal_(this->get_buffer_length_() * 2); - if (this->buffer_ != nullptr) { - return; - } - this->buffer_color_mode_ = BITS_8; + } else { + this->init_internal_(this->get_buffer_length_()); } - this->init_internal_(this->get_buffer_length_()); if (this->buffer_ == nullptr) { this->mark_failed(); } diff --git a/esphome/components/ili9xxx/ili9xxx_display.h b/esphome/components/ili9xxx/ili9xxx_display.h index c141739d2a..87d7c86e5c 100644 --- a/esphome/components/ili9xxx/ili9xxx_display.h +++ b/esphome/components/ili9xxx/ili9xxx_display.h @@ -98,7 +98,8 @@ class ILI9XXXDisplay : public display::DisplayBuffer, protected: inline bool check_buffer_() { if (this->buffer_ == nullptr) { - this->alloc_buffer_(); + if (!this->is_failed()) + this->alloc_buffer_(); return !this->is_failed(); } return true; diff --git a/tests/components/ili9xxx/test.esp32-ard.yaml b/tests/components/ili9xxx/test.esp32-ard.yaml index 850273230a..c00c38ce3e 100644 --- a/tests/components/ili9xxx/test.esp32-ard.yaml +++ b/tests/components/ili9xxx/test.esp32-ard.yaml @@ -20,6 +20,7 @@ display: it.rectangle(0, 0, it.get_width(), it.get_height()); - platform: ili9xxx invert_colors: false + color_palette: 8bit dimensions: width: 320 height: 240 From dac9768f6ac897d46b093ecee81ee64101b29b59 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 15 Jan 2025 11:56:52 +1100 Subject: [PATCH 079/194] [spi] Restore ``SPIDelegateDummy`` (#8019) --- esphome/components/spi/spi.cpp | 6 ++++++ esphome/components/spi/spi.h | 21 +++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/esphome/components/spi/spi.cpp b/esphome/components/spi/spi.cpp index f9435b0424..b13826c443 100644 --- a/esphome/components/spi/spi.cpp +++ b/esphome/components/spi/spi.cpp @@ -7,6 +7,10 @@ namespace spi { const char *const TAG = "spi"; +SPIDelegate *const SPIDelegate::NULL_DELEGATE = // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) + new SPIDelegateDummy(); +// https://bugs.llvm.org/show_bug.cgi?id=48040 + bool SPIDelegate::is_ready() { return true; } GPIOPin *const NullPin::NULL_PIN = new NullPin(); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) @@ -75,6 +79,8 @@ void SPIComponent::dump_config() { } } +void SPIDelegateDummy::begin_transaction() { ESP_LOGE(TAG, "SPIDevice not initialised - did you call spi_setup()?"); } + uint8_t SPIDelegateBitBash::transfer(uint8_t data) { return this->transfer_(data, 8); } void SPIDelegateBitBash::write(uint16_t data, size_t num_bits) { this->transfer_(data, num_bits); } diff --git a/esphome/components/spi/spi.h b/esphome/components/spi/spi.h index 4cd8d3383c..f581dc3f56 100644 --- a/esphome/components/spi/spi.h +++ b/esphome/components/spi/spi.h @@ -163,6 +163,8 @@ class Utility { } }; +class SPIDelegateDummy; + // represents a device attached to an SPI bus, with a defined clock rate, mode and bit order. On Arduino this is // a thin wrapper over SPIClass. class SPIDelegate { @@ -248,6 +250,21 @@ class SPIDelegate { uint32_t data_rate_{1000000}; SPIMode mode_{MODE0}; GPIOPin *cs_pin_{NullPin::NULL_PIN}; + static SPIDelegate *const NULL_DELEGATE; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) +}; + +/** + * A dummy SPIDelegate that complains if it's used. + */ + +class SPIDelegateDummy : public SPIDelegate { + public: + SPIDelegateDummy() = default; + + uint8_t transfer(uint8_t data) override { return 0; } + void end_transaction() override{}; + + void begin_transaction() override; }; /** @@ -365,7 +382,7 @@ class SPIClient { virtual void spi_teardown() { this->parent_->unregister_device(this); - this->delegate_ = nullptr; + this->delegate_ = SPIDelegate::NULL_DELEGATE; } bool spi_is_ready() { return this->delegate_->is_ready(); } @@ -376,7 +393,7 @@ class SPIClient { uint32_t data_rate_{1000000}; SPIComponent *parent_{nullptr}; GPIOPin *cs_{nullptr}; - SPIDelegate *delegate_{nullptr}; + SPIDelegate *delegate_{SPIDelegate::NULL_DELEGATE}; }; /** From 17b88f2e3e5d873b1961b40e4c1fb6acccfc1305 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 15 Jan 2025 12:29:51 +1100 Subject: [PATCH 080/194] [lvgl] fix lvgl.widget.update and friends (#8087) --- esphome/components/lvgl/automation.py | 15 +++++++++++- esphome/components/lvgl/schemas.py | 27 ++++++++++++++------- esphome/components/lvgl/widgets/dropdown.py | 2 +- esphome/components/lvgl/widgets/keyboard.py | 9 ++++++- esphome/components/lvgl/widgets/msgbox.py | 2 +- esphome/components/lvgl/widgets/obj.py | 13 +--------- esphome/components/lvgl/widgets/tabview.py | 2 +- tests/components/lvgl/lvgl-package.yaml | 15 ++++++++++++ 8 files changed, 59 insertions(+), 26 deletions(-) diff --git a/esphome/components/lvgl/automation.py b/esphome/components/lvgl/automation.py index 7db6e1f045..168fc03cb7 100644 --- a/esphome/components/lvgl/automation.py +++ b/esphome/components/lvgl/automation.py @@ -15,6 +15,7 @@ from .defines import ( CONF_FREEZE, CONF_LVGL_ID, CONF_SHOW_SNOW, + PARTS, literal, ) from .lv_validation import lv_bool, lv_color, lv_image, opacity @@ -33,7 +34,7 @@ from .lvcode import ( lvgl_comp, static_cast, ) -from .schemas import DISP_BG_SCHEMA, LIST_ACTION_SCHEMA, LVGL_SCHEMA +from .schemas import DISP_BG_SCHEMA, LIST_ACTION_SCHEMA, LVGL_SCHEMA, base_update_schema from .types import ( LV_STATE, LvglAction, @@ -41,6 +42,7 @@ from .types import ( ObjUpdateAction, lv_disp_t, lv_group_t, + lv_obj_base_t, lv_obj_t, lv_pseudo_button_t, ) @@ -336,3 +338,14 @@ async def widget_focus(config, action_id, template_arg, args): lv.group_focus_freeze(group, True) var = cg.new_Pvariable(action_id, template_arg, await context.get_lambda()) return var + + +@automation.register_action( + "lvgl.widget.update", ObjUpdateAction, base_update_schema(lv_obj_base_t, PARTS) +) +async def obj_update_to_code(config, action_id, template_arg, args): + async def do_update(widget: Widget): + await set_obj_properties(widget, config) + + widgets = await get_widgets(config[CONF_ID]) + return await action_to_code(widgets, do_update, action_id, template_arg, args) diff --git a/esphome/components/lvgl/schemas.py b/esphome/components/lvgl/schemas.py index 271dbea19f..f0318dd17a 100644 --- a/esphome/components/lvgl/schemas.py +++ b/esphome/components/lvgl/schemas.py @@ -199,13 +199,12 @@ FLAG_SCHEMA = cv.Schema({cv.Optional(flag): lvalid.lv_bool for flag in df.OBJ_FL FLAG_LIST = cv.ensure_list(df.LvConstant("LV_OBJ_FLAG_", *df.OBJ_FLAGS).one_of) -def part_schema(widget_type: WidgetType): +def part_schema(parts): """ Generate a schema for the various parts (e.g. main:, indicator:) of a widget type - :param widget_type: The type of widget to generate for - :return: + :param parts: The parts to include in the schema + :return: The schema """ - parts = widget_type.parts return cv.Schema({cv.Optional(part): STATE_SCHEMA for part in parts}).extend( STATE_SCHEMA ) @@ -228,9 +227,15 @@ def automation_schema(typ: LvType): } -def create_modify_schema(widget_type): +def base_update_schema(widget_type, parts): + """ + Create a schema for updating a widgets style properties, states and flags + :param widget_type: The type of the ID + :param parts: The allowable parts to specify + :return: + """ return ( - part_schema(widget_type) + part_schema(parts) .extend( { cv.Required(CONF_ID): cv.ensure_list( @@ -245,7 +250,12 @@ def create_modify_schema(widget_type): } ) .extend(FLAG_SCHEMA) - .extend(widget_type.modify_schema) + ) + + +def create_modify_schema(widget_type): + return base_update_schema(widget_type.w_type, widget_type.parts).extend( + widget_type.modify_schema ) @@ -256,7 +266,7 @@ def obj_schema(widget_type: WidgetType): :return: """ return ( - part_schema(widget_type) + part_schema(widget_type.parts) .extend(FLAG_SCHEMA) .extend(LAYOUT_SCHEMA) .extend(ALIGN_TO_SCHEMA) @@ -341,7 +351,6 @@ FLEX_OBJ_SCHEMA = { cv.Optional(df.CONF_FLEX_GROW): cv.int_, } - DISP_BG_SCHEMA = cv.Schema( { cv.Optional(df.CONF_DISP_BG_IMAGE): cv.Any( diff --git a/esphome/components/lvgl/widgets/dropdown.py b/esphome/components/lvgl/widgets/dropdown.py index a6bfc6bb88..b32b5a2b2e 100644 --- a/esphome/components/lvgl/widgets/dropdown.py +++ b/esphome/components/lvgl/widgets/dropdown.py @@ -37,7 +37,7 @@ DROPDOWN_BASE_SCHEMA = cv.Schema( cv.Exclusive(CONF_SELECTED_INDEX, CONF_SELECTED_TEXT): lv_int, cv.Exclusive(CONF_SELECTED_TEXT, CONF_SELECTED_TEXT): lv_text, cv.Optional(CONF_DIR, default="BOTTOM"): DIRECTIONS.one_of, - cv.Optional(CONF_DROPDOWN_LIST): part_schema(dropdown_list_spec), + cv.Optional(CONF_DROPDOWN_LIST): part_schema(dropdown_list_spec.parts), } ) diff --git a/esphome/components/lvgl/widgets/keyboard.py b/esphome/components/lvgl/widgets/keyboard.py index ba7edb302e..d4a71078d0 100644 --- a/esphome/components/lvgl/widgets/keyboard.py +++ b/esphome/components/lvgl/widgets/keyboard.py @@ -16,6 +16,11 @@ KEYBOARD_SCHEMA = { cv.Optional(CONF_TEXTAREA): cv.use_id(lv_textarea_t), } +KEYBOARD_MODIFY_SCHEMA = { + cv.Optional(CONF_MODE): KEYBOARD_MODES.one_of, + cv.Optional(CONF_TEXTAREA): cv.use_id(lv_textarea_t), +} + lv_keyboard_t = LvType( "LvKeyboardType", parents=(KeyProvider, LvCompound), @@ -32,6 +37,7 @@ class KeyboardType(WidgetType): lv_keyboard_t, (CONF_MAIN, CONF_ITEMS), KEYBOARD_SCHEMA, + modify_schema=KEYBOARD_MODIFY_SCHEMA, ) def get_uses(self): @@ -41,7 +47,8 @@ class KeyboardType(WidgetType): lvgl_components_required.add("KEY_LISTENER") lvgl_components_required.add(CONF_KEYBOARD) add_lv_use("btnmatrix") - await w.set_property(CONF_MODE, await KEYBOARD_MODES.process(config[CONF_MODE])) + if mode := config.get(CONF_MODE): + await w.set_property(CONF_MODE, await KEYBOARD_MODES.process(mode)) if ta := await get_widgets(config, CONF_TEXTAREA): await w.set_property(CONF_TEXTAREA, ta[0].obj) diff --git a/esphome/components/lvgl/widgets/msgbox.py b/esphome/components/lvgl/widgets/msgbox.py index c3393940b6..82b2442378 100644 --- a/esphome/components/lvgl/widgets/msgbox.py +++ b/esphome/components/lvgl/widgets/msgbox.py @@ -51,7 +51,7 @@ MSGBOX_SCHEMA = container_schema( cv.Required(CONF_TITLE): STYLED_TEXT_SCHEMA, cv.Optional(CONF_BODY, default=""): STYLED_TEXT_SCHEMA, cv.Optional(CONF_BUTTONS): cv.ensure_list(BUTTONMATRIX_BUTTON_SCHEMA), - cv.Optional(CONF_BUTTON_STYLE): part_schema(buttonmatrix_spec), + cv.Optional(CONF_BUTTON_STYLE): part_schema(buttonmatrix_spec.parts), cv.Optional(CONF_CLOSE_BUTTON, default=True): lv_bool, cv.GenerateID(CONF_BUTTON_TEXT_LIST_ID): cv.declare_id(char_ptr), } diff --git a/esphome/components/lvgl/widgets/obj.py b/esphome/components/lvgl/widgets/obj.py index afb4c97f33..ab22a5ce86 100644 --- a/esphome/components/lvgl/widgets/obj.py +++ b/esphome/components/lvgl/widgets/obj.py @@ -1,9 +1,5 @@ -from esphome import automation - -from ..automation import update_to_code from ..defines import CONF_MAIN, CONF_OBJ, CONF_SCROLLBAR -from ..schemas import create_modify_schema -from ..types import ObjUpdateAction, WidgetType, lv_obj_t +from ..types import WidgetType, lv_obj_t class ObjType(WidgetType): @@ -21,10 +17,3 @@ class ObjType(WidgetType): obj_spec = ObjType() - - -@automation.register_action( - "lvgl.widget.update", ObjUpdateAction, create_modify_schema(obj_spec) -) -async def obj_update_to_code(config, action_id, template_arg, args): - return await update_to_code(config, action_id, template_arg, args) diff --git a/esphome/components/lvgl/widgets/tabview.py b/esphome/components/lvgl/widgets/tabview.py index 226fc3f286..1d18ddd259 100644 --- a/esphome/components/lvgl/widgets/tabview.py +++ b/esphome/components/lvgl/widgets/tabview.py @@ -38,7 +38,7 @@ TABVIEW_SCHEMA = cv.Schema( }, ) ), - cv.Optional(CONF_TAB_STYLE): part_schema(buttonmatrix_spec), + cv.Optional(CONF_TAB_STYLE): part_schema(buttonmatrix_spec.parts), cv.Optional(CONF_POSITION, default="top"): DIRECTIONS.one_of, cv.Optional(CONF_SIZE, default="10%"): size, } diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index 7c59cfa171..b3227bb96e 100644 --- a/tests/components/lvgl/lvgl-package.yaml +++ b/tests/components/lvgl/lvgl-package.yaml @@ -805,9 +805,24 @@ lvgl: - logger.log: format: "keyboard value %s" args: [text.c_str()] + - lvgl.keyboard.update: + id: lv_keyboard + hidden: true + on_ready: + - lvgl.widget.update: + id: lv_keyboard + - lvgl.keyboard.update: + id: lv_keyboard + hidden: true + - keyboard: id: lv_keyboard1 mode: special + on_ready: + lvgl.keyboard.update: + id: lv_keyboard1 + hidden: true + mode: text_lower font: - file: "gfonts://Roboto" From c43d8460bdbc8d2e3c77986e55dbdc7deee99184 Mon Sep 17 00:00:00 2001 From: Saninn Salas Diaz <5490201+distante@users.noreply.github.com> Date: Wed, 15 Jan 2025 03:14:58 +0100 Subject: [PATCH 081/194] fix(web_server/fan): send speed update values even when fan is off (#8086) --- esphome/components/web_server/web_server.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/esphome/components/web_server/web_server.cpp b/esphome/components/web_server/web_server.cpp index ed0cb3db2c..8c09d607a7 100644 --- a/esphome/components/web_server/web_server.cpp +++ b/esphome/components/web_server/web_server.cpp @@ -455,8 +455,9 @@ void WebServer::handle_fan_request(AsyncWebServerRequest *request, const UrlMatc } else if (match.method == "toggle") { this->schedule_([obj]() { obj->toggle().perform(); }); request->send(200); - } else if (match.method == "turn_on") { - auto call = obj->turn_on(); + } else if (match.method == "turn_on" || match.method == "turn_off") { + auto call = match.method == "turn_on" ? obj->turn_on() : obj->turn_off(); + if (request->hasParam("speed_level")) { auto speed_level = request->getParam("speed_level")->value(); auto val = parse_number(speed_level.c_str()); @@ -486,9 +487,6 @@ void WebServer::handle_fan_request(AsyncWebServerRequest *request, const UrlMatc } this->schedule_([call]() mutable { call.perform(); }); request->send(200); - } else if (match.method == "turn_off") { - this->schedule_([obj]() { obj->turn_off().perform(); }); - request->send(200); } else { request->send(404); } From 98817a5bbfacced643d1046135eea26099a0ac36 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Tue, 14 Jan 2025 21:47:22 -0600 Subject: [PATCH 082/194] [es7210] add support for es7210 ADC (#8007) --- CODEOWNERS | 1 + esphome/components/es7210/__init__.py | 67 ++++++ esphome/components/es7210/es7210.cpp | 201 ++++++++++++++++++ esphome/components/es7210/es7210.h | 69 ++++++ esphome/components/es7210/es7210_const.h | 126 +++++++++++ esphome/components/es8311/audio_dac.py | 3 +- esphome/const.py | 1 + tests/components/es7210/common.yaml | 6 + tests/components/es7210/test.esp32-ard.yaml | 5 + .../components/es7210/test.esp32-c3-ard.yaml | 5 + .../components/es7210/test.esp32-c3-idf.yaml | 5 + tests/components/es7210/test.esp32-idf.yaml | 5 + 12 files changed, 492 insertions(+), 2 deletions(-) create mode 100644 esphome/components/es7210/__init__.py create mode 100644 esphome/components/es7210/es7210.cpp create mode 100644 esphome/components/es7210/es7210.h create mode 100644 esphome/components/es7210/es7210_const.h create mode 100644 tests/components/es7210/common.yaml create mode 100644 tests/components/es7210/test.esp32-ard.yaml create mode 100644 tests/components/es7210/test.esp32-c3-ard.yaml create mode 100644 tests/components/es7210/test.esp32-c3-idf.yaml create mode 100644 tests/components/es7210/test.esp32-idf.yaml diff --git a/CODEOWNERS b/CODEOWNERS index 088e350f5d..ba7106e6a3 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -131,6 +131,7 @@ esphome/components/ens160_base/* @latonita @vincentscode esphome/components/ens160_i2c/* @latonita esphome/components/ens160_spi/* @latonita esphome/components/ens210/* @itn3rd77 +esphome/components/es7210/* @kahrendt esphome/components/es8311/* @kahrendt @kroimon esphome/components/esp32/* @esphome/core esphome/components/esp32_ble/* @Rapsssito @jesserockz diff --git a/esphome/components/es7210/__init__.py b/esphome/components/es7210/__init__.py new file mode 100644 index 0000000000..8e63d7f04f --- /dev/null +++ b/esphome/components/es7210/__init__.py @@ -0,0 +1,67 @@ +import esphome.codegen as cg +from esphome.components import i2c +import esphome.config_validation as cv +from esphome.const import CONF_BITS_PER_SAMPLE, CONF_ID, CONF_MIC_GAIN, CONF_SAMPLE_RATE + +CODEOWNERS = ["@kahrendt"] +DEPENDENCIES = ["i2c"] + +es7210_ns = cg.esphome_ns.namespace("es7210") +ES7210 = es7210_ns.class_("ES7210", cg.Component, i2c.I2CDevice) + + +es7210_bits_per_sample = es7210_ns.enum("ES7210BitsPerSample") +ES7210_BITS_PER_SAMPLE_ENUM = { + 16: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_16, + 24: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_24, + 32: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_32, +} + + +es7210_mic_gain = es7210_ns.enum("ES7210MicGain") +ES7210_MIC_GAIN_ENUM = { + "0DB": es7210_mic_gain.ES7210_MIC_GAIN_0DB, + "3DB": es7210_mic_gain.ES7210_MIC_GAIN_3DB, + "6DB": es7210_mic_gain.ES7210_MIC_GAIN_6DB, + "9DB": es7210_mic_gain.ES7210_MIC_GAIN_9DB, + "12DB": es7210_mic_gain.ES7210_MIC_GAIN_12DB, + "15DB": es7210_mic_gain.ES7210_MIC_GAIN_15DB, + "18DB": es7210_mic_gain.ES7210_MIC_GAIN_18DB, + "21DB": es7210_mic_gain.ES7210_MIC_GAIN_21DB, + "24DB": es7210_mic_gain.ES7210_MIC_GAIN_24DB, + "27DB": es7210_mic_gain.ES7210_MIC_GAIN_27DB, + "30DB": es7210_mic_gain.ES7210_MIC_GAIN_30DB, + "33DB": es7210_mic_gain.ES7210_MIC_GAIN_33DB, + "34.5DB": es7210_mic_gain.ES7210_MIC_GAIN_34_5DB, + "36DB": es7210_mic_gain.ES7210_MIC_GAIN_36DB, + "37.5DB": es7210_mic_gain.ES7210_MIC_GAIN_37_5DB, +} + +_validate_bits = cv.float_with_unit("bits", "bit") + +CONFIG_SCHEMA = ( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(ES7210), + cv.Optional(CONF_BITS_PER_SAMPLE, default="16bit"): cv.All( + _validate_bits, cv.enum(ES7210_BITS_PER_SAMPLE_ENUM) + ), + cv.Optional(CONF_MIC_GAIN, default="24DB"): cv.enum( + ES7210_MIC_GAIN_ENUM, upper=True + ), + cv.Optional(CONF_SAMPLE_RATE, default=16000): cv.int_range(min=1), + } + ) + .extend(cv.COMPONENT_SCHEMA) + .extend(i2c.i2c_device_schema(0x40)) +) + + +async def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + + cg.add(var.set_bits_per_sample(config[CONF_BITS_PER_SAMPLE])) + cg.add(var.set_mic_gain(config[CONF_MIC_GAIN])) + cg.add(var.set_sample_rate(config[CONF_SAMPLE_RATE])) diff --git a/esphome/components/es7210/es7210.cpp b/esphome/components/es7210/es7210.cpp new file mode 100644 index 0000000000..d2f2c3c1ff --- /dev/null +++ b/esphome/components/es7210/es7210.cpp @@ -0,0 +1,201 @@ +#include "es7210.h" +#include "es7210_const.h" +#include "esphome/core/hal.h" +#include "esphome/core/log.h" +#include + +namespace esphome { +namespace es7210 { + +static const char *const TAG = "es7210"; + +static const size_t MCLK_DIV_FRE = 256; + +// Mark the component as failed; use only in setup +#define ES7210_ERROR_FAILED(func) \ + if (!(func)) { \ + this->mark_failed(); \ + return; \ + } + +// Return false; use outside of setup +#define ES7210_ERROR_CHECK(func) \ + if (!(func)) { \ + return false; \ + } + +void ES7210::dump_config() { + ESP_LOGCONFIG(TAG, "ES7210 ADC:"); + ESP_LOGCONFIG(TAG, " Bits Per Sample: %" PRIu8, this->bits_per_sample_); + ESP_LOGCONFIG(TAG, " Sample Rate: %" PRIu32, this->sample_rate_); + + if (this->is_failed()) { + ESP_LOGCONFIG(TAG, " Failed to initialize!"); + return; + } +} + +void ES7210::setup() { + ESP_LOGCONFIG(TAG, "Setting up ES7210..."); + + // Software reset + ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0xff)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x32)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_CLOCK_OFF_REG01, 0x3f)); + + // Set initialization time when device powers up + ES7210_ERROR_FAILED(this->write_byte(ES7210_TIME_CONTROL0_REG09, 0x30)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_TIME_CONTROL1_REG0A, 0x30)); + + // Configure HFP for all ADC channels + ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC12_HPF2_REG23, 0x2a)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC12_HPF1_REG22, 0x0a)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC34_HPF2_REG20, 0x0a)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_ADC34_HPF1_REG21, 0x2a)); + + // Secondary I2S mode settings + ES7210_ERROR_FAILED(this->es7210_update_reg_bit_(ES7210_MODE_CONFIG_REG08, 0x01, 0x00)); + + // Configure analog power + ES7210_ERROR_FAILED(this->write_byte(ES7210_ANALOG_REG40, 0xC3)); + + // Set mic bias + ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC12_BIAS_REG41, 0x70)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC34_BIAS_REG42, 0x70)); + + // Configure I2S settings, sample rate, and microphone gains + ES7210_ERROR_FAILED(this->configure_i2s_format_()); + ES7210_ERROR_FAILED(this->configure_sample_rate_()); + ES7210_ERROR_FAILED(this->configure_mic_gain_()); + + // Power on mics 1 through 4 + ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC1_POWER_REG47, 0x08)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC2_POWER_REG48, 0x08)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC3_POWER_REG49, 0x08)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC4_POWER_REG4A, 0x08)); + + // Power down DLL + ES7210_ERROR_FAILED(this->write_byte(ES7210_POWER_DOWN_REG06, 0x04)); + + // Power on MIC1-4 bias & ADC1-4 & PGA1-4 Power + ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x0F)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x0F)); + + // Enable device + ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x71)); + ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x41)); +} + +bool ES7210::configure_sample_rate_() { + int mclk_fre = this->sample_rate_ * MCLK_DIV_FRE; + int coeff = -1; + + for (int i = 0; i < (sizeof(ES7210_COEFFICIENTS) / sizeof(ES7210_COEFFICIENTS[0])); ++i) { + if (ES7210_COEFFICIENTS[i].lrclk == this->sample_rate_ && ES7210_COEFFICIENTS[i].mclk == mclk_fre) + coeff = i; + } + + if (coeff >= 0) { + // Set adc_div & doubler & dll + uint8_t regv; + ES7210_ERROR_CHECK(this->read_byte(ES7210_MAINCLK_REG02, ®v)); + regv = regv & 0x00; + regv |= ES7210_COEFFICIENTS[coeff].adc_div; + regv |= ES7210_COEFFICIENTS[coeff].doubler << 6; + regv |= ES7210_COEFFICIENTS[coeff].dll << 7; + + ES7210_ERROR_CHECK(this->write_byte(ES7210_MAINCLK_REG02, regv)); + + // Set osr + regv = ES7210_COEFFICIENTS[coeff].osr; + ES7210_ERROR_CHECK(this->write_byte(ES7210_OSR_REG07, regv)); + // Set lrck + regv = ES7210_COEFFICIENTS[coeff].lrck_h; + ES7210_ERROR_CHECK(this->write_byte(ES7210_LRCK_DIVH_REG04, regv)); + regv = ES7210_COEFFICIENTS[coeff].lrck_l; + ES7210_ERROR_CHECK(this->write_byte(ES7210_LRCK_DIVL_REG05, regv)); + } else { + // Invalid sample frequency + ESP_LOGE(TAG, "Invalid sample rate"); + return false; + } + + return true; +} +bool ES7210::configure_mic_gain_() { + for (int i = 0; i < 4; ++i) { + this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43 + i, 0x10, 0x00); + } + ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0xff)); + ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0xff)); + + // Configure mic 1 + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00)); + ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x00)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43, 0x10, 0x10)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43, 0x0f, this->mic_gain_)); + + // Configure mic 2 + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00)); + ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x00)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC2_GAIN_REG44, 0x10, 0x10)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC2_GAIN_REG44, 0x0f, this->mic_gain_)); + + // Configure mic 3 + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00)); + ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x00)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC3_GAIN_REG45, 0x10, 0x10)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC3_GAIN_REG45, 0x0f, this->mic_gain_)); + + // Configure mic 4 + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00)); + ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x00)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC4_GAIN_REG46, 0x10, 0x10)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC4_GAIN_REG46, 0x0f, this->mic_gain_)); + + return true; +} + +bool ES7210::configure_i2s_format_() { + // Configure bits per sample + uint8_t reg_val = 0; + switch (this->bits_per_sample_) { + case ES7210_BITS_PER_SAMPLE_16: + reg_val = 0x60; + break; + case ES7210_BITS_PER_SAMPLE_18: + reg_val = 0x40; + break; + case ES7210_BITS_PER_SAMPLE_20: + reg_val = 0x20; + break; + case ES7210_BITS_PER_SAMPLE_24: + reg_val = 0x00; + break; + case ES7210_BITS_PER_SAMPLE_32: + reg_val = 0x80; + break; + default: + return false; + } + ES7210_ERROR_CHECK(this->write_byte(ES7210_SDP_INTERFACE1_REG11, reg_val)); + + if (this->enable_tdm_) { + ES7210_ERROR_CHECK(this->write_byte(ES7210_SDP_INTERFACE2_REG12, 0x02)); + } else { + // Microphones 1 and 2 output on SDOUT1, microphones 3 and 4 output on SDOUT2 + ES7210_ERROR_CHECK(this->write_byte(ES7210_SDP_INTERFACE2_REG12, 0x00)); + } + + return true; +} + +bool ES7210::es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data) { + uint8_t regv; + ES7210_ERROR_CHECK(this->read_byte(reg_addr, ®v)); + regv = (regv & (~update_bits)) | (update_bits & data); + return this->write_byte(reg_addr, regv); +} + +} // namespace es7210 +} // namespace esphome diff --git a/esphome/components/es7210/es7210.h b/esphome/components/es7210/es7210.h new file mode 100644 index 0000000000..a40dde5aa5 --- /dev/null +++ b/esphome/components/es7210/es7210.h @@ -0,0 +1,69 @@ +#pragma once + +#include "esphome/components/i2c/i2c.h" +#include "esphome/core/component.h" + +namespace esphome { +namespace es7210 { + +enum ES7210BitsPerSample : uint8_t { + ES7210_BITS_PER_SAMPLE_16 = 16, + ES7210_BITS_PER_SAMPLE_18 = 18, + ES7210_BITS_PER_SAMPLE_20 = 20, + ES7210_BITS_PER_SAMPLE_24 = 24, + ES7210_BITS_PER_SAMPLE_32 = 32, +}; + +enum ES7210MicGain : uint8_t { + ES7210_MIC_GAIN_0DB = 0, + ES7210_MIC_GAIN_3DB, + ES7210_MIC_GAIN_6DB, + ES7210_MIC_GAIN_9DB, + ES7210_MIC_GAIN_12DB, + ES7210_MIC_GAIN_15DB, + ES7210_MIC_GAIN_18DB, + ES7210_MIC_GAIN_21DB, + ES7210_MIC_GAIN_24DB, + ES7210_MIC_GAIN_27DB, + ES7210_MIC_GAIN_30DB, + ES7210_MIC_GAIN_33DB, + ES7210_MIC_GAIN_34_5DB, + ES7210_MIC_GAIN_36DB, + ES7210_MIC_GAIN_37_5DB, +}; + +class ES7210 : public Component, public i2c::I2CDevice { + /* Class for configuring an ES7210 ADC for microphone input. + * Based on code from: + * - https://github.com/espressif/esp-bsp/ (accessed 20241219) + * - https://github.com/espressif/esp-adf/ (accessed 20241219) + */ + public: + void setup() override; + float get_setup_priority() const override { return setup_priority::DATA; } + void dump_config() override; + + void set_bits_per_sample(ES7210BitsPerSample bits_per_sample) { this->bits_per_sample_ = bits_per_sample; } + void set_mic_gain(ES7210MicGain mic_gain) { this->mic_gain_ = mic_gain; } + void set_sample_rate(uint32_t sample_rate) { this->sample_rate_ = sample_rate; } + + protected: + /// @brief Updates an I2C registry address by modifying the current state + /// @param reg_addr I2C register address + /// @param update_bits Mask of allowed bits to be modified + /// @param data Bit values to be written + /// @return True if successful, false otherwise + bool es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data); + + bool configure_i2s_format_(); + bool configure_mic_gain_(); + bool configure_sample_rate_(); + + bool enable_tdm_{false}; // TDM is unsupported in ESPHome as of version 2024.12 + ES7210MicGain mic_gain_; + ES7210BitsPerSample bits_per_sample_; + uint32_t sample_rate_; +}; + +} // namespace es7210 +} // namespace esphome diff --git a/esphome/components/es7210/es7210_const.h b/esphome/components/es7210/es7210_const.h new file mode 100644 index 0000000000..87fd6d86d2 --- /dev/null +++ b/esphome/components/es7210/es7210_const.h @@ -0,0 +1,126 @@ +#pragma once + +#include "es7210.h" + +namespace esphome { +namespace es7210 { + +// ES7210 register addresses +static const uint8_t ES7210_RESET_REG00 = 0x00; /* Reset control */ +static const uint8_t ES7210_CLOCK_OFF_REG01 = 0x01; /* Used to turn off the ADC clock */ +static const uint8_t ES7210_MAINCLK_REG02 = 0x02; /* Set ADC clock frequency division */ + +static const uint8_t ES7210_MASTER_CLK_REG03 = 0x03; /* MCLK source $ SCLK division */ +static const uint8_t ES7210_LRCK_DIVH_REG04 = 0x04; /* lrck_divh */ +static const uint8_t ES7210_LRCK_DIVL_REG05 = 0x05; /* lrck_divl */ +static const uint8_t ES7210_POWER_DOWN_REG06 = 0x06; /* power down */ +static const uint8_t ES7210_OSR_REG07 = 0x07; +static const uint8_t ES7210_MODE_CONFIG_REG08 = 0x08; /* Set primary/secondary & channels */ +static const uint8_t ES7210_TIME_CONTROL0_REG09 = 0x09; /* Set Chip intial state period*/ +static const uint8_t ES7210_TIME_CONTROL1_REG0A = 0x0A; /* Set Power up state period */ +static const uint8_t ES7210_SDP_INTERFACE1_REG11 = 0x11; /* Set sample & fmt */ +static const uint8_t ES7210_SDP_INTERFACE2_REG12 = 0x12; /* Pins state */ +static const uint8_t ES7210_ADC_AUTOMUTE_REG13 = 0x13; /* Set mute */ +static const uint8_t ES7210_ADC34_MUTERANGE_REG14 = 0x14; /* Set mute range */ +static const uint8_t ES7210_ADC12_MUTERANGE_REG15 = 0x15; /* Set mute range */ +static const uint8_t ES7210_ADC34_HPF2_REG20 = 0x20; /* HPF */ +static const uint8_t ES7210_ADC34_HPF1_REG21 = 0x21; /* HPF */ +static const uint8_t ES7210_ADC12_HPF1_REG22 = 0x22; /* HPF */ +static const uint8_t ES7210_ADC12_HPF2_REG23 = 0x23; /* HPF */ +static const uint8_t ES7210_ANALOG_REG40 = 0x40; /* ANALOG Power */ +static const uint8_t ES7210_MIC12_BIAS_REG41 = 0x41; +static const uint8_t ES7210_MIC34_BIAS_REG42 = 0x42; +static const uint8_t ES7210_MIC1_GAIN_REG43 = 0x43; +static const uint8_t ES7210_MIC2_GAIN_REG44 = 0x44; +static const uint8_t ES7210_MIC3_GAIN_REG45 = 0x45; +static const uint8_t ES7210_MIC4_GAIN_REG46 = 0x46; +static const uint8_t ES7210_MIC1_POWER_REG47 = 0x47; +static const uint8_t ES7210_MIC2_POWER_REG48 = 0x48; +static const uint8_t ES7210_MIC3_POWER_REG49 = 0x49; +static const uint8_t ES7210_MIC4_POWER_REG4A = 0x4A; +static const uint8_t ES7210_MIC12_POWER_REG4B = 0x4B; /* MICBias & ADC & PGA Power */ +static const uint8_t ES7210_MIC34_POWER_REG4C = 0x4C; + +/* + * Clock coefficient structer + */ +struct ES7210Coefficient { + uint32_t mclk; // mclk frequency + uint32_t lrclk; + uint8_t ss_ds; + uint8_t adc_div; + uint8_t dll; // dll_bypass + uint8_t doubler; // doubler_enable + uint8_t osr; // adc osr + uint8_t mclk_src; // sselect mclk source + uint8_t lrck_h; // High 4 bits of lrck + uint8_t lrck_l; // Low 8 bits of lrck +}; + +/* Codec hifi mclk clock divider coefficients + * MEMBER REG + * mclk: 0x03 + * lrck: standard + * ss_ds: -- + * adc_div: 0x02 + * dll: 0x06 + * doubler: 0x02 + * osr: 0x07 + * mclk_src: 0x03 + * lrckh: 0x04 + * lrckl: 0x05 + */ +static const ES7210Coefficient ES7210_COEFFICIENTS[] = { + // mclk lrck ss_ds adc_div dll doubler osr mclk_src lrckh lrckl + /* 8k */ + {12288000, 8000, 0x00, 0x03, 0x01, 0x00, 0x20, 0x00, 0x06, 0x00}, + {16384000, 8000, 0x00, 0x04, 0x01, 0x00, 0x20, 0x00, 0x08, 0x00}, + {19200000, 8000, 0x00, 0x1e, 0x00, 0x01, 0x28, 0x00, 0x09, 0x60}, + {4096000, 8000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00}, + + /* 11.025k */ + {11289600, 11025, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00}, + + /* 12k */ + {12288000, 12000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00}, + {19200000, 12000, 0x00, 0x14, 0x00, 0x01, 0x28, 0x00, 0x06, 0x40}, + + /* 16k */ + {4096000, 16000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00}, + {19200000, 16000, 0x00, 0x0a, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x80}, + {16384000, 16000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00}, + {12288000, 16000, 0x00, 0x03, 0x01, 0x01, 0x20, 0x00, 0x03, 0x00}, + + /* 22.05k */ + {11289600, 22050, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00}, + + /* 24k */ + {12288000, 24000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00}, + {19200000, 24000, 0x00, 0x0a, 0x00, 0x01, 0x28, 0x00, 0x03, 0x20}, + + /* 32k */ + {12288000, 32000, 0x00, 0x03, 0x00, 0x00, 0x20, 0x00, 0x01, 0x80}, + {16384000, 32000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00}, + {19200000, 32000, 0x00, 0x05, 0x00, 0x00, 0x1e, 0x00, 0x02, 0x58}, + + /* 44.1k */ + {11289600, 44100, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00}, + + /* 48k */ + {12288000, 48000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00}, + {19200000, 48000, 0x00, 0x05, 0x00, 0x01, 0x28, 0x00, 0x01, 0x90}, + + /* 64k */ + {16384000, 64000, 0x01, 0x01, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00}, + {19200000, 64000, 0x00, 0x05, 0x00, 0x01, 0x1e, 0x00, 0x01, 0x2c}, + + /* 88.2k */ + {11289600, 88200, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80}, + + /* 96k */ + {12288000, 96000, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80}, + {19200000, 96000, 0x01, 0x05, 0x00, 0x01, 0x28, 0x00, 0x00, 0xc8}, +}; + +} // namespace es7210 +} // namespace esphome diff --git a/esphome/components/es8311/audio_dac.py b/esphome/components/es8311/audio_dac.py index 1b450c3c11..7d80cfd5fb 100644 --- a/esphome/components/es8311/audio_dac.py +++ b/esphome/components/es8311/audio_dac.py @@ -2,7 +2,7 @@ import esphome.codegen as cg from esphome.components import i2c from esphome.components.audio_dac import AudioDac import esphome.config_validation as cv -from esphome.const import CONF_BITS_PER_SAMPLE, CONF_ID, CONF_SAMPLE_RATE +from esphome.const import CONF_BITS_PER_SAMPLE, CONF_ID, CONF_MIC_GAIN, CONF_SAMPLE_RATE CODEOWNERS = ["@kroimon", "@kahrendt"] DEPENDENCIES = ["i2c"] @@ -10,7 +10,6 @@ DEPENDENCIES = ["i2c"] es8311_ns = cg.esphome_ns.namespace("es8311") ES8311 = es8311_ns.class_("ES8311", AudioDac, cg.Component, i2c.I2CDevice) -CONF_MIC_GAIN = "mic_gain" CONF_USE_MCLK = "use_mclk" CONF_USE_MICROPHONE = "use_microphone" diff --git a/esphome/const.py b/esphome/const.py index 0f41dc1aec..4c0203c6a9 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -490,6 +490,7 @@ CONF_MEMORY_BLOCKS = "memory_blocks" CONF_MESSAGE = "message" CONF_METHANE = "methane" CONF_METHOD = "method" +CONF_MIC_GAIN = "mic_gain" CONF_MICROPHONE = "microphone" CONF_MIN_BRIGHTNESS = "min_brightness" CONF_MIN_COOLING_OFF_TIME = "min_cooling_off_time" diff --git a/tests/components/es7210/common.yaml b/tests/components/es7210/common.yaml new file mode 100644 index 0000000000..5c30f7e883 --- /dev/null +++ b/tests/components/es7210/common.yaml @@ -0,0 +1,6 @@ +i2c: + - id: i2c_aic3204 + scl: ${scl_pin} + sda: ${sda_pin} + +es7210: diff --git a/tests/components/es7210/test.esp32-ard.yaml b/tests/components/es7210/test.esp32-ard.yaml new file mode 100644 index 0000000000..63c3bd6afd --- /dev/null +++ b/tests/components/es7210/test.esp32-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/es7210/test.esp32-c3-ard.yaml b/tests/components/es7210/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/es7210/test.esp32-c3-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/es7210/test.esp32-c3-idf.yaml b/tests/components/es7210/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/es7210/test.esp32-c3-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/es7210/test.esp32-idf.yaml b/tests/components/es7210/test.esp32-idf.yaml new file mode 100644 index 0000000000..63c3bd6afd --- /dev/null +++ b/tests/components/es7210/test.esp32-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + +<<: !include common.yaml From c458fd18df52923b6b3fb35e2ea6efd4d6603f72 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:49:58 +1300 Subject: [PATCH 083/194] Bump version to 2025.2.0-dev --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 4c0203c6a9..284f8d5f78 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.1.0-dev" +__version__ = "2025.2.0-dev" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From e779a8bcb2e73eddb7eb3474814dd6c64bb98486 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:54:45 +1300 Subject: [PATCH 084/194] [event] Store ``last_event_type`` in class (#8088) --- esphome/components/event/event.cpp | 6 ++++-- esphome/components/event/event.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/esphome/components/event/event.cpp b/esphome/components/event/event.cpp index 061afcb026..d27b3b378e 100644 --- a/esphome/components/event/event.cpp +++ b/esphome/components/event/event.cpp @@ -8,11 +8,13 @@ namespace event { static const char *const TAG = "event"; void Event::trigger(const std::string &event_type) { - if (types_.find(event_type) == types_.end()) { + auto found = types_.find(event_type); + if (found == types_.end()) { ESP_LOGE(TAG, "'%s': invalid event type for trigger(): %s", this->get_name().c_str(), event_type.c_str()); return; } - ESP_LOGD(TAG, "'%s' Triggered event '%s'", this->get_name().c_str(), event_type.c_str()); + last_event_type = &(*found); + ESP_LOGD(TAG, "'%s' Triggered event '%s'", this->get_name().c_str(), last_event_type->c_str()); this->event_callback_.call(event_type); } diff --git a/esphome/components/event/event.h b/esphome/components/event/event.h index 067a867360..03c3c8d95a 100644 --- a/esphome/components/event/event.h +++ b/esphome/components/event/event.h @@ -23,6 +23,8 @@ namespace event { class Event : public EntityBase, public EntityBase_DeviceClass { public: + const std::string *last_event_type; + void trigger(const std::string &event_type); void set_event_types(const std::set &event_types) { this->types_ = event_types; } std::set get_event_types() const { return this->types_; } From df26ace0f172d1bad7f019fc4d095f3a7be188f9 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Tue, 14 Jan 2025 19:56:22 -0800 Subject: [PATCH 085/194] [prometheus] Select, media_player, and number prometheus metrics (#7895) --- .../prometheus/prometheus_handler.cpp | 168 ++++++++++++++++++ .../prometheus/prometheus_handler.h | 24 +++ tests/components/prometheus/common.yaml | 20 +++ .../components/prometheus/test.esp32-ard.yaml | 33 ++++ 4 files changed, 245 insertions(+) diff --git a/esphome/components/prometheus/prometheus_handler.cpp b/esphome/components/prometheus/prometheus_handler.cpp index 5d1861202a..2d39d8ef3f 100644 --- a/esphome/components/prometheus/prometheus_handler.cpp +++ b/esphome/components/prometheus/prometheus_handler.cpp @@ -59,6 +59,24 @@ void PrometheusHandler::handleRequest(AsyncWebServerRequest *req) { this->text_sensor_row_(stream, obj, area, node, friendly_name); #endif +#ifdef USE_NUMBER + this->number_type_(stream); + for (auto *obj : App.get_numbers()) + this->number_row_(stream, obj, area, node, friendly_name); +#endif + +#ifdef USE_SELECT + this->select_type_(stream); + for (auto *obj : App.get_selects()) + this->select_row_(stream, obj, area, node, friendly_name); +#endif + +#ifdef USE_MEDIA_PLAYER + this->media_player_type_(stream); + for (auto *obj : App.get_media_players()) + this->media_player_row_(stream, obj, area, node, friendly_name); +#endif + req->send(stream); } @@ -511,6 +529,156 @@ void PrometheusHandler::text_sensor_row_(AsyncResponseStream *stream, text_senso } #endif +// Type-specific implementation +#ifdef USE_NUMBER +void PrometheusHandler::number_type_(AsyncResponseStream *stream) { + stream->print(F("#TYPE esphome_number_value gauge\n")); + stream->print(F("#TYPE esphome_number_failed gauge\n")); +} +void PrometheusHandler::number_row_(AsyncResponseStream *stream, number::Number *obj, std::string &area, + std::string &node, std::string &friendly_name) { + if (obj->is_internal() && !this->include_internal_) + return; + if (!std::isnan(obj->state)) { + // We have a valid value, output this value + stream->print(F("esphome_number_failed{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} 0\n")); + // Data itself + stream->print(F("esphome_number_value{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} ")); + stream->print(obj->state); + stream->print(F("\n")); + } else { + // Invalid state + stream->print(F("esphome_number_failed{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} 1\n")); + } +} +#endif + +#ifdef USE_SELECT +void PrometheusHandler::select_type_(AsyncResponseStream *stream) { + stream->print(F("#TYPE esphome_select_value gauge\n")); + stream->print(F("#TYPE esphome_select_failed gauge\n")); +} +void PrometheusHandler::select_row_(AsyncResponseStream *stream, select::Select *obj, std::string &area, + std::string &node, std::string &friendly_name) { + if (obj->is_internal() && !this->include_internal_) + return; + if (obj->has_state()) { + // We have a valid value, output this value + stream->print(F("esphome_select_failed{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} 0\n")); + // Data itself + stream->print(F("esphome_select_value{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\",value=\"")); + stream->print(obj->state.c_str()); + stream->print(F("\"} ")); + stream->print(F("1.0")); + stream->print(F("\n")); + } else { + // Invalid state + stream->print(F("esphome_select_failed{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} 1\n")); + } +} +#endif + +#ifdef USE_MEDIA_PLAYER +void PrometheusHandler::media_player_type_(AsyncResponseStream *stream) { + stream->print(F("#TYPE esphome_media_player_state_value gauge\n")); + stream->print(F("#TYPE esphome_media_player_volume gauge\n")); + stream->print(F("#TYPE esphome_media_player_is_muted gauge\n")); + stream->print(F("#TYPE esphome_media_player_failed gauge\n")); +} +void PrometheusHandler::media_player_row_(AsyncResponseStream *stream, media_player::MediaPlayer *obj, + std::string &area, std::string &node, std::string &friendly_name) { + if (obj->is_internal() && !this->include_internal_) + return; + stream->print(F("esphome_media_player_failed{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} 0\n")); + // Data itself + stream->print(F("esphome_media_player_state_value{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\",value=\"")); + stream->print(media_player::media_player_state_to_string(obj->state)); + stream->print(F("\"} ")); + stream->print(F("1.0")); + stream->print(F("\n")); + stream->print(F("esphome_media_player_volume{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} ")); + stream->print(obj->volume); + stream->print(F("\n")); + stream->print(F("esphome_media_player_is_muted{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} ")); + if (obj->is_muted()) { + stream->print(F("1.0")); + } else { + stream->print(F("0.0")); + } + stream->print(F("\n")); +} +#endif + } // namespace prometheus } // namespace esphome #endif diff --git a/esphome/components/prometheus/prometheus_handler.h b/esphome/components/prometheus/prometheus_handler.h index 5d08aca63a..41a06537ed 100644 --- a/esphome/components/prometheus/prometheus_handler.h +++ b/esphome/components/prometheus/prometheus_handler.h @@ -128,6 +128,30 @@ class PrometheusHandler : public AsyncWebHandler, public Component { std::string &friendly_name); #endif +#ifdef USE_NUMBER + /// Return the type for prometheus + void number_type_(AsyncResponseStream *stream); + /// Return the sensor state as prometheus data point + void number_row_(AsyncResponseStream *stream, number::Number *obj, std::string &area, std::string &node, + std::string &friendly_name); +#endif + +#ifdef USE_SELECT + /// Return the type for prometheus + void select_type_(AsyncResponseStream *stream); + /// Return the select state as prometheus data point + void select_row_(AsyncResponseStream *stream, select::Select *obj, std::string &area, std::string &node, + std::string &friendly_name); +#endif + +#ifdef USE_MEDIA_PLAYER + /// Return the type for prometheus + void media_player_type_(AsyncResponseStream *stream); + /// Return the select state as prometheus data point + void media_player_row_(AsyncResponseStream *stream, media_player::MediaPlayer *obj, std::string &area, + std::string &node, std::string &friendly_name); +#endif + web_server_base::WebServerBase *base_; bool include_internal_{false}; std::map relabel_map_id_; diff --git a/tests/components/prometheus/common.yaml b/tests/components/prometheus/common.yaml index 68ef2a2f58..1b87c1d6c1 100644 --- a/tests/components/prometheus/common.yaml +++ b/tests/components/prometheus/common.yaml @@ -78,6 +78,26 @@ lock: } optimistic: true +select: + - platform: template + id: template_select1 + name: "Template select" + optimistic: true + options: + - one + - two + - three + initial_option: two + +number: + - platform: template + id: template_number1 + name: "Template number" + optimistic: true + min_value: 0 + max_value: 100 + step: 1 + prometheus: include_internal: true relabel: diff --git a/tests/components/prometheus/test.esp32-ard.yaml b/tests/components/prometheus/test.esp32-ard.yaml index dade44d145..3045a6db13 100644 --- a/tests/components/prometheus/test.esp32-ard.yaml +++ b/tests/components/prometheus/test.esp32-ard.yaml @@ -1 +1,34 @@ <<: !include common.yaml + +i2s_audio: + i2s_lrclk_pin: 1 + i2s_bclk_pin: 2 + i2s_mclk_pin: 3 + +media_player: + - platform: i2s_audio + name: "Media Player" + dac_type: external + i2s_dout_pin: 18 + mute_pin: 19 + on_state: + - media_player.play: + - media_player.play_media: http://localhost/media.mp3 + - media_player.play_media: !lambda 'return "http://localhost/media.mp3";' + on_idle: + - media_player.pause: + on_play: + - media_player.stop: + on_pause: + - media_player.toggle: + - wait_until: + media_player.is_idle: + - wait_until: + media_player.is_playing: + - wait_until: + media_player.is_announcing: + - wait_until: + media_player.is_paused: + - media_player.volume_up: + - media_player.volume_down: + - media_player.volume_set: 50% From b4a804cc779bcb8a3b1480a44741bf9f29caa33c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:53:23 +1300 Subject: [PATCH 086/194] Bump docker/build-push-action from 6.11.0 to 6.12.0 in /.github/actions/build-image (#8090) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/actions/build-image/action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-image/action.yaml b/.github/actions/build-image/action.yaml index e6b6da4177..b2a3394563 100644 --- a/.github/actions/build-image/action.yaml +++ b/.github/actions/build-image/action.yaml @@ -46,7 +46,7 @@ runs: - name: Build and push to ghcr by digest id: build-ghcr - uses: docker/build-push-action@v6.11.0 + uses: docker/build-push-action@v6.12.0 env: DOCKER_BUILD_SUMMARY: false DOCKER_BUILD_RECORD_UPLOAD: false @@ -72,7 +72,7 @@ runs: - name: Build and push to dockerhub by digest id: build-dockerhub - uses: docker/build-push-action@v6.11.0 + uses: docker/build-push-action@v6.12.0 env: DOCKER_BUILD_SUMMARY: false DOCKER_BUILD_RECORD_UPLOAD: false From 49c01c26f1847debfa53dc7e31b6434debcfd40e Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 16 Jan 2025 16:12:30 +1100 Subject: [PATCH 087/194] Revert "Add resistance_sampler interface for config validation" (#8093) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- CODEOWNERS | 1 - esphome/components/ntc/sensor.py | 6 ++---- esphome/components/resistance/resistance_sensor.h | 5 ++--- esphome/components/resistance/sensor.py | 11 ++--------- esphome/components/resistance_sampler/__init__.py | 6 ------ .../resistance_sampler/resistance_sampler.h | 10 ---------- 6 files changed, 6 insertions(+), 33 deletions(-) delete mode 100644 esphome/components/resistance_sampler/__init__.py delete mode 100644 esphome/components/resistance_sampler/resistance_sampler.h diff --git a/CODEOWNERS b/CODEOWNERS index ba7106e6a3..f0075549fd 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -339,7 +339,6 @@ esphome/components/radon_eye_rd200/* @jeffeb3 esphome/components/rc522/* @glmnet esphome/components/rc522_i2c/* @glmnet esphome/components/rc522_spi/* @glmnet -esphome/components/resistance_sampler/* @jesserockz esphome/components/restart/* @esphome/core esphome/components/rf_bridge/* @jesserockz esphome/components/rgbct/* @jesserockz diff --git a/esphome/components/ntc/sensor.py b/esphome/components/ntc/sensor.py index 961511fe00..bd5f4a1841 100644 --- a/esphome/components/ntc/sensor.py +++ b/esphome/components/ntc/sensor.py @@ -2,7 +2,7 @@ from math import log import esphome.config_validation as cv import esphome.codegen as cg -from esphome.components import sensor, resistance_sampler +from esphome.components import sensor from esphome.const import ( CONF_CALIBRATION, CONF_REFERENCE_RESISTANCE, @@ -15,8 +15,6 @@ from esphome.const import ( UNIT_CELSIUS, ) -AUTO_LOAD = ["resistance_sampler"] - ntc_ns = cg.esphome_ns.namespace("ntc") NTC = ntc_ns.class_("NTC", cg.Component, sensor.Sensor) @@ -126,7 +124,7 @@ CONFIG_SCHEMA = ( ) .extend( { - cv.Required(CONF_SENSOR): cv.use_id(resistance_sampler.ResistanceSampler), + cv.Required(CONF_SENSOR): cv.use_id(sensor.Sensor), cv.Required(CONF_CALIBRATION): process_calibration, } ) diff --git a/esphome/components/resistance/resistance_sensor.h b/esphome/components/resistance/resistance_sensor.h index 8fa1f8b570..b57f90b59c 100644 --- a/esphome/components/resistance/resistance_sensor.h +++ b/esphome/components/resistance/resistance_sensor.h @@ -1,8 +1,7 @@ #pragma once -#include "esphome/components/resistance_sampler/resistance_sampler.h" -#include "esphome/components/sensor/sensor.h" #include "esphome/core/component.h" +#include "esphome/components/sensor/sensor.h" namespace esphome { namespace resistance { @@ -12,7 +11,7 @@ enum ResistanceConfiguration { DOWNSTREAM, }; -class ResistanceSensor : public Component, public sensor::Sensor, resistance_sampler::ResistanceSampler { +class ResistanceSensor : public Component, public sensor::Sensor { public: void set_sensor(Sensor *sensor) { sensor_ = sensor; } void set_configuration(ResistanceConfiguration configuration) { configuration_ = configuration; } diff --git a/esphome/components/resistance/sensor.py b/esphome/components/resistance/sensor.py index ce4459fc6d..3622799a07 100644 --- a/esphome/components/resistance/sensor.py +++ b/esphome/components/resistance/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import sensor, resistance_sampler +from esphome.components import sensor from esphome.const import ( CONF_REFERENCE_VOLTAGE, CONF_SENSOR, @@ -9,15 +9,8 @@ from esphome.const import ( ICON_FLASH, ) -AUTO_LOAD = ["resistance_sampler"] - resistance_ns = cg.esphome_ns.namespace("resistance") -ResistanceSensor = resistance_ns.class_( - "ResistanceSensor", - cg.Component, - sensor.Sensor, - resistance_sampler.ResistanceSampler, -) +ResistanceSensor = resistance_ns.class_("ResistanceSensor", cg.Component, sensor.Sensor) CONF_CONFIGURATION = "configuration" CONF_RESISTOR = "resistor" diff --git a/esphome/components/resistance_sampler/__init__.py b/esphome/components/resistance_sampler/__init__.py deleted file mode 100644 index d2032848aa..0000000000 --- a/esphome/components/resistance_sampler/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -import esphome.codegen as cg - -resistance_sampler_ns = cg.esphome_ns.namespace("resistance_sampler") -ResistanceSampler = resistance_sampler_ns.class_("ResistanceSampler") - -CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/resistance_sampler/resistance_sampler.h b/esphome/components/resistance_sampler/resistance_sampler.h deleted file mode 100644 index 9e300bebcc..0000000000 --- a/esphome/components/resistance_sampler/resistance_sampler.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -namespace esphome { -namespace resistance_sampler { - -/// Abstract interface to mark components that provide resistance values. -class ResistanceSampler {}; - -} // namespace resistance_sampler -} // namespace esphome From 16bf56b0f95b1c5a75cc2f4ae167e37485c8803b Mon Sep 17 00:00:00 2001 From: Katherine Whitlock Date: Thu, 16 Jan 2025 15:10:20 -0500 Subject: [PATCH 088/194] Fix running pre-commit on Windows (#8095) --- .pre-commit-config.yaml | 4 ++-- script/run-in-env | 53 +++++++++++++++++++++++++++++++++++++++++ script/run-in-env.sh | 13 ---------- 3 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 script/run-in-env delete mode 100755 script/run-in-env.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aeb434167a..5308a2c047 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,6 +53,6 @@ repos: hooks: - id: pylint name: pylint - entry: script/run-in-env.sh pylint - language: script + entry: python script/run-in-env pylint + language: system types: [python] diff --git a/script/run-in-env b/script/run-in-env new file mode 100644 index 0000000000..57bfddccf7 --- /dev/null +++ b/script/run-in-env @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + +import os +from pathlib import Path +import subprocess +import sys + + +def find_and_activate_virtualenv(): + try: + # Get the top-level directory of the git repository + my_path = subprocess.check_output( + ["git", "rev-parse", "--show-toplevel"], text=True + ).strip() + except subprocess.CalledProcessError: + print( + "Error: Not a git repository or unable to determine the top-level directory.", + file=sys.stderr, + ) + sys.exit(1) + + # Check for virtual environments + for venv in ["venv", ".venv", "."]: + activate_path = ( + Path(my_path) + / venv + / ("Scripts" if os.name == "nt" else "bin") + / "activate" + ) + if activate_path.exists(): + # Activate the virtual environment by updating PATH + env = os.environ.copy() + venv_bin_dir = activate_path.parent + env["PATH"] = f"{venv_bin_dir}{os.pathsep}{env['PATH']}" + env["VIRTUAL_ENV"] = str(venv_bin_dir.parent) + print(f"Activated virtual environment: {venv_bin_dir.parent}") + + # Execute the remaining arguments in the new environment + if len(sys.argv) > 1: + subprocess.run(sys.argv[1:], env=env, check=False) + else: + print( + "No command provided to run in the virtual environment.", + file=sys.stderr, + ) + return + + print("No virtual environment found.", file=sys.stderr) + sys.exit(1) + + +if __name__ == "__main__": + find_and_activate_virtualenv() diff --git a/script/run-in-env.sh b/script/run-in-env.sh deleted file mode 100755 index 2e05fe1d17..0000000000 --- a/script/run-in-env.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env sh -set -eu - -my_path=$(git rev-parse --show-toplevel) - -for venv in venv .venv .; do - if [ -f "${my_path}/${venv}/bin/activate" ]; then - . "${my_path}/${venv}/bin/activate" - break - fi -done - -exec "$@" From 8c6c45e6c197eb45400f6a2dd17568afe3977749 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Thu, 16 Jan 2025 15:43:41 -0600 Subject: [PATCH 089/194] [http_request] Bugfix: run update function in a task (#8018) --- .../http_request/http_request_idf.cpp | 24 ++- .../http_request/http_request_idf.h | 3 + .../update/http_request_update.cpp | 147 ++++++++++-------- .../http_request/update/http_request_update.h | 9 ++ 4 files changed, 115 insertions(+), 68 deletions(-) diff --git a/esphome/components/http_request/http_request_idf.cpp b/esphome/components/http_request/http_request_idf.cpp index b449f046ee..66f064c2ce 100644 --- a/esphome/components/http_request/http_request_idf.cpp +++ b/esphome/components/http_request/http_request_idf.cpp @@ -12,6 +12,8 @@ #include "esp_crt_bundle.h" #endif +#include "esp_task_wdt.h" + namespace esphome { namespace http_request { @@ -117,11 +119,11 @@ std::shared_ptr HttpRequestIDF::start(std::string url, std::strin return nullptr; } - App.feed_wdt(); + container->feed_wdt(); container->content_length = esp_http_client_fetch_headers(client); - App.feed_wdt(); + container->feed_wdt(); container->status_code = esp_http_client_get_status_code(client); - App.feed_wdt(); + container->feed_wdt(); if (is_success(container->status_code)) { container->duration_ms = millis() - start; return container; @@ -151,11 +153,11 @@ std::shared_ptr HttpRequestIDF::start(std::string url, std::strin return nullptr; } - App.feed_wdt(); + container->feed_wdt(); container->content_length = esp_http_client_fetch_headers(client); - App.feed_wdt(); + container->feed_wdt(); container->status_code = esp_http_client_get_status_code(client); - App.feed_wdt(); + container->feed_wdt(); if (is_success(container->status_code)) { container->duration_ms = millis() - start; return container; @@ -185,8 +187,9 @@ int HttpContainerIDF::read(uint8_t *buf, size_t max_len) { return 0; } - App.feed_wdt(); + this->feed_wdt(); int read_len = esp_http_client_read(this->client_, (char *) buf, bufsize); + this->feed_wdt(); this->bytes_read_ += read_len; this->duration_ms += (millis() - start); @@ -201,6 +204,13 @@ void HttpContainerIDF::end() { esp_http_client_cleanup(this->client_); } +void HttpContainerIDF::feed_wdt() { + // Tests to see if the executing task has a watchdog timer attached + if (esp_task_wdt_status(nullptr) == ESP_OK) { + App.feed_wdt(); + } +} + } // namespace http_request } // namespace esphome diff --git a/esphome/components/http_request/http_request_idf.h b/esphome/components/http_request/http_request_idf.h index 431794924b..2ed50698b9 100644 --- a/esphome/components/http_request/http_request_idf.h +++ b/esphome/components/http_request/http_request_idf.h @@ -18,6 +18,9 @@ class HttpContainerIDF : public HttpContainer { int read(uint8_t *buf, size_t max_len) override; void end() override; + /// @brief Feeds the watchdog timer if the executing task has one attached + void feed_wdt(); + protected: esp_http_client_handle_t client_; }; diff --git a/esphome/components/http_request/update/http_request_update.cpp b/esphome/components/http_request/update/http_request_update.cpp index 0e0966c22b..d683495ac6 100644 --- a/esphome/components/http_request/update/http_request_update.cpp +++ b/esphome/components/http_request/update/http_request_update.cpp @@ -9,6 +9,13 @@ namespace esphome { namespace http_request { +// The update function runs in a task only on ESP32s. +#ifdef USE_ESP32 +#define UPDATE_RETURN vTaskDelete(nullptr) // Delete the current update task +#else +#define UPDATE_RETURN return +#endif + static const char *const TAG = "http_request.update"; static const size_t MAX_READ_SIZE = 256; @@ -29,113 +36,131 @@ void HttpRequestUpdate::setup() { } void HttpRequestUpdate::update() { - auto container = this->request_parent_->get(this->source_url_); +#ifdef USE_ESP32 + xTaskCreate(HttpRequestUpdate::update_task, "update_task", 8192, (void *) this, 1, &this->update_task_handle_); +#else + this->update_task(this); +#endif +} + +void HttpRequestUpdate::update_task(void *params) { + HttpRequestUpdate *this_update = (HttpRequestUpdate *) params; + + auto container = this_update->request_parent_->get(this_update->source_url_); if (container == nullptr || container->status_code != HTTP_STATUS_OK) { - std::string msg = str_sprintf("Failed to fetch manifest from %s", this->source_url_.c_str()); - this->status_set_error(msg.c_str()); - return; + std::string msg = str_sprintf("Failed to fetch manifest from %s", this_update->source_url_.c_str()); + this_update->status_set_error(msg.c_str()); + UPDATE_RETURN; } ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); uint8_t *data = allocator.allocate(container->content_length); if (data == nullptr) { std::string msg = str_sprintf("Failed to allocate %d bytes for manifest", container->content_length); - this->status_set_error(msg.c_str()); + this_update->status_set_error(msg.c_str()); container->end(); - return; + UPDATE_RETURN; } size_t read_index = 0; while (container->get_bytes_read() < container->content_length) { int read_bytes = container->read(data + read_index, MAX_READ_SIZE); - App.feed_wdt(); yield(); read_index += read_bytes; } - std::string response((char *) data, read_index); - allocator.deallocate(data, container->content_length); + bool valid = false; + { // Ensures the response string falls out of scope and deallocates before the task ends + std::string response((char *) data, read_index); + allocator.deallocate(data, container->content_length); - container->end(); + container->end(); + container.reset(); // Release ownership of the container's shared_ptr - bool valid = json::parse_json(response, [this](JsonObject root) -> bool { - if (!root.containsKey("name") || !root.containsKey("version") || !root.containsKey("builds")) { - ESP_LOGE(TAG, "Manifest does not contain required fields"); - return false; - } - this->update_info_.title = root["name"].as(); - this->update_info_.latest_version = root["version"].as(); - - for (auto build : root["builds"].as()) { - if (!build.containsKey("chipFamily")) { + valid = json::parse_json(response, [this_update](JsonObject root) -> bool { + if (!root.containsKey("name") || !root.containsKey("version") || !root.containsKey("builds")) { ESP_LOGE(TAG, "Manifest does not contain required fields"); return false; } - if (build["chipFamily"] == ESPHOME_VARIANT) { - if (!build.containsKey("ota")) { + this_update->update_info_.title = root["name"].as(); + this_update->update_info_.latest_version = root["version"].as(); + + for (auto build : root["builds"].as()) { + if (!build.containsKey("chipFamily")) { ESP_LOGE(TAG, "Manifest does not contain required fields"); return false; } - auto ota = build["ota"]; - if (!ota.containsKey("path") || !ota.containsKey("md5")) { - ESP_LOGE(TAG, "Manifest does not contain required fields"); - return false; + if (build["chipFamily"] == ESPHOME_VARIANT) { + if (!build.containsKey("ota")) { + ESP_LOGE(TAG, "Manifest does not contain required fields"); + return false; + } + auto ota = build["ota"]; + if (!ota.containsKey("path") || !ota.containsKey("md5")) { + ESP_LOGE(TAG, "Manifest does not contain required fields"); + return false; + } + this_update->update_info_.firmware_url = ota["path"].as(); + this_update->update_info_.md5 = ota["md5"].as(); + + if (ota.containsKey("summary")) + this_update->update_info_.summary = ota["summary"].as(); + if (ota.containsKey("release_url")) + this_update->update_info_.release_url = ota["release_url"].as(); + + return true; } - this->update_info_.firmware_url = ota["path"].as(); - this->update_info_.md5 = ota["md5"].as(); - - if (ota.containsKey("summary")) - this->update_info_.summary = ota["summary"].as(); - if (ota.containsKey("release_url")) - this->update_info_.release_url = ota["release_url"].as(); - - return true; } - } - return false; - }); + return false; + }); + } if (!valid) { - std::string msg = str_sprintf("Failed to parse JSON from %s", this->source_url_.c_str()); - this->status_set_error(msg.c_str()); - return; + std::string msg = str_sprintf("Failed to parse JSON from %s", this_update->source_url_.c_str()); + this_update->status_set_error(msg.c_str()); + UPDATE_RETURN; } - // Merge source_url_ and this->update_info_.firmware_url - if (this->update_info_.firmware_url.find("http") == std::string::npos) { - std::string path = this->update_info_.firmware_url; + // Merge source_url_ and this_update->update_info_.firmware_url + if (this_update->update_info_.firmware_url.find("http") == std::string::npos) { + std::string path = this_update->update_info_.firmware_url; if (path[0] == '/') { - std::string domain = this->source_url_.substr(0, this->source_url_.find('/', 8)); - this->update_info_.firmware_url = domain + path; + std::string domain = this_update->source_url_.substr(0, this_update->source_url_.find('/', 8)); + this_update->update_info_.firmware_url = domain + path; } else { - std::string domain = this->source_url_.substr(0, this->source_url_.rfind('/') + 1); - this->update_info_.firmware_url = domain + path; + std::string domain = this_update->source_url_.substr(0, this_update->source_url_.rfind('/') + 1); + this_update->update_info_.firmware_url = domain + path; } } - std::string current_version; + { // Ensures the current version string falls out of scope and deallocates before the task ends + std::string current_version; #ifdef ESPHOME_PROJECT_VERSION - current_version = ESPHOME_PROJECT_VERSION; + current_version = ESPHOME_PROJECT_VERSION; #else - current_version = ESPHOME_VERSION; + current_version = ESPHOME_VERSION; #endif - this->update_info_.current_version = current_version; - - if (this->update_info_.latest_version.empty() || this->update_info_.latest_version == update_info_.current_version) { - this->state_ = update::UPDATE_STATE_NO_UPDATE; - } else { - this->state_ = update::UPDATE_STATE_AVAILABLE; + this_update->update_info_.current_version = current_version; } - this->update_info_.has_progress = false; - this->update_info_.progress = 0.0f; + if (this_update->update_info_.latest_version.empty() || + this_update->update_info_.latest_version == this_update->update_info_.current_version) { + this_update->state_ = update::UPDATE_STATE_NO_UPDATE; + } else { + this_update->state_ = update::UPDATE_STATE_AVAILABLE; + } - this->status_clear_error(); - this->publish_state(); + this_update->update_info_.has_progress = false; + this_update->update_info_.progress = 0.0f; + + this_update->status_clear_error(); + this_update->publish_state(); + + UPDATE_RETURN; } void HttpRequestUpdate::perform(bool force) { diff --git a/esphome/components/http_request/update/http_request_update.h b/esphome/components/http_request/update/http_request_update.h index 45c7e6a447..e05fdb0cc2 100644 --- a/esphome/components/http_request/update/http_request_update.h +++ b/esphome/components/http_request/update/http_request_update.h @@ -7,6 +7,10 @@ #include "esphome/components/http_request/ota/ota_http_request.h" #include "esphome/components/update/update_entity.h" +#ifdef USE_ESP32 +#include +#endif + namespace esphome { namespace http_request { @@ -29,6 +33,11 @@ class HttpRequestUpdate : public update::UpdateEntity, public PollingComponent { HttpRequestComponent *request_parent_; OtaHttpRequestComponent *ota_parent_; std::string source_url_; + + static void update_task(void *params); +#ifdef USE_ESP32 + TaskHandle_t update_task_handle_{nullptr}; +#endif }; } // namespace http_request From 820e3488d03f3644a5661156d78995c2d964a092 Mon Sep 17 00:00:00 2001 From: Katherine Whitlock Date: Thu, 16 Jan 2025 16:44:26 -0500 Subject: [PATCH 090/194] Remove black-formatter from pre-commit hooks (#8097) --- .pre-commit-config.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5308a2c047..adf0ac6fc2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,14 +11,6 @@ repos: args: [--fix] # Run the formatter. - id: ruff-format - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.4.2 - hooks: - - id: black - args: - - --safe - - --quiet - files: ^((esphome|script|tests)/.+)?[^/]+\.py$ - repo: https://github.com/PyCQA/flake8 rev: 6.1.0 hooks: From 07be7ad7e2f874eaedcfc20ea68a9f8c33b72494 Mon Sep 17 00:00:00 2001 From: j-sepul <117353037+j-sepul@users.noreply.github.com> Date: Thu, 16 Jan 2025 23:08:04 +0100 Subject: [PATCH 091/194] Increase Daly-BMS coltage cells from 16 to 18 cells (#8057) --- esphome/components/daly_bms/daly_bms.cpp | 6 ++++++ esphome/components/daly_bms/daly_bms.h | 2 ++ esphome/components/daly_bms/sensor.py | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/esphome/components/daly_bms/daly_bms.cpp b/esphome/components/daly_bms/daly_bms.cpp index 8f6fc0fb57..929f31e008 100644 --- a/esphome/components/daly_bms/daly_bms.cpp +++ b/esphome/components/daly_bms/daly_bms.cpp @@ -298,6 +298,12 @@ void DalyBmsComponent::decode_data_(std::vector data) { if (this->cell_16_voltage_sensor_) { this->cell_16_voltage_sensor_->publish_state((float) encode_uint16(it[5], it[6]) / 1000); } + if (this->cell_17_voltage_sensor_) { + this->cell_17_voltage_sensor_->publish_state((float) encode_uint16(it[7], it[8]) / 1000); + } + if (this->cell_18_voltage_sensor_) { + this->cell_18_voltage_sensor_->publish_state((float) encode_uint16(it[9], it[10]) / 1000); + } break; } break; diff --git a/esphome/components/daly_bms/daly_bms.h b/esphome/components/daly_bms/daly_bms.h index 52ea30ecde..e6d476bcdd 100644 --- a/esphome/components/daly_bms/daly_bms.h +++ b/esphome/components/daly_bms/daly_bms.h @@ -54,6 +54,8 @@ class DalyBmsComponent : public PollingComponent, public uart::UARTDevice { SUB_SENSOR(cell_14_voltage) SUB_SENSOR(cell_15_voltage) SUB_SENSOR(cell_16_voltage) + SUB_SENSOR(cell_17_voltage) + SUB_SENSOR(cell_18_voltage) #endif #ifdef USE_TEXT_SENSOR diff --git a/esphome/components/daly_bms/sensor.py b/esphome/components/daly_bms/sensor.py index c447fbd8a2..6d78946a02 100644 --- a/esphome/components/daly_bms/sensor.py +++ b/esphome/components/daly_bms/sensor.py @@ -52,6 +52,8 @@ CONF_CELL_13_VOLTAGE = "cell_13_voltage" CONF_CELL_14_VOLTAGE = "cell_14_voltage" CONF_CELL_15_VOLTAGE = "cell_15_voltage" CONF_CELL_16_VOLTAGE = "cell_16_voltage" +CONF_CELL_17_VOLTAGE = "cell_17_voltage" +CONF_CELL_18_VOLTAGE = "cell_18_voltage" ICON_CURRENT_DC = "mdi:current-dc" ICON_BATTERY_OUTLINE = "mdi:battery-outline" ICON_THERMOMETER_CHEVRON_UP = "mdi:thermometer-chevron-up" @@ -92,6 +94,8 @@ TYPES = [ CONF_CELL_14_VOLTAGE, CONF_CELL_15_VOLTAGE, CONF_CELL_16_VOLTAGE, + CONF_CELL_17_VOLTAGE, + CONF_CELL_18_VOLTAGE, ] CELL_VOLTAGE_SCHEMA = sensor.sensor_schema( @@ -212,6 +216,8 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_CELL_14_VOLTAGE): CELL_VOLTAGE_SCHEMA, cv.Optional(CONF_CELL_15_VOLTAGE): CELL_VOLTAGE_SCHEMA, cv.Optional(CONF_CELL_16_VOLTAGE): CELL_VOLTAGE_SCHEMA, + cv.Optional(CONF_CELL_17_VOLTAGE): CELL_VOLTAGE_SCHEMA, + cv.Optional(CONF_CELL_18_VOLTAGE): CELL_VOLTAGE_SCHEMA, } ).extend(cv.COMPONENT_SCHEMA) ) From 47a0ec467abd812e85f6a65946f3922f31ac5981 Mon Sep 17 00:00:00 2001 From: guillempages Date: Sun, 19 Jan 2025 22:34:38 +0100 Subject: [PATCH 092/194] [image]Rename option "use_transparency" (#8113) --- esphome/components/image/__init__.py | 14 ++++++------- esphome/components/online_image/__init__.py | 4 ++-- tests/components/animation/common.yaml | 4 ++-- tests/components/image/common.yaml | 22 ++++++++++----------- tests/components/image/test.host.yaml | 14 ++++++------- tests/components/online_image/common.yaml | 6 +++--- 6 files changed, 31 insertions(+), 33 deletions(-) diff --git a/esphome/components/image/__init__.py b/esphome/components/image/__init__.py index a503e8f471..7cdce757be 100644 --- a/esphome/components/image/__init__.py +++ b/esphome/components/image/__init__.py @@ -282,7 +282,7 @@ IMAGE_TYPE = { TransparencyType = image_ns.enum("TransparencyType") -CONF_USE_TRANSPARENCY = "use_transparency" +CONF_TRANSPARENCY = "transparency" # If the MDI file cannot be downloaded within this time, abort. IMAGE_DOWNLOAD_TIMEOUT = 30 # seconds @@ -417,7 +417,7 @@ def validate_type(image_types): def validate_settings(value): type = value[CONF_TYPE] - transparency = value[CONF_USE_TRANSPARENCY].lower() + transparency = value[CONF_TRANSPARENCY].lower() allow_config = IMAGE_TYPE[type].allow_config if transparency not in allow_config: raise cv.Invalid( @@ -458,9 +458,7 @@ BASE_SCHEMA = cv.Schema( IMAGE_SCHEMA = BASE_SCHEMA.extend( { cv.Required(CONF_TYPE): validate_type(IMAGE_TYPE), - cv.Optional( - CONF_USE_TRANSPARENCY, default=CONF_OPAQUE - ): validate_transparency(), + cv.Optional(CONF_TRANSPARENCY, default=CONF_OPAQUE): validate_transparency(), } ) @@ -476,7 +474,7 @@ def typed_image_schema(image_type): BASE_SCHEMA.extend( { cv.Optional( - CONF_USE_TRANSPARENCY, default=t + CONF_TRANSPARENCY, default=t ): validate_transparency((t,)), cv.Optional(CONF_TYPE, default=image_type): validate_type( (image_type,) @@ -494,7 +492,7 @@ def typed_image_schema(image_type): BASE_SCHEMA.extend( { cv.Optional( - CONF_USE_TRANSPARENCY, default=CONF_OPAQUE + CONF_TRANSPARENCY, default=CONF_OPAQUE ): validate_transparency(), cv.Optional(CONF_TYPE, default=image_type): validate_type( (image_type,) @@ -556,7 +554,7 @@ async def write_image(config, all_frames=False): else Image.Dither.FLOYDSTEINBERG ) type = config[CONF_TYPE] - transparency = config[CONF_USE_TRANSPARENCY] + transparency = config[CONF_TRANSPARENCY] invert_alpha = config[CONF_INVERT_ALPHA] frame_count = 1 if all_frames: diff --git a/esphome/components/online_image/__init__.py b/esphome/components/online_image/__init__.py index d1915c7364..ca4eefea6f 100644 --- a/esphome/components/online_image/__init__.py +++ b/esphome/components/online_image/__init__.py @@ -5,7 +5,7 @@ import esphome.codegen as cg from esphome.components.http_request import CONF_HTTP_REQUEST_ID, HttpRequestComponent from esphome.components.image import ( CONF_INVERT_ALPHA, - CONF_USE_TRANSPARENCY, + CONF_TRANSPARENCY, IMAGE_SCHEMA, Image_, get_image_type_enum, @@ -168,7 +168,7 @@ async def to_code(config): url = config[CONF_URL] width, height = config.get(CONF_RESIZE, (0, 0)) - transparent = get_transparency_enum(config[CONF_USE_TRANSPARENCY]) + transparent = get_transparency_enum(config[CONF_TRANSPARENCY]) var = cg.new_Pvariable( config[CONF_ID], diff --git a/tests/components/animation/common.yaml b/tests/components/animation/common.yaml index c0f04fe768..8bb2a2f4d8 100644 --- a/tests/components/animation/common.yaml +++ b/tests/components/animation/common.yaml @@ -2,12 +2,12 @@ animation: - id: rgb565_animation file: $component_dir/anim.gif type: RGB565 - use_transparency: opaque + transparency: opaque resize: 50x50 - id: rgb_animation file: $component_dir/anim.apng type: RGB - use_transparency: chroma_key + transparency: chroma_key resize: 50x50 - id: grayscale_animation file: $component_dir/anim.apng diff --git a/tests/components/image/common.yaml b/tests/components/image/common.yaml index fdb0493d2a..4c9b9ed670 100644 --- a/tests/components/image/common.yaml +++ b/tests/components/image/common.yaml @@ -6,54 +6,54 @@ image: - id: transparent_transparent_image file: ../../pnglogo.png type: BINARY - use_transparency: chroma_key + transparency: chroma_key - id: rgba_image file: ../../pnglogo.png type: RGB - use_transparency: alpha_channel + transparency: alpha_channel resize: 50x50 - id: rgb24_image file: ../../pnglogo.png type: RGB - use_transparency: chroma_key + transparency: chroma_key - id: rgb_image file: ../../pnglogo.png type: RGB - use_transparency: opaque + transparency: opaque - id: rgb565_image file: ../../pnglogo.png type: RGB565 - use_transparency: opaque + transparency: opaque - id: rgb565_ck_image file: ../../pnglogo.png type: RGB565 - use_transparency: chroma_key + transparency: chroma_key - id: rgb565_alpha_image file: ../../pnglogo.png type: RGB565 - use_transparency: alpha_channel + transparency: alpha_channel - id: grayscale_alpha_image file: ../../pnglogo.png type: grayscale - use_transparency: alpha_channel + transparency: alpha_channel resize: 50x50 - id: grayscale_ck_image file: ../../pnglogo.png type: grayscale - use_transparency: chroma_key + transparency: chroma_key - id: grayscale_image file: ../../pnglogo.png type: grayscale - use_transparency: opaque + transparency: opaque - id: web_svg_image file: https://raw.githubusercontent.com/esphome/esphome-docs/a62d7ab193c1a464ed791670170c7d518189109b/images/logo.svg resize: 256x48 type: BINARY - use_transparency: chroma_key + transparency: chroma_key - id: web_tiff_image file: https://upload.wikimedia.org/wikipedia/commons/b/b6/SIPI_Jelly_Beans_4.1.07.tiff type: RGB diff --git a/tests/components/image/test.host.yaml b/tests/components/image/test.host.yaml index 61ecd5e374..0411195e2a 100644 --- a/tests/components/image/test.host.yaml +++ b/tests/components/image/test.host.yaml @@ -12,7 +12,7 @@ image: dither: FloydSteinberg - id: transparent_transparent_image file: ../../pnglogo.png - use_transparency: chroma_key + transparency: chroma_key rgb: alpha_channel: - id: rgba_image @@ -28,21 +28,21 @@ image: rgb565: - id: rgb565_image file: ../../pnglogo.png - use_transparency: opaque + transparency: opaque - id: rgb565_ck_image file: ../../pnglogo.png - use_transparency: chroma_key + transparency: chroma_key - id: rgb565_alpha_image file: ../../pnglogo.png - use_transparency: alpha_channel + transparency: alpha_channel grayscale: - id: grayscale_alpha_image file: ../../pnglogo.png - use_transparency: alpha_channel + transparency: alpha_channel resize: 50x50 - id: grayscale_ck_image file: ../../pnglogo.png - use_transparency: chroma_key + transparency: chroma_key - id: grayscale_image file: ../../pnglogo.png - use_transparency: opaque + transparency: opaque diff --git a/tests/components/online_image/common.yaml b/tests/components/online_image/common.yaml index 81f43e9fdc..6c161e4f20 100644 --- a/tests/components/online_image/common.yaml +++ b/tests/components/online_image/common.yaml @@ -14,18 +14,18 @@ online_image: - id: online_binary_transparent_image url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png type: BINARY - use_transparency: chroma_key + transparency: chroma_key format: png - id: online_rgba_image url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png format: PNG type: RGB - use_transparency: alpha_channel + transparency: alpha_channel - id: online_rgb24_image url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png format: PNG type: RGB - use_transparency: chroma_key + transparency: chroma_key # Check the set_url action esphome: From 75026be9519a17f3f502dcaea3f21ec5f0c2f917 Mon Sep 17 00:00:00 2001 From: guillempages Date: Sun, 19 Jan 2025 23:16:37 +0100 Subject: [PATCH 093/194] [online_image] Use RAMAllocator (#8114) --- esphome/components/online_image/image_decoder.h | 2 +- esphome/components/online_image/online_image.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/esphome/components/online_image/image_decoder.h b/esphome/components/online_image/image_decoder.h index cde7f572e3..7c5175d72d 100644 --- a/esphome/components/online_image/image_decoder.h +++ b/esphome/components/online_image/image_decoder.h @@ -100,7 +100,7 @@ class DownloadBuffer { void reset() { this->unread_ = 0; } protected: - ExternalRAMAllocator allocator_; + RAMAllocator allocator_{}; uint8_t *buffer_; size_t size_; /** Total number of downloaded bytes not yet read. */ diff --git a/esphome/components/online_image/online_image.h b/esphome/components/online_image/online_image.h index e044b4f390..bafd8ba67e 100644 --- a/esphome/components/online_image/online_image.h +++ b/esphome/components/online_image/online_image.h @@ -83,8 +83,7 @@ class OnlineImage : public PollingComponent, protected: bool validate_url_(const std::string &url); - using Allocator = ExternalRAMAllocator; - Allocator allocator_{Allocator::Flags::ALLOW_FAILURE}; + RAMAllocator allocator_{}; uint32_t get_buffer_size_() const { return get_buffer_size_(this->buffer_width_, this->buffer_height_); } int get_buffer_size_(int width, int height) const { return (this->get_bpp() * width + 7u) / 8u * height; } From 98b872abc71b555640a9465fd30e3ba184ab49be Mon Sep 17 00:00:00 2001 From: Mikkel Jeppesen <2756925+Duckle29@users.noreply.github.com> Date: Sun, 19 Jan 2025 23:36:07 +0100 Subject: [PATCH 094/194] Fixed incorrect display dimension (#8110) --- esphome/components/waveshare_epaper/waveshare_213v3.cpp | 6 ++++-- esphome/components/waveshare_epaper/waveshare_epaper.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/esphome/components/waveshare_epaper/waveshare_213v3.cpp b/esphome/components/waveshare_epaper/waveshare_213v3.cpp index 196aeed3f7..85d7033d4b 100644 --- a/esphome/components/waveshare_epaper/waveshare_213v3.cpp +++ b/esphome/components/waveshare_epaper/waveshare_213v3.cpp @@ -72,7 +72,8 @@ void WaveshareEPaper2P13InV3::write_buffer_(uint8_t cmd, int top, int bottom) { this->set_window_(top, bottom); this->command(cmd); this->start_data_(); - auto width_bytes = this->get_width_internal() / 8; + + auto width_bytes = this->get_width_controller() / 8; this->write_array(this->buffer_ + top * width_bytes, (bottom - top) * width_bytes); this->end_data_(); } @@ -162,7 +163,8 @@ void WaveshareEPaper2P13InV3::display() { } } -int WaveshareEPaper2P13InV3::get_width_internal() { return 128; } +int WaveshareEPaper2P13InV3::get_width_controller() { return 128; } +int WaveshareEPaper2P13InV3::get_width_internal() { return 122; } int WaveshareEPaper2P13InV3::get_height_internal() { return 250; } diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 4544f7df59..0fc1051268 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -811,6 +811,7 @@ class WaveshareEPaper2P13InV3 : public WaveshareEPaper { void initialize() override; protected: + int get_width_controller() override; int get_width_internal() override; int get_height_internal() override; uint32_t idle_timeout_() override; From c3d00b45f7703666fc06289d2ff84b72ce800ea5 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 21 Jan 2025 14:50:04 +1300 Subject: [PATCH 095/194] Update defines.h for esp-idf 5.1.5 (#8117) --- esphome/core/defines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/defines.h b/esphome/core/defines.h index c38a26c6a8..96a05435ed 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -120,7 +120,7 @@ #endif #ifdef USE_ESP_IDF -#define USE_ESP_IDF_VERSION_CODE VERSION_CODE(4, 4, 2) +#define USE_ESP_IDF_VERSION_CODE VERSION_CODE(5, 1, 5) #endif #if defined(USE_ESP32_VARIANT_ESP32S2) From 576dbd6f0c33ccddb2be4dcffd79e39749857b21 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Mon, 20 Jan 2025 20:35:40 -0600 Subject: [PATCH 096/194] [audio_adc] Add new ``audio_adc`` component (#8094) --- CODEOWNERS | 1 + esphome/components/audio_adc/__init__.py | 41 ++++++++++++++ esphome/components/audio_adc/audio_adc.h | 17 ++++++ esphome/components/audio_adc/automation.h | 23 ++++++++ esphome/components/es7210/__init__.py | 67 ----------------------- esphome/components/es7210/audio_adc.py | 51 +++++++++++++++++ esphome/components/es7210/es7210.cpp | 43 ++++++++++++--- esphome/components/es7210/es7210.h | 39 ++++++------- esphome/components/es7210/es7210_const.h | 7 ++- tests/components/es7210/common.yaml | 12 +++- 10 files changed, 200 insertions(+), 101 deletions(-) create mode 100644 esphome/components/audio_adc/__init__.py create mode 100644 esphome/components/audio_adc/audio_adc.h create mode 100644 esphome/components/audio_adc/automation.h create mode 100644 esphome/components/es7210/audio_adc.py diff --git a/CODEOWNERS b/CODEOWNERS index f0075549fd..56e20133ef 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -49,6 +49,7 @@ esphome/components/atc_mithermometer/* @ahpohl esphome/components/atm90e26/* @danieltwagner esphome/components/atm90e32/* @circuitsetup @descipher esphome/components/audio/* @kahrendt +esphome/components/audio_adc/* @kbx81 esphome/components/audio_dac/* @kbx81 esphome/components/axs15231/* @clydebarrow esphome/components/b_parasite/* @rbaron diff --git a/esphome/components/audio_adc/__init__.py b/esphome/components/audio_adc/__init__.py new file mode 100644 index 0000000000..dd3c958821 --- /dev/null +++ b/esphome/components/audio_adc/__init__.py @@ -0,0 +1,41 @@ +from esphome import automation +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_MIC_GAIN +from esphome.core import coroutine_with_priority + +CODEOWNERS = ["@kbx81"] +IS_PLATFORM_COMPONENT = True + +audio_adc_ns = cg.esphome_ns.namespace("audio_adc") +AudioAdc = audio_adc_ns.class_("AudioAdc") + +SetMicGainAction = audio_adc_ns.class_("SetMicGainAction", automation.Action) + + +SET_MIC_GAIN_ACTION_SCHEMA = cv.maybe_simple_value( + { + cv.GenerateID(): cv.use_id(AudioAdc), + cv.Required(CONF_MIC_GAIN): cv.templatable(cv.decibel), + }, + key=CONF_MIC_GAIN, +) + + +@automation.register_action( + "audio_adc.set_mic_gain", SetMicGainAction, SET_MIC_GAIN_ACTION_SCHEMA +) +async def audio_adc_set_mic_gain_to_code(config, action_id, template_arg, args): + paren = await cg.get_variable(config[CONF_ID]) + var = cg.new_Pvariable(action_id, template_arg, paren) + + template_ = await cg.templatable(config.get(CONF_MIC_GAIN), args, float) + cg.add(var.set_mic_gain(template_)) + + return var + + +@coroutine_with_priority(100.0) +async def to_code(config): + cg.add_define("USE_AUDIO_ADC") + cg.add_global(audio_adc_ns.using) diff --git a/esphome/components/audio_adc/audio_adc.h b/esphome/components/audio_adc/audio_adc.h new file mode 100644 index 0000000000..94bfb57db5 --- /dev/null +++ b/esphome/components/audio_adc/audio_adc.h @@ -0,0 +1,17 @@ +#pragma once + +#include "esphome/core/defines.h" +#include "esphome/core/hal.h" + +namespace esphome { +namespace audio_adc { + +class AudioAdc { + public: + virtual bool set_mic_gain(float mic_gain) = 0; + + virtual float mic_gain() = 0; +}; + +} // namespace audio_adc +} // namespace esphome diff --git a/esphome/components/audio_adc/automation.h b/esphome/components/audio_adc/automation.h new file mode 100644 index 0000000000..1b0bc2a6ad --- /dev/null +++ b/esphome/components/audio_adc/automation.h @@ -0,0 +1,23 @@ +#pragma once + +#include "esphome/core/automation.h" +#include "esphome/core/component.h" +#include "audio_adc.h" + +namespace esphome { +namespace audio_adc { + +template class SetMicGainAction : public Action { + public: + explicit SetMicGainAction(AudioAdc *audio_adc) : audio_adc_(audio_adc) {} + + TEMPLATABLE_VALUE(float, mic_gain) + + void play(Ts... x) override { this->audio_adc_->set_mic_gain(this->mic_gain_.value(x...)); } + + protected: + AudioAdc *audio_adc_; +}; + +} // namespace audio_adc +} // namespace esphome diff --git a/esphome/components/es7210/__init__.py b/esphome/components/es7210/__init__.py index 8e63d7f04f..e69de29bb2 100644 --- a/esphome/components/es7210/__init__.py +++ b/esphome/components/es7210/__init__.py @@ -1,67 +0,0 @@ -import esphome.codegen as cg -from esphome.components import i2c -import esphome.config_validation as cv -from esphome.const import CONF_BITS_PER_SAMPLE, CONF_ID, CONF_MIC_GAIN, CONF_SAMPLE_RATE - -CODEOWNERS = ["@kahrendt"] -DEPENDENCIES = ["i2c"] - -es7210_ns = cg.esphome_ns.namespace("es7210") -ES7210 = es7210_ns.class_("ES7210", cg.Component, i2c.I2CDevice) - - -es7210_bits_per_sample = es7210_ns.enum("ES7210BitsPerSample") -ES7210_BITS_PER_SAMPLE_ENUM = { - 16: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_16, - 24: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_24, - 32: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_32, -} - - -es7210_mic_gain = es7210_ns.enum("ES7210MicGain") -ES7210_MIC_GAIN_ENUM = { - "0DB": es7210_mic_gain.ES7210_MIC_GAIN_0DB, - "3DB": es7210_mic_gain.ES7210_MIC_GAIN_3DB, - "6DB": es7210_mic_gain.ES7210_MIC_GAIN_6DB, - "9DB": es7210_mic_gain.ES7210_MIC_GAIN_9DB, - "12DB": es7210_mic_gain.ES7210_MIC_GAIN_12DB, - "15DB": es7210_mic_gain.ES7210_MIC_GAIN_15DB, - "18DB": es7210_mic_gain.ES7210_MIC_GAIN_18DB, - "21DB": es7210_mic_gain.ES7210_MIC_GAIN_21DB, - "24DB": es7210_mic_gain.ES7210_MIC_GAIN_24DB, - "27DB": es7210_mic_gain.ES7210_MIC_GAIN_27DB, - "30DB": es7210_mic_gain.ES7210_MIC_GAIN_30DB, - "33DB": es7210_mic_gain.ES7210_MIC_GAIN_33DB, - "34.5DB": es7210_mic_gain.ES7210_MIC_GAIN_34_5DB, - "36DB": es7210_mic_gain.ES7210_MIC_GAIN_36DB, - "37.5DB": es7210_mic_gain.ES7210_MIC_GAIN_37_5DB, -} - -_validate_bits = cv.float_with_unit("bits", "bit") - -CONFIG_SCHEMA = ( - cv.Schema( - { - cv.GenerateID(): cv.declare_id(ES7210), - cv.Optional(CONF_BITS_PER_SAMPLE, default="16bit"): cv.All( - _validate_bits, cv.enum(ES7210_BITS_PER_SAMPLE_ENUM) - ), - cv.Optional(CONF_MIC_GAIN, default="24DB"): cv.enum( - ES7210_MIC_GAIN_ENUM, upper=True - ), - cv.Optional(CONF_SAMPLE_RATE, default=16000): cv.int_range(min=1), - } - ) - .extend(cv.COMPONENT_SCHEMA) - .extend(i2c.i2c_device_schema(0x40)) -) - - -async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await cg.register_component(var, config) - await i2c.register_i2c_device(var, config) - - cg.add(var.set_bits_per_sample(config[CONF_BITS_PER_SAMPLE])) - cg.add(var.set_mic_gain(config[CONF_MIC_GAIN])) - cg.add(var.set_sample_rate(config[CONF_SAMPLE_RATE])) diff --git a/esphome/components/es7210/audio_adc.py b/esphome/components/es7210/audio_adc.py new file mode 100644 index 0000000000..f0bd8bc25a --- /dev/null +++ b/esphome/components/es7210/audio_adc.py @@ -0,0 +1,51 @@ +import esphome.codegen as cg +from esphome.components import i2c +from esphome.components.audio_adc import AudioAdc +import esphome.config_validation as cv +from esphome.const import CONF_BITS_PER_SAMPLE, CONF_ID, CONF_MIC_GAIN, CONF_SAMPLE_RATE + +CODEOWNERS = ["@kahrendt"] +DEPENDENCIES = ["i2c"] + +es7210_ns = cg.esphome_ns.namespace("es7210") +ES7210 = es7210_ns.class_("ES7210", AudioAdc, cg.Component, i2c.I2CDevice) + + +es7210_bits_per_sample = es7210_ns.enum("ES7210BitsPerSample") +ES7210_BITS_PER_SAMPLE_ENUM = { + 16: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_16, + 24: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_24, + 32: es7210_bits_per_sample.ES7210_BITS_PER_SAMPLE_32, +} + + +ES7210_MIC_GAINS = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 34.5, 36, 37.5] + +_validate_bits = cv.float_with_unit("bits", "bit") + +CONFIG_SCHEMA = ( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(ES7210), + cv.Optional(CONF_BITS_PER_SAMPLE, default="16bit"): cv.All( + _validate_bits, cv.enum(ES7210_BITS_PER_SAMPLE_ENUM) + ), + cv.Optional(CONF_MIC_GAIN, default="24db"): cv.All( + cv.decibel, cv.one_of(*ES7210_MIC_GAINS) + ), + cv.Optional(CONF_SAMPLE_RATE, default=16000): cv.int_range(min=1), + } + ) + .extend(cv.COMPONENT_SCHEMA) + .extend(i2c.i2c_device_schema(0x40)) +) + + +async def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + + cg.add(var.set_bits_per_sample(config[CONF_BITS_PER_SAMPLE])) + cg.add(var.set_mic_gain(config[CONF_MIC_GAIN])) + cg.add(var.set_sample_rate(config[CONF_SAMPLE_RATE])) diff --git a/esphome/components/es7210/es7210.cpp b/esphome/components/es7210/es7210.cpp index d2f2c3c1ff..9a99e60995 100644 --- a/esphome/components/es7210/es7210.cpp +++ b/esphome/components/es7210/es7210.cpp @@ -25,12 +25,12 @@ static const size_t MCLK_DIV_FRE = 256; } void ES7210::dump_config() { - ESP_LOGCONFIG(TAG, "ES7210 ADC:"); + ESP_LOGCONFIG(TAG, "ES7210 audio ADC:"); ESP_LOGCONFIG(TAG, " Bits Per Sample: %" PRIu8, this->bits_per_sample_); ESP_LOGCONFIG(TAG, " Sample Rate: %" PRIu32, this->sample_rate_); if (this->is_failed()) { - ESP_LOGCONFIG(TAG, " Failed to initialize!"); + ESP_LOGE(TAG, " Failed to initialize"); return; } } @@ -84,6 +84,16 @@ void ES7210::setup() { // Enable device ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x71)); ES7210_ERROR_FAILED(this->write_byte(ES7210_RESET_REG00, 0x41)); + + this->setup_complete_ = true; +} + +bool ES7210::set_mic_gain(float mic_gain) { + this->mic_gain_ = clamp(mic_gain, ES7210_MIC_GAIN_MIN, ES7210_MIC_GAIN_MAX); + if (this->setup_complete_) { + return this->configure_mic_gain_(); + } + return true; } bool ES7210::configure_sample_rate_() { @@ -122,9 +132,11 @@ bool ES7210::configure_sample_rate_() { return true; } + bool ES7210::configure_mic_gain_() { - for (int i = 0; i < 4; ++i) { - this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43 + i, 0x10, 0x00); + auto regv = this->es7210_gain_reg_value_(this->mic_gain_); + for (uint8_t i = 0; i < 4; ++i) { + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43 + i, 0x10, 0x00)); } ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0xff)); ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0xff)); @@ -133,29 +145,44 @@ bool ES7210::configure_mic_gain_() { ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00)); ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x00)); ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43, 0x10, 0x10)); - ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43, 0x0f, this->mic_gain_)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC1_GAIN_REG43, 0x0f, regv)); // Configure mic 2 ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00)); ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC12_POWER_REG4B, 0x00)); ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC2_GAIN_REG44, 0x10, 0x10)); - ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC2_GAIN_REG44, 0x0f, this->mic_gain_)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC2_GAIN_REG44, 0x0f, regv)); // Configure mic 3 ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00)); ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x00)); ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC3_GAIN_REG45, 0x10, 0x10)); - ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC3_GAIN_REG45, 0x0f, this->mic_gain_)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC3_GAIN_REG45, 0x0f, regv)); // Configure mic 4 ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_CLOCK_OFF_REG01, 0x0b, 0x00)); ES7210_ERROR_CHECK(this->write_byte(ES7210_MIC34_POWER_REG4C, 0x00)); ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC4_GAIN_REG46, 0x10, 0x10)); - ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC4_GAIN_REG46, 0x0f, this->mic_gain_)); + ES7210_ERROR_CHECK(this->es7210_update_reg_bit_(ES7210_MIC4_GAIN_REG46, 0x0f, regv)); return true; } +uint8_t ES7210::es7210_gain_reg_value_(float mic_gain) { + // reg: 12 - 34.5dB, 13 - 36dB, 14 - 37.5dB + mic_gain += 0.5; + if (mic_gain <= 33.0) { + return (uint8_t) mic_gain / 3; + } + if (mic_gain < 36.0) { + return 12; + } + if (mic_gain < 37.0) { + return 13; + } + return 14; +} + bool ES7210::configure_i2s_format_() { // Configure bits per sample uint8_t reg_val = 0; diff --git a/esphome/components/es7210/es7210.h b/esphome/components/es7210/es7210.h index a40dde5aa5..8f6d9d8136 100644 --- a/esphome/components/es7210/es7210.h +++ b/esphome/components/es7210/es7210.h @@ -1,8 +1,11 @@ #pragma once +#include "esphome/components/audio_adc/audio_adc.h" #include "esphome/components/i2c/i2c.h" #include "esphome/core/component.h" +#include "es7210_const.h" + namespace esphome { namespace es7210 { @@ -14,25 +17,7 @@ enum ES7210BitsPerSample : uint8_t { ES7210_BITS_PER_SAMPLE_32 = 32, }; -enum ES7210MicGain : uint8_t { - ES7210_MIC_GAIN_0DB = 0, - ES7210_MIC_GAIN_3DB, - ES7210_MIC_GAIN_6DB, - ES7210_MIC_GAIN_9DB, - ES7210_MIC_GAIN_12DB, - ES7210_MIC_GAIN_15DB, - ES7210_MIC_GAIN_18DB, - ES7210_MIC_GAIN_21DB, - ES7210_MIC_GAIN_24DB, - ES7210_MIC_GAIN_27DB, - ES7210_MIC_GAIN_30DB, - ES7210_MIC_GAIN_33DB, - ES7210_MIC_GAIN_34_5DB, - ES7210_MIC_GAIN_36DB, - ES7210_MIC_GAIN_37_5DB, -}; - -class ES7210 : public Component, public i2c::I2CDevice { +class ES7210 : public audio_adc::AudioAdc, public Component, public i2c::I2CDevice { /* Class for configuring an ES7210 ADC for microphone input. * Based on code from: * - https://github.com/espressif/esp-bsp/ (accessed 20241219) @@ -44,9 +29,11 @@ class ES7210 : public Component, public i2c::I2CDevice { void dump_config() override; void set_bits_per_sample(ES7210BitsPerSample bits_per_sample) { this->bits_per_sample_ = bits_per_sample; } - void set_mic_gain(ES7210MicGain mic_gain) { this->mic_gain_ = mic_gain; } + bool set_mic_gain(float mic_gain) override; void set_sample_rate(uint32_t sample_rate) { this->sample_rate_ = sample_rate; } + float mic_gain() override { return this->mic_gain_; }; + protected: /// @brief Updates an I2C registry address by modifying the current state /// @param reg_addr I2C register address @@ -55,14 +42,20 @@ class ES7210 : public Component, public i2c::I2CDevice { /// @return True if successful, false otherwise bool es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data); + /// @brief Convert floating point mic gain value to register value + /// @param mic_gain Gain value to convert + /// @return Corresponding register value for specified gain + uint8_t es7210_gain_reg_value_(float mic_gain); + bool configure_i2s_format_(); bool configure_mic_gain_(); bool configure_sample_rate_(); + bool setup_complete_{false}; bool enable_tdm_{false}; // TDM is unsupported in ESPHome as of version 2024.12 - ES7210MicGain mic_gain_; - ES7210BitsPerSample bits_per_sample_; - uint32_t sample_rate_; + float mic_gain_{0}; + ES7210BitsPerSample bits_per_sample_{ES7210_BITS_PER_SAMPLE_16}; + uint32_t sample_rate_{0}; }; } // namespace es7210 diff --git a/esphome/components/es7210/es7210_const.h b/esphome/components/es7210/es7210_const.h index 87fd6d86d2..e5ffea5743 100644 --- a/esphome/components/es7210/es7210_const.h +++ b/esphome/components/es7210/es7210_const.h @@ -1,6 +1,6 @@ #pragma once -#include "es7210.h" +#include namespace esphome { namespace es7210 { @@ -42,7 +42,7 @@ static const uint8_t ES7210_MIC12_POWER_REG4B = 0x4B; /* MICBias & ADC & PGA Pow static const uint8_t ES7210_MIC34_POWER_REG4C = 0x4C; /* - * Clock coefficient structer + * Clock coefficient structure */ struct ES7210Coefficient { uint32_t mclk; // mclk frequency @@ -122,5 +122,8 @@ static const ES7210Coefficient ES7210_COEFFICIENTS[] = { {19200000, 96000, 0x01, 0x05, 0x00, 0x01, 0x28, 0x00, 0x00, 0xc8}, }; +static const float ES7210_MIC_GAIN_MIN = 0.0; +static const float ES7210_MIC_GAIN_MAX = 37.5; + } // namespace es7210 } // namespace esphome diff --git a/tests/components/es7210/common.yaml b/tests/components/es7210/common.yaml index 5c30f7e883..3fab177cb3 100644 --- a/tests/components/es7210/common.yaml +++ b/tests/components/es7210/common.yaml @@ -1,6 +1,16 @@ +esphome: + on_boot: + then: + - audio_adc.set_mic_gain: 0db + - audio_adc.set_mic_gain: !lambda 'return 4;' + i2c: - id: i2c_aic3204 scl: ${scl_pin} sda: ${sda_pin} -es7210: +audio_adc: + - platform: es7210 + id: es7210_adc + bits_per_sample: 16bit + sample_rate: 16000 From 0f4e274e522bb403b2e73fb535e0743c4129e2c4 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Tue, 21 Jan 2025 13:43:50 +1100 Subject: [PATCH 097/194] [uptime] Cosmetic improvements for uptime text_sensor (#8101) --- .../components/uptime/text_sensor/__init__.py | 2 +- .../uptime/text_sensor/uptime_text_sensor.cpp | 59 ++++++++++++------- .../uptime/text_sensor/uptime_text_sensor.h | 4 +- 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/esphome/components/uptime/text_sensor/__init__.py b/esphome/components/uptime/text_sensor/__init__.py index 996d983e71..e4a7ac6517 100644 --- a/esphome/components/uptime/text_sensor/__init__.py +++ b/esphome/components/uptime/text_sensor/__init__.py @@ -11,7 +11,7 @@ CONFIG_SCHEMA = text_sensor.text_sensor_schema( UptimeTextSensor, icon=ICON_TIMER, entity_category=ENTITY_CATEGORY_DIAGNOSTIC, -).extend(cv.polling_component_schema("60s")) +).extend(cv.polling_component_schema("30s")) async def to_code(config): diff --git a/esphome/components/uptime/text_sensor/uptime_text_sensor.cpp b/esphome/components/uptime/text_sensor/uptime_text_sensor.cpp index 0fa5e199f3..409af6e4ff 100644 --- a/esphome/components/uptime/text_sensor/uptime_text_sensor.cpp +++ b/esphome/components/uptime/text_sensor/uptime_text_sensor.cpp @@ -9,34 +9,51 @@ namespace uptime { static const char *const TAG = "uptime.sensor"; -void UptimeTextSensor::setup() { this->last_ms_ = millis(); } +void UptimeTextSensor::setup() { + this->last_ms_ = millis(); + if (this->last_ms_ < 60 * 1000) + this->last_ms_ = 0; + this->update(); +} void UptimeTextSensor::update() { - const auto now = millis(); + auto now = millis(); // get whole seconds since last update. Note that even if the millis count has overflowed between updates, // the difference will still be correct due to the way twos-complement arithmetic works. - const uint32_t delta = (now - this->last_ms_) / 1000; - if (delta == 0) - return; - // set last_ms_ to the last second boundary - this->last_ms_ = now - (now % 1000); + uint32_t delta = now - this->last_ms_; + this->last_ms_ = now - delta % 1000; // save remainder for next update + delta /= 1000; this->uptime_ += delta; auto uptime = this->uptime_; - unsigned days = uptime / (24 * 3600); - unsigned seconds = uptime % (24 * 3600); - unsigned hours = seconds / 3600; - seconds %= 3600; - unsigned minutes = seconds / 60; - seconds %= 60; - if (days != 0) { - this->publish_state(str_sprintf("%dd%dh%dm%ds", days, hours, minutes, seconds)); - } else if (hours != 0) { - this->publish_state(str_sprintf("%dh%dm%ds", hours, minutes, seconds)); - } else if (minutes != 0) { - this->publish_state(str_sprintf("%dm%ds", minutes, seconds)); - } else { - this->publish_state(str_sprintf("%ds", seconds)); + unsigned interval = this->get_update_interval() / 1000; + std::string buffer{}; + // display from the largest unit that corresponds to the update interval, drop larger units that are zero. + while (true) { // enable use of break for early exit + unsigned remainder = uptime % 60; + uptime /= 60; + if (interval < 30) { + buffer.insert(0, str_sprintf("%us", remainder)); + if (uptime == 0) + break; + } + remainder = uptime % 60; + uptime /= 60; + if (interval < 1800) { + buffer.insert(0, str_sprintf("%um", remainder)); + if (uptime == 0) + break; + } + remainder = uptime % 24; + uptime /= 24; + if (interval < 12 * 3600) { + buffer.insert(0, str_sprintf("%uh", remainder)); + if (uptime == 0) + break; + } + buffer.insert(0, str_sprintf("%ud", (unsigned) uptime)); + break; } + this->publish_state(buffer); } float UptimeTextSensor::get_setup_priority() const { return setup_priority::HARDWARE; } diff --git a/esphome/components/uptime/text_sensor/uptime_text_sensor.h b/esphome/components/uptime/text_sensor/uptime_text_sensor.h index 4baf1039b6..5719ef38a2 100644 --- a/esphome/components/uptime/text_sensor/uptime_text_sensor.h +++ b/esphome/components/uptime/text_sensor/uptime_text_sensor.h @@ -17,8 +17,8 @@ class UptimeTextSensor : public text_sensor::TextSensor, public PollingComponent float get_setup_priority() const override; protected: - uint64_t uptime_{0}; - uint64_t last_ms_{0}; + uint32_t uptime_{0}; // uptime in seconds, will overflow after 136 years + uint32_t last_ms_{0}; }; } // namespace uptime From 716a8b87e1b033b454e3a1f50e3e37bb37177403 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Mon, 20 Jan 2025 21:15:18 -0600 Subject: [PATCH 098/194] [es8156] Add support for ES8156 audio DAC (#8085) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- CODEOWNERS | 1 + esphome/components/es8156/__init__.py | 0 esphome/components/es8156/audio_dac.py | 27 ++++++ esphome/components/es8156/es8156.cpp | 87 +++++++++++++++++++ esphome/components/es8156/es8156.h | 51 +++++++++++ esphome/components/es8156/es8156_const.h | 68 +++++++++++++++ tests/components/es8156/common.yaml | 15 ++++ tests/components/es8156/test.esp32-ard.yaml | 5 ++ .../components/es8156/test.esp32-c3-ard.yaml | 5 ++ .../components/es8156/test.esp32-c3-idf.yaml | 5 ++ tests/components/es8156/test.esp32-idf.yaml | 5 ++ tests/components/es8156/test.esp8266-ard.yaml | 5 ++ 12 files changed, 274 insertions(+) create mode 100644 esphome/components/es8156/__init__.py create mode 100644 esphome/components/es8156/audio_dac.py create mode 100644 esphome/components/es8156/es8156.cpp create mode 100644 esphome/components/es8156/es8156.h create mode 100644 esphome/components/es8156/es8156_const.h create mode 100644 tests/components/es8156/common.yaml create mode 100644 tests/components/es8156/test.esp32-ard.yaml create mode 100644 tests/components/es8156/test.esp32-c3-ard.yaml create mode 100644 tests/components/es8156/test.esp32-c3-idf.yaml create mode 100644 tests/components/es8156/test.esp32-idf.yaml create mode 100644 tests/components/es8156/test.esp8266-ard.yaml diff --git a/CODEOWNERS b/CODEOWNERS index 56e20133ef..e2c674cfd3 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -133,6 +133,7 @@ esphome/components/ens160_i2c/* @latonita esphome/components/ens160_spi/* @latonita esphome/components/ens210/* @itn3rd77 esphome/components/es7210/* @kahrendt +esphome/components/es8156/* @kbx81 esphome/components/es8311/* @kahrendt @kroimon esphome/components/esp32/* @esphome/core esphome/components/esp32_ble/* @Rapsssito @jesserockz diff --git a/esphome/components/es8156/__init__.py b/esphome/components/es8156/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/esphome/components/es8156/audio_dac.py b/esphome/components/es8156/audio_dac.py new file mode 100644 index 0000000000..b9d8eae6b0 --- /dev/null +++ b/esphome/components/es8156/audio_dac.py @@ -0,0 +1,27 @@ +import esphome.codegen as cg +from esphome.components import i2c +from esphome.components.audio_dac import AudioDac +import esphome.config_validation as cv +from esphome.const import CONF_ID + +CODEOWNERS = ["@kbx81"] +DEPENDENCIES = ["i2c"] + +es8156_ns = cg.esphome_ns.namespace("es8156") +ES8156 = es8156_ns.class_("ES8156", AudioDac, cg.Component, i2c.I2CDevice) + +CONFIG_SCHEMA = ( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(ES8156), + } + ) + .extend(cv.COMPONENT_SCHEMA) + .extend(i2c.i2c_device_schema(0x08)) +) + + +async def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/es8156/es8156.cpp b/esphome/components/es8156/es8156.cpp new file mode 100644 index 0000000000..62d35aa2d2 --- /dev/null +++ b/esphome/components/es8156/es8156.cpp @@ -0,0 +1,87 @@ +#include "es8156.h" +#include "es8156_const.h" +#include "esphome/core/hal.h" +#include "esphome/core/log.h" +#include + +namespace esphome { +namespace es8156 { + +static const char *const TAG = "es8156"; + +// Mark the component as failed; use only in setup +#define ES8156_ERROR_FAILED(func) \ + if (!(func)) { \ + this->mark_failed(); \ + return; \ + } + +void ES8156::setup() { + ESP_LOGCONFIG(TAG, "Setting up ES8156..."); + + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG02_SCLK_MODE, 0x04)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG20_ANALOG_SYS1, 0x2A)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG21_ANALOG_SYS2, 0x3C)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG22_ANALOG_SYS3, 0x00)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG24_ANALOG_LP, 0x07)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG23_ANALOG_SYS4, 0x00)); + + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG0A_TIME_CONTROL1, 0x01)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG0B_TIME_CONTROL2, 0x01)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG11_DAC_SDP, 0x00)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG19_EQ_CONTROL1, 0x20)); + + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG0D_P2S_CONTROL, 0x14)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG09_MISC_CONTROL2, 0x00)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG18_MISC_CONTROL3, 0x00)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG08_CLOCK_ON_OFF, 0x3F)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG00_RESET, 0x02)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG00_RESET, 0x03)); + ES8156_ERROR_FAILED(this->write_byte(ES8156_REG25_ANALOG_SYS5, 0x20)); +} + +void ES8156::dump_config() { + ESP_LOGCONFIG(TAG, "ES8156 Audio Codec:"); + + if (this->is_failed()) { + ESP_LOGCONFIG(TAG, " Failed to initialize"); + return; + } +} + +bool ES8156::set_volume(float volume) { + volume = clamp(volume, 0.0f, 1.0f); + uint8_t reg = remap(volume, 0.0f, 1.0f, 0, 255); + ESP_LOGV(TAG, "Setting ES8156_REG14_VOLUME_CONTROL to %u (volume: %f)", reg, volume); + return this->write_byte(ES8156_REG14_VOLUME_CONTROL, reg); +} + +float ES8156::volume() { + uint8_t reg; + this->read_byte(ES8156_REG14_VOLUME_CONTROL, ®); + return remap(reg, 0, 255, 0.0f, 1.0f); +} + +bool ES8156::set_mute_state_(bool mute_state) { + uint8_t reg13; + + this->is_muted_ = mute_state; + + if (!this->read_byte(ES8156_REG13_DAC_MUTE, ®13)) { + return false; + } + + ESP_LOGV(TAG, "Read ES8156_REG13_DAC_MUTE: %u", reg13); + + if (mute_state) { + reg13 |= BIT(1) | BIT(2); + } else { + reg13 &= ~(BIT(1) | BIT(2)); + } + + ESP_LOGV(TAG, "Setting ES8156_REG13_DAC_MUTE to %u (muted: %s)", reg13, YESNO(mute_state)); + return this->write_byte(ES8156_REG13_DAC_MUTE, reg13); +} + +} // namespace es8156 +} // namespace esphome diff --git a/esphome/components/es8156/es8156.h b/esphome/components/es8156/es8156.h new file mode 100644 index 0000000000..e973599a7a --- /dev/null +++ b/esphome/components/es8156/es8156.h @@ -0,0 +1,51 @@ +#pragma once + +#include "esphome/components/audio_dac/audio_dac.h" +#include "esphome/components/i2c/i2c.h" +#include "esphome/core/component.h" + +namespace esphome { +namespace es8156 { + +class ES8156 : public audio_dac::AudioDac, public Component, public i2c::I2CDevice { + public: + ///////////////////////// + // Component overrides // + ///////////////////////// + + void setup() override; + float get_setup_priority() const override { return setup_priority::DATA; } + void dump_config() override; + + //////////////////////// + // AudioDac overrides // + //////////////////////// + + /// @brief Writes the volume out to the DAC + /// @param volume floating point between 0.0 and 1.0 + /// @return True if successful and false otherwise + bool set_volume(float volume) override; + + /// @brief Gets the current volume out from the DAC + /// @return floating point between 0.0 and 1.0 + float volume() override; + + /// @brief Disables mute for audio out + /// @return True if successful and false otherwise + bool set_mute_off() override { return this->set_mute_state_(false); } + + /// @brief Enables mute for audio out + /// @return True if successful and false otherwise + bool set_mute_on() override { return this->set_mute_state_(true); } + + bool is_muted() override { return this->is_muted_; } + + protected: + /// @brief Mutes or unmutes the DAC audio out + /// @param mute_state True to mute, false to unmute + /// @return True if successful and false otherwise + bool set_mute_state_(bool mute_state); +}; + +} // namespace es8156 +} // namespace esphome diff --git a/esphome/components/es8156/es8156_const.h b/esphome/components/es8156/es8156_const.h new file mode 100644 index 0000000000..0bc8f89dd4 --- /dev/null +++ b/esphome/components/es8156/es8156_const.h @@ -0,0 +1,68 @@ +#pragma once + +#include "es8156.h" + +namespace esphome { +namespace es8156 { + +/* ES8156 register addresses */ +/* + * RESET Control + */ +static const uint8_t ES8156_REG00_RESET = 0x00; +/* + * Clock Managerment + */ +static const uint8_t ES8156_REG01_MAINCLOCK_CTL = 0x01; +static const uint8_t ES8156_REG02_SCLK_MODE = 0x02; +static const uint8_t ES8156_REG03_LRCLK_DIV_H = 0x03; +static const uint8_t ES8156_REG04_LRCLK_DIV_L = 0x04; +static const uint8_t ES8156_REG05_SCLK_DIV = 0x05; +static const uint8_t ES8156_REG06_NFS_CONFIG = 0x06; +static const uint8_t ES8156_REG07_MISC_CONTROL1 = 0x07; +static const uint8_t ES8156_REG08_CLOCK_ON_OFF = 0x08; +static const uint8_t ES8156_REG09_MISC_CONTROL2 = 0x09; +static const uint8_t ES8156_REG0A_TIME_CONTROL1 = 0x0a; +static const uint8_t ES8156_REG0B_TIME_CONTROL2 = 0x0b; +/* + * System Control + */ +static const uint8_t ES8156_REG0C_CHIP_STATUS = 0x0c; +static const uint8_t ES8156_REG0D_P2S_CONTROL = 0x0d; +static const uint8_t ES8156_REG10_DAC_OSR_COUNTER = 0x10; +/* + * SDP Control + */ +static const uint8_t ES8156_REG11_DAC_SDP = 0x11; +static const uint8_t ES8156_REG12_AUTOMUTE_SET = 0x12; +static const uint8_t ES8156_REG13_DAC_MUTE = 0x13; +static const uint8_t ES8156_REG14_VOLUME_CONTROL = 0x14; + +/* + * ALC Control + */ +static const uint8_t ES8156_REG15_ALC_CONFIG1 = 0x15; +static const uint8_t ES8156_REG16_ALC_CONFIG2 = 0x16; +static const uint8_t ES8156_REG17_ALC_CONFIG3 = 0x17; +static const uint8_t ES8156_REG18_MISC_CONTROL3 = 0x18; +static const uint8_t ES8156_REG19_EQ_CONTROL1 = 0x19; +static const uint8_t ES8156_REG1A_EQ_CONTROL2 = 0x1a; +/* + * Analog System Control + */ +static const uint8_t ES8156_REG20_ANALOG_SYS1 = 0x20; +static const uint8_t ES8156_REG21_ANALOG_SYS2 = 0x21; +static const uint8_t ES8156_REG22_ANALOG_SYS3 = 0x22; +static const uint8_t ES8156_REG23_ANALOG_SYS4 = 0x23; +static const uint8_t ES8156_REG24_ANALOG_LP = 0x24; +static const uint8_t ES8156_REG25_ANALOG_SYS5 = 0x25; +/* + * Chip Information + */ +static const uint8_t ES8156_REGFC_I2C_PAGESEL = 0xFC; +static const uint8_t ES8156_REGFD_CHIPID1 = 0xFD; +static const uint8_t ES8156_REGFE_CHIPID0 = 0xFE; +static const uint8_t ES8156_REGFF_CHIP_VERSION = 0xFF; + +} // namespace es8156 +} // namespace esphome diff --git a/tests/components/es8156/common.yaml b/tests/components/es8156/common.yaml new file mode 100644 index 0000000000..addaa0b70a --- /dev/null +++ b/tests/components/es8156/common.yaml @@ -0,0 +1,15 @@ +esphome: + on_boot: + then: + - audio_dac.mute_off: + - audio_dac.mute_on: + - audio_dac.set_volume: + volume: 50% + +i2c: + - id: i2c_es8156 + scl: ${scl_pin} + sda: ${sda_pin} + +audio_dac: + - platform: es8156 diff --git a/tests/components/es8156/test.esp32-ard.yaml b/tests/components/es8156/test.esp32-ard.yaml new file mode 100644 index 0000000000..63c3bd6afd --- /dev/null +++ b/tests/components/es8156/test.esp32-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/es8156/test.esp32-c3-ard.yaml b/tests/components/es8156/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/es8156/test.esp32-c3-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/es8156/test.esp32-c3-idf.yaml b/tests/components/es8156/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/es8156/test.esp32-c3-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/es8156/test.esp32-idf.yaml b/tests/components/es8156/test.esp32-idf.yaml new file mode 100644 index 0000000000..63c3bd6afd --- /dev/null +++ b/tests/components/es8156/test.esp32-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/es8156/test.esp8266-ard.yaml b/tests/components/es8156/test.esp8266-ard.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/es8156/test.esp8266-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml From db644542eda3482a50f0d30c4ab36ea3c635ff6c Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Mon, 20 Jan 2025 22:17:32 -0500 Subject: [PATCH 099/194] [esp32_touch] Fix deprecated warning (#8092) Co-authored-by: Jonathan Swoboda --- esphome/components/esp32_touch/esp32_touch.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/esphome/components/esp32_touch/esp32_touch.cpp b/esphome/components/esp32_touch/esp32_touch.cpp index e43c3b844c..0ae414fa12 100644 --- a/esphome/components/esp32_touch/esp32_touch.cpp +++ b/esphome/components/esp32_touch/esp32_touch.cpp @@ -52,7 +52,12 @@ void ESP32TouchComponent::setup() { } #endif +#if ESP_IDF_VERSION_MAJOR >= 5 + touch_pad_set_measurement_clock_cycles(this->meas_cycle_); + touch_pad_set_measurement_interval(this->sleep_cycle_); +#else touch_pad_set_meas_time(this->sleep_cycle_, this->meas_cycle_); +#endif touch_pad_set_voltage(this->high_voltage_reference_, this->low_voltage_reference_, this->voltage_attenuation_); for (auto *child : this->children_) { From b454f63b3604d766abb038fe3c0f79dc20ab5cad Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 21 Jan 2025 19:32:47 +1300 Subject: [PATCH 100/194] [core] Remove old style platform configuration (#8118) --- esphome/core/config.py | 75 ++----------------- .../binary_sensor/test_binary_sensor.yaml | 3 +- tests/component_tests/button/test_button.yaml | 3 +- .../deep_sleep/test_deep_sleep1.yaml | 3 +- .../deep_sleep/test_deep_sleep2.yaml | 3 +- tests/component_tests/sensor/test_sensor.yaml | 3 +- .../text_sensor/test_text_sensor.yaml | 3 +- .../yaml_util/broken_includetest.yaml | 6 +- .../fixtures/yaml_util/includetest.yaml | 6 +- tests/unit_tests/test_yaml_util.py | 2 +- 10 files changed, 27 insertions(+), 80 deletions(-) diff --git a/esphome/core/config.py b/esphome/core/config.py index eee8b73934..c6a3b1b294 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -1,21 +1,16 @@ import logging import multiprocessing import os -import re from esphome import automation import esphome.codegen as cg import esphome.config_validation as cv from esphome.const import ( - CONF_ARDUINO_VERSION, CONF_AREA, - CONF_BOARD, - CONF_BOARD_FLASH_MODE, CONF_BUILD_PATH, CONF_COMMENT, CONF_COMPILE_PROCESS_LIMIT, CONF_ESPHOME, - CONF_FRAMEWORK, CONF_FRIENDLY_NAME, CONF_INCLUDES, CONF_LIBRARIES, @@ -30,12 +25,9 @@ from esphome.const import ( CONF_PLATFORMIO_OPTIONS, CONF_PRIORITY, CONF_PROJECT, - CONF_SOURCE, CONF_TRIGGER_ID, - CONF_TYPE, CONF_VERSION, KEY_CORE, - PLATFORM_ESP8266, TARGET_PLATFORMS, __version__ as ESPHOME_VERSION, ) @@ -44,7 +36,6 @@ from esphome.helpers import copy_file_if_changed, get_str_env, walk_files _LOGGER = logging.getLogger(__name__) -BUILD_FLASH_MODES = ["qio", "qout", "dio", "dout"] StartupTrigger = cg.esphome_ns.class_( "StartupTrigger", cg.Component, automation.Trigger.template() ) @@ -58,8 +49,6 @@ ProjectUpdateTrigger = cg.esphome_ns.class_( "ProjectUpdateTrigger", cg.Component, automation.Trigger.template(cg.std_string) ) -VERSION_REGEX = re.compile(r"^[0-9]+\.[0-9]+\.[0-9]+(?:[ab]\d+)?$") - VALID_INCLUDE_EXTS = {".h", ".hpp", ".tcc", ".ino", ".cpp", ".c"} @@ -111,7 +100,6 @@ else: _compile_process_limit_default = cv.UNDEFINED -CONF_ESP8266_RESTORE_FROM_FLASH = "esp8266_restore_from_flash" CONFIG_SCHEMA = cv.All( cv.Schema( { @@ -175,14 +163,9 @@ PRELOAD_CONFIG_SCHEMA = cv.Schema( { cv.Required(CONF_NAME): cv.valid_name, cv.Optional(CONF_BUILD_PATH): cv.string, - # Compat options, these were moved to target-platform specific sections - # but we'll keep these around for a long time because every config would - # be impacted - cv.Optional(CONF_PLATFORM): cv.one_of(*TARGET_PLATFORMS, lower=True), - cv.Optional(CONF_BOARD): cv.string_strict, - cv.Optional(CONF_ESP8266_RESTORE_FROM_FLASH): cv.valid, - cv.Optional(CONF_BOARD_FLASH_MODE): cv.valid, - cv.Optional(CONF_ARDUINO_VERSION): cv.valid, + cv.Optional(CONF_PLATFORM): cv.invalid( + "Please remove the `platform` key from the [esphome] block and use the correct platform component. This style of configuration has now been removed." + ), cv.Optional(CONF_MIN_VERSION, default=ESPHOME_VERSION): cv.All( cv.version_number, cv.validate_esphome_version ), @@ -204,62 +187,20 @@ def preload_core_config(config, result): conf[CONF_BUILD_PATH] = os.path.join(build_path, CORE.name) CORE.build_path = CORE.relative_internal_path(conf[CONF_BUILD_PATH]) - has_oldstyle = CONF_PLATFORM in conf - newstyle_found = [key for key in TARGET_PLATFORMS if key in config] - oldstyle_opts = [ - CONF_ESP8266_RESTORE_FROM_FLASH, - CONF_BOARD_FLASH_MODE, - CONF_ARDUINO_VERSION, - CONF_BOARD, - ] + target_platforms = [key for key in TARGET_PLATFORMS if key in config] - if not has_oldstyle and not newstyle_found: + if not target_platforms: raise cv.Invalid( "Platform missing. You must include one of the available platform keys: " + ", ".join(TARGET_PLATFORMS), [CONF_ESPHOME], ) - if has_oldstyle and newstyle_found: + if len(target_platforms) > 1: raise cv.Invalid( - f"Please remove the `platform` key from the [esphome] block. You're already using the new style with the [{conf[CONF_PLATFORM]}] block", - [CONF_ESPHOME, CONF_PLATFORM], + f"Found multiple target platform blocks: {', '.join(target_platforms)}. Only one is allowed.", + [target_platforms[0]], ) - if len(newstyle_found) > 1: - raise cv.Invalid( - f"Found multiple target platform blocks: {', '.join(newstyle_found)}. Only one is allowed.", - [newstyle_found[0]], - ) - if newstyle_found: - # Convert to newstyle - for key in oldstyle_opts: - if key in conf: - raise cv.Invalid( - f"Please move {key} to the [{newstyle_found[0]}] block.", - [CONF_ESPHOME, key], - ) - if has_oldstyle: - plat = conf.pop(CONF_PLATFORM) - plat_conf = {} - if CONF_ESP8266_RESTORE_FROM_FLASH in conf: - plat_conf["restore_from_flash"] = conf.pop(CONF_ESP8266_RESTORE_FROM_FLASH) - if CONF_BOARD_FLASH_MODE in conf: - plat_conf[CONF_BOARD_FLASH_MODE] = conf.pop(CONF_BOARD_FLASH_MODE) - if CONF_ARDUINO_VERSION in conf: - plat_conf[CONF_FRAMEWORK] = {} - if plat != PLATFORM_ESP8266: - plat_conf[CONF_FRAMEWORK][CONF_TYPE] = "arduino" - - try: - if conf[CONF_ARDUINO_VERSION] not in ("recommended", "latest", "dev"): - cv.Version.parse(conf[CONF_ARDUINO_VERSION]) - plat_conf[CONF_FRAMEWORK][CONF_VERSION] = conf.pop(CONF_ARDUINO_VERSION) - except ValueError: - plat_conf[CONF_FRAMEWORK][CONF_SOURCE] = conf.pop(CONF_ARDUINO_VERSION) - if CONF_BOARD in conf: - plat_conf[CONF_BOARD] = conf.pop(CONF_BOARD) - # Insert generated target platform config to main config - config[plat] = plat_conf config[CONF_ESPHOME] = conf diff --git a/tests/component_tests/binary_sensor/test_binary_sensor.yaml b/tests/component_tests/binary_sensor/test_binary_sensor.yaml index f98ce693f7..8842dda837 100644 --- a/tests/component_tests/binary_sensor/test_binary_sensor.yaml +++ b/tests/component_tests/binary_sensor/test_binary_sensor.yaml @@ -1,7 +1,8 @@ --- esphome: name: test - platform: ESP8266 + +esp8266: board: d1_mini_lite binary_sensor: diff --git a/tests/component_tests/button/test_button.yaml b/tests/component_tests/button/test_button.yaml index 48e13f0353..916c85cb8b 100644 --- a/tests/component_tests/button/test_button.yaml +++ b/tests/component_tests/button/test_button.yaml @@ -1,7 +1,8 @@ --- esphome: name: test - platform: ESP8266 + +esp8266: board: d1_mini_lite wifi: diff --git a/tests/component_tests/deep_sleep/test_deep_sleep1.yaml b/tests/component_tests/deep_sleep/test_deep_sleep1.yaml index 96514a677f..03145290a9 100644 --- a/tests/component_tests/deep_sleep/test_deep_sleep1.yaml +++ b/tests/component_tests/deep_sleep/test_deep_sleep1.yaml @@ -1,7 +1,8 @@ --- esphome: name: test - platform: ESP32 + +esp32: board: nodemcu-32s deep_sleep: diff --git a/tests/component_tests/deep_sleep/test_deep_sleep2.yaml b/tests/component_tests/deep_sleep/test_deep_sleep2.yaml index 0e8e598402..88ebb31728 100644 --- a/tests/component_tests/deep_sleep/test_deep_sleep2.yaml +++ b/tests/component_tests/deep_sleep/test_deep_sleep2.yaml @@ -1,7 +1,8 @@ --- esphome: name: test - platform: ESP32 + +esp32: board: nodemcu-32s deep_sleep: diff --git a/tests/component_tests/sensor/test_sensor.yaml b/tests/component_tests/sensor/test_sensor.yaml index 8c0fd85b17..612b8e5e56 100644 --- a/tests/component_tests/sensor/test_sensor.yaml +++ b/tests/component_tests/sensor/test_sensor.yaml @@ -1,7 +1,8 @@ --- esphome: name: test - platform: ESP8266 + +esp8266: board: d1_mini_lite sensor: diff --git a/tests/component_tests/text_sensor/test_text_sensor.yaml b/tests/component_tests/text_sensor/test_text_sensor.yaml index b426cb102c..9cc75082ac 100644 --- a/tests/component_tests/text_sensor/test_text_sensor.yaml +++ b/tests/component_tests/text_sensor/test_text_sensor.yaml @@ -1,7 +1,8 @@ --- esphome: name: test - platform: ESP8266 + +esp8266: board: d1_mini_lite text_sensor: diff --git a/tests/unit_tests/fixtures/yaml_util/broken_includetest.yaml b/tests/unit_tests/fixtures/yaml_util/broken_includetest.yaml index aaca55b807..a49ae706a4 100644 --- a/tests/unit_tests/fixtures/yaml_util/broken_includetest.yaml +++ b/tests/unit_tests/fixtures/yaml_util/broken_includetest.yaml @@ -12,7 +12,7 @@ esphome: # not overwritten by vars in the !include above name: ${name} name_add_mac_suffix: true - platform: esp8266 - board: !include {file: includes/scalar.yaml, vars: {var1: nodemcu}} - libraries: !include {file: includes/list.yaml, vars: {var1: Wire}} + +esp8266: + board: !include {file: includes/scalar.yaml, vars: {var1: nodemcu}} diff --git a/tests/unit_tests/fixtures/yaml_util/includetest.yaml b/tests/unit_tests/fixtures/yaml_util/includetest.yaml index af0a4e2030..7b01da6a17 100644 --- a/tests/unit_tests/fixtures/yaml_util/includetest.yaml +++ b/tests/unit_tests/fixtures/yaml_util/includetest.yaml @@ -12,7 +12,7 @@ esphome: # not overwritten by vars in the !include above name: ${name} name_add_mac_suffix: true - platform: esp8266 - board: !include {file: includes/scalar.yaml, vars: {var1: nodemcu}} - libraries: !include {file: includes/list.yaml, vars: {var1: Wire}} + +esp8266: + board: !include {file: includes/scalar.yaml, vars: {var1: nodemcu}} diff --git a/tests/unit_tests/test_yaml_util.py b/tests/unit_tests/test_yaml_util.py index 9178726247..828b2bf14b 100644 --- a/tests/unit_tests/test_yaml_util.py +++ b/tests/unit_tests/test_yaml_util.py @@ -10,7 +10,7 @@ def test_include_with_vars(fixture_path): substitutions.do_substitution_pass(actual, None) assert actual["esphome"]["name"] == "original" assert actual["esphome"]["libraries"][0] == "Wire" - assert actual["esphome"]["board"] == "nodemcu" + assert actual["esp8266"]["board"] == "nodemcu" assert actual["wifi"]["ssid"] == "my_custom_ssid" From 78ce8f014a8d8cf7b5f7e88101c6c9baa8a2da7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Jan 2025 08:15:56 +1300 Subject: [PATCH 101/194] Bump actions/stale from 9.0.0 to 9.1.0 (#8120) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/stale.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 95f275e5a4..b79939fc8e 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -17,7 +17,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v9.0.0 + - uses: actions/stale@v9.1.0 with: days-before-pr-stale: 90 days-before-pr-close: 7 @@ -37,7 +37,7 @@ jobs: close-issues: runs-on: ubuntu-latest steps: - - uses: actions/stale@v9.0.0 + - uses: actions/stale@v9.1.0 with: days-before-pr-stale: -1 days-before-pr-close: -1 From 4843bbd38a313911e7cb7ae3d87fc5d8a00079b3 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 21 Jan 2025 17:56:51 -0600 Subject: [PATCH 102/194] [custom] Remove platforms (#8119) --- esphome/components/custom/__init__.py | 3 - .../custom/binary_sensor/__init__.py | 30 +--------- .../binary_sensor/custom_binary_sensor.cpp | 16 ----- .../binary_sensor/custom_binary_sensor.h | 26 -------- esphome/components/custom/climate/__init__.py | 29 +-------- .../custom/climate/custom_climate.h | 22 ------- esphome/components/custom/cover/__init__.py | 29 +-------- .../components/custom/cover/custom_cover.h | 21 ------- esphome/components/custom/light/__init__.py | 29 +-------- .../custom/light/custom_light_output.h | 24 -------- esphome/components/custom/output/__init__.py | 60 +------------------ .../components/custom/output/custom_output.h | 37 ------------ esphome/components/custom/sensor/__init__.py | 26 +------- .../custom/sensor/custom_sensor.cpp | 16 ----- .../components/custom/sensor/custom_sensor.h | 24 -------- esphome/components/custom/switch/__init__.py | 26 +------- .../custom/switch/custom_switch.cpp | 16 ----- .../components/custom/switch/custom_switch.h | 24 -------- .../components/custom/text_sensor/__init__.py | 31 +--------- .../custom/text_sensor/custom_text_sensor.cpp | 16 ----- .../custom/text_sensor/custom_text_sensor.h | 26 -------- .../components/custom_component/__init__.py | 30 +--------- .../custom_component/custom_component.h | 28 --------- 23 files changed, 19 insertions(+), 570 deletions(-) delete mode 100644 esphome/components/custom/binary_sensor/custom_binary_sensor.cpp delete mode 100644 esphome/components/custom/binary_sensor/custom_binary_sensor.h delete mode 100644 esphome/components/custom/climate/custom_climate.h delete mode 100644 esphome/components/custom/cover/custom_cover.h delete mode 100644 esphome/components/custom/light/custom_light_output.h delete mode 100644 esphome/components/custom/output/custom_output.h delete mode 100644 esphome/components/custom/sensor/custom_sensor.cpp delete mode 100644 esphome/components/custom/sensor/custom_sensor.h delete mode 100644 esphome/components/custom/switch/custom_switch.cpp delete mode 100644 esphome/components/custom/switch/custom_switch.h delete mode 100644 esphome/components/custom/text_sensor/custom_text_sensor.cpp delete mode 100644 esphome/components/custom/text_sensor/custom_text_sensor.h delete mode 100644 esphome/components/custom_component/custom_component.h diff --git a/esphome/components/custom/__init__.py b/esphome/components/custom/__init__.py index 74450300f3..e69de29bb2 100644 --- a/esphome/components/custom/__init__.py +++ b/esphome/components/custom/__init__.py @@ -1,3 +0,0 @@ -import esphome.codegen as cg - -custom_ns = cg.esphome_ns.namespace("custom") diff --git a/esphome/components/custom/binary_sensor/__init__.py b/esphome/components/custom/binary_sensor/__init__.py index 8d6d621b3a..ca9747ea3e 100644 --- a/esphome/components/custom/binary_sensor/__init__.py +++ b/esphome/components/custom/binary_sensor/__init__.py @@ -1,31 +1,5 @@ -import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import binary_sensor -from esphome.const import CONF_BINARY_SENSORS, CONF_ID, CONF_LAMBDA -from .. import custom_ns -CustomBinarySensorConstructor = custom_ns.class_("CustomBinarySensorConstructor") - -CONFIG_SCHEMA = cv.Schema( - { - cv.GenerateID(): cv.declare_id(CustomBinarySensorConstructor), - cv.Required(CONF_LAMBDA): cv.returning_lambda, - cv.Required(CONF_BINARY_SENSORS): cv.ensure_list( - binary_sensor.binary_sensor_schema() - ), - } +CONFIG_SCHEMA = cv.invalid( + 'The "custom" component has been removed. Consider conversion to an external component.\nhttps://esphome.io/guides/contributing#a-note-about-custom-components' ) - - -async def to_code(config): - template_ = await cg.process_lambda( - config[CONF_LAMBDA], - [], - return_type=cg.std_vector.template(binary_sensor.BinarySensorPtr), - ) - - rhs = CustomBinarySensorConstructor(template_) - custom = cg.variable(config[CONF_ID], rhs) - for i, conf in enumerate(config[CONF_BINARY_SENSORS]): - rhs = custom.Pget_binary_sensor(i) - await binary_sensor.register_binary_sensor(rhs, conf) diff --git a/esphome/components/custom/binary_sensor/custom_binary_sensor.cpp b/esphome/components/custom/binary_sensor/custom_binary_sensor.cpp deleted file mode 100644 index ea83198568..0000000000 --- a/esphome/components/custom/binary_sensor/custom_binary_sensor.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "custom_binary_sensor.h" -#include "esphome/core/log.h" - -namespace esphome { -namespace custom { - -static const char *const TAG = "custom.binary_sensor"; - -void CustomBinarySensorConstructor::dump_config() { - for (auto *child : this->binary_sensors_) { - LOG_BINARY_SENSOR("", "Custom Binary Sensor", child); - } -} - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/binary_sensor/custom_binary_sensor.h b/esphome/components/custom/binary_sensor/custom_binary_sensor.h deleted file mode 100644 index b7d5458d9e..0000000000 --- a/esphome/components/custom/binary_sensor/custom_binary_sensor.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "esphome/core/component.h" -#include "esphome/components/binary_sensor/binary_sensor.h" - -#include - -namespace esphome { -namespace custom { - -class CustomBinarySensorConstructor : public Component { - public: - CustomBinarySensorConstructor(const std::function()> &init) { - this->binary_sensors_ = init(); - } - - binary_sensor::BinarySensor *get_binary_sensor(int i) { return this->binary_sensors_[i]; } - - void dump_config() override; - - protected: - std::vector binary_sensors_; -}; - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/climate/__init__.py b/esphome/components/custom/climate/__init__.py index a95456133a..ca9747ea3e 100644 --- a/esphome/components/custom/climate/__init__.py +++ b/esphome/components/custom/climate/__init__.py @@ -1,30 +1,5 @@ -import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import climate -from esphome.const import CONF_ID, CONF_LAMBDA -from .. import custom_ns -CustomClimateConstructor = custom_ns.class_("CustomClimateConstructor") -CONF_CLIMATES = "climates" - -CONFIG_SCHEMA = cv.Schema( - { - cv.GenerateID(): cv.declare_id(CustomClimateConstructor), - cv.Required(CONF_LAMBDA): cv.returning_lambda, - cv.Required(CONF_CLIMATES): cv.ensure_list(climate.CLIMATE_SCHEMA), - } +CONFIG_SCHEMA = cv.invalid( + 'The "custom" component has been removed. Consider conversion to an external component.\nhttps://esphome.io/guides/contributing#a-note-about-custom-components' ) - - -async def to_code(config): - template_ = await cg.process_lambda( - config[CONF_LAMBDA], - [], - return_type=cg.std_vector.template(climate.Climate.operator("ptr")), - ) - - rhs = CustomClimateConstructor(template_) - custom = cg.variable(config[CONF_ID], rhs) - for i, conf in enumerate(config[CONF_CLIMATES]): - rhs = custom.Pget_climate(i) - await climate.register_climate(rhs, conf) diff --git a/esphome/components/custom/climate/custom_climate.h b/esphome/components/custom/climate/custom_climate.h deleted file mode 100644 index 37876f7115..0000000000 --- a/esphome/components/custom/climate/custom_climate.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include "esphome/core/component.h" -#include "esphome/components/climate/climate.h" - -#include - -namespace esphome { -namespace custom { - -class CustomClimateConstructor { - public: - CustomClimateConstructor(const std::function()> &init) { this->climates_ = init(); } - - climate::Climate *get_climate(int i) { return this->climates_[i]; } - - protected: - std::vector climates_; -}; - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/cover/__init__.py b/esphome/components/custom/cover/__init__.py index 37fd4cdbbc..ca9747ea3e 100644 --- a/esphome/components/custom/cover/__init__.py +++ b/esphome/components/custom/cover/__init__.py @@ -1,30 +1,5 @@ -import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import cover -from esphome.const import CONF_ID, CONF_LAMBDA -from .. import custom_ns -CustomCoverConstructor = custom_ns.class_("CustomCoverConstructor") -CONF_COVERS = "covers" - -CONFIG_SCHEMA = cv.Schema( - { - cv.GenerateID(): cv.declare_id(CustomCoverConstructor), - cv.Required(CONF_LAMBDA): cv.returning_lambda, - cv.Required(CONF_COVERS): cv.ensure_list(cover.COVER_SCHEMA), - } +CONFIG_SCHEMA = cv.invalid( + 'The "custom" component has been removed. Consider conversion to an external component.\nhttps://esphome.io/guides/contributing#a-note-about-custom-components' ) - - -async def to_code(config): - template_ = await cg.process_lambda( - config[CONF_LAMBDA], - [], - return_type=cg.std_vector.template(cover.Cover.operator("ptr")), - ) - - rhs = CustomCoverConstructor(template_) - custom = cg.variable(config[CONF_ID], rhs) - for i, conf in enumerate(config[CONF_COVERS]): - rhs = custom.Pget_cover(i) - await cover.register_cover(rhs, conf) diff --git a/esphome/components/custom/cover/custom_cover.h b/esphome/components/custom/cover/custom_cover.h deleted file mode 100644 index 58330b9d54..0000000000 --- a/esphome/components/custom/cover/custom_cover.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include "esphome/components/cover/cover.h" - -#include - -namespace esphome { -namespace custom { - -class CustomCoverConstructor { - public: - CustomCoverConstructor(const std::function()> &init) { this->covers_ = init(); } - - cover::Cover *get_cover(int i) { return this->covers_[i]; } - - protected: - std::vector covers_; -}; - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/light/__init__.py b/esphome/components/custom/light/__init__.py index b6ebe13ab2..ca9747ea3e 100644 --- a/esphome/components/custom/light/__init__.py +++ b/esphome/components/custom/light/__init__.py @@ -1,30 +1,5 @@ -import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import light -from esphome.const import CONF_ID, CONF_LAMBDA -from .. import custom_ns -CustomLightOutputConstructor = custom_ns.class_("CustomLightOutputConstructor") -CONF_LIGHTS = "lights" - -CONFIG_SCHEMA = cv.Schema( - { - cv.GenerateID(): cv.declare_id(CustomLightOutputConstructor), - cv.Required(CONF_LAMBDA): cv.returning_lambda, - cv.Required(CONF_LIGHTS): cv.ensure_list(light.ADDRESSABLE_LIGHT_SCHEMA), - } +CONFIG_SCHEMA = cv.invalid( + 'The "custom" component has been removed. Consider conversion to an external component.\nhttps://esphome.io/guides/contributing#a-note-about-custom-components' ) - - -async def to_code(config): - template_ = await cg.process_lambda( - config[CONF_LAMBDA], - [], - return_type=cg.std_vector.template(light.LightOutput.operator("ptr")), - ) - - rhs = CustomLightOutputConstructor(template_) - custom = cg.variable(config[CONF_ID], rhs) - for i, conf in enumerate(config[CONF_LIGHTS]): - rhs = custom.Pget_light(i) - await light.register_light(rhs, conf) diff --git a/esphome/components/custom/light/custom_light_output.h b/esphome/components/custom/light/custom_light_output.h deleted file mode 100644 index c2c83ebe97..0000000000 --- a/esphome/components/custom/light/custom_light_output.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "esphome/core/component.h" -#include "esphome/components/light/light_output.h" - -#include - -namespace esphome { -namespace custom { - -class CustomLightOutputConstructor { - public: - CustomLightOutputConstructor(const std::function()> &init) { - this->outputs_ = init(); - } - - light::LightOutput *get_light(int i) { return this->outputs_[i]; } - - protected: - std::vector outputs_; -}; - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/output/__init__.py b/esphome/components/custom/output/__init__.py index 97ef070fc3..ca9747ea3e 100644 --- a/esphome/components/custom/output/__init__.py +++ b/esphome/components/custom/output/__init__.py @@ -1,61 +1,5 @@ -import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import output -from esphome.const import CONF_ID, CONF_LAMBDA, CONF_OUTPUTS, CONF_TYPE, CONF_BINARY -from .. import custom_ns -CustomBinaryOutputConstructor = custom_ns.class_("CustomBinaryOutputConstructor") -CustomFloatOutputConstructor = custom_ns.class_("CustomFloatOutputConstructor") - -CONF_FLOAT = "float" - -CONFIG_SCHEMA = cv.typed_schema( - { - CONF_BINARY: cv.Schema( - { - cv.GenerateID(): cv.declare_id(CustomBinaryOutputConstructor), - cv.Required(CONF_LAMBDA): cv.returning_lambda, - cv.Required(CONF_OUTPUTS): cv.ensure_list( - output.BINARY_OUTPUT_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(output.BinaryOutput), - } - ) - ), - } - ), - CONF_FLOAT: cv.Schema( - { - cv.GenerateID(): cv.declare_id(CustomFloatOutputConstructor), - cv.Required(CONF_LAMBDA): cv.returning_lambda, - cv.Required(CONF_OUTPUTS): cv.ensure_list( - output.FLOAT_OUTPUT_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(output.FloatOutput), - } - ) - ), - } - ), - }, - lower=True, +CONFIG_SCHEMA = cv.invalid( + 'The "custom" component has been removed. Consider conversion to an external component.\nhttps://esphome.io/guides/contributing#a-note-about-custom-components' ) - - -async def to_code(config): - type = config[CONF_TYPE] - if type == "binary": - ret_type = output.BinaryOutputPtr - klass = CustomBinaryOutputConstructor - else: - ret_type = output.FloatOutputPtr - klass = CustomFloatOutputConstructor - template_ = await cg.process_lambda( - config[CONF_LAMBDA], [], return_type=cg.std_vector.template(ret_type) - ) - - rhs = klass(template_) - custom = cg.variable(config[CONF_ID], rhs) - for i, conf in enumerate(config[CONF_OUTPUTS]): - out = cg.Pvariable(conf[CONF_ID], custom.get_output(i)) - await output.register_output(out, conf) diff --git a/esphome/components/custom/output/custom_output.h b/esphome/components/custom/output/custom_output.h deleted file mode 100644 index 4624642420..0000000000 --- a/esphome/components/custom/output/custom_output.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -#include "esphome/core/component.h" -#include "esphome/components/output/binary_output.h" -#include "esphome/components/output/float_output.h" - -#include - -namespace esphome { -namespace custom { - -class CustomBinaryOutputConstructor { - public: - CustomBinaryOutputConstructor(const std::function()> &init) { - this->outputs_ = init(); - } - - output::BinaryOutput *get_output(int i) { return this->outputs_[i]; } - - protected: - std::vector outputs_; -}; - -class CustomFloatOutputConstructor { - public: - CustomFloatOutputConstructor(const std::function()> &init) { - this->outputs_ = init(); - } - - output::FloatOutput *get_output(int i) { return this->outputs_[i]; } - - protected: - std::vector outputs_; -}; - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/sensor/__init__.py b/esphome/components/custom/sensor/__init__.py index be17d9a334..ca9747ea3e 100644 --- a/esphome/components/custom/sensor/__init__.py +++ b/esphome/components/custom/sensor/__init__.py @@ -1,27 +1,5 @@ -import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import sensor -from esphome.const import CONF_ID, CONF_LAMBDA, CONF_SENSORS -from .. import custom_ns -CustomSensorConstructor = custom_ns.class_("CustomSensorConstructor") - -CONFIG_SCHEMA = cv.Schema( - { - cv.GenerateID(): cv.declare_id(CustomSensorConstructor), - cv.Required(CONF_LAMBDA): cv.returning_lambda, - cv.Required(CONF_SENSORS): cv.ensure_list(sensor.sensor_schema()), - } +CONFIG_SCHEMA = cv.invalid( + 'The "custom" component has been removed. Consider conversion to an external component.\nhttps://esphome.io/guides/contributing#a-note-about-custom-components' ) - - -async def to_code(config): - template_ = await cg.process_lambda( - config[CONF_LAMBDA], [], return_type=cg.std_vector.template(sensor.SensorPtr) - ) - - rhs = CustomSensorConstructor(template_) - var = cg.variable(config[CONF_ID], rhs) - for i, conf in enumerate(config[CONF_SENSORS]): - sens = cg.Pvariable(conf[CONF_ID], var.get_sensor(i)) - await sensor.register_sensor(sens, conf) diff --git a/esphome/components/custom/sensor/custom_sensor.cpp b/esphome/components/custom/sensor/custom_sensor.cpp deleted file mode 100644 index e670f09530..0000000000 --- a/esphome/components/custom/sensor/custom_sensor.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "custom_sensor.h" -#include "esphome/core/log.h" - -namespace esphome { -namespace custom { - -static const char *const TAG = "custom.sensor"; - -void CustomSensorConstructor::dump_config() { - for (auto *child : this->sensors_) { - LOG_SENSOR("", "Custom Sensor", child); - } -} - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/sensor/custom_sensor.h b/esphome/components/custom/sensor/custom_sensor.h deleted file mode 100644 index d8f4fbc109..0000000000 --- a/esphome/components/custom/sensor/custom_sensor.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "esphome/core/component.h" -#include "esphome/components/sensor/sensor.h" - -#include - -namespace esphome { -namespace custom { - -class CustomSensorConstructor : public Component { - public: - CustomSensorConstructor(const std::function()> &init) { this->sensors_ = init(); } - - sensor::Sensor *get_sensor(int i) { return this->sensors_[i]; } - - void dump_config() override; - - protected: - std::vector sensors_; -}; - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/switch/__init__.py b/esphome/components/custom/switch/__init__.py index 5538ae6aa0..ca9747ea3e 100644 --- a/esphome/components/custom/switch/__init__.py +++ b/esphome/components/custom/switch/__init__.py @@ -1,27 +1,5 @@ -import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import switch -from esphome.const import CONF_ID, CONF_LAMBDA, CONF_SWITCHES -from .. import custom_ns -CustomSwitchConstructor = custom_ns.class_("CustomSwitchConstructor") - -CONFIG_SCHEMA = cv.Schema( - { - cv.GenerateID(): cv.declare_id(CustomSwitchConstructor), - cv.Required(CONF_LAMBDA): cv.returning_lambda, - cv.Required(CONF_SWITCHES): cv.ensure_list(switch.switch_schema(switch.Switch)), - } +CONFIG_SCHEMA = cv.invalid( + 'The "custom" component has been removed. Consider conversion to an external component.\nhttps://esphome.io/guides/contributing#a-note-about-custom-components' ) - - -async def to_code(config): - template_ = await cg.process_lambda( - config[CONF_LAMBDA], [], return_type=cg.std_vector.template(switch.SwitchPtr) - ) - - rhs = CustomSwitchConstructor(template_) - var = cg.variable(config[CONF_ID], rhs) - for i, conf in enumerate(config[CONF_SWITCHES]): - switch_ = cg.Pvariable(conf[CONF_ID], var.get_switch(i)) - await switch.register_switch(switch_, conf) diff --git a/esphome/components/custom/switch/custom_switch.cpp b/esphome/components/custom/switch/custom_switch.cpp deleted file mode 100644 index 6d0a8fa621..0000000000 --- a/esphome/components/custom/switch/custom_switch.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "custom_switch.h" -#include "esphome/core/log.h" - -namespace esphome { -namespace custom { - -static const char *const TAG = "custom.switch"; - -void CustomSwitchConstructor::dump_config() { - for (auto *child : this->switches_) { - LOG_SWITCH("", "Custom Switch", child); - } -} - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/switch/custom_switch.h b/esphome/components/custom/switch/custom_switch.h deleted file mode 100644 index 9657e4b44d..0000000000 --- a/esphome/components/custom/switch/custom_switch.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include "esphome/core/component.h" -#include "esphome/components/switch/switch.h" - -#include - -namespace esphome { -namespace custom { - -class CustomSwitchConstructor : public Component { - public: - CustomSwitchConstructor(const std::function()> &init) { this->switches_ = init(); } - - switch_::Switch *get_switch(int i) { return this->switches_[i]; } - - void dump_config() override; - - protected: - std::vector switches_; -}; - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/text_sensor/__init__.py b/esphome/components/custom/text_sensor/__init__.py index 70728af604..ca9747ea3e 100644 --- a/esphome/components/custom/text_sensor/__init__.py +++ b/esphome/components/custom/text_sensor/__init__.py @@ -1,32 +1,5 @@ -import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import text_sensor -from esphome.const import CONF_ID, CONF_LAMBDA, CONF_TEXT_SENSORS -from .. import custom_ns -CustomTextSensorConstructor = custom_ns.class_("CustomTextSensorConstructor") - -CONFIG_SCHEMA = cv.Schema( - { - cv.GenerateID(): cv.declare_id(CustomTextSensorConstructor), - cv.Required(CONF_LAMBDA): cv.returning_lambda, - cv.Required(CONF_TEXT_SENSORS): cv.ensure_list( - text_sensor.text_sensor_schema() - ), - } +CONFIG_SCHEMA = cv.invalid( + 'The "custom" component has been removed. Consider conversion to an external component.\nhttps://esphome.io/guides/contributing#a-note-about-custom-components' ) - - -async def to_code(config): - template_ = await cg.process_lambda( - config[CONF_LAMBDA], - [], - return_type=cg.std_vector.template(text_sensor.TextSensorPtr), - ) - - rhs = CustomTextSensorConstructor(template_) - var = cg.variable(config[CONF_ID], rhs) - - for i, conf in enumerate(config[CONF_TEXT_SENSORS]): - text = cg.Pvariable(conf[CONF_ID], var.get_text_sensor(i)) - await text_sensor.register_text_sensor(text, conf) diff --git a/esphome/components/custom/text_sensor/custom_text_sensor.cpp b/esphome/components/custom/text_sensor/custom_text_sensor.cpp deleted file mode 100644 index 618ba832a5..0000000000 --- a/esphome/components/custom/text_sensor/custom_text_sensor.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "custom_text_sensor.h" -#include "esphome/core/log.h" - -namespace esphome { -namespace custom { - -static const char *const TAG = "custom.text_sensor"; - -void CustomTextSensorConstructor::dump_config() { - for (auto *child : this->text_sensors_) { - LOG_TEXT_SENSOR("", "Custom Text Sensor", child); - } -} - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom/text_sensor/custom_text_sensor.h b/esphome/components/custom/text_sensor/custom_text_sensor.h deleted file mode 100644 index 13732c00b6..0000000000 --- a/esphome/components/custom/text_sensor/custom_text_sensor.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "esphome/core/component.h" -#include "esphome/components/text_sensor/text_sensor.h" - -#include - -namespace esphome { -namespace custom { - -class CustomTextSensorConstructor : public Component { - public: - CustomTextSensorConstructor(const std::function()> &init) { - this->text_sensors_ = init(); - } - - text_sensor::TextSensor *get_text_sensor(int i) { return this->text_sensors_[i]; } - - void dump_config() override; - - protected: - std::vector text_sensors_; -}; - -} // namespace custom -} // namespace esphome diff --git a/esphome/components/custom_component/__init__.py b/esphome/components/custom_component/__init__.py index d41dd7ea59..982153414d 100644 --- a/esphome/components/custom_component/__init__.py +++ b/esphome/components/custom_component/__init__.py @@ -1,31 +1,7 @@ -import esphome.codegen as cg import esphome.config_validation as cv -from esphome.const import CONF_COMPONENTS, CONF_ID, CONF_LAMBDA - -custom_component_ns = cg.esphome_ns.namespace("custom_component") -CustomComponentConstructor = custom_component_ns.class_("CustomComponentConstructor") MULTI_CONF = True -CONFIG_SCHEMA = cv.Schema( - { - cv.GenerateID(): cv.declare_id(CustomComponentConstructor), - cv.Required(CONF_LAMBDA): cv.returning_lambda, - cv.Optional(CONF_COMPONENTS): cv.ensure_list( - cv.Schema({cv.GenerateID(): cv.declare_id(cg.Component)}).extend( - cv.COMPONENT_SCHEMA - ) - ), - } + +CONFIG_SCHEMA = cv.invalid( + 'The "custom" component has been removed. Consider conversion to an external component.\nhttps://esphome.io/guides/contributing#a-note-about-custom-components' ) - - -async def to_code(config): - template_ = await cg.process_lambda( - config[CONF_LAMBDA], [], return_type=cg.std_vector.template(cg.ComponentPtr) - ) - - rhs = CustomComponentConstructor(template_) - var = cg.variable(config[CONF_ID], rhs) - for i, conf in enumerate(config.get(CONF_COMPONENTS, [])): - comp = cg.Pvariable(conf[CONF_ID], var.get_component(i)) - await cg.register_component(comp, conf) diff --git a/esphome/components/custom_component/custom_component.h b/esphome/components/custom_component/custom_component.h deleted file mode 100644 index 3b34019a7a..0000000000 --- a/esphome/components/custom_component/custom_component.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "esphome/core/component.h" -#include "esphome/core/application.h" - -#include - -namespace esphome { -namespace custom_component { - -class CustomComponentConstructor { - public: - CustomComponentConstructor(const std::function()> &init) { - this->components_ = init(); - - for (auto *comp : this->components_) { - App.register_component(comp); - } - } - - Component *get_component(int i) const { return this->components_[i]; } - - protected: - std::vector components_; -}; - -} // namespace custom_component -} // namespace esphome From c2e52f4b1177224a80e5585bbdc3151a61ec5a6d Mon Sep 17 00:00:00 2001 From: Citric Li <37475446+limengdu@users.noreply.github.com> Date: Wed, 22 Jan 2025 08:01:15 +0800 Subject: [PATCH 103/194] Add: Human Presence and Target Count to the Seeed Studio MR60BHA2 (#8010) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Spencer Yan --- .../seeed_mr60bha2/binary_sensor.py | 25 ++++++++++++++++ .../seeed_mr60bha2/seeed_mr60bha2.cpp | 28 ++++++++++++++++-- .../seeed_mr60bha2/seeed_mr60bha2.h | 29 ++++++------------- esphome/components/seeed_mr60bha2/sensor.py | 10 ++++++- tests/components/seeed_mr60bha2/common.yaml | 7 +++++ 5 files changed, 76 insertions(+), 23 deletions(-) create mode 100644 esphome/components/seeed_mr60bha2/binary_sensor.py diff --git a/esphome/components/seeed_mr60bha2/binary_sensor.py b/esphome/components/seeed_mr60bha2/binary_sensor.py new file mode 100644 index 0000000000..ae9e1c23e6 --- /dev/null +++ b/esphome/components/seeed_mr60bha2/binary_sensor.py @@ -0,0 +1,25 @@ +import esphome.codegen as cg +from esphome.components import binary_sensor +import esphome.config_validation as cv +from esphome.const import ( + DEVICE_CLASS_OCCUPANCY, + CONF_HAS_TARGET, +) +from . import CONF_MR60BHA2_ID, MR60BHA2Component + +DEPENDENCIES = ["seeed_mr60bha2"] + +CONFIG_SCHEMA = { + cv.GenerateID(CONF_MR60BHA2_ID): cv.use_id(MR60BHA2Component), + cv.Optional(CONF_HAS_TARGET): binary_sensor.binary_sensor_schema( + device_class=DEVICE_CLASS_OCCUPANCY, icon="mdi:motion-sensor" + ), +} + + +async def to_code(config): + mr60bha2_component = await cg.get_variable(config[CONF_MR60BHA2_ID]) + + if has_target_config := config.get(CONF_HAS_TARGET): + sens = await binary_sensor.new_binary_sensor(has_target_config) + cg.add(mr60bha2_component.set_has_target_binary_sensor(sens)) diff --git a/esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp b/esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp index 50d709c3b0..75f3f092a6 100644 --- a/esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp +++ b/esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp @@ -1,6 +1,7 @@ #include "seeed_mr60bha2.h" #include "esphome/core/log.h" +#include #include namespace esphome { @@ -12,10 +13,14 @@ static const char *const TAG = "seeed_mr60bha2"; // items in an easy-to-read format, including the configuration key-value pairs. void MR60BHA2Component::dump_config() { ESP_LOGCONFIG(TAG, "MR60BHA2:"); +#ifdef USE_BINARY_SENSOR + LOG_BINARY_SENSOR(" ", "People Exist Binary Sensor", this->has_target_binary_sensor_); +#endif #ifdef USE_SENSOR LOG_SENSOR(" ", "Breath Rate Sensor", this->breath_rate_sensor_); LOG_SENSOR(" ", "Heart Rate Sensor", this->heart_rate_sensor_); LOG_SENSOR(" ", "Distance Sensor", this->distance_sensor_); + LOG_SENSOR(" ", "Target Number Sensor", this->num_targets_sensor_); #endif } @@ -94,7 +99,8 @@ bool MR60BHA2Component::validate_message_() { uint16_t frame_type = encode_uint16(data[5], data[6]); if (frame_type != BREATH_RATE_TYPE_BUFFER && frame_type != HEART_RATE_TYPE_BUFFER && - frame_type != DISTANCE_TYPE_BUFFER) { + frame_type != DISTANCE_TYPE_BUFFER && frame_type != PEOPLE_EXIST_TYPE_BUFFER && + frame_type != PRINT_CLOUD_BUFFER) { return false; } @@ -144,6 +150,18 @@ void MR60BHA2Component::process_frame_(uint16_t frame_id, uint16_t frame_type, c } } break; + case PEOPLE_EXIST_TYPE_BUFFER: + if (this->has_target_binary_sensor_ != nullptr && length >= 2) { + uint16_t has_target_int = encode_uint16(data[1], data[0]); + this->has_target_binary_sensor_->publish_state(has_target_int); + if (has_target_int == 0) { + this->breath_rate_sensor_->publish_state(0.0); + this->heart_rate_sensor_->publish_state(0.0); + this->distance_sensor_->publish_state(0.0); + this->num_targets_sensor_->publish_state(0); + } + } + break; case HEART_RATE_TYPE_BUFFER: if (this->heart_rate_sensor_ != nullptr && length >= 4) { uint32_t current_heart_rate_int = encode_uint32(data[3], data[2], data[1], data[0]); @@ -155,7 +173,7 @@ void MR60BHA2Component::process_frame_(uint16_t frame_id, uint16_t frame_type, c } break; case DISTANCE_TYPE_BUFFER: - if (!data[0]) { + if (data[0] != 0) { if (this->distance_sensor_ != nullptr && length >= 8) { uint32_t current_distance_int = encode_uint32(data[7], data[6], data[5], data[4]); float distance_float; @@ -164,6 +182,12 @@ void MR60BHA2Component::process_frame_(uint16_t frame_id, uint16_t frame_type, c } } break; + case PRINT_CLOUD_BUFFER: + if (this->num_targets_sensor_ != nullptr && length >= 4) { + uint32_t current_num_targets_int = encode_uint32(data[3], data[2], data[1], data[0]); + this->num_targets_sensor_->publish_state(current_num_targets_int); + } + break; default: break; } diff --git a/esphome/components/seeed_mr60bha2/seeed_mr60bha2.h b/esphome/components/seeed_mr60bha2/seeed_mr60bha2.h index 0a4f21f1ad..d20c8e50cc 100644 --- a/esphome/components/seeed_mr60bha2/seeed_mr60bha2.h +++ b/esphome/components/seeed_mr60bha2/seeed_mr60bha2.h @@ -1,6 +1,9 @@ #pragma once #include "esphome/core/component.h" #include "esphome/core/defines.h" +#ifdef USE_BINARY_SENSOR +#include "esphome/components/binary_sensor/binary_sensor.h" +#endif #ifdef USE_SENSOR #include "esphome/components/sensor/sensor.h" #endif @@ -12,37 +15,23 @@ namespace esphome { namespace seeed_mr60bha2 { - -static const uint8_t DATA_BUF_MAX_SIZE = 12; -static const uint8_t FRAME_BUF_MAX_SIZE = 21; -static const uint8_t LEN_TO_HEAD_CKSUM = 8; -static const uint8_t LEN_TO_DATA_FRAME = 9; - static const uint8_t FRAME_HEADER_BUFFER = 0x01; static const uint16_t BREATH_RATE_TYPE_BUFFER = 0x0A14; +static const uint16_t PEOPLE_EXIST_TYPE_BUFFER = 0x0F09; static const uint16_t HEART_RATE_TYPE_BUFFER = 0x0A15; static const uint16_t DISTANCE_TYPE_BUFFER = 0x0A16; - -enum FrameLocation { - LOCATE_FRAME_HEADER, - LOCATE_ID_FRAME1, - LOCATE_ID_FRAME2, - LOCATE_LENGTH_FRAME_H, - LOCATE_LENGTH_FRAME_L, - LOCATE_TYPE_FRAME1, - LOCATE_TYPE_FRAME2, - LOCATE_HEAD_CKSUM_FRAME, // Header checksum: [from the first byte to the previous byte of the HEAD_CKSUM bit] - LOCATE_DATA_FRAME, - LOCATE_DATA_CKSUM_FRAME, // Data checksum: [from the first to the previous byte of the DATA_CKSUM bit] - LOCATE_PROCESS_FRAME, -}; +static const uint16_t PRINT_CLOUD_BUFFER = 0x0A04; class MR60BHA2Component : public Component, public uart::UARTDevice { // The class name must be the name defined by text_sensor.py +#ifdef USE_BINARY_SENSOR + SUB_BINARY_SENSOR(has_target); +#endif #ifdef USE_SENSOR SUB_SENSOR(breath_rate); SUB_SENSOR(heart_rate); SUB_SENSOR(distance); + SUB_SENSOR(num_targets); #endif public: diff --git a/esphome/components/seeed_mr60bha2/sensor.py b/esphome/components/seeed_mr60bha2/sensor.py index 5f30b363bf..916d4b4ba2 100644 --- a/esphome/components/seeed_mr60bha2/sensor.py +++ b/esphome/components/seeed_mr60bha2/sensor.py @@ -7,6 +7,7 @@ from esphome.const import ( ICON_HEART_PULSE, ICON_PULSE, ICON_SIGNAL, + ICON_COUNTER, STATE_CLASS_MEASUREMENT, UNIT_BEATS_PER_MINUTE, UNIT_CENTIMETER, @@ -18,12 +19,13 @@ DEPENDENCIES = ["seeed_mr60bha2"] CONF_BREATH_RATE = "breath_rate" CONF_HEART_RATE = "heart_rate" +CONF_NUM_TARGETS = "num_targets" CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(CONF_MR60BHA2_ID): cv.use_id(MR60BHA2Component), cv.Optional(CONF_BREATH_RATE): sensor.sensor_schema( - accuracy_decimals=2, + accuracy_decimals=0, state_class=STATE_CLASS_MEASUREMENT, icon=ICON_PULSE, ), @@ -40,6 +42,9 @@ CONFIG_SCHEMA = cv.Schema( accuracy_decimals=2, icon=ICON_SIGNAL, ), + cv.Optional(CONF_NUM_TARGETS): sensor.sensor_schema( + icon=ICON_COUNTER, + ), } ) @@ -55,3 +60,6 @@ async def to_code(config): if distance_config := config.get(CONF_DISTANCE): sens = await sensor.new_sensor(distance_config) cg.add(mr60bha2_component.set_distance_sensor(sens)) + if num_targets_config := config.get(CONF_NUM_TARGETS): + sens = await sensor.new_sensor(num_targets_config) + cg.add(mr60bha2_component.set_num_targets_sensor(sens)) diff --git a/tests/components/seeed_mr60bha2/common.yaml b/tests/components/seeed_mr60bha2/common.yaml index e9d0c735af..9eb0c8d527 100644 --- a/tests/components/seeed_mr60bha2/common.yaml +++ b/tests/components/seeed_mr60bha2/common.yaml @@ -9,6 +9,11 @@ uart: seeed_mr60bha2: id: my_seeed_mr60bha2 +binary_sensor: + - platform: seeed_mr60bha2 + has_target: + name: "Person Information" + sensor: - platform: seeed_mr60bha2 breath_rate: @@ -17,3 +22,5 @@ sensor: name: "Real-time heart rate" distance: name: "Distance to detection object" + num_targets: + name: "Target Number" From f2170c633a3ffe54960f84803e838f31944428b7 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Wed, 22 Jan 2025 14:23:22 -0600 Subject: [PATCH 104/194] [es7243e] Add support for ES7243E audio ADC (#8098) --- CODEOWNERS | 1 + esphome/components/es7243e/__init__.py | 0 esphome/components/es7243e/audio_adc.py | 34 +++++ esphome/components/es7243e/es7243e.cpp | 125 ++++++++++++++++++ esphome/components/es7243e/es7243e.h | 37 ++++++ esphome/components/es7243e/es7243e_const.h | 54 ++++++++ tests/components/es7243e/common.yaml | 14 ++ tests/components/es7243e/test.esp32-ard.yaml | 5 + .../components/es7243e/test.esp32-c3-ard.yaml | 5 + .../components/es7243e/test.esp32-c3-idf.yaml | 5 + tests/components/es7243e/test.esp32-idf.yaml | 5 + 11 files changed, 285 insertions(+) create mode 100644 esphome/components/es7243e/__init__.py create mode 100644 esphome/components/es7243e/audio_adc.py create mode 100644 esphome/components/es7243e/es7243e.cpp create mode 100644 esphome/components/es7243e/es7243e.h create mode 100644 esphome/components/es7243e/es7243e_const.h create mode 100644 tests/components/es7243e/common.yaml create mode 100644 tests/components/es7243e/test.esp32-ard.yaml create mode 100644 tests/components/es7243e/test.esp32-c3-ard.yaml create mode 100644 tests/components/es7243e/test.esp32-c3-idf.yaml create mode 100644 tests/components/es7243e/test.esp32-idf.yaml diff --git a/CODEOWNERS b/CODEOWNERS index e2c674cfd3..aa24b6cb82 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -133,6 +133,7 @@ esphome/components/ens160_i2c/* @latonita esphome/components/ens160_spi/* @latonita esphome/components/ens210/* @itn3rd77 esphome/components/es7210/* @kahrendt +esphome/components/es7243e/* @kbx81 esphome/components/es8156/* @kbx81 esphome/components/es8311/* @kahrendt @kroimon esphome/components/esp32/* @esphome/core diff --git a/esphome/components/es7243e/__init__.py b/esphome/components/es7243e/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/esphome/components/es7243e/audio_adc.py b/esphome/components/es7243e/audio_adc.py new file mode 100644 index 0000000000..c305d60172 --- /dev/null +++ b/esphome/components/es7243e/audio_adc.py @@ -0,0 +1,34 @@ +import esphome.codegen as cg +from esphome.components import i2c +from esphome.components.audio_adc import AudioAdc +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_MIC_GAIN + +CODEOWNERS = ["@kbx81"] +DEPENDENCIES = ["i2c"] + +es7243e_ns = cg.esphome_ns.namespace("es7243e") +ES7243E = es7243e_ns.class_("ES7243E", AudioAdc, cg.Component, i2c.I2CDevice) + +ES7243E_MIC_GAINS = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 34.5, 36, 37.5] + +CONFIG_SCHEMA = ( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(ES7243E), + cv.Optional(CONF_MIC_GAIN, default="24db"): cv.All( + cv.decibel, cv.one_of(*ES7243E_MIC_GAINS) + ), + } + ) + .extend(cv.COMPONENT_SCHEMA) + .extend(i2c.i2c_device_schema(0x10)) +) + + +async def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) + + cg.add(var.set_mic_gain(config[CONF_MIC_GAIN])) diff --git a/esphome/components/es7243e/es7243e.cpp b/esphome/components/es7243e/es7243e.cpp new file mode 100644 index 0000000000..ce65ce973e --- /dev/null +++ b/esphome/components/es7243e/es7243e.cpp @@ -0,0 +1,125 @@ +#include "es7243e.h" +#include "es7243e_const.h" + +#include "esphome/core/hal.h" +#include "esphome/core/log.h" + +#include + +namespace esphome { +namespace es7243e { + +static const char *const TAG = "es7243e"; + +// Mark the component as failed; use only in setup +#define ES7243E_ERROR_FAILED(func) \ + if (!(func)) { \ + this->mark_failed(); \ + return; \ + } + +// Return false; use outside of setup +#define ES7243E_ERROR_CHECK(func) \ + if (!(func)) { \ + return false; \ + } + +void ES7243E::dump_config() { + ESP_LOGCONFIG(TAG, "ES7243E audio ADC:"); + + if (this->is_failed()) { + ESP_LOGE(TAG, " Failed to initialize"); + return; + } +} + +void ES7243E::setup() { + ESP_LOGCONFIG(TAG, "Setting up ES7243E..."); + + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG01, 0x3A)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_RESET_REG00, 0x80)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_TEST_MODE_REGF9, 0x00)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG04, 0x02)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG04, 0x01)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_TEST_MODE_REGF9, 0x01)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_RESET_REG00, 0x1E)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG01, 0x00)); + + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG02, 0x00)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG03, 0x20)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG04, 0x01)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ADC_CTRL_REG0D, 0x00)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG05, 0x00)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG06, 0x03)); // SCLK=MCLK/4 + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG07, 0x00)); // LRCK=MCLK/256 + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG08, 0xFF)); // LRCK=MCLK/256 + + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG09, 0xCA)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_SDP_REG0A, 0x85)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_SDP_REG0B, 0x00)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ADC_CTRL_REG0E, 0xBF)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ADC_CTRL_REG0F, 0x80)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ADC_CTRL_REG14, 0x0C)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ADC_CTRL_REG15, 0x0C)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG17, 0x02)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG18, 0x26)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG19, 0x77)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG1A, 0xF4)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG1B, 0x66)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG1C, 0x44)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG1E, 0x00)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG1F, 0x0C)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG20, 0x1A)); // PGA gain +30dB + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG21, 0x1A)); + + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_RESET_REG00, 0x80)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG01, 0x3A)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG16, 0x3F)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG16, 0x00)); + + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_TEST_MODE_REGF9, 0x00)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG04, 0x01)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG17, 0x01)); + ES7243E_ERROR_FAILED(this->configure_mic_gain_()); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_RESET_REG00, 0x80)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_CLOCK_MGR_REG01, 0x3A)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG16, 0x3F)); + ES7243E_ERROR_FAILED(this->write_byte(ES7243E_ANALOG_REG16, 0x00)); + + this->setup_complete_ = true; +} + +bool ES7243E::set_mic_gain(float mic_gain) { + this->mic_gain_ = clamp(mic_gain, 0, 37.5); + if (this->setup_complete_) { + return this->configure_mic_gain_(); + } + return true; +} + +bool ES7243E::configure_mic_gain_() { + auto regv = this->es7243e_gain_reg_value_(this->mic_gain_); + + ES7243E_ERROR_CHECK(this->write_byte(ES7243E_ANALOG_REG20, 0x10 | regv)); + ES7243E_ERROR_CHECK(this->write_byte(ES7243E_ANALOG_REG21, 0x10 | regv)); + + return true; +} + +uint8_t ES7243E::es7243e_gain_reg_value_(float mic_gain) { + // reg: 12 - 34.5dB, 13 - 36dB, 14 - 37.5dB + mic_gain += 0.5; + if (mic_gain <= 33.0) { + return (uint8_t) mic_gain / 3; + } + if (mic_gain < 36.0) { + return 12; + } + if (mic_gain < 37.0) { + return 13; + } + return 14; +} + +} // namespace es7243e +} // namespace esphome diff --git a/esphome/components/es7243e/es7243e.h b/esphome/components/es7243e/es7243e.h new file mode 100644 index 0000000000..41a8acac8d --- /dev/null +++ b/esphome/components/es7243e/es7243e.h @@ -0,0 +1,37 @@ +#pragma once + +#include "esphome/components/audio_adc/audio_adc.h" +#include "esphome/components/i2c/i2c.h" +#include "esphome/core/component.h" + +namespace esphome { +namespace es7243e { + +class ES7243E : public audio_adc::AudioAdc, public Component, public i2c::I2CDevice { + /* Class for configuring an ES7243E ADC for microphone input. + * Based on code from: + * - https://github.com/espressif/esp-adf/ (accessed 20250116) + */ + public: + void setup() override; + float get_setup_priority() const override { return setup_priority::DATA; } + void dump_config() override; + + bool set_mic_gain(float mic_gain) override; + + float mic_gain() override { return this->mic_gain_; }; + + protected: + /// @brief Convert floating point mic gain value to register value + /// @param mic_gain Gain value to convert + /// @return Corresponding register value for specified gain + uint8_t es7243e_gain_reg_value_(float mic_gain); + + bool configure_mic_gain_(); + + bool setup_complete_{false}; + float mic_gain_{0}; +}; + +} // namespace es7243e +} // namespace esphome diff --git a/esphome/components/es7243e/es7243e_const.h b/esphome/components/es7243e/es7243e_const.h new file mode 100644 index 0000000000..daae53a108 --- /dev/null +++ b/esphome/components/es7243e/es7243e_const.h @@ -0,0 +1,54 @@ +#pragma once + +#include + +namespace esphome { +namespace es7243e { + +// ES7243E register addresses +static const uint8_t ES7243E_RESET_REG00 = 0x00; // Reset control +static const uint8_t ES7243E_CLOCK_MGR_REG01 = 0x01; // MCLK/BCLK/ADCCLK/Analog clocks on/off +static const uint8_t ES7243E_CLOCK_MGR_REG02 = 0x02; // MCLK & BCLK configuration, source selection + +static const uint8_t ES7243E_CLOCK_MGR_REG03 = 0x03; // ADC Over-sample rate control +static const uint8_t ES7243E_CLOCK_MGR_REG04 = 0x04; // Pre-divide/Pre-multiplication +static const uint8_t ES7243E_CLOCK_MGR_REG05 = 0x05; // CF/DSP clock divider +static const uint8_t ES7243E_CLOCK_MGR_REG06 = 0x06; // BCLK divider at master mode +static const uint8_t ES7243E_CLOCK_MGR_REG07 = 0x07; // BCLK/LRCK/SDOUT tri-state control/LRCK divider bit 11->8 +static const uint8_t ES7243E_CLOCK_MGR_REG08 = 0x08; // Master LRCK divider bit 7 to bit 0 +static const uint8_t ES7243E_CLOCK_MGR_REG09 = 0x09; // SEL S1/Timer for S1 +static const uint8_t ES7243E_SDP_REG0A = 0x0A; // SEL S3/Timer for S3 +static const uint8_t ES7243E_SDP_REG0B = 0x0B; // SDP out mute control/I2S/left-justify case/word length/format +static const uint8_t ES7243E_SDP_REG0C = 0x0C; // NFS flag at slot0/LSB/TDM mode selection +static const uint8_t ES7243E_ADC_CTRL_REG0D = 0x0D; // data mux/pol. inv./ram clear on lrck/mclk active/gain scale up +static const uint8_t ES7243E_ADC_CTRL_REG0E = 0x0E; // volume control +static const uint8_t ES7243E_ADC_CTRL_REG0F = 0x0F; // offset freeze/auto level control/automute control/VC ramp rate +static const uint8_t ES7243E_ADC_CTRL_REG10 = 0x10; // automute noise gate/detection +static const uint8_t ES7243E_ADC_CTRL_REG11 = 0x11; // automute SDP control/out gain select +static const uint8_t ES7243E_ADC_CTRL_REG12 = 0x12; // controls for automute PDN_PGA/MOD/reset/digital circuit +static const uint8_t ES7243E_ADC_CTRL_REG13 = 0x13; // ALC rate selection/ALC target level +static const uint8_t ES7243E_ADC_CTRL_REG14 = 0x14; // ADCHPF stage1 coeff +static const uint8_t ES7243E_ADC_CTRL_REG15 = 0x15; // ADCHPF stage2 coeff +static const uint8_t ES7243E_ANALOG_REG16 = 0x16; // power-down/reset +static const uint8_t ES7243E_ANALOG_REG17 = 0x17; // VMIDSEL +static const uint8_t ES7243E_ANALOG_REG18 = 0x18; // ADC/ADCFL bias +static const uint8_t ES7243E_ANALOG_REG19 = 0x19; // PGA1/PGA2 bias +static const uint8_t ES7243E_ANALOG_REG1A = 0x1A; // ADCI1/ADCI23 bias +static const uint8_t ES7243E_ANALOG_REG1B = 0x1B; // ADCSM/ADCCM bias +static const uint8_t ES7243E_ANALOG_REG1C = 0x1C; // ADCVRP/ADCCPP bias +static const uint8_t ES7243E_ANALOG_REG1D = 0x1D; // low power bits +static const uint8_t ES7243E_ANALOG_REG1E = 0x1E; // low power bits +static const uint8_t ES7243E_ANALOG_REG1F = 0x1F; // ADC_DMIC_ON/REFSEL/VX2OFF/VX1SEL/VMIDLVL +static const uint8_t ES7243E_ANALOG_REG20 = 0x20; // select MIC1 as PGA1 input/PGA1 gain +static const uint8_t ES7243E_ANALOG_REG21 = 0x21; // select MIC2 as PGA1 input/PGA2 gain +static const uint8_t ES7243E_TEST_MODE_REGF7 = 0xF7; +static const uint8_t ES7243E_TEST_MODE_REGF8 = 0xF8; +static const uint8_t ES7243E_TEST_MODE_REGF9 = 0xF9; +static const uint8_t ES7243E_I2C_CONF_REGFA = 0xFA; // I2C signals retime/reset registers to default +static const uint8_t ES7243E_FLAG_REGFC = 0xFC; // CSM flag/ADC automute flag (RO) +static const uint8_t ES7243E_CHIP_ID1_REGFD = 0xFD; // chip ID 1, reads 0x7A (RO) +static const uint8_t ES7243E_CHIP_ID2_REGFE = 0xFE; // chip ID 2, reads 0x43 (RO) +static const uint8_t ES7243E_CHIP_VERSION_REGFF = 0xFF; // chip version, reads 0x00 (RO) + +} // namespace es7243e +} // namespace esphome diff --git a/tests/components/es7243e/common.yaml b/tests/components/es7243e/common.yaml new file mode 100644 index 0000000000..3de76909e9 --- /dev/null +++ b/tests/components/es7243e/common.yaml @@ -0,0 +1,14 @@ +esphome: + on_boot: + then: + - audio_adc.set_mic_gain: 0db + - audio_adc.set_mic_gain: !lambda 'return 4;' + +i2c: + - id: i2c_es7243e + scl: ${scl_pin} + sda: ${sda_pin} + +audio_adc: + - platform: es7243e + id: es7243e_adc diff --git a/tests/components/es7243e/test.esp32-ard.yaml b/tests/components/es7243e/test.esp32-ard.yaml new file mode 100644 index 0000000000..63c3bd6afd --- /dev/null +++ b/tests/components/es7243e/test.esp32-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/es7243e/test.esp32-c3-ard.yaml b/tests/components/es7243e/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/es7243e/test.esp32-c3-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/es7243e/test.esp32-c3-idf.yaml b/tests/components/es7243e/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/es7243e/test.esp32-c3-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/es7243e/test.esp32-idf.yaml b/tests/components/es7243e/test.esp32-idf.yaml new file mode 100644 index 0000000000..63c3bd6afd --- /dev/null +++ b/tests/components/es7243e/test.esp32-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + +<<: !include common.yaml From 01ab6d3ddca81633d39c3279d5feb89eae3bec22 Mon Sep 17 00:00:00 2001 From: Frederik <5511687+fightforlife@users.noreply.github.com> Date: Wed, 22 Jan 2025 23:37:32 +0100 Subject: [PATCH 105/194] [debug] fix debug_esp32 printf for partition size and address (#8122) Co-authored-by: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> --- esphome/components/debug/debug_esp32.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/debug/debug_esp32.cpp b/esphome/components/debug/debug_esp32.cpp index 69ae7e3678..caa9f8d743 100644 --- a/esphome/components/debug/debug_esp32.cpp +++ b/esphome/components/debug/debug_esp32.cpp @@ -35,8 +35,8 @@ void DebugComponent::log_partition_info_() { esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL); while (it != NULL) { const esp_partition_t *partition = esp_partition_get(it); - ESP_LOGCONFIG(TAG, " %-12s %-4d %-8d 0x%08X 0x%08X", partition->label, partition->type, partition->subtype, - partition->address, partition->size); + ESP_LOGCONFIG(TAG, " %-12s %-4d %-8d 0x%08" PRIX32 " 0x%08" PRIX32, partition->label, partition->type, + partition->subtype, partition->address, partition->size); it = esp_partition_next(it); } esp_partition_iterator_release(it); From 5a103543c43385d240c5f80cae749e47d55f4269 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Wed, 22 Jan 2025 17:00:40 -0600 Subject: [PATCH 106/194] [esp32] Set logger default interface for C6 (#8126) --- esphome/components/logger/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/components/logger/__init__.py b/esphome/components/logger/__init__.py index f30bc23e38..6e92777058 100644 --- a/esphome/components/logger/__init__.py +++ b/esphome/components/logger/__init__.py @@ -186,6 +186,8 @@ CONFIG_SCHEMA = cv.All( esp32_s3_idf=USB_SERIAL_JTAG, esp32_c3_arduino=USB_CDC, esp32_c3_idf=USB_SERIAL_JTAG, + esp32_c6_arduino=USB_CDC, + esp32_c6_idf=USB_SERIAL_JTAG, rp2040=USB_CDC, bk72xx=DEFAULT, rtl87xx=DEFAULT, From 0c032bc431fb76ab5bc239e64733390c4bdfeef4 Mon Sep 17 00:00:00 2001 From: tomaszduda23 Date: Thu, 23 Jan 2025 00:06:07 +0100 Subject: [PATCH 107/194] [core] add support for custom platform (#7616) Co-authored-by: Tomasz Duda --- esphome/components/bk72xx/__init__.py | 1 + esphome/components/esp32/__init__.py | 1 + esphome/components/esp8266/__init__.py | 1 + esphome/components/host/__init__.py | 1 + esphome/components/libretiny/__init__.py | 1 + esphome/components/rp2040/__init__.py | 1 + esphome/components/rtl87xx/__init__.py | 2 ++ esphome/config.py | 9 +++--- esphome/const.py | 9 ------ esphome/core/config.py | 37 +++++++++++++++++++++--- esphome/loader.py | 16 +++++++--- 11 files changed, 57 insertions(+), 22 deletions(-) diff --git a/esphome/components/bk72xx/__init__.py b/esphome/components/bk72xx/__init__.py index b5122de956..5b14d0529d 100644 --- a/esphome/components/bk72xx/__init__.py +++ b/esphome/components/bk72xx/__init__.py @@ -19,6 +19,7 @@ from .boards import BK72XX_BOARD_PINS, BK72XX_BOARDS CODEOWNERS = ["@kuba2k2"] AUTO_LOAD = ["libretiny"] +IS_TARGET_PLATFORM = True COMPONENT_DATA = LibreTinyComponent( name=COMPONENT_BK72XX, diff --git a/esphome/components/esp32/__init__.py b/esphome/components/esp32/__init__.py index 98db45831a..23b84f3d13 100644 --- a/esphome/components/esp32/__init__.py +++ b/esphome/components/esp32/__init__.py @@ -64,6 +64,7 @@ from .gpio import esp32_pin_to_code # noqa _LOGGER = logging.getLogger(__name__) CODEOWNERS = ["@esphome/core"] AUTO_LOAD = ["preferences"] +IS_TARGET_PLATFORM = True CONF_RELEASE = "release" diff --git a/esphome/components/esp8266/__init__.py b/esphome/components/esp8266/__init__.py index c73027fe1b..c949e53aa6 100644 --- a/esphome/components/esp8266/__init__.py +++ b/esphome/components/esp8266/__init__.py @@ -34,6 +34,7 @@ from .gpio import PinInitialState, add_pin_initial_states_array CODEOWNERS = ["@esphome/core"] _LOGGER = logging.getLogger(__name__) AUTO_LOAD = ["preferences"] +IS_TARGET_PLATFORM = True def set_core_data(config): diff --git a/esphome/components/host/__init__.py b/esphome/components/host/__init__.py index eb8cfbd984..e275adafa9 100644 --- a/esphome/components/host/__init__.py +++ b/esphome/components/host/__init__.py @@ -17,6 +17,7 @@ from .gpio import host_pin_to_code # noqa CODEOWNERS = ["@esphome/core", "@clydebarrow"] AUTO_LOAD = ["network", "preferences"] +IS_TARGET_PLATFORM = True def set_core_data(config): diff --git a/esphome/components/libretiny/__init__.py b/esphome/components/libretiny/__init__.py index b29d2e309c..5bdfb15e19 100644 --- a/esphome/components/libretiny/__init__.py +++ b/esphome/components/libretiny/__init__.py @@ -47,6 +47,7 @@ from .const import ( _LOGGER = logging.getLogger(__name__) CODEOWNERS = ["@kuba2k2"] AUTO_LOAD = ["preferences"] +IS_TARGET_PLATFORM = True def _detect_variant(value): diff --git a/esphome/components/rp2040/__init__.py b/esphome/components/rp2040/__init__.py index b04e539182..3d73cad195 100644 --- a/esphome/components/rp2040/__init__.py +++ b/esphome/components/rp2040/__init__.py @@ -27,6 +27,7 @@ from .gpio import rp2040_pin_to_code # noqa _LOGGER = logging.getLogger(__name__) CODEOWNERS = ["@jesserockz"] AUTO_LOAD = ["preferences"] +IS_TARGET_PLATFORM = True def set_core_data(config): diff --git a/esphome/components/rtl87xx/__init__.py b/esphome/components/rtl87xx/__init__.py index 4c1956f0f4..109c986f75 100644 --- a/esphome/components/rtl87xx/__init__.py +++ b/esphome/components/rtl87xx/__init__.py @@ -19,6 +19,8 @@ from .boards import RTL87XX_BOARD_PINS, RTL87XX_BOARDS CODEOWNERS = ["@kuba2k2"] AUTO_LOAD = ["libretiny"] +IS_TARGET_PLATFORM = True + COMPONENT_DATA = LibreTinyComponent( name=COMPONENT_RTL87XX, diff --git a/esphome/config.py b/esphome/config.py index 65e9ac29bc..09ee2a8f9b 100644 --- a/esphome/config.py +++ b/esphome/config.py @@ -22,7 +22,6 @@ from esphome.const import ( CONF_PACKAGES, CONF_PLATFORM, CONF_SUBSTITUTIONS, - TARGET_PLATFORMS, ) from esphome.core import CORE, DocumentRange, EsphomeError import esphome.core.config as core_config @@ -833,7 +832,7 @@ def validate_config( result[CONF_ESPHOME] = config[CONF_ESPHOME] result.add_output_path([CONF_ESPHOME], CONF_ESPHOME) try: - core_config.preload_core_config(config, result) + target_platform = core_config.preload_core_config(config, result) except vol.Invalid as err: result.add_error(err) return result @@ -845,9 +844,9 @@ def validate_config( cv.All(cv.version_number, cv.validate_esphome_version)(min_version) # First run platform validation steps - for key in TARGET_PLATFORMS: - if key in config: - result.add_validation_step(LoadValidationStep(key, config[key])) + result.add_validation_step( + LoadValidationStep(target_platform, config[target_platform]) + ) result.run_validation_steps() if result.errors: diff --git a/esphome/const.py b/esphome/const.py index 284f8d5f78..95bf6afc02 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -15,15 +15,6 @@ PLATFORM_LIBRETINY_OLDSTYLE = "libretiny" PLATFORM_RP2040 = "rp2040" PLATFORM_RTL87XX = "rtl87xx" -TARGET_PLATFORMS = [ - PLATFORM_BK72XX, - PLATFORM_ESP32, - PLATFORM_ESP8266, - PLATFORM_HOST, - PLATFORM_LIBRETINY_OLDSTYLE, - PLATFORM_RP2040, - PLATFORM_RTL87XX, -] SOURCE_FILE_EXTENSIONS = {".cpp", ".hpp", ".h", ".c", ".tcc", ".ino"} HEADER_FILE_EXTENSIONS = {".h", ".hpp", ".tcc"} diff --git a/esphome/core/config.py b/esphome/core/config.py index c6a3b1b294..06ae1d7747 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -1,6 +1,7 @@ import logging import multiprocessing import os +from pathlib import Path from esphome import automation import esphome.codegen as cg @@ -28,7 +29,6 @@ from esphome.const import ( CONF_TRIGGER_ID, CONF_VERSION, KEY_CORE, - TARGET_PLATFORMS, __version__ as ESPHOME_VERSION, ) from esphome.core import CORE, coroutine_with_priority @@ -174,7 +174,31 @@ PRELOAD_CONFIG_SCHEMA = cv.Schema( ) -def preload_core_config(config, result): +def _is_target_platform(name): + from esphome.loader import get_component + + try: + if get_component(name, True).is_target_platform: + return True + except KeyError: + pass + return False + + +def _list_target_platforms(): + target_platforms = [] + root = Path(__file__).parents[1] + for path in (root / "components").iterdir(): + if not path.is_dir(): + continue + if not (path / "__init__.py").is_file(): + continue + if _is_target_platform(path.name): + target_platforms += [path.name] + return target_platforms + + +def preload_core_config(config, result) -> str: with cv.prepend_path(CONF_ESPHOME): conf = PRELOAD_CONFIG_SCHEMA(config[CONF_ESPHOME]) @@ -187,12 +211,16 @@ def preload_core_config(config, result): conf[CONF_BUILD_PATH] = os.path.join(build_path, CORE.name) CORE.build_path = CORE.relative_internal_path(conf[CONF_BUILD_PATH]) - target_platforms = [key for key in TARGET_PLATFORMS if key in config] + target_platforms = [] + + for domain, _ in config.items(): + if _is_target_platform(domain): + target_platforms += [domain] if not target_platforms: raise cv.Invalid( "Platform missing. You must include one of the available platform keys: " - + ", ".join(TARGET_PLATFORMS), + + ", ".join(_list_target_platforms()), [CONF_ESPHOME], ) if len(target_platforms) > 1: @@ -202,6 +230,7 @@ def preload_core_config(config, result): ) config[CONF_ESPHOME] = conf + return target_platforms[0] def include_file(path, basename): diff --git a/esphome/loader.py b/esphome/loader.py index d808805119..0fb4187b04 100644 --- a/esphome/loader.py +++ b/esphome/loader.py @@ -52,6 +52,10 @@ class ComponentManifest: def is_platform_component(self) -> bool: return getattr(self.module, "IS_PLATFORM_COMPONENT", False) + @property + def is_target_platform(self) -> bool: + return getattr(self.module, "IS_TARGET_PLATFORM", False) + @property def config_schema(self) -> Optional[Any]: return getattr(self.module, "CONFIG_SCHEMA", None) @@ -169,13 +173,15 @@ def install_custom_components_meta_finder(): install_meta_finder(custom_components_dir) -def _lookup_module(domain): +def _lookup_module(domain, exception): if domain in _COMPONENT_CACHE: return _COMPONENT_CACHE[domain] try: module = importlib.import_module(f"esphome.components.{domain}") except ImportError as e: + if exception: + raise if "No module named" in str(e): _LOGGER.info( "Unable to import component %s: %s", domain, str(e), exc_info=False @@ -184,6 +190,8 @@ def _lookup_module(domain): _LOGGER.error("Unable to import component %s:", domain, exc_info=True) return None except Exception: # pylint: disable=broad-except + if exception: + raise _LOGGER.error("Unable to load component %s:", domain, exc_info=True) return None @@ -192,14 +200,14 @@ def _lookup_module(domain): return manif -def get_component(domain): +def get_component(domain, exception=False): assert "." not in domain - return _lookup_module(domain) + return _lookup_module(domain, exception) def get_platform(domain, platform): full = f"{platform}.{domain}" - return _lookup_module(full) + return _lookup_module(full, False) _COMPONENT_CACHE = {} From d4857a17271122d1304b298b8f71dd27b0760f1b Mon Sep 17 00:00:00 2001 From: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> Date: Thu, 23 Jan 2025 00:07:26 +0100 Subject: [PATCH 108/194] Add verbose logging for pulse width calculation in pulse_meter (#8124) --- esphome/components/pulse_meter/pulse_meter_sensor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/components/pulse_meter/pulse_meter_sensor.cpp b/esphome/components/pulse_meter/pulse_meter_sensor.cpp index 530425563c..836a84b391 100644 --- a/esphome/components/pulse_meter/pulse_meter_sensor.cpp +++ b/esphome/components/pulse_meter/pulse_meter_sensor.cpp @@ -75,6 +75,8 @@ void PulseMeterSensor::loop() { case MeterState::RUNNING: { uint32_t delta_us = this->get_->last_detected_edge_us_ - this->last_processed_edge_us_; float pulse_width_us = delta_us / float(this->get_->count_); + ESP_LOGV(TAG, "New pulse, delta: %" PRIu32 " µs, count: %" PRIu32 ", width: %.5f µs", delta_us, + this->get_->count_, pulse_width_us); this->publish_state((60.0f * 1000000.0f) / pulse_width_us); } break; } From 8aeb08f8689a5d746c6ef0d36f4d3f958edd2ac3 Mon Sep 17 00:00:00 2001 From: brambo123 <52667932+brambo123@users.noreply.github.com> Date: Thu, 23 Jan 2025 00:31:07 +0100 Subject: [PATCH 109/194] [ads1115] Add sample rate control (#8102) --- esphome/components/ads1115/ads1115.cpp | 63 ++++++++++++++++--- esphome/components/ads1115/ads1115.h | 14 ++++- esphome/components/ads1115/sensor/__init__.py | 16 +++++ .../ads1115/sensor/ads1115_sensor.cpp | 3 +- .../ads1115/sensor/ads1115_sensor.h | 2 + tests/components/ads1115/test.esp32-ard.yaml | 1 + .../components/ads1115/test.esp32-c3-ard.yaml | 1 + .../components/ads1115/test.esp32-c3-idf.yaml | 1 + tests/components/ads1115/test.esp32-idf.yaml | 1 + .../components/ads1115/test.esp8266-ard.yaml | 1 + tests/components/ads1115/test.rp2040-ard.yaml | 1 + 11 files changed, 95 insertions(+), 9 deletions(-) diff --git a/esphome/components/ads1115/ads1115.cpp b/esphome/components/ads1115/ads1115.cpp index 218edc4c81..c05064383c 100644 --- a/esphome/components/ads1115/ads1115.cpp +++ b/esphome/components/ads1115/ads1115.cpp @@ -9,8 +9,6 @@ static const char *const TAG = "ads1115"; static const uint8_t ADS1115_REGISTER_CONVERSION = 0x00; static const uint8_t ADS1115_REGISTER_CONFIG = 0x01; -static const uint8_t ADS1115_DATA_RATE_860_SPS = 0b111; // 3300_SPS for ADS1015 - void ADS1115Component::setup() { ESP_LOGCONFIG(TAG, "Setting up ADS1115..."); uint16_t value; @@ -43,9 +41,9 @@ void ADS1115Component::setup() { config |= 0b0000000100000000; } - // Set data rate - 860 samples per second (we're in singleshot mode) + // Set data rate - 860 samples per second // 0bxxxxxxxx100xxxxx - config |= ADS1115_DATA_RATE_860_SPS << 5; + config |= ADS1115_860SPS << 5; // Set comparator mode - hysteresis // 0bxxxxxxxxxxx0xxxx @@ -77,7 +75,7 @@ void ADS1115Component::dump_config() { } } float ADS1115Component::request_measurement(ADS1115Multiplexer multiplexer, ADS1115Gain gain, - ADS1115Resolution resolution) { + ADS1115Resolution resolution, ADS1115Samplerate samplerate) { uint16_t config = this->prev_config_; // Multiplexer // 0bxBBBxxxxxxxxxxxx @@ -89,6 +87,11 @@ float ADS1115Component::request_measurement(ADS1115Multiplexer multiplexer, ADS1 config &= 0b1111000111111111; config |= (gain & 0b111) << 9; + // Sample rate + // 0bxxxxxxxxBBBxxxxx + config &= 0b1111111100011111; + config |= (samplerate & 0b111) << 5; + if (!this->continuous_mode_) { // Start conversion config |= 0b1000000000000000; @@ -101,8 +104,54 @@ float ADS1115Component::request_measurement(ADS1115Multiplexer multiplexer, ADS1 } this->prev_config_ = config; - // about 1.2 ms with 860 samples per second - delay(2); + // Delay calculated as: ceil((1000/SPS)+.5) + if (resolution == ADS1015_12_BITS) { + switch (samplerate) { + case ADS1115_8SPS: + delay(9); + break; + case ADS1115_16SPS: + delay(5); + break; + case ADS1115_32SPS: + delay(3); + break; + case ADS1115_64SPS: + case ADS1115_128SPS: + delay(2); + break; + default: + delay(1); + break; + } + } else { + switch (samplerate) { + case ADS1115_8SPS: + delay(126); // NOLINT + break; + case ADS1115_16SPS: + delay(63); // NOLINT + break; + case ADS1115_32SPS: + delay(32); + break; + case ADS1115_64SPS: + delay(17); + break; + case ADS1115_128SPS: + delay(9); + break; + case ADS1115_250SPS: + delay(5); + break; + case ADS1115_475SPS: + delay(3); + break; + case ADS1115_860SPS: + delay(2); + break; + } + } // in continuous mode, conversion will always be running, rely on the delay // to ensure conversion is taking place with the correct settings diff --git a/esphome/components/ads1115/ads1115.h b/esphome/components/ads1115/ads1115.h index 509333d2c8..e65835a386 100644 --- a/esphome/components/ads1115/ads1115.h +++ b/esphome/components/ads1115/ads1115.h @@ -33,6 +33,17 @@ enum ADS1115Resolution { ADS1015_12_BITS = 12, }; +enum ADS1115Samplerate { + ADS1115_8SPS = 0b000, + ADS1115_16SPS = 0b001, + ADS1115_32SPS = 0b010, + ADS1115_64SPS = 0b011, + ADS1115_128SPS = 0b100, + ADS1115_250SPS = 0b101, + ADS1115_475SPS = 0b110, + ADS1115_860SPS = 0b111 +}; + class ADS1115Component : public Component, public i2c::I2CDevice { public: void setup() override; @@ -42,7 +53,8 @@ class ADS1115Component : public Component, public i2c::I2CDevice { void set_continuous_mode(bool continuous_mode) { continuous_mode_ = continuous_mode; } /// Helper method to request a measurement from a sensor. - float request_measurement(ADS1115Multiplexer multiplexer, ADS1115Gain gain, ADS1115Resolution resolution); + float request_measurement(ADS1115Multiplexer multiplexer, ADS1115Gain gain, ADS1115Resolution resolution, + ADS1115Samplerate samplerate); protected: uint16_t prev_config_{0}; diff --git a/esphome/components/ads1115/sensor/__init__.py b/esphome/components/ads1115/sensor/__init__.py index baec31d35c..f346a71198 100644 --- a/esphome/components/ads1115/sensor/__init__.py +++ b/esphome/components/ads1115/sensor/__init__.py @@ -5,6 +5,7 @@ from esphome.const import ( CONF_GAIN, CONF_MULTIPLEXER, CONF_RESOLUTION, + CONF_SAMPLE_RATE, DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, UNIT_VOLT, @@ -43,6 +44,17 @@ RESOLUTION = { "12_BITS": ADS1115Resolution.ADS1015_12_BITS, } +ADS1115Samplerate = ads1115_ns.enum("ADS1115Samplerate") +SAMPLERATE = { + "8": ADS1115Samplerate.ADS1115_8SPS, + "16": ADS1115Samplerate.ADS1115_16SPS, + "32": ADS1115Samplerate.ADS1115_32SPS, + "64": ADS1115Samplerate.ADS1115_64SPS, + "128": ADS1115Samplerate.ADS1115_128SPS, + "250": ADS1115Samplerate.ADS1115_250SPS, + "475": ADS1115Samplerate.ADS1115_475SPS, + "860": ADS1115Samplerate.ADS1115_860SPS, +} ADS1115Sensor = ads1115_ns.class_( "ADS1115Sensor", sensor.Sensor, cg.PollingComponent, voltage_sampler.VoltageSampler @@ -64,6 +76,9 @@ CONFIG_SCHEMA = ( cv.Optional(CONF_RESOLUTION, default="16_BITS"): cv.enum( RESOLUTION, upper=True, space="_" ), + cv.Optional(CONF_SAMPLE_RATE, default="860"): cv.enum( + SAMPLERATE, string=True + ), } ) .extend(cv.polling_component_schema("60s")) @@ -79,3 +94,4 @@ async def to_code(config): cg.add(var.set_multiplexer(config[CONF_MULTIPLEXER])) cg.add(var.set_gain(config[CONF_GAIN])) cg.add(var.set_resolution(config[CONF_RESOLUTION])) + cg.add(var.set_samplerate(config[CONF_SAMPLE_RATE])) diff --git a/esphome/components/ads1115/sensor/ads1115_sensor.cpp b/esphome/components/ads1115/sensor/ads1115_sensor.cpp index 335fca4845..6de95f1d12 100644 --- a/esphome/components/ads1115/sensor/ads1115_sensor.cpp +++ b/esphome/components/ads1115/sensor/ads1115_sensor.cpp @@ -8,7 +8,7 @@ namespace ads1115 { static const char *const TAG = "ads1115.sensor"; float ADS1115Sensor::sample() { - return this->parent_->request_measurement(this->multiplexer_, this->gain_, this->resolution_); + return this->parent_->request_measurement(this->multiplexer_, this->gain_, this->resolution_, this->samplerate_); } void ADS1115Sensor::update() { @@ -24,6 +24,7 @@ void ADS1115Sensor::dump_config() { ESP_LOGCONFIG(TAG, " Multiplexer: %u", this->multiplexer_); ESP_LOGCONFIG(TAG, " Gain: %u", this->gain_); ESP_LOGCONFIG(TAG, " Resolution: %u", this->resolution_); + ESP_LOGCONFIG(TAG, " Sample rate: %u", this->samplerate_); } } // namespace ads1115 diff --git a/esphome/components/ads1115/sensor/ads1115_sensor.h b/esphome/components/ads1115/sensor/ads1115_sensor.h index 191afc3de6..5ca25c13ad 100644 --- a/esphome/components/ads1115/sensor/ads1115_sensor.h +++ b/esphome/components/ads1115/sensor/ads1115_sensor.h @@ -21,6 +21,7 @@ class ADS1115Sensor : public sensor::Sensor, void set_multiplexer(ADS1115Multiplexer multiplexer) { this->multiplexer_ = multiplexer; } void set_gain(ADS1115Gain gain) { this->gain_ = gain; } void set_resolution(ADS1115Resolution resolution) { this->resolution_ = resolution; } + void set_samplerate(ADS1115Samplerate samplerate) { this->samplerate_ = samplerate; } float sample() override; void dump_config() override; @@ -29,6 +30,7 @@ class ADS1115Sensor : public sensor::Sensor, ADS1115Multiplexer multiplexer_; ADS1115Gain gain_; ADS1115Resolution resolution_; + ADS1115Samplerate samplerate_; }; } // namespace ads1115 diff --git a/tests/components/ads1115/test.esp32-ard.yaml b/tests/components/ads1115/test.esp32-ard.yaml index a869f2379b..0fdaeff275 100644 --- a/tests/components/ads1115/test.esp32-ard.yaml +++ b/tests/components/ads1115/test.esp32-ard.yaml @@ -10,4 +10,5 @@ sensor: - platform: ads1115 multiplexer: A0_A1 gain: 1.024 + sample_rate: 128 id: ads1115_sensor diff --git a/tests/components/ads1115/test.esp32-c3-ard.yaml b/tests/components/ads1115/test.esp32-c3-ard.yaml index 7ac5a09f3f..265d2cad2c 100644 --- a/tests/components/ads1115/test.esp32-c3-ard.yaml +++ b/tests/components/ads1115/test.esp32-c3-ard.yaml @@ -10,4 +10,5 @@ sensor: - platform: ads1115 multiplexer: A0_A1 gain: 1.024 + sample_rate: 128 id: ads1115_sensor diff --git a/tests/components/ads1115/test.esp32-c3-idf.yaml b/tests/components/ads1115/test.esp32-c3-idf.yaml index 7ac5a09f3f..265d2cad2c 100644 --- a/tests/components/ads1115/test.esp32-c3-idf.yaml +++ b/tests/components/ads1115/test.esp32-c3-idf.yaml @@ -10,4 +10,5 @@ sensor: - platform: ads1115 multiplexer: A0_A1 gain: 1.024 + sample_rate: 128 id: ads1115_sensor diff --git a/tests/components/ads1115/test.esp32-idf.yaml b/tests/components/ads1115/test.esp32-idf.yaml index a869f2379b..0fdaeff275 100644 --- a/tests/components/ads1115/test.esp32-idf.yaml +++ b/tests/components/ads1115/test.esp32-idf.yaml @@ -10,4 +10,5 @@ sensor: - platform: ads1115 multiplexer: A0_A1 gain: 1.024 + sample_rate: 128 id: ads1115_sensor diff --git a/tests/components/ads1115/test.esp8266-ard.yaml b/tests/components/ads1115/test.esp8266-ard.yaml index 7ac5a09f3f..265d2cad2c 100644 --- a/tests/components/ads1115/test.esp8266-ard.yaml +++ b/tests/components/ads1115/test.esp8266-ard.yaml @@ -10,4 +10,5 @@ sensor: - platform: ads1115 multiplexer: A0_A1 gain: 1.024 + sample_rate: 128 id: ads1115_sensor diff --git a/tests/components/ads1115/test.rp2040-ard.yaml b/tests/components/ads1115/test.rp2040-ard.yaml index 7ac5a09f3f..265d2cad2c 100644 --- a/tests/components/ads1115/test.rp2040-ard.yaml +++ b/tests/components/ads1115/test.rp2040-ard.yaml @@ -10,4 +10,5 @@ sensor: - platform: ads1115 multiplexer: A0_A1 gain: 1.024 + sample_rate: 128 id: ads1115_sensor From 65b2d48a6fea3a0ee249d6c2dcf4288ed1a63704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskari=20Lemmel=C3=A4?= <41640457+olemmela@users.noreply.github.com> Date: Thu, 23 Jan 2025 01:32:45 +0200 Subject: [PATCH 110/194] Fix mqtt climate step rounding (#8121) --- esphome/components/mqtt/mqtt_climate.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/mqtt/mqtt_climate.cpp b/esphome/components/mqtt/mqtt_climate.cpp index f06574fa26..a8768114a4 100644 --- a/esphome/components/mqtt/mqtt_climate.cpp +++ b/esphome/components/mqtt/mqtt_climate.cpp @@ -72,9 +72,9 @@ void MQTTClimateComponent::send_discovery(JsonObject root, mqtt::SendDiscoveryCo // max_temp root[MQTT_MAX_TEMP] = traits.get_visual_max_temperature(); // target_temp_step - root[MQTT_TARGET_TEMPERATURE_STEP] = traits.get_visual_target_temperature_step(); + root[MQTT_TARGET_TEMPERATURE_STEP] = roundf(traits.get_visual_target_temperature_step() * 10) * 0.1; // current_temp_step - root[MQTT_CURRENT_TEMPERATURE_STEP] = traits.get_visual_current_temperature_step(); + root[MQTT_CURRENT_TEMPERATURE_STEP] = roundf(traits.get_visual_current_temperature_step() * 10) * 0.1; // temperature units are always coerced to Celsius internally root[MQTT_TEMPERATURE_UNIT] = "C"; From dee1d849793ae789a6f4bab730f02268b3975e60 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Thu, 23 Jan 2025 00:41:55 +0100 Subject: [PATCH 111/194] [spi] Fix data type in bitbash transfer_() (#8125) --- esphome/components/spi/spi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/spi/spi.cpp b/esphome/components/spi/spi.cpp index b13826c443..18f7852757 100644 --- a/esphome/components/spi/spi.cpp +++ b/esphome/components/spi/spi.cpp @@ -88,7 +88,7 @@ void SPIDelegateBitBash::write(uint16_t data, size_t num_bits) { this->transfer_ uint16_t SPIDelegateBitBash::transfer_(uint16_t data, size_t num_bits) { // Clock starts out at idle level this->clk_pin_->digital_write(clock_polarity_); - uint8_t out_data = 0; + uint16_t out_data = 0; for (uint8_t i = 0; i != num_bits; i++) { uint8_t shift; From 7fccc9ff86193a5f7d094c9253dcd4a5b924e6ad Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 23 Jan 2025 15:10:19 +1300 Subject: [PATCH 112/194] [online_image] Add binary bmp support (#8116) Co-authored-by: guillempages --- esphome/components/online_image/__init__.py | 16 ++- esphome/components/online_image/bmp_image.cpp | 101 ++++++++++++++++++ esphome/components/online_image/bmp_image.h | 40 +++++++ .../components/online_image/image_decoder.cpp | 5 +- .../components/online_image/image_decoder.h | 9 +- .../components/online_image/online_image.cpp | 11 +- .../components/online_image/online_image.h | 8 +- esphome/core/defines.h | 1 + tests/components/online_image/common.yaml | 4 + 9 files changed, 187 insertions(+), 8 deletions(-) create mode 100644 esphome/components/online_image/bmp_image.cpp create mode 100644 esphome/components/online_image/bmp_image.h diff --git a/esphome/components/online_image/__init__.py b/esphome/components/online_image/__init__.py index ca4eefea6f..fdb49fc493 100644 --- a/esphome/components/online_image/__init__.py +++ b/esphome/components/online_image/__init__.py @@ -61,8 +61,22 @@ class PNGFormat(Format): cg.add_library("pngle", "1.0.2") +class BMPFormat(Format): + def __init__(self): + super().__init__("BMP") + + def actions(self): + cg.add_define("USE_ONLINE_IMAGE_BMP_SUPPORT") + + # New formats can be added here. -IMAGE_FORMATS = {x.image_type: x for x in (PNGFormat(),)} +IMAGE_FORMATS = { + x.image_type: x + for x in ( + PNGFormat(), + BMPFormat(), + ) +} OnlineImage = online_image_ns.class_("OnlineImage", cg.PollingComponent, Image_) diff --git a/esphome/components/online_image/bmp_image.cpp b/esphome/components/online_image/bmp_image.cpp new file mode 100644 index 0000000000..af9019a4d2 --- /dev/null +++ b/esphome/components/online_image/bmp_image.cpp @@ -0,0 +1,101 @@ +#include "bmp_image.h" + +#ifdef USE_ONLINE_IMAGE_BMP_SUPPORT + +#include "esphome/components/display/display.h" +#include "esphome/core/helpers.h" +#include "esphome/core/log.h" + +namespace esphome { +namespace online_image { + +static const char *const TAG = "online_image.bmp"; + +int HOT BmpDecoder::decode(uint8_t *buffer, size_t size) { + size_t index = 0; + if (this->current_index_ == 0 && index == 0 && size > 14) { + /** + * BMP file format: + * 0-1: Signature (BM) + * 2-5: File size + * 6-9: Reserved + * 10-13: Pixel data offset + * + * Integer values are stored in little-endian format. + */ + + // Check if the file is a BMP image + if (buffer[0] != 'B' || buffer[1] != 'M') { + ESP_LOGE(TAG, "Not a BMP file"); + return DECODE_ERROR_INVALID_TYPE; + } + + this->download_size_ = encode_uint32(buffer[5], buffer[4], buffer[3], buffer[2]); + this->data_offset_ = encode_uint32(buffer[13], buffer[12], buffer[11], buffer[10]); + + this->current_index_ = 14; + index = 14; + } + if (this->current_index_ == 14 && index == 14 && size > this->data_offset_) { + /** + * BMP DIB header: + * 14-17: DIB header size + * 18-21: Image width + * 22-25: Image height + * 26-27: Number of color planes + * 28-29: Bits per pixel + * 30-33: Compression method + * 34-37: Image data size + * 38-41: Horizontal resolution + * 42-45: Vertical resolution + * 46-49: Number of colors in the color table + */ + + this->width_ = encode_uint32(buffer[21], buffer[20], buffer[19], buffer[18]); + this->height_ = encode_uint32(buffer[25], buffer[24], buffer[23], buffer[22]); + this->bits_per_pixel_ = encode_uint16(buffer[29], buffer[28]); + this->compression_method_ = encode_uint32(buffer[33], buffer[32], buffer[31], buffer[30]); + this->image_data_size_ = encode_uint32(buffer[37], buffer[36], buffer[35], buffer[34]); + this->color_table_entries_ = encode_uint32(buffer[49], buffer[48], buffer[47], buffer[46]); + + switch (this->bits_per_pixel_) { + case 1: + this->width_bytes_ = (this->width_ % 8 == 0) ? (this->width_ / 8) : (this->width_ / 8 + 1); + break; + default: + ESP_LOGE(TAG, "Unsupported bits per pixel: %d", this->bits_per_pixel_); + return DECODE_ERROR_UNSUPPORTED_FORMAT; + } + + if (this->compression_method_ != 0) { + ESP_LOGE(TAG, "Unsupported compression method: %d", this->compression_method_); + return DECODE_ERROR_UNSUPPORTED_FORMAT; + } + + if (!this->set_size(this->width_, this->height_)) { + return DECODE_ERROR_OUT_OF_MEMORY; + } + this->current_index_ = this->data_offset_; + index = this->data_offset_; + } + while (index < size) { + size_t paint_index = this->current_index_ - this->data_offset_; + + uint8_t current_byte = buffer[index]; + for (uint8_t i = 0; i < 8; i++) { + size_t x = (paint_index * 8) % this->width_ + i; + size_t y = (this->height_ - 1) - (paint_index / this->width_bytes_); + Color c = (current_byte & (1 << (7 - i))) ? display::COLOR_ON : display::COLOR_OFF; + this->draw(x, y, 1, 1, c); + } + this->current_index_++; + index++; + } + this->decoded_bytes_ += size; + return size; +}; + +} // namespace online_image +} // namespace esphome + +#endif // USE_ONLINE_IMAGE_BMP_SUPPORT diff --git a/esphome/components/online_image/bmp_image.h b/esphome/components/online_image/bmp_image.h new file mode 100644 index 0000000000..61192f6a46 --- /dev/null +++ b/esphome/components/online_image/bmp_image.h @@ -0,0 +1,40 @@ +#pragma once + +#include "esphome/core/defines.h" +#ifdef USE_ONLINE_IMAGE_BMP_SUPPORT + +#include "image_decoder.h" + +namespace esphome { +namespace online_image { + +/** + * @brief Image decoder specialization for PNG images. + */ +class BmpDecoder : public ImageDecoder { + public: + /** + * @brief Construct a new BMP Decoder object. + * + * @param display The image to decode the stream into. + */ + BmpDecoder(OnlineImage *image) : ImageDecoder(image) {} + + int HOT decode(uint8_t *buffer, size_t size) override; + + protected: + size_t current_index_{0}; + ssize_t width_{0}; + ssize_t height_{0}; + uint16_t bits_per_pixel_{0}; + uint32_t compression_method_{0}; + uint32_t image_data_size_{0}; + uint32_t color_table_entries_{0}; + size_t width_bytes_{0}; + size_t data_offset_{0}; +}; + +} // namespace online_image +} // namespace esphome + +#endif // USE_ONLINE_IMAGE_BMP_SUPPORT diff --git a/esphome/components/online_image/image_decoder.cpp b/esphome/components/online_image/image_decoder.cpp index 50ec39dfcc..d0d0495ba6 100644 --- a/esphome/components/online_image/image_decoder.cpp +++ b/esphome/components/online_image/image_decoder.cpp @@ -8,10 +8,11 @@ namespace online_image { static const char *const TAG = "online_image.decoder"; -void ImageDecoder::set_size(int width, int height) { - this->image_->resize_(width, height); +bool ImageDecoder::set_size(int width, int height) { + bool resized = this->image_->resize_(width, height); this->x_scale_ = static_cast(this->image_->buffer_width_) / width; this->y_scale_ = static_cast(this->image_->buffer_height_) / height; + return resized; } void ImageDecoder::draw(int x, int y, int w, int h, const Color &color) { diff --git a/esphome/components/online_image/image_decoder.h b/esphome/components/online_image/image_decoder.h index 7c5175d72d..3b04824bb9 100644 --- a/esphome/components/online_image/image_decoder.h +++ b/esphome/components/online_image/image_decoder.h @@ -4,6 +4,12 @@ namespace esphome { namespace online_image { +enum DecodeError : int { + DECODE_ERROR_INVALID_TYPE = -1, + DECODE_ERROR_UNSUPPORTED_FORMAT = -2, + DECODE_ERROR_OUT_OF_MEMORY = -3, +}; + class OnlineImage; /** @@ -45,8 +51,9 @@ class ImageDecoder { * * @param width The image's width. * @param height The image's height. + * @return true if the image was resized, false otherwise. */ - void set_size(int width, int height); + bool set_size(int width, int height); /** * @brief Fill a rectangle on the display_buffer using the defined color. diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index 93d070c6a9..23fe61b534 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -10,6 +10,10 @@ static const char *const TAG = "online_image"; #include "png_image.h" #endif +#ifdef USE_ONLINE_IMAGE_BMP_SUPPORT +#include "bmp_image.h" +#endif + namespace esphome { namespace online_image { @@ -120,9 +124,14 @@ void OnlineImage::update() { #ifdef USE_ONLINE_IMAGE_PNG_SUPPORT if (this->format_ == ImageFormat::PNG) { - this->decoder_ = esphome::make_unique(this); + this->decoder_ = make_unique(this); } #endif // ONLINE_IMAGE_PNG_SUPPORT +#ifdef USE_ONLINE_IMAGE_BMP_SUPPORT + if (this->format_ == ImageFormat::BMP) { + this->decoder_ = make_unique(this); + } +#endif // ONLINE_IMAGE_BMP_SUPPORT if (!this->decoder_) { ESP_LOGE(TAG, "Could not instantiate decoder. Image format unsupported."); diff --git a/esphome/components/online_image/online_image.h b/esphome/components/online_image/online_image.h index bafd8ba67e..849f860ad5 100644 --- a/esphome/components/online_image/online_image.h +++ b/esphome/components/online_image/online_image.h @@ -1,10 +1,10 @@ #pragma once +#include "esphome/components/http_request/http_request.h" +#include "esphome/components/image/image.h" #include "esphome/core/component.h" #include "esphome/core/defines.h" #include "esphome/core/helpers.h" -#include "esphome/components/http_request/http_request.h" -#include "esphome/components/image/image.h" #include "image_decoder.h" @@ -27,6 +27,8 @@ enum ImageFormat { JPEG, /** PNG format. */ PNG, + /** BMP format. */ + BMP, }; /** @@ -146,7 +148,7 @@ class OnlineImage : public PollingComponent, */ int buffer_height_; - friend void ImageDecoder::set_size(int width, int height); + friend bool ImageDecoder::set_size(int width, int height); friend void ImageDecoder::draw(int x, int y, int w, int h, const Color &color); }; diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 96a05435ed..074b19809f 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -60,6 +60,7 @@ #define USE_NETWORK #define USE_NEXTION_TFT_UPLOAD #define USE_NUMBER +#define USE_ONLINE_IMAGE_BMP_SUPPORT #define USE_ONLINE_IMAGE_PNG_SUPPORT #define USE_OTA #define USE_OTA_PASSWORD diff --git a/tests/components/online_image/common.yaml b/tests/components/online_image/common.yaml index 6c161e4f20..d75900adf9 100644 --- a/tests/components/online_image/common.yaml +++ b/tests/components/online_image/common.yaml @@ -26,6 +26,10 @@ online_image: format: PNG type: RGB transparency: chroma_key + - id: online_binary_bmp + url: https://samples-files.com/samples/images/bmp/480-360-sample.bmp + format: BMP + type: BINARY # Check the set_url action esphome: From fc847c1de8927871e783db1a35e967efabda9f04 Mon Sep 17 00:00:00 2001 From: guillempages Date: Thu, 23 Jan 2025 21:32:03 +0100 Subject: [PATCH 113/194] [online_image] Code Improvements (#8130) --- esphome/components/online_image/__init__.py | 18 +++++++++--------- .../components/online_image/image_decoder.h | 6 +++--- .../components/online_image/online_image.cpp | 17 ++++++++--------- esphome/components/online_image/png_image.cpp | 4 ++-- esphome/components/online_image/png_image.h | 2 +- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/esphome/components/online_image/__init__.py b/esphome/components/online_image/__init__.py index fdb49fc493..eb6debf8eb 100644 --- a/esphome/components/online_image/__init__.py +++ b/esphome/components/online_image/__init__.py @@ -52,6 +52,14 @@ class Format: pass +class BMPFormat(Format): + def __init__(self): + super().__init__("BMP") + + def actions(self): + cg.add_define("USE_ONLINE_IMAGE_BMP_SUPPORT") + + class PNGFormat(Format): def __init__(self): super().__init__("PNG") @@ -61,20 +69,12 @@ class PNGFormat(Format): cg.add_library("pngle", "1.0.2") -class BMPFormat(Format): - def __init__(self): - super().__init__("BMP") - - def actions(self): - cg.add_define("USE_ONLINE_IMAGE_BMP_SUPPORT") - - # New formats can be added here. IMAGE_FORMATS = { x.image_type: x for x in ( - PNGFormat(), BMPFormat(), + PNGFormat(), ) } diff --git a/esphome/components/online_image/image_decoder.h b/esphome/components/online_image/image_decoder.h index 3b04824bb9..4e5dd7b229 100644 --- a/esphome/components/online_image/image_decoder.h +++ b/esphome/components/online_image/image_decoder.h @@ -30,7 +30,7 @@ class ImageDecoder { * * @param download_size The total number of bytes that need to be downloaded for the image. */ - virtual void prepare(uint32_t download_size) { this->download_size_ = download_size; } + virtual void prepare(size_t download_size) { this->download_size_ = download_size; } /** * @brief Decode a part of the image. It will try reading from the buffer. @@ -75,8 +75,8 @@ class ImageDecoder { OnlineImage *image_; // Initializing to 1, to ensure it is distinguishable from initial "decoded_bytes_". // Will be overwritten anyway once the download size is known. - uint32_t download_size_ = 1; - uint32_t decoded_bytes_ = 0; + size_t download_size_ = 1; + size_t decoded_bytes_ = 0; double x_scale_ = 1.0; double y_scale_ = 1.0; }; diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index 23fe61b534..c6499c24e4 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -6,13 +6,12 @@ static const char *const TAG = "online_image"; #include "image_decoder.h" -#ifdef USE_ONLINE_IMAGE_PNG_SUPPORT -#include "png_image.h" -#endif - #ifdef USE_ONLINE_IMAGE_BMP_SUPPORT #include "bmp_image.h" #endif +#ifdef USE_ONLINE_IMAGE_PNG_SUPPORT +#include "png_image.h" +#endif namespace esphome { namespace online_image { @@ -122,16 +121,16 @@ void OnlineImage::update() { ESP_LOGD(TAG, "Starting download"); size_t total_size = this->downloader_->content_length; -#ifdef USE_ONLINE_IMAGE_PNG_SUPPORT - if (this->format_ == ImageFormat::PNG) { - this->decoder_ = make_unique(this); - } -#endif // ONLINE_IMAGE_PNG_SUPPORT #ifdef USE_ONLINE_IMAGE_BMP_SUPPORT if (this->format_ == ImageFormat::BMP) { this->decoder_ = make_unique(this); } #endif // ONLINE_IMAGE_BMP_SUPPORT +#ifdef USE_ONLINE_IMAGE_PNG_SUPPORT + if (this->format_ == ImageFormat::PNG) { + this->decoder_ = make_unique(this); + } +#endif // ONLINE_IMAGE_PNG_SUPPORT if (!this->decoder_) { ESP_LOGE(TAG, "Could not instantiate decoder. Image format unsupported."); diff --git a/esphome/components/online_image/png_image.cpp b/esphome/components/online_image/png_image.cpp index 4c4c22f9b7..59c1ce6c7d 100644 --- a/esphome/components/online_image/png_image.cpp +++ b/esphome/components/online_image/png_image.cpp @@ -41,7 +41,7 @@ static void draw_callback(pngle_t *pngle, uint32_t x, uint32_t y, uint32_t w, ui decoder->draw(x, y, w, h, color); } -void PngDecoder::prepare(uint32_t download_size) { +void PngDecoder::prepare(size_t download_size) { ImageDecoder::prepare(download_size); pngle_set_user_data(this->pngle_, this); pngle_set_init_callback(this->pngle_, init_callback); @@ -51,7 +51,7 @@ void PngDecoder::prepare(uint32_t download_size) { int HOT PngDecoder::decode(uint8_t *buffer, size_t size) { if (!this->pngle_) { ESP_LOGE(TAG, "PNG decoder engine not initialized!"); - return -1; + return DECODE_ERROR_OUT_OF_MEMORY; } if (size < 256 && size < this->download_size_ - this->decoded_bytes_) { ESP_LOGD(TAG, "Waiting for data"); diff --git a/esphome/components/online_image/png_image.h b/esphome/components/online_image/png_image.h index d82ff93149..c137227907 100644 --- a/esphome/components/online_image/png_image.h +++ b/esphome/components/online_image/png_image.h @@ -21,7 +21,7 @@ class PngDecoder : public ImageDecoder { PngDecoder(OnlineImage *image) : ImageDecoder(image), pngle_(pngle_new()) {} ~PngDecoder() override { pngle_destroy(this->pngle_); } - void prepare(uint32_t download_size) override; + void prepare(size_t download_size) override; int HOT decode(uint8_t *buffer, size_t size) override; protected: From dbf4c2c4dae43ee929471a26823db88f373576d6 Mon Sep 17 00:00:00 2001 From: Jimmy Hedman Date: Mon, 27 Jan 2025 05:23:57 +0100 Subject: [PATCH 114/194] Update mdns for ESP-IDF (#8145) --- esphome/components/mdns/__init__.py | 2 +- esphome/idf_component.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/mdns/__init__.py b/esphome/components/mdns/__init__.py index dd68fbb93c..1bc290b582 100644 --- a/esphome/components/mdns/__init__.py +++ b/esphome/components/mdns/__init__.py @@ -91,7 +91,7 @@ async def to_code(config): add_idf_component( name="mdns", repo="https://github.com/espressif/esp-protocols.git", - ref="mdns-v1.3.2", + ref="mdns-v1.5.1", path="components/mdns", ) diff --git a/esphome/idf_component.yml b/esphome/idf_component.yml index c79ba1b0ed..bd5bcda2fe 100644 --- a/esphome/idf_component.yml +++ b/esphome/idf_component.yml @@ -7,7 +7,7 @@ dependencies: version: v2.0.9 mdns: git: https://github.com/espressif/esp-protocols.git - version: mdns-v1.3.2 + version: mdns-v1.5.1 path: components/mdns rules: - if: "idf_version >=5.0" From dd18a219db7e4d7306c4cbd088baecfd146a811d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 27 Jan 2025 16:57:52 -1000 Subject: [PATCH 115/194] Include Bluetooth connection slot allocations in connections free message (#8148) --- esphome/components/api/api.proto | 1 + esphome/components/api/api_pb2.cpp | 14 ++++++++++++++ esphome/components/api/api_pb2.h | 1 + .../components/bluetooth_proxy/bluetooth_proxy.cpp | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 684540ffa6..534098e5fd 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -1381,6 +1381,7 @@ message BluetoothConnectionsFreeResponse { uint32 free = 1; uint32 limit = 2; + repeated uint64 allocated = 3; } message BluetoothGATTErrorResponse { diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 8df152881c..41016e510f 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -6430,6 +6430,10 @@ bool BluetoothConnectionsFreeResponse::decode_varint(uint32_t field_id, ProtoVar this->limit = value.as_uint32(); return true; } + case 3: { + this->allocated.push_back(value.as_uint64()); + return true; + } default: return false; } @@ -6437,6 +6441,9 @@ bool BluetoothConnectionsFreeResponse::decode_varint(uint32_t field_id, ProtoVar void BluetoothConnectionsFreeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_uint32(1, this->free); buffer.encode_uint32(2, this->limit); + for (auto &it : this->allocated) { + buffer.encode_uint64(3, it, true); + } } #ifdef HAS_PROTO_MESSAGE_DUMP void BluetoothConnectionsFreeResponse::dump_to(std::string &out) const { @@ -6451,6 +6458,13 @@ void BluetoothConnectionsFreeResponse::dump_to(std::string &out) const { sprintf(buffer, "%" PRIu32, this->limit); out.append(buffer); out.append("\n"); + + for (const auto &it : this->allocated) { + out.append(" allocated: "); + sprintf(buffer, "%llu", it); + out.append(buffer); + out.append("\n"); + } out.append("}"); } #endif diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index 063c217bf7..a3fccbc641 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -1624,6 +1624,7 @@ class BluetoothConnectionsFreeResponse : public ProtoMessage { public: uint32_t free{0}; uint32_t limit{0}; + std::vector allocated{}; void encode(ProtoWriteBuffer buffer) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; diff --git a/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp b/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp index bd1c8b7ea4..a263aca456 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +++ b/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp @@ -475,6 +475,11 @@ void BluetoothProxy::send_connections_free() { api::BluetoothConnectionsFreeResponse call; call.free = this->get_bluetooth_connections_free(); call.limit = this->get_bluetooth_connections_limit(); + for (auto *connection : this->connections_) { + if (connection->address_ != 0) { + call.allocated.push_back(connection->address_); + } + } this->api_connection_->send_bluetooth_connections_free_response(call); } From f7f8bf4da44b83796a301bc486d77fdb46d8ed82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Mart=C3=ADn?= Date: Tue, 28 Jan 2025 12:00:28 +0100 Subject: [PATCH 116/194] [esp32_ble_server] Create custom services, characteristics and descriptors (#7009) Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- CODEOWNERS | 1 + .../components/ble_client/sensor/__init__.py | 2 +- .../ble_client/text_sensor/__init__.py | 2 +- esphome/components/esp32_ble/__init__.py | 39 ++ .../components/esp32_ble_server/__init__.py | 594 +++++++++++++++++- .../components/esp32_ble_server/ble_2901.cpp | 18 - .../components/esp32_ble_server/ble_2901.h | 19 - .../esp32_ble_server/ble_characteristic.cpp | 108 ++-- .../esp32_ble_server/ble_characteristic.h | 41 +- .../esp32_ble_server/ble_descriptor.cpp | 30 +- .../esp32_ble_server/ble_descriptor.h | 23 +- .../esp32_ble_server/ble_server.cpp | 129 ++-- .../components/esp32_ble_server/ble_server.h | 60 +- .../ble_server_automations.cpp | 77 +++ .../esp32_ble_server/ble_server_automations.h | 115 ++++ .../esp32_ble_server/ble_service.cpp | 32 +- .../components/esp32_ble_server/ble_service.h | 24 +- .../components/esp32_ble_tracker/__init__.py | 45 +- esphome/components/esp32_improv/__init__.py | 10 +- .../esp32_improv/esp32_improv_component.cpp | 39 +- .../esp32_improv/esp32_improv_component.h | 7 +- esphome/components/event_emitter/__init__.py | 5 + .../event_emitter/event_emitter.cpp | 14 + .../components/event_emitter/event_emitter.h | 63 ++ esphome/const.py | 1 + tests/components/esp32_ble_server/common.yaml | 65 +- 26 files changed, 1221 insertions(+), 342 deletions(-) delete mode 100644 esphome/components/esp32_ble_server/ble_2901.cpp delete mode 100644 esphome/components/esp32_ble_server/ble_2901.h create mode 100644 esphome/components/esp32_ble_server/ble_server_automations.cpp create mode 100644 esphome/components/esp32_ble_server/ble_server_automations.h create mode 100644 esphome/components/event_emitter/__init__.py create mode 100644 esphome/components/event_emitter/event_emitter.cpp create mode 100644 esphome/components/event_emitter/event_emitter.h diff --git a/CODEOWNERS b/CODEOWNERS index aa24b6cb82..cdf4ab7a99 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -148,6 +148,7 @@ esphome/components/esp32_rmt_led_strip/* @jesserockz esphome/components/esp8266/* @esphome/core esphome/components/ethernet_info/* @gtjadsonsantos esphome/components/event/* @nohat +esphome/components/event_emitter/* @Rapsssito esphome/components/exposure_notifications/* @OttoWinter esphome/components/ezo/* @ssieb esphome/components/ezo_pmp/* @carlos-sarmiento diff --git a/esphome/components/ble_client/sensor/__init__.py b/esphome/components/ble_client/sensor/__init__.py index 0c48902a90..960410a5cc 100644 --- a/esphome/components/ble_client/sensor/__init__.py +++ b/esphome/components/ble_client/sensor/__init__.py @@ -11,6 +11,7 @@ from esphome.const import ( DEVICE_CLASS_SIGNAL_STRENGTH, STATE_CLASS_MEASUREMENT, UNIT_DECIBEL_MILLIWATT, + CONF_NOTIFY, ) from .. import ble_client_ns @@ -19,7 +20,6 @@ DEPENDENCIES = ["ble_client"] CONF_DESCRIPTOR_UUID = "descriptor_uuid" -CONF_NOTIFY = "notify" CONF_ON_NOTIFY = "on_notify" TYPE_CHARACTERISTIC = "characteristic" TYPE_RSSI = "rssi" diff --git a/esphome/components/ble_client/text_sensor/__init__.py b/esphome/components/ble_client/text_sensor/__init__.py index 479af1a57e..a6672e68f5 100644 --- a/esphome/components/ble_client/text_sensor/__init__.py +++ b/esphome/components/ble_client/text_sensor/__init__.py @@ -6,6 +6,7 @@ from esphome.const import ( CONF_CHARACTERISTIC_UUID, CONF_ID, CONF_SERVICE_UUID, + CONF_NOTIFY, CONF_TRIGGER_ID, ) @@ -15,7 +16,6 @@ DEPENDENCIES = ["ble_client"] CONF_DESCRIPTOR_UUID = "descriptor_uuid" -CONF_NOTIFY = "notify" CONF_ON_NOTIFY = "on_notify" adv_data_t = cg.std_vector.template(cg.uint8) diff --git a/esphome/components/esp32_ble/__init__.py b/esphome/components/esp32_ble/__init__.py index 08e30c9247..37b4900a03 100644 --- a/esphome/components/esp32_ble/__init__.py +++ b/esphome/components/esp32_ble/__init__.py @@ -1,3 +1,5 @@ +import re + from esphome import automation import esphome.codegen as cg from esphome.components.esp32 import add_idf_sdkconfig_option, const, get_esp32_variant @@ -64,6 +66,43 @@ CONFIG_SCHEMA = cv.Schema( ).extend(cv.COMPONENT_SCHEMA) +bt_uuid16_format = "XXXX" +bt_uuid32_format = "XXXXXXXX" +bt_uuid128_format = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" + + +def bt_uuid(value): + in_value = cv.string_strict(value) + value = in_value.upper() + + if len(value) == len(bt_uuid16_format): + pattern = re.compile("^[A-F|0-9]{4,}$") + if not pattern.match(value): + raise cv.Invalid( + f"Invalid hexadecimal value for 16 bit UUID format: '{in_value}'" + ) + return value + if len(value) == len(bt_uuid32_format): + pattern = re.compile("^[A-F|0-9]{8,}$") + if not pattern.match(value): + raise cv.Invalid( + f"Invalid hexadecimal value for 32 bit UUID format: '{in_value}'" + ) + return value + if len(value) == len(bt_uuid128_format): + pattern = re.compile( + "^[A-F|0-9]{8,}-[A-F|0-9]{4,}-[A-F|0-9]{4,}-[A-F|0-9]{4,}-[A-F|0-9]{12,}$" + ) + if not pattern.match(value): + raise cv.Invalid( + f"Invalid hexadecimal value for 128 UUID format: '{in_value}'" + ) + return value + raise cv.Invalid( + f"Bluetooth UUID must be in 16 bit '{bt_uuid16_format}', 32 bit '{bt_uuid32_format}', or 128 bit '{bt_uuid128_format}' format" + ) + + def validate_variant(_): variant = get_esp32_variant() if variant in NO_BLUETOOTH_VARIANTS: diff --git a/esphome/components/esp32_ble_server/__init__.py b/esphome/components/esp32_ble_server/__init__.py index 9da7d13999..ab8e27ec43 100644 --- a/esphome/components/esp32_ble_server/__init__.py +++ b/esphome/components/esp32_ble_server/__init__.py @@ -1,37 +1,526 @@ +import encodings + +from esphome import automation import esphome.codegen as cg from esphome.components import esp32_ble from esphome.components.esp32 import add_idf_sdkconfig_option +from esphome.components.esp32_ble import bt_uuid import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_MODEL +from esphome.config_validation import UNDEFINED +from esphome.const import ( + CONF_DATA, + CONF_ESPHOME, + CONF_ID, + CONF_MAX_LENGTH, + CONF_MODEL, + CONF_NOTIFY, + CONF_ON_CONNECT, + CONF_ON_DISCONNECT, + CONF_PROJECT, + CONF_SERVICES, + CONF_TYPE, + CONF_UUID, + CONF_VALUE, + __version__ as ESPHOME_VERSION, +) from esphome.core import CORE +from esphome.schema_extractors import SCHEMA_EXTRACT -AUTO_LOAD = ["esp32_ble"] +AUTO_LOAD = ["esp32_ble", "bytebuffer", "event_emitter"] CODEOWNERS = ["@jesserockz", "@clydebarrow", "@Rapsssito"] DEPENDENCIES = ["esp32"] +DOMAIN = "esp32_ble_server" +CONF_ADVERTISE = "advertise" +CONF_BROADCAST = "broadcast" +CONF_CHARACTERISTICS = "characteristics" +CONF_DESCRIPTION = "description" +CONF_DESCRIPTORS = "descriptors" +CONF_ENDIANNESS = "endianness" +CONF_FIRMWARE_VERSION = "firmware_version" +CONF_INDICATE = "indicate" CONF_MANUFACTURER = "manufacturer" CONF_MANUFACTURER_DATA = "manufacturer_data" +CONF_ON_WRITE = "on_write" +CONF_READ = "read" +CONF_STRING = "string" +CONF_STRING_ENCODING = "string_encoding" +CONF_WRITE = "write" +CONF_WRITE_NO_RESPONSE = "write_no_response" + +# Internal configuration keys +CONF_CHAR_VALUE_ACTION_ID_ = "char_value_action_id_" + +# BLE reserverd UUIDs +CCCD_DESCRIPTOR_UUID = 0x2902 +CUD_DESCRIPTOR_UUID = 0x2901 +DEVICE_INFORMATION_SERVICE_UUID = 0x180A +MANUFACTURER_NAME_CHARACTERISTIC_UUID = 0x2A29 +MODEL_CHARACTERISTIC_UUID = 0x2A24 +FIRMWARE_VERSION_CHARACTERISTIC_UUID = 0x2A26 + +# Core key to store the global configuration +KEY_NOTIFY_REQUIRED = "notify_required" +KEY_SET_VALUE = "set_value" esp32_ble_server_ns = cg.esphome_ns.namespace("esp32_ble_server") +ESPBTUUID_ns = cg.esphome_ns.namespace("esp32_ble").namespace("ESPBTUUID") +BLECharacteristic_ns = esp32_ble_server_ns.namespace("BLECharacteristic") BLEServer = esp32_ble_server_ns.class_( "BLEServer", cg.Component, esp32_ble.GATTsEventHandler, cg.Parented.template(esp32_ble.ESP32BLE), ) -BLEServiceComponent = esp32_ble_server_ns.class_("BLEServiceComponent") +esp32_ble_server_automations_ns = esp32_ble_server_ns.namespace( + "esp32_ble_server_automations" +) +BLETriggers_ns = esp32_ble_server_automations_ns.namespace("BLETriggers") +BLEDescriptor = esp32_ble_server_ns.class_("BLEDescriptor") +BLECharacteristic = esp32_ble_server_ns.class_("BLECharacteristic") +BLEService = esp32_ble_server_ns.class_("BLEService") +BLECharacteristicSetValueAction = esp32_ble_server_automations_ns.class_( + "BLECharacteristicSetValueAction", automation.Action +) +BLEDescriptorSetValueAction = esp32_ble_server_automations_ns.class_( + "BLEDescriptorSetValueAction", automation.Action +) +BLECharacteristicNotifyAction = esp32_ble_server_automations_ns.class_( + "BLECharacteristicNotifyAction", automation.Action +) +bytebuffer_ns = cg.esphome_ns.namespace("bytebuffer") +Endianness_ns = bytebuffer_ns.namespace("Endian") +ByteBuffer_ns = bytebuffer_ns.namespace("ByteBuffer") +ByteBuffer = bytebuffer_ns.class_("ByteBuffer") +PROPERTY_MAP = { + CONF_READ: BLECharacteristic_ns.PROPERTY_READ, + CONF_WRITE: BLECharacteristic_ns.PROPERTY_WRITE, + CONF_NOTIFY: BLECharacteristic_ns.PROPERTY_NOTIFY, + CONF_BROADCAST: BLECharacteristic_ns.PROPERTY_BROADCAST, + CONF_INDICATE: BLECharacteristic_ns.PROPERTY_INDICATE, + CONF_WRITE_NO_RESPONSE: BLECharacteristic_ns.PROPERTY_WRITE_NR, +} + + +class ValueType: + def __init__(self, type_, validator, length): + self.type_ = type_ + self.validator = validator + self.length = length + + def validate(self, value, encoding): + value = self.validator(value) + if self.type_ == "string": + try: + value.encode(encoding) + except UnicodeEncodeError as e: + raise cv.Invalid(str(e)) from e + return value + + +VALUE_TYPES = { + type_name: ValueType(type_name, validator, length) + for type_name, validator, length in ( + ("uint8_t", cv.uint8_t, 1), + ("uint16_t", cv.uint16_t, 2), + ("uint32_t", cv.uint32_t, 4), + ("uint64_t", cv.uint64_t, 8), + ("int8_t", cv.int_range(-128, 127), 1), + ("int16_t", cv.int_range(-32768, 32767), 2), + ("int32_t", cv.int_range(-2147483648, 2147483647), 4), + ("int64_t", cv.int_range(-9223372036854775808, 9223372036854775807), 8), + ("float", cv.float_, 4), + ("double", cv.float_, 8), + ("string", cv.string_strict, None), # Length is variable + ) +} + + +def validate_char_on_write(char_config): + if CONF_ON_WRITE in char_config: + if not char_config[CONF_WRITE] and not char_config[CONF_WRITE_NO_RESPONSE]: + raise cv.Invalid( + f"{CONF_ON_WRITE} requires the {CONF_WRITE} or {CONF_WRITE_NO_RESPONSE} property to be set" + ) + return char_config + + +def validate_descriptor(desc_config): + if CONF_ON_WRITE in desc_config: + if not desc_config[CONF_WRITE]: + raise cv.Invalid( + f"{CONF_ON_WRITE} requires the {CONF_WRITE} property to be set" + ) + if CONF_MAX_LENGTH not in desc_config: + value = desc_config[CONF_VALUE][CONF_DATA] + if cg.is_template(value): + raise cv.Invalid( + f"Descriptor {desc_config[CONF_UUID]} has a templatable value and the {CONF_MAX_LENGTH} property is not set" + ) + if isinstance(value, list): + desc_config[CONF_MAX_LENGTH] = len(value) + elif isinstance(value, str): + desc_config[CONF_MAX_LENGTH] = len( + value.encode(desc_config[CONF_VALUE][CONF_STRING_ENCODING]) + ) + else: + desc_config[CONF_MAX_LENGTH] = VALUE_TYPES[ + desc_config[CONF_VALUE][CONF_TYPE] + ].length + return desc_config + + +def validate_notify_action(config): + # Store the characteristic ID in the global data for the final validation + data = CORE.data.setdefault(DOMAIN, {}).setdefault(KEY_NOTIFY_REQUIRED, set()) + data.add(config[CONF_ID]) + return config + + +def validate_set_value_action(config): + # Store the characteristic ID in the global data for the final validation + data = CORE.data.setdefault(DOMAIN, {}).setdefault(KEY_SET_VALUE, set()) + data.add(config[CONF_ID]) + return config + + +def create_description_cud(char_config): + if CONF_DESCRIPTION not in char_config: + return char_config + # If the config displays a description, there cannot be a descriptor with the CUD UUID + for desc in char_config[CONF_DESCRIPTORS]: + if desc[CONF_UUID] == CUD_DESCRIPTOR_UUID: + raise cv.Invalid( + f"Characteristic {char_config[CONF_UUID]} has a description, but a CUD descriptor is already present" + ) + # Manually add the CUD descriptor + char_config[CONF_DESCRIPTORS].append( + DESCRIPTOR_SCHEMA( + { + CONF_UUID: CUD_DESCRIPTOR_UUID, + CONF_READ: True, + CONF_WRITE: False, + CONF_VALUE: char_config[CONF_DESCRIPTION], + } + ) + ) + return char_config + + +def create_notify_cccd(char_config): + if not char_config[CONF_NOTIFY] and not char_config[CONF_INDICATE]: + return char_config + # If the CCCD descriptor is already present, return the config + for desc in char_config[CONF_DESCRIPTORS]: + if desc[CONF_UUID] == CCCD_DESCRIPTOR_UUID: + # Check if the WRITE property is set + if not desc[CONF_WRITE]: + raise cv.Invalid( + f"Characteristic {char_config[CONF_UUID]} has notify actions, but the CCCD descriptor does not have the {CONF_WRITE} property set" + ) + return char_config + # Manually add the CCCD descriptor + char_config[CONF_DESCRIPTORS].append( + DESCRIPTOR_SCHEMA( + { + CONF_UUID: CCCD_DESCRIPTOR_UUID, + CONF_READ: True, + CONF_WRITE: True, + CONF_MAX_LENGTH: 2, + CONF_VALUE: [0, 0], + } + ) + ) + return char_config + + +def create_device_information_service(config): + # If there is already a device information service, + # there cannot be CONF_MODEL, CONF_MANUFACTURER or CONF_FIRMWARE_VERSION properties + for service in config[CONF_SERVICES]: + if service[CONF_UUID] == DEVICE_INFORMATION_SERVICE_UUID: + if ( + CONF_MODEL in config + or CONF_MANUFACTURER in config + or CONF_FIRMWARE_VERSION in config + ): + raise cv.Invalid( + "Device information service already present, cannot add manufacturer, model or firmware version" + ) + return config + project = CORE.raw_config[CONF_ESPHOME].get(CONF_PROJECT, {}) + model = config.get(CONF_MODEL, project.get("name", CORE.data["esp32"]["board"])) + version = config.get( + CONF_FIRMWARE_VERSION, project.get("version", "ESPHome " + ESPHOME_VERSION) + ) + # Manually add the device information service + config[CONF_SERVICES].append( + SERVICE_SCHEMA( + { + CONF_UUID: DEVICE_INFORMATION_SERVICE_UUID, + CONF_CHARACTERISTICS: [ + { + CONF_UUID: MANUFACTURER_NAME_CHARACTERISTIC_UUID, + CONF_READ: True, + CONF_VALUE: config.get(CONF_MANUFACTURER, "ESPHome"), + }, + { + CONF_UUID: MODEL_CHARACTERISTIC_UUID, + CONF_READ: True, + CONF_VALUE: model, + }, + { + CONF_UUID: FIRMWARE_VERSION_CHARACTERISTIC_UUID, + CONF_READ: True, + CONF_VALUE: version, + }, + ], + } + ) + ) + return config + + +def final_validate_config(config): + # Check if all characteristics that require notifications have the notify property set + for char_id in CORE.data.get(DOMAIN, {}).get(KEY_NOTIFY_REQUIRED, set()): + # Look for the characteristic in the configuration + char_config = [ + char_conf + for service_conf in config[CONF_SERVICES] + for char_conf in service_conf[CONF_CHARACTERISTICS] + if char_conf[CONF_ID] == char_id + ][0] + if not char_config[CONF_NOTIFY]: + raise cv.Invalid( + f"Characteristic {char_config[CONF_UUID]} has notify actions and the {CONF_NOTIFY} property is not set" + ) + for char_id in CORE.data.get(DOMAIN, {}).get(KEY_SET_VALUE, set()): + # Look for the characteristic in the configuration + char_config = [ + char_conf + for service_conf in config[CONF_SERVICES] + for char_conf in service_conf[CONF_CHARACTERISTICS] + if char_conf[CONF_ID] == char_id + ][0] + if isinstance(char_config.get(CONF_VALUE, {}).get(CONF_DATA), cv.Lambda): + raise cv.Invalid( + f"Characteristic {char_config[CONF_UUID]} has both a set_value action and a templated value" + ) + return config + + +def validate_value_type(value_config): + # If the value is a not a templatable, the type must be set + value = value_config[CONF_DATA] + + if type_ := value_config.get(CONF_TYPE): + if cg.is_template(value): + raise cv.Invalid( + f'The "{CONF_TYPE}" property is not allowed for templatable values' + ) + value_config[CONF_DATA] = VALUE_TYPES[type_].validate( + value, value_config[CONF_STRING_ENCODING] + ) + elif isinstance(value, (float, int)): + raise cv.Invalid( + f'The "{CONF_TYPE}" property is required for the value "{value}"' + ) + return value_config + + +def validate_encoding(value): + if value == SCHEMA_EXTRACT: + return cv.one_of("utf-8", "latin-1", "ascii", "utf-16", "utf-32") + value = encodings.normalize_encoding(value) + if not value: + raise cv.Invalid("Invalid encoding") + return value + + +def value_schema(default_type=UNDEFINED, templatable=True): + data_validators = [ + cv.string_strict, + cv.int_, + cv.float_, + cv.All([cv.uint8_t], cv.Length(min=1)), + ] + if templatable: + data_validators.append(cv.returning_lambda) + + return cv.maybe_simple_value( + cv.All( + { + cv.Required(CONF_DATA): cv.Any(*data_validators), + cv.Optional(CONF_TYPE, default=default_type): cv.one_of( + *VALUE_TYPES, lower=True + ), + cv.Optional(CONF_STRING_ENCODING, default="utf_8"): validate_encoding, + cv.Optional(CONF_ENDIANNESS, default="LITTLE"): cv.enum( + { + "LITTLE": Endianness_ns.LITTLE, + "BIG": Endianness_ns.BIG, + } + ), + }, + validate_value_type, + ), + key=CONF_DATA, + ) + + +DESCRIPTOR_SCHEMA = cv.All( + { + cv.GenerateID(): cv.declare_id(BLEDescriptor), + cv.Required(CONF_UUID): cv.Any(bt_uuid, cv.hex_uint32_t), + cv.Optional(CONF_READ, default=True): cv.boolean, + cv.Optional(CONF_WRITE, default=True): cv.boolean, + cv.Optional(CONF_ON_WRITE): automation.validate_automation(single=True), + cv.Required(CONF_VALUE): value_schema(templatable=False), + cv.Optional(CONF_MAX_LENGTH): cv.uint16_t, + }, + validate_descriptor, +) + +CHARACTERISTIC_SCHEMA = cv.Schema( + { + cv.GenerateID(): cv.declare_id(BLECharacteristic), + cv.Required(CONF_UUID): cv.Any(bt_uuid, cv.hex_uint32_t), + cv.Optional(CONF_VALUE): value_schema(templatable=True), + cv.GenerateID(CONF_CHAR_VALUE_ACTION_ID_): cv.declare_id( + BLECharacteristicSetValueAction + ), + cv.Optional(CONF_DESCRIPTORS, default=[]): cv.ensure_list(DESCRIPTOR_SCHEMA), + cv.Optional(CONF_ON_WRITE): automation.validate_automation(single=True), + cv.Optional(CONF_DESCRIPTION): value_schema( + default_type="string", templatable=False + ), + }, + extra_schemas=[ + validate_char_on_write, + create_description_cud, + create_notify_cccd, + ], +).extend({cv.Optional(k, default=False): cv.boolean for k in PROPERTY_MAP}) + +SERVICE_SCHEMA = cv.Schema( + { + cv.GenerateID(): cv.declare_id(BLEService), + cv.Required(CONF_UUID): cv.Any(bt_uuid, cv.hex_uint32_t), + cv.Optional(CONF_ADVERTISE, default=False): cv.boolean, + cv.Optional(CONF_CHARACTERISTICS, default=[]): cv.ensure_list( + CHARACTERISTIC_SCHEMA + ), + } +) + CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(): cv.declare_id(BLEServer), cv.GenerateID(esp32_ble.CONF_BLE_ID): cv.use_id(esp32_ble.ESP32BLE), - cv.Optional(CONF_MANUFACTURER, default="ESPHome"): cv.string, - cv.Optional(CONF_MANUFACTURER_DATA): cv.Schema([cv.hex_uint8_t]), - cv.Optional(CONF_MODEL): cv.string, - } + cv.Optional(CONF_MANUFACTURER): value_schema("string", templatable=False), + cv.Optional(CONF_MODEL): value_schema("string", templatable=False), + cv.Optional(CONF_FIRMWARE_VERSION): value_schema("string", templatable=False), + cv.Optional(CONF_MANUFACTURER_DATA): cv.Schema([cv.uint8_t]), + cv.Optional(CONF_SERVICES, default=[]): cv.ensure_list(SERVICE_SCHEMA), + cv.Optional(CONF_ON_CONNECT): automation.validate_automation(single=True), + cv.Optional(CONF_ON_DISCONNECT): automation.validate_automation(single=True), + }, + extra_schemas=[create_device_information_service], ).extend(cv.COMPONENT_SCHEMA) +FINAL_VALIDATE_SCHEMA = final_validate_config + + +def parse_properties(char_conf): + return sum( + (PROPERTY_MAP[k] for k in char_conf if k in PROPERTY_MAP and char_conf[k]), + start=0, + ) + + +def parse_uuid(uuid): + # If the UUID is a int, use from_uint32 + if isinstance(uuid, int): + return ESPBTUUID_ns.from_uint32(uuid) + # Otherwise, use ESPBTUUID_ns.from_raw + return ESPBTUUID_ns.from_raw(uuid) + + +async def parse_value(value_config, args): + value = value_config[CONF_DATA] + if isinstance(value, cv.Lambda): + return await cg.templatable(value, args, cg.std_vector.template(cg.uint8)) + + if isinstance(value, str): + value = list(value.encode(value_config[CONF_STRING_ENCODING])) + if isinstance(value, list): + return cg.std_vector.template(cg.uint8)(value) + val = cg.RawExpression(f"{value_config[CONF_TYPE]}({cg.safe_exp(value)})") + return ByteBuffer_ns.wrap(val, value_config[CONF_ENDIANNESS]) + + +def calculate_num_handles(service_config): + total = 1 + len(service_config[CONF_CHARACTERISTICS]) * 2 + total += sum( + len(char_conf[CONF_DESCRIPTORS]) + for char_conf in service_config[CONF_CHARACTERISTICS] + ) + return total + + +async def to_code_descriptor(descriptor_conf, char_var): + value = await parse_value(descriptor_conf[CONF_VALUE], {}) + desc_var = cg.new_Pvariable( + descriptor_conf[CONF_ID], + parse_uuid(descriptor_conf[CONF_UUID]), + descriptor_conf[CONF_MAX_LENGTH], + descriptor_conf[CONF_READ], + descriptor_conf[CONF_WRITE], + ) + cg.add(char_var.add_descriptor(desc_var)) + cg.add(desc_var.set_value(value)) + if CONF_ON_WRITE in descriptor_conf: + on_write_conf = descriptor_conf[CONF_ON_WRITE] + await automation.build_automation( + BLETriggers_ns.create_descriptor_on_write_trigger(desc_var), + [(cg.std_vector.template(cg.uint8), "x"), (cg.uint16, "id")], + on_write_conf, + ) + + +async def to_code_characteristic(service_var, char_conf): + char_var = cg.Pvariable( + char_conf[CONF_ID], + service_var.create_characteristic( + parse_uuid(char_conf[CONF_UUID]), + parse_properties(char_conf), + ), + ) + if CONF_ON_WRITE in char_conf: + on_write_conf = char_conf[CONF_ON_WRITE] + await automation.build_automation( + BLETriggers_ns.create_characteristic_on_write_trigger(char_var), + [(cg.std_vector.template(cg.uint8), "x"), (cg.uint16, "id")], + on_write_conf, + ) + if CONF_VALUE in char_conf: + action_conf = { + CONF_ID: char_conf[CONF_ID], + CONF_VALUE: char_conf[CONF_VALUE], + } + value_action = await ble_server_characteristic_set_value( + action_conf, + char_conf[CONF_CHAR_VALUE_ACTION_ID_], + cg.TemplateArguments(), + {}, + ) + cg.add(value_action.play()) + for descriptor_conf in char_conf[CONF_DESCRIPTORS]: + await to_code_descriptor(descriptor_conf, char_var) + async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) @@ -42,13 +531,94 @@ async def to_code(config): cg.add(parent.register_gatts_event_handler(var)) cg.add(parent.register_ble_status_event_handler(var)) cg.add(var.set_parent(parent)) - - cg.add(var.set_manufacturer(config[CONF_MANUFACTURER])) if CONF_MANUFACTURER_DATA in config: cg.add(var.set_manufacturer_data(config[CONF_MANUFACTURER_DATA])) - if CONF_MODEL in config: - cg.add(var.set_model(config[CONF_MODEL])) + for service_config in config[CONF_SERVICES]: + # Calculate the optimal number of handles based on the number of characteristics and descriptors + num_handles = calculate_num_handles(service_config) + service_var = cg.Pvariable( + service_config[CONF_ID], + var.create_service( + parse_uuid(service_config[CONF_UUID]), + service_config[CONF_ADVERTISE], + num_handles, + ), + ) + for char_conf in service_config[CONF_CHARACTERISTICS]: + await to_code_characteristic(service_var, char_conf) + if service_config[CONF_UUID] == DEVICE_INFORMATION_SERVICE_UUID: + cg.add(var.set_device_information_service(service_var)) + else: + cg.add(var.enqueue_start_service(service_var)) + if CONF_ON_CONNECT in config: + await automation.build_automation( + BLETriggers_ns.create_server_on_connect_trigger(var), + [(cg.uint16, "id")], + config[CONF_ON_CONNECT], + ) + if CONF_ON_DISCONNECT in config: + await automation.build_automation( + BLETriggers_ns.create_server_on_disconnect_trigger(var), + [(cg.uint16, "id")], + config[CONF_ON_DISCONNECT], + ) cg.add_define("USE_ESP32_BLE_SERVER") - if CORE.using_esp_idf: add_idf_sdkconfig_option("CONFIG_BT_ENABLED", True) + + +@automation.register_action( + "ble_server.characteristic.set_value", + BLECharacteristicSetValueAction, + cv.All( + cv.Schema( + { + cv.Required(CONF_ID): cv.use_id(BLECharacteristic), + cv.Required(CONF_VALUE): value_schema(), + } + ), + validate_set_value_action, + ), +) +async def ble_server_characteristic_set_value(config, action_id, template_arg, args): + paren = await cg.get_variable(config[CONF_ID]) + var = cg.new_Pvariable(action_id, template_arg, paren) + value = await parse_value(config[CONF_VALUE], args) + cg.add(var.set_buffer(value)) + return var + + +@automation.register_action( + "ble_server.descriptor.set_value", + BLEDescriptorSetValueAction, + cv.Schema( + { + cv.Required(CONF_ID): cv.use_id(BLEDescriptor), + cv.Required(CONF_VALUE): value_schema(), + } + ), +) +async def ble_server_descriptor_set_value(config, action_id, template_arg, args): + paren = await cg.get_variable(config[CONF_ID]) + var = cg.new_Pvariable(action_id, template_arg, paren) + value = await parse_value(config[CONF_VALUE], args) + cg.add(var.set_buffer(value)) + return var + + +@automation.register_action( + "ble_server.characteristic.notify", + BLECharacteristicNotifyAction, + cv.All( + cv.Schema( + { + cv.Required(CONF_ID): cv.use_id(BLECharacteristic), + } + ), + validate_notify_action, + ), +) +async def ble_server_characteristic_notify(config, action_id, template_arg, args): + paren = await cg.get_variable(config[CONF_ID]) + var = cg.new_Pvariable(action_id, template_arg, paren) + return var diff --git a/esphome/components/esp32_ble_server/ble_2901.cpp b/esphome/components/esp32_ble_server/ble_2901.cpp deleted file mode 100644 index ee0808d2c4..0000000000 --- a/esphome/components/esp32_ble_server/ble_2901.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "ble_2901.h" -#include "esphome/components/esp32_ble/ble_uuid.h" - -#ifdef USE_ESP32 - -namespace esphome { -namespace esp32_ble_server { - -BLE2901::BLE2901(const std::string &value) : BLE2901((uint8_t *) value.data(), value.length()) {} -BLE2901::BLE2901(const uint8_t *data, size_t length) : BLEDescriptor(esp32_ble::ESPBTUUID::from_uint16(0x2901)) { - this->set_value(data, length); - this->permissions_ = ESP_GATT_PERM_READ; -} - -} // namespace esp32_ble_server -} // namespace esphome - -#endif diff --git a/esphome/components/esp32_ble_server/ble_2901.h b/esphome/components/esp32_ble_server/ble_2901.h deleted file mode 100644 index 60f53e55b2..0000000000 --- a/esphome/components/esp32_ble_server/ble_2901.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "ble_descriptor.h" - -#ifdef USE_ESP32 - -namespace esphome { -namespace esp32_ble_server { - -class BLE2901 : public BLEDescriptor { - public: - BLE2901(const std::string &value); - BLE2901(const uint8_t *data, size_t length); -}; - -} // namespace esp32_ble_server -} // namespace esphome - -#endif diff --git a/esphome/components/esp32_ble_server/ble_characteristic.cpp b/esphome/components/esp32_ble_server/ble_characteristic.cpp index 6ff7d615f9..15739d60bb 100644 --- a/esphome/components/esp32_ble_server/ble_characteristic.cpp +++ b/esphome/components/esp32_ble_server/ble_characteristic.cpp @@ -32,70 +32,36 @@ BLECharacteristic::BLECharacteristic(const ESPBTUUID uuid, uint32_t properties) this->set_write_no_response_property((properties & PROPERTY_WRITE_NR) != 0); } -void BLECharacteristic::set_value(std::vector value) { +void BLECharacteristic::set_value(ByteBuffer buffer) { this->set_value(buffer.get_data()); } + +void BLECharacteristic::set_value(const std::vector &buffer) { xSemaphoreTake(this->set_value_lock_, 0L); - this->value_ = std::move(value); + this->value_ = buffer; xSemaphoreGive(this->set_value_lock_); } -void BLECharacteristic::set_value(const std::string &value) { - this->set_value(std::vector(value.begin(), value.end())); -} -void BLECharacteristic::set_value(const uint8_t *data, size_t length) { - this->set_value(std::vector(data, data + length)); -} -void BLECharacteristic::set_value(uint8_t &data) { - uint8_t temp[1]; - temp[0] = data; - this->set_value(temp, 1); -} -void BLECharacteristic::set_value(uint16_t &data) { - uint8_t temp[2]; - temp[0] = data; - temp[1] = data >> 8; - this->set_value(temp, 2); -} -void BLECharacteristic::set_value(uint32_t &data) { - uint8_t temp[4]; - temp[0] = data; - temp[1] = data >> 8; - temp[2] = data >> 16; - temp[3] = data >> 24; - this->set_value(temp, 4); -} -void BLECharacteristic::set_value(int &data) { - uint8_t temp[4]; - temp[0] = data; - temp[1] = data >> 8; - temp[2] = data >> 16; - temp[3] = data >> 24; - this->set_value(temp, 4); -} -void BLECharacteristic::set_value(float &data) { - float temp = data; - this->set_value((uint8_t *) &temp, 4); -} -void BLECharacteristic::set_value(double &data) { - double temp = data; - this->set_value((uint8_t *) &temp, 8); -} -void BLECharacteristic::set_value(bool &data) { - uint8_t temp[1]; - temp[0] = data; - this->set_value(temp, 1); +void BLECharacteristic::set_value(const std::string &buffer) { + this->set_value(std::vector(buffer.begin(), buffer.end())); } -void BLECharacteristic::notify(bool notification) { - if (!notification) { - ESP_LOGW(TAG, "notification=false is not yet supported"); - // TODO: Handle when notification=false - } - if (this->service_->get_server()->get_connected_client_count() == 0) +void BLECharacteristic::notify() { + if (this->service_ == nullptr || this->service_->get_server() == nullptr || + this->service_->get_server()->get_connected_client_count() == 0) return; for (auto &client : this->service_->get_server()->get_clients()) { size_t length = this->value_.size(); - esp_err_t err = esp_ble_gatts_send_indicate(this->service_->get_server()->get_gatts_if(), client.first, - this->handle_, length, this->value_.data(), false); + // If the client is not in the list of clients to notify, skip it + if (this->clients_to_notify_.count(client) == 0) + continue; + // If the client is in the list of clients to notify, check if it requires an ack (i.e. INDICATE) + bool require_ack = this->clients_to_notify_[client]; + // TODO: Remove this block when INDICATE acknowledgment is supported + if (require_ack) { + ESP_LOGW(TAG, "INDICATE acknowledgment is not yet supported (i.e. it works as a NOTIFY)"); + require_ack = false; + } + esp_err_t err = esp_ble_gatts_send_indicate(this->service_->get_server()->get_gatts_if(), client, this->handle_, + length, this->value_.data(), require_ack); if (err != ESP_OK) { ESP_LOGE(TAG, "esp_ble_gatts_send_indicate failed %d", err); return; @@ -103,7 +69,24 @@ void BLECharacteristic::notify(bool notification) { } } -void BLECharacteristic::add_descriptor(BLEDescriptor *descriptor) { this->descriptors_.push_back(descriptor); } +void BLECharacteristic::add_descriptor(BLEDescriptor *descriptor) { + // If the descriptor is the CCCD descriptor, listen to its write event to know if the client wants to be notified + if (descriptor->get_uuid() == ESPBTUUID::from_uint16(ESP_GATT_UUID_CHAR_CLIENT_CONFIG)) { + descriptor->on(BLEDescriptorEvt::VectorEvt::ON_WRITE, [this](const std::vector &value, uint16_t conn_id) { + if (value.size() != 2) + return; + uint16_t cccd = encode_uint16(value[1], value[0]); + bool notify = (cccd & 1) != 0; + bool indicate = (cccd & 2) != 0; + if (notify || indicate) { + this->clients_to_notify_[conn_id] = indicate; + } else { + this->clients_to_notify_.erase(conn_id); + } + }); + } + this->descriptors_.push_back(descriptor); +} void BLECharacteristic::remove_descriptor(BLEDescriptor *descriptor) { this->descriptors_.erase(std::remove(this->descriptors_.begin(), this->descriptors_.end(), descriptor), @@ -223,6 +206,9 @@ void BLECharacteristic::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt if (!param->read.need_rsp) break; // For some reason you can request a read but not want a response + this->EventEmitter::emit_(BLECharacteristicEvt::EmptyEvt::ON_READ, + param->read.conn_id); + uint16_t max_offset = 22; esp_gatt_rsp_t response; @@ -262,13 +248,13 @@ void BLECharacteristic::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt } case ESP_GATTS_WRITE_EVT: { if (this->handle_ != param->write.handle) - return; + break; if (param->write.is_prep) { this->value_.insert(this->value_.end(), param->write.value, param->write.value + param->write.len); this->write_event_ = true; } else { - this->set_value(param->write.value, param->write.len); + this->set_value(ByteBuffer::wrap(param->write.value, param->write.len)); } if (param->write.need_rsp) { @@ -289,7 +275,8 @@ void BLECharacteristic::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt } if (!param->write.is_prep) { - this->on_write_(this->value_); + this->EventEmitter, uint16_t>::emit_( + BLECharacteristicEvt::VectorEvt::ON_WRITE, this->value_, param->write.conn_id); } break; @@ -300,7 +287,8 @@ void BLECharacteristic::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt break; this->write_event_ = false; if (param->exec_write.exec_write_flag == ESP_GATT_PREP_WRITE_EXEC) { - this->on_write_(this->value_); + this->EventEmitter, uint16_t>::emit_( + BLECharacteristicEvt::VectorEvt::ON_WRITE, this->value_, param->exec_write.conn_id); } esp_err_t err = esp_ble_gatts_send_response(gatts_if, param->write.conn_id, param->write.trans_id, ESP_GATT_OK, nullptr); diff --git a/esphome/components/esp32_ble_server/ble_characteristic.h b/esphome/components/esp32_ble_server/ble_characteristic.h index 8837c796a5..3698b8c4aa 100644 --- a/esphome/components/esp32_ble_server/ble_characteristic.h +++ b/esphome/components/esp32_ble_server/ble_characteristic.h @@ -2,8 +2,11 @@ #include "ble_descriptor.h" #include "esphome/components/esp32_ble/ble_uuid.h" +#include "esphome/components/event_emitter/event_emitter.h" +#include "esphome/components/bytebuffer/bytebuffer.h" #include +#include #ifdef USE_ESP32 @@ -19,24 +22,30 @@ namespace esphome { namespace esp32_ble_server { using namespace esp32_ble; +using namespace bytebuffer; +using namespace event_emitter; class BLEService; -class BLECharacteristic { +namespace BLECharacteristicEvt { +enum VectorEvt { + ON_WRITE, +}; + +enum EmptyEvt { + ON_READ, +}; +} // namespace BLECharacteristicEvt + +class BLECharacteristic : public EventEmitter, uint16_t>, + public EventEmitter { public: BLECharacteristic(ESPBTUUID uuid, uint32_t properties); ~BLECharacteristic(); - void set_value(const uint8_t *data, size_t length); - void set_value(std::vector value); - void set_value(const std::string &value); - void set_value(uint8_t &data); - void set_value(uint16_t &data); - void set_value(uint32_t &data); - void set_value(int &data); - void set_value(float &data); - void set_value(double &data); - void set_value(bool &data); + void set_value(ByteBuffer buffer); + void set_value(const std::vector &buffer); + void set_value(const std::string &buffer); void set_broadcast_property(bool value); void set_indicate_property(bool value); @@ -45,13 +54,12 @@ class BLECharacteristic { void set_write_property(bool value); void set_write_no_response_property(bool value); - void notify(bool notification = true); + void notify(); void do_create(BLEService *service); + void do_delete() { this->clients_to_notify_.clear(); } void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param); - void on_write(const std::function &)> &&func) { this->on_write_ = func; } - void add_descriptor(BLEDescriptor *descriptor); void remove_descriptor(BLEDescriptor *descriptor); @@ -71,7 +79,7 @@ class BLECharacteristic { protected: bool write_event_{false}; - BLEService *service_; + BLEService *service_{}; ESPBTUUID uuid_; esp_gatt_char_prop_t properties_; uint16_t handle_{0xFFFF}; @@ -81,8 +89,7 @@ class BLECharacteristic { SemaphoreHandle_t set_value_lock_; std::vector descriptors_; - - std::function &)> on_write_; + std::unordered_map clients_to_notify_; esp_gatt_perm_t permissions_ = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE; diff --git a/esphome/components/esp32_ble_server/ble_descriptor.cpp b/esphome/components/esp32_ble_server/ble_descriptor.cpp index bfb6224335..afbe579513 100644 --- a/esphome/components/esp32_ble_server/ble_descriptor.cpp +++ b/esphome/components/esp32_ble_server/ble_descriptor.cpp @@ -12,11 +12,19 @@ namespace esp32_ble_server { static const char *const TAG = "esp32_ble_server.descriptor"; -BLEDescriptor::BLEDescriptor(ESPBTUUID uuid, uint16_t max_len) { +static RAMAllocator descriptor_allocator{}; // NOLINT + +BLEDescriptor::BLEDescriptor(ESPBTUUID uuid, uint16_t max_len, bool read, bool write) { this->uuid_ = uuid; this->value_.attr_len = 0; this->value_.attr_max_len = max_len; - this->value_.attr_value = (uint8_t *) malloc(max_len); // NOLINT + this->value_.attr_value = descriptor_allocator.allocate(max_len); + if (read) { + this->permissions_ |= ESP_GATT_PERM_READ; + } + if (write) { + this->permissions_ |= ESP_GATT_PERM_WRITE; + } } BLEDescriptor::~BLEDescriptor() { free(this->value_.attr_value); } // NOLINT @@ -38,14 +46,15 @@ void BLEDescriptor::do_create(BLECharacteristic *characteristic) { this->state_ = CREATING; } -void BLEDescriptor::set_value(const std::string &value) { this->set_value((uint8_t *) value.data(), value.length()); } -void BLEDescriptor::set_value(const uint8_t *data, size_t length) { +void BLEDescriptor::set_value(std::vector buffer) { + size_t length = buffer.size(); + if (length > this->value_.attr_max_len) { ESP_LOGE(TAG, "Size %d too large, must be no bigger than %d", length, this->value_.attr_max_len); return; } this->value_.attr_len = length; - memcpy(this->value_.attr_value, data, length); + memcpy(this->value_.attr_value, buffer.data(), length); } void BLEDescriptor::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, @@ -61,10 +70,13 @@ void BLEDescriptor::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_ break; } case ESP_GATTS_WRITE_EVT: { - if (this->handle_ == param->write.handle) { - this->value_.attr_len = param->write.len; - memcpy(this->value_.attr_value, param->write.value, param->write.len); - } + if (this->handle_ != param->write.handle) + break; + this->value_.attr_len = param->write.len; + memcpy(this->value_.attr_value, param->write.value, param->write.len); + this->emit_(BLEDescriptorEvt::VectorEvt::ON_WRITE, + std::vector(param->write.value, param->write.value + param->write.len), + param->write.conn_id); break; } default: diff --git a/esphome/components/esp32_ble_server/ble_descriptor.h b/esphome/components/esp32_ble_server/ble_descriptor.h index 4b8fb345c3..8d3c22c5a1 100644 --- a/esphome/components/esp32_ble_server/ble_descriptor.h +++ b/esphome/components/esp32_ble_server/ble_descriptor.h @@ -1,6 +1,8 @@ #pragma once #include "esphome/components/esp32_ble/ble_uuid.h" +#include "esphome/components/event_emitter/event_emitter.h" +#include "esphome/components/bytebuffer/bytebuffer.h" #ifdef USE_ESP32 @@ -11,17 +13,26 @@ namespace esphome { namespace esp32_ble_server { using namespace esp32_ble; +using namespace bytebuffer; +using namespace event_emitter; class BLECharacteristic; -class BLEDescriptor { +namespace BLEDescriptorEvt { +enum VectorEvt { + ON_WRITE, +}; +} // namespace BLEDescriptorEvt + +class BLEDescriptor : public EventEmitter, uint16_t> { public: - BLEDescriptor(ESPBTUUID uuid, uint16_t max_len = 100); + BLEDescriptor(ESPBTUUID uuid, uint16_t max_len = 100, bool read = true, bool write = true); virtual ~BLEDescriptor(); void do_create(BLECharacteristic *characteristic); + ESPBTUUID get_uuid() const { return this->uuid_; } - void set_value(const std::string &value); - void set_value(const uint8_t *data, size_t length); + void set_value(std::vector buffer); + void set_value(ByteBuffer buffer) { this->set_value(buffer.get_data()); } void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param); @@ -33,9 +44,9 @@ class BLEDescriptor { ESPBTUUID uuid_; uint16_t handle_{0xFFFF}; - esp_attr_value_t value_; + esp_attr_value_t value_{}; - esp_gatt_perm_t permissions_ = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE; + esp_gatt_perm_t permissions_{}; enum State : uint8_t { FAILED = 0x00, diff --git a/esphome/components/esp32_ble_server/ble_server.cpp b/esphome/components/esp32_ble_server/ble_server.cpp index 338413f64e..5339bf8aed 100644 --- a/esphome/components/esp32_ble_server/ble_server.cpp +++ b/esphome/components/esp32_ble_server/ble_server.cpp @@ -19,11 +19,6 @@ namespace esp32_ble_server { static const char *const TAG = "esp32_ble_server"; -static const uint16_t DEVICE_INFORMATION_SERVICE_UUID = 0x180A; -static const uint16_t MODEL_UUID = 0x2A24; -static const uint16_t VERSION_UUID = 0x2A26; -static const uint16_t MANUFACTURER_UUID = 0x2A29; - void BLEServer::setup() { if (this->parent_->is_failed()) { this->mark_failed(); @@ -38,9 +33,27 @@ void BLEServer::loop() { return; } switch (this->state_) { - case RUNNING: - return; - + case RUNNING: { + // Start all services that are pending to start + if (!this->services_to_start_.empty()) { + uint16_t index_to_remove = 0; + // Iterate over the services to start + for (unsigned i = 0; i < this->services_to_start_.size(); i++) { + BLEService *service = this->services_to_start_[i]; + if (service->is_created()) { + service->start(); // Needs to be called once per characteristic in the service + } else { + index_to_remove = i + 1; + } + } + // Remove the services that have been started + if (index_to_remove > 0) { + this->services_to_start_.erase(this->services_to_start_.begin(), + this->services_to_start_.begin() + index_to_remove - 1); + } + } + break; + } case INIT: { esp_err_t err = esp_ble_gatts_app_register(0); if (err != ESP_OK) { @@ -53,29 +66,26 @@ void BLEServer::loop() { } case REGISTERING: { if (this->registered_) { + // Create the device information service first so + // it is at the top of the GATT table + this->device_information_service_->do_create(this); // Create all services previously created for (auto &pair : this->services_) { + if (pair.second == this->device_information_service_) { + continue; + } pair.second->do_create(this); } - if (this->device_information_service_ == nullptr) { - this->create_service(ESPBTUUID::from_uint16(DEVICE_INFORMATION_SERVICE_UUID)); - this->device_information_service_ = - this->get_service(ESPBTUUID::from_uint16(DEVICE_INFORMATION_SERVICE_UUID)); - this->create_device_characteristics_(); - } this->state_ = STARTING_SERVICE; } break; } case STARTING_SERVICE: { - if (!this->device_information_service_->is_created()) { - break; - } if (this->device_information_service_->is_running()) { this->state_ = RUNNING; this->restart_advertising_(); ESP_LOGD(TAG, "BLE server setup successfully"); - } else if (!this->device_information_service_->is_starting()) { + } else if (this->device_information_service_->is_created()) { this->device_information_service_->start(); } break; @@ -93,81 +103,66 @@ void BLEServer::restart_advertising_() { } } -bool BLEServer::create_device_characteristics_() { - if (this->model_.has_value()) { - BLECharacteristic *model = - this->device_information_service_->create_characteristic(MODEL_UUID, BLECharacteristic::PROPERTY_READ); - model->set_value(this->model_.value()); - } else { - BLECharacteristic *model = - this->device_information_service_->create_characteristic(MODEL_UUID, BLECharacteristic::PROPERTY_READ); - model->set_value(ESPHOME_BOARD); - } - - BLECharacteristic *version = - this->device_information_service_->create_characteristic(VERSION_UUID, BLECharacteristic::PROPERTY_READ); - version->set_value("ESPHome " ESPHOME_VERSION); - - BLECharacteristic *manufacturer = - this->device_information_service_->create_characteristic(MANUFACTURER_UUID, BLECharacteristic::PROPERTY_READ); - manufacturer->set_value(this->manufacturer_); - - return true; -} - -void BLEServer::create_service(ESPBTUUID uuid, bool advertise, uint16_t num_handles, uint8_t inst_id) { +BLEService *BLEServer::create_service(ESPBTUUID uuid, bool advertise, uint16_t num_handles) { ESP_LOGV(TAG, "Creating BLE service - %s", uuid.to_string().c_str()); - // If the service already exists, do nothing - BLEService *service = this->get_service(uuid); - if (service != nullptr) { - ESP_LOGW(TAG, "BLE service %s already exists", uuid.to_string().c_str()); - return; + // Calculate the inst_id for the service + uint8_t inst_id = 0; + for (; inst_id < 0xFF; inst_id++) { + if (this->get_service(uuid, inst_id) == nullptr) { + break; + } } - service = new BLEService(uuid, num_handles, inst_id, advertise); // NOLINT(cppcoreguidelines-owning-memory) - this->services_.emplace(uuid.to_string(), service); - service->do_create(this); + if (inst_id == 0xFF) { + ESP_LOGW(TAG, "Could not create BLE service %s, too many instances", uuid.to_string().c_str()); + return nullptr; + } + BLEService *service = // NOLINT(cppcoreguidelines-owning-memory) + new BLEService(uuid, num_handles, inst_id, advertise); + this->services_.emplace(BLEServer::get_service_key(uuid, inst_id), service); + if (this->parent_->is_active() && this->registered_) { + service->do_create(this); + } + return service; } -void BLEServer::remove_service(ESPBTUUID uuid) { - ESP_LOGV(TAG, "Removing BLE service - %s", uuid.to_string().c_str()); - BLEService *service = this->get_service(uuid); +void BLEServer::remove_service(ESPBTUUID uuid, uint8_t inst_id) { + ESP_LOGV(TAG, "Removing BLE service - %s %d", uuid.to_string().c_str(), inst_id); + BLEService *service = this->get_service(uuid, inst_id); if (service == nullptr) { - ESP_LOGW(TAG, "BLE service %s not found", uuid.to_string().c_str()); + ESP_LOGW(TAG, "BLE service %s %d does not exist", uuid.to_string().c_str(), inst_id); return; } service->do_delete(); delete service; // NOLINT(cppcoreguidelines-owning-memory) - this->services_.erase(uuid.to_string()); + this->services_.erase(BLEServer::get_service_key(uuid, inst_id)); } -BLEService *BLEServer::get_service(ESPBTUUID uuid) { +BLEService *BLEServer::get_service(ESPBTUUID uuid, uint8_t inst_id) { BLEService *service = nullptr; - if (this->services_.count(uuid.to_string()) > 0) { - service = this->services_.at(uuid.to_string()); + if (this->services_.count(BLEServer::get_service_key(uuid, inst_id)) > 0) { + service = this->services_.at(BLEServer::get_service_key(uuid, inst_id)); } return service; } +std::string BLEServer::get_service_key(ESPBTUUID uuid, uint8_t inst_id) { + return uuid.to_string() + std::to_string(inst_id); +} + void BLEServer::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) { switch (event) { case ESP_GATTS_CONNECT_EVT: { ESP_LOGD(TAG, "BLE Client connected"); - this->add_client_(param->connect.conn_id, (void *) this); - this->connected_clients_++; - for (auto *component : this->service_components_) { - component->on_client_connect(); - } + this->add_client_(param->connect.conn_id); + this->emit_(BLEServerEvt::EmptyEvt::ON_CONNECT, param->connect.conn_id); break; } case ESP_GATTS_DISCONNECT_EVT: { ESP_LOGD(TAG, "BLE Client disconnected"); - if (this->remove_client_(param->disconnect.conn_id)) - this->connected_clients_--; + this->remove_client_(param->disconnect.conn_id); this->parent_->advertising_start(); - for (auto *component : this->service_components_) { - component->on_client_disconnect(); - } + this->emit_(BLEServerEvt::EmptyEvt::ON_DISCONNECT, param->disconnect.conn_id); break; } case ESP_GATTS_REG_EVT: { diff --git a/esphome/components/esp32_ble_server/ble_server.h b/esphome/components/esp32_ble_server/ble_server.h index e379e67296..43599438f3 100644 --- a/esphome/components/esp32_ble_server/ble_server.h +++ b/esphome/components/esp32_ble_server/ble_server.h @@ -4,36 +4,38 @@ #include "ble_characteristic.h" #include "esphome/components/esp32_ble/ble.h" -#include "esphome/components/esp32_ble/ble_advertising.h" #include "esphome/components/esp32_ble/ble_uuid.h" -#include "esphome/components/esp32_ble/queue.h" +#include "esphome/components/bytebuffer/bytebuffer.h" #include "esphome/core/component.h" #include "esphome/core/helpers.h" -#include "esphome/core/preferences.h" #include #include #include +#include #ifdef USE_ESP32 -#include #include namespace esphome { namespace esp32_ble_server { using namespace esp32_ble; +using namespace bytebuffer; -class BLEServiceComponent { - public: - virtual void on_client_connect(){}; - virtual void on_client_disconnect(){}; - virtual void start(); - virtual void stop(); +namespace BLEServerEvt { +enum EmptyEvt { + ON_CONNECT, + ON_DISCONNECT, }; +} // namespace BLEServerEvt -class BLEServer : public Component, public GATTsEventHandler, public BLEStatusEventHandler, public Parented { +class BLEServer : public Component, + public GATTsEventHandler, + public BLEStatusEventHandler, + public Parented, + public EventEmitter { public: void setup() override; void loop() override; @@ -44,47 +46,41 @@ class BLEServer : public Component, public GATTsEventHandler, public BLEStatusEv void teardown(); bool is_running(); - void set_manufacturer(const std::string &manufacturer) { this->manufacturer_ = manufacturer; } - void set_model(const std::string &model) { this->model_ = model; } void set_manufacturer_data(const std::vector &data) { this->manufacturer_data_ = data; this->restart_advertising_(); } - void create_service(ESPBTUUID uuid, bool advertise = false, uint16_t num_handles = 15, uint8_t inst_id = 0); - void remove_service(ESPBTUUID uuid); - BLEService *get_service(ESPBTUUID uuid); + BLEService *create_service(ESPBTUUID uuid, bool advertise = false, uint16_t num_handles = 15); + void remove_service(ESPBTUUID uuid, uint8_t inst_id = 0); + BLEService *get_service(ESPBTUUID uuid, uint8_t inst_id = 0); + void enqueue_start_service(BLEService *service) { this->services_to_start_.push_back(service); } + void set_device_information_service(BLEService *service) { this->device_information_service_ = service; } esp_gatt_if_t get_gatts_if() { return this->gatts_if_; } - uint32_t get_connected_client_count() { return this->connected_clients_; } - const std::unordered_map &get_clients() { return this->clients_; } + uint32_t get_connected_client_count() { return this->clients_.size(); } + const std::unordered_set &get_clients() { return this->clients_; } void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param) override; void ble_before_disabled_event_handler() override; - void register_service_component(BLEServiceComponent *component) { this->service_components_.push_back(component); } - protected: - bool create_device_characteristics_(); + static std::string get_service_key(ESPBTUUID uuid, uint8_t inst_id); void restart_advertising_(); - void add_client_(uint16_t conn_id, void *client) { this->clients_.emplace(conn_id, client); } - bool remove_client_(uint16_t conn_id) { return this->clients_.erase(conn_id) > 0; } + void add_client_(uint16_t conn_id) { this->clients_.insert(conn_id); } + void remove_client_(uint16_t conn_id) { this->clients_.erase(conn_id); } - std::string manufacturer_; - optional model_; - std::vector manufacturer_data_; + std::vector manufacturer_data_{}; esp_gatt_if_t gatts_if_{0}; bool registered_{false}; - uint32_t connected_clients_{0}; - std::unordered_map clients_; - std::unordered_map services_; - BLEService *device_information_service_; - - std::vector service_components_; + std::unordered_set clients_; + std::unordered_map services_{}; + std::vector services_to_start_{}; + BLEService *device_information_service_{}; enum State : uint8_t { INIT = 0x00, diff --git a/esphome/components/esp32_ble_server/ble_server_automations.cpp b/esphome/components/esp32_ble_server/ble_server_automations.cpp new file mode 100644 index 0000000000..41ef2b8bfe --- /dev/null +++ b/esphome/components/esp32_ble_server/ble_server_automations.cpp @@ -0,0 +1,77 @@ +#include "ble_server_automations.h" + +#ifdef USE_ESP32 + +namespace esphome { +namespace esp32_ble_server { +// Interface to interact with ESPHome automations and triggers +namespace esp32_ble_server_automations { + +using namespace esp32_ble; + +Trigger, uint16_t> *BLETriggers::create_characteristic_on_write_trigger( + BLECharacteristic *characteristic) { + Trigger, uint16_t> *on_write_trigger = // NOLINT(cppcoreguidelines-owning-memory) + new Trigger, uint16_t>(); + characteristic->EventEmitter, uint16_t>::on( + BLECharacteristicEvt::VectorEvt::ON_WRITE, + [on_write_trigger](const std::vector &data, uint16_t id) { on_write_trigger->trigger(data, id); }); + return on_write_trigger; +} + +Trigger, uint16_t> *BLETriggers::create_descriptor_on_write_trigger(BLEDescriptor *descriptor) { + Trigger, uint16_t> *on_write_trigger = // NOLINT(cppcoreguidelines-owning-memory) + new Trigger, uint16_t>(); + descriptor->on( + BLEDescriptorEvt::VectorEvt::ON_WRITE, + [on_write_trigger](const std::vector &data, uint16_t id) { on_write_trigger->trigger(data, id); }); + return on_write_trigger; +} + +Trigger *BLETriggers::create_server_on_connect_trigger(BLEServer *server) { + Trigger *on_connect_trigger = new Trigger(); // NOLINT(cppcoreguidelines-owning-memory) + server->on(BLEServerEvt::EmptyEvt::ON_CONNECT, + [on_connect_trigger](uint16_t conn_id) { on_connect_trigger->trigger(conn_id); }); + return on_connect_trigger; +} + +Trigger *BLETriggers::create_server_on_disconnect_trigger(BLEServer *server) { + Trigger *on_disconnect_trigger = new Trigger(); // NOLINT(cppcoreguidelines-owning-memory) + server->on(BLEServerEvt::EmptyEvt::ON_DISCONNECT, + [on_disconnect_trigger](uint16_t conn_id) { on_disconnect_trigger->trigger(conn_id); }); + return on_disconnect_trigger; +} + +void BLECharacteristicSetValueActionManager::set_listener(BLECharacteristic *characteristic, + EventEmitterListenerID listener_id, + const std::function &pre_notify_listener) { + // Check if there is already a listener for this characteristic + if (this->listeners_.count(characteristic) > 0) { + // Unpack the pair listener_id, pre_notify_listener_id + auto listener_pairs = this->listeners_[characteristic]; + EventEmitterListenerID old_listener_id = listener_pairs.first; + EventEmitterListenerID old_pre_notify_listener_id = listener_pairs.second; + // Remove the previous listener + characteristic->EventEmitter::off(BLECharacteristicEvt::EmptyEvt::ON_READ, + old_listener_id); + // Remove the pre-notify listener + this->off(BLECharacteristicSetValueActionEvt::PRE_NOTIFY, old_pre_notify_listener_id); + } + // Create a new listener for the pre-notify event + EventEmitterListenerID pre_notify_listener_id = + this->on(BLECharacteristicSetValueActionEvt::PRE_NOTIFY, + [pre_notify_listener, characteristic](const BLECharacteristic *evt_characteristic) { + // Only call the pre-notify listener if the characteristic is the one we are interested in + if (characteristic == evt_characteristic) { + pre_notify_listener(); + } + }); + // Save the pair listener_id, pre_notify_listener_id to the map + this->listeners_[characteristic] = std::make_pair(listener_id, pre_notify_listener_id); +} + +} // namespace esp32_ble_server_automations +} // namespace esp32_ble_server +} // namespace esphome + +#endif diff --git a/esphome/components/esp32_ble_server/ble_server_automations.h b/esphome/components/esp32_ble_server/ble_server_automations.h new file mode 100644 index 0000000000..eab6b05f05 --- /dev/null +++ b/esphome/components/esp32_ble_server/ble_server_automations.h @@ -0,0 +1,115 @@ +#pragma once + +#include "ble_server.h" +#include "ble_characteristic.h" +#include "ble_descriptor.h" + +#include "esphome/components/event_emitter/event_emitter.h" +#include "esphome/core/automation.h" + +#include +#include +#include + +#ifdef USE_ESP32 + +namespace esphome { +namespace esp32_ble_server { +// Interface to interact with ESPHome actions and triggers +namespace esp32_ble_server_automations { + +using namespace esp32_ble; +using namespace event_emitter; + +class BLETriggers { + public: + static Trigger, uint16_t> *create_characteristic_on_write_trigger( + BLECharacteristic *characteristic); + static Trigger, uint16_t> *create_descriptor_on_write_trigger(BLEDescriptor *descriptor); + static Trigger *create_server_on_connect_trigger(BLEServer *server); + static Trigger *create_server_on_disconnect_trigger(BLEServer *server); +}; + +enum BLECharacteristicSetValueActionEvt { + PRE_NOTIFY, +}; + +// Class to make sure only one BLECharacteristicSetValueAction is active at a time for each characteristic +class BLECharacteristicSetValueActionManager + : public EventEmitter { + public: + // Singleton pattern + static BLECharacteristicSetValueActionManager *get_instance() { + static BLECharacteristicSetValueActionManager instance; + return &instance; + } + void set_listener(BLECharacteristic *characteristic, EventEmitterListenerID listener_id, + const std::function &pre_notify_listener); + EventEmitterListenerID get_listener(BLECharacteristic *characteristic) { + return this->listeners_[characteristic].first; + } + void emit_pre_notify(BLECharacteristic *characteristic) { + this->emit_(BLECharacteristicSetValueActionEvt::PRE_NOTIFY, characteristic); + } + + private: + std::unordered_map> listeners_; +}; + +template class BLECharacteristicSetValueAction : public Action { + public: + BLECharacteristicSetValueAction(BLECharacteristic *characteristic) : parent_(characteristic) {} + TEMPLATABLE_VALUE(std::vector, buffer) + void set_buffer(ByteBuffer buffer) { this->set_buffer(buffer.get_data()); } + void play(Ts... x) override { + // If the listener is already set, do nothing + if (BLECharacteristicSetValueActionManager::get_instance()->get_listener(this->parent_) == this->listener_id_) + return; + // Set initial value + this->parent_->set_value(this->buffer_.value(x...)); + // Set the listener for read events + this->listener_id_ = this->parent_->EventEmitter::on( + BLECharacteristicEvt::EmptyEvt::ON_READ, [this, x...](uint16_t id) { + // Set the value of the characteristic every time it is read + this->parent_->set_value(this->buffer_.value(x...)); + }); + // Set the listener in the global manager so only one BLECharacteristicSetValueAction is set for each characteristic + BLECharacteristicSetValueActionManager::get_instance()->set_listener( + this->parent_, this->listener_id_, [this, x...]() { this->parent_->set_value(this->buffer_.value(x...)); }); + } + + protected: + BLECharacteristic *parent_; + EventEmitterListenerID listener_id_; +}; + +template class BLECharacteristicNotifyAction : public Action { + public: + BLECharacteristicNotifyAction(BLECharacteristic *characteristic) : parent_(characteristic) {} + void play(Ts... x) override { + // Call the pre-notify event + BLECharacteristicSetValueActionManager::get_instance()->emit_pre_notify(this->parent_); + // Notify the characteristic + this->parent_->notify(); + } + + protected: + BLECharacteristic *parent_; +}; + +template class BLEDescriptorSetValueAction : public Action { + public: + BLEDescriptorSetValueAction(BLEDescriptor *descriptor) : parent_(descriptor) {} + TEMPLATABLE_VALUE(std::vector, buffer) + void set_buffer(ByteBuffer buffer) { this->set_buffer(buffer.get_data()); } + void play(Ts... x) override { this->parent_->set_value(this->buffer_.value(x...)); } + + protected: + BLEDescriptor *parent_; +}; + +} // namespace esp32_ble_server_automations +} // namespace esp32_ble_server +} // namespace esphome + +#endif diff --git a/esphome/components/esp32_ble_server/ble_service.cpp b/esphome/components/esp32_ble_server/ble_service.cpp index 368f03fb52..96fedf2346 100644 --- a/esphome/components/esp32_ble_server/ble_service.cpp +++ b/esphome/components/esp32_ble_server/ble_service.cpp @@ -52,18 +52,21 @@ void BLEService::do_create(BLEServer *server) { esp_err_t err = esp_ble_gatts_create_service(server->get_gatts_if(), &srvc_id, this->num_handles_); if (err != ESP_OK) { ESP_LOGE(TAG, "esp_ble_gatts_create_service failed: %d", err); - this->init_state_ = FAILED; + this->state_ = FAILED; return; } - this->init_state_ = CREATING; + this->state_ = CREATING; } void BLEService::do_delete() { - if (this->init_state_ == DELETING || this->init_state_ == DELETED) + if (this->state_ == DELETING || this->state_ == DELETED) return; - this->init_state_ = DELETING; + this->state_ = DELETING; this->created_characteristic_count_ = 0; this->last_created_characteristic_ = nullptr; + // Call all characteristics to delete + for (auto *characteristic : this->characteristics_) + characteristic->do_delete(); this->stop_(); esp_err_t err = esp_ble_gatts_delete_service(this->handle_); if (err != ESP_OK) { @@ -91,6 +94,7 @@ void BLEService::start() { return; should_start_ = true; + this->state_ = STARTING; esp_err_t err = esp_ble_gatts_start_service(this->handle_); if (err != ESP_OK) { ESP_LOGE(TAG, "esp_ble_gatts_start_service failed: %d", err); @@ -98,7 +102,6 @@ void BLEService::start() { } if (this->advertise_) esp32_ble::global_ble->advertising_add_service_uuid(this->uuid_); - this->running_state_ = STARTING; } void BLEService::stop() { @@ -107,9 +110,9 @@ void BLEService::stop() { } void BLEService::stop_() { - if (this->running_state_ == STOPPING || this->running_state_ == STOPPED) + if (this->state_ == STOPPING || this->state_ == STOPPED) return; - this->running_state_ = STOPPING; + this->state_ = STOPPING; esp_err_t err = esp_ble_gatts_stop_service(this->handle_); if (err != ESP_OK) { ESP_LOGE(TAG, "esp_ble_gatts_stop_service failed: %d", err); @@ -119,17 +122,16 @@ void BLEService::stop_() { esp32_ble::global_ble->advertising_remove_service_uuid(this->uuid_); } -bool BLEService::is_created() { return this->init_state_ == CREATED; } bool BLEService::is_failed() { - if (this->init_state_ == FAILED) + if (this->state_ == FAILED) return true; bool failed = false; for (auto *characteristic : this->characteristics_) failed |= characteristic->is_failed(); if (failed) - this->init_state_ = FAILED; - return this->init_state_ == FAILED; + this->state_ = FAILED; + return this->state_ == FAILED; } void BLEService::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, @@ -139,7 +141,7 @@ void BLEService::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t g if (this->uuid_ == ESPBTUUID::from_uuid(param->create.service_id.id.uuid) && this->inst_id_ == param->create.service_id.id.inst_id) { this->handle_ = param->create.service_handle; - this->init_state_ = CREATED; + this->state_ = CREATED; if (this->should_start_) this->start(); } @@ -147,18 +149,18 @@ void BLEService::gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t g } case ESP_GATTS_DELETE_EVT: if (param->del.service_handle == this->handle_) { - this->init_state_ = DELETED; + this->state_ = DELETED; } break; case ESP_GATTS_START_EVT: { if (param->start.service_handle == this->handle_) { - this->running_state_ = RUNNING; + this->state_ = RUNNING; } break; } case ESP_GATTS_STOP_EVT: { if (param->start.service_handle == this->handle_) { - this->running_state_ = STOPPED; + this->state_ = STOPPED; } break; } diff --git a/esphome/components/esp32_ble_server/ble_service.h b/esphome/components/esp32_ble_server/ble_service.h index 5e5883b6bf..dcfad5f501 100644 --- a/esphome/components/esp32_ble_server/ble_service.h +++ b/esphome/components/esp32_ble_server/ble_service.h @@ -32,6 +32,7 @@ class BLEService { BLECharacteristic *create_characteristic(ESPBTUUID uuid, esp_gatt_char_prop_t properties); ESPBTUUID get_uuid() { return this->uuid_; } + uint8_t get_inst_id() { return this->inst_id_; } BLECharacteristic *get_last_created_characteristic() { return this->last_created_characteristic_; } uint16_t get_handle() { return this->handle_; } @@ -44,18 +45,17 @@ class BLEService { void start(); void stop(); - bool is_created(); bool is_failed(); - - bool is_running() { return this->running_state_ == RUNNING; } - bool is_starting() { return this->running_state_ == STARTING; } - bool is_deleted() { return this->init_state_ == DELETED; } + bool is_created() { return this->state_ == CREATED; } + bool is_running() { return this->state_ == RUNNING; } + bool is_starting() { return this->state_ == STARTING; } + bool is_deleted() { return this->state_ == DELETED; } protected: std::vector characteristics_; BLECharacteristic *last_created_characteristic_{nullptr}; uint32_t created_characteristic_count_{0}; - BLEServer *server_; + BLEServer *server_ = nullptr; ESPBTUUID uuid_; uint16_t num_handles_; uint16_t handle_{0xFFFF}; @@ -66,22 +66,18 @@ class BLEService { bool do_create_characteristics_(); void stop_(); - enum InitState : uint8_t { + enum State : uint8_t { FAILED = 0x00, INIT, CREATING, - CREATING_DEPENDENTS, CREATED, - DELETING, - DELETED, - } init_state_{INIT}; - - enum RunningState : uint8_t { STARTING, RUNNING, STOPPING, STOPPED, - } running_state_{STOPPED}; + DELETING, + DELETED, + } state_{INIT}; }; } // namespace esp32_ble_server diff --git a/esphome/components/esp32_ble_tracker/__init__.py b/esphome/components/esp32_ble_tracker/__init__.py index 0aa8eadd0a..e762c89b94 100644 --- a/esphome/components/esp32_ble_tracker/__init__.py +++ b/esphome/components/esp32_ble_tracker/__init__.py @@ -1,9 +1,13 @@ -import re - from esphome import automation import esphome.codegen as cg from esphome.components import esp32_ble from esphome.components.esp32 import add_idf_sdkconfig_option +from esphome.components.esp32_ble import ( + bt_uuid, + bt_uuid16_format, + bt_uuid32_format, + bt_uuid128_format, +) import esphome.config_validation as cv from esphome.const import ( CONF_ACTIVE, @@ -86,43 +90,6 @@ def validate_scan_parameters(config): return config -bt_uuid16_format = "XXXX" -bt_uuid32_format = "XXXXXXXX" -bt_uuid128_format = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" - - -def bt_uuid(value): - in_value = cv.string_strict(value) - value = in_value.upper() - - if len(value) == len(bt_uuid16_format): - pattern = re.compile("^[A-F|0-9]{4,}$") - if not pattern.match(value): - raise cv.Invalid( - f"Invalid hexadecimal value for 16 bit UUID format: '{in_value}'" - ) - return value - if len(value) == len(bt_uuid32_format): - pattern = re.compile("^[A-F|0-9]{8,}$") - if not pattern.match(value): - raise cv.Invalid( - f"Invalid hexadecimal value for 32 bit UUID format: '{in_value}'" - ) - return value - if len(value) == len(bt_uuid128_format): - pattern = re.compile( - "^[A-F|0-9]{8,}-[A-F|0-9]{4,}-[A-F|0-9]{4,}-[A-F|0-9]{4,}-[A-F|0-9]{12,}$" - ) - if not pattern.match(value): - raise cv.Invalid( - f"Invalid hexadecimal value for 128 UUID format: '{in_value}'" - ) - return value - raise cv.Invalid( - f"Service UUID must be in 16 bit '{bt_uuid16_format}', 32 bit '{bt_uuid32_format}', or 128 bit '{bt_uuid128_format}' format" - ) - - def as_hex(value): return cg.RawExpression(f"0x{value}ULL") diff --git a/esphome/components/esp32_improv/__init__.py b/esphome/components/esp32_improv/__init__.py index ecc07d4c91..ca39c1cd36 100644 --- a/esphome/components/esp32_improv/__init__.py +++ b/esphome/components/esp32_improv/__init__.py @@ -1,6 +1,6 @@ from esphome import automation import esphome.codegen as cg -from esphome.components import binary_sensor, esp32_ble_server, output +from esphome.components import binary_sensor, output import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_ON_STATE, CONF_TRIGGER_ID @@ -24,9 +24,7 @@ Error = improv_ns.enum("Error") State = improv_ns.enum("State") esp32_improv_ns = cg.esphome_ns.namespace("esp32_improv") -ESP32ImprovComponent = esp32_improv_ns.class_( - "ESP32ImprovComponent", cg.Component, esp32_ble_server.BLEServiceComponent -) +ESP32ImprovComponent = esp32_improv_ns.class_("ESP32ImprovComponent", cg.Component) ESP32ImprovProvisionedTrigger = esp32_improv_ns.class_( "ESP32ImprovProvisionedTrigger", automation.Trigger.template() ) @@ -47,7 +45,6 @@ ESP32ImprovStoppedTrigger = esp32_improv_ns.class_( CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(): cv.declare_id(ESP32ImprovComponent), - cv.GenerateID(CONF_BLE_SERVER_ID): cv.use_id(esp32_ble_server.BLEServer), cv.Required(CONF_AUTHORIZER): cv.Any( cv.none, cv.use_id(binary_sensor.BinarySensor) ), @@ -100,9 +97,6 @@ async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await cg.register_component(var, config) - ble_server = await cg.get_variable(config[CONF_BLE_SERVER_ID]) - cg.add(ble_server.register_service_component(var)) - cg.add_define("USE_IMPROV") cg.add_library("improv/Improv", "1.2.4") diff --git a/esphome/components/esp32_improv/esp32_improv_component.cpp b/esphome/components/esp32_improv/esp32_improv_component.cpp index c67431077c..b720425506 100644 --- a/esphome/components/esp32_improv/esp32_improv_component.cpp +++ b/esphome/components/esp32_improv/esp32_improv_component.cpp @@ -4,12 +4,15 @@ #include "esphome/components/esp32_ble_server/ble_2902.h" #include "esphome/core/application.h" #include "esphome/core/log.h" +#include "esphome/components/bytebuffer/bytebuffer.h" #ifdef USE_ESP32 namespace esphome { namespace esp32_improv { +using namespace bytebuffer; + static const char *const TAG = "esp32_improv.component"; static const char *const ESPHOME_MY_LINK = "https://my.home-assistant.io/redirect/config_flow_start?domain=esphome"; @@ -26,6 +29,8 @@ void ESP32ImprovComponent::setup() { }); } #endif + global_ble_server->on(BLEServerEvt::EmptyEvt::ON_DISCONNECT, + [this](uint16_t conn_id) { this->set_error_(improv::ERROR_NONE); }); } void ESP32ImprovComponent::setup_characteristics() { @@ -40,11 +45,12 @@ void ESP32ImprovComponent::setup_characteristics() { this->error_->add_descriptor(error_descriptor); this->rpc_ = this->service_->create_characteristic(improv::RPC_COMMAND_UUID, BLECharacteristic::PROPERTY_WRITE); - this->rpc_->on_write([this](const std::vector &data) { - if (!data.empty()) { - this->incoming_data_.insert(this->incoming_data_.end(), data.begin(), data.end()); - } - }); + this->rpc_->EventEmitter, uint16_t>::on( + BLECharacteristicEvt::VectorEvt::ON_WRITE, [this](const std::vector &data, uint16_t id) { + if (!data.empty()) { + this->incoming_data_.insert(this->incoming_data_.end(), data.begin(), data.end()); + } + }); BLEDescriptor *rpc_descriptor = new BLE2902(); this->rpc_->add_descriptor(rpc_descriptor); @@ -62,7 +68,7 @@ void ESP32ImprovComponent::setup_characteristics() { if (this->status_indicator_ != nullptr) capabilities |= improv::CAPABILITY_IDENTIFY; #endif - this->capabilities_->set_value(capabilities); + this->capabilities_->set_value(ByteBuffer::wrap(capabilities)); this->setup_complete_ = true; } @@ -80,8 +86,7 @@ void ESP32ImprovComponent::loop() { if (this->service_ == nullptr) { // Setup the service ESP_LOGD(TAG, "Creating Improv service"); - global_ble_server->create_service(ESPBTUUID::from_raw(improv::SERVICE_UUID), true); - this->service_ = global_ble_server->get_service(ESPBTUUID::from_raw(improv::SERVICE_UUID)); + this->service_ = global_ble_server->create_service(ESPBTUUID::from_raw(improv::SERVICE_UUID), true); this->setup_characteristics(); } @@ -93,15 +98,15 @@ void ESP32ImprovComponent::loop() { case improv::STATE_STOPPED: this->set_status_indicator_state_(false); - if (this->service_->is_created() && this->should_start_ && this->setup_complete_) { - if (this->service_->is_running()) { + if (this->should_start_ && this->setup_complete_) { + if (this->service_->is_created()) { + this->service_->start(); + } else if (this->service_->is_running()) { esp32_ble::global_ble->advertising_start(); this->set_state_(improv::STATE_AWAITING_AUTHORIZATION); this->set_error_(improv::ERROR_NONE); ESP_LOGD(TAG, "Service started!"); - } else { - this->service_->start(); } } break; @@ -199,8 +204,7 @@ void ESP32ImprovComponent::set_state_(improv::State state) { ESP_LOGV(TAG, "Setting state: %d", state); this->state_ = state; if (this->status_->get_value().empty() || this->status_->get_value()[0] != state) { - uint8_t data[1]{state}; - this->status_->set_value(data, 1); + this->status_->set_value(ByteBuffer::wrap(static_cast(state))); if (state != improv::STATE_STOPPED) this->status_->notify(); } @@ -232,15 +236,14 @@ void ESP32ImprovComponent::set_error_(improv::Error error) { ESP_LOGE(TAG, "Error: %d", error); } if (this->error_->get_value().empty() || this->error_->get_value()[0] != error) { - uint8_t data[1]{error}; - this->error_->set_value(data, 1); + this->error_->set_value(ByteBuffer::wrap(static_cast(error))); if (this->state_ != improv::STATE_STOPPED) this->error_->notify(); } } void ESP32ImprovComponent::send_response_(std::vector &response) { - this->rpc_response_->set_value(response); + this->rpc_response_->set_value(ByteBuffer::wrap(response)); if (this->state_ != improv::STATE_STOPPED) this->rpc_response_->notify(); } @@ -339,8 +342,6 @@ void ESP32ImprovComponent::on_wifi_connect_timeout_() { wifi::global_wifi_component->clear_sta(); } -void ESP32ImprovComponent::on_client_disconnect() { this->set_error_(improv::ERROR_NONE); }; - ESP32ImprovComponent *global_improv_component = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) } // namespace esp32_improv diff --git a/esphome/components/esp32_improv/esp32_improv_component.h b/esphome/components/esp32_improv/esp32_improv_component.h index 062b3f585b..87cec23876 100644 --- a/esphome/components/esp32_improv/esp32_improv_component.h +++ b/esphome/components/esp32_improv/esp32_improv_component.h @@ -32,18 +32,17 @@ namespace esp32_improv { using namespace esp32_ble_server; -class ESP32ImprovComponent : public Component, public BLEServiceComponent { +class ESP32ImprovComponent : public Component { public: ESP32ImprovComponent(); void dump_config() override; void loop() override; void setup() override; void setup_characteristics(); - void on_client_disconnect() override; float get_setup_priority() const override; - void start() override; - void stop() override; + void start(); + void stop(); bool is_active() const { return this->state_ != improv::STATE_STOPPED; } #ifdef USE_ESP32_IMPROV_STATE_CALLBACK diff --git a/esphome/components/event_emitter/__init__.py b/esphome/components/event_emitter/__init__.py new file mode 100644 index 0000000000..fcbbf26f02 --- /dev/null +++ b/esphome/components/event_emitter/__init__.py @@ -0,0 +1,5 @@ +CODEOWNERS = ["@Rapsssito"] + +# Allows event_emitter to be configured in yaml, to allow use of the C++ api. + +CONFIG_SCHEMA = {} diff --git a/esphome/components/event_emitter/event_emitter.cpp b/esphome/components/event_emitter/event_emitter.cpp new file mode 100644 index 0000000000..8487e19c2f --- /dev/null +++ b/esphome/components/event_emitter/event_emitter.cpp @@ -0,0 +1,14 @@ +#include "event_emitter.h" + +namespace esphome { +namespace event_emitter { + +static const char *const TAG = "event_emitter"; + +void raise_event_emitter_full_error() { + ESP_LOGE(TAG, "EventEmitter has reached the maximum number of listeners for event"); + ESP_LOGW(TAG, "Removing listener to make space for new listener"); +} + +} // namespace event_emitter +} // namespace esphome diff --git a/esphome/components/event_emitter/event_emitter.h b/esphome/components/event_emitter/event_emitter.h new file mode 100644 index 0000000000..3876a2cc14 --- /dev/null +++ b/esphome/components/event_emitter/event_emitter.h @@ -0,0 +1,63 @@ +#pragma once +#include +#include +#include +#include + +#include "esphome/core/log.h" + +namespace esphome { +namespace event_emitter { + +using EventEmitterListenerID = uint32_t; +void raise_event_emitter_full_error(); + +// EventEmitter class that can emit events with a specific name (it is highly recommended to use an enum class for this) +// and a list of arguments. Supports multiple listeners for each event. +template class EventEmitter { + public: + EventEmitterListenerID on(EvtType event, std::function listener) { + EventEmitterListenerID listener_id = get_next_id_(event); + listeners_[event][listener_id] = listener; + return listener_id; + } + + void off(EvtType event, EventEmitterListenerID id) { + if (listeners_.count(event) == 0) + return; + listeners_[event].erase(id); + } + + protected: + void emit_(EvtType event, Args... args) { + if (listeners_.count(event) == 0) + return; + for (const auto &listener : listeners_[event]) { + listener.second(args...); + } + } + + EventEmitterListenerID get_next_id_(EvtType event) { + // Check if the map is full + if (listeners_[event].size() == std::numeric_limits::max()) { + // Raise an error if the map is full + raise_event_emitter_full_error(); + off(event, 0); + return 0; + } + // Get the next ID for the given event. + EventEmitterListenerID next_id = (current_id_ + 1) % std::numeric_limits::max(); + while (listeners_[event].count(next_id) > 0) { + next_id = (next_id + 1) % std::numeric_limits::max(); + } + current_id_ = next_id; + return current_id_; + } + + private: + std::unordered_map>> listeners_; + EventEmitterListenerID current_id_ = 0; +}; + +} // namespace event_emitter +} // namespace esphome diff --git a/esphome/const.py b/esphome/const.py index 95bf6afc02..ab41d8cbc2 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -530,6 +530,7 @@ CONF_NETWORKS = "networks" CONF_NEW_PASSWORD = "new_password" CONF_NITROGEN_DIOXIDE = "nitrogen_dioxide" CONF_NOISE_LEVEL = "noise_level" +CONF_NOTIFY = "notify" CONF_NUM_ATTEMPTS = "num_attempts" CONF_NUM_CHANNELS = "num_channels" CONF_NUM_CHIPS = "num_chips" diff --git a/tests/components/esp32_ble_server/common.yaml b/tests/components/esp32_ble_server/common.yaml index 29a5407f84..696f4ea8fe 100644 --- a/tests/components/esp32_ble_server/common.yaml +++ b/tests/components/esp32_ble_server/common.yaml @@ -1,3 +1,66 @@ esp32_ble_server: - id: ble + id: ble_server manufacturer_data: [0x72, 0x4, 0x00, 0x23] + manufacturer: ESPHome + model: Test + on_connect: + - lambda: |- + ESP_LOGD("BLE", "Connection from %d", id); + on_disconnect: + - lambda: |- + ESP_LOGD("BLE", "Disconnection from %d", id); + services: + - uuid: 2a24b789-7aab-4535-af3e-ee76a35cc12d + advertise: false + characteristics: + - id: test_notify_characteristic + description: "Notify characteristic" + uuid: cad48e28-7fbe-41cf-bae9-d77a6c233423 + read: true + notify: true + value: [1, 2, 3, 4] + descriptors: + - uuid: cad48e28-7fbe-41cf-bae9-d77a6c111111 + on_write: + logger.log: + format: "Descriptor write id %u, data %s" + args: [id, 'format_hex_pretty(x.data(), x.size()).c_str()'] + value: + data: "123.1" + type: float + endianness: BIG + - uuid: 2a24b789-7a1b-4535-af3e-ee76a35cc42d + advertise: false + characteristics: + - id: test_change_characteristic + uuid: 2a24b789-7a1b-4535-af3e-ee76a35cc11c + read: true + value: + data: "Initial" + string_encoding: utf-8 + description: Change characteristic + descriptors: + - uuid: 0x4414 + id: test_change_descriptor + value: "Initial descriptor value" + - uuid: 0x2312 + value: + data: 0x12 + type: uint16_t + on_write: + - lambda: |- + ESP_LOGD("BLE", "Descriptor received: %s from %d", std::string(x.begin(), x.end()).c_str(), id); + - uuid: 2a24b789-7a1b-4535-af3e-ee76a35cc99a + write: true + on_write: + then: + - lambda: |- + ESP_LOGD("BLE", "Characteristic received: %s from %d", std::string(x.begin(), x.end()).c_str(), id); + - ble_server.characteristic.set_value: + id: test_change_characteristic + value: !lambda 'return bytebuffer::ByteBuffer::wrap({0x00, 0x01, 0x02}).get_data();' + - ble_server.characteristic.notify: + id: test_notify_characteristic + - ble_server.descriptor.set_value: + id: test_change_descriptor + value: !lambda return bytebuffer::ByteBuffer::wrap({0x03, 0x04, 0x05}).get_data(); From 7dab1a6082a2b9938f0c7f28d6a9861df0ad718b Mon Sep 17 00:00:00 2001 From: guillempages Date: Wed, 29 Jan 2025 00:35:43 +0100 Subject: [PATCH 117/194] [online_image] Add JPEG support to online_image (#8127) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jimmy Hedman Co-authored-by: J. Nick Koston Co-authored-by: Rodrigo Martín Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- esphome/components/online_image/__init__.py | 14 ++- .../components/online_image/image_decoder.cpp | 15 ++++ .../components/online_image/image_decoder.h | 2 + .../components/online_image/jpeg_image.cpp | 89 +++++++++++++++++++ esphome/components/online_image/jpeg_image.h | 34 +++++++ .../components/online_image/online_image.cpp | 22 ++++- .../components/online_image/online_image.h | 17 +++- esphome/components/online_image/png_image.cpp | 1 - esphome/core/defines.h | 1 + platformio.ini | 2 + tests/components/online_image/common.yaml | 8 ++ 11 files changed, 199 insertions(+), 6 deletions(-) create mode 100644 esphome/components/online_image/jpeg_image.cpp create mode 100644 esphome/components/online_image/jpeg_image.h diff --git a/esphome/components/online_image/__init__.py b/esphome/components/online_image/__init__.py index eb6debf8eb..c476270571 100644 --- a/esphome/components/online_image/__init__.py +++ b/esphome/components/online_image/__init__.py @@ -60,6 +60,15 @@ class BMPFormat(Format): cg.add_define("USE_ONLINE_IMAGE_BMP_SUPPORT") +class JPEGFormat(Format): + def __init__(self): + super().__init__("JPEG") + + def actions(self): + cg.add_define("USE_ONLINE_IMAGE_JPEG_SUPPORT") + cg.add_library("JPEGDEC", "1.6.2", "https://github.com/bitbank2/JPEGDEC") + + class PNGFormat(Format): def __init__(self): super().__init__("PNG") @@ -69,14 +78,15 @@ class PNGFormat(Format): cg.add_library("pngle", "1.0.2") -# New formats can be added here. IMAGE_FORMATS = { x.image_type: x for x in ( BMPFormat(), + JPEGFormat(), PNGFormat(), ) } +IMAGE_FORMATS.update({"JPG": IMAGE_FORMATS["JPEG"]}) OnlineImage = online_image_ns.class_("OnlineImage", cg.PollingComponent, Image_) @@ -116,7 +126,7 @@ ONLINE_IMAGE_SCHEMA = ( cv.Required(CONF_URL): cv.url, cv.Required(CONF_FORMAT): cv.one_of(*IMAGE_FORMATS, upper=True), cv.Optional(CONF_PLACEHOLDER): cv.use_id(Image_), - cv.Optional(CONF_BUFFER_SIZE, default=2048): cv.int_range(256, 65536), + cv.Optional(CONF_BUFFER_SIZE, default=65536): cv.int_range(256, 65536), cv.Optional(CONF_ON_DOWNLOAD_FINISHED): automation.validate_automation( { cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( diff --git a/esphome/components/online_image/image_decoder.cpp b/esphome/components/online_image/image_decoder.cpp index d0d0495ba6..2958d8671d 100644 --- a/esphome/components/online_image/image_decoder.cpp +++ b/esphome/components/online_image/image_decoder.cpp @@ -41,5 +41,20 @@ size_t DownloadBuffer::read(size_t len) { return this->unread_; } +size_t DownloadBuffer::resize(size_t size) { + if (this->size_ == size) { + return size; + } + this->allocator_.deallocate(this->buffer_, this->size_); + this->size_ = size; + this->buffer_ = this->allocator_.allocate(size); + this->reset(); + if (this->buffer_) { + return size; + } else { + return 0; + } +} + } // namespace online_image } // namespace esphome diff --git a/esphome/components/online_image/image_decoder.h b/esphome/components/online_image/image_decoder.h index 4e5dd7b229..957af49ac9 100644 --- a/esphome/components/online_image/image_decoder.h +++ b/esphome/components/online_image/image_decoder.h @@ -106,6 +106,8 @@ class DownloadBuffer { void reset() { this->unread_ = 0; } + size_t resize(size_t size); + protected: RAMAllocator allocator_{}; uint8_t *buffer_; diff --git a/esphome/components/online_image/jpeg_image.cpp b/esphome/components/online_image/jpeg_image.cpp new file mode 100644 index 0000000000..773b85a2c4 --- /dev/null +++ b/esphome/components/online_image/jpeg_image.cpp @@ -0,0 +1,89 @@ +#include "jpeg_image.h" +#ifdef USE_ONLINE_IMAGE_JPEG_SUPPORT + +#include "esphome/components/display/display_buffer.h" +#include "esphome/core/application.h" +#include "esphome/core/helpers.h" +#include "esphome/core/log.h" + +#include "online_image.h" +static const char *const TAG = "online_image.jpeg"; + +namespace esphome { +namespace online_image { + +/** + * @brief Callback method that will be called by the JPEGDEC engine when a chunk + * of the image is decoded. + * + * @param jpeg The JPEGDRAW object, including the context data. + */ +static int draw_callback(JPEGDRAW *jpeg) { + ImageDecoder *decoder = (ImageDecoder *) jpeg->pUser; + + // Some very big images take too long to decode, so feed the watchdog on each callback + // to avoid crashing. + App.feed_wdt(); + size_t position = 0; + for (size_t y = 0; y < jpeg->iHeight; y++) { + for (size_t x = 0; x < jpeg->iWidth; x++) { + auto rg = decode_value(jpeg->pPixels[position++]); + auto ba = decode_value(jpeg->pPixels[position++]); + Color color(rg[1], rg[0], ba[1], ba[0]); + + if (!decoder) { + ESP_LOGE(TAG, "Decoder pointer is null!"); + return 0; + } + decoder->draw(jpeg->x + x, jpeg->y + y, 1, 1, color); + } + } + return 1; +} + +void JpegDecoder::prepare(size_t download_size) { + ImageDecoder::prepare(download_size); + auto size = this->image_->resize_download_buffer(download_size); + if (size < download_size) { + ESP_LOGE(TAG, "Resize failed!"); + // TODO: return an error code; + } +} + +int HOT JpegDecoder::decode(uint8_t *buffer, size_t size) { + if (size < this->download_size_) { + ESP_LOGV(TAG, "Download not complete. Size: %d/%d", size, this->download_size_); + return 0; + } + + if (!this->jpeg_.openRAM(buffer, size, draw_callback)) { + ESP_LOGE(TAG, "Could not open image for decoding."); + return DECODE_ERROR_INVALID_TYPE; + } + auto jpeg_type = this->jpeg_.getJPEGType(); + if (jpeg_type == JPEG_MODE_INVALID) { + ESP_LOGE(TAG, "Unsupported JPEG image"); + return DECODE_ERROR_INVALID_TYPE; + } else if (jpeg_type == JPEG_MODE_PROGRESSIVE) { + ESP_LOGE(TAG, "Progressive JPEG images not supported"); + return DECODE_ERROR_INVALID_TYPE; + } + ESP_LOGD(TAG, "Image size: %d x %d, bpp: %d", this->jpeg_.getWidth(), this->jpeg_.getHeight(), this->jpeg_.getBpp()); + + this->jpeg_.setUserPointer(this); + this->jpeg_.setPixelType(RGB8888); + this->set_size(this->jpeg_.getWidth(), this->jpeg_.getHeight()); + if (!this->jpeg_.decode(0, 0, 0)) { + ESP_LOGE(TAG, "Error while decoding."); + this->jpeg_.close(); + return DECODE_ERROR_UNSUPPORTED_FORMAT; + } + this->decoded_bytes_ = size; + this->jpeg_.close(); + return size; +} + +} // namespace online_image +} // namespace esphome + +#endif // USE_ONLINE_IMAGE_JPEG_SUPPORT diff --git a/esphome/components/online_image/jpeg_image.h b/esphome/components/online_image/jpeg_image.h new file mode 100644 index 0000000000..f04a35655a --- /dev/null +++ b/esphome/components/online_image/jpeg_image.h @@ -0,0 +1,34 @@ +#pragma once + +#include "image_decoder.h" +#include "esphome/core/defines.h" +#ifdef USE_ONLINE_IMAGE_JPEG_SUPPORT +#include + +namespace esphome { +namespace online_image { + +/** + * @brief Image decoder specialization for JPEG images. + */ +class JpegDecoder : public ImageDecoder { + public: + /** + * @brief Construct a new JPEG Decoder object. + * + * @param display The image to decode the stream into. + */ + JpegDecoder(OnlineImage *image) : ImageDecoder(image) {} + ~JpegDecoder() override {} + + void prepare(size_t download_size) override; + int HOT decode(uint8_t *buffer, size_t size) override; + + protected: + JPEGDEC jpeg_{}; +}; + +} // namespace online_image +} // namespace esphome + +#endif // USE_ONLINE_IMAGE_JPEG_SUPPORT diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index c6499c24e4..b08c14b721 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -9,6 +9,9 @@ static const char *const TAG = "online_image"; #ifdef USE_ONLINE_IMAGE_BMP_SUPPORT #include "bmp_image.h" #endif +#ifdef USE_ONLINE_IMAGE_JPEG_SUPPORT +#include "jpeg_image.h" +#endif #ifdef USE_ONLINE_IMAGE_PNG_SUPPORT #include "png_image.h" #endif @@ -32,6 +35,7 @@ OnlineImage::OnlineImage(const std::string &url, int width, int height, ImageFor : Image(nullptr, 0, 0, type, transparency), buffer_(nullptr), download_buffer_(download_buffer_size), + download_buffer_initial_size_(download_buffer_size), format_(format), fixed_width_(width), fixed_height_(height) { @@ -123,23 +127,32 @@ void OnlineImage::update() { #ifdef USE_ONLINE_IMAGE_BMP_SUPPORT if (this->format_ == ImageFormat::BMP) { + ESP_LOGD(TAG, "Allocating BMP decoder"); this->decoder_ = make_unique(this); } #endif // ONLINE_IMAGE_BMP_SUPPORT +#ifdef USE_ONLINE_IMAGE_JPEG_SUPPORT + if (this->format_ == ImageFormat::JPEG) { + ESP_LOGD(TAG, "Allocating JPEG decoder"); + this->decoder_ = esphome::make_unique(this); + } +#endif // USE_ONLINE_IMAGE_JPEG_SUPPORT #ifdef USE_ONLINE_IMAGE_PNG_SUPPORT if (this->format_ == ImageFormat::PNG) { + ESP_LOGD(TAG, "Allocating PNG decoder"); this->decoder_ = make_unique(this); } #endif // ONLINE_IMAGE_PNG_SUPPORT if (!this->decoder_) { - ESP_LOGE(TAG, "Could not instantiate decoder. Image format unsupported."); + ESP_LOGE(TAG, "Could not instantiate decoder. Image format unsupported: %d", this->format_); this->end_connection_(); this->download_error_callback_.call(); return; } this->decoder_->prepare(total_size); - ESP_LOGI(TAG, "Downloading image"); + ESP_LOGI(TAG, "Downloading image (Size: %d)", total_size); + this->start_time_ = ::time(nullptr); } void OnlineImage::loop() { @@ -153,6 +166,7 @@ void OnlineImage::loop() { this->height_ = buffer_height_; ESP_LOGD(TAG, "Image fully downloaded, read %zu bytes, width/height = %d/%d", this->downloader_->get_bytes_read(), this->width_, this->height_); + ESP_LOGD(TAG, "Total time: %lds", ::time(nullptr) - this->start_time_); this->end_connection_(); this->download_finished_callback_.call(); return; @@ -163,6 +177,10 @@ void OnlineImage::loop() { } size_t available = this->download_buffer_.free_capacity(); if (available) { + // Some decoders need to fully download the image before downloading. + // In case of huge images, don't wait blocking until the whole image has been downloaded, + // use smaller chunks + available = std::min(available, this->download_buffer_initial_size_); auto len = this->downloader_->read(this->download_buffer_.append(), available); if (len > 0) { this->download_buffer_.write(len); diff --git a/esphome/components/online_image/online_image.h b/esphome/components/online_image/online_image.h index 849f860ad5..4abc047083 100644 --- a/esphome/components/online_image/online_image.h +++ b/esphome/components/online_image/online_image.h @@ -23,7 +23,7 @@ using t_http_codes = enum { enum ImageFormat { /** Automatically detect from MIME type. Not supported yet. */ AUTO, - /** JPEG format. Not supported yet. */ + /** JPEG format. */ JPEG, /** PNG format. */ PNG, @@ -79,6 +79,13 @@ class OnlineImage : public PollingComponent, */ void release(); + /** + * Resize the download buffer + * + * @param size The new size for the download buffer. + */ + size_t resize_download_buffer(size_t size) { return this->download_buffer_.resize(size); } + void add_on_finished_callback(std::function &&callback); void add_on_error_callback(std::function &&callback); @@ -119,6 +126,12 @@ class OnlineImage : public PollingComponent, uint8_t *buffer_; DownloadBuffer download_buffer_; + /** + * This is the *initial* size of the download buffer, not the current size. + * The download buffer can be resized at runtime; the download_buffer_initial_size_ + * will *not* change even if the download buffer has been resized. + */ + size_t download_buffer_initial_size_; const ImageFormat format_; image::Image *placeholder_{nullptr}; @@ -148,6 +161,8 @@ class OnlineImage : public PollingComponent, */ int buffer_height_; + time_t start_time_; + friend bool ImageDecoder::set_size(int width, int height); friend void ImageDecoder::draw(int x, int y, int w, int h, const Color &color); }; diff --git a/esphome/components/online_image/png_image.cpp b/esphome/components/online_image/png_image.cpp index 59c1ce6c7d..6bc968c7ba 100644 --- a/esphome/components/online_image/png_image.cpp +++ b/esphome/components/online_image/png_image.cpp @@ -2,7 +2,6 @@ #ifdef USE_ONLINE_IMAGE_PNG_SUPPORT #include "esphome/components/display/display_buffer.h" -#include "esphome/core/application.h" #include "esphome/core/helpers.h" #include "esphome/core/log.h" diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 074b19809f..211f3b8319 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -62,6 +62,7 @@ #define USE_NUMBER #define USE_ONLINE_IMAGE_BMP_SUPPORT #define USE_ONLINE_IMAGE_PNG_SUPPORT +#define USE_ONLINE_IMAGE_JPEG_SUPPORT #define USE_OTA #define USE_OTA_PASSWORD #define USE_OTA_STATE_CALLBACK diff --git a/platformio.ini b/platformio.ini index b9b80e933f..e91c06d86e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -41,6 +41,8 @@ lib_deps = functionpointer/arduino-MLX90393@1.0.2 ; mlx90393 pavlodn/HaierProtocol@0.9.31 ; haier kikuchan98/pngle@1.0.2 ; online_image + ; Using the repository directly, otherwise ESP-IDF can't use the library + https://github.com/bitbank2/JPEGDEC.git#1.6.2 ; online_image ; This is using the repository until a new release is published to PlatformIO https://github.com/Sensirion/arduino-gas-index-algorithm.git#3.2.1 ; Sensirion Gas Index Algorithm Arduino Library lvgl/lvgl@8.4.0 ; lvgl diff --git a/tests/components/online_image/common.yaml b/tests/components/online_image/common.yaml index d75900adf9..69daa915c5 100644 --- a/tests/components/online_image/common.yaml +++ b/tests/components/online_image/common.yaml @@ -30,6 +30,14 @@ online_image: url: https://samples-files.com/samples/images/bmp/480-360-sample.bmp format: BMP type: BINARY + - id: online_jpeg_image + url: http://www.faqs.org/images/library.jpg + format: JPEG + type: RGB + - id: online_jpg_image + url: http://www.faqs.org/images/library.jpg + format: JPG + type: RGB565 # Check the set_url action esphome: From 2489f951071ae45743a0dc1e28aa354bfc1250bd Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:58:06 +1100 Subject: [PATCH 118/194] [logger] Ensure PRIu32 and friends are available (#8155) --- esphome/core/log.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/core/log.h b/esphome/core/log.h index 99a68024c5..9ab80afe78 100644 --- a/esphome/core/log.h +++ b/esphome/core/log.h @@ -2,6 +2,8 @@ #include #include +// for PRIu32 and friends +#include #include #ifdef USE_STORE_LOG_STR_IN_FLASH From a23ce416ea150c1d0fda829664097f7a26253223 Mon Sep 17 00:00:00 2001 From: Stefan Rado <628587+kroimon@users.noreply.github.com> Date: Wed, 29 Jan 2025 04:54:10 +0100 Subject: [PATCH 119/194] Fix forgotten uses of use_transparency (#8115) --- esphome/components/image/__init__.py | 6 ++---- tests/components/lvgl/lvgl-package.yaml | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/esphome/components/image/__init__.py b/esphome/components/image/__init__.py index 7cdce757be..20b041a321 100644 --- a/esphome/components/image/__init__.py +++ b/esphome/components/image/__init__.py @@ -273,11 +273,9 @@ IMAGE_TYPE = { "GRAYSCALE": ImageGrayscale, "RGB565": ImageRGB565, "RGB": ImageRGB, - "TRANSPARENT_BINARY": ReplaceWith( - "'type: BINARY' and 'use_transparency: chroma_key'" - ), + "TRANSPARENT_BINARY": ReplaceWith("'type: BINARY' and 'transparency: chroma_key'"), "RGB24": ReplaceWith("'type: RGB'"), - "RGBA": ReplaceWith("'type: RGB' and 'use_transparency: alpha_channel'"), + "RGBA": ReplaceWith("'type: RGB' and 'transparency: alpha_channel'"), } TransparencyType = image_ns.enum("TransparencyType") diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index b3227bb96e..c51a3d03e7 100644 --- a/tests/components/lvgl/lvgl-package.yaml +++ b/tests/components/lvgl/lvgl-package.yaml @@ -834,12 +834,12 @@ image: resize: 256x48 file: $component_dir/logo-text.svg type: RGB565 - use_transparency: alpha_channel + transparency: alpha_channel - id: dog_image file: $component_dir/logo-text.svg resize: 256x48 type: BINARY - use_transparency: chroma_key + transparency: chroma_key color: - id: light_blue From 9957840dfc7544eec0369fd5cec9a4a190dc8ea5 Mon Sep 17 00:00:00 2001 From: Jimmy Hedman Date: Wed, 29 Jan 2025 11:00:18 +0100 Subject: [PATCH 120/194] Add multicast support to udp component (#8051) --- esphome/components/network/ip_address.h | 2 ++ esphome/components/udp/__init__.py | 6 ++++++ esphome/components/udp/udp_component.cpp | 18 ++++++++++++++++++ esphome/components/udp/udp_component.h | 3 +++ esphome/config_validation.py | 9 +++++++++ tests/components/udp/common.yaml | 1 + 6 files changed, 39 insertions(+) diff --git a/esphome/components/network/ip_address.h b/esphome/components/network/ip_address.h index 69d3788ca5..1598daf6f9 100644 --- a/esphome/components/network/ip_address.h +++ b/esphome/components/network/ip_address.h @@ -49,6 +49,7 @@ struct IPAddress { } IPAddress(const std::string &in_address) { inet_aton(in_address.c_str(), &ip_addr_); } IPAddress(const ip_addr_t *other_ip) { ip_addr_ = *other_ip; } + std::string str() const { return str_lower_case(inet_ntoa(ip_addr_)); } #else IPAddress() { ip_addr_set_zero(&ip_addr_); } IPAddress(uint8_t first, uint8_t second, uint8_t third, uint8_t fourth) { @@ -119,6 +120,7 @@ struct IPAddress { bool is_set() { return !ip_addr_isany(&ip_addr_); } // NOLINT(readability-simplify-boolean-expr) bool is_ip4() { return IP_IS_V4(&ip_addr_); } bool is_ip6() { return IP_IS_V6(&ip_addr_); } + bool is_multicast() { return ip_addr_ismulticast(&ip_addr_); } std::string str() const { return str_lower_case(ipaddr_ntoa(&ip_addr_)); } bool operator==(const IPAddress &other) const { return ip_addr_cmp(&ip_addr_, &other.ip_addr_); } bool operator!=(const IPAddress &other) const { return !ip_addr_cmp(&ip_addr_, &other.ip_addr_); } diff --git a/esphome/components/udp/__init__.py b/esphome/components/udp/__init__.py index e189975ade..5485663f1c 100644 --- a/esphome/components/udp/__init__.py +++ b/esphome/components/udp/__init__.py @@ -27,6 +27,7 @@ UDPComponent = udp_ns.class_("UDPComponent", cg.PollingComponent) CONF_BROADCAST = "broadcast" CONF_BROADCAST_ID = "broadcast_id" CONF_ADDRESSES = "addresses" +CONF_LISTEN_ADDRESS = "listen_address" CONF_PROVIDER = "provider" CONF_PROVIDERS = "providers" CONF_REMOTE_ID = "remote_id" @@ -84,6 +85,9 @@ CONFIG_SCHEMA = cv.All( { cv.GenerateID(): cv.declare_id(UDPComponent), cv.Optional(CONF_PORT, default=18511): cv.port, + cv.Optional( + CONF_LISTEN_ADDRESS, default="255.255.255.255" + ): cv.ipv4address_multi_broadcast, cv.Optional(CONF_ADDRESSES, default=["255.255.255.255"]): cv.ensure_list( cv.ipv4address, ), @@ -154,5 +158,7 @@ async def to_code(config): for provider in config.get(CONF_PROVIDERS, ()): name = provider[CONF_NAME] cg.add(var.add_provider(name)) + if (listen_address := str(config[CONF_LISTEN_ADDRESS])) != "255.255.255.255": + cg.add(var.set_listen_address(listen_address)) if encryption := provider.get(CONF_ENCRYPTION): cg.add(var.set_provider_encryption(name, hash_encryption_key(encryption))) diff --git a/esphome/components/udp/udp_component.cpp b/esphome/components/udp/udp_component.cpp index e29620fa9a..30f7356879 100644 --- a/esphome/components/udp/udp_component.cpp +++ b/esphome/components/udp/udp_component.cpp @@ -249,6 +249,21 @@ void UDPComponent::setup() { server.sin_addr.s_addr = ESPHOME_INADDR_ANY; server.sin_port = htons(this->port_); + if (this->listen_address_.has_value()) { + struct ip_mreq imreq = {}; + imreq.imr_interface.s_addr = ESPHOME_INADDR_ANY; + inet_aton(this->listen_address_.value().str().c_str(), &imreq.imr_multiaddr); + server.sin_addr.s_addr = imreq.imr_multiaddr.s_addr; + ESP_LOGV(TAG, "Join multicast %s", this->listen_address_.value().str().c_str()); + err = this->listen_socket_->setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, &imreq, sizeof(imreq)); + if (err < 0) { + ESP_LOGE(TAG, "Failed to set IP_ADD_MEMBERSHIP. Error %d", errno); + this->mark_failed(); + this->status_set_error("Failed to set IP_ADD_MEMBERSHIP"); + return; + } + } + err = this->listen_socket_->bind((struct sockaddr *) &server, sizeof(server)); if (err != 0) { ESP_LOGE(TAG, "Socket unable to bind: errno %d", errno); @@ -565,6 +580,9 @@ void UDPComponent::dump_config() { ESP_LOGCONFIG(TAG, " Ping-pong: %s", YESNO(this->ping_pong_enable_)); for (const auto &address : this->addresses_) ESP_LOGCONFIG(TAG, " Address: %s", address.c_str()); + if (this->listen_address_.has_value()) { + ESP_LOGCONFIG(TAG, " Listen address: %s", this->listen_address_.value().str().c_str()); + } #ifdef USE_SENSOR for (auto sensor : this->sensors_) ESP_LOGCONFIG(TAG, " Sensor: %s", sensor.id); diff --git a/esphome/components/udp/udp_component.h b/esphome/components/udp/udp_component.h index b4e11cf652..fb9b93e255 100644 --- a/esphome/components/udp/udp_component.h +++ b/esphome/components/udp/udp_component.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/component.h" +#include "esphome/components/network/ip_address.h" #ifdef USE_SENSOR #include "esphome/components/sensor/sensor.h" #endif @@ -69,6 +70,7 @@ class UDPComponent : public PollingComponent { } #endif void add_address(const char *addr) { this->addresses_.emplace_back(addr); } + void set_listen_address(const char *listen_addr) { this->listen_address_ = network::IPAddress(listen_addr); } void set_port(uint16_t port) { this->port_ = port; } float get_setup_priority() const override { return setup_priority::AFTER_WIFI; } @@ -143,6 +145,7 @@ class UDPComponent : public PollingComponent { std::map> remote_binary_sensors_{}; #endif + optional listen_address_{}; std::map providers_{}; std::vector ping_header_{}; std::vector header_{}; diff --git a/esphome/config_validation.py b/esphome/config_validation.py index 20a0774ccb..27d11e4ded 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -1168,6 +1168,15 @@ def ipv4address(value): return address +def ipv4address_multi_broadcast(value): + address = ipv4address(value) + if not (address.is_multicast or (address == IPv4Address("255.255.255.255"))): + raise Invalid( + f"{value} is not a multicasst address nor local broadcast address" + ) + return address + + def ipaddress(value): try: address = ip_address(value) diff --git a/tests/components/udp/common.yaml b/tests/components/udp/common.yaml index 3bdc19ece5..e533cb965e 100644 --- a/tests/components/udp/common.yaml +++ b/tests/components/udp/common.yaml @@ -7,6 +7,7 @@ udp: encryption: "our key goes here" rolling_code_enable: true ping_pong_enable: true + listen_address: 239.0.60.53 binary_sensors: - binary_sensor_id1 - id: binary_sensor_id1 From 619ce93dece3bc066115ae1ec828b9f88925333a Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 29 Jan 2025 21:45:29 +1100 Subject: [PATCH 121/194] [display] Properly handle case of auto_clear_enabled: false (#8156) --- esphome/components/display/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/display/__init__.py b/esphome/components/display/__init__.py index 99224df7b3..12c63231e7 100644 --- a/esphome/components/display/__init__.py +++ b/esphome/components/display/__init__.py @@ -101,7 +101,7 @@ async def setup_display_core_(var, config): if CONF_ROTATION in config: cg.add(var.set_rotation(DISPLAY_ROTATIONS[config[CONF_ROTATION]])) - if auto_clear := config.get(CONF_AUTO_CLEAR_ENABLED): + if (auto_clear := config.get(CONF_AUTO_CLEAR_ENABLED)) is not None: # Default to true if pages or lambda is specified. Ideally this would be done during validation, but # the possible schemas are too complex to do this easily. if auto_clear == CONF_UNSPECIFIED: From 67ccd0eb7f864307891d71983338acc99547e808 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Wed, 29 Jan 2025 05:51:04 -0500 Subject: [PATCH 122/194] [esp32_rmt] Increase default symbols in led strip and remove IRAM config (#8133) --- esphome/components/esp32_rmt_led_strip/light.py | 12 ++++++------ esphome/components/remote_receiver/__init__.py | 5 +---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/esphome/components/esp32_rmt_led_strip/light.py b/esphome/components/esp32_rmt_led_strip/light.py index 64104bb6de..e2c9f7e64a 100644 --- a/esphome/components/esp32_rmt_led_strip/light.py +++ b/esphome/components/esp32_rmt_led_strip/light.py @@ -127,12 +127,12 @@ CONFIG_SCHEMA = cv.All( ), OptionalForIDF5( CONF_RMT_SYMBOLS, - esp32_idf=64, - esp32_s2_idf=64, - esp32_s3_idf=48, - esp32_c3_idf=48, - esp32_c6_idf=48, - esp32_h2_idf=48, + esp32_idf=192, + esp32_s2_idf=192, + esp32_s3_idf=192, + esp32_c3_idf=96, + esp32_c6_idf=96, + esp32_h2_idf=96, ): cv.All(only_with_new_rmt_driver, cv.int_range(min=2)), cv.Optional(CONF_MAX_REFRESH_RATE): cv.positive_time_period_microseconds, cv.Optional(CONF_CHIPSET): cv.one_of(*CHIPSETS, upper=True), diff --git a/esphome/components/remote_receiver/__init__.py b/esphome/components/remote_receiver/__init__.py index b01443a974..8c21cb210c 100644 --- a/esphome/components/remote_receiver/__init__.py +++ b/esphome/components/remote_receiver/__init__.py @@ -1,6 +1,6 @@ from esphome import pins import esphome.codegen as cg -from esphome.components import esp32, esp32_rmt, remote_base +from esphome.components import esp32_rmt, remote_base import esphome.config_validation as cv from esphome.const import ( CONF_BUFFER_SIZE, @@ -158,9 +158,6 @@ async def to_code(config): cg.add(var.set_clock_resolution(config[CONF_CLOCK_RESOLUTION])) if CONF_FILTER_SYMBOLS in config: cg.add(var.set_filter_symbols(config[CONF_FILTER_SYMBOLS])) - if CORE.using_esp_idf: - esp32.add_idf_sdkconfig_option("CONFIG_RMT_RECV_FUNC_IN_IRAM", True) - esp32.add_idf_sdkconfig_option("CONFIG_RMT_ISR_IRAM_SAFE", True) else: if (rmt_channel := config.get(CONF_RMT_CHANNEL, None)) is not None: var = cg.new_Pvariable( From ba3e5e8ecb77639b549114217c128e4e3cc58341 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Wed, 29 Jan 2025 12:27:55 +0100 Subject: [PATCH 123/194] =?UTF-8?q?[climate]=20Accept=20=C2=B0K=20as=20int?= =?UTF-8?q?ended=20(#8134)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esphome/components/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/climate/__init__.py b/esphome/components/climate/__init__.py index ec68940726..aa705e7332 100644 --- a/esphome/components/climate/__init__.py +++ b/esphome/components/climate/__init__.py @@ -115,7 +115,7 @@ CONF_MAX_HUMIDITY = "max_humidity" CONF_TARGET_HUMIDITY = "target_humidity" visual_temperature = cv.float_with_unit( - "visual_temperature", "(°C|° C|°|C|° K|° K|K|°F|° F|F)?" + "visual_temperature", "(°C|° C|°|C|°K|° K|K|°F|° F|F)?" ) From f9856135d0fd6c919f732e18f374d3b7367ac209 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:40:25 +0100 Subject: [PATCH 124/194] Bump docker/build-push-action from 6.12.0 to 6.13.0 in /.github/actions/build-image (#8136) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/actions/build-image/action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-image/action.yaml b/.github/actions/build-image/action.yaml index b2a3394563..25ae21fbd0 100644 --- a/.github/actions/build-image/action.yaml +++ b/.github/actions/build-image/action.yaml @@ -46,7 +46,7 @@ runs: - name: Build and push to ghcr by digest id: build-ghcr - uses: docker/build-push-action@v6.12.0 + uses: docker/build-push-action@v6.13.0 env: DOCKER_BUILD_SUMMARY: false DOCKER_BUILD_RECORD_UPLOAD: false @@ -72,7 +72,7 @@ runs: - name: Build and push to dockerhub by digest id: build-dockerhub - uses: docker/build-push-action@v6.12.0 + uses: docker/build-push-action@v6.13.0 env: DOCKER_BUILD_SUMMARY: false DOCKER_BUILD_RECORD_UPLOAD: false From 334e952a340e57e84351fcb59ee29745ecb6d47e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:40:31 +0100 Subject: [PATCH 125/194] Bump pypa/gh-action-pypi-publish from 1.12.3 to 1.12.4 (#8137) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 962bc66e94..1d6813b1d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -65,7 +65,7 @@ jobs: pip3 install build python3 -m build - name: Publish - uses: pypa/gh-action-pypi-publish@v1.12.3 + uses: pypa/gh-action-pypi-publish@v1.12.4 deploy-docker: name: Build ESPHome ${{ matrix.platform }} From 7727879f01b4d52417b447446ab4575f301310d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 14:30:30 +0100 Subject: [PATCH 126/194] Bump actions/setup-python from 5.3.0 to 5.4.0 (#8154) 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 | 2 +- .github/workflows/release.yml | 4 ++-- .github/workflows/sync-device-classes.yml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-api-proto.yml b/.github/workflows/ci-api-proto.yml index a6b2e2b2b3..d06d8a8eec 100644 --- a/.github/workflows/ci-api-proto.yml +++ b/.github/workflows/ci-api-proto.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout uses: actions/checkout@v4.1.7 - name: Set up Python - uses: actions/setup-python@v5.3.0 + uses: actions/setup-python@v5.4.0 with: python-version: "3.11" diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index b994cfaf17..65f847bc66 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -42,7 +42,7 @@ jobs: steps: - uses: actions/checkout@v4.1.7 - name: Set up Python - uses: actions/setup-python@v5.3.0 + uses: actions/setup-python@v5.4.0 with: python-version: "3.9" - name: Set up Docker Buildx diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a344b177ae..ab77db5ca5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: run: echo key="${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}" >> $GITHUB_OUTPUT - name: Set up Python ${{ env.DEFAULT_PYTHON }} id: python - uses: actions/setup-python@v5.3.0 + uses: actions/setup-python@v5.4.0 with: python-version: ${{ env.DEFAULT_PYTHON }} - name: Restore Python virtual environment diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d6813b1d1..ca266c1f2c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,7 +53,7 @@ jobs: steps: - uses: actions/checkout@v4.1.7 - name: Set up Python - uses: actions/setup-python@v5.3.0 + uses: actions/setup-python@v5.4.0 with: python-version: "3.x" - name: Set up python environment @@ -85,7 +85,7 @@ jobs: steps: - uses: actions/checkout@v4.1.7 - name: Set up Python - uses: actions/setup-python@v5.3.0 + uses: actions/setup-python@v5.4.0 with: python-version: "3.9" diff --git a/.github/workflows/sync-device-classes.yml b/.github/workflows/sync-device-classes.yml index 9160ab4a1b..9abbb20e86 100644 --- a/.github/workflows/sync-device-classes.yml +++ b/.github/workflows/sync-device-classes.yml @@ -22,7 +22,7 @@ jobs: path: lib/home-assistant - name: Setup Python - uses: actions/setup-python@v5.3.0 + uses: actions/setup-python@v5.4.0 with: python-version: 3.12 From 12d6c1bbcae83cb79ed5f6018c18339a42a4dbf5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 14:31:49 +0100 Subject: [PATCH 127/194] Bump actions/setup-python from 5.3.0 to 5.4.0 in /.github/actions/restore-python (#8153) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/actions/restore-python/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/restore-python/action.yml b/.github/actions/restore-python/action.yml index 6b87cf0170..e95eb6331f 100644 --- a/.github/actions/restore-python/action.yml +++ b/.github/actions/restore-python/action.yml @@ -17,7 +17,7 @@ runs: steps: - name: Set up Python ${{ inputs.python-version }} id: python - uses: actions/setup-python@v5.3.0 + uses: actions/setup-python@v5.4.0 with: python-version: ${{ inputs.python-version }} - name: Restore Python virtual environment From 714e2d3e56be5ecb1a0e1a1ea8a5ec1167f7e6c5 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Wed, 29 Jan 2025 08:34:10 -0500 Subject: [PATCH 128/194] [remote_transmitter] Fix issues with 32bit rollover on esp8266 and libretiny (#8056) Co-authored-by: Jonathan Swoboda --- .../remote_transmitter/remote_transmitter_esp8266.cpp | 6 +++--- .../remote_transmitter/remote_transmitter_libretiny.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp b/esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp index 613f00b7f5..09cc16e975 100644 --- a/esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp +++ b/esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp @@ -37,7 +37,7 @@ void RemoteTransmitterComponent::await_target_time_() { const uint32_t current_time = micros(); if (this->target_time_ == 0) { this->target_time_ = current_time; - } else if (this->target_time_ > current_time) { + } else if ((int32_t) (this->target_time_ - current_time) > 0) { delayMicroseconds(this->target_time_ - current_time); } } @@ -50,13 +50,13 @@ void RemoteTransmitterComponent::mark_(uint32_t on_time, uint32_t off_time, uint if (this->carrier_duty_percent_ < 100 && (on_time > 0 || off_time > 0)) { while (true) { // Modulate with carrier frequency this->target_time_ += on_time; - if (this->target_time_ >= target) + if ((int32_t) (this->target_time_ - target) >= 0) break; this->await_target_time_(); this->pin_->digital_write(false); this->target_time_ += off_time; - if (this->target_time_ >= target) + if ((int32_t) (this->target_time_ - target) >= 0) break; this->await_target_time_(); this->pin_->digital_write(true); diff --git a/esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp b/esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp index ad9265fb14..20d8736c00 100644 --- a/esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp +++ b/esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp @@ -38,7 +38,7 @@ void RemoteTransmitterComponent::await_target_time_() { if (this->target_time_ == 0) { this->target_time_ = current_time; } else { - while (this->target_time_ > micros()) { + while ((int32_t) (this->target_time_ - micros()) > 0) { // busy loop that ensures micros is constantly called } } @@ -52,13 +52,13 @@ void RemoteTransmitterComponent::mark_(uint32_t on_time, uint32_t off_time, uint if (this->carrier_duty_percent_ < 100 && (on_time > 0 || off_time > 0)) { while (true) { // Modulate with carrier frequency this->target_time_ += on_time; - if (this->target_time_ >= target) + if ((int32_t) (this->target_time_ - target) >= 0) break; this->await_target_time_(); this->pin_->digital_write(false); this->target_time_ += off_time; - if (this->target_time_ >= target) + if ((int32_t) (this->target_time_ - target) >= 0) break; this->await_target_time_(); this->pin_->digital_write(true); From 73923976302825a2951bd8683cee3eda6a906b76 Mon Sep 17 00:00:00 2001 From: NicoIIT <69118344+NicoIIT@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:03:42 +0100 Subject: [PATCH 129/194] Use abspath for config path dir (#8044) --- esphome/core/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index f26c3da483..59cea6f09b 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -582,7 +582,7 @@ class EsphomeCore: @property def config_dir(self): - return os.path.dirname(self.config_path) + return os.path.dirname(os.path.abspath(self.config_path)) @property def data_dir(self): From 051fa3a49fe58155e48acfe168349c31c5efb344 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Sat, 1 Feb 2025 05:13:38 -0500 Subject: [PATCH 130/194] [remote_base] Add default value for offset in is_valid (#8159) --- esphome/components/remote_base/remote_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/remote_base/remote_base.h b/esphome/components/remote_base/remote_base.h index 70691177ef..4131d080f5 100644 --- a/esphome/components/remote_base/remote_base.h +++ b/esphome/components/remote_base/remote_base.h @@ -54,7 +54,7 @@ class RemoteReceiveData { uint32_t get_index() const { return index_; } int32_t operator[](uint32_t index) const { return this->data_[index]; } int32_t size() const { return this->data_.size(); } - bool is_valid(uint32_t offset) const { return this->index_ + offset < this->data_.size(); } + bool is_valid(uint32_t offset = 0) const { return this->index_ + offset < this->data_.size(); } int32_t peek(uint32_t offset = 0) const { return this->data_[this->index_ + offset]; } bool peek_mark(uint32_t length, uint32_t offset = 0) const; bool peek_space(uint32_t length, uint32_t offset = 0) const; From 03e2701bd0bbed893a830bc37e12c9f91ce18057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Mart=C3=ADn?= Date: Sun, 2 Feb 2025 21:34:38 +0100 Subject: [PATCH 131/194] feat(core): Add support for <...> includes (#8132) --- esphome/core/__init__.py | 7 +++++-- esphome/core/config.py | 17 ++++++++++++++++- esphome/cpp_generator.py | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index 59cea6f09b..2d856d99c5 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -689,7 +689,7 @@ class EsphomeCore: _LOGGER.debug("Adding: %s", expression) return expression - def add_global(self, expression): + def add_global(self, expression, prepend=False): from esphome.cpp_generator import Expression, Statement, statement if isinstance(expression, Expression): @@ -698,7 +698,10 @@ class EsphomeCore: raise ValueError( f"Add '{expression}' must be expression or statement, not {type(expression)}" ) - self.global_statements.append(expression) + if prepend: + self.global_statements.insert(0, expression) + else: + self.global_statements.append(expression) _LOGGER.debug("Adding global: %s", expression) return expression diff --git a/esphome/core/config.py b/esphome/core/config.py index 06ae1d7747..7152414463 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -72,6 +72,9 @@ def validate_hostname(config): def valid_include(value): + # Look for "<...>" includes + if value.startswith("<") and value.endswith(">"): + return value try: return cv.directory(value) except cv.Invalid: @@ -360,7 +363,19 @@ async def to_code(config): CORE.add_job(add_arduino_global_workaround) if config[CONF_INCLUDES]: - CORE.add_job(add_includes, config[CONF_INCLUDES]) + # Get the <...> includes + system_includes = [] + other_includes = [] + for include in config[CONF_INCLUDES]: + if include.startswith("<") and include.endswith(">"): + system_includes.append(include) + else: + other_includes.append(include) + # <...> includes should be at the start + for include in system_includes: + cg.add_global(cg.RawStatement(f"#include {include}"), prepend=True) + # Other includes should be at the end + CORE.add_job(add_includes, other_includes) if project_conf := config.get(CONF_PROJECT): cg.add_define("ESPHOME_PROJECT_NAME", project_conf[CONF_NAME]) diff --git a/esphome/cpp_generator.py b/esphome/cpp_generator.py index 7a82d5cba1..4e283868e1 100644 --- a/esphome/cpp_generator.py +++ b/esphome/cpp_generator.py @@ -588,9 +588,9 @@ def add(expression: Union[Expression, Statement]): CORE.add(expression) -def add_global(expression: Union[SafeExpType, Statement]): +def add_global(expression: Union[SafeExpType, Statement], prepend: bool = False): """Add an expression to the codegen global storage (above setup()).""" - CORE.add_global(expression) + CORE.add_global(expression, prepend) def add_library(name: str, version: Optional[str], repository: Optional[str] = None): From 72c6f04a974bf64c1534773cf626e2a23883d653 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 2 Feb 2025 14:35:52 -0600 Subject: [PATCH 132/194] Bump zeroconf to 0.143.0 (#8104) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d96004c8ef..0d93c3cc2d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ esptool==4.7.0 click==8.1.7 esphome-dashboard==20241217.1 aioesphomeapi==24.6.2 -zeroconf==0.132.2 +zeroconf==0.143.0 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import glyphsets==1.0.0 From 2b711e532b37746cd5e5d6b68e01012cb19b0d18 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Sun, 2 Feb 2025 14:38:10 -0600 Subject: [PATCH 133/194] [i2s_audio] Media Player Components PR1 (#8163) --- esphome/components/i2s_audio/speaker/__init__.py | 11 ++++++++--- esphome/const.py | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/esphome/components/i2s_audio/speaker/__init__.py b/esphome/components/i2s_audio/speaker/__init__.py index 0355c16321..eb6bb329ad 100644 --- a/esphome/components/i2s_audio/speaker/__init__.py +++ b/esphome/components/i2s_audio/speaker/__init__.py @@ -2,7 +2,14 @@ from esphome import pins import esphome.codegen as cg from esphome.components import esp32, speaker import esphome.config_validation as cv -from esphome.const import CONF_CHANNEL, CONF_ID, CONF_MODE, CONF_TIMEOUT +from esphome.const import ( + CONF_BUFFER_DURATION, + CONF_CHANNEL, + CONF_ID, + CONF_MODE, + CONF_NEVER, + CONF_TIMEOUT, +) from .. import ( CONF_I2S_DOUT_PIN, @@ -24,10 +31,8 @@ I2SAudioSpeaker = i2s_audio_ns.class_( "I2SAudioSpeaker", cg.Component, speaker.Speaker, I2SAudioOut ) -CONF_BUFFER_DURATION = "buffer_duration" CONF_DAC_TYPE = "dac_type" CONF_I2S_COMM_FMT = "i2s_comm_fmt" -CONF_NEVER = "never" i2s_dac_mode_t = cg.global_ns.enum("i2s_dac_mode_t") INTERNAL_DAC_OPTIONS = { diff --git a/esphome/const.py b/esphome/const.py index ab41d8cbc2..16bfda9478 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -94,6 +94,7 @@ CONF_BRIGHTNESS = "brightness" CONF_BRIGHTNESS_LIMITS = "brightness_limits" CONF_BROKER = "broker" CONF_BSSID = "bssid" +CONF_BUFFER_DURATION = "buffer_duration" CONF_BUFFER_SIZE = "buffer_size" CONF_BUILD_PATH = "build_path" CONF_BUS_VOLTAGE = "bus_voltage" @@ -527,6 +528,7 @@ CONF_NAME_FONT = "name_font" CONF_NBITS = "nbits" CONF_NEC = "nec" CONF_NETWORKS = "networks" +CONF_NEVER = "never" CONF_NEW_PASSWORD = "new_password" CONF_NITROGEN_DIOXIDE = "nitrogen_dioxide" CONF_NOISE_LEVEL = "noise_level" @@ -615,6 +617,7 @@ CONF_OTA = "ota" CONF_OUTDOOR_TEMPERATURE = "outdoor_temperature" CONF_OUTPUT = "output" CONF_OUTPUT_ID = "output_id" +CONF_OUTPUT_SPEAKER = "output_speaker" CONF_OUTPUTS = "outputs" CONF_OVERSAMPLING = "oversampling" CONF_PACKAGES = "packages" @@ -859,6 +862,7 @@ CONF_TARGET_TEMPERATURE_LOW = "target_temperature_low" CONF_TARGET_TEMPERATURE_LOW_COMMAND_TOPIC = "target_temperature_low_command_topic" CONF_TARGET_TEMPERATURE_LOW_STATE_TOPIC = "target_temperature_low_state_topic" CONF_TARGET_TEMPERATURE_STATE_TOPIC = "target_temperature_state_topic" +CONF_TASK_STACK_IN_PSRAM = "task_stack_in_psram" CONF_TEMPERATURE = "temperature" CONF_TEMPERATURE_COMPENSATION = "temperature_compensation" CONF_TEMPERATURE_OFFSET = "temperature_offset" From f6cf99384b8e34bc46162f6843953d22c412eff5 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Sun, 2 Feb 2025 20:25:41 -0600 Subject: [PATCH 134/194] [audio, i2s_audio, speaker] Media Player Components PR2 (#8164) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/audio/__init__.py | 112 ++++++++++++++ esphome/components/audio/audio.cpp | 67 +++++++++ esphome/components/audio/audio.h | 132 ++++++++++++++++- .../components/i2s_audio/speaker/__init__.py | 48 +++++- .../i2s_audio/speaker/i2s_audio_speaker.cpp | 138 ++++++++++++------ .../i2s_audio/speaker/i2s_audio_speaker.h | 8 + esphome/components/speaker/__init__.py | 9 +- esphome/components/speaker/speaker.h | 20 +++ platformio.ini | 4 +- 9 files changed, 477 insertions(+), 61 deletions(-) create mode 100644 esphome/components/audio/audio.cpp diff --git a/esphome/components/audio/__init__.py b/esphome/components/audio/__init__.py index 4ffdc401dc..31d3c39ffa 100644 --- a/esphome/components/audio/__init__.py +++ b/esphome/components/audio/__init__.py @@ -1,9 +1,121 @@ import esphome.codegen as cg import esphome.config_validation as cv +from esphome.const import CONF_BITS_PER_SAMPLE, CONF_NUM_CHANNELS, CONF_SAMPLE_RATE +import esphome.final_validate as fv CODEOWNERS = ["@kahrendt"] audio_ns = cg.esphome_ns.namespace("audio") +AudioFile = audio_ns.struct("AudioFile") +AudioFileType = audio_ns.enum("AudioFileType", is_class=True) +AUDIO_FILE_TYPE_ENUM = { + "NONE": AudioFileType.NONE, + "WAV": AudioFileType.WAV, + "MP3": AudioFileType.MP3, + "FLAC": AudioFileType.FLAC, +} + + +CONF_MIN_BITS_PER_SAMPLE = "min_bits_per_sample" +CONF_MAX_BITS_PER_SAMPLE = "max_bits_per_sample" +CONF_MIN_CHANNELS = "min_channels" +CONF_MAX_CHANNELS = "max_channels" +CONF_MIN_SAMPLE_RATE = "min_sample_rate" +CONF_MAX_SAMPLE_RATE = "max_sample_rate" + + CONFIG_SCHEMA = cv.All( cv.Schema({}), ) + +AUDIO_COMPONENT_SCHEMA = cv.Schema( + { + cv.Optional(CONF_BITS_PER_SAMPLE): cv.int_range(8, 32), + cv.Optional(CONF_NUM_CHANNELS): cv.int_range(1, 2), + cv.Optional(CONF_SAMPLE_RATE): cv.int_range(8000, 48000), + } +) + + +_UNDEF = object() + + +def set_stream_limits( + min_bits_per_sample: int = _UNDEF, + max_bits_per_sample: int = _UNDEF, + min_channels: int = _UNDEF, + max_channels: int = _UNDEF, + min_sample_rate: int = _UNDEF, + max_sample_rate: int = _UNDEF, +): + def set_limits_in_config(config): + if min_bits_per_sample is not _UNDEF: + config[CONF_MIN_BITS_PER_SAMPLE] = min_bits_per_sample + if max_bits_per_sample is not _UNDEF: + config[CONF_MAX_BITS_PER_SAMPLE] = max_bits_per_sample + if min_channels is not _UNDEF: + config[CONF_MIN_CHANNELS] = min_channels + if max_channels is not _UNDEF: + config[CONF_MAX_CHANNELS] = max_channels + if min_sample_rate is not _UNDEF: + config[CONF_MIN_SAMPLE_RATE] = min_sample_rate + if max_sample_rate is not _UNDEF: + config[CONF_MAX_SAMPLE_RATE] = max_sample_rate + + return set_limits_in_config + + +def final_validate_audio_schema( + name: str, + *, + audio_device: str, + bits_per_sample: int, + channels: int, + sample_rate: int, +): + def validate_audio_compatiblity(audio_config): + audio_schema = {} + + try: + cv.int_range( + min=audio_config.get(CONF_MIN_BITS_PER_SAMPLE), + max=audio_config.get(CONF_MAX_BITS_PER_SAMPLE), + )(bits_per_sample) + except cv.Invalid as exc: + raise cv.Invalid( + f"Invalid configuration for the {name} component. The {CONF_BITS_PER_SAMPLE} {str(exc)}" + ) from exc + + try: + cv.int_range( + min=audio_config.get(CONF_MIN_CHANNELS), + max=audio_config.get(CONF_MAX_CHANNELS), + )(channels) + except cv.Invalid as exc: + raise cv.Invalid( + f"Invalid configuration for the {name} component. The {CONF_NUM_CHANNELS} {str(exc)}" + ) from exc + + try: + cv.int_range( + min=audio_config.get(CONF_MIN_SAMPLE_RATE), + max=audio_config.get(CONF_MAX_SAMPLE_RATE), + )(sample_rate) + return cv.Schema(audio_schema, extra=cv.ALLOW_EXTRA)(audio_config) + except cv.Invalid as exc: + raise cv.Invalid( + f"Invalid configuration for the {name} component. The {CONF_SAMPLE_RATE} {str(exc)}" + ) from exc + + return cv.Schema( + { + cv.Required(audio_device): fv.id_declaration_match_schema( + validate_audio_compatiblity + ) + }, + extra=cv.ALLOW_EXTRA, + ) + + +async def to_code(config): + cg.add_library("esphome/esp-audio-libs", "1.1.1") diff --git a/esphome/components/audio/audio.cpp b/esphome/components/audio/audio.cpp new file mode 100644 index 0000000000..2a58c38ac7 --- /dev/null +++ b/esphome/components/audio/audio.cpp @@ -0,0 +1,67 @@ +#include "audio.h" + +namespace esphome { +namespace audio { + +// Euclidean's algorithm for finding the greatest common divisor +static uint32_t gcd(uint32_t a, uint32_t b) { + while (b != 0) { + uint32_t t = b; + b = a % b; + a = t; + } + return a; +} + +AudioStreamInfo::AudioStreamInfo(uint8_t bits_per_sample, uint8_t channels, uint32_t sample_rate) + : bits_per_sample_(bits_per_sample), channels_(channels), sample_rate_(sample_rate) { + this->ms_sample_rate_gcd_ = gcd(1000, this->sample_rate_); + this->bytes_per_sample_ = (this->bits_per_sample_ + 7) / 8; +} + +uint32_t AudioStreamInfo::frames_to_microseconds(uint32_t frames) const { + return (frames * 1000000 + (this->sample_rate_ >> 1)) / this->sample_rate_; +} + +uint32_t AudioStreamInfo::frames_to_milliseconds_with_remainder(uint32_t *total_frames) const { + uint32_t unprocessable_frames = *total_frames % (this->sample_rate_ / this->ms_sample_rate_gcd_); + uint32_t frames_for_ms_calculation = *total_frames - unprocessable_frames; + + uint32_t playback_ms = (frames_for_ms_calculation * 1000) / this->sample_rate_; + *total_frames = unprocessable_frames; + return playback_ms; +} + +bool AudioStreamInfo::operator==(const AudioStreamInfo &rhs) const { + return (this->bits_per_sample_ == rhs.get_bits_per_sample()) && (this->channels_ == rhs.get_channels()) && + (this->sample_rate_ == rhs.get_sample_rate()); +} + +const char *audio_file_type_to_string(AudioFileType file_type) { + switch (file_type) { +#ifdef USE_AUDIO_FLAC_SUPPORT + case AudioFileType::FLAC: + return "FLAC"; +#endif +#ifdef USE_AUDIO_MP3_SUPPORT + case AudioFileType::MP3: + return "MP3"; +#endif + case AudioFileType::WAV: + return "WAV"; + default: + return "unknown"; + } +} + +void scale_audio_samples(const int16_t *audio_samples, int16_t *output_buffer, int16_t scale_factor, + size_t samples_to_scale) { + // Note the assembly dsps_mulc function has audio glitches if the input and output buffers are the same. + for (int i = 0; i < samples_to_scale; i++) { + int32_t acc = (int32_t) audio_samples[i] * (int32_t) scale_factor; + output_buffer[i] = (int16_t) (acc >> 15); + } +} + +} // namespace audio +} // namespace esphome diff --git a/esphome/components/audio/audio.h b/esphome/components/audio/audio.h index caf325cf54..6f0f1aaa46 100644 --- a/esphome/components/audio/audio.h +++ b/esphome/components/audio/audio.h @@ -1,21 +1,139 @@ #pragma once +#include "esphome/core/defines.h" + #include #include namespace esphome { namespace audio { -struct AudioStreamInfo { - bool operator==(const AudioStreamInfo &rhs) const { - return (channels == rhs.channels) && (bits_per_sample == rhs.bits_per_sample) && (sample_rate == rhs.sample_rate); +class AudioStreamInfo { + /* Class to respresent important parameters of the audio stream that also provides helper function to convert between + * various audio related units. + * + * - An audio sample represents a unit of audio for one channel. + * - A frame represents a unit of audio with a sample for every channel. + * + * In gneneral, converting between bytes, samples, and frames shouldn't result in rounding errors so long as frames + * are used as the main unit when transferring audio data. Durations may result in rounding for certain sample rates; + * e.g., 44.1 KHz. The ``frames_to_milliseconds_with_remainder`` function should be used for accuracy, as it takes + * into account the remainder rather than just ignoring any rounding. + */ + public: + AudioStreamInfo() + : AudioStreamInfo(16, 1, 16000){}; // Default values represent ESPHome's audio components historical values + AudioStreamInfo(uint8_t bits_per_sample, uint8_t channels, uint32_t sample_rate); + + uint8_t get_bits_per_sample() const { return this->bits_per_sample_; } + uint8_t get_channels() const { return this->channels_; } + uint32_t get_sample_rate() const { return this->sample_rate_; } + + /// @brief Convert bytes to duration in milliseconds. + /// @param bytes Number of bytes to convert + /// @return Duration in milliseconds that will store `bytes` bytes of audio. May round down for certain sample rates + /// or values of `bytes`. + uint32_t bytes_to_ms(size_t bytes) const { + return bytes * 1000 / (this->sample_rate_ * this->bytes_per_sample_ * this->channels_); } + + /// @brief Convert bytes to frames. + /// @param bytes Number of bytes to convert + /// @return Audio frames that will store `bytes` bytes. + uint32_t bytes_to_frames(size_t bytes) const { return (bytes / (this->bytes_per_sample_ * this->channels_)); } + + /// @brief Convert bytes to samples. + /// @param bytes Number of bytes to convert + /// @return Audio samples that will store `bytes` bytes. + uint32_t bytes_to_samples(size_t bytes) const { return (bytes / this->bytes_per_sample_); } + + /// @brief Converts frames to bytes. + /// @param frames Number of frames to convert. + /// @return Number of bytes that will store `frames` frames of audio. + size_t frames_to_bytes(uint32_t frames) const { return frames * this->bytes_per_sample_ * this->channels_; } + + /// @brief Converts samples to bytes. + /// @param samples Number of samples to convert. + /// @return Number of bytes that will store `samples` samples of audio. + size_t samples_to_bytes(uint32_t samples) const { return samples * this->bytes_per_sample_; } + + /// @brief Converts duration to frames. + /// @param ms Duration in milliseconds + /// @return Audio frames that will store `ms` milliseconds of audio. May round down for certain sample rates. + uint32_t ms_to_frames(uint32_t ms) const { return (ms * this->sample_rate_) / 1000; } + + /// @brief Converts duration to samples. + /// @param ms Duration in milliseconds + /// @return Audio samples that will store `ms` milliseconds of audio. May round down for certain sample rates. + uint32_t ms_to_samples(uint32_t ms) const { return (ms * this->channels_ * this->sample_rate_) / 1000; } + + /// @brief Converts duration to bytes. May round down for certain sample rates. + /// @param ms Duration in milliseconds + /// @return Bytes that will store `ms` milliseconds of audio. May round down for certain sample rates. + size_t ms_to_bytes(uint32_t ms) const { + return (ms * this->bytes_per_sample_ * this->channels_ * this->sample_rate_) / 1000; + } + + /// @brief Computes the duration, in microseconds, the given amount of frames represents. + /// @param frames Number of audio frames + /// @return Duration in microseconds `frames` respresents. May be slightly inaccurate due to integer divison rounding + /// for certain sample rates. + uint32_t frames_to_microseconds(uint32_t frames) const; + + /// @brief Computes the duration, in milliseconds, the given amount of frames represents. Avoids + /// accumulating rounding errors by updating `frames` with the remainder after converting. + /// @param frames Pointer to uint32_t with the number of audio frames. Replaced with the remainder. + /// @return Duration in milliseconds `frames` represents. Always less than or equal to the actual value due to + /// rounding. + uint32_t frames_to_milliseconds_with_remainder(uint32_t *frames) const; + + // Class comparison operators + bool operator==(const AudioStreamInfo &rhs) const; bool operator!=(const AudioStreamInfo &rhs) const { return !operator==(rhs); } - size_t get_bytes_per_sample() const { return bits_per_sample / 8; } - uint8_t channels = 1; - uint8_t bits_per_sample = 16; - uint32_t sample_rate = 16000; + + protected: + uint8_t bits_per_sample_; + uint8_t channels_; + uint32_t sample_rate_; + + // The greatest common divisor between 1000 ms = 1 second and the sample rate. Used to avoid accumulating error when + // converting from frames to duration. Computed at construction. + uint32_t ms_sample_rate_gcd_; + + // Conversion factor derived from the number of bits per sample. Assumes audio data is aligned to the byte. Computed + // at construction. + size_t bytes_per_sample_; }; +enum class AudioFileType : uint8_t { + NONE = 0, +#ifdef USE_AUDIO_FLAC_SUPPORT + FLAC, +#endif +#ifdef USE_AUDIO_MP3_SUPPORT + MP3, +#endif + WAV, +}; + +struct AudioFile { + const uint8_t *data; + size_t length; + AudioFileType file_type; +}; + +/// @brief Helper function to convert file type to a const char string +/// @param file_type +/// @return const char pointer to the readable file type +const char *audio_file_type_to_string(AudioFileType file_type); + +/// @brief Scales Q15 fixed point audio samples. Scales in place if audio_samples == output_buffer. +/// @param audio_samples PCM int16 audio samples +/// @param output_buffer Buffer to store the scaled samples +/// @param scale_factor Q15 fixed point scaling factor +/// @param samples_to_scale Number of samples to scale +void scale_audio_samples(const int16_t *audio_samples, int16_t *output_buffer, int16_t scale_factor, + size_t samples_to_scale); + } // namespace audio } // namespace esphome diff --git a/esphome/components/i2s_audio/speaker/__init__.py b/esphome/components/i2s_audio/speaker/__init__.py index eb6bb329ad..aa3b50d336 100644 --- a/esphome/components/i2s_audio/speaker/__init__.py +++ b/esphome/components/i2s_audio/speaker/__init__.py @@ -1,20 +1,25 @@ from esphome import pins import esphome.codegen as cg -from esphome.components import esp32, speaker +from esphome.components import audio, esp32, speaker import esphome.config_validation as cv from esphome.const import ( + CONF_BITS_PER_SAMPLE, CONF_BUFFER_DURATION, CONF_CHANNEL, CONF_ID, CONF_MODE, CONF_NEVER, + CONF_NUM_CHANNELS, + CONF_SAMPLE_RATE, CONF_TIMEOUT, ) from .. import ( CONF_I2S_DOUT_PIN, + CONF_I2S_MODE, CONF_LEFT, CONF_MONO, + CONF_PRIMARY, CONF_RIGHT, CONF_STEREO, I2SAudioOut, @@ -58,7 +63,41 @@ I2C_COMM_FMT_OPTIONS = { NO_INTERNAL_DAC_VARIANTS = [esp32.const.VARIANT_ESP32S2] -def validate_esp32_variant(config): +def _set_num_channels_from_config(config): + if config[CONF_CHANNEL] in (CONF_MONO, CONF_LEFT, CONF_RIGHT): + config[CONF_NUM_CHANNELS] = 1 + else: + config[CONF_NUM_CHANNELS] = 2 + + return config + + +def _set_stream_limits(config): + if config[CONF_I2S_MODE] == CONF_PRIMARY: + # Primary mode has modifiable stream settings + audio.set_stream_limits( + min_bits_per_sample=8, + max_bits_per_sample=32, + min_channels=1, + max_channels=2, + min_sample_rate=16000, + max_sample_rate=48000, + )(config) + else: + # Secondary mode has unmodifiable max bits per sample and min/max sample rates + audio.set_stream_limits( + min_bits_per_sample=8, + max_bits_per_sample=config.get(CONF_BITS_PER_SAMPLE), + min_channels=1, + max_channels=2, + min_sample_rate=config.get(CONF_SAMPLE_RATE), + max_sample_rate=config.get(CONF_SAMPLE_RATE), + ) + + return config + + +def _validate_esp32_variant(config): if config[CONF_DAC_TYPE] != "internal": return config variant = esp32.get_esp32_variant() @@ -90,6 +129,7 @@ BASE_SCHEMA = ( .extend(cv.COMPONENT_SCHEMA) ) + CONFIG_SCHEMA = cv.All( cv.typed_schema( { @@ -111,7 +151,9 @@ CONFIG_SCHEMA = cv.All( }, key=CONF_DAC_TYPE, ), - validate_esp32_variant, + _validate_esp32_variant, + _set_num_channels_from_config, + _set_stream_limits, ) diff --git a/esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp b/esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp index 46f1b00d05..2a3fa9f5f3 100644 --- a/esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +++ b/esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp @@ -148,9 +148,11 @@ void I2SAudioSpeaker::loop() { this->status_set_error("Failed to adjust I2S bus to match the incoming audio"); ESP_LOGE(TAG, "Incompatible audio format: sample rate = %" PRIu32 ", channels = %" PRIu8 ", bits per sample = %" PRIu8, - this->audio_stream_info_.sample_rate, this->audio_stream_info_.channels, - this->audio_stream_info_.bits_per_sample); + this->audio_stream_info_.get_sample_rate(), this->audio_stream_info_.get_channels(), + this->audio_stream_info_.get_bits_per_sample()); } + + xEventGroupClearBits(this->event_group_, ALL_ERR_ESP_BITS); } void I2SAudioSpeaker::set_volume(float volume) { @@ -201,6 +203,12 @@ size_t I2SAudioSpeaker::play(const uint8_t *data, size_t length, TickType_t tick this->start(); } + if ((this->state_ != speaker::STATE_RUNNING) || (this->audio_ring_buffer_.use_count() == 1)) { + // Unable to write data to a running speaker, so delay the max amount of time so it can get ready + vTaskDelay(ticks_to_wait); + ticks_to_wait = 0; + } + size_t bytes_written = 0; if ((this->state_ == speaker::STATE_RUNNING) && (this->audio_ring_buffer_.use_count() == 1)) { // Only one owner of the ring buffer (the speaker task), so the ring buffer is allocated and no other components are @@ -223,6 +231,8 @@ bool I2SAudioSpeaker::has_buffered_data() const { void I2SAudioSpeaker::speaker_task(void *params) { I2SAudioSpeaker *this_speaker = (I2SAudioSpeaker *) params; + this_speaker->task_created_ = true; + uint32_t event_group_bits = xEventGroupWaitBits(this_speaker->event_group_, SpeakerEventGroupBits::COMMAND_START | SpeakerEventGroupBits::COMMAND_STOP | @@ -240,19 +250,20 @@ void I2SAudioSpeaker::speaker_task(void *params) { audio::AudioStreamInfo audio_stream_info = this_speaker->audio_stream_info_; - const uint32_t bytes_per_ms = - audio_stream_info.channels * audio_stream_info.get_bytes_per_sample() * audio_stream_info.sample_rate / 1000; + const uint32_t dma_buffers_duration_ms = DMA_BUFFER_DURATION_MS * DMA_BUFFERS_COUNT; + // Ensure ring buffer duration is at least the duration of all DMA buffers + const uint32_t ring_buffer_duration = std::max(dma_buffers_duration_ms, this_speaker->buffer_duration_ms_); - const size_t dma_buffers_size = DMA_BUFFERS_COUNT * DMA_BUFFER_DURATION_MS * bytes_per_ms; + // The DMA buffers may have more bits per sample, so calculate buffer sizes based in the input audio stream info + const size_t data_buffer_size = audio_stream_info.ms_to_bytes(dma_buffers_duration_ms); + const size_t ring_buffer_size = audio_stream_info.ms_to_bytes(ring_buffer_duration); - // Ensure ring buffer is at least as large as the total size of the DMA buffers - const size_t ring_buffer_size = - std::max((uint32_t) dma_buffers_size, this_speaker->buffer_duration_ms_ * bytes_per_ms); + const size_t single_dma_buffer_input_size = data_buffer_size / DMA_BUFFERS_COUNT; - if (this_speaker->send_esp_err_to_event_group_(this_speaker->allocate_buffers_(dma_buffers_size, ring_buffer_size))) { + if (this_speaker->send_esp_err_to_event_group_(this_speaker->allocate_buffers_(data_buffer_size, ring_buffer_size))) { // Failed to allocate buffers xEventGroupSetBits(this_speaker->event_group_, SpeakerEventGroupBits::ERR_ESP_NO_MEM); - this_speaker->delete_task_(dma_buffers_size); + this_speaker->delete_task_(data_buffer_size); } if (!this_speaker->send_esp_err_to_event_group_(this_speaker->start_i2s_driver_(audio_stream_info))) { @@ -262,20 +273,25 @@ void I2SAudioSpeaker::speaker_task(void *params) { uint32_t last_data_received_time = millis(); bool tx_dma_underflow = false; - while (!this_speaker->timeout_.has_value() || + this_speaker->accumulated_frames_written_ = 0; + + // Keep looping if paused, there is no timeout configured, or data was received more recently than the configured + // timeout + while (this_speaker->pause_state_ || !this_speaker->timeout_.has_value() || (millis() - last_data_received_time) <= this_speaker->timeout_.value()) { event_group_bits = xEventGroupGetBits(this_speaker->event_group_); if (event_group_bits & SpeakerEventGroupBits::COMMAND_STOP) { + xEventGroupClearBits(this_speaker->event_group_, SpeakerEventGroupBits::COMMAND_STOP); break; } if (event_group_bits & SpeakerEventGroupBits::COMMAND_STOP_GRACEFULLY) { + xEventGroupClearBits(this_speaker->event_group_, SpeakerEventGroupBits::COMMAND_STOP_GRACEFULLY); stop_gracefully = true; } if (this_speaker->audio_stream_info_ != audio_stream_info) { - // Audio stream info has changed, stop the speaker task so it will restart with the proper settings. - + // Audio stream info changed, stop the speaker task so it will restart with the proper settings. break; } @@ -286,33 +302,64 @@ void I2SAudioSpeaker::speaker_task(void *params) { } } - size_t bytes_to_read = dma_buffers_size; - size_t bytes_read = this_speaker->audio_ring_buffer_->read((void *) this_speaker->data_buffer_, bytes_to_read, + if (this_speaker->pause_state_) { + // Pause state is accessed atomically, so thread safe + // Delay so the task can yields, then skip transferring audio data + delay(TASK_DELAY_MS); + continue; + } + + size_t bytes_read = this_speaker->audio_ring_buffer_->read((void *) this_speaker->data_buffer_, data_buffer_size, pdMS_TO_TICKS(TASK_DELAY_MS)); if (bytes_read > 0) { - size_t bytes_written = 0; - - if ((audio_stream_info.bits_per_sample == 16) && (this_speaker->q15_volume_factor_ < INT16_MAX)) { + if ((audio_stream_info.get_bits_per_sample() == 16) && (this_speaker->q15_volume_factor_ < INT16_MAX)) { // Scale samples by the volume factor in place q15_multiplication((int16_t *) this_speaker->data_buffer_, (int16_t *) this_speaker->data_buffer_, bytes_read / sizeof(int16_t), this_speaker->q15_volume_factor_); } - if (audio_stream_info.bits_per_sample == (uint8_t) this_speaker->bits_per_sample_) { - i2s_write(this_speaker->parent_->get_port(), this_speaker->data_buffer_, bytes_read, &bytes_written, - portMAX_DELAY); - } else if (audio_stream_info.bits_per_sample < (uint8_t) this_speaker->bits_per_sample_) { - i2s_write_expand(this_speaker->parent_->get_port(), this_speaker->data_buffer_, bytes_read, - audio_stream_info.bits_per_sample, this_speaker->bits_per_sample_, &bytes_written, - portMAX_DELAY); - } + // Write the audio data to a single DMA buffer at a time to reduce latency for the audio duration played + // callback. + const uint32_t batches = (bytes_read + single_dma_buffer_input_size - 1) / single_dma_buffer_input_size; - if (bytes_written != bytes_read) { - xEventGroupSetBits(this_speaker->event_group_, SpeakerEventGroupBits::ERR_ESP_INVALID_SIZE); + for (uint32_t i = 0; i < batches; ++i) { + size_t bytes_written = 0; + size_t bytes_to_write = std::min(single_dma_buffer_input_size, bytes_read); + + if (audio_stream_info.get_bits_per_sample() == (uint8_t) this_speaker->bits_per_sample_) { + i2s_write(this_speaker->parent_->get_port(), this_speaker->data_buffer_ + i * single_dma_buffer_input_size, + bytes_to_write, &bytes_written, pdMS_TO_TICKS(DMA_BUFFER_DURATION_MS * 5)); + } else if (audio_stream_info.get_bits_per_sample() < (uint8_t) this_speaker->bits_per_sample_) { + i2s_write_expand(this_speaker->parent_->get_port(), + this_speaker->data_buffer_ + i * single_dma_buffer_input_size, bytes_to_write, + audio_stream_info.get_bits_per_sample(), this_speaker->bits_per_sample_, &bytes_written, + pdMS_TO_TICKS(DMA_BUFFER_DURATION_MS * 5)); + } + + uint32_t write_timestamp = micros(); + + if (bytes_written != bytes_to_write) { + xEventGroupSetBits(this_speaker->event_group_, SpeakerEventGroupBits::ERR_ESP_INVALID_SIZE); + } + + bytes_read -= bytes_written; + + this_speaker->accumulated_frames_written_ += audio_stream_info.bytes_to_frames(bytes_written); + const uint32_t new_playback_ms = + audio_stream_info.frames_to_milliseconds_with_remainder(&this_speaker->accumulated_frames_written_); + const uint32_t remainder_us = + audio_stream_info.frames_to_microseconds(this_speaker->accumulated_frames_written_); + + uint32_t pending_frames = + audio_stream_info.bytes_to_frames(bytes_read + this_speaker->audio_ring_buffer_->available()); + const uint32_t pending_ms = audio_stream_info.frames_to_milliseconds_with_remainder(&pending_frames); + + this_speaker->audio_output_callback_(new_playback_ms, remainder_us, pending_ms, write_timestamp); + + tx_dma_underflow = false; + last_data_received_time = millis(); } - tx_dma_underflow = false; - last_data_received_time = millis(); } else { // No data received if (stop_gracefully && tx_dma_underflow) { @@ -328,7 +375,7 @@ void I2SAudioSpeaker::speaker_task(void *params) { this_speaker->parent_->unlock(); } - this_speaker->delete_task_(dma_buffers_size); + this_speaker->delete_task_(data_buffer_size); } void I2SAudioSpeaker::start() { @@ -337,16 +384,15 @@ void I2SAudioSpeaker::start() { if ((this->state_ == speaker::STATE_STARTING) || (this->state_ == speaker::STATE_RUNNING)) return; - if (this->speaker_task_handle_ == nullptr) { + if (!this->task_created_ && (this->speaker_task_handle_ == nullptr)) { xTaskCreate(I2SAudioSpeaker::speaker_task, "speaker_task", TASK_STACK_SIZE, (void *) this, TASK_PRIORITY, &this->speaker_task_handle_); - } - if (this->speaker_task_handle_ != nullptr) { - xEventGroupSetBits(this->event_group_, SpeakerEventGroupBits::COMMAND_START); - this->task_created_ = true; - } else { - xEventGroupSetBits(this->event_group_, SpeakerEventGroupBits::ERR_TASK_FAILED_TO_START); + if (this->speaker_task_handle_ != nullptr) { + xEventGroupSetBits(this->event_group_, SpeakerEventGroupBits::COMMAND_START); + } else { + xEventGroupSetBits(this->event_group_, SpeakerEventGroupBits::ERR_TASK_FAILED_TO_START); + } } } @@ -416,12 +462,12 @@ esp_err_t I2SAudioSpeaker::allocate_buffers_(size_t data_buffer_size, size_t rin } esp_err_t I2SAudioSpeaker::start_i2s_driver_(audio::AudioStreamInfo &audio_stream_info) { - if ((this->i2s_mode_ & I2S_MODE_SLAVE) && (this->sample_rate_ != audio_stream_info.sample_rate)) { // NOLINT - // Can't reconfigure I2S bus, so the sample rate must match the configured value + if ((this->i2s_mode_ & I2S_MODE_SLAVE) && (this->sample_rate_ != audio_stream_info.get_sample_rate())) { // NOLINT + // Can't reconfigure I2S bus, so the sample rate must match the configured value return ESP_ERR_NOT_SUPPORTED; } - if ((i2s_bits_per_sample_t) audio_stream_info.bits_per_sample > this->bits_per_sample_) { + if ((i2s_bits_per_sample_t) audio_stream_info.get_bits_per_sample() > this->bits_per_sample_) { // Currently can't handle the case when the incoming audio has more bits per sample than the configured value return ESP_ERR_NOT_SUPPORTED; } @@ -432,21 +478,21 @@ esp_err_t I2SAudioSpeaker::start_i2s_driver_(audio::AudioStreamInfo &audio_strea i2s_channel_fmt_t channel = this->channel_; - if (audio_stream_info.channels == 1) { + if (audio_stream_info.get_channels() == 1) { if (this->channel_ == I2S_CHANNEL_FMT_ONLY_LEFT) { channel = I2S_CHANNEL_FMT_ONLY_LEFT; } else { channel = I2S_CHANNEL_FMT_ONLY_RIGHT; } - } else if (audio_stream_info.channels == 2) { + } else if (audio_stream_info.get_channels() == 2) { channel = I2S_CHANNEL_FMT_RIGHT_LEFT; } - int dma_buffer_length = DMA_BUFFER_DURATION_MS * this->sample_rate_ / 1000; + int dma_buffer_length = audio_stream_info.ms_to_frames(DMA_BUFFER_DURATION_MS); i2s_driver_config_t config = { .mode = (i2s_mode_t) (this->i2s_mode_ | I2S_MODE_TX), - .sample_rate = audio_stream_info.sample_rate, + .sample_rate = audio_stream_info.get_sample_rate(), .bits_per_sample = this->bits_per_sample_, .channel_format = channel, .communication_format = this->i2s_comm_fmt_, @@ -504,7 +550,7 @@ esp_err_t I2SAudioSpeaker::start_i2s_driver_(audio::AudioStreamInfo &audio_strea } void I2SAudioSpeaker::delete_task_(size_t buffer_size) { - this->audio_ring_buffer_.reset(); // Releases onwership of the shared_ptr + this->audio_ring_buffer_.reset(); // Releases ownership of the shared_ptr if (this->data_buffer_ != nullptr) { ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); diff --git a/esphome/components/i2s_audio/speaker/i2s_audio_speaker.h b/esphome/components/i2s_audio/speaker/i2s_audio_speaker.h index d706deb0f4..7b14a57aac 100644 --- a/esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +++ b/esphome/components/i2s_audio/speaker/i2s_audio_speaker.h @@ -40,6 +40,9 @@ class I2SAudioSpeaker : public I2SAudioOut, public speaker::Speaker, public Comp void stop() override; void finish() override; + void set_pause_state(bool pause_state) override { this->pause_state_ = pause_state; } + bool get_pause_state() const override { return this->pause_state_; } + /// @brief Plays the provided audio data. /// Starts the speaker task, if necessary. Writes the audio data to the ring buffer. /// @param data Audio data in the format set by the parent speaker classes ``set_audio_stream_info`` method. @@ -121,13 +124,18 @@ class I2SAudioSpeaker : public I2SAudioOut, public speaker::Speaker, public Comp uint8_t dout_pin_; bool task_created_{false}; + bool pause_state_{false}; int16_t q15_volume_factor_{INT16_MAX}; + size_t bytes_written_{0}; + #if SOC_I2S_SUPPORTS_DAC i2s_dac_mode_t internal_dac_mode_{I2S_DAC_CHANNEL_DISABLE}; #endif i2s_comm_format_t i2s_comm_fmt_; + + uint32_t accumulated_frames_written_{0}; }; } // namespace i2s_audio diff --git a/esphome/components/speaker/__init__.py b/esphome/components/speaker/__init__.py index 948fe4b534..2ac1ca0cb9 100644 --- a/esphome/components/speaker/__init__.py +++ b/esphome/components/speaker/__init__.py @@ -1,7 +1,6 @@ from esphome import automation -from esphome.automation import maybe_simple_id import esphome.codegen as cg -from esphome.components import audio_dac +from esphome.components import audio, audio_dac import esphome.config_validation as cv from esphome.const import CONF_DATA, CONF_ID, CONF_VOLUME from esphome.core import CORE @@ -54,13 +53,15 @@ async def register_speaker(var, config): await setup_speaker_core_(var, config) -SPEAKER_SCHEMA = cv.Schema( +SPEAKER_SCHEMA = cv.Schema.extend(audio.AUDIO_COMPONENT_SCHEMA).extend( { cv.Optional(CONF_AUDIO_DAC): cv.use_id(audio_dac.AudioDac), } ) -SPEAKER_AUTOMATION_SCHEMA = maybe_simple_id({cv.GenerateID(): cv.use_id(Speaker)}) +SPEAKER_AUTOMATION_SCHEMA = automation.maybe_simple_id( + {cv.GenerateID(): cv.use_id(Speaker)} +) async def speaker_action(config, action_id, template_arg, args): diff --git a/esphome/components/speaker/speaker.h b/esphome/components/speaker/speaker.h index 96843e2d5a..74c4822eca 100644 --- a/esphome/components/speaker/speaker.h +++ b/esphome/components/speaker/speaker.h @@ -9,6 +9,7 @@ #endif #include "esphome/core/defines.h" +#include "esphome/core/helpers.h" #include "esphome/components/audio/audio.h" #ifdef USE_AUDIO_DAC @@ -56,6 +57,10 @@ class Speaker { // When finish() is not implemented on the platform component it should just do a normal stop. virtual void finish() { this->stop(); } + // Pauses processing incoming audio. Needs to be implemented specifically per speaker component + virtual void set_pause_state(bool pause_state) {} + virtual bool get_pause_state() const { return false; } + virtual bool has_buffered_data() const = 0; bool is_running() const { return this->state_ == STATE_RUNNING; } @@ -95,6 +100,19 @@ class Speaker { this->audio_stream_info_ = audio_stream_info; } + audio::AudioStreamInfo &get_audio_stream_info() { return this->audio_stream_info_; } + + /// Callback function for sending the duration of the audio written to the speaker since the last callback. + /// Parameters: + /// - Duration in milliseconds. Never rounded and should always be less than or equal to the actual duration. + /// - Remainder duration in microseconds. Rounded duration after subtracting the previous parameter from the actual + /// duration. + /// - Duration of remaining, unwritten audio buffered in the speaker in milliseconds. + /// - System time in microseconds when the last write was completed. + void add_audio_output_callback(std::function &&callback) { + this->audio_output_callback_.add(std::move(callback)); + } + protected: State state_{STATE_STOPPED}; audio::AudioStreamInfo audio_stream_info_; @@ -104,6 +122,8 @@ class Speaker { #ifdef USE_AUDIO_DAC audio_dac::AudioDac *audio_dac_{nullptr}; #endif + + CallbackManager audio_output_callback_{}; }; } // namespace speaker diff --git a/platformio.ini b/platformio.ini index e91c06d86e..cf11139b73 100644 --- a/platformio.ini +++ b/platformio.ini @@ -127,7 +127,8 @@ lib_deps = ESPmDNS ; mdns (Arduino built-in) DNSServer ; captive_portal (Arduino built-in) esphome/ESP32-audioI2S@2.0.7 ; i2s_audio - droscy/esp_wireguard@0.4.2 ; wireguard + droscy/esp_wireguard@0.4.2 ; wireguard + esphome/esp-audio-libs@1.1.1 ; audio build_flags = ${common:arduino.build_flags} @@ -148,6 +149,7 @@ lib_deps = ${common:idf.lib_deps} droscy/esp_wireguard@0.4.2 ; wireguard kahrendt/ESPMicroSpeechFeatures@1.1.0 ; micro_wake_word + esphome/esp-audio-libs@1.1.1 ; audio build_flags = ${common:idf.build_flags} -Wno-nonnull-compare From 6e5e6810559a4e8f8e8306bd8843609ae1a06ad9 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Sun, 2 Feb 2025 20:54:55 -0600 Subject: [PATCH 135/194] [audio] Media Player Components PR3 (#8165) --- .../audio/audio_transfer_buffer.cpp | 165 ++++++++++++++++++ .../components/audio/audio_transfer_buffer.h | 139 +++++++++++++++ 2 files changed, 304 insertions(+) create mode 100644 esphome/components/audio/audio_transfer_buffer.cpp create mode 100644 esphome/components/audio/audio_transfer_buffer.h diff --git a/esphome/components/audio/audio_transfer_buffer.cpp b/esphome/components/audio/audio_transfer_buffer.cpp new file mode 100644 index 0000000000..9b6067aac4 --- /dev/null +++ b/esphome/components/audio/audio_transfer_buffer.cpp @@ -0,0 +1,165 @@ +#include "audio_transfer_buffer.h" + +#ifdef USE_ESP32 + +#include "esphome/core/helpers.h" + +namespace esphome { +namespace audio { + +AudioTransferBuffer::~AudioTransferBuffer() { this->deallocate_buffer_(); }; + +std::unique_ptr AudioSinkTransferBuffer::create(size_t buffer_size) { + std::unique_ptr sink_buffer = make_unique(); + + if (!sink_buffer->allocate_buffer_(buffer_size)) { + return nullptr; + } + + return sink_buffer; +} + +std::unique_ptr AudioSourceTransferBuffer::create(size_t buffer_size) { + std::unique_ptr source_buffer = make_unique(); + + if (!source_buffer->allocate_buffer_(buffer_size)) { + return nullptr; + } + + return source_buffer; +} + +size_t AudioTransferBuffer::free() const { + if (this->buffer_size_ == 0) { + return 0; + } + return this->buffer_size_ - (this->buffer_length_ - (this->data_start_ - this->buffer_)); +} + +void AudioTransferBuffer::decrease_buffer_length(size_t bytes) { + this->buffer_length_ -= bytes; + this->data_start_ += bytes; +} + +void AudioTransferBuffer::increase_buffer_length(size_t bytes) { this->buffer_length_ += bytes; } + +void AudioTransferBuffer::clear_buffered_data() { + this->buffer_length_ = 0; + if (this->ring_buffer_.use_count() > 0) { + this->ring_buffer_->reset(); + } +} + +void AudioSinkTransferBuffer::clear_buffered_data() { + this->buffer_length_ = 0; + if (this->ring_buffer_.use_count() > 0) { + this->ring_buffer_->reset(); + } +#ifdef USE_SPEAKER + if (this->speaker_ != nullptr) { + this->speaker_->stop(); + } +#endif +} + +bool AudioTransferBuffer::has_buffered_data() const { + if (this->ring_buffer_.use_count() > 0) { + return ((this->ring_buffer_->available() > 0) || (this->available() > 0)); + } + return (this->available() > 0); +} + +bool AudioTransferBuffer::reallocate(size_t new_buffer_size) { + if (this->buffer_length_ > 0) { + // Already has data in the buffer, fail + return false; + } + this->deallocate_buffer_(); + return this->allocate_buffer_(new_buffer_size); +} + +bool AudioTransferBuffer::allocate_buffer_(size_t buffer_size) { + this->buffer_size_ = buffer_size; + + RAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + + this->buffer_ = allocator.allocate(this->buffer_size_); + if (this->buffer_ == nullptr) { + return false; + } + + this->data_start_ = this->buffer_; + this->buffer_length_ = 0; + + return true; +} + +void AudioTransferBuffer::deallocate_buffer_() { + if (this->buffer_ != nullptr) { + RAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + allocator.deallocate(this->buffer_, this->buffer_size_); + this->buffer_ = nullptr; + this->data_start_ = nullptr; + } + + this->buffer_size_ = 0; + this->buffer_length_ = 0; +} + +size_t AudioSourceTransferBuffer::transfer_data_from_source(TickType_t ticks_to_wait) { + // Shift data in buffer to start + if (this->buffer_length_ > 0) { + memmove(this->buffer_, this->data_start_, this->buffer_length_); + } + this->data_start_ = this->buffer_; + + size_t bytes_to_read = this->free(); + size_t bytes_read = 0; + if (bytes_to_read > 0) { + if (this->ring_buffer_.use_count() > 0) { + bytes_read = this->ring_buffer_->read((void *) this->get_buffer_end(), bytes_to_read, ticks_to_wait); + } + + this->increase_buffer_length(bytes_read); + } + return bytes_read; +} + +size_t AudioSinkTransferBuffer::transfer_data_to_sink(TickType_t ticks_to_wait) { + size_t bytes_written = 0; + if (this->available()) { +#ifdef USE_SPEAKER + if (this->speaker_ != nullptr) { + bytes_written = this->speaker_->play(this->data_start_, this->available(), ticks_to_wait); + } else +#endif + if (this->ring_buffer_.use_count() > 0) { + bytes_written = + this->ring_buffer_->write_without_replacement((void *) this->data_start_, this->available(), ticks_to_wait); + } + + this->decrease_buffer_length(bytes_written); + + // Shift unwritten data to the start of the buffer + memmove(this->buffer_, this->data_start_, this->buffer_length_); + this->data_start_ = this->buffer_; + } + return bytes_written; +} + +bool AudioSinkTransferBuffer::has_buffered_data() const { +#ifdef USE_SPEAKER + if (this->speaker_ != nullptr) { + return (this->speaker_->has_buffered_data() || (this->available() > 0)); + } +#endif + if (this->ring_buffer_.use_count() > 0) { + return ((this->ring_buffer_->available() > 0) || (this->available() > 0)); + } + return (this->available() > 0); +} + +} // namespace audio +} // namespace esphome + +#endif diff --git a/esphome/components/audio/audio_transfer_buffer.h b/esphome/components/audio/audio_transfer_buffer.h new file mode 100644 index 0000000000..4e461db56d --- /dev/null +++ b/esphome/components/audio/audio_transfer_buffer.h @@ -0,0 +1,139 @@ +#pragma once + +#ifdef USE_ESP32 +#include "esphome/core/defines.h" +#include "esphome/core/ring_buffer.h" + +#ifdef USE_SPEAKER +#include "esphome/components/speaker/speaker.h" +#endif + +#include "esp_err.h" + +#include + +namespace esphome { +namespace audio { + +class AudioTransferBuffer { + /* + * @brief Class that facilitates tranferring data between a buffer and an audio source or sink. + * The transfer buffer is a typical C array that temporarily holds data for processing in other audio components. + * Both sink and source transfer buffers can use a ring buffer as the sink/source. + * - The ring buffer is stored in a shared_ptr, so destroying the transfer buffer object will release ownership. + */ + public: + /// @brief Destructor that deallocates the transfer buffer + ~AudioTransferBuffer(); + + /// @brief Returns a pointer to the start of the transfer buffer where available() bytes of exisiting data can be read + uint8_t *get_buffer_start() const { return this->data_start_; } + + /// @brief Returns a pointer to the end of the transfer buffer where free() bytes of new data can be written + uint8_t *get_buffer_end() const { return this->data_start_ + this->buffer_length_; } + + /// @brief Updates the internal state of the transfer buffer. This should be called after reading data + /// @param bytes The number of bytes consumed/read + void decrease_buffer_length(size_t bytes); + + /// @brief Updates the internal state of the transfer buffer. This should be called after writing data + /// @param bytes The number of bytes written + void increase_buffer_length(size_t bytes); + + /// @brief Returns the transfer buffer's currently available bytes to read + size_t available() const { return this->buffer_length_; } + + /// @brief Returns the transfer buffers allocated bytes + size_t capacity() const { return this->buffer_size_; } + + /// @brief Returns the transfer buffer's currrently free bytes available to write + size_t free() const; + + /// @brief Clears data in the transfer buffer and, if possible, the source/sink. + virtual void clear_buffered_data(); + + /// @brief Tests if there is any data in the tranfer buffer or the source/sink. + /// @return True if there is data, false otherwise. + virtual bool has_buffered_data() const; + + bool reallocate(size_t new_buffer_size); + + protected: + /// @brief Allocates the transfer buffer in external memory, if available. + /// @return True is successful, false otherwise. + bool allocate_buffer_(size_t buffer_size); + + /// @brief Deallocates the buffer and resets the class variables. + void deallocate_buffer_(); + + // A possible source or sink for the transfer buffer + std::shared_ptr ring_buffer_; + + uint8_t *buffer_{nullptr}; + uint8_t *data_start_{nullptr}; + + size_t buffer_size_{0}; + size_t buffer_length_{0}; +}; + +class AudioSinkTransferBuffer : public AudioTransferBuffer { + /* + * @brief A class that implements a transfer buffer for audio sinks. + * Supports writing processed data in the transfer buffer to a ring buffer or a speaker component. + */ + public: + /// @brief Creates a new sink transfer buffer. + /// @param buffer_size Size of the transfer buffer in bytes. + /// @return unique_ptr if successfully allocated, nullptr otherwise + static std::unique_ptr create(size_t buffer_size); + + /// @brief Writes any available data in the transfer buffer to the sink. + /// @param ticks_to_wait FreeRTOS ticks to block while waiting for the sink to have enough space + /// @return Number of bytes written + size_t transfer_data_to_sink(TickType_t ticks_to_wait); + + /// @brief Adds a ring buffer as the transfer buffer's sink. + /// @param ring_buffer weak_ptr to the allocated ring buffer + void set_sink(const std::weak_ptr &ring_buffer) { this->ring_buffer_ = ring_buffer.lock(); } + +#ifdef USE_SPEAKER + /// @brief Adds a speaker as the transfer buffer's sink. + /// @param speaker Pointer to the speaker component + void set_sink(speaker::Speaker *speaker) { this->speaker_ = speaker; } +#endif + + void clear_buffered_data() override; + + bool has_buffered_data() const override; + + protected: +#ifdef USE_SPEAKER + speaker::Speaker *speaker_{nullptr}; +#endif +}; + +class AudioSourceTransferBuffer : public AudioTransferBuffer { + /* + * @brief A class that implements a transfer buffer for audio sources. + * Supports reading audio data from a ring buffer into the transfer buffer for processing. + */ + public: + /// @brief Creates a new source transfer buffer. + /// @param buffer_size Size of the transfer buffer in bytes. + /// @return unique_ptr if successfully allocated, nullptr otherwise + static std::unique_ptr create(size_t buffer_size); + + /// @brief Reads any available data from the sink into the transfer buffer. + /// @param ticks_to_wait FreeRTOS ticks to block while waiting for the source to have enough data + /// @return Number of bytes read + size_t transfer_data_from_source(TickType_t ticks_to_wait); + + /// @brief Adds a ring buffer as the transfer buffer's source. + /// @param ring_buffer weak_ptr to the allocated ring buffer + void set_source(const std::weak_ptr &ring_buffer) { this->ring_buffer_ = ring_buffer.lock(); }; +}; + +} // namespace audio +} // namespace esphome + +#endif From 8de5af4eecaddee52fe6416668c7bf27cf884f87 Mon Sep 17 00:00:00 2001 From: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> Date: Mon, 3 Feb 2025 04:55:55 +0100 Subject: [PATCH 136/194] Add virtual get_flags() to GPIOPin and implementation in InternalGPIOPin derivatives (#8151) --- esphome/components/esp32/gpio.h | 2 ++ esphome/components/esp8266/gpio.h | 1 + esphome/components/host/gpio.h | 1 + esphome/components/libretiny/gpio_arduino.h | 1 + esphome/components/rp2040/gpio.h | 1 + esphome/core/gpio.h | 10 ++++++++++ 6 files changed, 16 insertions(+) diff --git a/esphome/components/esp32/gpio.h b/esphome/components/esp32/gpio.h index 23b723e0b4..d69ac1c493 100644 --- a/esphome/components/esp32/gpio.h +++ b/esphome/components/esp32/gpio.h @@ -13,6 +13,7 @@ class ESP32InternalGPIOPin : public InternalGPIOPin { void set_inverted(bool inverted) { inverted_ = inverted; } void set_drive_strength(gpio_drive_cap_t drive_strength) { drive_strength_ = drive_strength; } void set_flags(gpio::Flags flags) { flags_ = flags; } + void setup() override; void pin_mode(gpio::Flags flags) override; bool digital_read() override; @@ -21,6 +22,7 @@ class ESP32InternalGPIOPin : public InternalGPIOPin { void detach_interrupt() const override; ISRInternalGPIOPin to_isr() const override; uint8_t get_pin() const override { return (uint8_t) pin_; } + gpio::Flags get_flags() const override { return flags_; } bool is_inverted() const override { return inverted_; } protected: diff --git a/esphome/components/esp8266/gpio.h b/esphome/components/esp8266/gpio.h index 0474d0baa6..dd6407885e 100644 --- a/esphome/components/esp8266/gpio.h +++ b/esphome/components/esp8266/gpio.h @@ -22,6 +22,7 @@ class ESP8266GPIOPin : public InternalGPIOPin { void detach_interrupt() const override; ISRInternalGPIOPin to_isr() const override; uint8_t get_pin() const override { return pin_; } + gpio::Flags get_flags() const override { return flags_; } bool is_inverted() const override { return inverted_; } protected: diff --git a/esphome/components/host/gpio.h b/esphome/components/host/gpio.h index c0920467d6..a60d535912 100644 --- a/esphome/components/host/gpio.h +++ b/esphome/components/host/gpio.h @@ -21,6 +21,7 @@ class HostGPIOPin : public InternalGPIOPin { void detach_interrupt() const override; ISRInternalGPIOPin to_isr() const override; uint8_t get_pin() const override { return pin_; } + gpio::Flags get_flags() const override { return flags_; } bool is_inverted() const override { return inverted_; } protected: diff --git a/esphome/components/libretiny/gpio_arduino.h b/esphome/components/libretiny/gpio_arduino.h index a43ed28c5e..9adc425a41 100644 --- a/esphome/components/libretiny/gpio_arduino.h +++ b/esphome/components/libretiny/gpio_arduino.h @@ -20,6 +20,7 @@ class ArduinoInternalGPIOPin : public InternalGPIOPin { void detach_interrupt() const override; ISRInternalGPIOPin to_isr() const override; uint8_t get_pin() const override { return pin_; } + gpio::Flags get_flags() const override { return flags_; } bool is_inverted() const override { return inverted_; } protected: diff --git a/esphome/components/rp2040/gpio.h b/esphome/components/rp2040/gpio.h index ef9500d5dd..9bc66d9e4b 100644 --- a/esphome/components/rp2040/gpio.h +++ b/esphome/components/rp2040/gpio.h @@ -22,6 +22,7 @@ class RP2040GPIOPin : public InternalGPIOPin { void detach_interrupt() const override; ISRInternalGPIOPin to_isr() const override; uint8_t get_pin() const override { return pin_; } + gpio::Flags get_flags() const override { return flags_; } bool is_inverted() const override { return inverted_; } protected: diff --git a/esphome/core/gpio.h b/esphome/core/gpio.h index 1b6f2ba1e6..19d57a0af8 100644 --- a/esphome/core/gpio.h +++ b/esphome/core/gpio.h @@ -53,6 +53,16 @@ class GPIOPin { virtual void pin_mode(gpio::Flags flags) = 0; + /** + * @brief Retrieve GPIO pin flags. + * + * @note This is currently optional to limit changes but will be mandatory in a future update. + * It is primarily applied to internal pins for now. + * + * @return The GPIO flags describing the pin mode and properties. Returns `gpio::Flags::FLAG_NONE` if not overridden. + */ + virtual gpio::Flags get_flags() const { return gpio::Flags::FLAG_NONE; } + virtual bool digital_read() = 0; virtual void digital_write(bool value) = 0; From 5108b9a8b7ca7bc3b541fd743d81821c47a6c000 Mon Sep 17 00:00:00 2001 From: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> Date: Mon, 3 Feb 2025 18:14:55 +0100 Subject: [PATCH 137/194] Make get_flags() in GPIOPin mandatory (#8182) Co-authored-by: Keith Burzinski --- esphome/components/ch422g/ch422g.h | 2 ++ esphome/components/max6956/max6956.h | 2 ++ esphome/components/mcp23016/mcp23016.h | 2 ++ esphome/components/mcp23xxx_base/mcp23xxx_base.h | 2 ++ esphome/components/mpr121/mpr121.h | 2 ++ esphome/components/pca6416a/pca6416a.h | 2 ++ esphome/components/pca9554/pca9554.h | 2 ++ esphome/components/pcf8574/pcf8574.h | 2 ++ esphome/components/sn74hc165/sn74hc165.h | 3 +++ esphome/components/sn74hc595/sn74hc595.h | 3 +++ esphome/components/spi/spi.h | 2 ++ esphome/components/sx1509/sx1509_gpio_pin.h | 2 ++ esphome/components/tca9555/tca9555.h | 2 ++ esphome/components/weikai/weikai.h | 2 ++ esphome/components/xl9535/xl9535.h | 2 ++ esphome/core/gpio.h | 7 ++----- 16 files changed, 34 insertions(+), 5 deletions(-) diff --git a/esphome/components/ch422g/ch422g.h b/esphome/components/ch422g/ch422g.h index 30780e09ad..1193a3db27 100644 --- a/esphome/components/ch422g/ch422g.h +++ b/esphome/components/ch422g/ch422g.h @@ -57,6 +57,8 @@ class CH422GGPIOPin : public GPIOPin { void set_inverted(bool inverted) { inverted_ = inverted; } void set_flags(gpio::Flags flags); + gpio::Flags get_flags() const override { return this->flags_; } + protected: CH422GComponent *parent_{}; uint8_t pin_{}; diff --git a/esphome/components/max6956/max6956.h b/esphome/components/max6956/max6956.h index 759fa45b07..0a1fd5e4b5 100644 --- a/esphome/components/max6956/max6956.h +++ b/esphome/components/max6956/max6956.h @@ -83,6 +83,8 @@ class MAX6956GPIOPin : public GPIOPin { void set_inverted(bool inverted) { inverted_ = inverted; } void set_flags(gpio::Flags flags) { flags_ = flags; } + gpio::Flags get_flags() const override { return this->flags_; } + protected: MAX6956 *parent_; uint8_t pin_; diff --git a/esphome/components/mcp23016/mcp23016.h b/esphome/components/mcp23016/mcp23016.h index a4890b4120..e4ed47a3b2 100644 --- a/esphome/components/mcp23016/mcp23016.h +++ b/esphome/components/mcp23016/mcp23016.h @@ -61,6 +61,8 @@ class MCP23016GPIOPin : public GPIOPin { void set_inverted(bool inverted) { inverted_ = inverted; } void set_flags(gpio::Flags flags) { flags_ = flags; } + gpio::Flags get_flags() const override { return this->flags_; } + protected: MCP23016 *parent_; uint8_t pin_; diff --git a/esphome/components/mcp23xxx_base/mcp23xxx_base.h b/esphome/components/mcp23xxx_base/mcp23xxx_base.h index a522ea28c5..9686c9fd33 100644 --- a/esphome/components/mcp23xxx_base/mcp23xxx_base.h +++ b/esphome/components/mcp23xxx_base/mcp23xxx_base.h @@ -43,6 +43,8 @@ class MCP23XXXGPIOPin : public GPIOPin { void set_flags(gpio::Flags flags) { flags_ = flags; } void set_interrupt_mode(MCP23XXXInterruptMode interrupt_mode) { interrupt_mode_ = interrupt_mode; } + gpio::Flags get_flags() const override { return this->flags_; } + protected: MCP23XXXBase *parent_; uint8_t pin_; diff --git a/esphome/components/mpr121/mpr121.h b/esphome/components/mpr121/mpr121.h index f2dc2fe9c9..eb2e2edc57 100644 --- a/esphome/components/mpr121/mpr121.h +++ b/esphome/components/mpr121/mpr121.h @@ -117,6 +117,8 @@ class MPR121GPIOPin : public GPIOPin { void set_inverted(bool inverted) { this->inverted_ = inverted; } void set_flags(gpio::Flags flags) { this->flags_ = flags; } + gpio::Flags get_flags() const override { return this->flags_; } + protected: MPR121Component *parent_; uint8_t pin_; diff --git a/esphome/components/pca6416a/pca6416a.h b/esphome/components/pca6416a/pca6416a.h index 247f443e87..1e8015c40a 100644 --- a/esphome/components/pca6416a/pca6416a.h +++ b/esphome/components/pca6416a/pca6416a.h @@ -52,6 +52,8 @@ class PCA6416AGPIOPin : public GPIOPin { void set_inverted(bool inverted) { inverted_ = inverted; } void set_flags(gpio::Flags flags) { flags_ = flags; } + gpio::Flags get_flags() const override { return this->flags_; } + protected: PCA6416AComponent *parent_; uint8_t pin_; diff --git a/esphome/components/pca9554/pca9554.h b/esphome/components/pca9554/pca9554.h index c548bec619..efeec4d306 100644 --- a/esphome/components/pca9554/pca9554.h +++ b/esphome/components/pca9554/pca9554.h @@ -65,6 +65,8 @@ class PCA9554GPIOPin : public GPIOPin { void set_inverted(bool inverted) { inverted_ = inverted; } void set_flags(gpio::Flags flags) { flags_ = flags; } + gpio::Flags get_flags() const override { return this->flags_; } + protected: PCA9554Component *parent_; uint8_t pin_; diff --git a/esphome/components/pcf8574/pcf8574.h b/esphome/components/pcf8574/pcf8574.h index c201e0615f..6edc67fc96 100644 --- a/esphome/components/pcf8574/pcf8574.h +++ b/esphome/components/pcf8574/pcf8574.h @@ -54,6 +54,8 @@ class PCF8574GPIOPin : public GPIOPin { void set_inverted(bool inverted) { inverted_ = inverted; } void set_flags(gpio::Flags flags) { flags_ = flags; } + gpio::Flags get_flags() const override { return this->flags_; } + protected: PCF8574Component *parent_; uint8_t pin_; diff --git a/esphome/components/sn74hc165/sn74hc165.h b/esphome/components/sn74hc165/sn74hc165.h index c349d079ae..4684844687 100644 --- a/esphome/components/sn74hc165/sn74hc165.h +++ b/esphome/components/sn74hc165/sn74hc165.h @@ -52,6 +52,9 @@ class SN74HC165GPIOPin : public GPIOPin, public Parented { void set_pin(uint16_t pin) { pin_ = pin; } void set_inverted(bool inverted) { inverted_ = inverted; } + /// Always returns `gpio::Flags::FLAG_INPUT`. + gpio::Flags get_flags() const override { return gpio::Flags::FLAG_INPUT; } + protected: uint16_t pin_; bool inverted_; diff --git a/esphome/components/sn74hc595/sn74hc595.h b/esphome/components/sn74hc595/sn74hc595.h index cb9d7bf140..181015b1e6 100644 --- a/esphome/components/sn74hc595/sn74hc595.h +++ b/esphome/components/sn74hc595/sn74hc595.h @@ -59,6 +59,9 @@ class SN74HC595GPIOPin : public GPIOPin, public Parented { void set_pin(uint16_t pin) { pin_ = pin; } void set_inverted(bool inverted) { inverted_ = inverted; } + /// Always returns `gpio::Flags::FLAG_OUTPUT`. + gpio::Flags get_flags() const override { return gpio::Flags::FLAG_OUTPUT; } + protected: uint16_t pin_; bool inverted_; diff --git a/esphome/components/spi/spi.h b/esphome/components/spi/spi.h index f581dc3f56..64463747a2 100644 --- a/esphome/components/spi/spi.h +++ b/esphome/components/spi/spi.h @@ -114,6 +114,8 @@ class NullPin : public GPIOPin { void pin_mode(gpio::Flags flags) override {} + gpio::Flags get_flags() const override { return gpio::Flags::FLAG_NONE; } + bool digital_read() override { return false; } void digital_write(bool value) override {} diff --git a/esphome/components/sx1509/sx1509_gpio_pin.h b/esphome/components/sx1509/sx1509_gpio_pin.h index 1cfa341ee7..eb9207e882 100644 --- a/esphome/components/sx1509/sx1509_gpio_pin.h +++ b/esphome/components/sx1509/sx1509_gpio_pin.h @@ -20,6 +20,8 @@ class SX1509GPIOPin : public GPIOPin { void set_inverted(bool inverted) { this->inverted_ = inverted; } void set_flags(gpio::Flags flags) { this->flags_ = flags; } + gpio::Flags get_flags() const override { return this->flags_; } + protected: SX1509Component *parent_; uint8_t pin_; diff --git a/esphome/components/tca9555/tca9555.h b/esphome/components/tca9555/tca9555.h index ea464db043..0c236ae4e3 100644 --- a/esphome/components/tca9555/tca9555.h +++ b/esphome/components/tca9555/tca9555.h @@ -54,6 +54,8 @@ class TCA9555GPIOPin : public GPIOPin, public Parented { void set_inverted(bool inverted) { this->inverted_ = inverted; } void set_flags(gpio::Flags flags) { this->flags_ = flags; } + gpio::Flags get_flags() const override { return this->flags_; } + protected: uint8_t pin_; bool inverted_; diff --git a/esphome/components/weikai/weikai.h b/esphome/components/weikai/weikai.h index 175a067b27..987278213a 100644 --- a/esphome/components/weikai/weikai.h +++ b/esphome/components/weikai/weikai.h @@ -275,6 +275,8 @@ class WeikaiGPIOPin : public GPIOPin { void set_inverted(bool inverted) { this->inverted_ = inverted; } void set_flags(gpio::Flags flags) { this->flags_ = flags; } + gpio::Flags get_flags() const override { return this->flags_; } + void setup() override; std::string dump_summary() const override; void pin_mode(gpio::Flags flags) override { this->parent_->set_pin_direction_(this->pin_, flags); } diff --git a/esphome/components/xl9535/xl9535.h b/esphome/components/xl9535/xl9535.h index dd67990fa8..3b511fd9b3 100644 --- a/esphome/components/xl9535/xl9535.h +++ b/esphome/components/xl9535/xl9535.h @@ -36,6 +36,8 @@ class XL9535GPIOPin : public GPIOPin { void set_inverted(bool inverted) { this->inverted_ = inverted; } void set_flags(gpio::Flags flags) { this->flags_ = flags; } + gpio::Flags get_flags() const override { return this->flags_; } + void setup() override; std::string dump_summary() const override; void pin_mode(gpio::Flags flags) override; diff --git a/esphome/core/gpio.h b/esphome/core/gpio.h index 19d57a0af8..dd6f14fef9 100644 --- a/esphome/core/gpio.h +++ b/esphome/core/gpio.h @@ -56,12 +56,9 @@ class GPIOPin { /** * @brief Retrieve GPIO pin flags. * - * @note This is currently optional to limit changes but will be mandatory in a future update. - * It is primarily applied to internal pins for now. - * - * @return The GPIO flags describing the pin mode and properties. Returns `gpio::Flags::FLAG_NONE` if not overridden. + * @return The GPIO flags describing the pin mode and properties. */ - virtual gpio::Flags get_flags() const { return gpio::Flags::FLAG_NONE; } + virtual gpio::Flags get_flags() const = 0; virtual bool digital_read() = 0; From c8bbc2e84c2eb53c58ec43f0e69a2a4501f8afab Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Mon, 3 Feb 2025 16:34:20 -0600 Subject: [PATCH 138/194] [audio] Media Player Components PR4 (#8166) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/audio/audio_reader.cpp | 308 ++++++++++++++++++++++ esphome/components/audio/audio_reader.h | 85 ++++++ 2 files changed, 393 insertions(+) create mode 100644 esphome/components/audio/audio_reader.cpp create mode 100644 esphome/components/audio/audio_reader.h diff --git a/esphome/components/audio/audio_reader.cpp b/esphome/components/audio/audio_reader.cpp new file mode 100644 index 0000000000..b93e4e74ea --- /dev/null +++ b/esphome/components/audio/audio_reader.cpp @@ -0,0 +1,308 @@ +#include "audio_reader.h" + +#ifdef USE_ESP_IDF + +#include "esphome/core/defines.h" +#include "esphome/core/hal.h" +#include "esphome/core/helpers.h" + +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE +#include "esp_crt_bundle.h" +#endif + +namespace esphome { +namespace audio { + +static const uint32_t READ_WRITE_TIMEOUT_MS = 20; + +// 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; + +static const size_t HTTP_STREAM_BUFFER_SIZE = 2048; + +static const uint8_t MAX_REDIRECTION = 5; + +// Some common HTTP status codes - borrowed from http_request component accessed 20241224 +enum HttpStatus { + HTTP_STATUS_OK = 200, + HTTP_STATUS_NO_CONTENT = 204, + HTTP_STATUS_PARTIAL_CONTENT = 206, + + /* 3xx - Redirection */ + HTTP_STATUS_MULTIPLE_CHOICES = 300, + HTTP_STATUS_MOVED_PERMANENTLY = 301, + HTTP_STATUS_FOUND = 302, + HTTP_STATUS_SEE_OTHER = 303, + HTTP_STATUS_NOT_MODIFIED = 304, + HTTP_STATUS_TEMPORARY_REDIRECT = 307, + HTTP_STATUS_PERMANENT_REDIRECT = 308, + + /* 4XX - CLIENT ERROR */ + HTTP_STATUS_BAD_REQUEST = 400, + HTTP_STATUS_UNAUTHORIZED = 401, + HTTP_STATUS_FORBIDDEN = 403, + HTTP_STATUS_NOT_FOUND = 404, + HTTP_STATUS_METHOD_NOT_ALLOWED = 405, + HTTP_STATUS_NOT_ACCEPTABLE = 406, + HTTP_STATUS_LENGTH_REQUIRED = 411, + + /* 5xx - Server Error */ + HTTP_STATUS_INTERNAL_ERROR = 500 +}; + +AudioReader::~AudioReader() { this->cleanup_connection_(); } + +esp_err_t AudioReader::add_sink(const std::weak_ptr &output_ring_buffer) { + if (current_audio_file_ != nullptr) { + // A transfer buffer isn't ncessary for a local file + this->file_ring_buffer_ = output_ring_buffer.lock(); + return ESP_OK; + } + + if (this->output_transfer_buffer_ != nullptr) { + this->output_transfer_buffer_->set_sink(output_ring_buffer); + return ESP_OK; + } + + return ESP_ERR_INVALID_STATE; +} + +esp_err_t AudioReader::start(AudioFile *audio_file, AudioFileType &file_type) { + file_type = AudioFileType::NONE; + + this->current_audio_file_ = audio_file; + + this->file_current_ = audio_file->data; + file_type = audio_file->file_type; + + return ESP_OK; +} + +esp_err_t AudioReader::start(const std::string &uri, AudioFileType &file_type) { + file_type = AudioFileType::NONE; + + this->cleanup_connection_(); + + if (uri.empty()) { + return ESP_ERR_INVALID_ARG; + } + + esp_http_client_config_t client_config = {}; + + client_config.url = uri.c_str(); + client_config.cert_pem = nullptr; + client_config.disable_auto_redirect = false; + client_config.max_redirection_count = 10; + client_config.event_handler = http_event_handler; + 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 + +#if CONFIG_MBEDTLS_CERTIFICATE_BUNDLE + if (uri.find("https:") != std::string::npos) { + client_config.crt_bundle_attach = esp_crt_bundle_attach; + } +#endif + + this->client_ = esp_http_client_init(&client_config); + + if (this->client_ == nullptr) { + return ESP_FAIL; + } + + esp_err_t err = esp_http_client_open(this->client_, 0); + + if (err != ESP_OK) { + this->cleanup_connection_(); + return err; + } + + int64_t header_length = esp_http_client_fetch_headers(this->client_); + if (header_length < 0) { + this->cleanup_connection_(); + return ESP_FAIL; + } + + int status_code = esp_http_client_get_status_code(this->client_); + + if ((status_code < HTTP_STATUS_OK) || (status_code > HTTP_STATUS_PERMANENT_REDIRECT)) { + this->cleanup_connection_(); + return ESP_FAIL; + } + + ssize_t redirect_count = 0; + + while ((esp_http_client_set_redirection(this->client_) == ESP_OK) && (redirect_count < MAX_REDIRECTION)) { + err = esp_http_client_open(this->client_, 0); + if (err != ESP_OK) { + this->cleanup_connection_(); + return ESP_FAIL; + } + + header_length = esp_http_client_fetch_headers(this->client_); + if (header_length < 0) { + this->cleanup_connection_(); + return ESP_FAIL; + } + + status_code = esp_http_client_get_status_code(this->client_); + + if ((status_code < HTTP_STATUS_OK) || (status_code > HTTP_STATUS_PERMANENT_REDIRECT)) { + this->cleanup_connection_(); + return ESP_FAIL; + } + + ++redirect_count; + } + + if (this->audio_file_type_ == AudioFileType::NONE) { + // Failed to determine the file type from the header, fallback to using the url + char url[500]; + err = esp_http_client_get_url(this->client_, url, 500); + if (err != ESP_OK) { + this->cleanup_connection_(); + return err; + } + + std::string url_string = str_lower_case(url); + + if (str_endswith(url_string, ".wav")) { + file_type = AudioFileType::WAV; + } +#ifdef USE_AUDIO_MP3_SUPPORT + else if (str_endswith(url_string, ".mp3")) { + file_type = AudioFileType::MP3; + } +#endif +#ifdef USE_AUDIO_FLAC_SUPPORT + else if (str_endswith(url_string, ".flac")) { + file_type = AudioFileType::FLAC; + } +#endif + else { + file_type = AudioFileType::NONE; + this->cleanup_connection_(); + return ESP_ERR_NOT_SUPPORTED; + } + } else { + file_type = this->audio_file_type_; + } + + this->no_data_read_count_ = 0; + + this->output_transfer_buffer_ = AudioSinkTransferBuffer::create(this->buffer_size_); + if (this->output_transfer_buffer_ == nullptr) { + return ESP_ERR_NO_MEM; + } + + return ESP_OK; +} + +AudioReaderState AudioReader::read() { + if (this->client_ != nullptr) { + return this->http_read_(); + } else if (this->current_audio_file_ != nullptr) { + return this->file_read_(); + } + + return AudioReaderState::FAILED; +} + +AudioFileType AudioReader::get_audio_type(const char *content_type) { +#ifdef USE_AUDIO_MP3_SUPPORT + if (strcasecmp(content_type, "mp3") == 0 || strcasecmp(content_type, "audio/mp3") == 0 || + strcasecmp(content_type, "audio/mpeg") == 0) { + return AudioFileType::MP3; + } +#endif + if (strcasecmp(content_type, "audio/wav") == 0) { + return AudioFileType::WAV; + } +#ifdef USE_AUDIO_FLAC_SUPPORT + if (strcasecmp(content_type, "audio/flac") == 0 || strcasecmp(content_type, "audio/x-flac") == 0) { + return AudioFileType::FLAC; + } +#endif + return AudioFileType::NONE; +} + +esp_err_t AudioReader::http_event_handler(esp_http_client_event_t *evt) { + // Based on https://github.com/maroc81/WeatherLily/tree/main/main/net accessed 20241224 + AudioReader *this_reader = (AudioReader *) evt->user_data; + + switch (evt->event_id) { + case HTTP_EVENT_ON_HEADER: + if (strcasecmp(evt->header_key, "Content-Type") == 0) { + this_reader->audio_file_type_ = get_audio_type(evt->header_value); + } + break; + default: + break; + } + return ESP_OK; +} + +AudioReaderState AudioReader::file_read_() { + size_t remaining_bytes = this->current_audio_file_->length - (this->file_current_ - this->current_audio_file_->data); + if (remaining_bytes > 0) { + size_t bytes_written = this->file_ring_buffer_->write_without_replacement(this->file_current_, remaining_bytes, + pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS)); + this->file_current_ += bytes_written; + + return AudioReaderState::READING; + } + + return AudioReaderState::FINISHED; +} + +AudioReaderState AudioReader::http_read_() { + this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS)); + + if (esp_http_client_is_complete_data_received(this->client_)) { + if (this->output_transfer_buffer_->available() == 0) { + this->cleanup_connection_(); + return AudioReaderState::FINISHED; + } + } else { + size_t bytes_to_read = this->output_transfer_buffer_->free(); + int received_len = + esp_http_client_read(this->client_, (char *) this->output_transfer_buffer_->get_buffer_end(), bytes_to_read); + + if (received_len > 0) { + this->output_transfer_buffer_->increase_buffer_length(received_len); + + this->no_data_read_count_ = 0; + } else if (received_len < 0) { + // HTTP read error + this->cleanup_connection_(); + return AudioReaderState::FAILED; + } 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 + this->cleanup_connection_(); + return AudioReaderState::FAILED; + } + delay(READ_WRITE_TIMEOUT_MS); + } + } + } + + return AudioReaderState::READING; +} + +void AudioReader::cleanup_connection_() { + if (this->client_ != nullptr) { + esp_http_client_close(this->client_); + esp_http_client_cleanup(this->client_); + this->client_ = nullptr; + } +} + +} // namespace audio +} // namespace esphome + +#endif diff --git a/esphome/components/audio/audio_reader.h b/esphome/components/audio/audio_reader.h new file mode 100644 index 0000000000..90113e6dda --- /dev/null +++ b/esphome/components/audio/audio_reader.h @@ -0,0 +1,85 @@ +#pragma once + +#ifdef USE_ESP_IDF + +#include "audio.h" +#include "audio_transfer_buffer.h" + +#include "esphome/core/ring_buffer.h" + +#include "esp_err.h" + +#include + +namespace esphome { +namespace audio { + +enum class AudioReaderState : uint8_t { + READING = 0, // More data is available to read + FINISHED, // All data has been read and transferred + FAILED, // Encountered an error +}; + +class AudioReader { + /* + * @brief Class that facilitates reading a raw audio file. + * Files can be read from flash (stored in a AudioFile struct) or from an http source. + * The file data is sent to a ring buffer sink. + */ + public: + /// @brief Constructs an AudioReader object. + /// The transfer buffer isn't allocated here, but only if necessary (an http source) in the start function. + /// @param buffer_size Transfer buffer size in bytes. + AudioReader(size_t buffer_size) : buffer_size_(buffer_size) {} + ~AudioReader(); + + /// @brief Adds a sink ring buffer for audio data. Takes ownership of the ring buffer in a shared_ptr + /// @param output_ring_buffer weak_ptr of a shared_ptr of the sink ring buffer to transfer ownership + /// @return ESP_OK if successful, ESP_ERR_INVALID_STATE otherwise + esp_err_t add_sink(const std::weak_ptr &output_ring_buffer); + + /// @brief Starts reading an audio file from an http source. The transfer buffer is allocated here. + /// @param uri Web url to the http file. + /// @param file_type AudioFileType variable passed-by-reference indicating the type of file being read. + /// @return ESP_OK if successful, an ESP_ERR* code otherwise. + esp_err_t start(const std::string &uri, AudioFileType &file_type); + + /// @brief Starts reading an audio file from flash. No transfer buffer is allocated. + /// @param audio_file AudioFile struct containing the file. + /// @param file_type AudioFileType variable passed-by-reference indicating the type of file being read. + /// @return ESP_OK + esp_err_t start(AudioFile *audio_file, AudioFileType &file_type); + + /// @brief Reads new file data from the source and sends to the ring buffer sink. + /// @return AudioReaderState + AudioReaderState read(); + + protected: + /// @brief Monitors the http client events to attempt determining the file type from the Content-Type header + static esp_err_t http_event_handler(esp_http_client_event_t *evt); + + /// @brief Determines the audio file type from the http header's Content-Type key + /// @param content_type string with the Content-Type key + /// @return AudioFileType of the url, if it can be determined. If not, return AudioFileType::NONE. + static AudioFileType get_audio_type(const char *content_type); + + AudioReaderState file_read_(); + AudioReaderState http_read_(); + + std::shared_ptr file_ring_buffer_; + std::unique_ptr output_transfer_buffer_; + void cleanup_connection_(); + + size_t buffer_size_; + uint32_t no_data_read_count_; + + esp_http_client_handle_t client_{nullptr}; + + AudioFile *current_audio_file_{nullptr}; + AudioFileType audio_file_type_{AudioFileType::NONE}; + const uint8_t *file_current_{nullptr}; +}; +} // namespace audio +} // namespace esphome + +#endif From b8f9eaecd85fc2b9e6b3086f030b6fe76d94c656 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Mon, 3 Feb 2025 17:47:50 -0600 Subject: [PATCH 139/194] [audio] Media Player Components PR5 (#8167) --- esphome/components/audio/audio_decoder.cpp | 362 +++++++++++++++++++++ esphome/components/audio/audio_decoder.h | 135 ++++++++ 2 files changed, 497 insertions(+) create mode 100644 esphome/components/audio/audio_decoder.cpp create mode 100644 esphome/components/audio/audio_decoder.h diff --git a/esphome/components/audio/audio_decoder.cpp b/esphome/components/audio/audio_decoder.cpp new file mode 100644 index 0000000000..b249f1381d --- /dev/null +++ b/esphome/components/audio/audio_decoder.cpp @@ -0,0 +1,362 @@ +#include "audio_decoder.h" + +#ifdef USE_ESP32 + +#include "esphome/core/hal.h" + +namespace esphome { +namespace audio { + +static const uint32_t DECODING_TIMEOUT_MS = 50; // The decode function will yield after this duration +static const uint32_t READ_WRITE_TIMEOUT_MS = 20; // Timeout for transferring audio data + +static const uint32_t MAX_POTENTIALLY_FAILED_COUNT = 10; + +AudioDecoder::AudioDecoder(size_t input_buffer_size, size_t output_buffer_size) { + this->input_transfer_buffer_ = AudioSourceTransferBuffer::create(input_buffer_size); + this->output_transfer_buffer_ = AudioSinkTransferBuffer::create(output_buffer_size); +} + +AudioDecoder::~AudioDecoder() { +#ifdef USE_AUDIO_MP3_SUPPORT + if (this->audio_file_type_ == AudioFileType::MP3) { + esp_audio_libs::helix_decoder::MP3FreeDecoder(this->mp3_decoder_); + } +#endif +} + +esp_err_t AudioDecoder::add_source(std::weak_ptr &input_ring_buffer) { + if (this->input_transfer_buffer_ != nullptr) { + this->input_transfer_buffer_->set_source(input_ring_buffer); + return ESP_OK; + } + return ESP_ERR_NO_MEM; +} + +esp_err_t AudioDecoder::add_sink(std::weak_ptr &output_ring_buffer) { + if (this->output_transfer_buffer_ != nullptr) { + this->output_transfer_buffer_->set_sink(output_ring_buffer); + return ESP_OK; + } + return ESP_ERR_NO_MEM; +} + +#ifdef USE_SPEAKER +esp_err_t AudioDecoder::add_sink(speaker::Speaker *speaker) { + if (this->output_transfer_buffer_ != nullptr) { + this->output_transfer_buffer_->set_sink(speaker); + return ESP_OK; + } + return ESP_ERR_NO_MEM; +} +#endif + +esp_err_t AudioDecoder::start(AudioFileType audio_file_type) { + if ((this->input_transfer_buffer_ == nullptr) || (this->output_transfer_buffer_ == nullptr)) { + return ESP_ERR_NO_MEM; + } + + this->audio_file_type_ = audio_file_type; + + this->potentially_failed_count_ = 0; + this->end_of_file_ = false; + + switch (this->audio_file_type_) { +#ifdef USE_AUDIO_FLAC_SUPPORT + case AudioFileType::FLAC: + this->flac_decoder_ = make_unique(); + this->free_buffer_required_ = + this->output_transfer_buffer_->capacity(); // We'll revise this after reading the header + break; +#endif +#ifdef USE_AUDIO_MP3_SUPPORT + case AudioFileType::MP3: + this->mp3_decoder_ = esp_audio_libs::helix_decoder::MP3InitDecoder(); + this->free_buffer_required_ = 1152 * sizeof(int16_t) * 2; // samples * size per sample * channels + break; +#endif + case AudioFileType::WAV: + this->wav_decoder_ = make_unique(); + this->wav_decoder_->reset(); + this->free_buffer_required_ = 1024; + break; + case AudioFileType::NONE: + default: + return ESP_ERR_NOT_SUPPORTED; + break; + } + + return ESP_OK; +} + +AudioDecoderState AudioDecoder::decode(bool stop_gracefully) { + if (stop_gracefully) { + if (this->output_transfer_buffer_->available() == 0) { + if (this->end_of_file_) { + // The file decoder indicates it reached the end of file + return AudioDecoderState::FINISHED; + } + + if (!this->input_transfer_buffer_->has_buffered_data()) { + // If all the internal buffers are empty, the decoding is done + return AudioDecoderState::FINISHED; + } + } + } + + if (this->potentially_failed_count_ > MAX_POTENTIALLY_FAILED_COUNT) { + if (stop_gracefully) { + // No more new data is going to come in, so decoding is done + return AudioDecoderState::FINISHED; + } + return AudioDecoderState::FAILED; + } + + FileDecoderState state = FileDecoderState::MORE_TO_PROCESS; + + uint32_t decoding_start = millis(); + + while (state == FileDecoderState::MORE_TO_PROCESS) { + // Transfer decoded out + if (!this->pause_output_) { + size_t bytes_written = this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS)); + if (this->audio_stream_info_.has_value()) { + this->accumulated_frames_written_ += this->audio_stream_info_.value().bytes_to_frames(bytes_written); + this->playback_ms_ += + this->audio_stream_info_.value().frames_to_milliseconds_with_remainder(&this->accumulated_frames_written_); + } + } else { + // If paused, block to avoid wasting CPU resources + delay(READ_WRITE_TIMEOUT_MS); + } + + // Verify there is enough space to store more decoded audio and that the function hasn't been running too long + if ((this->output_transfer_buffer_->free() < this->free_buffer_required_) || + (millis() - decoding_start > DECODING_TIMEOUT_MS)) { + return AudioDecoderState::DECODING; + } + + // Decode more audio + + size_t bytes_read = this->input_transfer_buffer_->transfer_data_from_source(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS)); + + if ((this->potentially_failed_count_ > 0) && (bytes_read == 0)) { + // Failed to decode in last attempt and there is no new data + + if (this->input_transfer_buffer_->free() == 0) { + // The input buffer is full. Since it previously failed on the exact same data, we can never recover + state = FileDecoderState::FAILED; + } else { + // Attempt to get more data next time + state = FileDecoderState::IDLE; + } + } else if (this->input_transfer_buffer_->available() == 0) { + // No data to decode, attempt to get more data next time + state = FileDecoderState::IDLE; + } else { + switch (this->audio_file_type_) { +#ifdef USE_AUDIO_FLAC_SUPPORT + case AudioFileType::FLAC: + state = this->decode_flac_(); + break; +#endif +#ifdef USE_AUDIO_MP3_SUPPORT + case AudioFileType::MP3: + state = this->decode_mp3_(); + break; +#endif + case AudioFileType::WAV: + state = this->decode_wav_(); + break; + case AudioFileType::NONE: + default: + state = FileDecoderState::IDLE; + break; + } + } + + if (state == FileDecoderState::POTENTIALLY_FAILED) { + ++this->potentially_failed_count_; + } else if (state == FileDecoderState::END_OF_FILE) { + this->end_of_file_ = true; + } else if (state == FileDecoderState::FAILED) { + return AudioDecoderState::FAILED; + } else if (state == FileDecoderState::MORE_TO_PROCESS) { + this->potentially_failed_count_ = 0; + } + } + return AudioDecoderState::DECODING; +} + +#ifdef USE_AUDIO_FLAC_SUPPORT +FileDecoderState AudioDecoder::decode_flac_() { + if (!this->audio_stream_info_.has_value()) { + // Header hasn't been read + auto result = this->flac_decoder_->read_header(this->input_transfer_buffer_->get_buffer_start(), + this->input_transfer_buffer_->available()); + + if (result == esp_audio_libs::flac::FLAC_DECODER_HEADER_OUT_OF_DATA) { + return FileDecoderState::POTENTIALLY_FAILED; + } + + if (result != esp_audio_libs::flac::FLAC_DECODER_SUCCESS) { + // Couldn't read FLAC header + return FileDecoderState::FAILED; + } + + size_t bytes_consumed = this->flac_decoder_->get_bytes_index(); + this->input_transfer_buffer_->decrease_buffer_length(bytes_consumed); + + this->free_buffer_required_ = flac_decoder_->get_output_buffer_size_bytes(); + if (this->output_transfer_buffer_->capacity() < this->free_buffer_required_) { + // Output buffer is not big enough + if (!this->output_transfer_buffer_->reallocate(this->free_buffer_required_)) { + // Couldn't reallocate output buffer + return FileDecoderState::FAILED; + } + } + + this->audio_stream_info_ = + audio::AudioStreamInfo(this->flac_decoder_->get_sample_depth(), this->flac_decoder_->get_num_channels(), + this->flac_decoder_->get_sample_rate()); + + return FileDecoderState::MORE_TO_PROCESS; + } + + uint32_t output_samples = 0; + auto result = this->flac_decoder_->decode_frame( + this->input_transfer_buffer_->get_buffer_start(), this->input_transfer_buffer_->available(), + reinterpret_cast(this->output_transfer_buffer_->get_buffer_end()), &output_samples); + + if (result == esp_audio_libs::flac::FLAC_DECODER_ERROR_OUT_OF_DATA) { + // Not an issue, just needs more data that we'll get next time. + return FileDecoderState::POTENTIALLY_FAILED; + } + + size_t bytes_consumed = this->flac_decoder_->get_bytes_index(); + this->input_transfer_buffer_->decrease_buffer_length(bytes_consumed); + + if (result > esp_audio_libs::flac::FLAC_DECODER_ERROR_OUT_OF_DATA) { + // Corrupted frame, don't retry with current buffer content, wait for new sync + return FileDecoderState::POTENTIALLY_FAILED; + } + + // We have successfully decoded some input data and have new output data + this->output_transfer_buffer_->increase_buffer_length( + this->audio_stream_info_.value().samples_to_bytes(output_samples)); + + if (result == esp_audio_libs::flac::FLAC_DECODER_NO_MORE_FRAMES) { + return FileDecoderState::END_OF_FILE; + } + + return FileDecoderState::MORE_TO_PROCESS; +} +#endif + +#ifdef USE_AUDIO_MP3_SUPPORT +FileDecoderState AudioDecoder::decode_mp3_() { + // Look for the next sync word + int buffer_length = (int) this->input_transfer_buffer_->available(); + int32_t offset = + esp_audio_libs::helix_decoder::MP3FindSyncWord(this->input_transfer_buffer_->get_buffer_start(), buffer_length); + + if (offset < 0) { + // New data may have the sync word + this->input_transfer_buffer_->decrease_buffer_length(buffer_length); + return FileDecoderState::POTENTIALLY_FAILED; + } + + // Advance read pointer to match the offset for the syncword + this->input_transfer_buffer_->decrease_buffer_length(offset); + uint8_t *buffer_start = this->input_transfer_buffer_->get_buffer_start(); + + buffer_length = (int) this->input_transfer_buffer_->available(); + int err = esp_audio_libs::helix_decoder::MP3Decode(this->mp3_decoder_, &buffer_start, &buffer_length, + (int16_t *) this->output_transfer_buffer_->get_buffer_end(), 0); + + size_t consumed = this->input_transfer_buffer_->available() - buffer_length; + this->input_transfer_buffer_->decrease_buffer_length(consumed); + + if (err) { + switch (err) { + case esp_audio_libs::helix_decoder::ERR_MP3_OUT_OF_MEMORY: + return FileDecoderState::FAILED; + break; + case esp_audio_libs::helix_decoder::ERR_MP3_NULL_POINTER: + return FileDecoderState::FAILED; + break; + default: + // Most errors are recoverable by moving on to the next frame, so mark as potentailly failed + return FileDecoderState::POTENTIALLY_FAILED; + break; + } + } else { + esp_audio_libs::helix_decoder::MP3FrameInfo mp3_frame_info; + esp_audio_libs::helix_decoder::MP3GetLastFrameInfo(this->mp3_decoder_, &mp3_frame_info); + if (mp3_frame_info.outputSamps > 0) { + int bytes_per_sample = (mp3_frame_info.bitsPerSample / 8); + this->output_transfer_buffer_->increase_buffer_length(mp3_frame_info.outputSamps * bytes_per_sample); + + if (!this->audio_stream_info_.has_value()) { + this->audio_stream_info_ = + audio::AudioStreamInfo(mp3_frame_info.bitsPerSample, mp3_frame_info.nChans, mp3_frame_info.samprate); + } + } + } + + return FileDecoderState::MORE_TO_PROCESS; +} +#endif + +FileDecoderState AudioDecoder::decode_wav_() { + if (!this->audio_stream_info_.has_value()) { + // Header hasn't been processed + + esp_audio_libs::wav_decoder::WAVDecoderResult result = this->wav_decoder_->decode_header( + this->input_transfer_buffer_->get_buffer_start(), this->input_transfer_buffer_->available()); + + if (result == esp_audio_libs::wav_decoder::WAV_DECODER_SUCCESS_IN_DATA) { + this->input_transfer_buffer_->decrease_buffer_length(this->wav_decoder_->bytes_processed()); + + this->audio_stream_info_ = audio::AudioStreamInfo( + this->wav_decoder_->bits_per_sample(), this->wav_decoder_->num_channels(), this->wav_decoder_->sample_rate()); + + this->wav_bytes_left_ = this->wav_decoder_->chunk_bytes_left(); + this->wav_has_known_end_ = (this->wav_bytes_left_ > 0); + return FileDecoderState::MORE_TO_PROCESS; + } else if (result == esp_audio_libs::wav_decoder::WAV_DECODER_WARNING_INCOMPLETE_DATA) { + // Available data didn't have the full header + return FileDecoderState::POTENTIALLY_FAILED; + } else { + return FileDecoderState::FAILED; + } + } else { + if (!this->wav_has_known_end_ || (this->wav_bytes_left_ > 0)) { + size_t bytes_to_copy = this->input_transfer_buffer_->available(); + + if (this->wav_has_known_end_) { + bytes_to_copy = std::min(bytes_to_copy, this->wav_bytes_left_); + } + + bytes_to_copy = std::min(bytes_to_copy, this->output_transfer_buffer_->free()); + + if (bytes_to_copy > 0) { + std::memcpy(this->output_transfer_buffer_->get_buffer_end(), this->input_transfer_buffer_->get_buffer_start(), + bytes_to_copy); + this->input_transfer_buffer_->decrease_buffer_length(bytes_to_copy); + this->output_transfer_buffer_->increase_buffer_length(bytes_to_copy); + if (this->wav_has_known_end_) { + this->wav_bytes_left_ -= bytes_to_copy; + } + } + return FileDecoderState::IDLE; + } + } + + return FileDecoderState::END_OF_FILE; +} + +} // namespace audio +} // namespace esphome + +#endif diff --git a/esphome/components/audio/audio_decoder.h b/esphome/components/audio/audio_decoder.h new file mode 100644 index 0000000000..2ca1d623fe --- /dev/null +++ b/esphome/components/audio/audio_decoder.h @@ -0,0 +1,135 @@ +#pragma once + +#ifdef USE_ESP32 + +#include "audio.h" +#include "audio_transfer_buffer.h" + +#include "esphome/core/defines.h" +#include "esphome/core/helpers.h" +#include "esphome/core/ring_buffer.h" + +#ifdef USE_SPEAKER +#include "esphome/components/speaker/speaker.h" +#endif + +#include "esp_err.h" + +// esp-audio-libs +#ifdef USE_AUDIO_FLAC_SUPPORT +#include +#endif +#ifdef USE_AUDIO_MP3_SUPPORT +#include +#endif +#include + +namespace esphome { +namespace audio { + +enum class AudioDecoderState : uint8_t { + DECODING = 0, // More data is available to decode + FINISHED, // All file data has been decoded and transferred + FAILED, // Encountered an error +}; + +// Only used within the AudioDecoder class; conveys the state of the particular file type decoder +enum class FileDecoderState : uint8_t { + MORE_TO_PROCESS, // Successsfully read a file chunk and more data is available to decode + IDLE, // Not enough data to decode, waiting for more to be transferred + POTENTIALLY_FAILED, // Decoder encountered a potentially recoverable error if more file data is available + FAILED, // Decoder encoutnered an uncrecoverable error + END_OF_FILE, // The specific file decoder knows its the end of the file +}; + +class AudioDecoder { + /* + * @brief Class that facilitates decoding an audio file. + * The audio file is read from a ring buffer source, decoded, and sent to an audio sink (ring buffer or speaker + * component). + * Supports wav, flac, and mp3 formats. + */ + public: + /// @brief Allocates the input and output transfer buffers + /// @param input_buffer_size Size of the input transfer buffer in bytes. + /// @param output_buffer_size Size of the output transfer buffer in bytes. + AudioDecoder(size_t input_buffer_size, size_t output_buffer_size); + + /// @brief Deallocates the MP3 decoder (the flac and wav decoders are deallocated automatically) + ~AudioDecoder(); + + /// @brief Adds a source ring buffer for raw file data. Takes ownership of the ring buffer in a shared_ptr. + /// @param input_ring_buffer weak_ptr of a shared_ptr of the sink ring buffer to transfer ownership + /// @return ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated + esp_err_t add_source(std::weak_ptr &input_ring_buffer); + + /// @brief Adds a sink ring buffer for decoded audio. Takes ownership of the ring buffer in a shared_ptr. + /// @param output_ring_buffer weak_ptr of a shared_ptr of the sink ring buffer to transfer ownership + /// @return ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated + esp_err_t add_sink(std::weak_ptr &output_ring_buffer); + +#ifdef USE_SPEAKER + /// @brief Adds a sink speaker for decoded audio. + /// @param speaker pointer to speaker component + /// @return ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated + esp_err_t add_sink(speaker::Speaker *speaker); +#endif + + /// @brief Sets up decoding the file + /// @param audio_file_type AudioFileType of the file + /// @return ESP_OK if successful, ESP_ERR_NO_MEM if the transfer buffers fail to allocate, or ESP_ERR_NOT_SUPPORTED if + /// the format isn't supported. + esp_err_t start(AudioFileType audio_file_type); + + /// @brief Decodes audio from the ring buffer source and writes to the sink. + /// @param stop_gracefully If true, it indicates the file source is finished. The decoder will decode all the + /// reamining data and then finish. + /// @return AudioDecoderState + AudioDecoderState decode(bool stop_gracefully); + + /// @brief Gets the audio stream information, if it has been decoded from the files header + /// @return optional with the audio information. If not available yet, returns no value. + const optional &get_audio_stream_info() const { return this->audio_stream_info_; } + + /// @brief Returns the duration of audio (in milliseconds) decoded and sent to the sink + /// @return Duration of decoded audio in milliseconds + uint32_t get_playback_ms() const { return this->playback_ms_; } + + /// @brief Pauses sending resampled audio to the sink. If paused, it will continue to process internal buffers. + /// @param pause_state If true, audio data is not sent to the sink. + void set_pause_output_state(bool pause_state) { this->pause_output_ = pause_state; } + + protected: + std::unique_ptr wav_decoder_; +#ifdef USE_AUDIO_FLAC_SUPPORT + FileDecoderState decode_flac_(); + std::unique_ptr flac_decoder_; +#endif +#ifdef USE_AUDIO_MP3_SUPPORT + FileDecoderState decode_mp3_(); + esp_audio_libs::helix_decoder::HMP3Decoder mp3_decoder_; +#endif + FileDecoderState decode_wav_(); + + std::unique_ptr input_transfer_buffer_; + std::unique_ptr output_transfer_buffer_; + + AudioFileType audio_file_type_{AudioFileType::NONE}; + optional audio_stream_info_{}; + + size_t free_buffer_required_{0}; + size_t wav_bytes_left_{0}; + + uint32_t potentially_failed_count_{0}; + bool end_of_file_{false}; + bool wav_has_known_end_{false}; + + bool pause_output_{false}; + + uint32_t accumulated_frames_written_{0}; + uint32_t playback_ms_{0}; +}; +} // namespace audio +} // namespace esphome + +#endif From 6b55df36c7e21997d69c4688ee1627e545596087 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Mon, 3 Feb 2025 20:58:35 -0600 Subject: [PATCH 140/194] [audio] Media Player Components PR6 (#8168) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/audio/audio_resampler.cpp | 159 +++++++++++++++++++ esphome/components/audio/audio_resampler.h | 100 ++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 esphome/components/audio/audio_resampler.cpp create mode 100644 esphome/components/audio/audio_resampler.h diff --git a/esphome/components/audio/audio_resampler.cpp b/esphome/components/audio/audio_resampler.cpp new file mode 100644 index 0000000000..05e9ff6ca1 --- /dev/null +++ b/esphome/components/audio/audio_resampler.cpp @@ -0,0 +1,159 @@ +#include "audio_resampler.h" + +#ifdef USE_ESP32 + +#include "esphome/core/hal.h" + +namespace esphome { +namespace audio { + +static const uint32_t READ_WRITE_TIMEOUT_MS = 20; + +AudioResampler::AudioResampler(size_t input_buffer_size, size_t output_buffer_size) + : input_buffer_size_(input_buffer_size), output_buffer_size_(output_buffer_size) { + this->input_transfer_buffer_ = AudioSourceTransferBuffer::create(input_buffer_size); + this->output_transfer_buffer_ = AudioSinkTransferBuffer::create(output_buffer_size); +} + +esp_err_t AudioResampler::add_source(std::weak_ptr &input_ring_buffer) { + if (this->input_transfer_buffer_ != nullptr) { + this->input_transfer_buffer_->set_source(input_ring_buffer); + return ESP_OK; + } + return ESP_ERR_NO_MEM; +} + +esp_err_t AudioResampler::add_sink(std::weak_ptr &output_ring_buffer) { + if (this->output_transfer_buffer_ != nullptr) { + this->output_transfer_buffer_->set_sink(output_ring_buffer); + return ESP_OK; + } + return ESP_ERR_NO_MEM; +} + +#ifdef USE_SPEAKER +esp_err_t AudioResampler::add_sink(speaker::Speaker *speaker) { + if (this->output_transfer_buffer_ != nullptr) { + this->output_transfer_buffer_->set_sink(speaker); + return ESP_OK; + } + return ESP_ERR_NO_MEM; +} +#endif + +esp_err_t AudioResampler::start(AudioStreamInfo &input_stream_info, AudioStreamInfo &output_stream_info, + uint16_t number_of_taps, uint16_t number_of_filters) { + this->input_stream_info_ = input_stream_info; + this->output_stream_info_ = output_stream_info; + + if ((this->input_transfer_buffer_ == nullptr) || (this->output_transfer_buffer_ == nullptr)) { + return ESP_ERR_NO_MEM; + } + + if ((input_stream_info.get_bits_per_sample() > 32) || (output_stream_info.get_bits_per_sample() > 32) || + (input_stream_info_.get_channels() != output_stream_info.get_channels())) { + return ESP_ERR_NOT_SUPPORTED; + } + + if ((input_stream_info.get_sample_rate() != output_stream_info.get_sample_rate()) || + (input_stream_info.get_bits_per_sample() != output_stream_info.get_bits_per_sample())) { + this->resampler_ = make_unique( + input_stream_info.bytes_to_samples(this->input_buffer_size_), + output_stream_info.bytes_to_samples(this->output_buffer_size_)); + + // Use cascaded biquad filters when downsampling to avoid aliasing + bool use_pre_filter = output_stream_info.get_sample_rate() < input_stream_info.get_sample_rate(); + + esp_audio_libs::resampler::ResamplerConfiguration resample_config = { + .source_sample_rate = static_cast(input_stream_info.get_sample_rate()), + .target_sample_rate = static_cast(output_stream_info.get_sample_rate()), + .source_bits_per_sample = input_stream_info.get_bits_per_sample(), + .target_bits_per_sample = output_stream_info.get_bits_per_sample(), + .channels = input_stream_info_.get_channels(), + .use_pre_or_post_filter = use_pre_filter, + .subsample_interpolate = false, // Doubles the CPU load. Using more filters is a better alternative + .number_of_taps = number_of_taps, + .number_of_filters = number_of_filters, + }; + + if (!this->resampler_->initialize(resample_config)) { + // Failed to allocate the resampler's internal buffers + return ESP_ERR_NO_MEM; + } + } + + return ESP_OK; +} + +AudioResamplerState AudioResampler::resample(bool stop_gracefully, int32_t *ms_differential) { + if (stop_gracefully) { + if (!this->input_transfer_buffer_->has_buffered_data() && (this->output_transfer_buffer_->available() == 0)) { + return AudioResamplerState::FINISHED; + } + } + + if (!this->pause_output_) { + // Move audio data to the sink + this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS)); + } else { + // If paused, block to avoid wasting CPU resources + delay(READ_WRITE_TIMEOUT_MS); + } + + this->input_transfer_buffer_->transfer_data_from_source(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS)); + + if (this->input_transfer_buffer_->available() == 0) { + // No samples available to process + return AudioResamplerState::RESAMPLING; + } + + const size_t bytes_free = this->output_transfer_buffer_->free(); + const uint32_t frames_free = this->output_stream_info_.bytes_to_frames(bytes_free); + + const size_t bytes_available = this->input_transfer_buffer_->available(); + const uint32_t frames_available = this->input_stream_info_.bytes_to_frames(bytes_available); + + if ((this->input_stream_info_.get_sample_rate() != this->output_stream_info_.get_sample_rate()) || + (this->input_stream_info_.get_bits_per_sample() != this->output_stream_info_.get_bits_per_sample())) { + esp_audio_libs::resampler::ResamplerResults results = + this->resampler_->resample(this->input_transfer_buffer_->get_buffer_start(), + this->output_transfer_buffer_->get_buffer_end(), frames_available, frames_free, -3); + + this->input_transfer_buffer_->decrease_buffer_length(this->input_stream_info_.frames_to_bytes(results.frames_used)); + this->output_transfer_buffer_->increase_buffer_length( + this->output_stream_info_.frames_to_bytes(results.frames_generated)); + + // Resampling causes slight differences in the durations used versus generated. Computes the difference in + // millisconds. The callback function passing the played audio duration uses the difference to convert from output + // duration to input duration. + this->accumulated_frames_used_ += results.frames_used; + this->accumulated_frames_generated_ += results.frames_generated; + + const int32_t used_ms = + this->input_stream_info_.frames_to_milliseconds_with_remainder(&this->accumulated_frames_used_); + const int32_t generated_ms = + this->output_stream_info_.frames_to_milliseconds_with_remainder(&this->accumulated_frames_generated_); + + *ms_differential = used_ms - generated_ms; + + } else { + // No resampling required, copy samples directly to the output transfer buffer + *ms_differential = 0; + + const size_t bytes_to_transfer = std::min(this->output_stream_info_.frames_to_bytes(frames_free), + this->input_stream_info_.frames_to_bytes(frames_available)); + + std::memcpy((void *) this->output_transfer_buffer_->get_buffer_end(), + (void *) this->input_transfer_buffer_->get_buffer_start(), bytes_to_transfer); + + this->input_transfer_buffer_->decrease_buffer_length(bytes_to_transfer); + this->output_transfer_buffer_->increase_buffer_length(bytes_to_transfer); + } + + return AudioResamplerState::RESAMPLING; +} + +} // namespace audio +} // namespace esphome + +#endif diff --git a/esphome/components/audio/audio_resampler.h b/esphome/components/audio/audio_resampler.h new file mode 100644 index 0000000000..a348aaf783 --- /dev/null +++ b/esphome/components/audio/audio_resampler.h @@ -0,0 +1,100 @@ +#pragma once + +#ifdef USE_ESP32 + +#include "audio.h" +#include "audio_transfer_buffer.h" + +#ifdef USE_SPEAKER +#include "esphome/components/speaker/speaker.h" +#endif + +#include "esphome/core/ring_buffer.h" + +#include "esp_err.h" + +#include // esp-audio-libs + +namespace esphome { +namespace audio { + +enum class AudioResamplerState : uint8_t { + RESAMPLING, // More data is available to resample + FINISHED, // All file data has been resampled and transferred + FAILED, // Unused state included for consistency among Audio classes +}; + +class AudioResampler { + /* + * @brief Class that facilitates resampling audio. + * The audio data is read from a ring buffer source, resampled, and sent to an audio sink (ring buffer or speaker + * component). Also supports converting bits per sample. + */ + public: + /// @brief Allocates the input and output transfer buffers + /// @param input_buffer_size Size of the input transfer buffer in bytes. + /// @param output_buffer_size Size of the output transfer buffer in bytes. + AudioResampler(size_t input_buffer_size, size_t output_buffer_size); + + /// @brief Adds a source ring buffer for audio data. Takes ownership of the ring buffer in a shared_ptr. + /// @param input_ring_buffer weak_ptr of a shared_ptr of the sink ring buffer to transfer ownership + /// @return ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated + esp_err_t add_source(std::weak_ptr &input_ring_buffer); + + /// @brief Adds a sink ring buffer for resampled audio. Takes ownership of the ring buffer in a shared_ptr. + /// @param output_ring_buffer weak_ptr of a shared_ptr of the sink ring buffer to transfer ownership + /// @return ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated + esp_err_t add_sink(std::weak_ptr &output_ring_buffer); + +#ifdef USE_SPEAKER + /// @brief Adds a sink speaker for decoded audio. + /// @param speaker pointer to speaker component + /// @return ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated + esp_err_t add_sink(speaker::Speaker *speaker); +#endif + + /// @brief Sets up the class to resample. + /// @param input_stream_info The incoming sample rate, bits per sample, and number of channels + /// @param output_stream_info The desired outgoing sample rate, bits per sample, and number of channels + /// @param number_of_taps Number of taps per FIR filter + /// @param number_of_filters Number of FIR filters + /// @return ESP_OK if it is able to convert the incoming stream, + /// ESP_ERR_NO_MEM if the transfer buffers failed to allocate, + /// ESP_ERR_NOT_SUPPORTED if the stream can't be converted. + esp_err_t start(AudioStreamInfo &input_stream_info, AudioStreamInfo &output_stream_info, uint16_t number_of_taps, + uint16_t number_of_filters); + + /// @brief Resamples audio from the ring buffer source and writes to the sink. + /// @param stop_gracefully If true, it indicates the file decoder is finished. The resampler will resample all the + /// remaining audio and then finish. + /// @param ms_differential Pointer to a (int32_t) variable that will store the difference, in milliseconds, between + /// the duration of input audio used and the duration of output audio generated. + /// @return AudioResamplerState + AudioResamplerState resample(bool stop_gracefully, int32_t *ms_differential); + + /// @brief Pauses sending resampled audio to the sink. If paused, it will continue to process internal buffers. + /// @param pause_state If true, audio data is not sent to the sink. + void set_pause_output_state(bool pause_state) { this->pause_output_ = pause_state; } + + protected: + std::unique_ptr input_transfer_buffer_; + std::unique_ptr output_transfer_buffer_; + + size_t input_buffer_size_; + size_t output_buffer_size_; + + uint32_t accumulated_frames_used_{0}; + uint32_t accumulated_frames_generated_{0}; + + bool pause_output_{false}; + + AudioStreamInfo input_stream_info_; + AudioStreamInfo output_stream_info_; + + std::unique_ptr resampler_; +}; + +} // namespace audio +} // namespace esphome + +#endif From bd3469771566d04bd7a251081f26de22fbf9eb4b Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 5 Feb 2025 07:56:38 +1300 Subject: [PATCH 141/194] Remove arm/v7 container image support (#8194) --- .github/workflows/ci-docker.yml | 2 +- .github/workflows/release.yml | 1 - docker/Dockerfile | 49 +++++---------------------------- docker/build.py | 12 +++----- 4 files changed, 12 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 65f847bc66..e156dbf1e2 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -37,7 +37,7 @@ jobs: strategy: fail-fast: false matrix: - arch: [amd64, armv7, aarch64] + arch: [amd64, aarch64] build_type: ["ha-addon", "docker", "lint"] steps: - uses: actions/checkout@v4.1.7 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca266c1f2c..d406ee0069 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,7 +80,6 @@ jobs: matrix: platform: - linux/amd64 - - linux/arm/v7 - linux/arm64 steps: - uses: actions/checkout@v4.1.7 diff --git a/docker/Dockerfile b/docker/Dockerfile index 429f5c4a1f..1db1ee7b51 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -51,19 +51,7 @@ ENV \ # Store globally installed pio libs in /piolibs PLATFORMIO_GLOBALLIB_DIR=/piolibs -# Support legacy binaries on Debian multiarch system. There is no "correct" way -# to do this, other than using properly built toolchains... -# See: https://unix.stackexchange.com/questions/553743/correct-way-to-add-lib-ld-linux-so-3-in-debian RUN \ - if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \ - ln -s /lib/arm-linux-gnueabihf/ld-linux-armhf.so.3 /lib/ld-linux.so.3; \ - fi - -RUN \ - # Ubuntu python3-pip is missing wheel - if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \ - export PIP_EXTRA_INDEX_URL="https://www.piwheels.org/simple"; \ - fi; \ pip3 install \ --break-system-packages --no-cache-dir \ # Keep platformio version in sync with requirements.txt @@ -82,14 +70,6 @@ RUN --mount=type=tmpfs,target=/root/.cargo < Date: Tue, 4 Feb 2025 14:18:11 -0600 Subject: [PATCH 142/194] [resampler] Media Player Components PR7 (#8169) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- CODEOWNERS | 1 + esphome/components/audio/audio_decoder.cpp | 3 +- esphome/components/audio/audio_resampler.h | 5 +- esphome/components/resampler/__init__.py | 0 .../components/resampler/speaker/__init__.py | 103 ++++++ .../resampler/speaker/resampler_speaker.cpp | 318 ++++++++++++++++++ .../resampler/speaker/resampler_speaker.h | 107 ++++++ esphome/core/defines.h | 2 + tests/components/resampler/common.yaml | 13 + .../components/resampler/test.esp32-ard.yaml | 7 + .../resampler/test.esp32-c3-ard.yaml | 7 + .../resampler/test.esp32-c3-idf.yaml | 7 + .../components/resampler/test.esp32-idf.yaml | 7 + .../resampler/test.esp32-s3-ard.yaml | 7 + .../resampler/test.esp32-s3-idf.yaml | 7 + 15 files changed, 590 insertions(+), 4 deletions(-) create mode 100644 esphome/components/resampler/__init__.py create mode 100644 esphome/components/resampler/speaker/__init__.py create mode 100644 esphome/components/resampler/speaker/resampler_speaker.cpp create mode 100644 esphome/components/resampler/speaker/resampler_speaker.h create mode 100644 tests/components/resampler/common.yaml create mode 100644 tests/components/resampler/test.esp32-ard.yaml create mode 100644 tests/components/resampler/test.esp32-c3-ard.yaml create mode 100644 tests/components/resampler/test.esp32-c3-idf.yaml create mode 100644 tests/components/resampler/test.esp32-idf.yaml create mode 100644 tests/components/resampler/test.esp32-s3-ard.yaml create mode 100644 tests/components/resampler/test.esp32-s3-idf.yaml diff --git a/CODEOWNERS b/CODEOWNERS index cdf4ab7a99..9fbf191be0 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -343,6 +343,7 @@ esphome/components/radon_eye_rd200/* @jeffeb3 esphome/components/rc522/* @glmnet esphome/components/rc522_i2c/* @glmnet esphome/components/rc522_spi/* @glmnet +esphome/components/resampler/speaker/* @kahrendt esphome/components/restart/* @esphome/core esphome/components/rf_bridge/* @jesserockz esphome/components/rgbct/* @jesserockz diff --git a/esphome/components/audio/audio_decoder.cpp b/esphome/components/audio/audio_decoder.cpp index b249f1381d..ab358ad805 100644 --- a/esphome/components/audio/audio_decoder.cpp +++ b/esphome/components/audio/audio_decoder.cpp @@ -280,8 +280,7 @@ FileDecoderState AudioDecoder::decode_mp3_() { if (err) { switch (err) { case esp_audio_libs::helix_decoder::ERR_MP3_OUT_OF_MEMORY: - return FileDecoderState::FAILED; - break; + // Intentional fallthrough case esp_audio_libs::helix_decoder::ERR_MP3_NULL_POINTER: return FileDecoderState::FAILED; break; diff --git a/esphome/components/audio/audio_resampler.h b/esphome/components/audio/audio_resampler.h index a348aaf783..7f4e987b4c 100644 --- a/esphome/components/audio/audio_resampler.h +++ b/esphome/components/audio/audio_resampler.h @@ -5,12 +5,13 @@ #include "audio.h" #include "audio_transfer_buffer.h" +#include "esphome/core/defines.h" +#include "esphome/core/ring_buffer.h" + #ifdef USE_SPEAKER #include "esphome/components/speaker/speaker.h" #endif -#include "esphome/core/ring_buffer.h" - #include "esp_err.h" #include // esp-audio-libs diff --git a/esphome/components/resampler/__init__.py b/esphome/components/resampler/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/esphome/components/resampler/speaker/__init__.py b/esphome/components/resampler/speaker/__init__.py new file mode 100644 index 0000000000..9e9b32476f --- /dev/null +++ b/esphome/components/resampler/speaker/__init__.py @@ -0,0 +1,103 @@ +import esphome.codegen as cg +from esphome.components import audio, esp32, speaker +import esphome.config_validation as cv +from esphome.const import ( + CONF_BITS_PER_SAMPLE, + CONF_BUFFER_DURATION, + CONF_FILTERS, + CONF_ID, + CONF_NUM_CHANNELS, + CONF_OUTPUT_SPEAKER, + CONF_SAMPLE_RATE, + CONF_TASK_STACK_IN_PSRAM, + PLATFORM_ESP32, +) +from esphome.core.entity_helpers import inherit_property_from + +AUTO_LOAD = ["audio"] +CODEOWNERS = ["@kahrendt"] + +resampler_ns = cg.esphome_ns.namespace("resampler") +ResamplerSpeaker = resampler_ns.class_( + "ResamplerSpeaker", cg.Component, speaker.Speaker +) + +CONF_TAPS = "taps" + + +def _set_stream_limits(config): + audio.set_stream_limits( + min_bits_per_sample=16, + max_bits_per_sample=32, + )(config) + + return config + + +def _validate_audio_compatability(config): + inherit_property_from(CONF_BITS_PER_SAMPLE, CONF_OUTPUT_SPEAKER)(config) + inherit_property_from(CONF_NUM_CHANNELS, CONF_OUTPUT_SPEAKER)(config) + inherit_property_from(CONF_SAMPLE_RATE, CONF_OUTPUT_SPEAKER)(config) + + audio.final_validate_audio_schema( + "source_speaker", + audio_device=CONF_OUTPUT_SPEAKER, + bits_per_sample=config.get(CONF_BITS_PER_SAMPLE), + channels=config.get(CONF_NUM_CHANNELS), + sample_rate=config.get(CONF_SAMPLE_RATE), + )(config) + + +def _validate_taps(taps): + value = cv.int_range(min=16, max=128)(taps) + if value % 4 != 0: + raise cv.Invalid("Number of taps must be divisible by 4") + return value + + +CONFIG_SCHEMA = cv.All( + speaker.SPEAKER_SCHEMA.extend( + { + cv.GenerateID(): cv.declare_id(ResamplerSpeaker), + cv.Required(CONF_OUTPUT_SPEAKER): cv.use_id(speaker.Speaker), + cv.Optional( + CONF_BUFFER_DURATION, default="100ms" + ): cv.positive_time_period_milliseconds, + cv.SplitDefault(CONF_TASK_STACK_IN_PSRAM, esp32_idf=False): cv.All( + cv.boolean, cv.only_with_esp_idf + ), + cv.Optional(CONF_FILTERS, default=16): cv.int_range(min=2, max=1024), + cv.Optional(CONF_TAPS, default=16): _validate_taps, + } + ).extend(cv.COMPONENT_SCHEMA), + cv.only_on([PLATFORM_ESP32]), + _set_stream_limits, +) + + +FINAL_VALIDATE_SCHEMA = _validate_audio_compatability + + +async def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + await cg.register_component(var, config) + await speaker.register_speaker(var, config) + + output_spkr = await cg.get_variable(config[CONF_OUTPUT_SPEAKER]) + cg.add(var.set_output_speaker(output_spkr)) + + cg.add(var.set_buffer_duration(config[CONF_BUFFER_DURATION])) + + if task_stack_in_psram := config.get(CONF_TASK_STACK_IN_PSRAM): + cg.add(var.set_task_stack_in_psram(task_stack_in_psram)) + if task_stack_in_psram: + if config[CONF_TASK_STACK_IN_PSRAM]: + esp32.add_idf_sdkconfig_option( + "CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY", True + ) + + cg.add(var.set_target_bits_per_sample(config[CONF_BITS_PER_SAMPLE])) + cg.add(var.set_target_sample_rate(config[CONF_SAMPLE_RATE])) + + cg.add(var.set_filters(config[CONF_FILTERS])) + cg.add(var.set_taps(config[CONF_TAPS])) diff --git a/esphome/components/resampler/speaker/resampler_speaker.cpp b/esphome/components/resampler/speaker/resampler_speaker.cpp new file mode 100644 index 0000000000..9bb46ad78c --- /dev/null +++ b/esphome/components/resampler/speaker/resampler_speaker.cpp @@ -0,0 +1,318 @@ +#include "resampler_speaker.h" + +#ifdef USE_ESP32 + +#include "esphome/components/audio/audio_resampler.h" + +#include "esphome/core/helpers.h" +#include "esphome/core/log.h" + +#include +#include + +namespace esphome { +namespace resampler { + +static const UBaseType_t RESAMPLER_TASK_PRIORITY = 1; + +static const uint32_t TRANSFER_BUFFER_DURATION_MS = 50; + +static const uint32_t TASK_DELAY_MS = 20; +static const uint32_t TASK_STACK_SIZE = 3072; + +static const char *const TAG = "resampler_speaker"; + +enum ResamplingEventGroupBits : uint32_t { + COMMAND_STOP = (1 << 0), // stops the resampler task + STATE_STARTING = (1 << 10), + STATE_RUNNING = (1 << 11), + STATE_STOPPING = (1 << 12), + STATE_STOPPED = (1 << 13), + ERR_ESP_NO_MEM = (1 << 19), + ERR_ESP_NOT_SUPPORTED = (1 << 20), + ERR_ESP_FAIL = (1 << 21), + ALL_BITS = 0x00FFFFFF, // All valid FreeRTOS event group bits +}; + +void ResamplerSpeaker::setup() { + this->event_group_ = xEventGroupCreate(); + + if (this->event_group_ == nullptr) { + ESP_LOGE(TAG, "Failed to create event group"); + this->mark_failed(); + return; + } + + this->output_speaker_->add_audio_output_callback( + [this](uint32_t new_playback_ms, uint32_t remainder_us, uint32_t pending_ms, uint32_t write_timestamp) { + int32_t adjustment = this->playback_differential_ms_; + this->playback_differential_ms_ -= adjustment; + int32_t adjusted_playback_ms = static_cast(new_playback_ms) + adjustment; + this->audio_output_callback_(adjusted_playback_ms, remainder_us, pending_ms, write_timestamp); + }); +} + +void ResamplerSpeaker::loop() { + uint32_t event_group_bits = xEventGroupGetBits(this->event_group_); + + if (event_group_bits & ResamplingEventGroupBits::STATE_STARTING) { + ESP_LOGD(TAG, "Starting resampler task"); + xEventGroupClearBits(this->event_group_, ResamplingEventGroupBits::STATE_STARTING); + } + + if (event_group_bits & ResamplingEventGroupBits::ERR_ESP_NO_MEM) { + this->status_set_error("Resampler task failed to allocate the internal buffers"); + xEventGroupClearBits(this->event_group_, ResamplingEventGroupBits::ERR_ESP_NO_MEM); + this->state_ = speaker::STATE_STOPPING; + } + if (event_group_bits & ResamplingEventGroupBits::ERR_ESP_NOT_SUPPORTED) { + this->status_set_error("Cannot resample due to an unsupported audio stream"); + xEventGroupClearBits(this->event_group_, ResamplingEventGroupBits::ERR_ESP_NOT_SUPPORTED); + this->state_ = speaker::STATE_STOPPING; + } + if (event_group_bits & ResamplingEventGroupBits::ERR_ESP_FAIL) { + this->status_set_error("Resampler task failed"); + xEventGroupClearBits(this->event_group_, ResamplingEventGroupBits::ERR_ESP_FAIL); + this->state_ = speaker::STATE_STOPPING; + } + + if (event_group_bits & ResamplingEventGroupBits::STATE_RUNNING) { + ESP_LOGD(TAG, "Started resampler task"); + this->status_clear_error(); + xEventGroupClearBits(this->event_group_, ResamplingEventGroupBits::STATE_RUNNING); + } + if (event_group_bits & ResamplingEventGroupBits::STATE_STOPPING) { + ESP_LOGD(TAG, "Stopping resampler task"); + xEventGroupClearBits(this->event_group_, ResamplingEventGroupBits::STATE_STOPPING); + } + if (event_group_bits & ResamplingEventGroupBits::STATE_STOPPED) { + if (this->delete_task_() == ESP_OK) { + ESP_LOGD(TAG, "Stopped resampler task"); + xEventGroupClearBits(this->event_group_, ResamplingEventGroupBits::ALL_BITS); + } + } + + switch (this->state_) { + case speaker::STATE_STARTING: { + esp_err_t err = this->start_(); + if (err == ESP_OK) { + this->status_clear_error(); + this->state_ = speaker::STATE_RUNNING; + } else { + switch (err) { + case ESP_ERR_INVALID_STATE: + this->status_set_error("Failed to start resampler: resampler task failed to start"); + break; + case ESP_ERR_NO_MEM: + this->status_set_error("Failed to start resampler: not enough memory for task stack"); + default: + this->status_set_error("Failed to start resampler"); + break; + } + + this->state_ = speaker::STATE_STOPPING; + } + break; + } + case speaker::STATE_RUNNING: + if (this->output_speaker_->is_stopped()) { + this->state_ = speaker::STATE_STOPPING; + } + + break; + case speaker::STATE_STOPPING: + this->stop_(); + this->state_ = speaker::STATE_STOPPED; + break; + case speaker::STATE_STOPPED: + break; + } +} + +size_t ResamplerSpeaker::play(const uint8_t *data, size_t length, TickType_t ticks_to_wait) { + if (this->is_stopped()) { + this->start(); + } + + size_t bytes_written = 0; + if ((this->output_speaker_->is_running()) && (!this->requires_resampling_())) { + bytes_written = this->output_speaker_->play(data, length, ticks_to_wait); + } else { + if (this->ring_buffer_.use_count() == 1) { + std::shared_ptr temp_ring_buffer = this->ring_buffer_.lock(); + bytes_written = temp_ring_buffer->write_without_replacement(data, length, ticks_to_wait); + } + } + + return bytes_written; +} + +void ResamplerSpeaker::start() { this->state_ = speaker::STATE_STARTING; } + +esp_err_t ResamplerSpeaker::start_() { + this->target_stream_info_ = audio::AudioStreamInfo( + this->target_bits_per_sample_, this->audio_stream_info_.get_channels(), this->target_sample_rate_); + + this->output_speaker_->set_audio_stream_info(this->target_stream_info_); + this->output_speaker_->start(); + + if (this->requires_resampling_()) { + // Start the resampler task to handle converting sample rates + return this->start_task_(); + } + + return ESP_OK; +} + +esp_err_t ResamplerSpeaker::start_task_() { + if (this->task_stack_buffer_ == nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + this->task_stack_buffer_ = stack_allocator.allocate(TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + this->task_stack_buffer_ = stack_allocator.allocate(TASK_STACK_SIZE); + } + } + + if (this->task_stack_buffer_ == nullptr) { + return ESP_ERR_NO_MEM; + } + + if (this->task_handle_ == nullptr) { + this->task_handle_ = xTaskCreateStatic(resample_task, "sample", TASK_STACK_SIZE, (void *) this, + RESAMPLER_TASK_PRIORITY, this->task_stack_buffer_, &this->task_stack_); + } + + if (this->task_handle_ == nullptr) { + return ESP_ERR_INVALID_STATE; + } + + return ESP_OK; +} + +void ResamplerSpeaker::stop() { this->state_ = speaker::STATE_STOPPING; } + +void ResamplerSpeaker::stop_() { + if (this->task_handle_ != nullptr) { + xEventGroupSetBits(this->event_group_, ResamplingEventGroupBits::COMMAND_STOP); + } + this->output_speaker_->stop(); +} + +esp_err_t ResamplerSpeaker::delete_task_() { + if (!this->task_created_) { + this->task_handle_ = nullptr; + + if (this->task_stack_buffer_ != nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + stack_allocator.deallocate(this->task_stack_buffer_, TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + stack_allocator.deallocate(this->task_stack_buffer_, TASK_STACK_SIZE); + } + + this->task_stack_buffer_ = nullptr; + } + + return ESP_OK; + } + + return ESP_ERR_INVALID_STATE; +} + +void ResamplerSpeaker::finish() { this->output_speaker_->finish(); } + +bool ResamplerSpeaker::has_buffered_data() const { + bool has_ring_buffer_data = false; + if (this->requires_resampling_() && (this->ring_buffer_.use_count() > 0)) { + has_ring_buffer_data = (this->ring_buffer_.lock()->available() > 0); + } + return (has_ring_buffer_data || this->output_speaker_->has_buffered_data()); +} + +void ResamplerSpeaker::set_mute_state(bool mute_state) { + this->mute_state_ = mute_state; + this->output_speaker_->set_mute_state(mute_state); +} + +void ResamplerSpeaker::set_volume(float volume) { + this->volume_ = volume; + this->output_speaker_->set_volume(volume); +} + +bool ResamplerSpeaker::requires_resampling_() const { + return (this->audio_stream_info_.get_sample_rate() != this->target_sample_rate_) || + (this->audio_stream_info_.get_bits_per_sample() != this->target_bits_per_sample_); +} + +void ResamplerSpeaker::resample_task(void *params) { + ResamplerSpeaker *this_resampler = (ResamplerSpeaker *) params; + + this_resampler->task_created_ = true; + xEventGroupSetBits(this_resampler->event_group_, ResamplingEventGroupBits::STATE_STARTING); + + std::unique_ptr resampler = + make_unique(this_resampler->audio_stream_info_.ms_to_bytes(TRANSFER_BUFFER_DURATION_MS), + this_resampler->target_stream_info_.ms_to_bytes(TRANSFER_BUFFER_DURATION_MS)); + + esp_err_t err = resampler->start(this_resampler->audio_stream_info_, this_resampler->target_stream_info_, + this_resampler->taps_, this_resampler->filters_); + + if (err == ESP_OK) { + std::shared_ptr temp_ring_buffer = + RingBuffer::create(this_resampler->audio_stream_info_.ms_to_bytes(this_resampler->buffer_duration_ms_)); + + if (temp_ring_buffer.use_count() == 0) { + err = ESP_ERR_NO_MEM; + } else { + this_resampler->ring_buffer_ = temp_ring_buffer; + resampler->add_source(this_resampler->ring_buffer_); + + this_resampler->output_speaker_->set_audio_stream_info(this_resampler->target_stream_info_); + resampler->add_sink(this_resampler->output_speaker_); + } + } + + if (err == ESP_OK) { + xEventGroupSetBits(this_resampler->event_group_, ResamplingEventGroupBits::STATE_RUNNING); + } else if (err == ESP_ERR_NO_MEM) { + xEventGroupSetBits(this_resampler->event_group_, ResamplingEventGroupBits::ERR_ESP_NO_MEM); + } else if (err == ESP_ERR_NOT_SUPPORTED) { + xEventGroupSetBits(this_resampler->event_group_, ResamplingEventGroupBits::ERR_ESP_NOT_SUPPORTED); + } + + this_resampler->playback_differential_ms_ = 0; + while (err == ESP_OK) { + uint32_t event_bits = xEventGroupGetBits(this_resampler->event_group_); + + if (event_bits & ResamplingEventGroupBits::COMMAND_STOP) { + break; + } + + // Stop gracefully if the decoder is done + int32_t ms_differential = 0; + audio::AudioResamplerState resampler_state = resampler->resample(false, &ms_differential); + + this_resampler->playback_differential_ms_ += ms_differential; + + if (resampler_state == audio::AudioResamplerState::FINISHED) { + break; + } else if (resampler_state == audio::AudioResamplerState::FAILED) { + xEventGroupSetBits(this_resampler->event_group_, ResamplingEventGroupBits::ERR_ESP_FAIL); + break; + } + } + + xEventGroupSetBits(this_resampler->event_group_, ResamplingEventGroupBits::STATE_STOPPING); + resampler.reset(); + xEventGroupSetBits(this_resampler->event_group_, ResamplingEventGroupBits::STATE_STOPPED); + this_resampler->task_created_ = false; + vTaskDelete(nullptr); +} + +} // namespace resampler +} // namespace esphome + +#endif diff --git a/esphome/components/resampler/speaker/resampler_speaker.h b/esphome/components/resampler/speaker/resampler_speaker.h new file mode 100644 index 0000000000..c44f740fa2 --- /dev/null +++ b/esphome/components/resampler/speaker/resampler_speaker.h @@ -0,0 +1,107 @@ +#pragma once + +#ifdef USE_ESP32 + +#include "esphome/components/audio/audio.h" +#include "esphome/components/audio/audio_transfer_buffer.h" +#include "esphome/components/speaker/speaker.h" + +#include "esphome/core/component.h" + +#include +#include + +namespace esphome { +namespace resampler { + +class ResamplerSpeaker : public Component, public speaker::Speaker { + public: + float get_setup_priority() const override { return esphome::setup_priority::DATA; } + void setup() override; + void loop() override; + + size_t play(const uint8_t *data, size_t length, TickType_t ticks_to_wait) override; + size_t play(const uint8_t *data, size_t length) override { return this->play(data, length, 0); } + + void start() override; + void stop() override; + void finish() override; + + void set_pause_state(bool pause_state) override { this->output_speaker_->set_pause_state(pause_state); } + bool get_pause_state() const override { return this->output_speaker_->get_pause_state(); } + + bool has_buffered_data() const override; + + /// @brief Mute state changes are passed to the parent's output speaker + void set_mute_state(bool mute_state) override; + + /// @brief Volume state changes are passed to the parent's output speaker + void set_volume(float volume) override; + + void set_output_speaker(speaker::Speaker *speaker) { this->output_speaker_ = speaker; } + void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; } + + void set_target_bits_per_sample(uint8_t target_bits_per_sample) { + this->target_bits_per_sample_ = target_bits_per_sample; + } + void set_target_sample_rate(uint32_t target_sample_rate) { this->target_sample_rate_ = target_sample_rate; } + + void set_filters(uint16_t filters) { this->filters_ = filters; } + void set_taps(uint16_t taps) { this->taps_ = taps; } + + void set_buffer_duration(uint32_t buffer_duration_ms) { this->buffer_duration_ms_ = buffer_duration_ms; } + + protected: + /// @brief Starts the output speaker after setting the resampled stream info. If resampling is required, it starts the + /// task. + /// @return ESP_OK if resampling is required + /// return value of start_task_() if resampling is required + esp_err_t start_(); + + /// @brief Starts the resampler task after allocating the task stack + /// @return ESP_OK if successful, + /// ESP_ERR_NO_MEM if the task stack couldn't be allocated + /// ESP_ERR_INVALID_STATE if the task wasn't created + esp_err_t start_task_(); + + /// @brief Stops the output speaker. If the resampling task is running, it sends the stop command. + void stop_(); + + /// @brief Deallocates the task stack and resets the pointers. + /// @return ESP_OK if successful + /// ESP_ERR_INVALID_STATE if the task hasn't stopped itself + esp_err_t delete_task_(); + + inline bool requires_resampling_() const; + static void resample_task(void *params); + + EventGroupHandle_t event_group_{nullptr}; + + std::weak_ptr ring_buffer_; + + speaker::Speaker *output_speaker_{nullptr}; + + bool task_stack_in_psram_{false}; + bool task_created_{false}; + + TaskHandle_t task_handle_{nullptr}; + StaticTask_t task_stack_; + StackType_t *task_stack_buffer_{nullptr}; + + audio::AudioStreamInfo target_stream_info_; + + uint16_t taps_; + uint16_t filters_; + + uint8_t target_bits_per_sample_; + uint32_t target_sample_rate_; + + uint32_t buffer_duration_ms_; + + int32_t playback_differential_ms_{0}; +}; + +} // namespace resampler +} // namespace esphome + +#endif diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 211f3b8319..8407391bce 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -16,6 +16,8 @@ // Feature flags #define USE_ALARM_CONTROL_PANEL +#define USE_AUDIO_FLAC_SUPPORT +#define USE_AUDIO_MP3_SUPPORT #define USE_API #define USE_API_NOISE #define USE_API_PLAINTEXT diff --git a/tests/components/resampler/common.yaml b/tests/components/resampler/common.yaml new file mode 100644 index 0000000000..8ff09ed256 --- /dev/null +++ b/tests/components/resampler/common.yaml @@ -0,0 +1,13 @@ +i2s_audio: + i2s_lrclk_pin: ${lrclk_pin} + i2s_bclk_pin: ${bclk_pin} + i2s_mclk_pin: ${mclk_pin} + +speaker: + - platform: i2s_audio + id: speaker_id + dac_type: external + i2s_dout_pin: ${dout_pin} + - platform: resampler + id: resampler_speaker_id + output_speaker: speaker_id diff --git a/tests/components/resampler/test.esp32-ard.yaml b/tests/components/resampler/test.esp32-ard.yaml new file mode 100644 index 0000000000..96d2d37458 --- /dev/null +++ b/tests/components/resampler/test.esp32-ard.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO16 + bclk_pin: GPIO17 + mclk_pin: GPIO15 + dout_pin: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/resampler/test.esp32-c3-ard.yaml b/tests/components/resampler/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..f1721f0862 --- /dev/null +++ b/tests/components/resampler/test.esp32-c3-ard.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO4 + bclk_pin: GPIO5 + mclk_pin: GPIO6 + dout_pin: GPIO7 + +<<: !include common.yaml diff --git a/tests/components/resampler/test.esp32-c3-idf.yaml b/tests/components/resampler/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..f1721f0862 --- /dev/null +++ b/tests/components/resampler/test.esp32-c3-idf.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO4 + bclk_pin: GPIO5 + mclk_pin: GPIO6 + dout_pin: GPIO7 + +<<: !include common.yaml diff --git a/tests/components/resampler/test.esp32-idf.yaml b/tests/components/resampler/test.esp32-idf.yaml new file mode 100644 index 0000000000..96d2d37458 --- /dev/null +++ b/tests/components/resampler/test.esp32-idf.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO16 + bclk_pin: GPIO17 + mclk_pin: GPIO15 + dout_pin: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/resampler/test.esp32-s3-ard.yaml b/tests/components/resampler/test.esp32-s3-ard.yaml new file mode 100644 index 0000000000..f1721f0862 --- /dev/null +++ b/tests/components/resampler/test.esp32-s3-ard.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO4 + bclk_pin: GPIO5 + mclk_pin: GPIO6 + dout_pin: GPIO7 + +<<: !include common.yaml diff --git a/tests/components/resampler/test.esp32-s3-idf.yaml b/tests/components/resampler/test.esp32-s3-idf.yaml new file mode 100644 index 0000000000..f1721f0862 --- /dev/null +++ b/tests/components/resampler/test.esp32-s3-idf.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO4 + bclk_pin: GPIO5 + mclk_pin: GPIO6 + dout_pin: GPIO7 + +<<: !include common.yaml From 6f4e8f1fbfa77fa114f34296841af266c75324e6 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Tue, 4 Feb 2025 17:00:02 -0600 Subject: [PATCH 143/194] [mixer] Media Player Components PR8 (#8170) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- CODEOWNERS | 1 + esphome/components/mixer/__init__.py | 0 esphome/components/mixer/speaker/__init__.py | 172 +++++ esphome/components/mixer/speaker/automation.h | 19 + .../mixer/speaker/mixer_speaker.cpp | 624 ++++++++++++++++++ .../components/mixer/speaker/mixer_speaker.h | 207 ++++++ tests/components/mixer/common.yaml | 23 + tests/components/mixer/test.esp32-ard.yaml | 7 + tests/components/mixer/test.esp32-c3-ard.yaml | 7 + tests/components/mixer/test.esp32-c3-idf.yaml | 7 + tests/components/mixer/test.esp32-idf.yaml | 7 + tests/components/mixer/test.esp32-s3-ard.yaml | 7 + tests/components/mixer/test.esp32-s3-idf.yaml | 7 + 13 files changed, 1088 insertions(+) create mode 100644 esphome/components/mixer/__init__.py create mode 100644 esphome/components/mixer/speaker/__init__.py create mode 100644 esphome/components/mixer/speaker/automation.h create mode 100644 esphome/components/mixer/speaker/mixer_speaker.cpp create mode 100644 esphome/components/mixer/speaker/mixer_speaker.h create mode 100644 tests/components/mixer/common.yaml create mode 100644 tests/components/mixer/test.esp32-ard.yaml create mode 100644 tests/components/mixer/test.esp32-c3-ard.yaml create mode 100644 tests/components/mixer/test.esp32-c3-idf.yaml create mode 100644 tests/components/mixer/test.esp32-idf.yaml create mode 100644 tests/components/mixer/test.esp32-s3-ard.yaml create mode 100644 tests/components/mixer/test.esp32-s3-idf.yaml diff --git a/CODEOWNERS b/CODEOWNERS index 9fbf191be0..d26e153c1a 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -277,6 +277,7 @@ esphome/components/mics_4514/* @jesserockz esphome/components/midea/* @dudanov esphome/components/midea_ir/* @dudanov esphome/components/mitsubishi/* @RubyBailey +esphome/components/mixer/speaker/* @kahrendt esphome/components/mlx90393/* @functionpointer esphome/components/mlx90614/* @jesserockz esphome/components/mmc5603/* @benhoff diff --git a/esphome/components/mixer/__init__.py b/esphome/components/mixer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/esphome/components/mixer/speaker/__init__.py b/esphome/components/mixer/speaker/__init__.py new file mode 100644 index 0000000000..a451f2b7b4 --- /dev/null +++ b/esphome/components/mixer/speaker/__init__.py @@ -0,0 +1,172 @@ +from esphome import automation +import esphome.codegen as cg +from esphome.components import audio, esp32, speaker +import esphome.config_validation as cv +from esphome.const import ( + CONF_BITS_PER_SAMPLE, + CONF_BUFFER_DURATION, + CONF_DURATION, + CONF_ID, + CONF_NEVER, + CONF_NUM_CHANNELS, + CONF_OUTPUT_SPEAKER, + CONF_SAMPLE_RATE, + CONF_TASK_STACK_IN_PSRAM, + CONF_TIMEOUT, + PLATFORM_ESP32, +) +from esphome.core.entity_helpers import inherit_property_from +import esphome.final_validate as fv + +AUTO_LOAD = ["audio"] +CODEOWNERS = ["@kahrendt"] + +mixer_speaker_ns = cg.esphome_ns.namespace("mixer_speaker") +MixerSpeaker = mixer_speaker_ns.class_("MixerSpeaker", cg.Component) +SourceSpeaker = mixer_speaker_ns.class_("SourceSpeaker", cg.Component, speaker.Speaker) + +CONF_DECIBEL_REDUCTION = "decibel_reduction" +CONF_QUEUE_MODE = "queue_mode" +CONF_SOURCE_SPEAKERS = "source_speakers" + +DuckingApplyAction = mixer_speaker_ns.class_( + "DuckingApplyAction", automation.Action, cg.Parented.template(SourceSpeaker) +) + + +SOURCE_SPEAKER_SCHEMA = speaker.SPEAKER_SCHEMA.extend( + { + cv.GenerateID(): cv.declare_id(SourceSpeaker), + cv.Optional( + CONF_BUFFER_DURATION, default="100ms" + ): cv.positive_time_period_milliseconds, + cv.Optional(CONF_TIMEOUT, default="500ms"): cv.Any( + cv.positive_time_period_milliseconds, + cv.one_of(CONF_NEVER, lower=True), + ), + cv.Optional(CONF_BITS_PER_SAMPLE, default=16): cv.int_range(16, 16), + } +) + + +def _set_stream_limits(config): + audio.set_stream_limits( + min_bits_per_sample=16, + max_bits_per_sample=16, + )(config) + + return config + + +def _validate_source_speaker(config): + fconf = fv.full_config.get() + + # Get ID for the output speaker and add it to the source speakrs config to easily inherit properties + path = fconf.get_path_for_id(config[CONF_ID])[:-3] + path.append(CONF_OUTPUT_SPEAKER) + output_speaker_id = fconf.get_config_for_path(path) + config[CONF_OUTPUT_SPEAKER] = output_speaker_id + + inherit_property_from(CONF_NUM_CHANNELS, CONF_OUTPUT_SPEAKER)(config) + inherit_property_from(CONF_SAMPLE_RATE, CONF_OUTPUT_SPEAKER)(config) + + audio.final_validate_audio_schema( + "mixer", + audio_device=CONF_OUTPUT_SPEAKER, + bits_per_sample=config.get(CONF_BITS_PER_SAMPLE), + channels=config.get(CONF_NUM_CHANNELS), + sample_rate=config.get(CONF_SAMPLE_RATE), + )(config) + + return config + + +CONFIG_SCHEMA = cv.All( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(MixerSpeaker), + cv.Required(CONF_OUTPUT_SPEAKER): cv.use_id(speaker.Speaker), + cv.Required(CONF_SOURCE_SPEAKERS): cv.All( + cv.ensure_list(SOURCE_SPEAKER_SCHEMA), + cv.Length(min=2, max=8), + [_set_stream_limits], + ), + cv.Optional(CONF_NUM_CHANNELS): cv.int_range(min=1, max=2), + cv.Optional(CONF_QUEUE_MODE, default=False): cv.boolean, + cv.SplitDefault(CONF_TASK_STACK_IN_PSRAM, esp32_idf=False): cv.All( + cv.boolean, cv.only_with_esp_idf + ), + } + ), + cv.only_on([PLATFORM_ESP32]), +) + +FINAL_VALIDATE_SCHEMA = cv.All( + cv.Schema( + { + cv.Optional(CONF_SOURCE_SPEAKERS): [_validate_source_speaker], + }, + extra=cv.ALLOW_EXTRA, + ), + inherit_property_from(CONF_NUM_CHANNELS, CONF_OUTPUT_SPEAKER), +) + + +async def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + await cg.register_component(var, config) + + spkr = await cg.get_variable(config[CONF_OUTPUT_SPEAKER]) + + cg.add(var.set_output_channels(config[CONF_NUM_CHANNELS])) + cg.add(var.set_output_speaker(spkr)) + cg.add(var.set_queue_mode(config[CONF_QUEUE_MODE])) + + if task_stack_in_psram := config.get(CONF_TASK_STACK_IN_PSRAM): + cg.add(var.set_task_stack_in_psram(task_stack_in_psram)) + if task_stack_in_psram: + if config[CONF_TASK_STACK_IN_PSRAM]: + esp32.add_idf_sdkconfig_option( + "CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY", True + ) + + for speaker_config in config[CONF_SOURCE_SPEAKERS]: + source_speaker = cg.new_Pvariable(speaker_config[CONF_ID]) + + cg.add(source_speaker.set_buffer_duration(speaker_config[CONF_BUFFER_DURATION])) + + if speaker_config[CONF_TIMEOUT] != CONF_NEVER: + cg.add(source_speaker.set_timeout(speaker_config[CONF_TIMEOUT])) + + await cg.register_component(source_speaker, speaker_config) + await cg.register_parented(source_speaker, config[CONF_ID]) + await speaker.register_speaker(source_speaker, speaker_config) + + cg.add(var.add_source_speaker(source_speaker)) + + +@automation.register_action( + "mixer_speaker.apply_ducking", + DuckingApplyAction, + cv.Schema( + { + cv.GenerateID(): cv.use_id(SourceSpeaker), + cv.Required(CONF_DECIBEL_REDUCTION): cv.templatable( + cv.int_range(min=0, max=51) + ), + cv.Optional(CONF_DURATION, default="0.0s"): cv.templatable( + cv.positive_time_period_milliseconds + ), + } + ), +) +async def ducking_set_to_code(config, action_id, template_arg, args): + var = cg.new_Pvariable(action_id, template_arg) + await cg.register_parented(var, config[CONF_ID]) + decibel_reduction = await cg.templatable( + config[CONF_DECIBEL_REDUCTION], args, cg.uint8 + ) + cg.add(var.set_decibel_reduction(decibel_reduction)) + duration = await cg.templatable(config[CONF_DURATION], args, cg.uint32) + cg.add(var.set_duration(duration)) + return var diff --git a/esphome/components/mixer/speaker/automation.h b/esphome/components/mixer/speaker/automation.h new file mode 100644 index 0000000000..b688fa2c1e --- /dev/null +++ b/esphome/components/mixer/speaker/automation.h @@ -0,0 +1,19 @@ +#pragma once + +#include "mixer_speaker.h" + +#ifdef USE_ESP32 + +namespace esphome { +namespace mixer_speaker { +template class DuckingApplyAction : public Action, public Parented { + TEMPLATABLE_VALUE(uint8_t, decibel_reduction) + TEMPLATABLE_VALUE(uint32_t, duration) + void play(Ts... x) override { + this->parent_->apply_ducking(this->decibel_reduction_.value(x...), this->duration_.value(x...)); + } +}; +} // namespace mixer_speaker +} // namespace esphome + +#endif diff --git a/esphome/components/mixer/speaker/mixer_speaker.cpp b/esphome/components/mixer/speaker/mixer_speaker.cpp new file mode 100644 index 0000000000..60cff95eb2 --- /dev/null +++ b/esphome/components/mixer/speaker/mixer_speaker.cpp @@ -0,0 +1,624 @@ +#include "mixer_speaker.h" + +#ifdef USE_ESP32 + +#include "esphome/core/hal.h" +#include "esphome/core/helpers.h" +#include "esphome/core/log.h" + +#include +#include + +namespace esphome { +namespace mixer_speaker { + +static const UBaseType_t MIXER_TASK_PRIORITY = 10; + +static const uint32_t TRANSFER_BUFFER_DURATION_MS = 50; +static const uint32_t TASK_DELAY_MS = 25; + +static const size_t TASK_STACK_SIZE = 4096; + +static const int16_t MAX_AUDIO_SAMPLE_VALUE = INT16_MAX; +static const int16_t MIN_AUDIO_SAMPLE_VALUE = INT16_MIN; + +static const char *const TAG = "speaker_mixer"; + +// Gives the Q15 fixed point scaling factor to reduce by 0 dB, 1dB, ..., 50 dB +// dB to PCM scaling factor formula: floating_point_scale_factor = 2^(-db/6.014) +// float to Q15 fixed point formula: q15_scale_factor = floating_point_scale_factor * 2^(15) +static const std::vector DECIBEL_REDUCTION_TABLE = { + 32767, 29201, 26022, 23189, 20665, 18415, 16410, 14624, 13032, 11613, 10349, 9222, 8218, 7324, 6527, 5816, 5183, + 4619, 4116, 3668, 3269, 2913, 2596, 2313, 2061, 1837, 1637, 1459, 1300, 1158, 1032, 920, 820, 731, + 651, 580, 517, 461, 411, 366, 326, 291, 259, 231, 206, 183, 163, 146, 130, 116, 103}; + +enum MixerEventGroupBits : uint32_t { + COMMAND_STOP = (1 << 0), // stops the mixer task + STATE_STARTING = (1 << 10), + STATE_RUNNING = (1 << 11), + STATE_STOPPING = (1 << 12), + STATE_STOPPED = (1 << 13), + ERR_ESP_NO_MEM = (1 << 19), + ALL_BITS = 0x00FFFFFF, // All valid FreeRTOS event group bits +}; + +void SourceSpeaker::dump_config() { + ESP_LOGCONFIG(TAG, "Mixer Source Speaker"); + ESP_LOGCONFIG(TAG, " Buffer Duration: %" PRIu32 " ms", this->buffer_duration_ms_); + if (this->timeout_ms_.has_value()) { + ESP_LOGCONFIG(TAG, " Timeout: %" PRIu32 " ms", this->timeout_ms_.value()); + } else { + ESP_LOGCONFIG(TAG, " Timeout: never"); + } +} + +void SourceSpeaker::setup() { + this->parent_->get_output_speaker()->add_audio_output_callback( + [this](uint32_t new_playback_ms, uint32_t remainder_us, uint32_t pending_ms, uint32_t write_timestamp) { + uint32_t personal_playback_ms = std::min(new_playback_ms, this->pending_playback_ms_); + if (personal_playback_ms > 0) { + this->pending_playback_ms_ -= personal_playback_ms; + this->audio_output_callback_(personal_playback_ms, remainder_us, this->pending_playback_ms_, write_timestamp); + } + }); +} + +void SourceSpeaker::loop() { + switch (this->state_) { + case speaker::STATE_STARTING: { + esp_err_t err = this->start_(); + if (err == ESP_OK) { + this->state_ = speaker::STATE_RUNNING; + this->stop_gracefully_ = false; + this->last_seen_data_ms_ = millis(); + this->status_clear_error(); + } else { + switch (err) { + case ESP_ERR_NO_MEM: + this->status_set_error("Failed to start mixer: not enough memory"); + break; + case ESP_ERR_NOT_SUPPORTED: + this->status_set_error("Failed to start mixer: unsupported bits per sample"); + break; + case ESP_ERR_INVALID_ARG: + this->status_set_error("Failed to start mixer: audio stream isn't compatible with the other audio stream."); + break; + case ESP_ERR_INVALID_STATE: + this->status_set_error("Failed to start mixer: mixer task failed to start"); + break; + default: + this->status_set_error("Failed to start mixer"); + break; + } + + this->state_ = speaker::STATE_STOPPING; + } + break; + } + case speaker::STATE_RUNNING: + if (!this->transfer_buffer_->has_buffered_data()) { + if ((this->timeout_ms_.has_value() && ((millis() - this->last_seen_data_ms_) > this->timeout_ms_.value())) || + this->stop_gracefully_) { + this->state_ = speaker::STATE_STOPPING; + } + } + break; + case speaker::STATE_STOPPING: + this->stop_(); + this->stop_gracefully_ = false; + this->state_ = speaker::STATE_STOPPED; + break; + case speaker::STATE_STOPPED: + break; + } +} + +size_t SourceSpeaker::play(const uint8_t *data, size_t length, TickType_t ticks_to_wait) { + if (this->is_stopped()) { + this->start(); + } + size_t bytes_written = 0; + if (this->ring_buffer_.use_count() == 1) { + std::shared_ptr temp_ring_buffer = this->ring_buffer_.lock(); + bytes_written = temp_ring_buffer->write_without_replacement(data, length, ticks_to_wait); + if (bytes_written > 0) { + this->last_seen_data_ms_ = millis(); + } + } + return bytes_written; +} + +void SourceSpeaker::start() { this->state_ = speaker::STATE_STARTING; } + +esp_err_t SourceSpeaker::start_() { + const size_t ring_buffer_size = this->audio_stream_info_.ms_to_bytes(this->buffer_duration_ms_); + if (this->transfer_buffer_.use_count() == 0) { + this->transfer_buffer_ = + audio::AudioSourceTransferBuffer::create(this->audio_stream_info_.ms_to_bytes(TRANSFER_BUFFER_DURATION_MS)); + + if (this->transfer_buffer_ == nullptr) { + return ESP_ERR_NO_MEM; + } + std::shared_ptr temp_ring_buffer; + + if (!this->ring_buffer_.use_count()) { + temp_ring_buffer = RingBuffer::create(ring_buffer_size); + this->ring_buffer_ = temp_ring_buffer; + } + + if (!this->ring_buffer_.use_count()) { + return ESP_ERR_NO_MEM; + } else { + this->transfer_buffer_->set_source(temp_ring_buffer); + } + } + + return this->parent_->start(this->audio_stream_info_); +} + +void SourceSpeaker::stop() { + if (this->state_ != speaker::STATE_STOPPED) { + this->state_ = speaker::STATE_STOPPING; + } +} + +void SourceSpeaker::stop_() { + this->transfer_buffer_.reset(); // deallocates the transfer buffer +} + +void SourceSpeaker::finish() { this->stop_gracefully_ = true; } + +bool SourceSpeaker::has_buffered_data() const { + return ((this->transfer_buffer_.use_count() > 0) && this->transfer_buffer_->has_buffered_data()); +} + +void SourceSpeaker::set_mute_state(bool mute_state) { + this->mute_state_ = mute_state; + this->parent_->get_output_speaker()->set_mute_state(mute_state); +} + +void SourceSpeaker::set_volume(float volume) { + this->volume_ = volume; + this->parent_->get_output_speaker()->set_volume(volume); +} + +size_t SourceSpeaker::process_data_from_source(TickType_t ticks_to_wait) { + if (!this->transfer_buffer_.use_count()) { + return 0; + } + + // Store current offset, as these samples are already ducked + const size_t current_length = this->transfer_buffer_->available(); + + size_t bytes_read = this->transfer_buffer_->transfer_data_from_source(ticks_to_wait); + + uint32_t samples_to_duck = this->audio_stream_info_.bytes_to_samples(bytes_read); + if (samples_to_duck > 0) { + int16_t *current_buffer = reinterpret_cast(this->transfer_buffer_->get_buffer_start() + current_length); + + duck_samples(current_buffer, samples_to_duck, &this->current_ducking_db_reduction_, + &this->ducking_transition_samples_remaining_, this->samples_per_ducking_step_, + this->db_change_per_ducking_step_); + } + + return bytes_read; +} + +void SourceSpeaker::apply_ducking(uint8_t decibel_reduction, uint32_t duration) { + if (this->target_ducking_db_reduction_ != decibel_reduction) { + this->current_ducking_db_reduction_ = this->target_ducking_db_reduction_; + + this->target_ducking_db_reduction_ = decibel_reduction; + + uint8_t total_ducking_steps = 0; + if (this->target_ducking_db_reduction_ > this->current_ducking_db_reduction_) { + // The dB reduction level is increasing (which results in quieter audio) + total_ducking_steps = this->target_ducking_db_reduction_ - this->current_ducking_db_reduction_ - 1; + this->db_change_per_ducking_step_ = 1; + } else { + // The dB reduction level is decreasing (which results in louder audio) + total_ducking_steps = this->current_ducking_db_reduction_ - this->target_ducking_db_reduction_ - 1; + this->db_change_per_ducking_step_ = -1; + } + if ((duration > 0) && (total_ducking_steps > 0)) { + this->ducking_transition_samples_remaining_ = this->audio_stream_info_.ms_to_samples(duration); + + this->samples_per_ducking_step_ = this->ducking_transition_samples_remaining_ / total_ducking_steps; + this->ducking_transition_samples_remaining_ = + this->samples_per_ducking_step_ * total_ducking_steps; // Adjust for integer division rounding + + this->current_ducking_db_reduction_ += this->db_change_per_ducking_step_; + } else { + this->ducking_transition_samples_remaining_ = 0; + this->current_ducking_db_reduction_ = this->target_ducking_db_reduction_; + } + } +} + +void SourceSpeaker::duck_samples(int16_t *input_buffer, uint32_t input_samples_to_duck, + int8_t *current_ducking_db_reduction, uint32_t *ducking_transition_samples_remaining, + uint32_t samples_per_ducking_step, int8_t db_change_per_ducking_step) { + if (*ducking_transition_samples_remaining > 0) { + // Ducking level is still transitioning + + // Takes the ceiling of input_samples_to_duck/samples_per_ducking_step + uint32_t ducking_steps_in_batch = + input_samples_to_duck / samples_per_ducking_step + (input_samples_to_duck % samples_per_ducking_step != 0); + + for (uint32_t i = 0; i < ducking_steps_in_batch; ++i) { + uint32_t samples_left_in_step = *ducking_transition_samples_remaining % samples_per_ducking_step; + + if (samples_left_in_step == 0) { + samples_left_in_step = samples_per_ducking_step; + } + + uint32_t samples_to_duck = std::min(input_samples_to_duck, samples_left_in_step); + samples_to_duck = std::min(samples_to_duck, *ducking_transition_samples_remaining); + + // Ensure we only point to valid index in the Q15 scaling factor table + uint8_t safe_db_reduction_index = + clamp(*current_ducking_db_reduction, 0, DECIBEL_REDUCTION_TABLE.size() - 1); + int16_t q15_scale_factor = DECIBEL_REDUCTION_TABLE[safe_db_reduction_index]; + + audio::scale_audio_samples(input_buffer, input_buffer, q15_scale_factor, samples_to_duck); + + if (samples_left_in_step - samples_to_duck == 0) { + // After scaling the current samples, we are ready to transition to the next step + *current_ducking_db_reduction += db_change_per_ducking_step; + } + + input_buffer += samples_to_duck; + *ducking_transition_samples_remaining -= samples_to_duck; + input_samples_to_duck -= samples_to_duck; + } + } + + if ((*current_ducking_db_reduction > 0) && (input_samples_to_duck > 0)) { + // Audio is ducked, but its not in the middle of a transition step + + uint8_t safe_db_reduction_index = + clamp(*current_ducking_db_reduction, 0, DECIBEL_REDUCTION_TABLE.size() - 1); + int16_t q15_scale_factor = DECIBEL_REDUCTION_TABLE[safe_db_reduction_index]; + + audio::scale_audio_samples(input_buffer, input_buffer, q15_scale_factor, input_samples_to_duck); + } +} + +void MixerSpeaker::dump_config() { + ESP_LOGCONFIG(TAG, "Speaker Mixer:"); + ESP_LOGCONFIG(TAG, " Number of output channels: %u", this->output_channels_); +} + +void MixerSpeaker::setup() { + this->event_group_ = xEventGroupCreate(); + + if (this->event_group_ == nullptr) { + ESP_LOGE(TAG, "Failed to create event group"); + this->mark_failed(); + return; + } +} + +void MixerSpeaker::loop() { + uint32_t event_group_bits = xEventGroupGetBits(this->event_group_); + + if (event_group_bits & MixerEventGroupBits::STATE_STARTING) { + ESP_LOGD(TAG, "Starting speaker mixer"); + xEventGroupClearBits(this->event_group_, MixerEventGroupBits::STATE_STARTING); + } + if (event_group_bits & MixerEventGroupBits::ERR_ESP_NO_MEM) { + this->status_set_error("Failed to allocate the mixer's internal buffer"); + xEventGroupClearBits(this->event_group_, MixerEventGroupBits::ERR_ESP_NO_MEM); + } + if (event_group_bits & MixerEventGroupBits::STATE_RUNNING) { + ESP_LOGD(TAG, "Started speaker mixer"); + this->status_clear_error(); + xEventGroupClearBits(this->event_group_, MixerEventGroupBits::STATE_RUNNING); + } + if (event_group_bits & MixerEventGroupBits::STATE_STOPPING) { + ESP_LOGD(TAG, "Stopping speaker mixer"); + xEventGroupClearBits(this->event_group_, MixerEventGroupBits::STATE_STOPPING); + } + if (event_group_bits & MixerEventGroupBits::STATE_STOPPED) { + if (this->delete_task_() == ESP_OK) { + xEventGroupClearBits(this->event_group_, MixerEventGroupBits::ALL_BITS); + } + } + + if (this->task_handle_ != nullptr) { + bool all_stopped = true; + + for (auto &speaker : this->source_speakers_) { + all_stopped &= speaker->is_stopped(); + } + + if (all_stopped) { + this->stop(); + } + } +} + +esp_err_t MixerSpeaker::start(audio::AudioStreamInfo &stream_info) { + if (!this->audio_stream_info_.has_value()) { + if (stream_info.get_bits_per_sample() != 16) { + // Audio streams that don't have 16 bits per sample are not supported + return ESP_ERR_NOT_SUPPORTED; + } + + this->audio_stream_info_ = audio::AudioStreamInfo(stream_info.get_bits_per_sample(), this->output_channels_, + stream_info.get_sample_rate()); + this->output_speaker_->set_audio_stream_info(this->audio_stream_info_.value()); + } else { + if (!this->queue_mode_ && (stream_info.get_sample_rate() != this->audio_stream_info_.value().get_sample_rate())) { + // The two audio streams must have the same sample rate to mix properly if not in queue mode + return ESP_ERR_INVALID_ARG; + } + } + + return this->start_task_(); +} + +esp_err_t MixerSpeaker::start_task_() { + if (this->task_stack_buffer_ == nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + this->task_stack_buffer_ = stack_allocator.allocate(TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + this->task_stack_buffer_ = stack_allocator.allocate(TASK_STACK_SIZE); + } + } + + if (this->task_stack_buffer_ == nullptr) { + return ESP_ERR_NO_MEM; + } + + if (this->task_handle_ == nullptr) { + this->task_handle_ = xTaskCreateStatic(audio_mixer_task, "mixer", TASK_STACK_SIZE, (void *) this, + MIXER_TASK_PRIORITY, this->task_stack_buffer_, &this->task_stack_); + } + + if (this->task_handle_ == nullptr) { + return ESP_ERR_INVALID_STATE; + } + + return ESP_OK; +} + +esp_err_t MixerSpeaker::delete_task_() { + if (!this->task_created_) { + this->task_handle_ = nullptr; + + if (this->task_stack_buffer_ != nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + stack_allocator.deallocate(this->task_stack_buffer_, TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + stack_allocator.deallocate(this->task_stack_buffer_, TASK_STACK_SIZE); + } + + this->task_stack_buffer_ = nullptr; + } + + return ESP_OK; + } + + return ESP_ERR_INVALID_STATE; +} + +void MixerSpeaker::stop() { xEventGroupSetBits(this->event_group_, MixerEventGroupBits::COMMAND_STOP); } + +void MixerSpeaker::copy_frames(const int16_t *input_buffer, audio::AudioStreamInfo input_stream_info, + int16_t *output_buffer, audio::AudioStreamInfo output_stream_info, + uint32_t frames_to_transfer) { + uint8_t input_channels = input_stream_info.get_channels(); + uint8_t output_channels = output_stream_info.get_channels(); + const uint8_t max_input_channel_index = input_channels - 1; + + if (input_channels == output_channels) { + size_t bytes_to_copy = input_stream_info.frames_to_bytes(frames_to_transfer); + memcpy(output_buffer, input_buffer, bytes_to_copy); + + return; + } + + for (uint32_t frame_index = 0; frame_index < frames_to_transfer; ++frame_index) { + for (uint8_t output_channel_index = 0; output_channel_index < output_channels; ++output_channel_index) { + uint8_t input_channel_index = std::min(output_channel_index, max_input_channel_index); + output_buffer[output_channels * frame_index + output_channel_index] = + input_buffer[input_channels * frame_index + input_channel_index]; + } + } +} + +void MixerSpeaker::mix_audio_samples(const int16_t *primary_buffer, audio::AudioStreamInfo primary_stream_info, + const int16_t *secondary_buffer, audio::AudioStreamInfo secondary_stream_info, + int16_t *output_buffer, audio::AudioStreamInfo output_stream_info, + uint32_t frames_to_mix) { + const uint8_t primary_channels = primary_stream_info.get_channels(); + const uint8_t secondary_channels = secondary_stream_info.get_channels(); + const uint8_t output_channels = output_stream_info.get_channels(); + + const uint8_t max_primary_channel_index = primary_channels - 1; + const uint8_t max_secondary_channel_index = secondary_channels - 1; + + for (uint32_t frames_index = 0; frames_index < frames_to_mix; ++frames_index) { + for (uint8_t output_channel_index = 0; output_channel_index < output_channels; ++output_channel_index) { + const uint32_t secondary_channel_index = std::min(output_channel_index, max_secondary_channel_index); + const int32_t secondary_sample = secondary_buffer[frames_index * secondary_channels + secondary_channel_index]; + + const uint32_t primary_channel_index = std::min(output_channel_index, max_primary_channel_index); + const int32_t primary_sample = + static_cast(primary_buffer[frames_index * primary_channels + primary_channel_index]); + + const int32_t added_sample = secondary_sample + primary_sample; + + output_buffer[frames_index * output_channels + output_channel_index] = + static_cast(clamp(added_sample, MIN_AUDIO_SAMPLE_VALUE, MAX_AUDIO_SAMPLE_VALUE)); + } + } +} + +void MixerSpeaker::audio_mixer_task(void *params) { + MixerSpeaker *this_mixer = (MixerSpeaker *) params; + + xEventGroupSetBits(this_mixer->event_group_, MixerEventGroupBits::STATE_STARTING); + + this_mixer->task_created_ = true; + + std::unique_ptr output_transfer_buffer = audio::AudioSinkTransferBuffer::create( + this_mixer->audio_stream_info_.value().ms_to_bytes(TRANSFER_BUFFER_DURATION_MS)); + + if (output_transfer_buffer == nullptr) { + xEventGroupSetBits(this_mixer->event_group_, + MixerEventGroupBits::STATE_STOPPED | MixerEventGroupBits::ERR_ESP_NO_MEM); + + this_mixer->task_created_ = false; + vTaskDelete(nullptr); + } + + output_transfer_buffer->set_sink(this_mixer->output_speaker_); + + xEventGroupSetBits(this_mixer->event_group_, MixerEventGroupBits::STATE_RUNNING); + + bool sent_finished = false; + + while (true) { + uint32_t event_group_bits = xEventGroupGetBits(this_mixer->event_group_); + if (event_group_bits & MixerEventGroupBits::COMMAND_STOP) { + break; + } + + output_transfer_buffer->transfer_data_to_sink(pdMS_TO_TICKS(TASK_DELAY_MS)); + + const uint32_t output_frames_free = + this_mixer->audio_stream_info_.value().bytes_to_frames(output_transfer_buffer->free()); + + std::vector speakers_with_data; + std::vector> transfer_buffers_with_data; + + for (auto &speaker : this_mixer->source_speakers_) { + if (speaker->get_transfer_buffer().use_count() > 0) { + std::shared_ptr transfer_buffer = speaker->get_transfer_buffer().lock(); + speaker->process_data_from_source(0); // Transfers and ducks audio from source ring buffers + + if ((transfer_buffer->available() > 0) && !speaker->get_pause_state()) { + // Store the locked transfer buffers in their own vector to avoid releasing ownership until after the loop + transfer_buffers_with_data.push_back(transfer_buffer); + speakers_with_data.push_back(speaker); + } + } + } + + if (transfer_buffers_with_data.empty()) { + // No audio available for transferring, block task temporarily + delay(TASK_DELAY_MS); + continue; + } + + uint32_t frames_to_mix = output_frames_free; + + if ((transfer_buffers_with_data.size() == 1) || this_mixer->queue_mode_) { + // Only one speaker has audio data, just copy samples over + + audio::AudioStreamInfo active_stream_info = speakers_with_data[0]->get_audio_stream_info(); + + if (active_stream_info.get_sample_rate() == + this_mixer->output_speaker_->get_audio_stream_info().get_sample_rate()) { + // Speaker's sample rate matches the output speaker's, copy directly + + const uint32_t frames_available_in_buffer = + active_stream_info.bytes_to_frames(transfer_buffers_with_data[0]->available()); + frames_to_mix = std::min(frames_to_mix, frames_available_in_buffer); + copy_frames(reinterpret_cast(transfer_buffers_with_data[0]->get_buffer_start()), active_stream_info, + reinterpret_cast(output_transfer_buffer->get_buffer_end()), + this_mixer->audio_stream_info_.value(), frames_to_mix); + + // Update source speaker buffer length + transfer_buffers_with_data[0]->decrease_buffer_length(active_stream_info.frames_to_bytes(frames_to_mix)); + speakers_with_data[0]->accumulated_frames_read_ += frames_to_mix; + + // Add new audio duration to the source speaker pending playback + speakers_with_data[0]->pending_playback_ms_ += + active_stream_info.frames_to_milliseconds_with_remainder(&speakers_with_data[0]->accumulated_frames_read_); + + // Update output transfer buffer length + output_transfer_buffer->increase_buffer_length( + this_mixer->audio_stream_info_.value().frames_to_bytes(frames_to_mix)); + } else { + // Speaker's stream info doesn't match the output speaker's, so it's a new source speaker + if (!this_mixer->output_speaker_->is_stopped()) { + if (!sent_finished) { + this_mixer->output_speaker_->finish(); + sent_finished = true; // Avoid repeatedly sending the finish command + } + } else { + // Speaker has finished writing the current audio, update the stream information and restart the speaker + this_mixer->audio_stream_info_ = + audio::AudioStreamInfo(active_stream_info.get_bits_per_sample(), this_mixer->output_channels_, + active_stream_info.get_sample_rate()); + this_mixer->output_speaker_->set_audio_stream_info(this_mixer->audio_stream_info_.value()); + this_mixer->output_speaker_->start(); + sent_finished = false; + } + } + } else { + // Determine how many frames to mix + for (int i = 0; i < transfer_buffers_with_data.size(); ++i) { + const uint32_t frames_available_in_buffer = + speakers_with_data[i]->get_audio_stream_info().bytes_to_frames(transfer_buffers_with_data[i]->available()); + frames_to_mix = std::min(frames_to_mix, frames_available_in_buffer); + } + int16_t *primary_buffer = reinterpret_cast(transfer_buffers_with_data[0]->get_buffer_start()); + audio::AudioStreamInfo primary_stream_info = speakers_with_data[0]->get_audio_stream_info(); + + // Mix two streams together + for (int i = 1; i < transfer_buffers_with_data.size(); ++i) { + mix_audio_samples(primary_buffer, primary_stream_info, + reinterpret_cast(transfer_buffers_with_data[i]->get_buffer_start()), + speakers_with_data[i]->get_audio_stream_info(), + reinterpret_cast(output_transfer_buffer->get_buffer_end()), + this_mixer->audio_stream_info_.value(), frames_to_mix); + + speakers_with_data[i]->pending_playback_ms_ += + speakers_with_data[i]->get_audio_stream_info().frames_to_milliseconds_with_remainder( + &speakers_with_data[i]->accumulated_frames_read_); + + if (i != transfer_buffers_with_data.size() - 1) { + // Need to mix more streams together, point primary buffer and stream info to the already mixed output + primary_buffer = reinterpret_cast(output_transfer_buffer->get_buffer_end()); + primary_stream_info = this_mixer->audio_stream_info_.value(); + } + } + + // Update source transfer buffer lengths and add new audio durations to the source speaker pending playbacks + for (int i = 0; i < transfer_buffers_with_data.size(); ++i) { + transfer_buffers_with_data[i]->decrease_buffer_length( + speakers_with_data[i]->get_audio_stream_info().frames_to_bytes(frames_to_mix)); + speakers_with_data[i]->accumulated_frames_read_ += frames_to_mix; + + speakers_with_data[i]->pending_playback_ms_ += + speakers_with_data[i]->get_audio_stream_info().frames_to_milliseconds_with_remainder( + &speakers_with_data[i]->accumulated_frames_read_); + } + + // Update output transfer buffer length + output_transfer_buffer->increase_buffer_length( + this_mixer->audio_stream_info_.value().frames_to_bytes(frames_to_mix)); + } + } + + xEventGroupSetBits(this_mixer->event_group_, MixerEventGroupBits::STATE_STOPPING); + + output_transfer_buffer.reset(); + + xEventGroupSetBits(this_mixer->event_group_, MixerEventGroupBits::STATE_STOPPED); + this_mixer->task_created_ = false; + vTaskDelete(nullptr); +} + +} // namespace mixer_speaker +} // namespace esphome + +#endif diff --git a/esphome/components/mixer/speaker/mixer_speaker.h b/esphome/components/mixer/speaker/mixer_speaker.h new file mode 100644 index 0000000000..b2cb3e1e39 --- /dev/null +++ b/esphome/components/mixer/speaker/mixer_speaker.h @@ -0,0 +1,207 @@ +#pragma once + +#ifdef USE_ESP32 + +#include "esphome/components/audio/audio.h" +#include "esphome/components/audio/audio_transfer_buffer.h" +#include "esphome/components/speaker/speaker.h" + +#include "esphome/core/component.h" + +#include +#include + +namespace esphome { +namespace mixer_speaker { + +/* Classes for mixing several source speaker audio streams and writing it to another speaker component. + * - Volume controls are passed through to the output speaker + * - Directly handles pausing at the SourceSpeaker level; pause state is not passed through to the output speaker. + * - Audio sent to the SourceSpeaker's must have 16 bits per sample. + * - Audio sent to the SourceSpeaker can have any number of channels. They are duplicated or ignored as needed to match + * the number of channels required for the output speaker. + * - In queue mode, the audio sent to the SoureSpeakers can have different sample rates. + * - In non-queue mode, the audio sent to the SourceSpeakers must have the same sample rates. + * - SourceSpeaker has an internal ring buffer. It also allocates a shared_ptr for an AudioTranserBuffer object. + * - Audio Data Flow: + * - Audio data played on a SourceSpeaker first writes to its internal ring buffer. + * - MixerSpeaker task temporarily takes shared ownership of each SourceSpeaker's AudioTransferBuffer. + * - MixerSpeaker calls SourceSpeaker's `process_data_from_source`, which tranfers audio from the SourceSpeaker's + * ring buffer to its AudioTransferBuffer. Audio ducking is applied at this step. + * - In queue mode, MixerSpeaker prioritizes the earliest configured SourceSpeaker with audio data. Audio data is + * sent to the output speaker. + * - In non-queue mode, MixerSpeaker adds all the audio data in each SourceSpeaker into one stream that is written + * to the output speaker. + */ + +class MixerSpeaker; + +class SourceSpeaker : public speaker::Speaker, public Component { + public: + void dump_config() override; + void setup() override; + void loop() override; + + size_t play(const uint8_t *data, size_t length, TickType_t ticks_to_wait) override; + size_t play(const uint8_t *data, size_t length) override { return this->play(data, length, 0); } + + void start() override; + void stop() override; + void finish() override; + + bool has_buffered_data() const override; + + /// @brief Mute state changes are passed to the parent's output speaker + void set_mute_state(bool mute_state) override; + + /// @brief Volume state changes are passed to the parent's output speaker + void set_volume(float volume) override; + + void set_pause_state(bool pause_state) override { this->pause_state_ = pause_state; } + bool get_pause_state() const override { return this->pause_state_; } + + /// @brief Transfers audio from the ring buffer into the transfer buffer. Ducks audio while transferring. + /// @param ticks_to_wait FreeRTOS ticks to wait while waiting to read from the ring buffer. + /// @return Number of bytes transferred from the ring buffer. + size_t process_data_from_source(TickType_t ticks_to_wait); + + /// @brief Sets the ducking level for the source speaker. + /// @param decibel_reduction (uint8_t) The dB reduction level. For example, 0 is no change, 10 is a reduction by 10 dB + /// @param duration (uint32_t) The number of milliseconds to transition from the current level to the new level + void apply_ducking(uint8_t decibel_reduction, uint32_t duration); + + void set_buffer_duration(uint32_t buffer_duration_ms) { this->buffer_duration_ms_ = buffer_duration_ms; } + void set_parent(MixerSpeaker *parent) { this->parent_ = parent; } + void set_timeout(uint32_t ms) { this->timeout_ms_ = ms; } + + std::weak_ptr get_transfer_buffer() { return this->transfer_buffer_; } + + protected: + friend class MixerSpeaker; + esp_err_t start_(); + void stop_(); + + /// @brief Ducks audio samples by a specified amount. When changing the ducking amount, it can transition gradually + /// over a specified amount of samples. + /// @param input_buffer buffer with audio samples to be ducked in place + /// @param input_samples_to_duck number of samples to process in ``input_buffer`` + /// @param current_ducking_db_reduction pointer to the current dB reduction + /// @param ducking_transition_samples_remaining pointer to the total number of samples left before the the + /// transition is finished + /// @param samples_per_ducking_step total number of samples per ducking step for the transition + /// @param db_change_per_ducking_step the change in dB reduction per step + static void duck_samples(int16_t *input_buffer, uint32_t input_samples_to_duck, int8_t *current_ducking_db_reduction, + uint32_t *ducking_transition_samples_remaining, uint32_t samples_per_ducking_step, + int8_t db_change_per_ducking_step); + + MixerSpeaker *parent_; + + std::shared_ptr transfer_buffer_; + std::weak_ptr ring_buffer_; + + uint32_t buffer_duration_ms_; + uint32_t last_seen_data_ms_{0}; + optional timeout_ms_; + bool stop_gracefully_{false}; + + bool pause_state_{false}; + + int8_t target_ducking_db_reduction_{0}; + int8_t current_ducking_db_reduction_{0}; + int8_t db_change_per_ducking_step_{1}; + uint32_t ducking_transition_samples_remaining_{0}; + uint32_t samples_per_ducking_step_{0}; + + uint32_t accumulated_frames_read_{0}; + + uint32_t pending_playback_ms_{0}; +}; + +class MixerSpeaker : public Component { + public: + void dump_config() override; + void setup() override; + void loop() override; + + void add_source_speaker(SourceSpeaker *source_speaker) { this->source_speakers_.push_back(source_speaker); } + + /// @brief Starts the mixer task. Called by a source speaker giving the current audio stream information + /// @param stream_info The calling source speakers audio stream information + /// @return ESP_ERR_NOT_SUPPORTED if the incoming stream is incompatible due to unsupported bits per sample + /// ESP_ERR_INVALID_ARG if the incoming stream is incompatible to be mixed with the other input audio stream + /// ESP_ERR_NO_MEM if there isn't enough memory for the task's stack + /// ESP_ERR_INVALID_STATE if the task fails to start + /// ESP_OK if the incoming stream is compatible and the mixer task starts + esp_err_t start(audio::AudioStreamInfo &stream_info); + + void stop(); + + void set_output_channels(uint8_t output_channels) { this->output_channels_ = output_channels; } + void set_output_speaker(speaker::Speaker *speaker) { this->output_speaker_ = speaker; } + void set_queue_mode(bool queue_mode) { this->queue_mode_ = queue_mode; } + void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; } + + speaker::Speaker *get_output_speaker() const { return this->output_speaker_; } + + protected: + /// @brief Copies audio frames from the input buffer to the output buffer taking into account the number of channels + /// in each stream. If the output stream has more channels, the input samples are duplicated. If the output stream has + /// less channels, the extra channel input samples are dropped. + /// @param input_buffer + /// @param input_stream_info + /// @param output_buffer + /// @param output_stream_info + /// @param frames_to_transfer number of frames (consisting of a sample for each channel) to copy from the input buffer + static void copy_frames(const int16_t *input_buffer, audio::AudioStreamInfo input_stream_info, int16_t *output_buffer, + audio::AudioStreamInfo output_stream_info, uint32_t frames_to_transfer); + + /// @brief Mixes the primary and secondary streams taking into account the number of channels in each stream. Primary + /// and secondary samples are duplicated or dropped as necessary to ensure the output stream has the configured number + /// of channels. Output samples are clamped to the corresponding int16 min or max values if the mixed sample + /// overflows. + /// @param primary_buffer (int16_t *) samples buffer for the primary stream + /// @param primary_stream_info stream info for the primary stream + /// @param secondary_buffer (int16_t *) samples buffer for secondary stream + /// @param secondary_stream_info stream info for the secondary stream + /// @param output_buffer (int16_t *) buffer for the mixed samples + /// @param output_stream_info stream info for the output buffer + /// @param frames_to_mix number of frames in the primary and secondary buffers to mix together + static void mix_audio_samples(const int16_t *primary_buffer, audio::AudioStreamInfo primary_stream_info, + const int16_t *secondary_buffer, audio::AudioStreamInfo secondary_stream_info, + int16_t *output_buffer, audio::AudioStreamInfo output_stream_info, + uint32_t frames_to_mix); + + static void audio_mixer_task(void *params); + + /// @brief Starts the mixer task after allocating memory for the task stack. + /// @return ESP_ERR_NO_MEM if there isn't enough memory for the task's stack + /// ESP_ERR_INVALID_STATE if the task didn't start + /// ESP_OK if successful + esp_err_t start_task_(); + + /// @brief If the task is stopped, it sets the task handle to the nullptr and deallocates its stack + /// @return ESP_OK if the task was stopped, ESP_ERR_INVALID_STATE otherwise. + esp_err_t delete_task_(); + + EventGroupHandle_t event_group_{nullptr}; + + std::vector source_speakers_; + speaker::Speaker *output_speaker_{nullptr}; + + uint8_t output_channels_; + bool queue_mode_; + bool task_stack_in_psram_{false}; + + bool task_created_{false}; + + TaskHandle_t task_handle_{nullptr}; + StaticTask_t task_stack_; + StackType_t *task_stack_buffer_{nullptr}; + + optional audio_stream_info_; +}; + +} // namespace mixer_speaker +} // namespace esphome + +#endif diff --git a/tests/components/mixer/common.yaml b/tests/components/mixer/common.yaml new file mode 100644 index 0000000000..e171b9499c --- /dev/null +++ b/tests/components/mixer/common.yaml @@ -0,0 +1,23 @@ +esphome: + on_boot: + then: + - mixer_speaker.apply_ducking: + id: source_speaker_1_id + decibel_reduction: 10 + duration: 1s + +i2s_audio: + i2s_lrclk_pin: ${lrclk_pin} + i2s_bclk_pin: ${bclk_pin} + i2s_mclk_pin: ${mclk_pin} + +speaker: + - platform: i2s_audio + id: speaker_id + dac_type: external + i2s_dout_pin: ${dout_pin} + - platform: mixer + output_speaker: speaker_id + source_speakers: + - id: source_speaker_1_id + - id: source_speaker_2_id diff --git a/tests/components/mixer/test.esp32-ard.yaml b/tests/components/mixer/test.esp32-ard.yaml new file mode 100644 index 0000000000..96d2d37458 --- /dev/null +++ b/tests/components/mixer/test.esp32-ard.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO16 + bclk_pin: GPIO17 + mclk_pin: GPIO15 + dout_pin: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/mixer/test.esp32-c3-ard.yaml b/tests/components/mixer/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..f1721f0862 --- /dev/null +++ b/tests/components/mixer/test.esp32-c3-ard.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO4 + bclk_pin: GPIO5 + mclk_pin: GPIO6 + dout_pin: GPIO7 + +<<: !include common.yaml diff --git a/tests/components/mixer/test.esp32-c3-idf.yaml b/tests/components/mixer/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..f1721f0862 --- /dev/null +++ b/tests/components/mixer/test.esp32-c3-idf.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO4 + bclk_pin: GPIO5 + mclk_pin: GPIO6 + dout_pin: GPIO7 + +<<: !include common.yaml diff --git a/tests/components/mixer/test.esp32-idf.yaml b/tests/components/mixer/test.esp32-idf.yaml new file mode 100644 index 0000000000..96d2d37458 --- /dev/null +++ b/tests/components/mixer/test.esp32-idf.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO16 + bclk_pin: GPIO17 + mclk_pin: GPIO15 + dout_pin: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/mixer/test.esp32-s3-ard.yaml b/tests/components/mixer/test.esp32-s3-ard.yaml new file mode 100644 index 0000000000..f1721f0862 --- /dev/null +++ b/tests/components/mixer/test.esp32-s3-ard.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO4 + bclk_pin: GPIO5 + mclk_pin: GPIO6 + dout_pin: GPIO7 + +<<: !include common.yaml diff --git a/tests/components/mixer/test.esp32-s3-idf.yaml b/tests/components/mixer/test.esp32-s3-idf.yaml new file mode 100644 index 0000000000..f1721f0862 --- /dev/null +++ b/tests/components/mixer/test.esp32-s3-idf.yaml @@ -0,0 +1,7 @@ +substitutions: + lrclk_pin: GPIO4 + bclk_pin: GPIO5 + mclk_pin: GPIO6 + dout_pin: GPIO7 + +<<: !include common.yaml From d4ac2d3c7edfa7a4a30b50820e0eeb9bd198b036 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:04:53 -0600 Subject: [PATCH 144/194] [CI] Consolidate some tests (A) (#8184) --- tests/components/a02yyuw/common.yaml | 11 +++ tests/components/a02yyuw/test.esp32-ard.yaml | 16 +--- .../components/a02yyuw/test.esp32-c3-ard.yaml | 16 +--- .../components/a02yyuw/test.esp32-c3-idf.yaml | 16 +--- tests/components/a02yyuw/test.esp32-idf.yaml | 16 +--- .../components/a02yyuw/test.esp8266-ard.yaml | 16 +--- tests/components/a02yyuw/test.rp2040-ard.yaml | 16 +--- tests/components/a4988/common.yaml | 9 ++ tests/components/a4988/test.esp32-ard.yaml | 18 ++-- tests/components/a4988/test.esp32-c3-ard.yaml | 18 ++-- tests/components/a4988/test.esp32-c3-idf.yaml | 18 ++-- tests/components/a4988/test.esp32-idf.yaml | 18 ++-- tests/components/a4988/test.esp8266-ard.yaml | 18 ++-- tests/components/a4988/test.rp2040-ard.yaml | 18 ++-- tests/components/ac_dimmer/common.yaml | 5 + .../components/ac_dimmer/test.esp32-ard.yaml | 12 +-- .../ac_dimmer/test.esp32-c3-ard.yaml | 12 +-- .../ac_dimmer/test.esp8266-ard.yaml | 12 +-- .../components/ac_dimmer/test.rp2040-ard.yaml | 12 +-- tests/components/adc/test.esp32-c3-ard.yaml | 2 +- tests/components/adc/test.esp32-s2-ard.yaml | 2 +- tests/components/adc/test.esp32-s3-ard.yaml | 2 +- tests/components/adc128s102/common.yaml | 14 +++ .../components/adc128s102/test.esp32-ard.yaml | 19 ++-- .../adc128s102/test.esp32-c3-ard.yaml | 19 ++-- .../adc128s102/test.esp32-c3-idf.yaml | 19 ++-- .../components/adc128s102/test.esp32-idf.yaml | 19 ++-- .../adc128s102/test.esp8266-ard.yaml | 19 ++-- .../adc128s102/test.rp2040-ard.yaml | 19 ++-- ...ml => common-ard-esp32_rmt_led_strip.yaml} | 2 +- ...esp32-ard.yaml => common-ard-fastled.yaml} | 2 +- ...ml => common-idf-esp32_rmt_led_strip.yaml} | 2 +- .../esp32_rmt_led_strip.esp32-ard.yaml | 4 + .../esp32_rmt_led_strip.esp32-c3-ard.yaml | 4 + .../esp32_rmt_led_strip.esp32-c3-idf.yaml | 4 + .../esp32_rmt_led_strip.esp32-idf.yaml | 4 + .../fastled_clockless.esp32-ard.yaml | 4 + .../addressable_light/test.esp32-idf.yaml | 30 ------ tests/components/ade7953_i2c/common.yaml | 34 +++++++ .../ade7953_i2c/test.esp32-ard.yaml | 38 +------- .../ade7953_i2c/test.esp32-c3-ard.yaml | 38 +------- .../ade7953_i2c/test.esp32-c3-idf.yaml | 38 +------- .../ade7953_i2c/test.esp32-idf.yaml | 38 +------- .../ade7953_i2c/test.esp8266-ard.yaml | 38 +------- .../ade7953_i2c/test.rp2040-ard.yaml | 38 +------- tests/components/ade7953_spi/common.yaml | 36 +++++++ .../ade7953_spi/test.esp32-ard.yaml | 42 ++------ .../ade7953_spi/test.esp32-c3-ard.yaml | 42 ++------ .../ade7953_spi/test.esp32-c3-idf.yaml | 42 ++------ .../ade7953_spi/test.esp32-idf.yaml | 42 ++------ .../ade7953_spi/test.esp8266-ard.yaml | 42 ++------ .../ade7953_spi/test.rp2040-ard.yaml | 42 ++------ tests/components/ads1115/common.yaml | 14 +++ tests/components/ads1115/test.esp32-ard.yaml | 17 +--- .../components/ads1115/test.esp32-c3-ard.yaml | 17 +--- .../components/ads1115/test.esp32-c3-idf.yaml | 17 +--- tests/components/ads1115/test.esp32-idf.yaml | 17 +--- .../components/ads1115/test.esp8266-ard.yaml | 17 +--- tests/components/ads1115/test.rp2040-ard.yaml | 17 +--- tests/components/ags10/common.yaml | 12 +++ tests/components/ags10/test.esp32-ard.yaml | 15 +-- tests/components/ags10/test.esp32-c3-ard.yaml | 15 +-- tests/components/ags10/test.esp32-c3-idf.yaml | 15 +-- tests/components/ags10/test.esp32-idf.yaml | 15 +-- tests/components/ags10/test.esp8266-ard.yaml | 15 +-- tests/components/aht10/common.yaml | 11 +++ tests/components/aht10/test.esp32-ard.yaml | 14 +-- tests/components/aht10/test.esp32-c3-ard.yaml | 14 +-- tests/components/aht10/test.esp32-c3-idf.yaml | 14 +-- tests/components/aht10/test.esp32-idf.yaml | 14 +-- tests/components/aht10/test.esp8266-ard.yaml | 14 +-- tests/components/aht10/test.rp2040-ard.yaml | 14 +-- tests/components/am2315c/common.yaml | 11 +++ tests/components/am2315c/test.esp32-ard.yaml | 14 +-- .../components/am2315c/test.esp32-c3-ard.yaml | 14 +-- .../components/am2315c/test.esp32-c3-idf.yaml | 14 +-- tests/components/am2315c/test.esp32-idf.yaml | 14 +-- .../components/am2315c/test.esp8266-ard.yaml | 14 +-- tests/components/am2315c/test.rp2040-ard.yaml | 14 +-- tests/components/am2320/common.yaml | 11 +++ tests/components/am2320/test.esp32-ard.yaml | 14 +-- .../components/am2320/test.esp32-c3-ard.yaml | 14 +-- .../components/am2320/test.esp32-c3-idf.yaml | 14 +-- tests/components/am2320/test.esp32-idf.yaml | 14 +-- tests/components/am2320/test.esp8266-ard.yaml | 14 +-- tests/components/am2320/test.rp2040-ard.yaml | 14 +-- tests/components/apds9960/common.yaml | 48 ++++++++++ tests/components/apds9960/test.esp32-ard.yaml | 51 +--------- .../apds9960/test.esp32-c3-ard.yaml | 51 +--------- .../apds9960/test.esp32-c3-idf.yaml | 51 +--------- tests/components/apds9960/test.esp32-idf.yaml | 51 +--------- .../components/apds9960/test.esp8266-ard.yaml | 51 +--------- .../components/apds9960/test.rp2040-ard.yaml | 51 +--------- tests/components/as3935_i2c/common.yaml | 18 ++++ .../components/as3935_i2c/test.esp32-ard.yaml | 22 +---- .../as3935_i2c/test.esp32-c3-ard.yaml | 22 +---- .../as3935_i2c/test.esp32-c3-idf.yaml | 22 +---- .../components/as3935_i2c/test.esp32-idf.yaml | 22 +---- .../as3935_i2c/test.esp8266-ard.yaml | 22 +---- .../as3935_i2c/test.rp2040-ard.yaml | 22 +---- tests/components/as3935_spi/common.yaml | 20 ++++ .../components/as3935_spi/test.esp32-ard.yaml | 26 ++--- .../as3935_spi/test.esp32-c3-ard.yaml | 26 ++--- .../as3935_spi/test.esp32-c3-idf.yaml | 26 ++--- .../components/as3935_spi/test.esp32-idf.yaml | 26 ++--- .../as3935_spi/test.esp8266-ard.yaml | 26 ++--- .../as3935_spi/test.rp2040-ard.yaml | 26 ++--- tests/components/as5600/common.yaml | 27 ++++++ tests/components/as5600/test.esp32-ard.yaml | 31 +----- .../components/as5600/test.esp32-c3-ard.yaml | 31 +----- .../components/as5600/test.esp32-c3-idf.yaml | 31 +----- tests/components/as5600/test.esp32-idf.yaml | 31 +----- tests/components/as5600/test.esp8266-ard.yaml | 31 +----- tests/components/as5600/test.rp2040-ard.yaml | 31 +----- tests/components/as7341/common.yaml | 31 ++++++ tests/components/as7341/test.esp32-ard.yaml | 34 +------ .../components/as7341/test.esp32-c3-ard.yaml | 34 +------ .../components/as7341/test.esp32-c3-idf.yaml | 34 +------ tests/components/as7341/test.esp32-idf.yaml | 34 +------ tests/components/as7341/test.esp8266-ard.yaml | 34 +------ tests/components/as7341/test.rp2040-ard.yaml | 34 +------ tests/components/at581x/common.yaml | 28 ++++++ tests/components/at581x/test.esp32-ard.yaml | 41 +------- .../components/at581x/test.esp32-c3-ard.yaml | 41 +------- .../components/at581x/test.esp32-c3-idf.yaml | 41 +------- tests/components/at581x/test.esp32-idf.yaml | 41 +------- tests/components/at581x/test.esp8266-ard.yaml | 41 +------- tests/components/at581x/test.rp2040-ard.yaml | 41 +------- tests/components/atm90e26/common.yaml | 26 +++++ tests/components/atm90e26/test.esp32-ard.yaml | 31 ++---- .../atm90e26/test.esp32-c3-ard.yaml | 31 ++---- .../atm90e26/test.esp32-c3-idf.yaml | 31 ++---- tests/components/atm90e26/test.esp32-idf.yaml | 31 ++---- .../components/atm90e26/test.esp8266-ard.yaml | 31 ++---- .../components/atm90e26/test.rp2040-ard.yaml | 31 ++---- tests/components/atm90e32/common.yaml | 61 ++++++++++++ tests/components/atm90e32/test.esp32-ard.yaml | 65 ++----------- .../atm90e32/test.esp32-c3-ard.yaml | 65 ++----------- .../atm90e32/test.esp32-c3-idf.yaml | 65 ++----------- tests/components/atm90e32/test.esp32-idf.yaml | 65 ++----------- .../components/atm90e32/test.esp8266-ard.yaml | 96 ++----------------- .../components/atm90e32/test.rp2040-ard.yaml | 65 ++----------- 142 files changed, 1003 insertions(+), 2598 deletions(-) create mode 100644 tests/components/a02yyuw/common.yaml create mode 100644 tests/components/a4988/common.yaml create mode 100644 tests/components/ac_dimmer/common.yaml create mode 100644 tests/components/adc128s102/common.yaml rename tests/components/addressable_light/{test.esp32-c3-ard.yaml => common-ard-esp32_rmt_led_strip.yaml} (98%) rename tests/components/addressable_light/{test.esp32-ard.yaml => common-ard-fastled.yaml} (98%) rename tests/components/addressable_light/{test.esp32-c3-idf.yaml => common-idf-esp32_rmt_led_strip.yaml} (98%) create mode 100644 tests/components/addressable_light/esp32_rmt_led_strip.esp32-ard.yaml create mode 100644 tests/components/addressable_light/esp32_rmt_led_strip.esp32-c3-ard.yaml create mode 100644 tests/components/addressable_light/esp32_rmt_led_strip.esp32-c3-idf.yaml create mode 100644 tests/components/addressable_light/esp32_rmt_led_strip.esp32-idf.yaml create mode 100644 tests/components/addressable_light/fastled_clockless.esp32-ard.yaml delete mode 100644 tests/components/addressable_light/test.esp32-idf.yaml create mode 100644 tests/components/ade7953_i2c/common.yaml create mode 100644 tests/components/ade7953_spi/common.yaml create mode 100644 tests/components/ads1115/common.yaml create mode 100644 tests/components/ags10/common.yaml create mode 100644 tests/components/aht10/common.yaml create mode 100644 tests/components/am2315c/common.yaml create mode 100644 tests/components/am2320/common.yaml create mode 100644 tests/components/apds9960/common.yaml create mode 100644 tests/components/as3935_i2c/common.yaml create mode 100644 tests/components/as3935_spi/common.yaml create mode 100644 tests/components/as5600/common.yaml create mode 100644 tests/components/as7341/common.yaml create mode 100644 tests/components/at581x/common.yaml create mode 100644 tests/components/atm90e26/common.yaml create mode 100644 tests/components/atm90e32/common.yaml diff --git a/tests/components/a02yyuw/common.yaml b/tests/components/a02yyuw/common.yaml new file mode 100644 index 0000000000..b2e5927ff4 --- /dev/null +++ b/tests/components/a02yyuw/common.yaml @@ -0,0 +1,11 @@ +uart: + - id: uart_a02yyuw + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: a02yyuw + id: a02yyuw_sensor + name: a02yyuw Distance + uart_id: uart_a02yyuw diff --git a/tests/components/a02yyuw/test.esp32-ard.yaml b/tests/components/a02yyuw/test.esp32-ard.yaml index 98d6a266b3..f486544afa 100644 --- a/tests/components/a02yyuw/test.esp32-ard.yaml +++ b/tests/components/a02yyuw/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_a02yyuw - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: a02yyuw - id: a02yyuw_sensor - name: a02yyuw Distance - uart_id: uart_a02yyuw +<<: !include common.yaml diff --git a/tests/components/a02yyuw/test.esp32-c3-ard.yaml b/tests/components/a02yyuw/test.esp32-c3-ard.yaml index 76e1ad8ee1..b516342f3b 100644 --- a/tests/components/a02yyuw/test.esp32-c3-ard.yaml +++ b/tests/components/a02yyuw/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_a02yyuw - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: a02yyuw - id: a02yyuw_sensor - name: a02yyuw Distance - uart_id: uart_a02yyuw +<<: !include common.yaml diff --git a/tests/components/a02yyuw/test.esp32-c3-idf.yaml b/tests/components/a02yyuw/test.esp32-c3-idf.yaml index 76e1ad8ee1..b516342f3b 100644 --- a/tests/components/a02yyuw/test.esp32-c3-idf.yaml +++ b/tests/components/a02yyuw/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_a02yyuw - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: a02yyuw - id: a02yyuw_sensor - name: a02yyuw Distance - uart_id: uart_a02yyuw +<<: !include common.yaml diff --git a/tests/components/a02yyuw/test.esp32-idf.yaml b/tests/components/a02yyuw/test.esp32-idf.yaml index 98d6a266b3..f486544afa 100644 --- a/tests/components/a02yyuw/test.esp32-idf.yaml +++ b/tests/components/a02yyuw/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_a02yyuw - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: a02yyuw - id: a02yyuw_sensor - name: a02yyuw Distance - uart_id: uart_a02yyuw +<<: !include common.yaml diff --git a/tests/components/a02yyuw/test.esp8266-ard.yaml b/tests/components/a02yyuw/test.esp8266-ard.yaml index 76e1ad8ee1..b516342f3b 100644 --- a/tests/components/a02yyuw/test.esp8266-ard.yaml +++ b/tests/components/a02yyuw/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_a02yyuw - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: a02yyuw - id: a02yyuw_sensor - name: a02yyuw Distance - uart_id: uart_a02yyuw +<<: !include common.yaml diff --git a/tests/components/a02yyuw/test.rp2040-ard.yaml b/tests/components/a02yyuw/test.rp2040-ard.yaml index 76e1ad8ee1..b516342f3b 100644 --- a/tests/components/a02yyuw/test.rp2040-ard.yaml +++ b/tests/components/a02yyuw/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_a02yyuw - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: a02yyuw - id: a02yyuw_sensor - name: a02yyuw Distance - uart_id: uart_a02yyuw +<<: !include common.yaml diff --git a/tests/components/a4988/common.yaml b/tests/components/a4988/common.yaml new file mode 100644 index 0000000000..b85f2f41c6 --- /dev/null +++ b/tests/components/a4988/common.yaml @@ -0,0 +1,9 @@ +stepper: + - platform: a4988 + id: a4988_stepper + step_pin: ${step_pin} + dir_pin: ${dir_pin} + sleep_pin: ${sleep_pin} + max_speed: 250 steps/s + acceleration: 100 steps/s^2 + deceleration: 200 steps/s^2 diff --git a/tests/components/a4988/test.esp32-ard.yaml b/tests/components/a4988/test.esp32-ard.yaml index 0ca5e3f504..1ca8c0c084 100644 --- a/tests/components/a4988/test.esp32-ard.yaml +++ b/tests/components/a4988/test.esp32-ard.yaml @@ -1,12 +1,6 @@ -stepper: - - platform: a4988 - id: a4988_stepper - step_pin: - number: 22 - dir_pin: - number: 23 - sleep_pin: - number: 25 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +substitutions: + step_pin: GPIO22 + dir_pin: GPIO23 + sleep_pin: GPIO25 + +<<: !include common.yaml diff --git a/tests/components/a4988/test.esp32-c3-ard.yaml b/tests/components/a4988/test.esp32-c3-ard.yaml index af4e4fa32b..25caba75b5 100644 --- a/tests/components/a4988/test.esp32-c3-ard.yaml +++ b/tests/components/a4988/test.esp32-c3-ard.yaml @@ -1,12 +1,6 @@ -stepper: - - platform: a4988 - id: a4988_stepper - step_pin: - number: 2 - dir_pin: - number: 3 - sleep_pin: - number: 5 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +substitutions: + step_pin: GPIO2 + dir_pin: GPIO3 + sleep_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/a4988/test.esp32-c3-idf.yaml b/tests/components/a4988/test.esp32-c3-idf.yaml index af4e4fa32b..25caba75b5 100644 --- a/tests/components/a4988/test.esp32-c3-idf.yaml +++ b/tests/components/a4988/test.esp32-c3-idf.yaml @@ -1,12 +1,6 @@ -stepper: - - platform: a4988 - id: a4988_stepper - step_pin: - number: 2 - dir_pin: - number: 3 - sleep_pin: - number: 5 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +substitutions: + step_pin: GPIO2 + dir_pin: GPIO3 + sleep_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/a4988/test.esp32-idf.yaml b/tests/components/a4988/test.esp32-idf.yaml index 0ca5e3f504..1ca8c0c084 100644 --- a/tests/components/a4988/test.esp32-idf.yaml +++ b/tests/components/a4988/test.esp32-idf.yaml @@ -1,12 +1,6 @@ -stepper: - - platform: a4988 - id: a4988_stepper - step_pin: - number: 22 - dir_pin: - number: 23 - sleep_pin: - number: 25 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +substitutions: + step_pin: GPIO22 + dir_pin: GPIO23 + sleep_pin: GPIO25 + +<<: !include common.yaml diff --git a/tests/components/a4988/test.esp8266-ard.yaml b/tests/components/a4988/test.esp8266-ard.yaml index f4c1886fc5..22b5677d27 100644 --- a/tests/components/a4988/test.esp8266-ard.yaml +++ b/tests/components/a4988/test.esp8266-ard.yaml @@ -1,12 +1,6 @@ -stepper: - - platform: a4988 - id: a4988_stepper - step_pin: - number: 1 - dir_pin: - number: 2 - sleep_pin: - number: 5 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +substitutions: + step_pin: GPIO1 + dir_pin: GPIO2 + sleep_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/a4988/test.rp2040-ard.yaml b/tests/components/a4988/test.rp2040-ard.yaml index af4e4fa32b..25caba75b5 100644 --- a/tests/components/a4988/test.rp2040-ard.yaml +++ b/tests/components/a4988/test.rp2040-ard.yaml @@ -1,12 +1,6 @@ -stepper: - - platform: a4988 - id: a4988_stepper - step_pin: - number: 2 - dir_pin: - number: 3 - sleep_pin: - number: 5 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +substitutions: + step_pin: GPIO2 + dir_pin: GPIO3 + sleep_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/ac_dimmer/common.yaml b/tests/components/ac_dimmer/common.yaml new file mode 100644 index 0000000000..8f93066838 --- /dev/null +++ b/tests/components/ac_dimmer/common.yaml @@ -0,0 +1,5 @@ +output: + - platform: ac_dimmer + id: ac_dimmer_1 + gate_pin: ${gate_pin} + zero_cross_pin: ${zero_cross_pin} diff --git a/tests/components/ac_dimmer/test.esp32-ard.yaml b/tests/components/ac_dimmer/test.esp32-ard.yaml index cc17201666..3ec069f430 100644 --- a/tests/components/ac_dimmer/test.esp32-ard.yaml +++ b/tests/components/ac_dimmer/test.esp32-ard.yaml @@ -1,7 +1,5 @@ -output: - - platform: ac_dimmer - id: ac_dimmer_1 - gate_pin: - number: 12 - zero_cross_pin: - number: 13 +substitutions: + gate_pin: GPIO18 + zero_cross_pin: GPIO19 + +<<: !include common.yaml diff --git a/tests/components/ac_dimmer/test.esp32-c3-ard.yaml b/tests/components/ac_dimmer/test.esp32-c3-ard.yaml index f411d376be..5d2d42b713 100644 --- a/tests/components/ac_dimmer/test.esp32-c3-ard.yaml +++ b/tests/components/ac_dimmer/test.esp32-c3-ard.yaml @@ -1,7 +1,5 @@ -output: - - platform: ac_dimmer - id: ac_dimmer_1 - gate_pin: - number: 5 - zero_cross_pin: - number: 6 +substitutions: + gate_pin: GPIO5 + zero_cross_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/ac_dimmer/test.esp8266-ard.yaml b/tests/components/ac_dimmer/test.esp8266-ard.yaml index af18d11c5f..5d2d42b713 100644 --- a/tests/components/ac_dimmer/test.esp8266-ard.yaml +++ b/tests/components/ac_dimmer/test.esp8266-ard.yaml @@ -1,7 +1,5 @@ -output: - - platform: ac_dimmer - id: ac_dimmer_1 - gate_pin: - number: 5 - zero_cross_pin: - number: 4 +substitutions: + gate_pin: GPIO5 + zero_cross_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/ac_dimmer/test.rp2040-ard.yaml b/tests/components/ac_dimmer/test.rp2040-ard.yaml index f411d376be..5d2d42b713 100644 --- a/tests/components/ac_dimmer/test.rp2040-ard.yaml +++ b/tests/components/ac_dimmer/test.rp2040-ard.yaml @@ -1,7 +1,5 @@ -output: - - platform: ac_dimmer - id: ac_dimmer_1 - gate_pin: - number: 5 - zero_cross_pin: - number: 6 +substitutions: + gate_pin: GPIO5 + zero_cross_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/adc/test.esp32-c3-ard.yaml b/tests/components/adc/test.esp32-c3-ard.yaml index 18e5ab3561..e74477c582 100644 --- a/tests/components/adc/test.esp32-c3-ard.yaml +++ b/tests/components/adc/test.esp32-c3-ard.yaml @@ -2,4 +2,4 @@ sensor: - platform: adc id: my_sensor pin: 4 - attenuation: 11db + attenuation: 12db diff --git a/tests/components/adc/test.esp32-s2-ard.yaml b/tests/components/adc/test.esp32-s2-ard.yaml index 0119ad5e4d..e1a6bc22e5 100644 --- a/tests/components/adc/test.esp32-s2-ard.yaml +++ b/tests/components/adc/test.esp32-s2-ard.yaml @@ -2,4 +2,4 @@ sensor: - platform: adc id: my_sensor pin: 1 - attenuation: 11db + attenuation: 12db diff --git a/tests/components/adc/test.esp32-s3-ard.yaml b/tests/components/adc/test.esp32-s3-ard.yaml index 0119ad5e4d..e1a6bc22e5 100644 --- a/tests/components/adc/test.esp32-s3-ard.yaml +++ b/tests/components/adc/test.esp32-s3-ard.yaml @@ -2,4 +2,4 @@ sensor: - platform: adc id: my_sensor pin: 1 - attenuation: 11db + attenuation: 12db diff --git a/tests/components/adc128s102/common.yaml b/tests/components/adc128s102/common.yaml new file mode 100644 index 0000000000..5f1638a7e2 --- /dev/null +++ b/tests/components/adc128s102/common.yaml @@ -0,0 +1,14 @@ +spi: + - id: spi_adc128s102 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +adc128s102: + cs_pin: ${cs_pin} + id: adc128s102_adc + +sensor: + - platform: adc128s102 + id: adc128s102_channel_0 + channel: 0 diff --git a/tests/components/adc128s102/test.esp32-ard.yaml b/tests/components/adc128s102/test.esp32-ard.yaml index 005fbccc34..aba72f0614 100644 --- a/tests/components/adc128s102/test.esp32-ard.yaml +++ b/tests/components/adc128s102/test.esp32-ard.yaml @@ -1,14 +1,7 @@ -spi: - - id: spi_adc128s102 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO12 -adc128s102: - cs_pin: 12 - id: adc128s102_adc - -sensor: - - platform: adc128s102 - id: adc128s102_channel_0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/adc128s102/test.esp32-c3-ard.yaml b/tests/components/adc128s102/test.esp32-c3-ard.yaml index 8edf745e58..24da4b5452 100644 --- a/tests/components/adc128s102/test.esp32-c3-ard.yaml +++ b/tests/components/adc128s102/test.esp32-c3-ard.yaml @@ -1,14 +1,7 @@ -spi: - - id: spi_adc128s102 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO2 -adc128s102: - cs_pin: 8 - id: adc128s102_adc - -sensor: - - platform: adc128s102 - id: adc128s102_channel_0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/adc128s102/test.esp32-c3-idf.yaml b/tests/components/adc128s102/test.esp32-c3-idf.yaml index 8edf745e58..24da4b5452 100644 --- a/tests/components/adc128s102/test.esp32-c3-idf.yaml +++ b/tests/components/adc128s102/test.esp32-c3-idf.yaml @@ -1,14 +1,7 @@ -spi: - - id: spi_adc128s102 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO2 -adc128s102: - cs_pin: 8 - id: adc128s102_adc - -sensor: - - platform: adc128s102 - id: adc128s102_channel_0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/adc128s102/test.esp32-idf.yaml b/tests/components/adc128s102/test.esp32-idf.yaml index 005fbccc34..aba72f0614 100644 --- a/tests/components/adc128s102/test.esp32-idf.yaml +++ b/tests/components/adc128s102/test.esp32-idf.yaml @@ -1,14 +1,7 @@ -spi: - - id: spi_adc128s102 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO12 -adc128s102: - cs_pin: 12 - id: adc128s102_adc - -sensor: - - platform: adc128s102 - id: adc128s102_channel_0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/adc128s102/test.esp8266-ard.yaml b/tests/components/adc128s102/test.esp8266-ard.yaml index 09a51caec1..dbd158d030 100644 --- a/tests/components/adc128s102/test.esp8266-ard.yaml +++ b/tests/components/adc128s102/test.esp8266-ard.yaml @@ -1,14 +1,7 @@ -spi: - - id: spi_adc128s102 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -adc128s102: - cs_pin: 15 - id: adc128s102_adc - -sensor: - - platform: adc128s102 - id: adc128s102_channel_0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/adc128s102/test.rp2040-ard.yaml b/tests/components/adc128s102/test.rp2040-ard.yaml index a7d54cbfe6..f6c3f1eeca 100644 --- a/tests/components/adc128s102/test.rp2040-ard.yaml +++ b/tests/components/adc128s102/test.rp2040-ard.yaml @@ -1,14 +1,7 @@ -spi: - - id: spi_adc128s102 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -adc128s102: - cs_pin: 5 - id: adc128s102_adc - -sensor: - - platform: adc128s102 - id: adc128s102_channel_0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/addressable_light/test.esp32-c3-ard.yaml b/tests/components/addressable_light/common-ard-esp32_rmt_led_strip.yaml similarity index 98% rename from tests/components/addressable_light/test.esp32-c3-ard.yaml rename to tests/components/addressable_light/common-ard-esp32_rmt_led_strip.yaml index f587113fac..9c5e63cdc6 100644 --- a/tests/components/addressable_light/test.esp32-c3-ard.yaml +++ b/tests/components/addressable_light/common-ard-esp32_rmt_led_strip.yaml @@ -5,7 +5,7 @@ light: chipset: ws2812 rgb_order: GRB num_leds: 256 - pin: 2 + pin: ${pin} rmt_channel: 0 display: diff --git a/tests/components/addressable_light/test.esp32-ard.yaml b/tests/components/addressable_light/common-ard-fastled.yaml similarity index 98% rename from tests/components/addressable_light/test.esp32-ard.yaml rename to tests/components/addressable_light/common-ard-fastled.yaml index f7717be610..77a5c5fe12 100644 --- a/tests/components/addressable_light/test.esp32-ard.yaml +++ b/tests/components/addressable_light/common-ard-fastled.yaml @@ -3,7 +3,7 @@ light: id: led_matrix_32x8 name: led_matrix_32x8 chipset: WS2812B - pin: 2 + pin: ${pin} num_leds: 256 rgb_order: GRB default_transition_length: 0s diff --git a/tests/components/addressable_light/test.esp32-c3-idf.yaml b/tests/components/addressable_light/common-idf-esp32_rmt_led_strip.yaml similarity index 98% rename from tests/components/addressable_light/test.esp32-c3-idf.yaml rename to tests/components/addressable_light/common-idf-esp32_rmt_led_strip.yaml index 7b3516345d..a071f9df91 100644 --- a/tests/components/addressable_light/test.esp32-c3-idf.yaml +++ b/tests/components/addressable_light/common-idf-esp32_rmt_led_strip.yaml @@ -5,7 +5,7 @@ light: chipset: ws2812 rgb_order: GRB num_leds: 256 - pin: 2 + pin: ${pin} display: - platform: addressable_light diff --git a/tests/components/addressable_light/esp32_rmt_led_strip.esp32-ard.yaml b/tests/components/addressable_light/esp32_rmt_led_strip.esp32-ard.yaml new file mode 100644 index 0000000000..d93c554dae --- /dev/null +++ b/tests/components/addressable_light/esp32_rmt_led_strip.esp32-ard.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO2 + +<<: !include common-ard-esp32_rmt_led_strip.yaml diff --git a/tests/components/addressable_light/esp32_rmt_led_strip.esp32-c3-ard.yaml b/tests/components/addressable_light/esp32_rmt_led_strip.esp32-c3-ard.yaml new file mode 100644 index 0000000000..d93c554dae --- /dev/null +++ b/tests/components/addressable_light/esp32_rmt_led_strip.esp32-c3-ard.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO2 + +<<: !include common-ard-esp32_rmt_led_strip.yaml diff --git a/tests/components/addressable_light/esp32_rmt_led_strip.esp32-c3-idf.yaml b/tests/components/addressable_light/esp32_rmt_led_strip.esp32-c3-idf.yaml new file mode 100644 index 0000000000..ca2c244d80 --- /dev/null +++ b/tests/components/addressable_light/esp32_rmt_led_strip.esp32-c3-idf.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO2 + +<<: !include common-idf-esp32_rmt_led_strip.yaml diff --git a/tests/components/addressable_light/esp32_rmt_led_strip.esp32-idf.yaml b/tests/components/addressable_light/esp32_rmt_led_strip.esp32-idf.yaml new file mode 100644 index 0000000000..ca2c244d80 --- /dev/null +++ b/tests/components/addressable_light/esp32_rmt_led_strip.esp32-idf.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO2 + +<<: !include common-idf-esp32_rmt_led_strip.yaml diff --git a/tests/components/addressable_light/fastled_clockless.esp32-ard.yaml b/tests/components/addressable_light/fastled_clockless.esp32-ard.yaml new file mode 100644 index 0000000000..78eb5d7fdb --- /dev/null +++ b/tests/components/addressable_light/fastled_clockless.esp32-ard.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO2 + +<<: !include common-ard-fastled.yaml diff --git a/tests/components/addressable_light/test.esp32-idf.yaml b/tests/components/addressable_light/test.esp32-idf.yaml deleted file mode 100644 index 7b3516345d..0000000000 --- a/tests/components/addressable_light/test.esp32-idf.yaml +++ /dev/null @@ -1,30 +0,0 @@ -light: - - platform: esp32_rmt_led_strip - id: led_matrix_32x8 - default_transition_length: 500ms - chipset: ws2812 - rgb_order: GRB - num_leds: 256 - pin: 2 - -display: - - platform: addressable_light - id: led_matrix_32x8_display - addressable_light_id: led_matrix_32x8 - width: 32 - height: 8 - pixel_mapper: |- - if (x % 2 == 0) { - return (x * 8) + y; - } - return (x * 8) + (7 - y); - lambda: |- - Color red = Color(0xFF0000); - Color green = Color(0x00FF00); - Color blue = Color(0x0000FF); - it.rectangle(0, 0, it.get_width(), it.get_height(), red); - it.rectangle(1, 1, it.get_width()-2, it.get_height()-2, green); - it.rectangle(2, 2, it.get_width()-4, it.get_height()-4, blue); - it.rectangle(3, 3, it.get_width()-6, it.get_height()-6, red); - rotation: 0° - update_interval: 16ms diff --git a/tests/components/ade7953_i2c/common.yaml b/tests/components/ade7953_i2c/common.yaml new file mode 100644 index 0000000000..a2d163567d --- /dev/null +++ b/tests/components/ade7953_i2c/common.yaml @@ -0,0 +1,34 @@ +i2c: + - id: i2c_ade7953 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ade7953_i2c + irq_pin: ${irq_pin} + voltage: + name: ADE7953 Voltage + id: ade7953_voltage + current_a: + name: ADE7953 Current A + id: ade7953_current_a + current_b: + name: ADE7953 Current B + id: ade7953_current_b + power_factor_a: + name: ADE7953 Power Factor A + power_factor_b: + name: ADE7953 Power Factor B + apparent_power_a: + name: ADE7953 Apparent Power A + apparent_power_b: + name: ADE7953 Apparent Power B + active_power_a: + name: ADE7953 Active Power A + active_power_b: + name: ADE7953 Active Power B + reactive_power_a: + name: ADE7953 Reactive Power A + reactive_power_b: + name: ADE7953 Reactive Power B + update_interval: 1s diff --git a/tests/components/ade7953_i2c/test.esp32-ard.yaml b/tests/components/ade7953_i2c/test.esp32-ard.yaml index 71602f20a3..2c57d412f6 100644 --- a/tests/components/ade7953_i2c/test.esp32-ard.yaml +++ b/tests/components/ade7953_i2c/test.esp32-ard.yaml @@ -1,34 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + irq_pin: GPIO15 -sensor: - - platform: ade7953_i2c - irq_pin: 15 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_i2c/test.esp32-c3-ard.yaml b/tests/components/ade7953_i2c/test.esp32-c3-ard.yaml index d7b365a7e1..799acabd5a 100644 --- a/tests/components/ade7953_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/ade7953_i2c/test.esp32-c3-ard.yaml @@ -1,34 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 -sensor: - - platform: ade7953_i2c - irq_pin: 6 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_i2c/test.esp32-c3-idf.yaml b/tests/components/ade7953_i2c/test.esp32-c3-idf.yaml index d7b365a7e1..799acabd5a 100644 --- a/tests/components/ade7953_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/ade7953_i2c/test.esp32-c3-idf.yaml @@ -1,34 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 -sensor: - - platform: ade7953_i2c - irq_pin: 6 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_i2c/test.esp32-idf.yaml b/tests/components/ade7953_i2c/test.esp32-idf.yaml index 71602f20a3..2c57d412f6 100644 --- a/tests/components/ade7953_i2c/test.esp32-idf.yaml +++ b/tests/components/ade7953_i2c/test.esp32-idf.yaml @@ -1,34 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + irq_pin: GPIO15 -sensor: - - platform: ade7953_i2c - irq_pin: 15 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_i2c/test.esp8266-ard.yaml b/tests/components/ade7953_i2c/test.esp8266-ard.yaml index 6903cd1953..c8e6a43f44 100644 --- a/tests/components/ade7953_i2c/test.esp8266-ard.yaml +++ b/tests/components/ade7953_i2c/test.esp8266-ard.yaml @@ -1,34 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO15 -sensor: - - platform: ade7953_i2c - irq_pin: 15 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_i2c/test.rp2040-ard.yaml b/tests/components/ade7953_i2c/test.rp2040-ard.yaml index d7b365a7e1..799acabd5a 100644 --- a/tests/components/ade7953_i2c/test.rp2040-ard.yaml +++ b/tests/components/ade7953_i2c/test.rp2040-ard.yaml @@ -1,34 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 -sensor: - - platform: ade7953_i2c - irq_pin: 6 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_spi/common.yaml b/tests/components/ade7953_spi/common.yaml new file mode 100644 index 0000000000..706f31f22c --- /dev/null +++ b/tests/components/ade7953_spi/common.yaml @@ -0,0 +1,36 @@ +spi: + - id: spi_ade7953 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sensor: + - platform: ade7953_spi + cs_pin: ${cs_pin} + irq_pin: ${irq_pin} + voltage: + name: ADE7953 Voltage + id: ade7953_voltage + current_a: + name: ADE7953 Current A + id: ade7953_current_a + current_b: + name: ADE7953 Current B + id: ade7953_current_b + power_factor_a: + name: ADE7953 Power Factor A + power_factor_b: + name: ADE7953 Power Factor B + apparent_power_a: + name: ADE7953 Apparent Power A + apparent_power_b: + name: ADE7953 Apparent Power B + active_power_a: + name: ADE7953 Active Power A + active_power_b: + name: ADE7953 Active Power B + reactive_power_a: + name: ADE7953 Reactive Power A + reactive_power_b: + name: ADE7953 Reactive Power B + update_interval: 1s diff --git a/tests/components/ade7953_spi/test.esp32-ard.yaml b/tests/components/ade7953_spi/test.esp32-ard.yaml index e9ef7e4116..e00f522dd4 100644 --- a/tests/components/ade7953_spi/test.esp32-ard.yaml +++ b/tests/components/ade7953_spi/test.esp32-ard.yaml @@ -1,36 +1,8 @@ -spi: - - id: spi_ade7953 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + irq_pin: GPIO13 + cs_pin: GPIO5 -sensor: - - platform: ade7953_spi - cs_pin: 5 - irq_pin: 13 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_spi/test.esp32-c3-ard.yaml b/tests/components/ade7953_spi/test.esp32-c3-ard.yaml index a967f28d9c..fcf35f528e 100644 --- a/tests/components/ade7953_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ade7953_spi/test.esp32-c3-ard.yaml @@ -1,36 +1,8 @@ -spi: - - id: spi_ade7953 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + irq_pin: GPIO9 + cs_pin: GPIO8 -sensor: - - platform: ade7953_spi - cs_pin: 8 - irq_pin: 9 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_spi/test.esp32-c3-idf.yaml b/tests/components/ade7953_spi/test.esp32-c3-idf.yaml index a967f28d9c..fcf35f528e 100644 --- a/tests/components/ade7953_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ade7953_spi/test.esp32-c3-idf.yaml @@ -1,36 +1,8 @@ -spi: - - id: spi_ade7953 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + irq_pin: GPIO9 + cs_pin: GPIO8 -sensor: - - platform: ade7953_spi - cs_pin: 8 - irq_pin: 9 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_spi/test.esp32-idf.yaml b/tests/components/ade7953_spi/test.esp32-idf.yaml index e9ef7e4116..e00f522dd4 100644 --- a/tests/components/ade7953_spi/test.esp32-idf.yaml +++ b/tests/components/ade7953_spi/test.esp32-idf.yaml @@ -1,36 +1,8 @@ -spi: - - id: spi_ade7953 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + irq_pin: GPIO13 + cs_pin: GPIO5 -sensor: - - platform: ade7953_spi - cs_pin: 5 - irq_pin: 13 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_spi/test.esp8266-ard.yaml b/tests/components/ade7953_spi/test.esp8266-ard.yaml index b36b4445ab..b90e661ec0 100644 --- a/tests/components/ade7953_spi/test.esp8266-ard.yaml +++ b/tests/components/ade7953_spi/test.esp8266-ard.yaml @@ -1,36 +1,8 @@ -spi: - - id: spi_ade7953 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + irq_pin: GPIO5 + cs_pin: GPIO15 -sensor: - - platform: ade7953_spi - cs_pin: 15 - irq_pin: 5 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ade7953_spi/test.rp2040-ard.yaml b/tests/components/ade7953_spi/test.rp2040-ard.yaml index 319abd4613..8f5941e1b2 100644 --- a/tests/components/ade7953_spi/test.rp2040-ard.yaml +++ b/tests/components/ade7953_spi/test.rp2040-ard.yaml @@ -1,36 +1,8 @@ -spi: - - id: spi_ade7953 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + irq_pin: GPIO5 + cs_pin: GPIO6 -sensor: - - platform: ade7953_spi - cs_pin: 5 - irq_pin: 6 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/ads1115/common.yaml b/tests/components/ads1115/common.yaml new file mode 100644 index 0000000000..297877d2d8 --- /dev/null +++ b/tests/components/ads1115/common.yaml @@ -0,0 +1,14 @@ +i2c: + - id: i2c_ads1115 + scl: ${scl_pin} + sda: ${sda_pin} + +ads1115: + address: 0x48 + +sensor: + - platform: ads1115 + multiplexer: A0_A1 + gain: 1.024 + sample_rate: 128 + id: ads1115_sensor diff --git a/tests/components/ads1115/test.esp32-ard.yaml b/tests/components/ads1115/test.esp32-ard.yaml index 0fdaeff275..63c3bd6afd 100644 --- a/tests/components/ads1115/test.esp32-ard.yaml +++ b/tests/components/ads1115/test.esp32-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ads1115 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -ads1115: - address: 0x48 - -sensor: - - platform: ads1115 - multiplexer: A0_A1 - gain: 1.024 - sample_rate: 128 - id: ads1115_sensor +<<: !include common.yaml diff --git a/tests/components/ads1115/test.esp32-c3-ard.yaml b/tests/components/ads1115/test.esp32-c3-ard.yaml index 265d2cad2c..ee2c29ca4e 100644 --- a/tests/components/ads1115/test.esp32-c3-ard.yaml +++ b/tests/components/ads1115/test.esp32-c3-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ads1115 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ads1115: - address: 0x48 - -sensor: - - platform: ads1115 - multiplexer: A0_A1 - gain: 1.024 - sample_rate: 128 - id: ads1115_sensor +<<: !include common.yaml diff --git a/tests/components/ads1115/test.esp32-c3-idf.yaml b/tests/components/ads1115/test.esp32-c3-idf.yaml index 265d2cad2c..ee2c29ca4e 100644 --- a/tests/components/ads1115/test.esp32-c3-idf.yaml +++ b/tests/components/ads1115/test.esp32-c3-idf.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ads1115 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ads1115: - address: 0x48 - -sensor: - - platform: ads1115 - multiplexer: A0_A1 - gain: 1.024 - sample_rate: 128 - id: ads1115_sensor +<<: !include common.yaml diff --git a/tests/components/ads1115/test.esp32-idf.yaml b/tests/components/ads1115/test.esp32-idf.yaml index 0fdaeff275..63c3bd6afd 100644 --- a/tests/components/ads1115/test.esp32-idf.yaml +++ b/tests/components/ads1115/test.esp32-idf.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ads1115 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -ads1115: - address: 0x48 - -sensor: - - platform: ads1115 - multiplexer: A0_A1 - gain: 1.024 - sample_rate: 128 - id: ads1115_sensor +<<: !include common.yaml diff --git a/tests/components/ads1115/test.esp8266-ard.yaml b/tests/components/ads1115/test.esp8266-ard.yaml index 265d2cad2c..ee2c29ca4e 100644 --- a/tests/components/ads1115/test.esp8266-ard.yaml +++ b/tests/components/ads1115/test.esp8266-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ads1115 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ads1115: - address: 0x48 - -sensor: - - platform: ads1115 - multiplexer: A0_A1 - gain: 1.024 - sample_rate: 128 - id: ads1115_sensor +<<: !include common.yaml diff --git a/tests/components/ads1115/test.rp2040-ard.yaml b/tests/components/ads1115/test.rp2040-ard.yaml index 265d2cad2c..ee2c29ca4e 100644 --- a/tests/components/ads1115/test.rp2040-ard.yaml +++ b/tests/components/ads1115/test.rp2040-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ads1115 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ads1115: - address: 0x48 - -sensor: - - platform: ads1115 - multiplexer: A0_A1 - gain: 1.024 - sample_rate: 128 - id: ads1115_sensor +<<: !include common.yaml diff --git a/tests/components/ags10/common.yaml b/tests/components/ags10/common.yaml new file mode 100644 index 0000000000..0c4c3513cf --- /dev/null +++ b/tests/components/ags10/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_ags10 + scl: ${scl_pin} + sda: ${sda_pin} + frequency: 10kHz + +sensor: + - platform: ags10 + id: ags10_1 + tvoc: + name: AGS10 TVOC + update_interval: 60s diff --git a/tests/components/ags10/test.esp32-ard.yaml b/tests/components/ags10/test.esp32-ard.yaml index b3b53c0d31..63c3bd6afd 100644 --- a/tests/components/ags10/test.esp32-ard.yaml +++ b/tests/components/ags10/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ags10 - scl: 16 - sda: 17 - frequency: 10kHz +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ags10 - id: ags10_1 - tvoc: - name: AGS10 TVOC - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ags10/test.esp32-c3-ard.yaml b/tests/components/ags10/test.esp32-c3-ard.yaml index e338fc78e0..ee2c29ca4e 100644 --- a/tests/components/ags10/test.esp32-c3-ard.yaml +++ b/tests/components/ags10/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ags10 - scl: 5 - sda: 4 - frequency: 10kHz +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ags10 - id: ags10_1 - tvoc: - name: AGS10 TVOC - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ags10/test.esp32-c3-idf.yaml b/tests/components/ags10/test.esp32-c3-idf.yaml index e338fc78e0..ee2c29ca4e 100644 --- a/tests/components/ags10/test.esp32-c3-idf.yaml +++ b/tests/components/ags10/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ags10 - scl: 5 - sda: 4 - frequency: 10kHz +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ags10 - id: ags10_1 - tvoc: - name: AGS10 TVOC - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ags10/test.esp32-idf.yaml b/tests/components/ags10/test.esp32-idf.yaml index b3b53c0d31..63c3bd6afd 100644 --- a/tests/components/ags10/test.esp32-idf.yaml +++ b/tests/components/ags10/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ags10 - scl: 16 - sda: 17 - frequency: 10kHz +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ags10 - id: ags10_1 - tvoc: - name: AGS10 TVOC - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ags10/test.esp8266-ard.yaml b/tests/components/ags10/test.esp8266-ard.yaml index e338fc78e0..ee2c29ca4e 100644 --- a/tests/components/ags10/test.esp8266-ard.yaml +++ b/tests/components/ags10/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ags10 - scl: 5 - sda: 4 - frequency: 10kHz +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ags10 - id: ags10_1 - tvoc: - name: AGS10 TVOC - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/aht10/common.yaml b/tests/components/aht10/common.yaml new file mode 100644 index 0000000000..721af09bb4 --- /dev/null +++ b/tests/components/aht10/common.yaml @@ -0,0 +1,11 @@ +i2c: + - id: i2c_aht10 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: aht10 + temperature: + name: Temperature + humidity: + name: Humidity diff --git a/tests/components/aht10/test.esp32-ard.yaml b/tests/components/aht10/test.esp32-ard.yaml index 499e69e5d3..63c3bd6afd 100644 --- a/tests/components/aht10/test.esp32-ard.yaml +++ b/tests/components/aht10/test.esp32-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_aht10 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: aht10 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/aht10/test.esp32-c3-ard.yaml b/tests/components/aht10/test.esp32-c3-ard.yaml index 2e5f505476..ee2c29ca4e 100644 --- a/tests/components/aht10/test.esp32-c3-ard.yaml +++ b/tests/components/aht10/test.esp32-c3-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_aht10 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: aht10 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/aht10/test.esp32-c3-idf.yaml b/tests/components/aht10/test.esp32-c3-idf.yaml index 2e5f505476..ee2c29ca4e 100644 --- a/tests/components/aht10/test.esp32-c3-idf.yaml +++ b/tests/components/aht10/test.esp32-c3-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_aht10 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: aht10 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/aht10/test.esp32-idf.yaml b/tests/components/aht10/test.esp32-idf.yaml index 499e69e5d3..63c3bd6afd 100644 --- a/tests/components/aht10/test.esp32-idf.yaml +++ b/tests/components/aht10/test.esp32-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_aht10 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: aht10 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/aht10/test.esp8266-ard.yaml b/tests/components/aht10/test.esp8266-ard.yaml index 2e5f505476..ee2c29ca4e 100644 --- a/tests/components/aht10/test.esp8266-ard.yaml +++ b/tests/components/aht10/test.esp8266-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_aht10 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: aht10 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/aht10/test.rp2040-ard.yaml b/tests/components/aht10/test.rp2040-ard.yaml index 2e5f505476..ee2c29ca4e 100644 --- a/tests/components/aht10/test.rp2040-ard.yaml +++ b/tests/components/aht10/test.rp2040-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_aht10 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: aht10 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2315c/common.yaml b/tests/components/am2315c/common.yaml new file mode 100644 index 0000000000..ab4656c17d --- /dev/null +++ b/tests/components/am2315c/common.yaml @@ -0,0 +1,11 @@ +i2c: + - id: i2c_am2315c + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: am2315c + temperature: + name: Temperature + humidity: + name: Humidity diff --git a/tests/components/am2315c/test.esp32-ard.yaml b/tests/components/am2315c/test.esp32-ard.yaml index ed6b65f787..63c3bd6afd 100644 --- a/tests/components/am2315c/test.esp32-ard.yaml +++ b/tests/components/am2315c/test.esp32-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_am2315c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: am2315c - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2315c/test.esp32-c3-ard.yaml b/tests/components/am2315c/test.esp32-c3-ard.yaml index d09bffb7a4..ee2c29ca4e 100644 --- a/tests/components/am2315c/test.esp32-c3-ard.yaml +++ b/tests/components/am2315c/test.esp32-c3-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_am2315c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: am2315c - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2315c/test.esp32-c3-idf.yaml b/tests/components/am2315c/test.esp32-c3-idf.yaml index d09bffb7a4..ee2c29ca4e 100644 --- a/tests/components/am2315c/test.esp32-c3-idf.yaml +++ b/tests/components/am2315c/test.esp32-c3-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_am2315c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: am2315c - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2315c/test.esp32-idf.yaml b/tests/components/am2315c/test.esp32-idf.yaml index ed6b65f787..63c3bd6afd 100644 --- a/tests/components/am2315c/test.esp32-idf.yaml +++ b/tests/components/am2315c/test.esp32-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_am2315c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: am2315c - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2315c/test.esp8266-ard.yaml b/tests/components/am2315c/test.esp8266-ard.yaml index d09bffb7a4..ee2c29ca4e 100644 --- a/tests/components/am2315c/test.esp8266-ard.yaml +++ b/tests/components/am2315c/test.esp8266-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_am2315c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: am2315c - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2315c/test.rp2040-ard.yaml b/tests/components/am2315c/test.rp2040-ard.yaml index d09bffb7a4..ee2c29ca4e 100644 --- a/tests/components/am2315c/test.rp2040-ard.yaml +++ b/tests/components/am2315c/test.rp2040-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_am2315c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: am2315c - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2320/common.yaml b/tests/components/am2320/common.yaml new file mode 100644 index 0000000000..c0982b8818 --- /dev/null +++ b/tests/components/am2320/common.yaml @@ -0,0 +1,11 @@ +i2c: + - id: i2c_am2320 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: am2320 + temperature: + name: Temperature + humidity: + name: Humidity diff --git a/tests/components/am2320/test.esp32-ard.yaml b/tests/components/am2320/test.esp32-ard.yaml index 99f4173b85..63c3bd6afd 100644 --- a/tests/components/am2320/test.esp32-ard.yaml +++ b/tests/components/am2320/test.esp32-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: am2320 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2320/test.esp32-c3-ard.yaml b/tests/components/am2320/test.esp32-c3-ard.yaml index 6acfe8d4fd..ee2c29ca4e 100644 --- a/tests/components/am2320/test.esp32-c3-ard.yaml +++ b/tests/components/am2320/test.esp32-c3-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: am2320 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2320/test.esp32-c3-idf.yaml b/tests/components/am2320/test.esp32-c3-idf.yaml index 6acfe8d4fd..ee2c29ca4e 100644 --- a/tests/components/am2320/test.esp32-c3-idf.yaml +++ b/tests/components/am2320/test.esp32-c3-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: am2320 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2320/test.esp32-idf.yaml b/tests/components/am2320/test.esp32-idf.yaml index 99f4173b85..63c3bd6afd 100644 --- a/tests/components/am2320/test.esp32-idf.yaml +++ b/tests/components/am2320/test.esp32-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: am2320 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2320/test.esp8266-ard.yaml b/tests/components/am2320/test.esp8266-ard.yaml index 6acfe8d4fd..ee2c29ca4e 100644 --- a/tests/components/am2320/test.esp8266-ard.yaml +++ b/tests/components/am2320/test.esp8266-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: am2320 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/am2320/test.rp2040-ard.yaml b/tests/components/am2320/test.rp2040-ard.yaml index 6acfe8d4fd..ee2c29ca4e 100644 --- a/tests/components/am2320/test.rp2040-ard.yaml +++ b/tests/components/am2320/test.rp2040-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: am2320 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/apds9960/common.yaml b/tests/components/apds9960/common.yaml new file mode 100644 index 0000000000..de7706648a --- /dev/null +++ b/tests/components/apds9960/common.yaml @@ -0,0 +1,48 @@ +i2c: + - id: i2c_apds9960 + scl: ${scl_pin} + sda: ${sda_pin} + +apds9960: + address: 0x20 + update_interval: 60s + +binary_sensor: + - platform: apds9960 + id: apds9960_binary_sensor + direction: up + name: APDS9960 Up + device_class: motion + filters: + - invert + - delayed_on: 20ms + - delayed_off: 20ms + - lambda: "return false;" + on_state: + - logger.log: New state + - platform: apds9960 + direction: down + name: APDS9960 Down + - platform: apds9960 + direction: left + name: APDS9960 Left + - platform: apds9960 + direction: right + name: APDS9960 Right + +sensor: + - platform: apds9960 + type: proximity + name: APDS9960 Proximity + - platform: apds9960 + type: clear + name: APDS9960 Clear + - platform: apds9960 + type: red + name: APDS9960 Red + - platform: apds9960 + type: green + name: APDS9960 Green + - platform: apds9960 + type: blue + name: APDS9960 Blue diff --git a/tests/components/apds9960/test.esp32-ard.yaml b/tests/components/apds9960/test.esp32-ard.yaml index 7ff70a4d47..63c3bd6afd 100644 --- a/tests/components/apds9960/test.esp32-ard.yaml +++ b/tests/components/apds9960/test.esp32-ard.yaml @@ -1,48 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -apds9960: - address: 0x20 - update_interval: 60s - -binary_sensor: - - platform: apds9960 - id: apds9960_binary_sensor - direction: up - name: APDS9960 Up - device_class: motion - filters: - - invert - - delayed_on: 20ms - - delayed_off: 20ms - - lambda: "return false;" - on_state: - - logger.log: New state - - platform: apds9960 - direction: down - name: APDS9960 Down - - platform: apds9960 - direction: left - name: APDS9960 Left - - platform: apds9960 - direction: right - name: APDS9960 Right - -sensor: - - platform: apds9960 - type: proximity - name: APDS9960 Proximity - - platform: apds9960 - type: clear - name: APDS9960 Clear - - platform: apds9960 - type: red - name: APDS9960 Red - - platform: apds9960 - type: green - name: APDS9960 Green - - platform: apds9960 - type: blue - name: APDS9960 Blue +<<: !include common.yaml diff --git a/tests/components/apds9960/test.esp32-c3-ard.yaml b/tests/components/apds9960/test.esp32-c3-ard.yaml index f6b6f7bac0..ee2c29ca4e 100644 --- a/tests/components/apds9960/test.esp32-c3-ard.yaml +++ b/tests/components/apds9960/test.esp32-c3-ard.yaml @@ -1,48 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -apds9960: - address: 0x20 - update_interval: 60s - -binary_sensor: - - platform: apds9960 - id: apds9960_binary_sensor - direction: up - name: APDS9960 Up - device_class: motion - filters: - - invert - - delayed_on: 20ms - - delayed_off: 20ms - - lambda: "return false;" - on_state: - - logger.log: New state - - platform: apds9960 - direction: down - name: APDS9960 Down - - platform: apds9960 - direction: left - name: APDS9960 Left - - platform: apds9960 - direction: right - name: APDS9960 Right - -sensor: - - platform: apds9960 - type: proximity - name: APDS9960 Proximity - - platform: apds9960 - type: clear - name: APDS9960 Clear - - platform: apds9960 - type: red - name: APDS9960 Red - - platform: apds9960 - type: green - name: APDS9960 Green - - platform: apds9960 - type: blue - name: APDS9960 Blue +<<: !include common.yaml diff --git a/tests/components/apds9960/test.esp32-c3-idf.yaml b/tests/components/apds9960/test.esp32-c3-idf.yaml index f6b6f7bac0..ee2c29ca4e 100644 --- a/tests/components/apds9960/test.esp32-c3-idf.yaml +++ b/tests/components/apds9960/test.esp32-c3-idf.yaml @@ -1,48 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -apds9960: - address: 0x20 - update_interval: 60s - -binary_sensor: - - platform: apds9960 - id: apds9960_binary_sensor - direction: up - name: APDS9960 Up - device_class: motion - filters: - - invert - - delayed_on: 20ms - - delayed_off: 20ms - - lambda: "return false;" - on_state: - - logger.log: New state - - platform: apds9960 - direction: down - name: APDS9960 Down - - platform: apds9960 - direction: left - name: APDS9960 Left - - platform: apds9960 - direction: right - name: APDS9960 Right - -sensor: - - platform: apds9960 - type: proximity - name: APDS9960 Proximity - - platform: apds9960 - type: clear - name: APDS9960 Clear - - platform: apds9960 - type: red - name: APDS9960 Red - - platform: apds9960 - type: green - name: APDS9960 Green - - platform: apds9960 - type: blue - name: APDS9960 Blue +<<: !include common.yaml diff --git a/tests/components/apds9960/test.esp32-idf.yaml b/tests/components/apds9960/test.esp32-idf.yaml index 7ff70a4d47..63c3bd6afd 100644 --- a/tests/components/apds9960/test.esp32-idf.yaml +++ b/tests/components/apds9960/test.esp32-idf.yaml @@ -1,48 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -apds9960: - address: 0x20 - update_interval: 60s - -binary_sensor: - - platform: apds9960 - id: apds9960_binary_sensor - direction: up - name: APDS9960 Up - device_class: motion - filters: - - invert - - delayed_on: 20ms - - delayed_off: 20ms - - lambda: "return false;" - on_state: - - logger.log: New state - - platform: apds9960 - direction: down - name: APDS9960 Down - - platform: apds9960 - direction: left - name: APDS9960 Left - - platform: apds9960 - direction: right - name: APDS9960 Right - -sensor: - - platform: apds9960 - type: proximity - name: APDS9960 Proximity - - platform: apds9960 - type: clear - name: APDS9960 Clear - - platform: apds9960 - type: red - name: APDS9960 Red - - platform: apds9960 - type: green - name: APDS9960 Green - - platform: apds9960 - type: blue - name: APDS9960 Blue +<<: !include common.yaml diff --git a/tests/components/apds9960/test.esp8266-ard.yaml b/tests/components/apds9960/test.esp8266-ard.yaml index f6b6f7bac0..ee2c29ca4e 100644 --- a/tests/components/apds9960/test.esp8266-ard.yaml +++ b/tests/components/apds9960/test.esp8266-ard.yaml @@ -1,48 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -apds9960: - address: 0x20 - update_interval: 60s - -binary_sensor: - - platform: apds9960 - id: apds9960_binary_sensor - direction: up - name: APDS9960 Up - device_class: motion - filters: - - invert - - delayed_on: 20ms - - delayed_off: 20ms - - lambda: "return false;" - on_state: - - logger.log: New state - - platform: apds9960 - direction: down - name: APDS9960 Down - - platform: apds9960 - direction: left - name: APDS9960 Left - - platform: apds9960 - direction: right - name: APDS9960 Right - -sensor: - - platform: apds9960 - type: proximity - name: APDS9960 Proximity - - platform: apds9960 - type: clear - name: APDS9960 Clear - - platform: apds9960 - type: red - name: APDS9960 Red - - platform: apds9960 - type: green - name: APDS9960 Green - - platform: apds9960 - type: blue - name: APDS9960 Blue +<<: !include common.yaml diff --git a/tests/components/apds9960/test.rp2040-ard.yaml b/tests/components/apds9960/test.rp2040-ard.yaml index f6b6f7bac0..ee2c29ca4e 100644 --- a/tests/components/apds9960/test.rp2040-ard.yaml +++ b/tests/components/apds9960/test.rp2040-ard.yaml @@ -1,48 +1,5 @@ -i2c: - - id: i2c_bme280 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -apds9960: - address: 0x20 - update_interval: 60s - -binary_sensor: - - platform: apds9960 - id: apds9960_binary_sensor - direction: up - name: APDS9960 Up - device_class: motion - filters: - - invert - - delayed_on: 20ms - - delayed_off: 20ms - - lambda: "return false;" - on_state: - - logger.log: New state - - platform: apds9960 - direction: down - name: APDS9960 Down - - platform: apds9960 - direction: left - name: APDS9960 Left - - platform: apds9960 - direction: right - name: APDS9960 Right - -sensor: - - platform: apds9960 - type: proximity - name: APDS9960 Proximity - - platform: apds9960 - type: clear - name: APDS9960 Clear - - platform: apds9960 - type: red - name: APDS9960 Red - - platform: apds9960 - type: green - name: APDS9960 Green - - platform: apds9960 - type: blue - name: APDS9960 Blue +<<: !include common.yaml diff --git a/tests/components/as3935_i2c/common.yaml b/tests/components/as3935_i2c/common.yaml new file mode 100644 index 0000000000..d76cc37fc1 --- /dev/null +++ b/tests/components/as3935_i2c/common.yaml @@ -0,0 +1,18 @@ +i2c: + - id: i2c_as3935 + scl: ${scl_pin} + sda: ${sda_pin} + +as3935_i2c: + irq_pin: ${irq_pin} + +binary_sensor: + - platform: as3935 + name: Storm Alert + +sensor: + - platform: as3935 + lightning_energy: + name: Lightning Energy + distance: + name: Distance Storm diff --git a/tests/components/as3935_i2c/test.esp32-ard.yaml b/tests/components/as3935_i2c/test.esp32-ard.yaml index fad703bee5..2c57d412f6 100644 --- a/tests/components/as3935_i2c/test.esp32-ard.yaml +++ b/tests/components/as3935_i2c/test.esp32-ard.yaml @@ -1,18 +1,6 @@ -i2c: - - id: i2c_as3935 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + irq_pin: GPIO15 -as3935_i2c: - irq_pin: 12 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_i2c/test.esp32-c3-ard.yaml b/tests/components/as3935_i2c/test.esp32-c3-ard.yaml index c72556dbac..799acabd5a 100644 --- a/tests/components/as3935_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/as3935_i2c/test.esp32-c3-ard.yaml @@ -1,18 +1,6 @@ -i2c: - - id: i2c_as3935 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 -as3935_i2c: - irq_pin: 6 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_i2c/test.esp32-c3-idf.yaml b/tests/components/as3935_i2c/test.esp32-c3-idf.yaml index c72556dbac..799acabd5a 100644 --- a/tests/components/as3935_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/as3935_i2c/test.esp32-c3-idf.yaml @@ -1,18 +1,6 @@ -i2c: - - id: i2c_as3935 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 -as3935_i2c: - irq_pin: 6 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_i2c/test.esp32-idf.yaml b/tests/components/as3935_i2c/test.esp32-idf.yaml index fad703bee5..2c57d412f6 100644 --- a/tests/components/as3935_i2c/test.esp32-idf.yaml +++ b/tests/components/as3935_i2c/test.esp32-idf.yaml @@ -1,18 +1,6 @@ -i2c: - - id: i2c_as3935 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + irq_pin: GPIO15 -as3935_i2c: - irq_pin: 12 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_i2c/test.esp8266-ard.yaml b/tests/components/as3935_i2c/test.esp8266-ard.yaml index adba9e440f..c8e6a43f44 100644 --- a/tests/components/as3935_i2c/test.esp8266-ard.yaml +++ b/tests/components/as3935_i2c/test.esp8266-ard.yaml @@ -1,18 +1,6 @@ -i2c: - - id: i2c_as3935 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO15 -as3935_i2c: - irq_pin: 15 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_i2c/test.rp2040-ard.yaml b/tests/components/as3935_i2c/test.rp2040-ard.yaml index c72556dbac..799acabd5a 100644 --- a/tests/components/as3935_i2c/test.rp2040-ard.yaml +++ b/tests/components/as3935_i2c/test.rp2040-ard.yaml @@ -1,18 +1,6 @@ -i2c: - - id: i2c_as3935 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 -as3935_i2c: - irq_pin: 6 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_spi/common.yaml b/tests/components/as3935_spi/common.yaml new file mode 100644 index 0000000000..c3fb93dff1 --- /dev/null +++ b/tests/components/as3935_spi/common.yaml @@ -0,0 +1,20 @@ +spi: + - id: spi_as3935 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +as3935_spi: + cs_pin: ${cs_pin} + irq_pin: ${irq_pin} + +binary_sensor: + - platform: as3935 + name: Storm Alert + +sensor: + - platform: as3935 + lightning_energy: + name: Lightning Energy + distance: + name: Distance Storm diff --git a/tests/components/as3935_spi/test.esp32-ard.yaml b/tests/components/as3935_spi/test.esp32-ard.yaml index 813a39cb23..e00f522dd4 100644 --- a/tests/components/as3935_spi/test.esp32-ard.yaml +++ b/tests/components/as3935_spi/test.esp32-ard.yaml @@ -1,20 +1,8 @@ -spi: - - id: spi_as3935 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + irq_pin: GPIO13 + cs_pin: GPIO5 -as3935_spi: - cs_pin: 12 - irq_pin: 13 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_spi/test.esp32-c3-ard.yaml b/tests/components/as3935_spi/test.esp32-c3-ard.yaml index 7a4a01aeea..fcf35f528e 100644 --- a/tests/components/as3935_spi/test.esp32-c3-ard.yaml +++ b/tests/components/as3935_spi/test.esp32-c3-ard.yaml @@ -1,20 +1,8 @@ -spi: - - id: spi_as3935 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + irq_pin: GPIO9 + cs_pin: GPIO8 -as3935_spi: - cs_pin: 2 - irq_pin: 3 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_spi/test.esp32-c3-idf.yaml b/tests/components/as3935_spi/test.esp32-c3-idf.yaml index 7a4a01aeea..fcf35f528e 100644 --- a/tests/components/as3935_spi/test.esp32-c3-idf.yaml +++ b/tests/components/as3935_spi/test.esp32-c3-idf.yaml @@ -1,20 +1,8 @@ -spi: - - id: spi_as3935 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + irq_pin: GPIO9 + cs_pin: GPIO8 -as3935_spi: - cs_pin: 2 - irq_pin: 3 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_spi/test.esp32-idf.yaml b/tests/components/as3935_spi/test.esp32-idf.yaml index 813a39cb23..e00f522dd4 100644 --- a/tests/components/as3935_spi/test.esp32-idf.yaml +++ b/tests/components/as3935_spi/test.esp32-idf.yaml @@ -1,20 +1,8 @@ -spi: - - id: spi_as3935 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + irq_pin: GPIO13 + cs_pin: GPIO5 -as3935_spi: - cs_pin: 12 - irq_pin: 13 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_spi/test.esp8266-ard.yaml b/tests/components/as3935_spi/test.esp8266-ard.yaml index 38a40b0833..b90e661ec0 100644 --- a/tests/components/as3935_spi/test.esp8266-ard.yaml +++ b/tests/components/as3935_spi/test.esp8266-ard.yaml @@ -1,20 +1,8 @@ -spi: - - id: spi_as3935 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + irq_pin: GPIO5 + cs_pin: GPIO15 -as3935_spi: - cs_pin: 15 - irq_pin: 16 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as3935_spi/test.rp2040-ard.yaml b/tests/components/as3935_spi/test.rp2040-ard.yaml index 528759d97d..8f5941e1b2 100644 --- a/tests/components/as3935_spi/test.rp2040-ard.yaml +++ b/tests/components/as3935_spi/test.rp2040-ard.yaml @@ -1,20 +1,8 @@ -spi: - - id: spi_as3935 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + irq_pin: GPIO5 + cs_pin: GPIO6 -as3935_spi: - cs_pin: 6 - irq_pin: 7 - -binary_sensor: - - platform: as3935 - name: Storm Alert - -sensor: - - platform: as3935 - lightning_energy: - name: Lightning Energy - distance: - name: Distance Storm +<<: !include common.yaml diff --git a/tests/components/as5600/common.yaml b/tests/components/as5600/common.yaml new file mode 100644 index 0000000000..860f5bf803 --- /dev/null +++ b/tests/components/as5600/common.yaml @@ -0,0 +1,27 @@ +i2c: + - id: i2c_as5600 + scl: ${scl_pin} + sda: ${sda_pin} + +as5600: + dir_pin: ${dir_pin} + direction: clockwise + start_position: 90deg + range: 180deg + watchdog: true + power_mode: low1 + hysteresis: lsb1 + slow_filter: 8x + fast_filter: lsb6 + +sensor: + - platform: as5600 + name: AS5600 Position + raw_position: + name: AS5600 Raw Position + gain: + name: AS5600 Gain + magnitude: + name: AS5600 Magnitude + status: + name: AS5600 Status diff --git a/tests/components/as5600/test.esp32-ard.yaml b/tests/components/as5600/test.esp32-ard.yaml index 312ee9ad04..fa08763501 100644 --- a/tests/components/as5600/test.esp32-ard.yaml +++ b/tests/components/as5600/test.esp32-ard.yaml @@ -1,27 +1,6 @@ -i2c: - - id: i2c_as5600 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + dir_pin: GPIO15 -as5600: - dir_pin: 12 - direction: clockwise - start_position: 90deg - range: 180deg - watchdog: true - power_mode: low1 - hysteresis: lsb1 - slow_filter: 8x - fast_filter: lsb6 - -sensor: - - platform: as5600 - name: AS5600 Position - raw_position: - name: AS5600 Raw Position - gain: - name: AS5600 Gain - magnitude: - name: AS5600 Magnitude - status: - name: AS5600 Status +<<: !include common.yaml diff --git a/tests/components/as5600/test.esp32-c3-ard.yaml b/tests/components/as5600/test.esp32-c3-ard.yaml index e074fa5e0c..a0623c91e5 100644 --- a/tests/components/as5600/test.esp32-c3-ard.yaml +++ b/tests/components/as5600/test.esp32-c3-ard.yaml @@ -1,27 +1,6 @@ -i2c: - - id: i2c_as5600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + dir_pin: GPIO6 -as5600: - dir_pin: 6 - direction: clockwise - start_position: 90deg - range: 180deg - watchdog: true - power_mode: low1 - hysteresis: lsb1 - slow_filter: 8x - fast_filter: lsb6 - -sensor: - - platform: as5600 - name: AS5600 Position - raw_position: - name: AS5600 Raw Position - gain: - name: AS5600 Gain - magnitude: - name: AS5600 Magnitude - status: - name: AS5600 Status +<<: !include common.yaml diff --git a/tests/components/as5600/test.esp32-c3-idf.yaml b/tests/components/as5600/test.esp32-c3-idf.yaml index e074fa5e0c..a0623c91e5 100644 --- a/tests/components/as5600/test.esp32-c3-idf.yaml +++ b/tests/components/as5600/test.esp32-c3-idf.yaml @@ -1,27 +1,6 @@ -i2c: - - id: i2c_as5600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + dir_pin: GPIO6 -as5600: - dir_pin: 6 - direction: clockwise - start_position: 90deg - range: 180deg - watchdog: true - power_mode: low1 - hysteresis: lsb1 - slow_filter: 8x - fast_filter: lsb6 - -sensor: - - platform: as5600 - name: AS5600 Position - raw_position: - name: AS5600 Raw Position - gain: - name: AS5600 Gain - magnitude: - name: AS5600 Magnitude - status: - name: AS5600 Status +<<: !include common.yaml diff --git a/tests/components/as5600/test.esp32-idf.yaml b/tests/components/as5600/test.esp32-idf.yaml index 312ee9ad04..fa08763501 100644 --- a/tests/components/as5600/test.esp32-idf.yaml +++ b/tests/components/as5600/test.esp32-idf.yaml @@ -1,27 +1,6 @@ -i2c: - - id: i2c_as5600 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + dir_pin: GPIO15 -as5600: - dir_pin: 12 - direction: clockwise - start_position: 90deg - range: 180deg - watchdog: true - power_mode: low1 - hysteresis: lsb1 - slow_filter: 8x - fast_filter: lsb6 - -sensor: - - platform: as5600 - name: AS5600 Position - raw_position: - name: AS5600 Raw Position - gain: - name: AS5600 Gain - magnitude: - name: AS5600 Magnitude - status: - name: AS5600 Status +<<: !include common.yaml diff --git a/tests/components/as5600/test.esp8266-ard.yaml b/tests/components/as5600/test.esp8266-ard.yaml index a232d27305..5e27f8c134 100644 --- a/tests/components/as5600/test.esp8266-ard.yaml +++ b/tests/components/as5600/test.esp8266-ard.yaml @@ -1,27 +1,6 @@ -i2c: - - id: i2c_as5600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + dir_pin: GPIO15 -as5600: - dir_pin: 15 - direction: clockwise - start_position: 90deg - range: 180deg - watchdog: true - power_mode: low1 - hysteresis: lsb1 - slow_filter: 8x - fast_filter: lsb6 - -sensor: - - platform: as5600 - name: AS5600 Position - raw_position: - name: AS5600 Raw Position - gain: - name: AS5600 Gain - magnitude: - name: AS5600 Magnitude - status: - name: AS5600 Status +<<: !include common.yaml diff --git a/tests/components/as5600/test.rp2040-ard.yaml b/tests/components/as5600/test.rp2040-ard.yaml index e074fa5e0c..a0623c91e5 100644 --- a/tests/components/as5600/test.rp2040-ard.yaml +++ b/tests/components/as5600/test.rp2040-ard.yaml @@ -1,27 +1,6 @@ -i2c: - - id: i2c_as5600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + dir_pin: GPIO6 -as5600: - dir_pin: 6 - direction: clockwise - start_position: 90deg - range: 180deg - watchdog: true - power_mode: low1 - hysteresis: lsb1 - slow_filter: 8x - fast_filter: lsb6 - -sensor: - - platform: as5600 - name: AS5600 Position - raw_position: - name: AS5600 Raw Position - gain: - name: AS5600 Gain - magnitude: - name: AS5600 Magnitude - status: - name: AS5600 Status +<<: !include common.yaml diff --git a/tests/components/as7341/common.yaml b/tests/components/as7341/common.yaml new file mode 100644 index 0000000000..0351b344c6 --- /dev/null +++ b/tests/components/as7341/common.yaml @@ -0,0 +1,31 @@ +i2c: + - id: i2c_as7341 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: as7341 + update_interval: 15s + gain: X8 + atime: 120 + astep: 99 + f1: + name: F1 + f2: + name: F2 + f3: + name: F3 + f4: + name: F4 + f5: + name: F5 + f6: + name: F6 + f7: + name: F7 + f8: + name: F8 + clear: + name: Clear + nir: + name: NIR diff --git a/tests/components/as7341/test.esp32-ard.yaml b/tests/components/as7341/test.esp32-ard.yaml index d582a367ac..63c3bd6afd 100644 --- a/tests/components/as7341/test.esp32-ard.yaml +++ b/tests/components/as7341/test.esp32-ard.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_as5600 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: as7341 - update_interval: 15s - gain: X8 - atime: 120 - astep: 99 - f1: - name: F1 - f2: - name: F2 - f3: - name: F3 - f4: - name: F4 - f5: - name: F5 - f6: - name: F6 - f7: - name: F7 - f8: - name: F8 - clear: - name: Clear - nir: - name: NIR +<<: !include common.yaml diff --git a/tests/components/as7341/test.esp32-c3-ard.yaml b/tests/components/as7341/test.esp32-c3-ard.yaml index 19965d1715..ee2c29ca4e 100644 --- a/tests/components/as7341/test.esp32-c3-ard.yaml +++ b/tests/components/as7341/test.esp32-c3-ard.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_as5600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: as7341 - update_interval: 15s - gain: X8 - atime: 120 - astep: 99 - f1: - name: F1 - f2: - name: F2 - f3: - name: F3 - f4: - name: F4 - f5: - name: F5 - f6: - name: F6 - f7: - name: F7 - f8: - name: F8 - clear: - name: Clear - nir: - name: NIR +<<: !include common.yaml diff --git a/tests/components/as7341/test.esp32-c3-idf.yaml b/tests/components/as7341/test.esp32-c3-idf.yaml index 19965d1715..ee2c29ca4e 100644 --- a/tests/components/as7341/test.esp32-c3-idf.yaml +++ b/tests/components/as7341/test.esp32-c3-idf.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_as5600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: as7341 - update_interval: 15s - gain: X8 - atime: 120 - astep: 99 - f1: - name: F1 - f2: - name: F2 - f3: - name: F3 - f4: - name: F4 - f5: - name: F5 - f6: - name: F6 - f7: - name: F7 - f8: - name: F8 - clear: - name: Clear - nir: - name: NIR +<<: !include common.yaml diff --git a/tests/components/as7341/test.esp32-idf.yaml b/tests/components/as7341/test.esp32-idf.yaml index d582a367ac..63c3bd6afd 100644 --- a/tests/components/as7341/test.esp32-idf.yaml +++ b/tests/components/as7341/test.esp32-idf.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_as5600 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: as7341 - update_interval: 15s - gain: X8 - atime: 120 - astep: 99 - f1: - name: F1 - f2: - name: F2 - f3: - name: F3 - f4: - name: F4 - f5: - name: F5 - f6: - name: F6 - f7: - name: F7 - f8: - name: F8 - clear: - name: Clear - nir: - name: NIR +<<: !include common.yaml diff --git a/tests/components/as7341/test.esp8266-ard.yaml b/tests/components/as7341/test.esp8266-ard.yaml index 19965d1715..ee2c29ca4e 100644 --- a/tests/components/as7341/test.esp8266-ard.yaml +++ b/tests/components/as7341/test.esp8266-ard.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_as5600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: as7341 - update_interval: 15s - gain: X8 - atime: 120 - astep: 99 - f1: - name: F1 - f2: - name: F2 - f3: - name: F3 - f4: - name: F4 - f5: - name: F5 - f6: - name: F6 - f7: - name: F7 - f8: - name: F8 - clear: - name: Clear - nir: - name: NIR +<<: !include common.yaml diff --git a/tests/components/as7341/test.rp2040-ard.yaml b/tests/components/as7341/test.rp2040-ard.yaml index 19965d1715..ee2c29ca4e 100644 --- a/tests/components/as7341/test.rp2040-ard.yaml +++ b/tests/components/as7341/test.rp2040-ard.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_as5600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: as7341 - update_interval: 15s - gain: X8 - atime: 120 - astep: 99 - f1: - name: F1 - f2: - name: F2 - f3: - name: F3 - f4: - name: F4 - f5: - name: F5 - f6: - name: F6 - f7: - name: F7 - f8: - name: F8 - clear: - name: Clear - nir: - name: NIR +<<: !include common.yaml diff --git a/tests/components/at581x/common.yaml b/tests/components/at581x/common.yaml new file mode 100644 index 0000000000..018a0fded1 --- /dev/null +++ b/tests/components/at581x/common.yaml @@ -0,0 +1,28 @@ +esphome: + on_boot: + then: + - at581x.settings: + id: waveradar + hw_frontend_reset: false + frequency: 5800MHz + sensing_distance: 200 + poweron_selfcheck_time: 2s + protect_time: 1s + trigger_base: 500ms + trigger_keep: 10s + stage_gain: 3 + power_consumption: 70uA + - at581x.reset: + id: waveradar + +at581x: + id: waveradar + +i2c: + - id: i2c_at581x + scl: ${scl_pin} + sda: ${sda_pin} + +switch: + - platform: at581x + name: Enable Radar diff --git a/tests/components/at581x/test.esp32-ard.yaml b/tests/components/at581x/test.esp32-ard.yaml index ff84e61e1e..63c3bd6afd 100644 --- a/tests/components/at581x/test.esp32-ard.yaml +++ b/tests/components/at581x/test.esp32-ard.yaml @@ -1,38 +1,5 @@ -esphome: - on_boot: - then: - - at581x.settings: - id: "Waveradar" - hw_frontend_reset: false - frequency: 5800MHz - sensing_distance: 200 - poweron_selfcheck_time: 2s - protect_time: 1s - trigger_base: 500ms - trigger_keep: 10s - stage_gain: 3 - power_consumption: 70uA - - at581x.reset: - id: "Waveradar" +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -at581x: - id: "Waveradar" - i2c_id: i2c_bus - -i2c: - sda: 14 - scl: 15 - scan: true - frequency: 100kHz - setup_priority: -100 - id: i2c_bus - -binary_sensor: - - platform: gpio - pin: GPIO21 - name: "Radar motion" - -switch: - - platform: at581x - at581x_id: "Waveradar" - name: "Enable Radar" +<<: !include common.yaml diff --git a/tests/components/at581x/test.esp32-c3-ard.yaml b/tests/components/at581x/test.esp32-c3-ard.yaml index b49a283eca..ee2c29ca4e 100644 --- a/tests/components/at581x/test.esp32-c3-ard.yaml +++ b/tests/components/at581x/test.esp32-c3-ard.yaml @@ -1,38 +1,5 @@ -esphome: - on_boot: - then: - - at581x.settings: - id: "Waveradar" - hw_frontend_reset: false - frequency: 5800MHz - sensing_distance: 200 - poweron_selfcheck_time: 2s - protect_time: 1s - trigger_base: 500ms - trigger_keep: 10s - stage_gain: 3 - power_consumption: 70uA - - at581x.reset: - id: "Waveradar" +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -at581x: - id: "Waveradar" - i2c_id: i2c_bus - -i2c: - sda: 8 - scl: 9 - scan: true - frequency: 100kHz - setup_priority: -100 - id: i2c_bus - -binary_sensor: - - platform: gpio - pin: GPIO21 - name: "Radar motion" - -switch: - - platform: at581x - at581x_id: "Waveradar" - name: "Enable Radar" +<<: !include common.yaml diff --git a/tests/components/at581x/test.esp32-c3-idf.yaml b/tests/components/at581x/test.esp32-c3-idf.yaml index b49a283eca..ee2c29ca4e 100644 --- a/tests/components/at581x/test.esp32-c3-idf.yaml +++ b/tests/components/at581x/test.esp32-c3-idf.yaml @@ -1,38 +1,5 @@ -esphome: - on_boot: - then: - - at581x.settings: - id: "Waveradar" - hw_frontend_reset: false - frequency: 5800MHz - sensing_distance: 200 - poweron_selfcheck_time: 2s - protect_time: 1s - trigger_base: 500ms - trigger_keep: 10s - stage_gain: 3 - power_consumption: 70uA - - at581x.reset: - id: "Waveradar" +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -at581x: - id: "Waveradar" - i2c_id: i2c_bus - -i2c: - sda: 8 - scl: 9 - scan: true - frequency: 100kHz - setup_priority: -100 - id: i2c_bus - -binary_sensor: - - platform: gpio - pin: GPIO21 - name: "Radar motion" - -switch: - - platform: at581x - at581x_id: "Waveradar" - name: "Enable Radar" +<<: !include common.yaml diff --git a/tests/components/at581x/test.esp32-idf.yaml b/tests/components/at581x/test.esp32-idf.yaml index ff84e61e1e..63c3bd6afd 100644 --- a/tests/components/at581x/test.esp32-idf.yaml +++ b/tests/components/at581x/test.esp32-idf.yaml @@ -1,38 +1,5 @@ -esphome: - on_boot: - then: - - at581x.settings: - id: "Waveradar" - hw_frontend_reset: false - frequency: 5800MHz - sensing_distance: 200 - poweron_selfcheck_time: 2s - protect_time: 1s - trigger_base: 500ms - trigger_keep: 10s - stage_gain: 3 - power_consumption: 70uA - - at581x.reset: - id: "Waveradar" +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -at581x: - id: "Waveradar" - i2c_id: i2c_bus - -i2c: - sda: 14 - scl: 15 - scan: true - frequency: 100kHz - setup_priority: -100 - id: i2c_bus - -binary_sensor: - - platform: gpio - pin: GPIO21 - name: "Radar motion" - -switch: - - platform: at581x - at581x_id: "Waveradar" - name: "Enable Radar" +<<: !include common.yaml diff --git a/tests/components/at581x/test.esp8266-ard.yaml b/tests/components/at581x/test.esp8266-ard.yaml index a7b0069045..ee2c29ca4e 100644 --- a/tests/components/at581x/test.esp8266-ard.yaml +++ b/tests/components/at581x/test.esp8266-ard.yaml @@ -1,38 +1,5 @@ -esphome: - on_boot: - then: - - at581x.settings: - id: "Waveradar" - hw_frontend_reset: false - frequency: 5800MHz - sensing_distance: 200 - poweron_selfcheck_time: 2s - protect_time: 1s - trigger_base: 500ms - trigger_keep: 10s - stage_gain: 3 - power_consumption: 70uA - - at581x.reset: - id: "Waveradar" +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -at581x: - id: "Waveradar" - i2c_id: i2c_bus - -i2c: - sda: 14 - scl: 15 - scan: true - frequency: 100kHz - setup_priority: -100 - id: i2c_bus - -binary_sensor: - - platform: gpio - pin: GPIO4 - name: "Radar motion" - -switch: - - platform: at581x - at581x_id: "Waveradar" - name: "Enable Radar" +<<: !include common.yaml diff --git a/tests/components/at581x/test.rp2040-ard.yaml b/tests/components/at581x/test.rp2040-ard.yaml index b49a283eca..ee2c29ca4e 100644 --- a/tests/components/at581x/test.rp2040-ard.yaml +++ b/tests/components/at581x/test.rp2040-ard.yaml @@ -1,38 +1,5 @@ -esphome: - on_boot: - then: - - at581x.settings: - id: "Waveradar" - hw_frontend_reset: false - frequency: 5800MHz - sensing_distance: 200 - poweron_selfcheck_time: 2s - protect_time: 1s - trigger_base: 500ms - trigger_keep: 10s - stage_gain: 3 - power_consumption: 70uA - - at581x.reset: - id: "Waveradar" +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -at581x: - id: "Waveradar" - i2c_id: i2c_bus - -i2c: - sda: 8 - scl: 9 - scan: true - frequency: 100kHz - setup_priority: -100 - id: i2c_bus - -binary_sensor: - - platform: gpio - pin: GPIO21 - name: "Radar motion" - -switch: - - platform: at581x - at581x_id: "Waveradar" - name: "Enable Radar" +<<: !include common.yaml diff --git a/tests/components/atm90e26/common.yaml b/tests/components/atm90e26/common.yaml new file mode 100644 index 0000000000..49c3a73ec8 --- /dev/null +++ b/tests/components/atm90e26/common.yaml @@ -0,0 +1,26 @@ +spi: + - id: spi_atm90e26 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sensor: + - platform: atm90e26 + cs_pin: ${cs_pin} + voltage: + name: Line Voltage + current: + name: CT Amps + power: + name: Active Watts + power_factor: + name: Power Factor + frequency: + name: Line Frequency + line_frequency: 50Hz + meter_constant: 1000 + pl_const: 1429876 + gain_pga: 1X + gain_metering: 7481 + gain_voltage: 26400 + gain_ct: 31251 diff --git a/tests/components/atm90e26/test.esp32-ard.yaml b/tests/components/atm90e26/test.esp32-ard.yaml index 72fb3e5b24..54e027a614 100644 --- a/tests/components/atm90e26/test.esp32-ard.yaml +++ b/tests/components/atm90e26/test.esp32-ard.yaml @@ -1,26 +1,7 @@ -spi: - - id: spi_atm90e26 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: atm90e26 - cs_pin: 13 - voltage: - name: Line Voltage - current: - name: CT Amps - power: - name: Active Watts - power_factor: - name: Power Factor - frequency: - name: Line Frequency - line_frequency: 50Hz - meter_constant: 1000 - pl_const: 1429876 - gain_pga: 1X - gain_metering: 7481 - gain_voltage: 26400 - gain_ct: 31251 +<<: !include common.yaml diff --git a/tests/components/atm90e26/test.esp32-c3-ard.yaml b/tests/components/atm90e26/test.esp32-c3-ard.yaml index ce123bcf72..2415ba5dc6 100644 --- a/tests/components/atm90e26/test.esp32-c3-ard.yaml +++ b/tests/components/atm90e26/test.esp32-c3-ard.yaml @@ -1,26 +1,7 @@ -spi: - - id: spi_atm90e26 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: atm90e26 - cs_pin: 8 - voltage: - name: Line Voltage - current: - name: CT Amps - power: - name: Active Watts - power_factor: - name: Power Factor - frequency: - name: Line Frequency - line_frequency: 50Hz - meter_constant: 1000 - pl_const: 1429876 - gain_pga: 1X - gain_metering: 7481 - gain_voltage: 26400 - gain_ct: 31251 +<<: !include common.yaml diff --git a/tests/components/atm90e26/test.esp32-c3-idf.yaml b/tests/components/atm90e26/test.esp32-c3-idf.yaml index ce123bcf72..2415ba5dc6 100644 --- a/tests/components/atm90e26/test.esp32-c3-idf.yaml +++ b/tests/components/atm90e26/test.esp32-c3-idf.yaml @@ -1,26 +1,7 @@ -spi: - - id: spi_atm90e26 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: atm90e26 - cs_pin: 8 - voltage: - name: Line Voltage - current: - name: CT Amps - power: - name: Active Watts - power_factor: - name: Power Factor - frequency: - name: Line Frequency - line_frequency: 50Hz - meter_constant: 1000 - pl_const: 1429876 - gain_pga: 1X - gain_metering: 7481 - gain_voltage: 26400 - gain_ct: 31251 +<<: !include common.yaml diff --git a/tests/components/atm90e26/test.esp32-idf.yaml b/tests/components/atm90e26/test.esp32-idf.yaml index 72fb3e5b24..54e027a614 100644 --- a/tests/components/atm90e26/test.esp32-idf.yaml +++ b/tests/components/atm90e26/test.esp32-idf.yaml @@ -1,26 +1,7 @@ -spi: - - id: spi_atm90e26 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: atm90e26 - cs_pin: 13 - voltage: - name: Line Voltage - current: - name: CT Amps - power: - name: Active Watts - power_factor: - name: Power Factor - frequency: - name: Line Frequency - line_frequency: 50Hz - meter_constant: 1000 - pl_const: 1429876 - gain_pga: 1X - gain_metering: 7481 - gain_voltage: 26400 - gain_ct: 31251 +<<: !include common.yaml diff --git a/tests/components/atm90e26/test.esp8266-ard.yaml b/tests/components/atm90e26/test.esp8266-ard.yaml index 68d63cc278..dbd158d030 100644 --- a/tests/components/atm90e26/test.esp8266-ard.yaml +++ b/tests/components/atm90e26/test.esp8266-ard.yaml @@ -1,26 +1,7 @@ -spi: - - id: spi_atm90e26 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -sensor: - - platform: atm90e26 - cs_pin: 5 - voltage: - name: Line Voltage - current: - name: CT Amps - power: - name: Active Watts - power_factor: - name: Power Factor - frequency: - name: Line Frequency - line_frequency: 50Hz - meter_constant: 1000 - pl_const: 1429876 - gain_pga: 1X - gain_metering: 7481 - gain_voltage: 26400 - gain_ct: 31251 +<<: !include common.yaml diff --git a/tests/components/atm90e26/test.rp2040-ard.yaml b/tests/components/atm90e26/test.rp2040-ard.yaml index f43277dbb1..c8bfab0023 100644 --- a/tests/components/atm90e26/test.rp2040-ard.yaml +++ b/tests/components/atm90e26/test.rp2040-ard.yaml @@ -1,26 +1,7 @@ -spi: - - id: spi_atm90e26 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO6 -sensor: - - platform: atm90e26 - cs_pin: 5 - voltage: - name: Line Voltage - current: - name: CT Amps - power: - name: Active Watts - power_factor: - name: Power Factor - frequency: - name: Line Frequency - line_frequency: 50Hz - meter_constant: 1000 - pl_const: 1429876 - gain_pga: 1X - gain_metering: 7481 - gain_voltage: 26400 - gain_ct: 31251 +<<: !include common.yaml diff --git a/tests/components/atm90e32/common.yaml b/tests/components/atm90e32/common.yaml new file mode 100644 index 0000000000..156d00b4e0 --- /dev/null +++ b/tests/components/atm90e32/common.yaml @@ -0,0 +1,61 @@ +spi: + - id: spi_atm90e32 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sensor: + - platform: atm90e32 + cs_pin: ${cs_pin} + id: atm90e32_chip1 + phase_a: + voltage: + name: EMON Line Voltage A + current: + name: EMON CT1 Current + power: + name: EMON Active Power CT1 + reactive_power: + name: EMON Reactive Power CT1 + power_factor: + name: EMON Power Factor CT1 + gain_voltage: 7305 + gain_ct: 27961 + phase_b: + current: + name: EMON CT2 Current + power: + name: EMON Active Power CT2 + reactive_power: + name: EMON Reactive Power CT2 + power_factor: + name: EMON Power Factor CT2 + gain_voltage: 7305 + gain_ct: 27961 + phase_c: + current: + name: EMON CT3 Current + power: + name: EMON Active Power CT3 + reactive_power: + name: EMON Reactive Power CT3 + power_factor: + name: EMON Power Factor CT3 + gain_voltage: 7305 + gain_ct: 27961 + frequency: + name: EMON Line Frequency + chip_temperature: + name: EMON Chip Temp A + line_frequency: 60Hz + current_phases: 3 + gain_pga: 2X + enable_offset_calibration: True + +button: + - platform: atm90e32 + id: atm90e32_chip1 + run_offset_calibration: + name: Chip1 - Run Offset Calibration + clear_offset_calibration: + name: Chip1 - Clear Offset Calibration diff --git a/tests/components/atm90e32/test.esp32-ard.yaml b/tests/components/atm90e32/test.esp32-ard.yaml index 3bdc2bcec6..54e027a614 100644 --- a/tests/components/atm90e32/test.esp32-ard.yaml +++ b/tests/components/atm90e32/test.esp32-ard.yaml @@ -1,60 +1,7 @@ -spi: - - id: spi_atm90e32 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: atm90e32 - cs_pin: 13 - id: chip1 - phase_a: - voltage: - name: EMON Line Voltage A - current: - name: EMON CT1 Current - power: - name: EMON Active Power CT1 - reactive_power: - name: EMON Reactive Power CT1 - power_factor: - name: EMON Power Factor CT1 - gain_voltage: 7305 - gain_ct: 27961 - phase_b: - current: - name: EMON CT2 Current - power: - name: EMON Active Power CT2 - reactive_power: - name: EMON Reactive Power CT2 - power_factor: - name: EMON Power Factor CT2 - gain_voltage: 7305 - gain_ct: 27961 - phase_c: - current: - name: EMON CT3 Current - power: - name: EMON Active Power CT3 - reactive_power: - name: EMON Reactive Power CT3 - power_factor: - name: EMON Power Factor CT3 - gain_voltage: 7305 - gain_ct: 27961 - frequency: - name: EMON Line Frequency - chip_temperature: - name: EMON Chip Temp A - line_frequency: 60Hz - current_phases: 3 - gain_pga: 2X - enable_offset_calibration: True -button: - - platform: atm90e32 - id: chip1 - run_offset_calibration: - name: "Chip1 - Run Offset Calibration" - clear_offset_calibration: - name: "Chip1 - Clear Offset Calibration" +<<: !include common.yaml diff --git a/tests/components/atm90e32/test.esp32-c3-ard.yaml b/tests/components/atm90e32/test.esp32-c3-ard.yaml index 9ec0037a61..2415ba5dc6 100644 --- a/tests/components/atm90e32/test.esp32-c3-ard.yaml +++ b/tests/components/atm90e32/test.esp32-c3-ard.yaml @@ -1,60 +1,7 @@ -spi: - - id: spi_atm90e32 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: atm90e32 - cs_pin: 8 - id: chip1 - phase_a: - voltage: - name: EMON Line Voltage A - current: - name: EMON CT1 Current - power: - name: EMON Active Power CT1 - reactive_power: - name: EMON Reactive Power CT1 - power_factor: - name: EMON Power Factor CT1 - gain_voltage: 7305 - gain_ct: 27961 - phase_b: - current: - name: EMON CT2 Current - power: - name: EMON Active Power CT2 - reactive_power: - name: EMON Reactive Power CT2 - power_factor: - name: EMON Power Factor CT2 - gain_voltage: 7305 - gain_ct: 27961 - phase_c: - current: - name: EMON CT3 Current - power: - name: EMON Active Power CT3 - reactive_power: - name: EMON Reactive Power CT3 - power_factor: - name: EMON Power Factor CT3 - gain_voltage: 7305 - gain_ct: 27961 - frequency: - name: EMON Line Frequency - chip_temperature: - name: EMON Chip Temp A - line_frequency: 60Hz - current_phases: 3 - gain_pga: 2X - enable_offset_calibration: True -button: - - platform: atm90e32 - id: chip1 - run_offset_calibration: - name: "Chip1 - Run Offset Calibration" - clear_offset_calibration: - name: "Chip1 - Clear Offset Calibration" +<<: !include common.yaml diff --git a/tests/components/atm90e32/test.esp32-c3-idf.yaml b/tests/components/atm90e32/test.esp32-c3-idf.yaml index 9ec0037a61..2415ba5dc6 100644 --- a/tests/components/atm90e32/test.esp32-c3-idf.yaml +++ b/tests/components/atm90e32/test.esp32-c3-idf.yaml @@ -1,60 +1,7 @@ -spi: - - id: spi_atm90e32 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: atm90e32 - cs_pin: 8 - id: chip1 - phase_a: - voltage: - name: EMON Line Voltage A - current: - name: EMON CT1 Current - power: - name: EMON Active Power CT1 - reactive_power: - name: EMON Reactive Power CT1 - power_factor: - name: EMON Power Factor CT1 - gain_voltage: 7305 - gain_ct: 27961 - phase_b: - current: - name: EMON CT2 Current - power: - name: EMON Active Power CT2 - reactive_power: - name: EMON Reactive Power CT2 - power_factor: - name: EMON Power Factor CT2 - gain_voltage: 7305 - gain_ct: 27961 - phase_c: - current: - name: EMON CT3 Current - power: - name: EMON Active Power CT3 - reactive_power: - name: EMON Reactive Power CT3 - power_factor: - name: EMON Power Factor CT3 - gain_voltage: 7305 - gain_ct: 27961 - frequency: - name: EMON Line Frequency - chip_temperature: - name: EMON Chip Temp A - line_frequency: 60Hz - current_phases: 3 - gain_pga: 2X - enable_offset_calibration: True -button: - - platform: atm90e32 - id: chip1 - run_offset_calibration: - name: "Chip1 - Run Offset Calibration" - clear_offset_calibration: - name: "Chip1 - Clear Offset Calibration" +<<: !include common.yaml diff --git a/tests/components/atm90e32/test.esp32-idf.yaml b/tests/components/atm90e32/test.esp32-idf.yaml index 3bdc2bcec6..54e027a614 100644 --- a/tests/components/atm90e32/test.esp32-idf.yaml +++ b/tests/components/atm90e32/test.esp32-idf.yaml @@ -1,60 +1,7 @@ -spi: - - id: spi_atm90e32 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: atm90e32 - cs_pin: 13 - id: chip1 - phase_a: - voltage: - name: EMON Line Voltage A - current: - name: EMON CT1 Current - power: - name: EMON Active Power CT1 - reactive_power: - name: EMON Reactive Power CT1 - power_factor: - name: EMON Power Factor CT1 - gain_voltage: 7305 - gain_ct: 27961 - phase_b: - current: - name: EMON CT2 Current - power: - name: EMON Active Power CT2 - reactive_power: - name: EMON Reactive Power CT2 - power_factor: - name: EMON Power Factor CT2 - gain_voltage: 7305 - gain_ct: 27961 - phase_c: - current: - name: EMON CT3 Current - power: - name: EMON Active Power CT3 - reactive_power: - name: EMON Reactive Power CT3 - power_factor: - name: EMON Power Factor CT3 - gain_voltage: 7305 - gain_ct: 27961 - frequency: - name: EMON Line Frequency - chip_temperature: - name: EMON Chip Temp A - line_frequency: 60Hz - current_phases: 3 - gain_pga: 2X - enable_offset_calibration: True -button: - - platform: atm90e32 - id: chip1 - run_offset_calibration: - name: "Chip1 - Run Offset Calibration" - clear_offset_calibration: - name: "Chip1 - Clear Offset Calibration" +<<: !include common.yaml diff --git a/tests/components/atm90e32/test.esp8266-ard.yaml b/tests/components/atm90e32/test.esp8266-ard.yaml index fbb3368efa..dbd158d030 100644 --- a/tests/components/atm90e32/test.esp8266-ard.yaml +++ b/tests/components/atm90e32/test.esp8266-ard.yaml @@ -1,91 +1,7 @@ -spi: - - id: spi_atm90e32 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -sensor: - - platform: atm90e32 - cs_pin: 5 - id: chip1 - phase_a: - voltage: - name: EMON Line Voltage A - current: - name: EMON CT1 Current - power: - name: EMON Active Power CT1 - reactive_power: - name: EMON Reactive Power CT1 - power_factor: - name: EMON Power Factor CT1 - gain_voltage: 7305 - gain_ct: 27961 - phase_b: - current: - name: EMON CT2 Current - power: - name: EMON Active Power CT2 - reactive_power: - name: EMON Reactive Power CT2 - power_factor: - name: EMON Power Factor CT2 - gain_voltage: 7305 - gain_ct: 27961 - phase_c: - current: - name: EMON CT3 Current - power: - name: EMON Active Power CT3 - reactive_power: - name: EMON Reactive Power CT3 - power_factor: - name: EMON Power Factor CT3 - gain_voltage: 7305 - gain_ct: 27961 - frequency: - name: EMON Line Frequency - chip_temperature: - name: EMON Chip Temp A - line_frequency: 60Hz - current_phases: 3 - gain_pga: 2X - enable_offset_calibration: True - - platform: atm90e32 - cs_pin: 4 - id: chip2 - phase_a: - voltage: - name: EMON Line Voltage A - current: - name: EMON CT1 Current - power: - name: EMON Active Power CT1 - reactive_power: - name: EMON Reactive Power CT1 - power_factor: - name: EMON Power Factor CT1 - gain_voltage: 7305 - gain_ct: 27961 - phase_c: - voltage: - name: EMON Line Voltage C - current: - name: EMON CT2 Current - power: - name: EMON Active Power CT2 - reactive_power: - name: EMON Reactive Power CT2 - power_factor: - name: EMON Power Factor CT2 - gain_voltage: 7305 - gain_ct: 27961 - line_frequency: 60Hz - current_phases: 2 -button: - - platform: atm90e32 - id: chip1 - run_offset_calibration: - name: "Chip1 - Run Offset Calibration" - clear_offset_calibration: - name: "Chip1 - Clear Offset Calibration" +<<: !include common.yaml diff --git a/tests/components/atm90e32/test.rp2040-ard.yaml b/tests/components/atm90e32/test.rp2040-ard.yaml index a6b7956da7..c8bfab0023 100644 --- a/tests/components/atm90e32/test.rp2040-ard.yaml +++ b/tests/components/atm90e32/test.rp2040-ard.yaml @@ -1,60 +1,7 @@ -spi: - - id: spi_atm90e32 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO6 -sensor: - - platform: atm90e32 - cs_pin: 5 - id: chip1 - phase_a: - voltage: - name: EMON Line Voltage A - current: - name: EMON CT1 Current - power: - name: EMON Active Power CT1 - reactive_power: - name: EMON Reactive Power CT1 - power_factor: - name: EMON Power Factor CT1 - gain_voltage: 7305 - gain_ct: 27961 - phase_b: - current: - name: EMON CT2 Current - power: - name: EMON Active Power CT2 - reactive_power: - name: EMON Reactive Power CT2 - power_factor: - name: EMON Power Factor CT2 - gain_voltage: 7305 - gain_ct: 27961 - phase_c: - current: - name: EMON CT3 Current - power: - name: EMON Active Power CT3 - reactive_power: - name: EMON Reactive Power CT3 - power_factor: - name: EMON Power Factor CT3 - gain_voltage: 7305 - gain_ct: 27961 - frequency: - name: EMON Line Frequency - chip_temperature: - name: EMON Chip Temp A - line_frequency: 60Hz - current_phases: 3 - gain_pga: 2X - enable_offset_calibration: True -button: - - platform: atm90e32 - id: chip1 - run_offset_calibration: - name: "Chip1 - Run Offset Calibration" - clear_offset_calibration: - name: "Chip1 - Clear Offset Calibration" +<<: !include common.yaml From 53c15f671691cf3ab8ac8bfc9961600afd910353 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:05:02 -0600 Subject: [PATCH 145/194] [CI] Consolidate some tests (B) (#8185) --- tests/components/ballu/common.yaml | 12 +++++++ tests/components/ballu/test.esp32-ard.yaml | 14 ++------ tests/components/ballu/test.esp8266-ard.yaml | 14 ++------ tests/components/bh1750/common.yaml | 10 ++++++ tests/components/bh1750/test.esp32-ard.yaml | 13 +++----- .../components/bh1750/test.esp32-c3-ard.yaml | 13 +++----- .../components/bh1750/test.esp32-c3-idf.yaml | 13 +++----- tests/components/bh1750/test.esp32-idf.yaml | 13 +++----- tests/components/bh1750/test.esp8266-ard.yaml | 13 +++----- tests/components/bh1750/test.rp2040-ard.yaml | 13 +++----- tests/components/bl0906/common.yaml | 6 ++-- tests/components/bl0939/common.yaml | 24 ++++++++++++++ tests/components/bl0939/test.esp32-ard.yaml | 29 +++-------------- .../components/bl0939/test.esp32-c3-ard.yaml | 29 +++-------------- .../components/bl0939/test.esp32-c3-idf.yaml | 29 +++-------------- tests/components/bl0939/test.esp32-idf.yaml | 29 +++-------------- tests/components/bl0939/test.esp8266-ard.yaml | 29 +++-------------- tests/components/bl0939/test.rp2040-ard.yaml | 29 +++-------------- tests/components/bl0940/common.yaml | 20 ++++++++++++ tests/components/bl0940/test.esp32-ard.yaml | 25 +++------------ .../components/bl0940/test.esp32-c3-ard.yaml | 25 +++------------ .../components/bl0940/test.esp32-c3-idf.yaml | 25 +++------------ tests/components/bl0940/test.esp32-idf.yaml | 25 +++------------ tests/components/bl0940/test.esp8266-ard.yaml | 25 +++------------ tests/components/bl0940/test.rp2040-ard.yaml | 25 +++------------ tests/components/bl0942/common.yaml | 19 +++++++++++ tests/components/bl0942/test.bk72xx-ard.yaml | 30 +++-------------- tests/components/bl0942/test.esp32-ard.yaml | 24 +++----------- .../components/bl0942/test.esp32-c3-ard.yaml | 23 +++---------- .../components/bl0942/test.esp32-c3-idf.yaml | 23 +++---------- tests/components/bl0942/test.esp32-idf.yaml | 23 +++---------- tests/components/bl0942/test.esp8266-ard.yaml | 23 +++---------- tests/components/bl0942/test.rp2040-ard.yaml | 25 +++------------ tests/components/bme680/common.yaml | 21 ++++++++++++ tests/components/bme680/test.esp32-ard.yaml | 24 +++----------- .../components/bme680/test.esp32-c3-ard.yaml | 24 +++----------- .../components/bme680/test.esp32-c3-idf.yaml | 24 +++----------- tests/components/bme680/test.esp32-idf.yaml | 24 +++----------- tests/components/bme680/test.esp8266-ard.yaml | 24 +++----------- tests/components/bme680/test.rp2040-ard.yaml | 24 +++----------- tests/components/bme680_bsec/common.yaml | 29 +++++++++++++++++ .../bme680_bsec/test.esp32-ard.yaml | 32 +++---------------- .../bme680_bsec/test.esp8266-ard.yaml | 32 +++---------------- tests/components/bmi160/common.yaml | 22 +++++++++++++ tests/components/bmi160/test.esp32-ard.yaml | 25 +++------------ .../components/bmi160/test.esp32-c3-ard.yaml | 25 +++------------ .../components/bmi160/test.esp32-c3-idf.yaml | 25 +++------------ tests/components/bmi160/test.esp32-idf.yaml | 25 +++------------ tests/components/bmi160/test.esp8266-ard.yaml | 25 +++------------ tests/components/bmi160/test.rp2040-ard.yaml | 25 +++------------ tests/components/bmp085/common.yaml | 15 +++++++++ tests/components/bmp085/test.esp32-ard.yaml | 18 +++-------- .../components/bmp085/test.esp32-c3-ard.yaml | 18 +++-------- .../components/bmp085/test.esp32-c3-idf.yaml | 18 +++-------- tests/components/bmp085/test.esp32-idf.yaml | 18 +++-------- tests/components/bmp085/test.esp8266-ard.yaml | 18 +++-------- tests/components/bmp085/test.rp2040-ard.yaml | 18 +++-------- tests/components/bmp581/common.yaml | 13 ++++++++ tests/components/bmp581/test.esp32-ard.yaml | 16 +++------- .../components/bmp581/test.esp32-c3-ard.yaml | 16 +++------- .../components/bmp581/test.esp32-c3-idf.yaml | 16 +++------- tests/components/bmp581/test.esp32-idf.yaml | 16 +++------- tests/components/bmp581/test.esp8266-ard.yaml | 16 +++------- tests/components/bmp581/test.rp2040-ard.yaml | 16 +++------- tests/components/bp1658cj/common.yaml | 22 +++++++++++++ tests/components/bp1658cj/test.esp32-ard.yaml | 25 +++------------ .../bp1658cj/test.esp32-c3-ard.yaml | 25 +++------------ .../bp1658cj/test.esp32-c3-idf.yaml | 25 +++------------ tests/components/bp1658cj/test.esp32-idf.yaml | 25 +++------------ .../components/bp1658cj/test.esp8266-ard.yaml | 25 +++------------ .../components/bp1658cj/test.rp2040-ard.yaml | 25 +++------------ tests/components/bp5758d/common.yaml | 25 +++++++++++++++ tests/components/bp5758d/test.esp32-ard.yaml | 28 +++------------- .../components/bp5758d/test.esp32-c3-ard.yaml | 28 +++------------- .../components/bp5758d/test.esp32-c3-idf.yaml | 28 +++------------- tests/components/bp5758d/test.esp32-idf.yaml | 28 +++------------- .../components/bp5758d/test.esp8266-ard.yaml | 28 +++------------- tests/components/bp5758d/test.rp2040-ard.yaml | 28 +++------------- 78 files changed, 492 insertions(+), 1227 deletions(-) create mode 100644 tests/components/ballu/common.yaml create mode 100644 tests/components/bh1750/common.yaml create mode 100644 tests/components/bl0939/common.yaml create mode 100644 tests/components/bl0940/common.yaml create mode 100644 tests/components/bl0942/common.yaml create mode 100644 tests/components/bme680/common.yaml create mode 100644 tests/components/bme680_bsec/common.yaml create mode 100644 tests/components/bmi160/common.yaml create mode 100644 tests/components/bmp085/common.yaml create mode 100644 tests/components/bmp581/common.yaml create mode 100644 tests/components/bp1658cj/common.yaml create mode 100644 tests/components/bp5758d/common.yaml diff --git a/tests/components/ballu/common.yaml b/tests/components/ballu/common.yaml new file mode 100644 index 0000000000..52f86aa26a --- /dev/null +++ b/tests/components/ballu/common.yaml @@ -0,0 +1,12 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: heatpumpir + protocol: ballu + horizontal_default: middle + vertical_default: middle + name: HeatpumpIR Climate + min_temperature: 18 + max_temperature: 30 diff --git a/tests/components/ballu/test.esp32-ard.yaml b/tests/components/ballu/test.esp32-ard.yaml index bb7b9b0435..7b012aa64c 100644 --- a/tests/components/ballu/test.esp32-ard.yaml +++ b/tests/components/ballu/test.esp32-ard.yaml @@ -1,12 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: heatpumpir - protocol: ballu - horizontal_default: middle - vertical_default: middle - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 +<<: !include common.yaml diff --git a/tests/components/ballu/test.esp8266-ard.yaml b/tests/components/ballu/test.esp8266-ard.yaml index 05aa446739..f5097fcf5f 100644 --- a/tests/components/ballu/test.esp8266-ard.yaml +++ b/tests/components/ballu/test.esp8266-ard.yaml @@ -1,12 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: heatpumpir - protocol: ballu - horizontal_default: middle - vertical_default: middle - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 +<<: !include common.yaml diff --git a/tests/components/bh1750/common.yaml b/tests/components/bh1750/common.yaml new file mode 100644 index 0000000000..c0e0bc1c59 --- /dev/null +++ b/tests/components/bh1750/common.yaml @@ -0,0 +1,10 @@ +i2c: + - id: i2c_bh1750 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: bh1750 + name: Living Room Brightness + address: 0x23 + update_interval: 30s diff --git a/tests/components/bh1750/test.esp32-ard.yaml b/tests/components/bh1750/test.esp32-ard.yaml index b10ec231ae..3b761d3fc1 100644 --- a/tests/components/bh1750/test.esp32-ard.yaml +++ b/tests/components/bh1750/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_bh1750 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -sensor: - - platform: bh1750 - name: Living Room Brightness - address: 0x23 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/bh1750/test.esp32-c3-ard.yaml b/tests/components/bh1750/test.esp32-c3-ard.yaml index e367de3845..ee2c29ca4e 100644 --- a/tests/components/bh1750/test.esp32-c3-ard.yaml +++ b/tests/components/bh1750/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_bh1750 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bh1750 - name: Living Room Brightness - address: 0x23 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/bh1750/test.esp32-c3-idf.yaml b/tests/components/bh1750/test.esp32-c3-idf.yaml index e367de3845..ee2c29ca4e 100644 --- a/tests/components/bh1750/test.esp32-c3-idf.yaml +++ b/tests/components/bh1750/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_bh1750 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bh1750 - name: Living Room Brightness - address: 0x23 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/bh1750/test.esp32-idf.yaml b/tests/components/bh1750/test.esp32-idf.yaml index b10ec231ae..3b761d3fc1 100644 --- a/tests/components/bh1750/test.esp32-idf.yaml +++ b/tests/components/bh1750/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_bh1750 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -sensor: - - platform: bh1750 - name: Living Room Brightness - address: 0x23 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/bh1750/test.esp8266-ard.yaml b/tests/components/bh1750/test.esp8266-ard.yaml index e367de3845..ee2c29ca4e 100644 --- a/tests/components/bh1750/test.esp8266-ard.yaml +++ b/tests/components/bh1750/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_bh1750 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bh1750 - name: Living Room Brightness - address: 0x23 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/bh1750/test.rp2040-ard.yaml b/tests/components/bh1750/test.rp2040-ard.yaml index e367de3845..ee2c29ca4e 100644 --- a/tests/components/bh1750/test.rp2040-ard.yaml +++ b/tests/components/bh1750/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_bh1750 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bh1750 - name: Living Room Brightness - address: 0x23 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/bl0906/common.yaml b/tests/components/bl0906/common.yaml index 29321a9471..29b82a5958 100644 --- a/tests/components/bl0906/common.yaml +++ b/tests/components/bl0906/common.yaml @@ -1,9 +1,7 @@ uart: - id: uart_bl0906 - tx_pin: - number: ${tx_pin} - rx_pin: - number: ${rx_pin} + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} baud_rate: 19200 sensor: diff --git a/tests/components/bl0939/common.yaml b/tests/components/bl0939/common.yaml new file mode 100644 index 0000000000..7a6b635b70 --- /dev/null +++ b/tests/components/bl0939/common.yaml @@ -0,0 +1,24 @@ +uart: + - id: uart_bl0939 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: bl0939 + voltage: + name: BL0939 Voltage + current_1: + name: BL0939 Current 1 + current_2: + name: BL0939 Current 2 + active_power_1: + name: BL0939 Active Power 1 + active_power_2: + name: BL0939 Active Power 2 + energy_1: + name: BL0939 Energy 1 + energy_2: + name: BL0939 Energy 2 + energy_total: + name: BL0939 Total energy diff --git a/tests/components/bl0939/test.esp32-ard.yaml b/tests/components/bl0939/test.esp32-ard.yaml index df0e683b2f..811f6b72a6 100644 --- a/tests/components/bl0939/test.esp32-ard.yaml +++ b/tests/components/bl0939/test.esp32-ard.yaml @@ -1,26 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: bl0939 - voltage: - name: BL0939 Voltage - current_1: - name: BL0939 Current 1 - current_2: - name: BL0939 Current 2 - active_power_1: - name: BL0939 Active Power 1 - active_power_2: - name: BL0939 Active Power 2 - energy_1: - name: BL0939 Energy 1 - energy_2: - name: BL0939 Energy 2 - energy_total: - name: BL0939 Total energy +<<: !include common.yaml diff --git a/tests/components/bl0939/test.esp32-c3-ard.yaml b/tests/components/bl0939/test.esp32-c3-ard.yaml index 4c92ccb7dd..c79d14c740 100644 --- a/tests/components/bl0939/test.esp32-c3-ard.yaml +++ b/tests/components/bl0939/test.esp32-c3-ard.yaml @@ -1,26 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -sensor: - - platform: bl0939 - voltage: - name: BL0939 Voltage - current_1: - name: BL0939 Current 1 - current_2: - name: BL0939 Current 2 - active_power_1: - name: BL0939 Active Power 1 - active_power_2: - name: BL0939 Active Power 2 - energy_1: - name: BL0939 Energy 1 - energy_2: - name: BL0939 Energy 2 - energy_total: - name: BL0939 Total energy +<<: !include common.yaml diff --git a/tests/components/bl0939/test.esp32-c3-idf.yaml b/tests/components/bl0939/test.esp32-c3-idf.yaml index 4c92ccb7dd..c79d14c740 100644 --- a/tests/components/bl0939/test.esp32-c3-idf.yaml +++ b/tests/components/bl0939/test.esp32-c3-idf.yaml @@ -1,26 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -sensor: - - platform: bl0939 - voltage: - name: BL0939 Voltage - current_1: - name: BL0939 Current 1 - current_2: - name: BL0939 Current 2 - active_power_1: - name: BL0939 Active Power 1 - active_power_2: - name: BL0939 Active Power 2 - energy_1: - name: BL0939 Energy 1 - energy_2: - name: BL0939 Energy 2 - energy_total: - name: BL0939 Total energy +<<: !include common.yaml diff --git a/tests/components/bl0939/test.esp32-idf.yaml b/tests/components/bl0939/test.esp32-idf.yaml index df0e683b2f..811f6b72a6 100644 --- a/tests/components/bl0939/test.esp32-idf.yaml +++ b/tests/components/bl0939/test.esp32-idf.yaml @@ -1,26 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: bl0939 - voltage: - name: BL0939 Voltage - current_1: - name: BL0939 Current 1 - current_2: - name: BL0939 Current 2 - active_power_1: - name: BL0939 Active Power 1 - active_power_2: - name: BL0939 Active Power 2 - energy_1: - name: BL0939 Energy 1 - energy_2: - name: BL0939 Energy 2 - energy_total: - name: BL0939 Total energy +<<: !include common.yaml diff --git a/tests/components/bl0939/test.esp8266-ard.yaml b/tests/components/bl0939/test.esp8266-ard.yaml index 4c92ccb7dd..3b44f9c9c3 100644 --- a/tests/components/bl0939/test.esp8266-ard.yaml +++ b/tests/components/bl0939/test.esp8266-ard.yaml @@ -1,26 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO1 + rx_pin: GPIO3 -sensor: - - platform: bl0939 - voltage: - name: BL0939 Voltage - current_1: - name: BL0939 Current 1 - current_2: - name: BL0939 Current 2 - active_power_1: - name: BL0939 Active Power 1 - active_power_2: - name: BL0939 Active Power 2 - energy_1: - name: BL0939 Energy 1 - energy_2: - name: BL0939 Energy 2 - energy_total: - name: BL0939 Total energy +<<: !include common.yaml diff --git a/tests/components/bl0939/test.rp2040-ard.yaml b/tests/components/bl0939/test.rp2040-ard.yaml index 4c92ccb7dd..b516342f3b 100644 --- a/tests/components/bl0939/test.rp2040-ard.yaml +++ b/tests/components/bl0939/test.rp2040-ard.yaml @@ -1,26 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: bl0939 - voltage: - name: BL0939 Voltage - current_1: - name: BL0939 Current 1 - current_2: - name: BL0939 Current 2 - active_power_1: - name: BL0939 Active Power 1 - active_power_2: - name: BL0939 Active Power 2 - energy_1: - name: BL0939 Energy 1 - energy_2: - name: BL0939 Energy 2 - energy_total: - name: BL0939 Total energy +<<: !include common.yaml diff --git a/tests/components/bl0940/common.yaml b/tests/components/bl0940/common.yaml new file mode 100644 index 0000000000..97a997d2b4 --- /dev/null +++ b/tests/components/bl0940/common.yaml @@ -0,0 +1,20 @@ +uart: + - id: uart_bl0939 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: bl0940 + voltage: + name: BL0940 Voltage + current: + name: BL0940 Current + power: + name: BL0940 Power + energy: + name: BL0940 Energy + internal_temperature: + name: BL0940 Internal temperature + external_temperature: + name: BL0940 External temperature diff --git a/tests/components/bl0940/test.esp32-ard.yaml b/tests/components/bl0940/test.esp32-ard.yaml index c7d97ca3b9..811f6b72a6 100644 --- a/tests/components/bl0940/test.esp32-ard.yaml +++ b/tests/components/bl0940/test.esp32-ard.yaml @@ -1,22 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: bl0940 - voltage: - name: BL0940 Voltage - current: - name: BL0940 Current - power: - name: BL0940 Power - energy: - name: BL0940 Energy - internal_temperature: - name: BL0940 Internal temperature - external_temperature: - name: BL0940 External temperature +<<: !include common.yaml diff --git a/tests/components/bl0940/test.esp32-c3-ard.yaml b/tests/components/bl0940/test.esp32-c3-ard.yaml index a20f785b02..c79d14c740 100644 --- a/tests/components/bl0940/test.esp32-c3-ard.yaml +++ b/tests/components/bl0940/test.esp32-c3-ard.yaml @@ -1,22 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -sensor: - - platform: bl0940 - voltage: - name: BL0940 Voltage - current: - name: BL0940 Current - power: - name: BL0940 Power - energy: - name: BL0940 Energy - internal_temperature: - name: BL0940 Internal temperature - external_temperature: - name: BL0940 External temperature +<<: !include common.yaml diff --git a/tests/components/bl0940/test.esp32-c3-idf.yaml b/tests/components/bl0940/test.esp32-c3-idf.yaml index a20f785b02..c79d14c740 100644 --- a/tests/components/bl0940/test.esp32-c3-idf.yaml +++ b/tests/components/bl0940/test.esp32-c3-idf.yaml @@ -1,22 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -sensor: - - platform: bl0940 - voltage: - name: BL0940 Voltage - current: - name: BL0940 Current - power: - name: BL0940 Power - energy: - name: BL0940 Energy - internal_temperature: - name: BL0940 Internal temperature - external_temperature: - name: BL0940 External temperature +<<: !include common.yaml diff --git a/tests/components/bl0940/test.esp32-idf.yaml b/tests/components/bl0940/test.esp32-idf.yaml index c7d97ca3b9..811f6b72a6 100644 --- a/tests/components/bl0940/test.esp32-idf.yaml +++ b/tests/components/bl0940/test.esp32-idf.yaml @@ -1,22 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: bl0940 - voltage: - name: BL0940 Voltage - current: - name: BL0940 Current - power: - name: BL0940 Power - energy: - name: BL0940 Energy - internal_temperature: - name: BL0940 Internal temperature - external_temperature: - name: BL0940 External temperature +<<: !include common.yaml diff --git a/tests/components/bl0940/test.esp8266-ard.yaml b/tests/components/bl0940/test.esp8266-ard.yaml index a20f785b02..3b44f9c9c3 100644 --- a/tests/components/bl0940/test.esp8266-ard.yaml +++ b/tests/components/bl0940/test.esp8266-ard.yaml @@ -1,22 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO1 + rx_pin: GPIO3 -sensor: - - platform: bl0940 - voltage: - name: BL0940 Voltage - current: - name: BL0940 Current - power: - name: BL0940 Power - energy: - name: BL0940 Energy - internal_temperature: - name: BL0940 Internal temperature - external_temperature: - name: BL0940 External temperature +<<: !include common.yaml diff --git a/tests/components/bl0940/test.rp2040-ard.yaml b/tests/components/bl0940/test.rp2040-ard.yaml index a20f785b02..b516342f3b 100644 --- a/tests/components/bl0940/test.rp2040-ard.yaml +++ b/tests/components/bl0940/test.rp2040-ard.yaml @@ -1,22 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: bl0940 - voltage: - name: BL0940 Voltage - current: - name: BL0940 Current - power: - name: BL0940 Power - energy: - name: BL0940 Energy - internal_temperature: - name: BL0940 Internal temperature - external_temperature: - name: BL0940 External temperature +<<: !include common.yaml diff --git a/tests/components/bl0942/common.yaml b/tests/components/bl0942/common.yaml new file mode 100644 index 0000000000..32da24885f --- /dev/null +++ b/tests/components/bl0942/common.yaml @@ -0,0 +1,19 @@ +uart: + - id: uart_bl0939 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: bl0942 + reset: true + voltage: + name: BL0942 Voltage + current: + name: BL0942 Current + power: + name: BL0942 Power + energy: + name: BL0942 Energy + frequency: + name: BL0942 Frequency diff --git a/tests/components/bl0942/test.bk72xx-ard.yaml b/tests/components/bl0942/test.bk72xx-ard.yaml index ea61734441..96e13c83a9 100644 --- a/tests/components/bl0942/test.bk72xx-ard.yaml +++ b/tests/components/bl0942/test.bk72xx-ard.yaml @@ -1,27 +1,5 @@ -uart: - - id: uart_bl0942 - tx_pin: - number: TX1 - rx_pin: - number: RX1 - baud_rate: 2400 +substitutions: + tx_pin: TX1 + rx_pin: RX1 -sensor: - - platform: bl0942 - address: 0 - line_frequency: 50Hz - reset: false - voltage: - name: BL0942 Voltage - current: - name: BL0942 Current - power: - name: BL0942 Power - energy: - name: BL0942 Energy - frequency: - name: BL0942 Frequency - voltage_reference: 15968 - current_reference: 124180 - power_reference: 309.1 - energy_reference: 2653 +<<: !include common.yaml diff --git a/tests/components/bl0942/test.esp32-ard.yaml b/tests/components/bl0942/test.esp32-ard.yaml index 4138543967..811f6b72a6 100644 --- a/tests/components/bl0942/test.esp32-ard.yaml +++ b/tests/components/bl0942/test.esp32-ard.yaml @@ -1,21 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: bl0942 - reset: true - voltage: - name: BL0942 Voltage - current: - name: BL0942 Current - power: - name: BL0942 Power - energy: - name: BL0942 Energy - frequency: - name: BL0942 Frequency +<<: !include common.yaml diff --git a/tests/components/bl0942/test.esp32-c3-ard.yaml b/tests/components/bl0942/test.esp32-c3-ard.yaml index 8d16efed4f..c79d14c740 100644 --- a/tests/components/bl0942/test.esp32-c3-ard.yaml +++ b/tests/components/bl0942/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -sensor: - - platform: bl0942 - voltage: - name: BL0942 Voltage - current: - name: BL0942 Current - power: - name: BL0942 Power - energy: - name: BL0942 Energy - frequency: - name: BL0942 Frequency +<<: !include common.yaml diff --git a/tests/components/bl0942/test.esp32-c3-idf.yaml b/tests/components/bl0942/test.esp32-c3-idf.yaml index 8d16efed4f..c79d14c740 100644 --- a/tests/components/bl0942/test.esp32-c3-idf.yaml +++ b/tests/components/bl0942/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -sensor: - - platform: bl0942 - voltage: - name: BL0942 Voltage - current: - name: BL0942 Current - power: - name: BL0942 Power - energy: - name: BL0942 Energy - frequency: - name: BL0942 Frequency +<<: !include common.yaml diff --git a/tests/components/bl0942/test.esp32-idf.yaml b/tests/components/bl0942/test.esp32-idf.yaml index 45ac85aa2a..811f6b72a6 100644 --- a/tests/components/bl0942/test.esp32-idf.yaml +++ b/tests/components/bl0942/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: bl0942 - voltage: - name: BL0942 Voltage - current: - name: BL0942 Current - power: - name: BL0942 Power - energy: - name: BL0942 Energy - frequency: - name: BL0942 Frequency +<<: !include common.yaml diff --git a/tests/components/bl0942/test.esp8266-ard.yaml b/tests/components/bl0942/test.esp8266-ard.yaml index 8d16efed4f..3b44f9c9c3 100644 --- a/tests/components/bl0942/test.esp8266-ard.yaml +++ b/tests/components/bl0942/test.esp8266-ard.yaml @@ -1,20 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO1 + rx_pin: GPIO3 -sensor: - - platform: bl0942 - voltage: - name: BL0942 Voltage - current: - name: BL0942 Current - power: - name: BL0942 Power - energy: - name: BL0942 Energy - frequency: - name: BL0942 Frequency +<<: !include common.yaml diff --git a/tests/components/bl0942/test.rp2040-ard.yaml b/tests/components/bl0942/test.rp2040-ard.yaml index d07e0c4402..b516342f3b 100644 --- a/tests/components/bl0942/test.rp2040-ard.yaml +++ b/tests/components/bl0942/test.rp2040-ard.yaml @@ -1,22 +1,5 @@ -uart: - - id: uart_bl0939 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: bl0942 - voltage: - name: BL0942 Voltage - current: - name: BL0942 Current - power: - name: BL0942 Power - energy: - name: BL0942 Energy - frequency: - name: BL0942 Frequency - voltage_reference: 15968 - current_reference: 124180 +<<: !include common.yaml diff --git a/tests/components/bme680/common.yaml b/tests/components/bme680/common.yaml new file mode 100644 index 0000000000..13a42488f2 --- /dev/null +++ b/tests/components/bme680/common.yaml @@ -0,0 +1,21 @@ +i2c: + - id: i2c_bme680 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: bme680 + temperature: + name: BME680 Temperature + oversampling: 16x + pressure: + name: BME680 Pressure + humidity: + name: BME680 Humidity + gas_resistance: + name: BME680 Gas Sensor + address: 0x77 + heater: + temperature: 320 + duration: 150ms + update_interval: 15s diff --git a/tests/components/bme680/test.esp32-ard.yaml b/tests/components/bme680/test.esp32-ard.yaml index 04d0ed8fe4..3b761d3fc1 100644 --- a/tests/components/bme680/test.esp32-ard.yaml +++ b/tests/components/bme680/test.esp32-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_bme680 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -sensor: - - platform: bme680 - temperature: - name: BME680 Temperature - oversampling: 16x - pressure: - name: BME680 Pressure - humidity: - name: BME680 Humidity - gas_resistance: - name: BME680 Gas Sensor - address: 0x77 - heater: - temperature: 320 - duration: 150ms - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bme680/test.esp32-c3-ard.yaml b/tests/components/bme680/test.esp32-c3-ard.yaml index f12be09d20..ee2c29ca4e 100644 --- a/tests/components/bme680/test.esp32-c3-ard.yaml +++ b/tests/components/bme680/test.esp32-c3-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_bme680 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bme680 - temperature: - name: BME680 Temperature - oversampling: 16x - pressure: - name: BME680 Pressure - humidity: - name: BME680 Humidity - gas_resistance: - name: BME680 Gas Sensor - address: 0x77 - heater: - temperature: 320 - duration: 150ms - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bme680/test.esp32-c3-idf.yaml b/tests/components/bme680/test.esp32-c3-idf.yaml index f12be09d20..ee2c29ca4e 100644 --- a/tests/components/bme680/test.esp32-c3-idf.yaml +++ b/tests/components/bme680/test.esp32-c3-idf.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_bme680 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bme680 - temperature: - name: BME680 Temperature - oversampling: 16x - pressure: - name: BME680 Pressure - humidity: - name: BME680 Humidity - gas_resistance: - name: BME680 Gas Sensor - address: 0x77 - heater: - temperature: 320 - duration: 150ms - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bme680/test.esp32-idf.yaml b/tests/components/bme680/test.esp32-idf.yaml index 04d0ed8fe4..3b761d3fc1 100644 --- a/tests/components/bme680/test.esp32-idf.yaml +++ b/tests/components/bme680/test.esp32-idf.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_bme680 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -sensor: - - platform: bme680 - temperature: - name: BME680 Temperature - oversampling: 16x - pressure: - name: BME680 Pressure - humidity: - name: BME680 Humidity - gas_resistance: - name: BME680 Gas Sensor - address: 0x77 - heater: - temperature: 320 - duration: 150ms - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bme680/test.esp8266-ard.yaml b/tests/components/bme680/test.esp8266-ard.yaml index f12be09d20..ee2c29ca4e 100644 --- a/tests/components/bme680/test.esp8266-ard.yaml +++ b/tests/components/bme680/test.esp8266-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_bme680 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bme680 - temperature: - name: BME680 Temperature - oversampling: 16x - pressure: - name: BME680 Pressure - humidity: - name: BME680 Humidity - gas_resistance: - name: BME680 Gas Sensor - address: 0x77 - heater: - temperature: 320 - duration: 150ms - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bme680/test.rp2040-ard.yaml b/tests/components/bme680/test.rp2040-ard.yaml index f12be09d20..ee2c29ca4e 100644 --- a/tests/components/bme680/test.rp2040-ard.yaml +++ b/tests/components/bme680/test.rp2040-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_bme680 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bme680 - temperature: - name: BME680 Temperature - oversampling: 16x - pressure: - name: BME680 Pressure - humidity: - name: BME680 Humidity - gas_resistance: - name: BME680 Gas Sensor - address: 0x77 - heater: - temperature: 320 - duration: 150ms - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bme680_bsec/common.yaml b/tests/components/bme680_bsec/common.yaml new file mode 100644 index 0000000000..7d2e9e210b --- /dev/null +++ b/tests/components/bme680_bsec/common.yaml @@ -0,0 +1,29 @@ +i2c: + - id: i2c_bme680 + scl: ${scl_pin} + sda: ${sda_pin} + +bme680_bsec: + address: 0x77 + +sensor: + - platform: bme680_bsec + temperature: + name: BME680 Temperature + pressure: + name: BME680 Pressure + humidity: + name: BME680 Humidity + gas_resistance: + name: BME680 Gas Sensor + iaq: + name: BME680 IAQ + co2_equivalent: + name: BME680 eCO2 + breath_voc_equivalent: + name: BME680 Breath eVOC + +text_sensor: + - platform: bme680_bsec + iaq_accuracy: + name: BME680 Accuracy diff --git a/tests/components/bme680_bsec/test.esp32-ard.yaml b/tests/components/bme680_bsec/test.esp32-ard.yaml index 4f62f13abb..3b761d3fc1 100644 --- a/tests/components/bme680_bsec/test.esp32-ard.yaml +++ b/tests/components/bme680_bsec/test.esp32-ard.yaml @@ -1,29 +1,5 @@ -i2c: - - id: i2c_bme680 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -bme680_bsec: - address: 0x77 - -sensor: - - platform: bme680_bsec - temperature: - name: BME680 Temperature - pressure: - name: BME680 Pressure - humidity: - name: BME680 Humidity - gas_resistance: - name: BME680 Gas Sensor - iaq: - name: BME680 IAQ - co2_equivalent: - name: BME680 eCO2 - breath_voc_equivalent: - name: BME680 Breath eVOC - -text_sensor: - - platform: bme680_bsec - iaq_accuracy: - name: BME680 Accuracy +<<: !include common.yaml diff --git a/tests/components/bme680_bsec/test.esp8266-ard.yaml b/tests/components/bme680_bsec/test.esp8266-ard.yaml index 84b32d3635..ee2c29ca4e 100644 --- a/tests/components/bme680_bsec/test.esp8266-ard.yaml +++ b/tests/components/bme680_bsec/test.esp8266-ard.yaml @@ -1,29 +1,5 @@ -i2c: - - id: i2c_bme680 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -bme680_bsec: - address: 0x77 - -sensor: - - platform: bme680_bsec - temperature: - name: BME680 Temperature - pressure: - name: BME680 Pressure - humidity: - name: BME680 Humidity - gas_resistance: - name: BME680 Gas Sensor - iaq: - name: BME680 IAQ - co2_equivalent: - name: BME680 eCO2 - breath_voc_equivalent: - name: BME680 Breath eVOC - -text_sensor: - - platform: bme680_bsec - iaq_accuracy: - name: BME680 Accuracy +<<: !include common.yaml diff --git a/tests/components/bmi160/common.yaml b/tests/components/bmi160/common.yaml new file mode 100644 index 0000000000..6aa9aa6ed0 --- /dev/null +++ b/tests/components/bmi160/common.yaml @@ -0,0 +1,22 @@ +i2c: + - id: i2c_bmi160 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: bmi160 + address: 0x68 + acceleration_x: + name: BMI160 Accel X + acceleration_y: + name: BMI160 Accel Y + acceleration_z: + name: BMI160 Accel z + gyroscope_x: + name: BMI160 Gyro X + gyroscope_y: + name: BMI160 Gyro Y + gyroscope_z: + name: BMI160 Gyro z + temperature: + name: BMI160 Temperature diff --git a/tests/components/bmi160/test.esp32-ard.yaml b/tests/components/bmi160/test.esp32-ard.yaml index a8a90c8c87..3b761d3fc1 100644 --- a/tests/components/bmi160/test.esp32-ard.yaml +++ b/tests/components/bmi160/test.esp32-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_bmi160 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -sensor: - - platform: bmi160 - address: 0x68 - acceleration_x: - name: BMI160 Accel X - acceleration_y: - name: BMI160 Accel Y - acceleration_z: - name: BMI160 Accel z - gyroscope_x: - name: BMI160 Gyro X - gyroscope_y: - name: BMI160 Gyro Y - gyroscope_z: - name: BMI160 Gyro z - temperature: - name: BMI160 Temperature +<<: !include common.yaml diff --git a/tests/components/bmi160/test.esp32-c3-ard.yaml b/tests/components/bmi160/test.esp32-c3-ard.yaml index 3fd6441980..ee2c29ca4e 100644 --- a/tests/components/bmi160/test.esp32-c3-ard.yaml +++ b/tests/components/bmi160/test.esp32-c3-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_bmi160 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmi160 - address: 0x68 - acceleration_x: - name: BMI160 Accel X - acceleration_y: - name: BMI160 Accel Y - acceleration_z: - name: BMI160 Accel z - gyroscope_x: - name: BMI160 Gyro X - gyroscope_y: - name: BMI160 Gyro Y - gyroscope_z: - name: BMI160 Gyro z - temperature: - name: BMI160 Temperature +<<: !include common.yaml diff --git a/tests/components/bmi160/test.esp32-c3-idf.yaml b/tests/components/bmi160/test.esp32-c3-idf.yaml index 3fd6441980..ee2c29ca4e 100644 --- a/tests/components/bmi160/test.esp32-c3-idf.yaml +++ b/tests/components/bmi160/test.esp32-c3-idf.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_bmi160 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmi160 - address: 0x68 - acceleration_x: - name: BMI160 Accel X - acceleration_y: - name: BMI160 Accel Y - acceleration_z: - name: BMI160 Accel z - gyroscope_x: - name: BMI160 Gyro X - gyroscope_y: - name: BMI160 Gyro Y - gyroscope_z: - name: BMI160 Gyro z - temperature: - name: BMI160 Temperature +<<: !include common.yaml diff --git a/tests/components/bmi160/test.esp32-idf.yaml b/tests/components/bmi160/test.esp32-idf.yaml index a8a90c8c87..3b761d3fc1 100644 --- a/tests/components/bmi160/test.esp32-idf.yaml +++ b/tests/components/bmi160/test.esp32-idf.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_bmi160 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -sensor: - - platform: bmi160 - address: 0x68 - acceleration_x: - name: BMI160 Accel X - acceleration_y: - name: BMI160 Accel Y - acceleration_z: - name: BMI160 Accel z - gyroscope_x: - name: BMI160 Gyro X - gyroscope_y: - name: BMI160 Gyro Y - gyroscope_z: - name: BMI160 Gyro z - temperature: - name: BMI160 Temperature +<<: !include common.yaml diff --git a/tests/components/bmi160/test.esp8266-ard.yaml b/tests/components/bmi160/test.esp8266-ard.yaml index 3fd6441980..ee2c29ca4e 100644 --- a/tests/components/bmi160/test.esp8266-ard.yaml +++ b/tests/components/bmi160/test.esp8266-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_bmi160 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmi160 - address: 0x68 - acceleration_x: - name: BMI160 Accel X - acceleration_y: - name: BMI160 Accel Y - acceleration_z: - name: BMI160 Accel z - gyroscope_x: - name: BMI160 Gyro X - gyroscope_y: - name: BMI160 Gyro Y - gyroscope_z: - name: BMI160 Gyro z - temperature: - name: BMI160 Temperature +<<: !include common.yaml diff --git a/tests/components/bmi160/test.rp2040-ard.yaml b/tests/components/bmi160/test.rp2040-ard.yaml index 3fd6441980..ee2c29ca4e 100644 --- a/tests/components/bmi160/test.rp2040-ard.yaml +++ b/tests/components/bmi160/test.rp2040-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_bmi160 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmi160 - address: 0x68 - acceleration_x: - name: BMI160 Accel X - acceleration_y: - name: BMI160 Accel Y - acceleration_z: - name: BMI160 Accel z - gyroscope_x: - name: BMI160 Gyro X - gyroscope_y: - name: BMI160 Gyro Y - gyroscope_z: - name: BMI160 Gyro z - temperature: - name: BMI160 Temperature +<<: !include common.yaml diff --git a/tests/components/bmp085/common.yaml b/tests/components/bmp085/common.yaml new file mode 100644 index 0000000000..219bc51fbb --- /dev/null +++ b/tests/components/bmp085/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_bmp085 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: bmp085 + temperature: + name: Outside Temperature + pressure: + name: Outside Pressure + filters: + - lambda: >- + return x / powf(1.0 - (x / 44330.0), 5.255); + update_interval: 15s diff --git a/tests/components/bmp085/test.esp32-ard.yaml b/tests/components/bmp085/test.esp32-ard.yaml index 8a4f714ddd..3b761d3fc1 100644 --- a/tests/components/bmp085/test.esp32-ard.yaml +++ b/tests/components/bmp085/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_bmp085 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -sensor: - - platform: bmp085 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - filters: - - lambda: >- - return x / powf(1.0 - (x / 44330.0), 5.255); - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bmp085/test.esp32-c3-ard.yaml b/tests/components/bmp085/test.esp32-c3-ard.yaml index 76a9fd07ba..ee2c29ca4e 100644 --- a/tests/components/bmp085/test.esp32-c3-ard.yaml +++ b/tests/components/bmp085/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_bmp085 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmp085 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - filters: - - lambda: >- - return x / powf(1.0 - (x / 44330.0), 5.255); - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bmp085/test.esp32-c3-idf.yaml b/tests/components/bmp085/test.esp32-c3-idf.yaml index 76a9fd07ba..ee2c29ca4e 100644 --- a/tests/components/bmp085/test.esp32-c3-idf.yaml +++ b/tests/components/bmp085/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_bmp085 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmp085 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - filters: - - lambda: >- - return x / powf(1.0 - (x / 44330.0), 5.255); - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bmp085/test.esp32-idf.yaml b/tests/components/bmp085/test.esp32-idf.yaml index 8a4f714ddd..3b761d3fc1 100644 --- a/tests/components/bmp085/test.esp32-idf.yaml +++ b/tests/components/bmp085/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_bmp085 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -sensor: - - platform: bmp085 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - filters: - - lambda: >- - return x / powf(1.0 - (x / 44330.0), 5.255); - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bmp085/test.esp8266-ard.yaml b/tests/components/bmp085/test.esp8266-ard.yaml index 76a9fd07ba..ee2c29ca4e 100644 --- a/tests/components/bmp085/test.esp8266-ard.yaml +++ b/tests/components/bmp085/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_bmp085 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmp085 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - filters: - - lambda: >- - return x / powf(1.0 - (x / 44330.0), 5.255); - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bmp085/test.rp2040-ard.yaml b/tests/components/bmp085/test.rp2040-ard.yaml index 76a9fd07ba..ee2c29ca4e 100644 --- a/tests/components/bmp085/test.rp2040-ard.yaml +++ b/tests/components/bmp085/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_bmp085 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmp085 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - filters: - - lambda: >- - return x / powf(1.0 - (x / 44330.0), 5.255); - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/bmp581/common.yaml b/tests/components/bmp581/common.yaml new file mode 100644 index 0000000000..71ad4bfb1a --- /dev/null +++ b/tests/components/bmp581/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_bmp581 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: bmp581 + temperature: + name: BMP581 Temperature + iir_filter: 2x + pressure: + name: BMP581 Pressure + oversampling: 128x diff --git a/tests/components/bmp581/test.esp32-ard.yaml b/tests/components/bmp581/test.esp32-ard.yaml index a464b8ce6a..3b761d3fc1 100644 --- a/tests/components/bmp581/test.esp32-ard.yaml +++ b/tests/components/bmp581/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_bmp581 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -sensor: - - platform: bmp581 - temperature: - name: "BMP581 Temperature" - iir_filter: 2x - pressure: - name: "BMP581 Pressure" - oversampling: 128x +<<: !include common.yaml diff --git a/tests/components/bmp581/test.esp32-c3-ard.yaml b/tests/components/bmp581/test.esp32-c3-ard.yaml index 29d27afb90..ee2c29ca4e 100644 --- a/tests/components/bmp581/test.esp32-c3-ard.yaml +++ b/tests/components/bmp581/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_bmp581 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmp581 - temperature: - name: "BMP581 Temperature" - iir_filter: 2x - pressure: - name: "BMP581 Pressure" - oversampling: 128x +<<: !include common.yaml diff --git a/tests/components/bmp581/test.esp32-c3-idf.yaml b/tests/components/bmp581/test.esp32-c3-idf.yaml index 29d27afb90..ee2c29ca4e 100644 --- a/tests/components/bmp581/test.esp32-c3-idf.yaml +++ b/tests/components/bmp581/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_bmp581 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmp581 - temperature: - name: "BMP581 Temperature" - iir_filter: 2x - pressure: - name: "BMP581 Pressure" - oversampling: 128x +<<: !include common.yaml diff --git a/tests/components/bmp581/test.esp32-idf.yaml b/tests/components/bmp581/test.esp32-idf.yaml index a464b8ce6a..3b761d3fc1 100644 --- a/tests/components/bmp581/test.esp32-idf.yaml +++ b/tests/components/bmp581/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_bmp581 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO22 + sda_pin: GPIO21 -sensor: - - platform: bmp581 - temperature: - name: "BMP581 Temperature" - iir_filter: 2x - pressure: - name: "BMP581 Pressure" - oversampling: 128x +<<: !include common.yaml diff --git a/tests/components/bmp581/test.esp8266-ard.yaml b/tests/components/bmp581/test.esp8266-ard.yaml index 29d27afb90..ee2c29ca4e 100644 --- a/tests/components/bmp581/test.esp8266-ard.yaml +++ b/tests/components/bmp581/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_bmp581 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmp581 - temperature: - name: "BMP581 Temperature" - iir_filter: 2x - pressure: - name: "BMP581 Pressure" - oversampling: 128x +<<: !include common.yaml diff --git a/tests/components/bmp581/test.rp2040-ard.yaml b/tests/components/bmp581/test.rp2040-ard.yaml index 29d27afb90..ee2c29ca4e 100644 --- a/tests/components/bmp581/test.rp2040-ard.yaml +++ b/tests/components/bmp581/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_bmp581 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: bmp581 - temperature: - name: "BMP581 Temperature" - iir_filter: 2x - pressure: - name: "BMP581 Pressure" - oversampling: 128x +<<: !include common.yaml diff --git a/tests/components/bp1658cj/common.yaml b/tests/components/bp1658cj/common.yaml new file mode 100644 index 0000000000..e1d71bd4f3 --- /dev/null +++ b/tests/components/bp1658cj/common.yaml @@ -0,0 +1,22 @@ +bp1658cj: + clock_pin: ${clock_pin} + data_pin: ${data_pin} + max_power_color_channels: 4 + max_power_white_channels: 6 + +output: + - platform: bp1658cj + id: bp1658cj_red + channel: 1 + - platform: bp1658cj + id: bp1658cj_green + channel: 2 + - platform: bp1658cj + id: bp1658cj_blue + channel: 0 + - platform: bp1658cj + id: bp1658cj_coldwhite + channel: 3 + - platform: bp1658cj + id: bp1658cj_warmwhite + channel: 4 diff --git a/tests/components/bp1658cj/test.esp32-ard.yaml b/tests/components/bp1658cj/test.esp32-ard.yaml index 5f9e25d3bd..d295973e3f 100644 --- a/tests/components/bp1658cj/test.esp32-ard.yaml +++ b/tests/components/bp1658cj/test.esp32-ard.yaml @@ -1,22 +1,5 @@ -bp1658cj: - clock_pin: 16 - data_pin: 17 - max_power_color_channels: 4 - max_power_white_channels: 6 +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 -output: - - platform: bp1658cj - id: bp1658cj_red - channel: 1 - - platform: bp1658cj - id: bp1658cj_green - channel: 2 - - platform: bp1658cj - id: bp1658cj_blue - channel: 0 - - platform: bp1658cj - id: bp1658cj_coldwhite - channel: 3 - - platform: bp1658cj - id: bp1658cj_warmwhite - channel: 4 +<<: !include common.yaml diff --git a/tests/components/bp1658cj/test.esp32-c3-ard.yaml b/tests/components/bp1658cj/test.esp32-c3-ard.yaml index 74d3155371..7808481215 100644 --- a/tests/components/bp1658cj/test.esp32-c3-ard.yaml +++ b/tests/components/bp1658cj/test.esp32-c3-ard.yaml @@ -1,22 +1,5 @@ -bp1658cj: - clock_pin: 5 - data_pin: 4 - max_power_color_channels: 4 - max_power_white_channels: 6 +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 -output: - - platform: bp1658cj - id: bp1658cj_red - channel: 1 - - platform: bp1658cj - id: bp1658cj_green - channel: 2 - - platform: bp1658cj - id: bp1658cj_blue - channel: 0 - - platform: bp1658cj - id: bp1658cj_coldwhite - channel: 3 - - platform: bp1658cj - id: bp1658cj_warmwhite - channel: 4 +<<: !include common.yaml diff --git a/tests/components/bp1658cj/test.esp32-c3-idf.yaml b/tests/components/bp1658cj/test.esp32-c3-idf.yaml index 74d3155371..7808481215 100644 --- a/tests/components/bp1658cj/test.esp32-c3-idf.yaml +++ b/tests/components/bp1658cj/test.esp32-c3-idf.yaml @@ -1,22 +1,5 @@ -bp1658cj: - clock_pin: 5 - data_pin: 4 - max_power_color_channels: 4 - max_power_white_channels: 6 +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 -output: - - platform: bp1658cj - id: bp1658cj_red - channel: 1 - - platform: bp1658cj - id: bp1658cj_green - channel: 2 - - platform: bp1658cj - id: bp1658cj_blue - channel: 0 - - platform: bp1658cj - id: bp1658cj_coldwhite - channel: 3 - - platform: bp1658cj - id: bp1658cj_warmwhite - channel: 4 +<<: !include common.yaml diff --git a/tests/components/bp1658cj/test.esp32-idf.yaml b/tests/components/bp1658cj/test.esp32-idf.yaml index 5f9e25d3bd..d295973e3f 100644 --- a/tests/components/bp1658cj/test.esp32-idf.yaml +++ b/tests/components/bp1658cj/test.esp32-idf.yaml @@ -1,22 +1,5 @@ -bp1658cj: - clock_pin: 16 - data_pin: 17 - max_power_color_channels: 4 - max_power_white_channels: 6 +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 -output: - - platform: bp1658cj - id: bp1658cj_red - channel: 1 - - platform: bp1658cj - id: bp1658cj_green - channel: 2 - - platform: bp1658cj - id: bp1658cj_blue - channel: 0 - - platform: bp1658cj - id: bp1658cj_coldwhite - channel: 3 - - platform: bp1658cj - id: bp1658cj_warmwhite - channel: 4 +<<: !include common.yaml diff --git a/tests/components/bp1658cj/test.esp8266-ard.yaml b/tests/components/bp1658cj/test.esp8266-ard.yaml index 74d3155371..7808481215 100644 --- a/tests/components/bp1658cj/test.esp8266-ard.yaml +++ b/tests/components/bp1658cj/test.esp8266-ard.yaml @@ -1,22 +1,5 @@ -bp1658cj: - clock_pin: 5 - data_pin: 4 - max_power_color_channels: 4 - max_power_white_channels: 6 +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 -output: - - platform: bp1658cj - id: bp1658cj_red - channel: 1 - - platform: bp1658cj - id: bp1658cj_green - channel: 2 - - platform: bp1658cj - id: bp1658cj_blue - channel: 0 - - platform: bp1658cj - id: bp1658cj_coldwhite - channel: 3 - - platform: bp1658cj - id: bp1658cj_warmwhite - channel: 4 +<<: !include common.yaml diff --git a/tests/components/bp1658cj/test.rp2040-ard.yaml b/tests/components/bp1658cj/test.rp2040-ard.yaml index 74d3155371..7808481215 100644 --- a/tests/components/bp1658cj/test.rp2040-ard.yaml +++ b/tests/components/bp1658cj/test.rp2040-ard.yaml @@ -1,22 +1,5 @@ -bp1658cj: - clock_pin: 5 - data_pin: 4 - max_power_color_channels: 4 - max_power_white_channels: 6 +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 -output: - - platform: bp1658cj - id: bp1658cj_red - channel: 1 - - platform: bp1658cj - id: bp1658cj_green - channel: 2 - - platform: bp1658cj - id: bp1658cj_blue - channel: 0 - - platform: bp1658cj - id: bp1658cj_coldwhite - channel: 3 - - platform: bp1658cj - id: bp1658cj_warmwhite - channel: 4 +<<: !include common.yaml diff --git a/tests/components/bp5758d/common.yaml b/tests/components/bp5758d/common.yaml new file mode 100644 index 0000000000..4a39a6f69f --- /dev/null +++ b/tests/components/bp5758d/common.yaml @@ -0,0 +1,25 @@ +bp5758d: + clock_pin: ${clock_pin} + data_pin: ${data_pin} + +output: + - platform: bp5758d + id: bp5758d_red + channel: 2 + current: 10 + - platform: bp5758d + id: bp5758d_green + channel: 3 + current: 10 + - platform: bp5758d + id: bp5758d_blue + channel: 1 + current: 10 + - platform: bp5758d + id: bp5758d_coldwhite + channel: 5 + current: 10 + - platform: bp5758d + id: bp5758d_warmwhite + channel: 4 + current: 10 diff --git a/tests/components/bp5758d/test.esp32-ard.yaml b/tests/components/bp5758d/test.esp32-ard.yaml index b7929a0518..d295973e3f 100644 --- a/tests/components/bp5758d/test.esp32-ard.yaml +++ b/tests/components/bp5758d/test.esp32-ard.yaml @@ -1,25 +1,5 @@ -bp5758d: - clock_pin: 16 - data_pin: 17 +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 -output: - - platform: bp5758d - id: bp5758d_red - channel: 2 - current: 10 - - platform: bp5758d - id: bp5758d_green - channel: 3 - current: 10 - - platform: bp5758d - id: bp5758d_blue - channel: 1 - current: 10 - - platform: bp5758d - id: bp5758d_coldwhite - channel: 5 - current: 10 - - platform: bp5758d - id: bp5758d_warmwhite - channel: 4 - current: 10 +<<: !include common.yaml diff --git a/tests/components/bp5758d/test.esp32-c3-ard.yaml b/tests/components/bp5758d/test.esp32-c3-ard.yaml index ec74e935cd..7808481215 100644 --- a/tests/components/bp5758d/test.esp32-c3-ard.yaml +++ b/tests/components/bp5758d/test.esp32-c3-ard.yaml @@ -1,25 +1,5 @@ -bp5758d: - clock_pin: 5 - data_pin: 4 +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 -output: - - platform: bp5758d - id: bp5758d_red - channel: 2 - current: 10 - - platform: bp5758d - id: bp5758d_green - channel: 3 - current: 10 - - platform: bp5758d - id: bp5758d_blue - channel: 1 - current: 10 - - platform: bp5758d - id: bp5758d_coldwhite - channel: 5 - current: 10 - - platform: bp5758d - id: bp5758d_warmwhite - channel: 4 - current: 10 +<<: !include common.yaml diff --git a/tests/components/bp5758d/test.esp32-c3-idf.yaml b/tests/components/bp5758d/test.esp32-c3-idf.yaml index ec74e935cd..7808481215 100644 --- a/tests/components/bp5758d/test.esp32-c3-idf.yaml +++ b/tests/components/bp5758d/test.esp32-c3-idf.yaml @@ -1,25 +1,5 @@ -bp5758d: - clock_pin: 5 - data_pin: 4 +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 -output: - - platform: bp5758d - id: bp5758d_red - channel: 2 - current: 10 - - platform: bp5758d - id: bp5758d_green - channel: 3 - current: 10 - - platform: bp5758d - id: bp5758d_blue - channel: 1 - current: 10 - - platform: bp5758d - id: bp5758d_coldwhite - channel: 5 - current: 10 - - platform: bp5758d - id: bp5758d_warmwhite - channel: 4 - current: 10 +<<: !include common.yaml diff --git a/tests/components/bp5758d/test.esp32-idf.yaml b/tests/components/bp5758d/test.esp32-idf.yaml index b7929a0518..d295973e3f 100644 --- a/tests/components/bp5758d/test.esp32-idf.yaml +++ b/tests/components/bp5758d/test.esp32-idf.yaml @@ -1,25 +1,5 @@ -bp5758d: - clock_pin: 16 - data_pin: 17 +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 -output: - - platform: bp5758d - id: bp5758d_red - channel: 2 - current: 10 - - platform: bp5758d - id: bp5758d_green - channel: 3 - current: 10 - - platform: bp5758d - id: bp5758d_blue - channel: 1 - current: 10 - - platform: bp5758d - id: bp5758d_coldwhite - channel: 5 - current: 10 - - platform: bp5758d - id: bp5758d_warmwhite - channel: 4 - current: 10 +<<: !include common.yaml diff --git a/tests/components/bp5758d/test.esp8266-ard.yaml b/tests/components/bp5758d/test.esp8266-ard.yaml index ec74e935cd..7808481215 100644 --- a/tests/components/bp5758d/test.esp8266-ard.yaml +++ b/tests/components/bp5758d/test.esp8266-ard.yaml @@ -1,25 +1,5 @@ -bp5758d: - clock_pin: 5 - data_pin: 4 +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 -output: - - platform: bp5758d - id: bp5758d_red - channel: 2 - current: 10 - - platform: bp5758d - id: bp5758d_green - channel: 3 - current: 10 - - platform: bp5758d - id: bp5758d_blue - channel: 1 - current: 10 - - platform: bp5758d - id: bp5758d_coldwhite - channel: 5 - current: 10 - - platform: bp5758d - id: bp5758d_warmwhite - channel: 4 - current: 10 +<<: !include common.yaml diff --git a/tests/components/bp5758d/test.rp2040-ard.yaml b/tests/components/bp5758d/test.rp2040-ard.yaml index ec74e935cd..7808481215 100644 --- a/tests/components/bp5758d/test.rp2040-ard.yaml +++ b/tests/components/bp5758d/test.rp2040-ard.yaml @@ -1,25 +1,5 @@ -bp5758d: - clock_pin: 5 - data_pin: 4 +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 -output: - - platform: bp5758d - id: bp5758d_red - channel: 2 - current: 10 - - platform: bp5758d - id: bp5758d_green - channel: 3 - current: 10 - - platform: bp5758d - id: bp5758d_blue - channel: 1 - current: 10 - - platform: bp5758d - id: bp5758d_coldwhite - channel: 5 - current: 10 - - platform: bp5758d - id: bp5758d_warmwhite - channel: 4 - current: 10 +<<: !include common.yaml From 61ad2510fc045f05034975c42516868acb9de5a8 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:05:08 -0600 Subject: [PATCH 146/194] [CI] Consolidate some tests (C) (#8186) --- tests/components/cap1188/common.yaml | 11 +++ tests/components/cap1188/test.esp32-ard.yaml | 15 ++-- .../components/cap1188/test.esp32-c3-ard.yaml | 15 ++-- .../components/cap1188/test.esp32-c3-idf.yaml | 15 ++-- tests/components/cap1188/test.esp32-idf.yaml | 15 ++-- .../components/cap1188/test.esp8266-ard.yaml | 15 ++-- tests/components/cap1188/test.rp2040-ard.yaml | 15 ++-- tests/components/ccs811/common.yaml | 13 ++++ tests/components/ccs811/test.esp32-ard.yaml | 16 ++--- .../components/ccs811/test.esp32-c3-ard.yaml | 16 ++--- .../components/ccs811/test.esp32-c3-idf.yaml | 16 ++--- tests/components/ccs811/test.esp32-idf.yaml | 16 ++--- tests/components/ccs811/test.esp8266-ard.yaml | 16 ++--- tests/components/ccs811/test.rp2040-ard.yaml | 16 ++--- tests/components/cd74hc4067/common.yaml | 18 +++++ .../components/cd74hc4067/test.esp32-ard.yaml | 24 ++----- .../cd74hc4067/test.esp32-c3-ard.yaml | 24 ++----- .../cd74hc4067/test.esp32-c3-idf.yaml | 24 ++----- .../components/cd74hc4067/test.esp32-idf.yaml | 24 ++----- .../cd74hc4067/test.esp8266-ard.yaml | 24 ++----- .../cd74hc4067/test.rp2040-ard.yaml | 24 ++----- tests/components/climate_ir_lg/common.yaml | 7 ++ .../climate_ir_lg/test.esp32-ard.yaml | 9 +-- .../climate_ir_lg/test.esp32-c3-ard.yaml | 9 +-- .../climate_ir_lg/test.esp32-c3-idf.yaml | 9 +-- .../climate_ir_lg/test.esp32-idf.yaml | 9 +-- .../climate_ir_lg/test.esp8266-ard.yaml | 9 +-- .../components/color_temperature/common.yaml | 15 ++++ .../color_temperature/test.esp32-ard.yaml | 19 ++--- .../color_temperature/test.esp32-c3-ard.yaml | 19 ++--- .../color_temperature/test.esp32-c3-idf.yaml | 19 ++--- .../color_temperature/test.esp32-idf.yaml | 19 ++--- .../color_temperature/test.esp8266-ard.yaml | 19 ++--- .../color_temperature/test.rp2040-ard.yaml | 19 ++--- tests/components/coolix/common.yaml | 7 ++ tests/components/coolix/test.esp32-ard.yaml | 9 +-- .../components/coolix/test.esp32-c3-ard.yaml | 9 +-- .../components/coolix/test.esp32-c3-idf.yaml | 9 +-- tests/components/coolix/test.esp32-idf.yaml | 9 +-- tests/components/coolix/test.esp8266-ard.yaml | 9 +-- tests/components/copy/common.yaml | 23 ++++++ tests/components/copy/test.esp32-ard.yaml | 26 ++----- tests/components/copy/test.esp32-c3-ard.yaml | 26 ++----- tests/components/copy/test.esp32-c3-idf.yaml | 26 ++----- tests/components/copy/test.esp32-idf.yaml | 26 ++----- tests/components/copy/test.esp8266-ard.yaml | 26 ++----- tests/components/copy/test.rp2040-ard.yaml | 26 ++----- tests/components/cs5460a/common.yaml | 27 +++++++ tests/components/cs5460a/test.esp32-ard.yaml | 32 ++------- .../components/cs5460a/test.esp32-c3-ard.yaml | 32 ++------- .../components/cs5460a/test.esp32-c3-idf.yaml | 32 ++------- tests/components/cs5460a/test.esp32-idf.yaml | 32 ++------- .../components/cs5460a/test.esp8266-ard.yaml | 32 ++------- tests/components/cs5460a/test.rp2040-ard.yaml | 32 ++------- tests/components/cse7761/common.yaml | 18 +++++ tests/components/cse7761/test.esp32-ard.yaml | 23 ++---- .../components/cse7761/test.esp32-c3-ard.yaml | 23 ++---- .../components/cse7761/test.esp32-c3-idf.yaml | 23 ++---- tests/components/cse7761/test.esp32-idf.yaml | 23 ++---- .../components/cse7761/test.esp8266-ard.yaml | 23 ++---- tests/components/cse7761/test.rp2040-ard.yaml | 23 ++---- tests/components/cse7766/common.yaml | 15 ++++ tests/components/cse7766/test.esp32-ard.yaml | 20 ++---- .../components/cse7766/test.esp32-c3-ard.yaml | 20 ++---- .../components/cse7766/test.esp32-c3-idf.yaml | 20 ++---- tests/components/cse7766/test.esp32-idf.yaml | 20 ++---- .../components/cse7766/test.esp8266-ard.yaml | 20 ++---- tests/components/cse7766/test.rp2040-ard.yaml | 20 ++---- tests/components/cst226/common.yaml | 34 ++++----- tests/components/cst226/test.esp32-ard.yaml | 12 ++++ .../components/cst226/test.esp32-c3-ard.yaml | 11 +++ .../components/cst226/test.esp32-c3-idf.yaml | 12 ++++ tests/components/cst226/test.esp32-idf.yaml | 12 ++++ tests/components/cst816/common.yaml | 41 +++++------ tests/components/cst816/test.esp32-ard.yaml | 11 +++ .../components/cst816/test.esp32-c3-ard.yaml | 12 ++++ .../components/cst816/test.esp32-c3-idf.yaml | 12 ++++ tests/components/cst816/test.esp32-idf.yaml | 12 ++++ tests/components/ct_clamp/common.yaml | 9 +++ tests/components/ct_clamp/test.esp32-ard.yaml | 13 ++-- .../ct_clamp/test.esp32-c3-ard.yaml | 13 ++-- .../ct_clamp/test.esp32-c3-idf.yaml | 13 ++-- tests/components/ct_clamp/test.esp32-idf.yaml | 13 ++-- .../components/ct_clamp/test.esp8266-ard.yaml | 13 ++-- .../components/ct_clamp/test.rp2040-ard.yaml | 13 ++-- tests/components/current_based/common.yaml | 68 ++++++++++++++++++ .../current_based/test.esp32-ard.yaml | 72 ++----------------- .../current_based/test.esp32-c3-ard.yaml | 72 ++----------------- .../current_based/test.esp32-c3-idf.yaml | 72 ++----------------- .../current_based/test.esp32-idf.yaml | 72 ++----------------- .../current_based/test.esp8266-ard.yaml | 72 ++----------------- .../current_based/test.rp2040-ard.yaml | 72 ++----------------- tests/components/cwww/common.yaml | 16 +++++ tests/components/cwww/test.esp32-ard.yaml | 20 ++---- tests/components/cwww/test.esp32-c3-ard.yaml | 20 ++---- tests/components/cwww/test.esp32-c3-idf.yaml | 25 +++---- tests/components/cwww/test.esp32-idf.yaml | 25 +++---- tests/components/cwww/test.esp8266-ard.yaml | 20 ++---- tests/components/cwww/test.rp2040-ard.yaml | 20 ++---- 99 files changed, 737 insertions(+), 1459 deletions(-) create mode 100644 tests/components/cap1188/common.yaml create mode 100644 tests/components/ccs811/common.yaml create mode 100644 tests/components/cd74hc4067/common.yaml create mode 100644 tests/components/climate_ir_lg/common.yaml create mode 100644 tests/components/color_temperature/common.yaml create mode 100644 tests/components/coolix/common.yaml create mode 100644 tests/components/copy/common.yaml create mode 100644 tests/components/cs5460a/common.yaml create mode 100644 tests/components/cse7761/common.yaml create mode 100644 tests/components/cse7766/common.yaml create mode 100644 tests/components/cst226/test.esp32-ard.yaml create mode 100644 tests/components/cst226/test.esp32-c3-idf.yaml create mode 100644 tests/components/cst226/test.esp32-idf.yaml create mode 100644 tests/components/cst816/test.esp32-c3-ard.yaml create mode 100644 tests/components/cst816/test.esp32-c3-idf.yaml create mode 100644 tests/components/cst816/test.esp32-idf.yaml create mode 100644 tests/components/ct_clamp/common.yaml create mode 100644 tests/components/current_based/common.yaml create mode 100644 tests/components/cwww/common.yaml diff --git a/tests/components/cap1188/common.yaml b/tests/components/cap1188/common.yaml new file mode 100644 index 0000000000..e83bf5d5d2 --- /dev/null +++ b/tests/components/cap1188/common.yaml @@ -0,0 +1,11 @@ +i2c: + - id: i2c_cap1188 + scl: ${scl_pin} + sda: ${sda_pin} + +cap1188: + id: cap1188_component + address: 0x29 + reset_pin: ${reset_pin} + touch_threshold: 0x20 + allow_multiple_touches: true diff --git a/tests/components/cap1188/test.esp32-ard.yaml b/tests/components/cap1188/test.esp32-ard.yaml index efd1d60217..1ca773e06c 100644 --- a/tests/components/cap1188/test.esp32-ard.yaml +++ b/tests/components/cap1188/test.esp32-ard.yaml @@ -1,11 +1,6 @@ -i2c: - - id: i2c_cap1188 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -cap1188: - id: cap1188_component - address: 0x29 - reset_pin: 15 - touch_threshold: 0x20 - allow_multiple_touches: true +<<: !include common.yaml diff --git a/tests/components/cap1188/test.esp32-c3-ard.yaml b/tests/components/cap1188/test.esp32-c3-ard.yaml index c6d3c95942..1e6670c196 100644 --- a/tests/components/cap1188/test.esp32-c3-ard.yaml +++ b/tests/components/cap1188/test.esp32-c3-ard.yaml @@ -1,11 +1,6 @@ -i2c: - - id: i2c_cap1188 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -cap1188: - id: cap1188_component - address: 0x29 - reset_pin: 6 - touch_threshold: 0x20 - allow_multiple_touches: true +<<: !include common.yaml diff --git a/tests/components/cap1188/test.esp32-c3-idf.yaml b/tests/components/cap1188/test.esp32-c3-idf.yaml index c6d3c95942..1e6670c196 100644 --- a/tests/components/cap1188/test.esp32-c3-idf.yaml +++ b/tests/components/cap1188/test.esp32-c3-idf.yaml @@ -1,11 +1,6 @@ -i2c: - - id: i2c_cap1188 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -cap1188: - id: cap1188_component - address: 0x29 - reset_pin: 6 - touch_threshold: 0x20 - allow_multiple_touches: true +<<: !include common.yaml diff --git a/tests/components/cap1188/test.esp32-idf.yaml b/tests/components/cap1188/test.esp32-idf.yaml index efd1d60217..1ca773e06c 100644 --- a/tests/components/cap1188/test.esp32-idf.yaml +++ b/tests/components/cap1188/test.esp32-idf.yaml @@ -1,11 +1,6 @@ -i2c: - - id: i2c_cap1188 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -cap1188: - id: cap1188_component - address: 0x29 - reset_pin: 15 - touch_threshold: 0x20 - allow_multiple_touches: true +<<: !include common.yaml diff --git a/tests/components/cap1188/test.esp8266-ard.yaml b/tests/components/cap1188/test.esp8266-ard.yaml index 7573d45140..dfdc12a3d1 100644 --- a/tests/components/cap1188/test.esp8266-ard.yaml +++ b/tests/components/cap1188/test.esp8266-ard.yaml @@ -1,11 +1,6 @@ -i2c: - - id: i2c_cap1188 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO15 -cap1188: - id: cap1188_component - address: 0x29 - reset_pin: 15 - touch_threshold: 0x20 - allow_multiple_touches: true +<<: !include common.yaml diff --git a/tests/components/cap1188/test.rp2040-ard.yaml b/tests/components/cap1188/test.rp2040-ard.yaml index c6d3c95942..1e6670c196 100644 --- a/tests/components/cap1188/test.rp2040-ard.yaml +++ b/tests/components/cap1188/test.rp2040-ard.yaml @@ -1,11 +1,6 @@ -i2c: - - id: i2c_cap1188 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -cap1188: - id: cap1188_component - address: 0x29 - reset_pin: 6 - touch_threshold: 0x20 - allow_multiple_touches: true +<<: !include common.yaml diff --git a/tests/components/ccs811/common.yaml b/tests/components/ccs811/common.yaml new file mode 100644 index 0000000000..a781996c66 --- /dev/null +++ b/tests/components/ccs811/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_ccs811 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ccs811 + eco2: + name: CCS811 eCO2 + tvoc: + name: CCS811 TVOC + baseline: 0x4242 + update_interval: 30s diff --git a/tests/components/ccs811/test.esp32-ard.yaml b/tests/components/ccs811/test.esp32-ard.yaml index 08b3a48cc7..63c3bd6afd 100644 --- a/tests/components/ccs811/test.esp32-ard.yaml +++ b/tests/components/ccs811/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ccs811 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ccs811 - eco2: - name: CCS811 eCO2 - tvoc: - name: CCS811 TVOC - baseline: 0x4242 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/ccs811/test.esp32-c3-ard.yaml b/tests/components/ccs811/test.esp32-c3-ard.yaml index 26ec7807e4..ee2c29ca4e 100644 --- a/tests/components/ccs811/test.esp32-c3-ard.yaml +++ b/tests/components/ccs811/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ccs811 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ccs811 - eco2: - name: CCS811 eCO2 - tvoc: - name: CCS811 TVOC - baseline: 0x4242 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/ccs811/test.esp32-c3-idf.yaml b/tests/components/ccs811/test.esp32-c3-idf.yaml index 26ec7807e4..ee2c29ca4e 100644 --- a/tests/components/ccs811/test.esp32-c3-idf.yaml +++ b/tests/components/ccs811/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ccs811 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ccs811 - eco2: - name: CCS811 eCO2 - tvoc: - name: CCS811 TVOC - baseline: 0x4242 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/ccs811/test.esp32-idf.yaml b/tests/components/ccs811/test.esp32-idf.yaml index 08b3a48cc7..63c3bd6afd 100644 --- a/tests/components/ccs811/test.esp32-idf.yaml +++ b/tests/components/ccs811/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ccs811 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ccs811 - eco2: - name: CCS811 eCO2 - tvoc: - name: CCS811 TVOC - baseline: 0x4242 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/ccs811/test.esp8266-ard.yaml b/tests/components/ccs811/test.esp8266-ard.yaml index 26ec7807e4..ee2c29ca4e 100644 --- a/tests/components/ccs811/test.esp8266-ard.yaml +++ b/tests/components/ccs811/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ccs811 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ccs811 - eco2: - name: CCS811 eCO2 - tvoc: - name: CCS811 TVOC - baseline: 0x4242 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/ccs811/test.rp2040-ard.yaml b/tests/components/ccs811/test.rp2040-ard.yaml index 26ec7807e4..ee2c29ca4e 100644 --- a/tests/components/ccs811/test.rp2040-ard.yaml +++ b/tests/components/ccs811/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ccs811 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ccs811 - eco2: - name: CCS811 eCO2 - tvoc: - name: CCS811 TVOC - baseline: 0x4242 - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/cd74hc4067/common.yaml b/tests/components/cd74hc4067/common.yaml new file mode 100644 index 0000000000..9afb39cd31 --- /dev/null +++ b/tests/components/cd74hc4067/common.yaml @@ -0,0 +1,18 @@ +cd74hc4067: + pin_s0: ${pin_s0} + pin_s1: ${pin_s1} + pin_s2: ${pin_s2} + pin_s3: ${pin_s3} + +sensor: + - platform: adc + id: esp_adc_sensor + pin: ${pin} + - platform: cd74hc4067 + id: cd74hc4067_adc_0 + number: 0 + sensor: esp_adc_sensor + - platform: cd74hc4067 + id: cd74hc4067_adc_1 + number: 1 + sensor: esp_adc_sensor diff --git a/tests/components/cd74hc4067/test.esp32-ard.yaml b/tests/components/cd74hc4067/test.esp32-ard.yaml index 71a1238ccc..c4dd280943 100644 --- a/tests/components/cd74hc4067/test.esp32-ard.yaml +++ b/tests/components/cd74hc4067/test.esp32-ard.yaml @@ -1,18 +1,8 @@ -cd74hc4067: - pin_s0: 12 - pin_s1: 13 - pin_s2: 14 - pin_s3: 15 +substitutions: + pin_s0: GPIO12 + pin_s1: GPIO13 + pin_s2: GPIO14 + pin_s3: GPIO15 + pin: GPIO39 -sensor: - - platform: adc - id: esp_adc_sensor - pin: 39 - - platform: cd74hc4067 - id: cd74hc4067_adc_0 - number: 0 - sensor: esp_adc_sensor - - platform: cd74hc4067 - id: cd74hc4067_adc_1 - number: 1 - sensor: esp_adc_sensor +<<: !include common.yaml diff --git a/tests/components/cd74hc4067/test.esp32-c3-ard.yaml b/tests/components/cd74hc4067/test.esp32-c3-ard.yaml index 5aa653d26c..5e8784c1fc 100644 --- a/tests/components/cd74hc4067/test.esp32-c3-ard.yaml +++ b/tests/components/cd74hc4067/test.esp32-c3-ard.yaml @@ -1,18 +1,8 @@ -cd74hc4067: - pin_s0: 2 - pin_s1: 3 - pin_s2: 4 - pin_s3: 5 +substitutions: + pin_s0: GPIO2 + pin_s1: GPIO3 + pin_s2: GPIO4 + pin_s3: GPIO5 + pin: GPIO0 -sensor: - - platform: adc - id: esp_adc_sensor - pin: 0 - - platform: cd74hc4067 - id: cd74hc4067_adc_0 - number: 0 - sensor: esp_adc_sensor - - platform: cd74hc4067 - id: cd74hc4067_adc_1 - number: 1 - sensor: esp_adc_sensor +<<: !include common.yaml diff --git a/tests/components/cd74hc4067/test.esp32-c3-idf.yaml b/tests/components/cd74hc4067/test.esp32-c3-idf.yaml index 5aa653d26c..5e8784c1fc 100644 --- a/tests/components/cd74hc4067/test.esp32-c3-idf.yaml +++ b/tests/components/cd74hc4067/test.esp32-c3-idf.yaml @@ -1,18 +1,8 @@ -cd74hc4067: - pin_s0: 2 - pin_s1: 3 - pin_s2: 4 - pin_s3: 5 +substitutions: + pin_s0: GPIO2 + pin_s1: GPIO3 + pin_s2: GPIO4 + pin_s3: GPIO5 + pin: GPIO0 -sensor: - - platform: adc - id: esp_adc_sensor - pin: 0 - - platform: cd74hc4067 - id: cd74hc4067_adc_0 - number: 0 - sensor: esp_adc_sensor - - platform: cd74hc4067 - id: cd74hc4067_adc_1 - number: 1 - sensor: esp_adc_sensor +<<: !include common.yaml diff --git a/tests/components/cd74hc4067/test.esp32-idf.yaml b/tests/components/cd74hc4067/test.esp32-idf.yaml index 71a1238ccc..c4dd280943 100644 --- a/tests/components/cd74hc4067/test.esp32-idf.yaml +++ b/tests/components/cd74hc4067/test.esp32-idf.yaml @@ -1,18 +1,8 @@ -cd74hc4067: - pin_s0: 12 - pin_s1: 13 - pin_s2: 14 - pin_s3: 15 +substitutions: + pin_s0: GPIO12 + pin_s1: GPIO13 + pin_s2: GPIO14 + pin_s3: GPIO15 + pin: GPIO39 -sensor: - - platform: adc - id: esp_adc_sensor - pin: 39 - - platform: cd74hc4067 - id: cd74hc4067_adc_0 - number: 0 - sensor: esp_adc_sensor - - platform: cd74hc4067 - id: cd74hc4067_adc_1 - number: 1 - sensor: esp_adc_sensor +<<: !include common.yaml diff --git a/tests/components/cd74hc4067/test.esp8266-ard.yaml b/tests/components/cd74hc4067/test.esp8266-ard.yaml index 8bcce5bc17..1162cec1f8 100644 --- a/tests/components/cd74hc4067/test.esp8266-ard.yaml +++ b/tests/components/cd74hc4067/test.esp8266-ard.yaml @@ -1,18 +1,8 @@ -cd74hc4067: - pin_s0: 12 - pin_s1: 13 - pin_s2: 14 - pin_s3: 15 +substitutions: + pin_s0: GPIO12 + pin_s1: GPIO13 + pin_s2: GPIO14 + pin_s3: GPIO15 + pin: A0 -sensor: - - platform: adc - id: esp_adc_sensor - pin: A0 - - platform: cd74hc4067 - id: cd74hc4067_adc_0 - number: 0 - sensor: esp_adc_sensor - - platform: cd74hc4067 - id: cd74hc4067_adc_1 - number: 1 - sensor: esp_adc_sensor +<<: !include common.yaml diff --git a/tests/components/cd74hc4067/test.rp2040-ard.yaml b/tests/components/cd74hc4067/test.rp2040-ard.yaml index 75adcce796..88c3273a44 100644 --- a/tests/components/cd74hc4067/test.rp2040-ard.yaml +++ b/tests/components/cd74hc4067/test.rp2040-ard.yaml @@ -1,18 +1,8 @@ -cd74hc4067: - pin_s0: 2 - pin_s1: 3 - pin_s2: 4 - pin_s3: 5 +substitutions: + pin_s0: GPIO2 + pin_s1: GPIO3 + pin_s2: GPIO4 + pin_s3: GPIO5 + pin: GPIO26 -sensor: - - platform: adc - id: esp_adc_sensor - pin: 26 - - platform: cd74hc4067 - id: cd74hc4067_adc_0 - number: 0 - sensor: esp_adc_sensor - - platform: cd74hc4067 - id: cd74hc4067_adc_1 - number: 1 - sensor: esp_adc_sensor +<<: !include common.yaml diff --git a/tests/components/climate_ir_lg/common.yaml b/tests/components/climate_ir_lg/common.yaml new file mode 100644 index 0000000000..c8f84411c0 --- /dev/null +++ b/tests/components/climate_ir_lg/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: climate_ir_lg + name: LG Climate diff --git a/tests/components/climate_ir_lg/test.esp32-ard.yaml b/tests/components/climate_ir_lg/test.esp32-ard.yaml index e714bf0686..7b012aa64c 100644 --- a/tests/components/climate_ir_lg/test.esp32-ard.yaml +++ b/tests/components/climate_ir_lg/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: climate_ir_lg - name: LG Climate +<<: !include common.yaml diff --git a/tests/components/climate_ir_lg/test.esp32-c3-ard.yaml b/tests/components/climate_ir_lg/test.esp32-c3-ard.yaml index e714bf0686..7b012aa64c 100644 --- a/tests/components/climate_ir_lg/test.esp32-c3-ard.yaml +++ b/tests/components/climate_ir_lg/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: climate_ir_lg - name: LG Climate +<<: !include common.yaml diff --git a/tests/components/climate_ir_lg/test.esp32-c3-idf.yaml b/tests/components/climate_ir_lg/test.esp32-c3-idf.yaml index e714bf0686..7b012aa64c 100644 --- a/tests/components/climate_ir_lg/test.esp32-c3-idf.yaml +++ b/tests/components/climate_ir_lg/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: climate_ir_lg - name: LG Climate +<<: !include common.yaml diff --git a/tests/components/climate_ir_lg/test.esp32-idf.yaml b/tests/components/climate_ir_lg/test.esp32-idf.yaml index e714bf0686..7b012aa64c 100644 --- a/tests/components/climate_ir_lg/test.esp32-idf.yaml +++ b/tests/components/climate_ir_lg/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: climate_ir_lg - name: LG Climate +<<: !include common.yaml diff --git a/tests/components/climate_ir_lg/test.esp8266-ard.yaml b/tests/components/climate_ir_lg/test.esp8266-ard.yaml index 7482bf0580..f5097fcf5f 100644 --- a/tests/components/climate_ir_lg/test.esp8266-ard.yaml +++ b/tests/components/climate_ir_lg/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: climate_ir_lg - name: LG Climate +<<: !include common.yaml diff --git a/tests/components/color_temperature/common.yaml b/tests/components/color_temperature/common.yaml new file mode 100644 index 0000000000..fe0c5bf917 --- /dev/null +++ b/tests/components/color_temperature/common.yaml @@ -0,0 +1,15 @@ +output: + - platform: ${light_platform} + id: light_output_1 + pin: ${pin_o1} + - platform: ${light_platform} + id: light_output_2 + pin: ${pin_o2} + +light: + - platform: color_temperature + name: Lights + color_temperature: light_output_1 + brightness: light_output_2 + cold_white_color_temperature: 153 mireds + warm_white_color_temperature: 500 mireds diff --git a/tests/components/color_temperature/test.esp32-ard.yaml b/tests/components/color_temperature/test.esp32-ard.yaml index 608907d2fc..1831adda6e 100644 --- a/tests/components/color_temperature/test.esp32-ard.yaml +++ b/tests/components/color_temperature/test.esp32-ard.yaml @@ -1,15 +1,6 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 +substitutions: + light_platform: ledc + pin_o1: GPIO16 + pin_o2: GPIO17 -light: - - platform: color_temperature - name: Lights - color_temperature: light_output_1 - brightness: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds +<<: !include common.yaml diff --git a/tests/components/color_temperature/test.esp32-c3-ard.yaml b/tests/components/color_temperature/test.esp32-c3-ard.yaml index 8d3faa54ee..016f315d9f 100644 --- a/tests/components/color_temperature/test.esp32-c3-ard.yaml +++ b/tests/components/color_temperature/test.esp32-c3-ard.yaml @@ -1,15 +1,6 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 +substitutions: + light_platform: ledc + pin_o1: GPIO6 + pin_o2: GPIO7 -light: - - platform: color_temperature - name: Lights - color_temperature: light_output_1 - brightness: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds +<<: !include common.yaml diff --git a/tests/components/color_temperature/test.esp32-c3-idf.yaml b/tests/components/color_temperature/test.esp32-c3-idf.yaml index 8d3faa54ee..016f315d9f 100644 --- a/tests/components/color_temperature/test.esp32-c3-idf.yaml +++ b/tests/components/color_temperature/test.esp32-c3-idf.yaml @@ -1,15 +1,6 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 +substitutions: + light_platform: ledc + pin_o1: GPIO6 + pin_o2: GPIO7 -light: - - platform: color_temperature - name: Lights - color_temperature: light_output_1 - brightness: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds +<<: !include common.yaml diff --git a/tests/components/color_temperature/test.esp32-idf.yaml b/tests/components/color_temperature/test.esp32-idf.yaml index 608907d2fc..1831adda6e 100644 --- a/tests/components/color_temperature/test.esp32-idf.yaml +++ b/tests/components/color_temperature/test.esp32-idf.yaml @@ -1,15 +1,6 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 +substitutions: + light_platform: ledc + pin_o1: GPIO16 + pin_o2: GPIO17 -light: - - platform: color_temperature - name: Lights - color_temperature: light_output_1 - brightness: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds +<<: !include common.yaml diff --git a/tests/components/color_temperature/test.esp8266-ard.yaml b/tests/components/color_temperature/test.esp8266-ard.yaml index ed0bfb6aa4..75a5b9d64d 100644 --- a/tests/components/color_temperature/test.esp8266-ard.yaml +++ b/tests/components/color_temperature/test.esp8266-ard.yaml @@ -1,15 +1,6 @@ -output: - - platform: esp8266_pwm - id: light_output_1 - pin: 12 - - platform: esp8266_pwm - id: light_output_2 - pin: 13 +substitutions: + light_platform: esp8266_pwm + pin_o1: GPIO12 + pin_o2: GPIO13 -light: - - platform: color_temperature - name: Lights - color_temperature: light_output_1 - brightness: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds +<<: !include common.yaml diff --git a/tests/components/color_temperature/test.rp2040-ard.yaml b/tests/components/color_temperature/test.rp2040-ard.yaml index 887ad1c857..537177aca1 100644 --- a/tests/components/color_temperature/test.rp2040-ard.yaml +++ b/tests/components/color_temperature/test.rp2040-ard.yaml @@ -1,15 +1,6 @@ -output: - - platform: rp2040_pwm - id: light_output_1 - pin: 12 - - platform: rp2040_pwm - id: light_output_2 - pin: 13 +substitutions: + light_platform: rp2040_pwm + pin_o1: GPIO12 + pin_o2: GPIO13 -light: - - platform: color_temperature - name: Lights - color_temperature: light_output_1 - brightness: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds +<<: !include common.yaml diff --git a/tests/components/coolix/common.yaml b/tests/components/coolix/common.yaml new file mode 100644 index 0000000000..abe609c3ea --- /dev/null +++ b/tests/components/coolix/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: coolix + name: Coolix Climate diff --git a/tests/components/coolix/test.esp32-ard.yaml b/tests/components/coolix/test.esp32-ard.yaml index 0f9518d2cf..7b012aa64c 100644 --- a/tests/components/coolix/test.esp32-ard.yaml +++ b/tests/components/coolix/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: coolix - name: Coolix Climate +<<: !include common.yaml diff --git a/tests/components/coolix/test.esp32-c3-ard.yaml b/tests/components/coolix/test.esp32-c3-ard.yaml index 0f9518d2cf..7b012aa64c 100644 --- a/tests/components/coolix/test.esp32-c3-ard.yaml +++ b/tests/components/coolix/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: coolix - name: Coolix Climate +<<: !include common.yaml diff --git a/tests/components/coolix/test.esp32-c3-idf.yaml b/tests/components/coolix/test.esp32-c3-idf.yaml index 0f9518d2cf..7b012aa64c 100644 --- a/tests/components/coolix/test.esp32-c3-idf.yaml +++ b/tests/components/coolix/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: coolix - name: Coolix Climate +<<: !include common.yaml diff --git a/tests/components/coolix/test.esp32-idf.yaml b/tests/components/coolix/test.esp32-idf.yaml index 0f9518d2cf..7b012aa64c 100644 --- a/tests/components/coolix/test.esp32-idf.yaml +++ b/tests/components/coolix/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: coolix - name: Coolix Climate +<<: !include common.yaml diff --git a/tests/components/coolix/test.esp8266-ard.yaml b/tests/components/coolix/test.esp8266-ard.yaml index 61de8c7558..f5097fcf5f 100644 --- a/tests/components/coolix/test.esp8266-ard.yaml +++ b/tests/components/coolix/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: coolix - name: Coolix Climate +<<: !include common.yaml diff --git a/tests/components/copy/common.yaml b/tests/components/copy/common.yaml new file mode 100644 index 0000000000..a73b3467e6 --- /dev/null +++ b/tests/components/copy/common.yaml @@ -0,0 +1,23 @@ +output: + - platform: ${pwm_platform} + id: fan_output_1 + pin: ${pin} + +fan: + - platform: speed + id: fan_speed + output: fan_output_1 + - platform: copy + source_id: fan_speed + name: Fan Speed Copy + +select: + - platform: template + id: test_select + options: + - one + - two + optimistic: true + - platform: copy + source_id: test_select + name: Test Select Copy diff --git a/tests/components/copy/test.esp32-ard.yaml b/tests/components/copy/test.esp32-ard.yaml index 806dbfe9f3..e5337726dc 100644 --- a/tests/components/copy/test.esp32-ard.yaml +++ b/tests/components/copy/test.esp32-ard.yaml @@ -1,23 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 12 +substitutions: + pwm_platform: ledc + pin: GPIO12 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 - - platform: copy - source_id: fan_speed - name: Fan Speed Copy - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - - platform: copy - source_id: test_select - name: Test Select Copy +<<: !include common.yaml diff --git a/tests/components/copy/test.esp32-c3-ard.yaml b/tests/components/copy/test.esp32-c3-ard.yaml index 554638f462..76272beb77 100644 --- a/tests/components/copy/test.esp32-c3-ard.yaml +++ b/tests/components/copy/test.esp32-c3-ard.yaml @@ -1,23 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 2 +substitutions: + pwm_platform: ledc + pin: GPIO2 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 - - platform: copy - source_id: fan_speed - name: Fan Speed Copy - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - - platform: copy - source_id: test_select - name: Test Select Copy +<<: !include common.yaml diff --git a/tests/components/copy/test.esp32-c3-idf.yaml b/tests/components/copy/test.esp32-c3-idf.yaml index 554638f462..76272beb77 100644 --- a/tests/components/copy/test.esp32-c3-idf.yaml +++ b/tests/components/copy/test.esp32-c3-idf.yaml @@ -1,23 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 2 +substitutions: + pwm_platform: ledc + pin: GPIO2 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 - - platform: copy - source_id: fan_speed - name: Fan Speed Copy - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - - platform: copy - source_id: test_select - name: Test Select Copy +<<: !include common.yaml diff --git a/tests/components/copy/test.esp32-idf.yaml b/tests/components/copy/test.esp32-idf.yaml index 806dbfe9f3..e5337726dc 100644 --- a/tests/components/copy/test.esp32-idf.yaml +++ b/tests/components/copy/test.esp32-idf.yaml @@ -1,23 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 12 +substitutions: + pwm_platform: ledc + pin: GPIO12 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 - - platform: copy - source_id: fan_speed - name: Fan Speed Copy - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - - platform: copy - source_id: test_select - name: Test Select Copy +<<: !include common.yaml diff --git a/tests/components/copy/test.esp8266-ard.yaml b/tests/components/copy/test.esp8266-ard.yaml index 1521e5f279..497fac5161 100644 --- a/tests/components/copy/test.esp8266-ard.yaml +++ b/tests/components/copy/test.esp8266-ard.yaml @@ -1,23 +1,5 @@ -output: - - platform: esp8266_pwm - id: fan_output_1 - pin: 12 +substitutions: + pwm_platform: esp8266_pwm + pin: GPIO12 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 - - platform: copy - source_id: fan_speed - name: Fan Speed Copy - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - - platform: copy - source_id: test_select - name: Test Select Copy +<<: !include common.yaml diff --git a/tests/components/copy/test.rp2040-ard.yaml b/tests/components/copy/test.rp2040-ard.yaml index 42e5eb8000..61e461d247 100644 --- a/tests/components/copy/test.rp2040-ard.yaml +++ b/tests/components/copy/test.rp2040-ard.yaml @@ -1,23 +1,5 @@ -output: - - platform: rp2040_pwm - id: fan_output_1 - pin: 12 +substitutions: + pwm_platform: rp2040_pwm + pin: GPIO12 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 - - platform: copy - source_id: fan_speed - name: Fan Speed Copy - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - - platform: copy - source_id: test_select - name: Test Select Copy +<<: !include common.yaml diff --git a/tests/components/cs5460a/common.yaml b/tests/components/cs5460a/common.yaml new file mode 100644 index 0000000000..d97b01716b --- /dev/null +++ b/tests/components/cs5460a/common.yaml @@ -0,0 +1,27 @@ +spi: + - id: spi_cs5460a + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sensor: + - platform: cs5460a + id: cs5460a1 + cs_pin: ${cs_pin} + current: + name: Socket current + voltage: + name: Mains voltage + power: + name: Socket power + on_value: + then: + cs5460a.restart: cs5460a1 + samples: 1600 + pga_gain: 10X + current_gain: 0.01 + voltage_gain: 0.000573 + current_hpf: true + voltage_hpf: true + phase_offset: 20 + pulse_energy: 0.01 kWh diff --git a/tests/components/cs5460a/test.esp32-ard.yaml b/tests/components/cs5460a/test.esp32-ard.yaml index e7eb1cbd73..54e027a614 100644 --- a/tests/components/cs5460a/test.esp32-ard.yaml +++ b/tests/components/cs5460a/test.esp32-ard.yaml @@ -1,27 +1,7 @@ -spi: - - id: spi_cs5460a - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: cs5460a - id: cs5460a1 - cs_pin: 12 - current: - name: Socket current - voltage: - name: Mains voltage - power: - name: Socket power - on_value: - then: - cs5460a.restart: cs5460a1 - samples: 1600 - pga_gain: 10X - current_gain: 0.01 - voltage_gain: 0.000573 - current_hpf: true - voltage_hpf: true - phase_offset: 20 - pulse_energy: 0.01 kWh +<<: !include common.yaml diff --git a/tests/components/cs5460a/test.esp32-c3-ard.yaml b/tests/components/cs5460a/test.esp32-c3-ard.yaml index 4ce21783a3..2415ba5dc6 100644 --- a/tests/components/cs5460a/test.esp32-c3-ard.yaml +++ b/tests/components/cs5460a/test.esp32-c3-ard.yaml @@ -1,27 +1,7 @@ -spi: - - id: spi_cs5460a - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: cs5460a - id: cs5460a1 - cs_pin: 8 - current: - name: Socket current - voltage: - name: Mains voltage - power: - name: Socket power - on_value: - then: - cs5460a.restart: cs5460a1 - samples: 1600 - pga_gain: 10X - current_gain: 0.01 - voltage_gain: 0.000573 - current_hpf: true - voltage_hpf: true - phase_offset: 20 - pulse_energy: 0.01 kWh +<<: !include common.yaml diff --git a/tests/components/cs5460a/test.esp32-c3-idf.yaml b/tests/components/cs5460a/test.esp32-c3-idf.yaml index 4ce21783a3..2415ba5dc6 100644 --- a/tests/components/cs5460a/test.esp32-c3-idf.yaml +++ b/tests/components/cs5460a/test.esp32-c3-idf.yaml @@ -1,27 +1,7 @@ -spi: - - id: spi_cs5460a - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: cs5460a - id: cs5460a1 - cs_pin: 8 - current: - name: Socket current - voltage: - name: Mains voltage - power: - name: Socket power - on_value: - then: - cs5460a.restart: cs5460a1 - samples: 1600 - pga_gain: 10X - current_gain: 0.01 - voltage_gain: 0.000573 - current_hpf: true - voltage_hpf: true - phase_offset: 20 - pulse_energy: 0.01 kWh +<<: !include common.yaml diff --git a/tests/components/cs5460a/test.esp32-idf.yaml b/tests/components/cs5460a/test.esp32-idf.yaml index e7eb1cbd73..54e027a614 100644 --- a/tests/components/cs5460a/test.esp32-idf.yaml +++ b/tests/components/cs5460a/test.esp32-idf.yaml @@ -1,27 +1,7 @@ -spi: - - id: spi_cs5460a - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: cs5460a - id: cs5460a1 - cs_pin: 12 - current: - name: Socket current - voltage: - name: Mains voltage - power: - name: Socket power - on_value: - then: - cs5460a.restart: cs5460a1 - samples: 1600 - pga_gain: 10X - current_gain: 0.01 - voltage_gain: 0.000573 - current_hpf: true - voltage_hpf: true - phase_offset: 20 - pulse_energy: 0.01 kWh +<<: !include common.yaml diff --git a/tests/components/cs5460a/test.esp8266-ard.yaml b/tests/components/cs5460a/test.esp8266-ard.yaml index c5a458d0ec..dbd158d030 100644 --- a/tests/components/cs5460a/test.esp8266-ard.yaml +++ b/tests/components/cs5460a/test.esp8266-ard.yaml @@ -1,27 +1,7 @@ -spi: - - id: spi_cs5460a - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -sensor: - - platform: cs5460a - id: cs5460a1 - cs_pin: 15 - current: - name: Socket current - voltage: - name: Mains voltage - power: - name: Socket power - on_value: - then: - cs5460a.restart: cs5460a1 - samples: 1600 - pga_gain: 10X - current_gain: 0.01 - voltage_gain: 0.000573 - current_hpf: true - voltage_hpf: true - phase_offset: 20 - pulse_energy: 0.01 kWh +<<: !include common.yaml diff --git a/tests/components/cs5460a/test.rp2040-ard.yaml b/tests/components/cs5460a/test.rp2040-ard.yaml index f3daf7d72d..f6c3f1eeca 100644 --- a/tests/components/cs5460a/test.rp2040-ard.yaml +++ b/tests/components/cs5460a/test.rp2040-ard.yaml @@ -1,27 +1,7 @@ -spi: - - id: spi_cs5460a - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -sensor: - - platform: cs5460a - id: cs5460a1 - cs_pin: 6 - current: - name: Socket current - voltage: - name: Mains voltage - power: - name: Socket power - on_value: - then: - cs5460a.restart: cs5460a1 - samples: 1600 - pga_gain: 10X - current_gain: 0.01 - voltage_gain: 0.000573 - current_hpf: true - voltage_hpf: true - phase_offset: 20 - pulse_energy: 0.01 kWh +<<: !include common.yaml diff --git a/tests/components/cse7761/common.yaml b/tests/components/cse7761/common.yaml new file mode 100644 index 0000000000..60cce3864a --- /dev/null +++ b/tests/components/cse7761/common.yaml @@ -0,0 +1,18 @@ +uart: + - id: uart_cse7761 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 38400 + +sensor: + - platform: cse7761 + voltage: + name: CSE7761 Voltage + current_1: + name: CSE7761 Current 1 + current_2: + name: CSE7761 Current 2 + active_power_1: + name: CSE7761 Active Power 1 + active_power_2: + name: CSE7761 Active Power 2 diff --git a/tests/components/cse7761/test.esp32-ard.yaml b/tests/components/cse7761/test.esp32-ard.yaml index 4174e9a92e..811f6b72a6 100644 --- a/tests/components/cse7761/test.esp32-ard.yaml +++ b/tests/components/cse7761/test.esp32-ard.yaml @@ -1,20 +1,5 @@ -uart: - - id: uart_cse7761 - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 38400 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: cse7761 - voltage: - name: CSE7761 Voltage - current_1: - name: CSE7761 Current 1 - current_2: - name: CSE7761 Current 2 - active_power_1: - name: CSE7761 Active Power 1 - active_power_2: - name: CSE7761 Active Power 2 +<<: !include common.yaml diff --git a/tests/components/cse7761/test.esp32-c3-ard.yaml b/tests/components/cse7761/test.esp32-c3-ard.yaml index 581db24fd5..c79d14c740 100644 --- a/tests/components/cse7761/test.esp32-c3-ard.yaml +++ b/tests/components/cse7761/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -uart: - - id: uart_cse7761 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 38400 +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -sensor: - - platform: cse7761 - voltage: - name: CSE7761 Voltage - current_1: - name: CSE7761 Current 1 - current_2: - name: CSE7761 Current 2 - active_power_1: - name: CSE7761 Active Power 1 - active_power_2: - name: CSE7761 Active Power 2 +<<: !include common.yaml diff --git a/tests/components/cse7761/test.esp32-c3-idf.yaml b/tests/components/cse7761/test.esp32-c3-idf.yaml index 581db24fd5..c79d14c740 100644 --- a/tests/components/cse7761/test.esp32-c3-idf.yaml +++ b/tests/components/cse7761/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -uart: - - id: uart_cse7761 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 38400 +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -sensor: - - platform: cse7761 - voltage: - name: CSE7761 Voltage - current_1: - name: CSE7761 Current 1 - current_2: - name: CSE7761 Current 2 - active_power_1: - name: CSE7761 Active Power 1 - active_power_2: - name: CSE7761 Active Power 2 +<<: !include common.yaml diff --git a/tests/components/cse7761/test.esp32-idf.yaml b/tests/components/cse7761/test.esp32-idf.yaml index 4174e9a92e..811f6b72a6 100644 --- a/tests/components/cse7761/test.esp32-idf.yaml +++ b/tests/components/cse7761/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -uart: - - id: uart_cse7761 - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 38400 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: cse7761 - voltage: - name: CSE7761 Voltage - current_1: - name: CSE7761 Current 1 - current_2: - name: CSE7761 Current 2 - active_power_1: - name: CSE7761 Active Power 1 - active_power_2: - name: CSE7761 Active Power 2 +<<: !include common.yaml diff --git a/tests/components/cse7761/test.esp8266-ard.yaml b/tests/components/cse7761/test.esp8266-ard.yaml index 581db24fd5..3b44f9c9c3 100644 --- a/tests/components/cse7761/test.esp8266-ard.yaml +++ b/tests/components/cse7761/test.esp8266-ard.yaml @@ -1,20 +1,5 @@ -uart: - - id: uart_cse7761 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 38400 +substitutions: + tx_pin: GPIO1 + rx_pin: GPIO3 -sensor: - - platform: cse7761 - voltage: - name: CSE7761 Voltage - current_1: - name: CSE7761 Current 1 - current_2: - name: CSE7761 Current 2 - active_power_1: - name: CSE7761 Active Power 1 - active_power_2: - name: CSE7761 Active Power 2 +<<: !include common.yaml diff --git a/tests/components/cse7761/test.rp2040-ard.yaml b/tests/components/cse7761/test.rp2040-ard.yaml index 581db24fd5..b516342f3b 100644 --- a/tests/components/cse7761/test.rp2040-ard.yaml +++ b/tests/components/cse7761/test.rp2040-ard.yaml @@ -1,20 +1,5 @@ -uart: - - id: uart_cse7761 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 38400 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: cse7761 - voltage: - name: CSE7761 Voltage - current_1: - name: CSE7761 Current 1 - current_2: - name: CSE7761 Current 2 - active_power_1: - name: CSE7761 Active Power 1 - active_power_2: - name: CSE7761 Active Power 2 +<<: !include common.yaml diff --git a/tests/components/cse7766/common.yaml b/tests/components/cse7766/common.yaml new file mode 100644 index 0000000000..f12b135a77 --- /dev/null +++ b/tests/components/cse7766/common.yaml @@ -0,0 +1,15 @@ +uart: + - id: uart_cse7766 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 4800 + parity: EVEN + +sensor: + - platform: cse7766 + voltage: + name: CSE7766 Voltage + current: + name: CSE7766 Current + power: + name: CSE776 Power diff --git a/tests/components/cse7766/test.esp32-ard.yaml b/tests/components/cse7766/test.esp32-ard.yaml index 5542b52824..811f6b72a6 100644 --- a/tests/components/cse7766/test.esp32-ard.yaml +++ b/tests/components/cse7766/test.esp32-ard.yaml @@ -1,17 +1,5 @@ -uart: - - id: uart_cse7766 - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 4800 - parity: EVEN +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: cse7766 - voltage: - name: CSE7766 Voltage - current: - name: CSE7766 Current - power: - name: CSE776 Power +<<: !include common.yaml diff --git a/tests/components/cse7766/test.esp32-c3-ard.yaml b/tests/components/cse7766/test.esp32-c3-ard.yaml index d27c9d4463..c79d14c740 100644 --- a/tests/components/cse7766/test.esp32-c3-ard.yaml +++ b/tests/components/cse7766/test.esp32-c3-ard.yaml @@ -1,17 +1,5 @@ -uart: - - id: uart_cse7766 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 4800 - parity: EVEN +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -sensor: - - platform: cse7766 - voltage: - name: CSE7766 Voltage - current: - name: CSE7766 Current - power: - name: CSE776 Power +<<: !include common.yaml diff --git a/tests/components/cse7766/test.esp32-c3-idf.yaml b/tests/components/cse7766/test.esp32-c3-idf.yaml index d27c9d4463..c79d14c740 100644 --- a/tests/components/cse7766/test.esp32-c3-idf.yaml +++ b/tests/components/cse7766/test.esp32-c3-idf.yaml @@ -1,17 +1,5 @@ -uart: - - id: uart_cse7766 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 4800 - parity: EVEN +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -sensor: - - platform: cse7766 - voltage: - name: CSE7766 Voltage - current: - name: CSE7766 Current - power: - name: CSE776 Power +<<: !include common.yaml diff --git a/tests/components/cse7766/test.esp32-idf.yaml b/tests/components/cse7766/test.esp32-idf.yaml index 5542b52824..811f6b72a6 100644 --- a/tests/components/cse7766/test.esp32-idf.yaml +++ b/tests/components/cse7766/test.esp32-idf.yaml @@ -1,17 +1,5 @@ -uart: - - id: uart_cse7766 - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 4800 - parity: EVEN +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: cse7766 - voltage: - name: CSE7766 Voltage - current: - name: CSE7766 Current - power: - name: CSE776 Power +<<: !include common.yaml diff --git a/tests/components/cse7766/test.esp8266-ard.yaml b/tests/components/cse7766/test.esp8266-ard.yaml index d27c9d4463..3b44f9c9c3 100644 --- a/tests/components/cse7766/test.esp8266-ard.yaml +++ b/tests/components/cse7766/test.esp8266-ard.yaml @@ -1,17 +1,5 @@ -uart: - - id: uart_cse7766 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 4800 - parity: EVEN +substitutions: + tx_pin: GPIO1 + rx_pin: GPIO3 -sensor: - - platform: cse7766 - voltage: - name: CSE7766 Voltage - current: - name: CSE7766 Current - power: - name: CSE776 Power +<<: !include common.yaml diff --git a/tests/components/cse7766/test.rp2040-ard.yaml b/tests/components/cse7766/test.rp2040-ard.yaml index d27c9d4463..b516342f3b 100644 --- a/tests/components/cse7766/test.rp2040-ard.yaml +++ b/tests/components/cse7766/test.rp2040-ard.yaml @@ -1,17 +1,5 @@ -uart: - - id: uart_cse7766 - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 4800 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: cse7766 - voltage: - name: CSE7766 Voltage - current: - name: CSE7766 Current - power: - name: CSE776 Power +<<: !include common.yaml diff --git a/tests/components/cst226/common.yaml b/tests/components/cst226/common.yaml index 7e1c5dde36..c12d8d872c 100644 --- a/tests/components/cst226/common.yaml +++ b/tests/components/cst226/common.yaml @@ -1,25 +1,25 @@ +i2c: + - id: i2c_cst226 + scl: ${scl_pin} + sda: ${sda_pin} + spi: - - id: spi_id_1 - clk_pin: GPIO7 - mosi_pin: GPIO6 - interface: any + - id: spi_ili9xxx + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} display: - - platform: ili9xxx - id: displ8 + - id: my_display + platform: ili9xxx model: ili9342 - cs_pin: GPIO5 - dc_pin: GPIO4 - reset_pin: - number: GPIO21 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${disp_reset_pin} invert_colors: false -i2c: - scl: GPIO18 - sda: GPIO8 - touchscreen: - - platform: cst226 - interrupt_pin: GPIO3 - reset_pin: GPIO20 + - id: ts_cst226 + platform: cst226 + interrupt_pin: ${interrupt_pin} + reset_pin: ${reset_pin} diff --git a/tests/components/cst226/test.esp32-ard.yaml b/tests/components/cst226/test.esp32-ard.yaml new file mode 100644 index 0000000000..11e2c4fd43 --- /dev/null +++ b/tests/components/cst226/test.esp32-ard.yaml @@ -0,0 +1,12 @@ +substitutions: + clk_pin: GPIO0 + mosi_pin: GPIO2 + cs_pin: GPIO4 + dc_pin: GPIO5 + disp_reset_pin: GPIO12 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 + +<<: !include common.yaml diff --git a/tests/components/cst226/test.esp32-c3-ard.yaml b/tests/components/cst226/test.esp32-c3-ard.yaml index dade44d145..2f9bd72882 100644 --- a/tests/components/cst226/test.esp32-c3-ard.yaml +++ b/tests/components/cst226/test.esp32-c3-ard.yaml @@ -1 +1,12 @@ +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + cs_pin: GPIO8 + dc_pin: GPIO9 + disp_reset_pin: GPIO10 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 + <<: !include common.yaml diff --git a/tests/components/cst226/test.esp32-c3-idf.yaml b/tests/components/cst226/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..2f9bd72882 --- /dev/null +++ b/tests/components/cst226/test.esp32-c3-idf.yaml @@ -0,0 +1,12 @@ +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + cs_pin: GPIO8 + dc_pin: GPIO9 + disp_reset_pin: GPIO10 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/cst226/test.esp32-idf.yaml b/tests/components/cst226/test.esp32-idf.yaml new file mode 100644 index 0000000000..11e2c4fd43 --- /dev/null +++ b/tests/components/cst226/test.esp32-idf.yaml @@ -0,0 +1,12 @@ +substitutions: + clk_pin: GPIO0 + mosi_pin: GPIO2 + cs_pin: GPIO4 + dc_pin: GPIO5 + disp_reset_pin: GPIO12 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 + +<<: !include common.yaml diff --git a/tests/components/cst816/common.yaml b/tests/components/cst816/common.yaml index 765a353d1d..a4ac4aafec 100644 --- a/tests/components/cst816/common.yaml +++ b/tests/components/cst816/common.yaml @@ -1,27 +1,21 @@ -touchscreen: - - platform: cst816 - id: my_touchscreen - interrupt_pin: - number: 21 - reset_pin: GPIO16 - skip_probe: false - transform: - mirror_x: false - mirror_y: false - swap_xy: false - i2c: - sda: 3 - scl: 4 + - id: i2c_cst816 + scl: ${scl_pin} + sda: ${sda_pin} + +spi: + - id: spi_ili9xxx + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} display: - id: my_display platform: ili9xxx dimensions: 480x320 model: ST7796 - cs_pin: 18 - dc_pin: 20 - reset_pin: 22 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${disp_reset_pin} transform: swap_xy: true mirror_x: true @@ -29,9 +23,16 @@ display: auto_clear_enabled: false invert_colors: false -spi: - clk_pin: 14 - mosi_pin: 13 +touchscreen: + - id: ts_cst816 + platform: cst816 + interrupt_pin: ${interrupt_pin} + reset_pin: ${reset_pin} + skip_probe: false + transform: + mirror_x: false + mirror_y: false + swap_xy: false binary_sensor: - platform: cst816 diff --git a/tests/components/cst816/test.esp32-ard.yaml b/tests/components/cst816/test.esp32-ard.yaml index dade44d145..11e2c4fd43 100644 --- a/tests/components/cst816/test.esp32-ard.yaml +++ b/tests/components/cst816/test.esp32-ard.yaml @@ -1 +1,12 @@ +substitutions: + clk_pin: GPIO0 + mosi_pin: GPIO2 + cs_pin: GPIO4 + dc_pin: GPIO5 + disp_reset_pin: GPIO12 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 + <<: !include common.yaml diff --git a/tests/components/cst816/test.esp32-c3-ard.yaml b/tests/components/cst816/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..2f9bd72882 --- /dev/null +++ b/tests/components/cst816/test.esp32-c3-ard.yaml @@ -0,0 +1,12 @@ +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + cs_pin: GPIO8 + dc_pin: GPIO9 + disp_reset_pin: GPIO10 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/cst816/test.esp32-c3-idf.yaml b/tests/components/cst816/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..2f9bd72882 --- /dev/null +++ b/tests/components/cst816/test.esp32-c3-idf.yaml @@ -0,0 +1,12 @@ +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + cs_pin: GPIO8 + dc_pin: GPIO9 + disp_reset_pin: GPIO10 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/cst816/test.esp32-idf.yaml b/tests/components/cst816/test.esp32-idf.yaml new file mode 100644 index 0000000000..11e2c4fd43 --- /dev/null +++ b/tests/components/cst816/test.esp32-idf.yaml @@ -0,0 +1,12 @@ +substitutions: + clk_pin: GPIO0 + mosi_pin: GPIO2 + cs_pin: GPIO4 + dc_pin: GPIO5 + disp_reset_pin: GPIO12 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 + +<<: !include common.yaml diff --git a/tests/components/ct_clamp/common.yaml b/tests/components/ct_clamp/common.yaml new file mode 100644 index 0000000000..3ed9678447 --- /dev/null +++ b/tests/components/ct_clamp/common.yaml @@ -0,0 +1,9 @@ +sensor: + - platform: adc + id: esp_adc_sensor + pin: ${pin} + - platform: ct_clamp + sensor: esp_adc_sensor + name: CT Clamp + sample_duration: 500ms + update_interval: 5s diff --git a/tests/components/ct_clamp/test.esp32-ard.yaml b/tests/components/ct_clamp/test.esp32-ard.yaml index 1ea964fa96..0a70e3f733 100644 --- a/tests/components/ct_clamp/test.esp32-ard.yaml +++ b/tests/components/ct_clamp/test.esp32-ard.yaml @@ -1,9 +1,4 @@ -sensor: - - platform: adc - id: esp_adc_sensor - pin: 39 - - platform: ct_clamp - sensor: esp_adc_sensor - name: CT Clamp - sample_duration: 500ms - update_interval: 5s +substitutions: + pin: GPIO39 + +<<: !include common.yaml diff --git a/tests/components/ct_clamp/test.esp32-c3-ard.yaml b/tests/components/ct_clamp/test.esp32-c3-ard.yaml index e25acc95e1..a8f29c98ae 100644 --- a/tests/components/ct_clamp/test.esp32-c3-ard.yaml +++ b/tests/components/ct_clamp/test.esp32-c3-ard.yaml @@ -1,9 +1,4 @@ -sensor: - - platform: adc - id: esp_adc_sensor - pin: 0 - - platform: ct_clamp - sensor: esp_adc_sensor - name: CT Clamp - sample_duration: 500ms - update_interval: 5s +substitutions: + pin: GPIO0 + +<<: !include common.yaml diff --git a/tests/components/ct_clamp/test.esp32-c3-idf.yaml b/tests/components/ct_clamp/test.esp32-c3-idf.yaml index e25acc95e1..a8f29c98ae 100644 --- a/tests/components/ct_clamp/test.esp32-c3-idf.yaml +++ b/tests/components/ct_clamp/test.esp32-c3-idf.yaml @@ -1,9 +1,4 @@ -sensor: - - platform: adc - id: esp_adc_sensor - pin: 0 - - platform: ct_clamp - sensor: esp_adc_sensor - name: CT Clamp - sample_duration: 500ms - update_interval: 5s +substitutions: + pin: GPIO0 + +<<: !include common.yaml diff --git a/tests/components/ct_clamp/test.esp32-idf.yaml b/tests/components/ct_clamp/test.esp32-idf.yaml index 1ea964fa96..0a70e3f733 100644 --- a/tests/components/ct_clamp/test.esp32-idf.yaml +++ b/tests/components/ct_clamp/test.esp32-idf.yaml @@ -1,9 +1,4 @@ -sensor: - - platform: adc - id: esp_adc_sensor - pin: 39 - - platform: ct_clamp - sensor: esp_adc_sensor - name: CT Clamp - sample_duration: 500ms - update_interval: 5s +substitutions: + pin: GPIO39 + +<<: !include common.yaml diff --git a/tests/components/ct_clamp/test.esp8266-ard.yaml b/tests/components/ct_clamp/test.esp8266-ard.yaml index 9c7126480d..4a6d36cbb4 100644 --- a/tests/components/ct_clamp/test.esp8266-ard.yaml +++ b/tests/components/ct_clamp/test.esp8266-ard.yaml @@ -1,9 +1,4 @@ -sensor: - - platform: adc - id: esp_adc_sensor - pin: A0 - - platform: ct_clamp - sensor: esp_adc_sensor - name: CT Clamp - sample_duration: 500ms - update_interval: 5s +substitutions: + pin: A0 + +<<: !include common.yaml diff --git a/tests/components/ct_clamp/test.rp2040-ard.yaml b/tests/components/ct_clamp/test.rp2040-ard.yaml index 47077308aa..9479437434 100644 --- a/tests/components/ct_clamp/test.rp2040-ard.yaml +++ b/tests/components/ct_clamp/test.rp2040-ard.yaml @@ -1,9 +1,4 @@ -sensor: - - platform: adc - id: esp_adc_sensor - pin: 26 - - platform: ct_clamp - sensor: esp_adc_sensor - name: CT Clamp - sample_duration: 500ms - update_interval: 5s +substitutions: + pin: GPIO26 + +<<: !include common.yaml diff --git a/tests/components/current_based/common.yaml b/tests/components/current_based/common.yaml new file mode 100644 index 0000000000..25dc9671b7 --- /dev/null +++ b/tests/components/current_based/common.yaml @@ -0,0 +1,68 @@ +i2c: + - id: i2c_ade7953 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ade7953_i2c + irq_pin: ${irq_pin} + voltage: + name: ADE7953 Voltage + id: ade7953_voltage + current_a: + name: ADE7953 Current A + id: ade7953_current_a + current_b: + name: ADE7953 Current B + id: ade7953_current_b + power_factor_a: + name: ADE7953 Power Factor A + power_factor_b: + name: ADE7953 Power Factor B + apparent_power_a: + name: ADE7953 Apparent Power A + apparent_power_b: + name: ADE7953 Apparent Power B + active_power_a: + name: ADE7953 Active Power A + active_power_b: + name: ADE7953 Active Power B + reactive_power_a: + name: ADE7953 Reactive Power A + reactive_power_b: + name: ADE7953 Reactive Power B + update_interval: 1s + +switch: + - platform: template + id: template_switch1 + optimistic: true + - platform: template + id: template_switch2 + optimistic: true + +cover: + - platform: current_based + name: Current Based Cover + id: current_based_cover + open_sensor: ade7953_current_a + open_moving_current_threshold: 0.5 + open_obstacle_current_threshold: 0.8 + open_duration: 12s + open_action: + - switch.turn_on: template_switch1 + close_sensor: ade7953_current_b + close_moving_current_threshold: 0.5 + close_obstacle_current_threshold: 0.8 + close_duration: 10s + close_action: + - switch.turn_on: template_switch2 + stop_action: + - switch.turn_off: template_switch1 + - switch.turn_off: template_switch2 + obstacle_rollback: 30% + start_sensing_delay: 0.8s + malfunction_detection: true + malfunction_action: + then: + - logger.log: Malfunction Detected diff --git a/tests/components/current_based/test.esp32-ard.yaml b/tests/components/current_based/test.esp32-ard.yaml index 90781120bc..2c57d412f6 100644 --- a/tests/components/current_based/test.esp32-ard.yaml +++ b/tests/components/current_based/test.esp32-ard.yaml @@ -1,68 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + irq_pin: GPIO15 -sensor: - - platform: ade7953_i2c - irq_pin: 15 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s - -switch: - - platform: template - id: template_switch1 - optimistic: true - - platform: template - id: template_switch2 - optimistic: true - -cover: - - platform: current_based - name: Current Based Cover - id: current_based_cover - open_sensor: ade7953_current_a - open_moving_current_threshold: 0.5 - open_obstacle_current_threshold: 0.8 - open_duration: 12s - open_action: - - switch.turn_on: template_switch1 - close_sensor: ade7953_current_b - close_moving_current_threshold: 0.5 - close_obstacle_current_threshold: 0.8 - close_duration: 10s - close_action: - - switch.turn_on: template_switch2 - stop_action: - - switch.turn_off: template_switch1 - - switch.turn_off: template_switch2 - obstacle_rollback: 30% - start_sensing_delay: 0.8s - malfunction_detection: true - malfunction_action: - then: - - logger.log: Malfunction Detected +<<: !include common.yaml diff --git a/tests/components/current_based/test.esp32-c3-ard.yaml b/tests/components/current_based/test.esp32-c3-ard.yaml index 69ab8830c3..799acabd5a 100644 --- a/tests/components/current_based/test.esp32-c3-ard.yaml +++ b/tests/components/current_based/test.esp32-c3-ard.yaml @@ -1,68 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 -sensor: - - platform: ade7953_i2c - irq_pin: 6 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s - -switch: - - platform: template - id: template_switch1 - optimistic: true - - platform: template - id: template_switch2 - optimistic: true - -cover: - - platform: current_based - name: Current Based Cover - id: current_based_cover - open_sensor: ade7953_current_a - open_moving_current_threshold: 0.5 - open_obstacle_current_threshold: 0.8 - open_duration: 12s - open_action: - - switch.turn_on: template_switch1 - close_sensor: ade7953_current_b - close_moving_current_threshold: 0.5 - close_obstacle_current_threshold: 0.8 - close_duration: 10s - close_action: - - switch.turn_on: template_switch2 - stop_action: - - switch.turn_off: template_switch1 - - switch.turn_off: template_switch2 - obstacle_rollback: 30% - start_sensing_delay: 0.8s - malfunction_detection: true - malfunction_action: - then: - - logger.log: Malfunction Detected +<<: !include common.yaml diff --git a/tests/components/current_based/test.esp32-c3-idf.yaml b/tests/components/current_based/test.esp32-c3-idf.yaml index 69ab8830c3..799acabd5a 100644 --- a/tests/components/current_based/test.esp32-c3-idf.yaml +++ b/tests/components/current_based/test.esp32-c3-idf.yaml @@ -1,68 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 -sensor: - - platform: ade7953_i2c - irq_pin: 6 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s - -switch: - - platform: template - id: template_switch1 - optimistic: true - - platform: template - id: template_switch2 - optimistic: true - -cover: - - platform: current_based - name: Current Based Cover - id: current_based_cover - open_sensor: ade7953_current_a - open_moving_current_threshold: 0.5 - open_obstacle_current_threshold: 0.8 - open_duration: 12s - open_action: - - switch.turn_on: template_switch1 - close_sensor: ade7953_current_b - close_moving_current_threshold: 0.5 - close_obstacle_current_threshold: 0.8 - close_duration: 10s - close_action: - - switch.turn_on: template_switch2 - stop_action: - - switch.turn_off: template_switch1 - - switch.turn_off: template_switch2 - obstacle_rollback: 30% - start_sensing_delay: 0.8s - malfunction_detection: true - malfunction_action: - then: - - logger.log: Malfunction Detected +<<: !include common.yaml diff --git a/tests/components/current_based/test.esp32-idf.yaml b/tests/components/current_based/test.esp32-idf.yaml index 90781120bc..2c57d412f6 100644 --- a/tests/components/current_based/test.esp32-idf.yaml +++ b/tests/components/current_based/test.esp32-idf.yaml @@ -1,68 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + irq_pin: GPIO15 -sensor: - - platform: ade7953_i2c - irq_pin: 15 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s - -switch: - - platform: template - id: template_switch1 - optimistic: true - - platform: template - id: template_switch2 - optimistic: true - -cover: - - platform: current_based - name: Current Based Cover - id: current_based_cover - open_sensor: ade7953_current_a - open_moving_current_threshold: 0.5 - open_obstacle_current_threshold: 0.8 - open_duration: 12s - open_action: - - switch.turn_on: template_switch1 - close_sensor: ade7953_current_b - close_moving_current_threshold: 0.5 - close_obstacle_current_threshold: 0.8 - close_duration: 10s - close_action: - - switch.turn_on: template_switch2 - stop_action: - - switch.turn_off: template_switch1 - - switch.turn_off: template_switch2 - obstacle_rollback: 30% - start_sensing_delay: 0.8s - malfunction_detection: true - malfunction_action: - then: - - logger.log: Malfunction Detected +<<: !include common.yaml diff --git a/tests/components/current_based/test.esp8266-ard.yaml b/tests/components/current_based/test.esp8266-ard.yaml index 42d6d4676b..c8e6a43f44 100644 --- a/tests/components/current_based/test.esp8266-ard.yaml +++ b/tests/components/current_based/test.esp8266-ard.yaml @@ -1,68 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO15 -sensor: - - platform: ade7953_i2c - irq_pin: 15 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s - -switch: - - platform: template - id: template_switch1 - optimistic: true - - platform: template - id: template_switch2 - optimistic: true - -cover: - - platform: current_based - name: Current Based Cover - id: current_based_cover - open_sensor: ade7953_current_a - open_moving_current_threshold: 0.5 - open_obstacle_current_threshold: 0.8 - open_duration: 12s - open_action: - - switch.turn_on: template_switch1 - close_sensor: ade7953_current_b - close_moving_current_threshold: 0.5 - close_obstacle_current_threshold: 0.8 - close_duration: 10s - close_action: - - switch.turn_on: template_switch2 - stop_action: - - switch.turn_off: template_switch1 - - switch.turn_off: template_switch2 - obstacle_rollback: 30% - start_sensing_delay: 0.8s - malfunction_detection: true - malfunction_action: - then: - - logger.log: Malfunction Detected +<<: !include common.yaml diff --git a/tests/components/current_based/test.rp2040-ard.yaml b/tests/components/current_based/test.rp2040-ard.yaml index 69ab8830c3..799acabd5a 100644 --- a/tests/components/current_based/test.rp2040-ard.yaml +++ b/tests/components/current_based/test.rp2040-ard.yaml @@ -1,68 +1,6 @@ -i2c: - - id: i2c_ade7953 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 -sensor: - - platform: ade7953_i2c - irq_pin: 6 - voltage: - name: ADE7953 Voltage - id: ade7953_voltage - current_a: - name: ADE7953 Current A - id: ade7953_current_a - current_b: - name: ADE7953 Current B - id: ade7953_current_b - power_factor_a: - name: ADE7953 Power Factor A - power_factor_b: - name: ADE7953 Power Factor B - apparent_power_a: - name: ADE7953 Apparent Power A - apparent_power_b: - name: ADE7953 Apparent Power B - active_power_a: - name: ADE7953 Active Power A - active_power_b: - name: ADE7953 Active Power B - reactive_power_a: - name: ADE7953 Reactive Power A - reactive_power_b: - name: ADE7953 Reactive Power B - update_interval: 1s - -switch: - - platform: template - id: template_switch1 - optimistic: true - - platform: template - id: template_switch2 - optimistic: true - -cover: - - platform: current_based - name: Current Based Cover - id: current_based_cover - open_sensor: ade7953_current_a - open_moving_current_threshold: 0.5 - open_obstacle_current_threshold: 0.8 - open_duration: 12s - open_action: - - switch.turn_on: template_switch1 - close_sensor: ade7953_current_b - close_moving_current_threshold: 0.5 - close_obstacle_current_threshold: 0.8 - close_duration: 10s - close_action: - - switch.turn_on: template_switch2 - stop_action: - - switch.turn_off: template_switch1 - - switch.turn_off: template_switch2 - obstacle_rollback: 30% - start_sensing_delay: 0.8s - malfunction_detection: true - malfunction_action: - then: - - logger.log: Malfunction Detected +<<: !include common.yaml diff --git a/tests/components/cwww/common.yaml b/tests/components/cwww/common.yaml new file mode 100644 index 0000000000..0ad5beeaae --- /dev/null +++ b/tests/components/cwww/common.yaml @@ -0,0 +1,16 @@ +output: + - platform: ${light_platform} + id: light_output_1 + pin: ${pin_o1} + - platform: ${light_platform} + id: light_output_2 + pin: ${pin_o2} + +light: + - platform: cwww + name: CWWW Light + cold_white: light_output_1 + warm_white: light_output_2 + cold_white_color_temperature: 153 mireds + warm_white_color_temperature: 500 mireds + constant_brightness: true diff --git a/tests/components/cwww/test.esp32-ard.yaml b/tests/components/cwww/test.esp32-ard.yaml index f108d96ad3..1831adda6e 100644 --- a/tests/components/cwww/test.esp32-ard.yaml +++ b/tests/components/cwww/test.esp32-ard.yaml @@ -1,16 +1,6 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 +substitutions: + light_platform: ledc + pin_o1: GPIO16 + pin_o2: GPIO17 -light: - - platform: cwww - name: CWWW Light - cold_white: light_output_1 - warm_white: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - constant_brightness: true +<<: !include common.yaml diff --git a/tests/components/cwww/test.esp32-c3-ard.yaml b/tests/components/cwww/test.esp32-c3-ard.yaml index c829ca2a2b..016f315d9f 100644 --- a/tests/components/cwww/test.esp32-c3-ard.yaml +++ b/tests/components/cwww/test.esp32-c3-ard.yaml @@ -1,16 +1,6 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 +substitutions: + light_platform: ledc + pin_o1: GPIO6 + pin_o2: GPIO7 -light: - - platform: cwww - name: CWWW Light - cold_white: light_output_1 - warm_white: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - constant_brightness: true +<<: !include common.yaml diff --git a/tests/components/cwww/test.esp32-c3-idf.yaml b/tests/components/cwww/test.esp32-c3-idf.yaml index 2760a167ee..982394ded6 100644 --- a/tests/components/cwww/test.esp32-c3-idf.yaml +++ b/tests/components/cwww/test.esp32-c3-idf.yaml @@ -1,19 +1,14 @@ +substitutions: + light_platform: ledc + pin_o1: GPIO6 + pin_o2: GPIO7 + +packages: + device_base: !include common.yaml + output: - - platform: ledc - id: light_output_1 - pin: 1 + - id: !extend light_output_1 channel: 0 - - platform: ledc - id: light_output_2 - pin: 2 + - id: !extend light_output_2 channel: 1 phase_angle: 180° - -light: - - platform: cwww - name: CWWW Light - cold_white: light_output_1 - warm_white: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - constant_brightness: true diff --git a/tests/components/cwww/test.esp32-idf.yaml b/tests/components/cwww/test.esp32-idf.yaml index 27fa160e56..d2a998e6b3 100644 --- a/tests/components/cwww/test.esp32-idf.yaml +++ b/tests/components/cwww/test.esp32-idf.yaml @@ -1,19 +1,14 @@ +substitutions: + light_platform: ledc + pin_o1: GPIO16 + pin_o2: GPIO17 + +packages: + device_base: !include common.yaml + output: - - platform: ledc - id: light_output_1 - pin: 12 + - id: !extend light_output_1 channel: 0 - - platform: ledc - id: light_output_2 - pin: 13 + - id: !extend light_output_2 channel: 1 phase_angle: 180° - -light: - - platform: cwww - name: CWWW Light - cold_white: light_output_1 - warm_white: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - constant_brightness: true diff --git a/tests/components/cwww/test.esp8266-ard.yaml b/tests/components/cwww/test.esp8266-ard.yaml index 50c311f616..75a5b9d64d 100644 --- a/tests/components/cwww/test.esp8266-ard.yaml +++ b/tests/components/cwww/test.esp8266-ard.yaml @@ -1,16 +1,6 @@ -output: - - platform: esp8266_pwm - id: light_output_1 - pin: 12 - - platform: esp8266_pwm - id: light_output_2 - pin: 13 +substitutions: + light_platform: esp8266_pwm + pin_o1: GPIO12 + pin_o2: GPIO13 -light: - - platform: cwww - name: CWWW Light - cold_white: light_output_1 - warm_white: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - constant_brightness: true +<<: !include common.yaml diff --git a/tests/components/cwww/test.rp2040-ard.yaml b/tests/components/cwww/test.rp2040-ard.yaml index 505d67f862..537177aca1 100644 --- a/tests/components/cwww/test.rp2040-ard.yaml +++ b/tests/components/cwww/test.rp2040-ard.yaml @@ -1,16 +1,6 @@ -output: - - platform: rp2040_pwm - id: light_output_1 - pin: 12 - - platform: rp2040_pwm - id: light_output_2 - pin: 13 +substitutions: + light_platform: rp2040_pwm + pin_o1: GPIO12 + pin_o2: GPIO13 -light: - - platform: cwww - name: CWWW Light - cold_white: light_output_1 - warm_white: light_output_2 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - constant_brightness: true +<<: !include common.yaml From 693d813c4b5afdc224ac57699944bd366f780f30 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:05:17 -0600 Subject: [PATCH 147/194] [CI] Consolidate some tests (D) (#8189) --- tests/components/dac7678/common.yaml | 43 ++++++++++++++ tests/components/dac7678/test.esp32-ard.yaml | 46 ++------------- .../components/dac7678/test.esp32-c3-ard.yaml | 46 ++------------- .../components/dac7678/test.esp32-c3-idf.yaml | 46 ++------------- tests/components/dac7678/test.esp32-idf.yaml | 46 ++------------- .../components/dac7678/test.esp8266-ard.yaml | 46 ++------------- tests/components/dac7678/test.rp2040-ard.yaml | 46 ++------------- tests/components/daikin/common.yaml | 12 ++++ tests/components/daikin/test.esp32-ard.yaml | 14 +---- tests/components/daikin/test.esp8266-ard.yaml | 14 +---- tests/components/daikin_arc/common.yaml | 19 ++++++ .../components/daikin_arc/test.esp32-ard.yaml | 22 ++----- .../daikin_arc/test.esp8266-ard.yaml | 22 ++----- tests/components/daikin_brc/common.yaml | 7 +++ .../components/daikin_brc/test.esp32-ard.yaml | 9 +-- .../daikin_brc/test.esp32-c3-ard.yaml | 9 +-- .../daikin_brc/test.esp32-c3-idf.yaml | 9 +-- .../components/daikin_brc/test.esp32-idf.yaml | 9 +-- .../daikin_brc/test.esp8266-ard.yaml | 9 +-- tests/components/daly_bms/common.yaml | 53 +++++++++++++++++ tests/components/daly_bms/test.esp32-ard.yaml | 58 ++----------------- .../daly_bms/test.esp32-c3-ard.yaml | 58 ++----------------- .../daly_bms/test.esp32-c3-idf.yaml | 58 ++----------------- tests/components/daly_bms/test.esp32-idf.yaml | 58 ++----------------- .../components/daly_bms/test.esp8266-ard.yaml | 58 ++----------------- .../components/daly_bms/test.rp2040-ard.yaml | 58 ++----------------- tests/components/deep_sleep/common-esp32.yaml | 7 +++ tests/components/deep_sleep/common.yaml | 6 ++ .../components/deep_sleep/test.esp32-ard.yaml | 17 ++---- .../deep_sleep/test.esp32-c3-ard.yaml | 17 ++---- .../deep_sleep/test.esp32-c3-idf.yaml | 17 ++---- .../components/deep_sleep/test.esp32-idf.yaml | 17 ++---- .../deep_sleep/test.esp8266-ard.yaml | 9 +-- tests/components/delonghi/common.yaml | 7 +++ tests/components/delonghi/test.esp32-ard.yaml | 9 +-- .../delonghi/test.esp32-c3-ard.yaml | 9 +-- .../delonghi/test.esp32-c3-idf.yaml | 9 +-- tests/components/delonghi/test.esp32-idf.yaml | 9 +-- .../components/delonghi/test.esp8266-ard.yaml | 9 +-- tests/components/dfplayer/common.yaml | 42 ++++++++++++++ tests/components/dfplayer/test.esp32-ard.yaml | 45 ++------------ .../dfplayer/test.esp32-c3-ard.yaml | 45 ++------------ .../dfplayer/test.esp32-c3-idf.yaml | 45 ++------------ tests/components/dfplayer/test.esp32-idf.yaml | 45 ++------------ .../components/dfplayer/test.esp8266-ard.yaml | 45 ++------------ .../components/dfplayer/test.rp2040-ard.yaml | 45 ++------------ tests/components/dfrobot_sen0395/common.yaml | 28 +++++++++ .../dfrobot_sen0395/test.esp32-ard.yaml | 31 ++-------- .../dfrobot_sen0395/test.esp32-c3-ard.yaml | 31 ++-------- .../dfrobot_sen0395/test.esp32-c3-idf.yaml | 31 ++-------- .../dfrobot_sen0395/test.esp32-idf.yaml | 31 ++-------- .../dfrobot_sen0395/test.esp8266-ard.yaml | 31 ++-------- .../dfrobot_sen0395/test.rp2040-ard.yaml | 31 ++-------- tests/components/dht12/common.yaml | 12 ++++ tests/components/dht12/test.esp32-ard.yaml | 15 ++--- tests/components/dht12/test.esp32-c3-ard.yaml | 15 ++--- tests/components/dht12/test.esp32-c3-idf.yaml | 15 ++--- tests/components/dht12/test.esp32-idf.yaml | 15 ++--- tests/components/dht12/test.esp8266-ard.yaml | 15 ++--- tests/components/dht12/test.rp2040-ard.yaml | 15 ++--- tests/components/dps310/common.yaml | 12 ++++ tests/components/dps310/test.esp32-ard.yaml | 15 ++--- .../components/dps310/test.esp32-c3-ard.yaml | 15 ++--- .../components/dps310/test.esp32-c3-idf.yaml | 15 ++--- tests/components/dps310/test.esp32-idf.yaml | 15 ++--- tests/components/dps310/test.esp8266-ard.yaml | 15 ++--- tests/components/dps310/test.rp2040-ard.yaml | 15 ++--- tests/components/ds1307/common.yaml | 9 +++ tests/components/ds1307/test.esp32-ard.yaml | 12 ++-- .../components/ds1307/test.esp32-c3-ard.yaml | 12 ++-- .../components/ds1307/test.esp32-c3-idf.yaml | 12 ++-- tests/components/ds1307/test.esp32-idf.yaml | 12 ++-- tests/components/ds1307/test.esp8266-ard.yaml | 12 ++-- tests/components/ds1307/test.rp2040-ard.yaml | 12 ++-- tests/components/dsmr/common.yaml | 12 ++++ tests/components/dsmr/test.esp32-ard.yaml | 16 ++--- tests/components/dsmr/test.esp32-c3-ard.yaml | 16 ++--- tests/components/dsmr/test.esp8266-ard.yaml | 16 ++--- tests/components/dsmr/test.rp2040-ard.yaml | 16 ++--- 79 files changed, 519 insertions(+), 1385 deletions(-) create mode 100644 tests/components/dac7678/common.yaml create mode 100644 tests/components/daikin/common.yaml create mode 100644 tests/components/daikin_arc/common.yaml create mode 100644 tests/components/daikin_brc/common.yaml create mode 100644 tests/components/daly_bms/common.yaml create mode 100644 tests/components/deep_sleep/common-esp32.yaml create mode 100644 tests/components/deep_sleep/common.yaml create mode 100644 tests/components/delonghi/common.yaml create mode 100644 tests/components/dfplayer/common.yaml create mode 100644 tests/components/dfrobot_sen0395/common.yaml create mode 100644 tests/components/dht12/common.yaml create mode 100644 tests/components/dps310/common.yaml create mode 100644 tests/components/ds1307/common.yaml create mode 100644 tests/components/dsmr/common.yaml diff --git a/tests/components/dac7678/common.yaml b/tests/components/dac7678/common.yaml new file mode 100644 index 0000000000..efad81a5ff --- /dev/null +++ b/tests/components/dac7678/common.yaml @@ -0,0 +1,43 @@ +i2c: + - id: i2c_dac7678 + scl: ${scl_pin} + sda: ${sda_pin} + +dac7678: + address: 0x4A + id: dac7678_hub + internal_reference: true + +output: + - platform: dac7678 + dac7678_id: dac7678_hub + channel: 0 + id: dac7678_1_ch0 + - platform: dac7678 + dac7678_id: dac7678_hub + channel: 1 + id: dac7678_1_ch1 + - platform: dac7678 + dac7678_id: dac7678_hub + channel: 2 + id: dac7678_1_ch2 + - platform: dac7678 + dac7678_id: dac7678_hub + channel: 3 + id: dac7678_1_ch3 + - platform: dac7678 + dac7678_id: dac7678_hub + channel: 4 + id: dac7678_1_ch4 + - platform: dac7678 + dac7678_id: dac7678_hub + channel: 5 + id: dac7678_1_ch5 + - platform: dac7678 + dac7678_id: dac7678_hub + channel: 6 + id: dac7678_1_ch6 + - platform: dac7678 + dac7678_id: dac7678_hub + channel: 7 + id: dac7678_1_ch7 diff --git a/tests/components/dac7678/test.esp32-ard.yaml b/tests/components/dac7678/test.esp32-ard.yaml index 946a7ca58d..63c3bd6afd 100644 --- a/tests/components/dac7678/test.esp32-ard.yaml +++ b/tests/components/dac7678/test.esp32-ard.yaml @@ -1,43 +1,5 @@ -i2c: - - id: i2c_dac7678 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -dac7678: - address: 0x4A - id: dac7678_hub - internal_reference: true - -output: - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 0 - id: dac7678_1_ch0 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 1 - id: dac7678_1_ch1 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 2 - id: dac7678_1_ch2 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 3 - id: dac7678_1_ch3 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 4 - id: dac7678_1_ch4 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 5 - id: dac7678_1_ch5 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 6 - id: dac7678_1_ch6 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 7 - id: dac7678_1_ch7 +<<: !include common.yaml diff --git a/tests/components/dac7678/test.esp32-c3-ard.yaml b/tests/components/dac7678/test.esp32-c3-ard.yaml index 7e3455bb68..ee2c29ca4e 100644 --- a/tests/components/dac7678/test.esp32-c3-ard.yaml +++ b/tests/components/dac7678/test.esp32-c3-ard.yaml @@ -1,43 +1,5 @@ -i2c: - - id: i2c_dac7678 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -dac7678: - address: 0x4A - id: dac7678_hub - internal_reference: true - -output: - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 0 - id: dac7678_1_ch0 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 1 - id: dac7678_1_ch1 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 2 - id: dac7678_1_ch2 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 3 - id: dac7678_1_ch3 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 4 - id: dac7678_1_ch4 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 5 - id: dac7678_1_ch5 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 6 - id: dac7678_1_ch6 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 7 - id: dac7678_1_ch7 +<<: !include common.yaml diff --git a/tests/components/dac7678/test.esp32-c3-idf.yaml b/tests/components/dac7678/test.esp32-c3-idf.yaml index 7e3455bb68..ee2c29ca4e 100644 --- a/tests/components/dac7678/test.esp32-c3-idf.yaml +++ b/tests/components/dac7678/test.esp32-c3-idf.yaml @@ -1,43 +1,5 @@ -i2c: - - id: i2c_dac7678 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -dac7678: - address: 0x4A - id: dac7678_hub - internal_reference: true - -output: - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 0 - id: dac7678_1_ch0 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 1 - id: dac7678_1_ch1 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 2 - id: dac7678_1_ch2 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 3 - id: dac7678_1_ch3 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 4 - id: dac7678_1_ch4 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 5 - id: dac7678_1_ch5 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 6 - id: dac7678_1_ch6 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 7 - id: dac7678_1_ch7 +<<: !include common.yaml diff --git a/tests/components/dac7678/test.esp32-idf.yaml b/tests/components/dac7678/test.esp32-idf.yaml index 946a7ca58d..63c3bd6afd 100644 --- a/tests/components/dac7678/test.esp32-idf.yaml +++ b/tests/components/dac7678/test.esp32-idf.yaml @@ -1,43 +1,5 @@ -i2c: - - id: i2c_dac7678 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -dac7678: - address: 0x4A - id: dac7678_hub - internal_reference: true - -output: - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 0 - id: dac7678_1_ch0 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 1 - id: dac7678_1_ch1 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 2 - id: dac7678_1_ch2 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 3 - id: dac7678_1_ch3 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 4 - id: dac7678_1_ch4 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 5 - id: dac7678_1_ch5 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 6 - id: dac7678_1_ch6 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 7 - id: dac7678_1_ch7 +<<: !include common.yaml diff --git a/tests/components/dac7678/test.esp8266-ard.yaml b/tests/components/dac7678/test.esp8266-ard.yaml index 7e3455bb68..ee2c29ca4e 100644 --- a/tests/components/dac7678/test.esp8266-ard.yaml +++ b/tests/components/dac7678/test.esp8266-ard.yaml @@ -1,43 +1,5 @@ -i2c: - - id: i2c_dac7678 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -dac7678: - address: 0x4A - id: dac7678_hub - internal_reference: true - -output: - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 0 - id: dac7678_1_ch0 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 1 - id: dac7678_1_ch1 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 2 - id: dac7678_1_ch2 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 3 - id: dac7678_1_ch3 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 4 - id: dac7678_1_ch4 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 5 - id: dac7678_1_ch5 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 6 - id: dac7678_1_ch6 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 7 - id: dac7678_1_ch7 +<<: !include common.yaml diff --git a/tests/components/dac7678/test.rp2040-ard.yaml b/tests/components/dac7678/test.rp2040-ard.yaml index 7e3455bb68..ee2c29ca4e 100644 --- a/tests/components/dac7678/test.rp2040-ard.yaml +++ b/tests/components/dac7678/test.rp2040-ard.yaml @@ -1,43 +1,5 @@ -i2c: - - id: i2c_dac7678 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -dac7678: - address: 0x4A - id: dac7678_hub - internal_reference: true - -output: - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 0 - id: dac7678_1_ch0 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 1 - id: dac7678_1_ch1 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 2 - id: dac7678_1_ch2 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 3 - id: dac7678_1_ch3 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 4 - id: dac7678_1_ch4 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 5 - id: dac7678_1_ch5 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 6 - id: dac7678_1_ch6 - - platform: dac7678 - dac7678_id: dac7678_hub - channel: 7 - id: dac7678_1_ch7 +<<: !include common.yaml diff --git a/tests/components/daikin/common.yaml b/tests/components/daikin/common.yaml new file mode 100644 index 0000000000..27f381b422 --- /dev/null +++ b/tests/components/daikin/common.yaml @@ -0,0 +1,12 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: heatpumpir + protocol: daikin + horizontal_default: middle + vertical_default: middle + name: HeatpumpIR Climate + min_temperature: 18 + max_temperature: 30 diff --git a/tests/components/daikin/test.esp32-ard.yaml b/tests/components/daikin/test.esp32-ard.yaml index 6672fe3e45..7b012aa64c 100644 --- a/tests/components/daikin/test.esp32-ard.yaml +++ b/tests/components/daikin/test.esp32-ard.yaml @@ -1,12 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: heatpumpir - protocol: daikin - horizontal_default: middle - vertical_default: middle - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 +<<: !include common.yaml diff --git a/tests/components/daikin/test.esp8266-ard.yaml b/tests/components/daikin/test.esp8266-ard.yaml index 47f02bbad9..f5097fcf5f 100644 --- a/tests/components/daikin/test.esp8266-ard.yaml +++ b/tests/components/daikin/test.esp8266-ard.yaml @@ -1,12 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: heatpumpir - protocol: daikin - horizontal_default: middle - vertical_default: middle - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 +<<: !include common.yaml diff --git a/tests/components/daikin_arc/common.yaml b/tests/components/daikin_arc/common.yaml new file mode 100644 index 0000000000..5c0510f6df --- /dev/null +++ b/tests/components/daikin_arc/common.yaml @@ -0,0 +1,19 @@ +remote_transmitter: + pin: ${tx_pin} + carrier_duty_percent: 50% + id: tsvr + +remote_receiver: + id: rcvr + pin: + number: ${rx_pin} + inverted: true + mode: + input: true + pullup: true + tolerance: 40% + +climate: + - platform: daikin_arc + name: Daikin AC + receiver_id: rcvr diff --git a/tests/components/daikin_arc/test.esp32-ard.yaml b/tests/components/daikin_arc/test.esp32-ard.yaml index a8556e8576..cd59eb0832 100644 --- a/tests/components/daikin_arc/test.esp32-ard.yaml +++ b/tests/components/daikin_arc/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% - id: tsvr +substitutions: + tx_pin: GPIO2 + rx_pin: GPIO4 -remote_receiver: - id: rcvr - pin: - number: 27 - inverted: true - mode: - input: true - pullup: true - tolerance: 40% - -climate: - - platform: daikin_arc - name: "AC" - receiver_id: rcvr +<<: !include common.yaml diff --git a/tests/components/daikin_arc/test.esp8266-ard.yaml b/tests/components/daikin_arc/test.esp8266-ard.yaml index abf1b34a6e..8e08490d0c 100644 --- a/tests/components/daikin_arc/test.esp8266-ard.yaml +++ b/tests/components/daikin_arc/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% - id: tsvr +substitutions: + tx_pin: GPIO5 + rx_pin: GPIO4 -remote_receiver: - id: rcvr - pin: - number: 2 - inverted: true - mode: - input: true - pullup: true - tolerance: 40% - -climate: - - platform: daikin_arc - name: "AC" - receiver_id: rcvr +<<: !include common.yaml diff --git a/tests/components/daikin_brc/common.yaml b/tests/components/daikin_brc/common.yaml new file mode 100644 index 0000000000..c9d7baa989 --- /dev/null +++ b/tests/components/daikin_brc/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: daikin_brc + name: Daikin_brc Climate diff --git a/tests/components/daikin_brc/test.esp32-ard.yaml b/tests/components/daikin_brc/test.esp32-ard.yaml index 89a5b00f5d..7b012aa64c 100644 --- a/tests/components/daikin_brc/test.esp32-ard.yaml +++ b/tests/components/daikin_brc/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: daikin_brc - name: Daikin_brc Climate +<<: !include common.yaml diff --git a/tests/components/daikin_brc/test.esp32-c3-ard.yaml b/tests/components/daikin_brc/test.esp32-c3-ard.yaml index 89a5b00f5d..7b012aa64c 100644 --- a/tests/components/daikin_brc/test.esp32-c3-ard.yaml +++ b/tests/components/daikin_brc/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: daikin_brc - name: Daikin_brc Climate +<<: !include common.yaml diff --git a/tests/components/daikin_brc/test.esp32-c3-idf.yaml b/tests/components/daikin_brc/test.esp32-c3-idf.yaml index 89a5b00f5d..7b012aa64c 100644 --- a/tests/components/daikin_brc/test.esp32-c3-idf.yaml +++ b/tests/components/daikin_brc/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: daikin_brc - name: Daikin_brc Climate +<<: !include common.yaml diff --git a/tests/components/daikin_brc/test.esp32-idf.yaml b/tests/components/daikin_brc/test.esp32-idf.yaml index 89a5b00f5d..7b012aa64c 100644 --- a/tests/components/daikin_brc/test.esp32-idf.yaml +++ b/tests/components/daikin_brc/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: daikin_brc - name: Daikin_brc Climate +<<: !include common.yaml diff --git a/tests/components/daikin_brc/test.esp8266-ard.yaml b/tests/components/daikin_brc/test.esp8266-ard.yaml index b8c74803a2..f5097fcf5f 100644 --- a/tests/components/daikin_brc/test.esp8266-ard.yaml +++ b/tests/components/daikin_brc/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: daikin_brc - name: Daikin_brc Climate +<<: !include common.yaml diff --git a/tests/components/daly_bms/common.yaml b/tests/components/daly_bms/common.yaml new file mode 100644 index 0000000000..a4cb849f9f --- /dev/null +++ b/tests/components/daly_bms/common.yaml @@ -0,0 +1,53 @@ +uart: + - id: uart_daly_bms + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 4800 + +daly_bms: + update_interval: 20s + +binary_sensor: + - platform: daly_bms + charging_mos_enabled: + name: Charging MOS + discharging_mos_enabled: + name: Discharging MOS + +sensor: + - platform: daly_bms + voltage: + name: Battery Voltage + current: + name: Battery Current + battery_level: + name: Battery Level + max_cell_voltage: + name: Max Cell Voltage + max_cell_voltage_number: + name: Max Cell Voltage Number + min_cell_voltage: + name: Min Cell Voltage + min_cell_voltage_number: + name: Min Cell Voltage Number + max_temperature: + name: Max Temperature + max_temperature_probe_number: + name: Max Temperature Probe Number + min_temperature: + name: Min Temperature + min_temperature_probe_number: + name: Min Temperature Probe Number + remaining_capacity: + name: Remaining Capacity + cells_number: + name: Cells Number + temperature_1: + name: Temperature 1 + temperature_2: + name: Temperature 2 + +text_sensor: + - platform: daly_bms + status: + name: BMS Status diff --git a/tests/components/daly_bms/test.esp32-ard.yaml b/tests/components/daly_bms/test.esp32-ard.yaml index ec9607334d..811f6b72a6 100644 --- a/tests/components/daly_bms/test.esp32-ard.yaml +++ b/tests/components/daly_bms/test.esp32-ard.yaml @@ -1,55 +1,5 @@ -uart: - - id: uart_daly_bms - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 4800 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -daly_bms: - update_interval: 20s - -binary_sensor: - - platform: daly_bms - charging_mos_enabled: - name: Charging MOS - discharging_mos_enabled: - name: Discharging MOS - -sensor: - - platform: daly_bms - voltage: - name: Battery Voltage - current: - name: Battery Current - battery_level: - name: Battery Level - max_cell_voltage: - name: Max Cell Voltage - max_cell_voltage_number: - name: Max Cell Voltage Number - min_cell_voltage: - name: Min Cell Voltage - min_cell_voltage_number: - name: Min Cell Voltage Number - max_temperature: - name: Max Temperature - max_temperature_probe_number: - name: Max Temperature Probe Number - min_temperature: - name: Min Temperature - min_temperature_probe_number: - name: Min Temperature Probe Number - remaining_capacity: - name: Remaining Capacity - cells_number: - name: Cells Number - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - -text_sensor: - - platform: daly_bms - status: - name: BMS Status +<<: !include common.yaml diff --git a/tests/components/daly_bms/test.esp32-c3-ard.yaml b/tests/components/daly_bms/test.esp32-c3-ard.yaml index 237a6570b5..c79d14c740 100644 --- a/tests/components/daly_bms/test.esp32-c3-ard.yaml +++ b/tests/components/daly_bms/test.esp32-c3-ard.yaml @@ -1,55 +1,5 @@ -uart: - - id: uart_daly_bms - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 4800 +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -daly_bms: - update_interval: 20s - -binary_sensor: - - platform: daly_bms - charging_mos_enabled: - name: Charging MOS - discharging_mos_enabled: - name: Discharging MOS - -sensor: - - platform: daly_bms - voltage: - name: Battery Voltage - current: - name: Battery Current - battery_level: - name: Battery Level - max_cell_voltage: - name: Max Cell Voltage - max_cell_voltage_number: - name: Max Cell Voltage Number - min_cell_voltage: - name: Min Cell Voltage - min_cell_voltage_number: - name: Min Cell Voltage Number - max_temperature: - name: Max Temperature - max_temperature_probe_number: - name: Max Temperature Probe Number - min_temperature: - name: Min Temperature - min_temperature_probe_number: - name: Min Temperature Probe Number - remaining_capacity: - name: Remaining Capacity - cells_number: - name: Cells Number - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - -text_sensor: - - platform: daly_bms - status: - name: BMS Status +<<: !include common.yaml diff --git a/tests/components/daly_bms/test.esp32-c3-idf.yaml b/tests/components/daly_bms/test.esp32-c3-idf.yaml index 237a6570b5..c79d14c740 100644 --- a/tests/components/daly_bms/test.esp32-c3-idf.yaml +++ b/tests/components/daly_bms/test.esp32-c3-idf.yaml @@ -1,55 +1,5 @@ -uart: - - id: uart_daly_bms - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 4800 +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -daly_bms: - update_interval: 20s - -binary_sensor: - - platform: daly_bms - charging_mos_enabled: - name: Charging MOS - discharging_mos_enabled: - name: Discharging MOS - -sensor: - - platform: daly_bms - voltage: - name: Battery Voltage - current: - name: Battery Current - battery_level: - name: Battery Level - max_cell_voltage: - name: Max Cell Voltage - max_cell_voltage_number: - name: Max Cell Voltage Number - min_cell_voltage: - name: Min Cell Voltage - min_cell_voltage_number: - name: Min Cell Voltage Number - max_temperature: - name: Max Temperature - max_temperature_probe_number: - name: Max Temperature Probe Number - min_temperature: - name: Min Temperature - min_temperature_probe_number: - name: Min Temperature Probe Number - remaining_capacity: - name: Remaining Capacity - cells_number: - name: Cells Number - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - -text_sensor: - - platform: daly_bms - status: - name: BMS Status +<<: !include common.yaml diff --git a/tests/components/daly_bms/test.esp32-idf.yaml b/tests/components/daly_bms/test.esp32-idf.yaml index ec9607334d..811f6b72a6 100644 --- a/tests/components/daly_bms/test.esp32-idf.yaml +++ b/tests/components/daly_bms/test.esp32-idf.yaml @@ -1,55 +1,5 @@ -uart: - - id: uart_daly_bms - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 4800 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -daly_bms: - update_interval: 20s - -binary_sensor: - - platform: daly_bms - charging_mos_enabled: - name: Charging MOS - discharging_mos_enabled: - name: Discharging MOS - -sensor: - - platform: daly_bms - voltage: - name: Battery Voltage - current: - name: Battery Current - battery_level: - name: Battery Level - max_cell_voltage: - name: Max Cell Voltage - max_cell_voltage_number: - name: Max Cell Voltage Number - min_cell_voltage: - name: Min Cell Voltage - min_cell_voltage_number: - name: Min Cell Voltage Number - max_temperature: - name: Max Temperature - max_temperature_probe_number: - name: Max Temperature Probe Number - min_temperature: - name: Min Temperature - min_temperature_probe_number: - name: Min Temperature Probe Number - remaining_capacity: - name: Remaining Capacity - cells_number: - name: Cells Number - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - -text_sensor: - - platform: daly_bms - status: - name: BMS Status +<<: !include common.yaml diff --git a/tests/components/daly_bms/test.esp8266-ard.yaml b/tests/components/daly_bms/test.esp8266-ard.yaml index 237a6570b5..3b44f9c9c3 100644 --- a/tests/components/daly_bms/test.esp8266-ard.yaml +++ b/tests/components/daly_bms/test.esp8266-ard.yaml @@ -1,55 +1,5 @@ -uart: - - id: uart_daly_bms - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 4800 +substitutions: + tx_pin: GPIO1 + rx_pin: GPIO3 -daly_bms: - update_interval: 20s - -binary_sensor: - - platform: daly_bms - charging_mos_enabled: - name: Charging MOS - discharging_mos_enabled: - name: Discharging MOS - -sensor: - - platform: daly_bms - voltage: - name: Battery Voltage - current: - name: Battery Current - battery_level: - name: Battery Level - max_cell_voltage: - name: Max Cell Voltage - max_cell_voltage_number: - name: Max Cell Voltage Number - min_cell_voltage: - name: Min Cell Voltage - min_cell_voltage_number: - name: Min Cell Voltage Number - max_temperature: - name: Max Temperature - max_temperature_probe_number: - name: Max Temperature Probe Number - min_temperature: - name: Min Temperature - min_temperature_probe_number: - name: Min Temperature Probe Number - remaining_capacity: - name: Remaining Capacity - cells_number: - name: Cells Number - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - -text_sensor: - - platform: daly_bms - status: - name: BMS Status +<<: !include common.yaml diff --git a/tests/components/daly_bms/test.rp2040-ard.yaml b/tests/components/daly_bms/test.rp2040-ard.yaml index 237a6570b5..b516342f3b 100644 --- a/tests/components/daly_bms/test.rp2040-ard.yaml +++ b/tests/components/daly_bms/test.rp2040-ard.yaml @@ -1,55 +1,5 @@ -uart: - - id: uart_daly_bms - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 4800 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -daly_bms: - update_interval: 20s - -binary_sensor: - - platform: daly_bms - charging_mos_enabled: - name: Charging MOS - discharging_mos_enabled: - name: Discharging MOS - -sensor: - - platform: daly_bms - voltage: - name: Battery Voltage - current: - name: Battery Current - battery_level: - name: Battery Level - max_cell_voltage: - name: Max Cell Voltage - max_cell_voltage_number: - name: Max Cell Voltage Number - min_cell_voltage: - name: Min Cell Voltage - min_cell_voltage_number: - name: Min Cell Voltage Number - max_temperature: - name: Max Temperature - max_temperature_probe_number: - name: Max Temperature Probe Number - min_temperature: - name: Min Temperature - min_temperature_probe_number: - name: Min Temperature Probe Number - remaining_capacity: - name: Remaining Capacity - cells_number: - name: Cells Number - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - -text_sensor: - - platform: daly_bms - status: - name: BMS Status +<<: !include common.yaml diff --git a/tests/components/deep_sleep/common-esp32.yaml b/tests/components/deep_sleep/common-esp32.yaml new file mode 100644 index 0000000000..c20e1a902e --- /dev/null +++ b/tests/components/deep_sleep/common-esp32.yaml @@ -0,0 +1,7 @@ +deep_sleep: + run_duration: + default: 10s + gpio_wakeup_reason: 30s + sleep_duration: 50s + wakeup_pin: ${wakeup_pin} + wakeup_pin_mode: INVERT_WAKEUP diff --git a/tests/components/deep_sleep/common.yaml b/tests/components/deep_sleep/common.yaml new file mode 100644 index 0000000000..c090cb83e2 --- /dev/null +++ b/tests/components/deep_sleep/common.yaml @@ -0,0 +1,6 @@ +esphome: + on_boot: + then: + - deep_sleep.prevent + - delay: 1s + - deep_sleep.allow diff --git a/tests/components/deep_sleep/test.esp32-ard.yaml b/tests/components/deep_sleep/test.esp32-ard.yaml index 94942fd5b0..10c17af0f5 100644 --- a/tests/components/deep_sleep/test.esp32-ard.yaml +++ b/tests/components/deep_sleep/test.esp32-ard.yaml @@ -1,14 +1,5 @@ -esphome: - on_boot: - then: - - deep_sleep.prevent - - delay: 1s - - deep_sleep.allow +substitutions: + wakeup_pin: GPIO4 -deep_sleep: - run_duration: - default: 10s - gpio_wakeup_reason: 30s - sleep_duration: 50s - wakeup_pin: 4 - wakeup_pin_mode: INVERT_WAKEUP +<<: !include common.yaml +<<: !include common-esp32.yaml diff --git a/tests/components/deep_sleep/test.esp32-c3-ard.yaml b/tests/components/deep_sleep/test.esp32-c3-ard.yaml index 94942fd5b0..10c17af0f5 100644 --- a/tests/components/deep_sleep/test.esp32-c3-ard.yaml +++ b/tests/components/deep_sleep/test.esp32-c3-ard.yaml @@ -1,14 +1,5 @@ -esphome: - on_boot: - then: - - deep_sleep.prevent - - delay: 1s - - deep_sleep.allow +substitutions: + wakeup_pin: GPIO4 -deep_sleep: - run_duration: - default: 10s - gpio_wakeup_reason: 30s - sleep_duration: 50s - wakeup_pin: 4 - wakeup_pin_mode: INVERT_WAKEUP +<<: !include common.yaml +<<: !include common-esp32.yaml diff --git a/tests/components/deep_sleep/test.esp32-c3-idf.yaml b/tests/components/deep_sleep/test.esp32-c3-idf.yaml index 94942fd5b0..10c17af0f5 100644 --- a/tests/components/deep_sleep/test.esp32-c3-idf.yaml +++ b/tests/components/deep_sleep/test.esp32-c3-idf.yaml @@ -1,14 +1,5 @@ -esphome: - on_boot: - then: - - deep_sleep.prevent - - delay: 1s - - deep_sleep.allow +substitutions: + wakeup_pin: GPIO4 -deep_sleep: - run_duration: - default: 10s - gpio_wakeup_reason: 30s - sleep_duration: 50s - wakeup_pin: 4 - wakeup_pin_mode: INVERT_WAKEUP +<<: !include common.yaml +<<: !include common-esp32.yaml diff --git a/tests/components/deep_sleep/test.esp32-idf.yaml b/tests/components/deep_sleep/test.esp32-idf.yaml index 94942fd5b0..10c17af0f5 100644 --- a/tests/components/deep_sleep/test.esp32-idf.yaml +++ b/tests/components/deep_sleep/test.esp32-idf.yaml @@ -1,14 +1,5 @@ -esphome: - on_boot: - then: - - deep_sleep.prevent - - delay: 1s - - deep_sleep.allow +substitutions: + wakeup_pin: GPIO4 -deep_sleep: - run_duration: - default: 10s - gpio_wakeup_reason: 30s - sleep_duration: 50s - wakeup_pin: 4 - wakeup_pin_mode: INVERT_WAKEUP +<<: !include common.yaml +<<: !include common-esp32.yaml diff --git a/tests/components/deep_sleep/test.esp8266-ard.yaml b/tests/components/deep_sleep/test.esp8266-ard.yaml index 0992fa9696..df08ec8a14 100644 --- a/tests/components/deep_sleep/test.esp8266-ard.yaml +++ b/tests/components/deep_sleep/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -esphome: - on_boot: - then: - - deep_sleep.prevent - - delay: 1s - - deep_sleep.allow - deep_sleep: run_duration: 10s sleep_duration: 50s + +<<: !include common.yaml diff --git a/tests/components/delonghi/common.yaml b/tests/components/delonghi/common.yaml new file mode 100644 index 0000000000..8e9a1293d7 --- /dev/null +++ b/tests/components/delonghi/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: delonghi + name: Delonghi Climate diff --git a/tests/components/delonghi/test.esp32-ard.yaml b/tests/components/delonghi/test.esp32-ard.yaml index cfe0f837f0..7b012aa64c 100644 --- a/tests/components/delonghi/test.esp32-ard.yaml +++ b/tests/components/delonghi/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: delonghi - name: Delonghi Climate +<<: !include common.yaml diff --git a/tests/components/delonghi/test.esp32-c3-ard.yaml b/tests/components/delonghi/test.esp32-c3-ard.yaml index cfe0f837f0..7b012aa64c 100644 --- a/tests/components/delonghi/test.esp32-c3-ard.yaml +++ b/tests/components/delonghi/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: delonghi - name: Delonghi Climate +<<: !include common.yaml diff --git a/tests/components/delonghi/test.esp32-c3-idf.yaml b/tests/components/delonghi/test.esp32-c3-idf.yaml index cfe0f837f0..7b012aa64c 100644 --- a/tests/components/delonghi/test.esp32-c3-idf.yaml +++ b/tests/components/delonghi/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: delonghi - name: Delonghi Climate +<<: !include common.yaml diff --git a/tests/components/delonghi/test.esp32-idf.yaml b/tests/components/delonghi/test.esp32-idf.yaml index cfe0f837f0..7b012aa64c 100644 --- a/tests/components/delonghi/test.esp32-idf.yaml +++ b/tests/components/delonghi/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: delonghi - name: Delonghi Climate +<<: !include common.yaml diff --git a/tests/components/delonghi/test.esp8266-ard.yaml b/tests/components/delonghi/test.esp8266-ard.yaml index adc478a6e6..f5097fcf5f 100644 --- a/tests/components/delonghi/test.esp8266-ard.yaml +++ b/tests/components/delonghi/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: delonghi - name: Delonghi Climate +<<: !include common.yaml diff --git a/tests/components/dfplayer/common.yaml b/tests/components/dfplayer/common.yaml new file mode 100644 index 0000000000..d7446141c3 --- /dev/null +++ b/tests/components/dfplayer/common.yaml @@ -0,0 +1,42 @@ +esphome: + on_boot: + then: + - dfplayer.play: 5 + - dfplayer.play: + file: 4 + loop: true + - dfplayer.play_folder: + folder: 1 + file: 3 + - dfplayer.play_folder: + folder: 1 + loop: true + - dfplayer.set_device: + device: TF_CARD + - dfplayer.set_volume: 5 + - dfplayer.set_eq: ROCK + - dfplayer.play_next + - dfplayer.play_previous + - dfplayer.reset + - dfplayer.start + - dfplayer.pause + - dfplayer.stop + - dfplayer.random + - dfplayer.volume_up + - dfplayer.volume_down + - dfplayer.sleep + +uart: + - id: uart_dfplayer + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +dfplayer: + on_finished_playback: + then: + if: + condition: + not: dfplayer.is_playing + then: + logger.log: Playback finished event diff --git a/tests/components/dfplayer/test.esp32-ard.yaml b/tests/components/dfplayer/test.esp32-ard.yaml index 03b44b8ca9..811f6b72a6 100644 --- a/tests/components/dfplayer/test.esp32-ard.yaml +++ b/tests/components/dfplayer/test.esp32-ard.yaml @@ -1,42 +1,5 @@ -esphome: - on_boot: - then: - - dfplayer.play: 5 - - dfplayer.play: - file: 4 - loop: true - - dfplayer.play_folder: - folder: 1 - file: 3 - - dfplayer.play_folder: - folder: 1 - loop: true - - dfplayer.set_device: - device: TF_CARD - - dfplayer.set_volume: 5 - - dfplayer.set_eq: ROCK - - dfplayer.play_next - - dfplayer.play_previous - - dfplayer.reset - - dfplayer.start - - dfplayer.pause - - dfplayer.stop - - dfplayer.random - - dfplayer.volume_up - - dfplayer.volume_down - - dfplayer.sleep +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -uart: - - id: uart_dfplayer - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -dfplayer: - on_finished_playback: - then: - if: - condition: - not: dfplayer.is_playing - then: - logger.log: Playback finished event +<<: !include common.yaml diff --git a/tests/components/dfplayer/test.esp32-c3-ard.yaml b/tests/components/dfplayer/test.esp32-c3-ard.yaml index 94355915a7..c79d14c740 100644 --- a/tests/components/dfplayer/test.esp32-c3-ard.yaml +++ b/tests/components/dfplayer/test.esp32-c3-ard.yaml @@ -1,42 +1,5 @@ -esphome: - on_boot: - then: - - dfplayer.play: 5 - - dfplayer.play: - file: 4 - loop: true - - dfplayer.play_folder: - folder: 1 - file: 3 - - dfplayer.play_folder: - folder: 1 - loop: true - - dfplayer.set_device: - device: TF_CARD - - dfplayer.set_volume: 5 - - dfplayer.set_eq: ROCK - - dfplayer.play_next - - dfplayer.play_previous - - dfplayer.reset - - dfplayer.start - - dfplayer.pause - - dfplayer.stop - - dfplayer.random - - dfplayer.volume_up - - dfplayer.volume_down - - dfplayer.sleep +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -uart: - - id: uart_dfplayer - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -dfplayer: - on_finished_playback: - then: - if: - condition: - not: dfplayer.is_playing - then: - logger.log: Playback finished event +<<: !include common.yaml diff --git a/tests/components/dfplayer/test.esp32-c3-idf.yaml b/tests/components/dfplayer/test.esp32-c3-idf.yaml index 94355915a7..c79d14c740 100644 --- a/tests/components/dfplayer/test.esp32-c3-idf.yaml +++ b/tests/components/dfplayer/test.esp32-c3-idf.yaml @@ -1,42 +1,5 @@ -esphome: - on_boot: - then: - - dfplayer.play: 5 - - dfplayer.play: - file: 4 - loop: true - - dfplayer.play_folder: - folder: 1 - file: 3 - - dfplayer.play_folder: - folder: 1 - loop: true - - dfplayer.set_device: - device: TF_CARD - - dfplayer.set_volume: 5 - - dfplayer.set_eq: ROCK - - dfplayer.play_next - - dfplayer.play_previous - - dfplayer.reset - - dfplayer.start - - dfplayer.pause - - dfplayer.stop - - dfplayer.random - - dfplayer.volume_up - - dfplayer.volume_down - - dfplayer.sleep +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -uart: - - id: uart_dfplayer - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -dfplayer: - on_finished_playback: - then: - if: - condition: - not: dfplayer.is_playing - then: - logger.log: Playback finished event +<<: !include common.yaml diff --git a/tests/components/dfplayer/test.esp32-idf.yaml b/tests/components/dfplayer/test.esp32-idf.yaml index 03b44b8ca9..811f6b72a6 100644 --- a/tests/components/dfplayer/test.esp32-idf.yaml +++ b/tests/components/dfplayer/test.esp32-idf.yaml @@ -1,42 +1,5 @@ -esphome: - on_boot: - then: - - dfplayer.play: 5 - - dfplayer.play: - file: 4 - loop: true - - dfplayer.play_folder: - folder: 1 - file: 3 - - dfplayer.play_folder: - folder: 1 - loop: true - - dfplayer.set_device: - device: TF_CARD - - dfplayer.set_volume: 5 - - dfplayer.set_eq: ROCK - - dfplayer.play_next - - dfplayer.play_previous - - dfplayer.reset - - dfplayer.start - - dfplayer.pause - - dfplayer.stop - - dfplayer.random - - dfplayer.volume_up - - dfplayer.volume_down - - dfplayer.sleep +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -uart: - - id: uart_dfplayer - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -dfplayer: - on_finished_playback: - then: - if: - condition: - not: dfplayer.is_playing - then: - logger.log: Playback finished event +<<: !include common.yaml diff --git a/tests/components/dfplayer/test.esp8266-ard.yaml b/tests/components/dfplayer/test.esp8266-ard.yaml index 94355915a7..3b44f9c9c3 100644 --- a/tests/components/dfplayer/test.esp8266-ard.yaml +++ b/tests/components/dfplayer/test.esp8266-ard.yaml @@ -1,42 +1,5 @@ -esphome: - on_boot: - then: - - dfplayer.play: 5 - - dfplayer.play: - file: 4 - loop: true - - dfplayer.play_folder: - folder: 1 - file: 3 - - dfplayer.play_folder: - folder: 1 - loop: true - - dfplayer.set_device: - device: TF_CARD - - dfplayer.set_volume: 5 - - dfplayer.set_eq: ROCK - - dfplayer.play_next - - dfplayer.play_previous - - dfplayer.reset - - dfplayer.start - - dfplayer.pause - - dfplayer.stop - - dfplayer.random - - dfplayer.volume_up - - dfplayer.volume_down - - dfplayer.sleep +substitutions: + tx_pin: GPIO1 + rx_pin: GPIO3 -uart: - - id: uart_dfplayer - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -dfplayer: - on_finished_playback: - then: - if: - condition: - not: dfplayer.is_playing - then: - logger.log: Playback finished event +<<: !include common.yaml diff --git a/tests/components/dfplayer/test.rp2040-ard.yaml b/tests/components/dfplayer/test.rp2040-ard.yaml index 94355915a7..b516342f3b 100644 --- a/tests/components/dfplayer/test.rp2040-ard.yaml +++ b/tests/components/dfplayer/test.rp2040-ard.yaml @@ -1,42 +1,5 @@ -esphome: - on_boot: - then: - - dfplayer.play: 5 - - dfplayer.play: - file: 4 - loop: true - - dfplayer.play_folder: - folder: 1 - file: 3 - - dfplayer.play_folder: - folder: 1 - loop: true - - dfplayer.set_device: - device: TF_CARD - - dfplayer.set_volume: 5 - - dfplayer.set_eq: ROCK - - dfplayer.play_next - - dfplayer.play_previous - - dfplayer.reset - - dfplayer.start - - dfplayer.pause - - dfplayer.stop - - dfplayer.random - - dfplayer.volume_up - - dfplayer.volume_down - - dfplayer.sleep +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_dfplayer - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -dfplayer: - on_finished_playback: - then: - if: - condition: - not: dfplayer.is_playing - then: - logger.log: Playback finished event +<<: !include common.yaml diff --git a/tests/components/dfrobot_sen0395/common.yaml b/tests/components/dfrobot_sen0395/common.yaml new file mode 100644 index 0000000000..69bcebf182 --- /dev/null +++ b/tests/components/dfrobot_sen0395/common.yaml @@ -0,0 +1,28 @@ +esphome: + on_boot: + then: + - dfrobot_sen0395.settings: + id: mmwave + factory_reset: true + detection_segments: + - [0cm, 5m] + - 600cm + - !lambda "return 7;" + output_latency: + delay_after_detect: 0s + delay_after_disappear: 0s + sensitivity: 6 + - dfrobot_sen0395.reset + +uart: + - id: uart_dfrobot_sen0395 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +dfrobot_sen0395: + - id: mmwave + +binary_sensor: + - platform: dfrobot_sen0395 + id: mmwave_detected diff --git a/tests/components/dfrobot_sen0395/test.esp32-ard.yaml b/tests/components/dfrobot_sen0395/test.esp32-ard.yaml index 5c06fc6660..811f6b72a6 100644 --- a/tests/components/dfrobot_sen0395/test.esp32-ard.yaml +++ b/tests/components/dfrobot_sen0395/test.esp32-ard.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - dfrobot_sen0395.settings: - id: mmwave - factory_reset: true - detection_segments: - - [0cm, 5m] - - 600cm - - !lambda "return 7;" - output_latency: - delay_after_detect: 0s - delay_after_disappear: 0s - sensitivity: 6 - - dfrobot_sen0395.reset +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -uart: - - id: uart_dfrobot_sen0395 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -dfrobot_sen0395: - - id: mmwave - -binary_sensor: - - platform: dfrobot_sen0395 - id: mmwave_detected +<<: !include common.yaml diff --git a/tests/components/dfrobot_sen0395/test.esp32-c3-ard.yaml b/tests/components/dfrobot_sen0395/test.esp32-c3-ard.yaml index 71b17cecd5..c79d14c740 100644 --- a/tests/components/dfrobot_sen0395/test.esp32-c3-ard.yaml +++ b/tests/components/dfrobot_sen0395/test.esp32-c3-ard.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - dfrobot_sen0395.settings: - id: mmwave - factory_reset: true - detection_segments: - - [0cm, 5m] - - 600cm - - !lambda "return 7;" - output_latency: - delay_after_detect: 0s - delay_after_disappear: 0s - sensitivity: 6 - - dfrobot_sen0395.reset +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -uart: - - id: uart_dfrobot_sen0395 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -dfrobot_sen0395: - - id: mmwave - -binary_sensor: - - platform: dfrobot_sen0395 - id: mmwave_detected +<<: !include common.yaml diff --git a/tests/components/dfrobot_sen0395/test.esp32-c3-idf.yaml b/tests/components/dfrobot_sen0395/test.esp32-c3-idf.yaml index 71b17cecd5..c79d14c740 100644 --- a/tests/components/dfrobot_sen0395/test.esp32-c3-idf.yaml +++ b/tests/components/dfrobot_sen0395/test.esp32-c3-idf.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - dfrobot_sen0395.settings: - id: mmwave - factory_reset: true - detection_segments: - - [0cm, 5m] - - 600cm - - !lambda "return 7;" - output_latency: - delay_after_detect: 0s - delay_after_disappear: 0s - sensitivity: 6 - - dfrobot_sen0395.reset +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -uart: - - id: uart_dfrobot_sen0395 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -dfrobot_sen0395: - - id: mmwave - -binary_sensor: - - platform: dfrobot_sen0395 - id: mmwave_detected +<<: !include common.yaml diff --git a/tests/components/dfrobot_sen0395/test.esp32-idf.yaml b/tests/components/dfrobot_sen0395/test.esp32-idf.yaml index 5c06fc6660..811f6b72a6 100644 --- a/tests/components/dfrobot_sen0395/test.esp32-idf.yaml +++ b/tests/components/dfrobot_sen0395/test.esp32-idf.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - dfrobot_sen0395.settings: - id: mmwave - factory_reset: true - detection_segments: - - [0cm, 5m] - - 600cm - - !lambda "return 7;" - output_latency: - delay_after_detect: 0s - delay_after_disappear: 0s - sensitivity: 6 - - dfrobot_sen0395.reset +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -uart: - - id: uart_dfrobot_sen0395 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -dfrobot_sen0395: - - id: mmwave - -binary_sensor: - - platform: dfrobot_sen0395 - id: mmwave_detected +<<: !include common.yaml diff --git a/tests/components/dfrobot_sen0395/test.esp8266-ard.yaml b/tests/components/dfrobot_sen0395/test.esp8266-ard.yaml index 71b17cecd5..3b44f9c9c3 100644 --- a/tests/components/dfrobot_sen0395/test.esp8266-ard.yaml +++ b/tests/components/dfrobot_sen0395/test.esp8266-ard.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - dfrobot_sen0395.settings: - id: mmwave - factory_reset: true - detection_segments: - - [0cm, 5m] - - 600cm - - !lambda "return 7;" - output_latency: - delay_after_detect: 0s - delay_after_disappear: 0s - sensitivity: 6 - - dfrobot_sen0395.reset +substitutions: + tx_pin: GPIO1 + rx_pin: GPIO3 -uart: - - id: uart_dfrobot_sen0395 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -dfrobot_sen0395: - - id: mmwave - -binary_sensor: - - platform: dfrobot_sen0395 - id: mmwave_detected +<<: !include common.yaml diff --git a/tests/components/dfrobot_sen0395/test.rp2040-ard.yaml b/tests/components/dfrobot_sen0395/test.rp2040-ard.yaml index 71b17cecd5..b516342f3b 100644 --- a/tests/components/dfrobot_sen0395/test.rp2040-ard.yaml +++ b/tests/components/dfrobot_sen0395/test.rp2040-ard.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - dfrobot_sen0395.settings: - id: mmwave - factory_reset: true - detection_segments: - - [0cm, 5m] - - 600cm - - !lambda "return 7;" - output_latency: - delay_after_detect: 0s - delay_after_disappear: 0s - sensitivity: 6 - - dfrobot_sen0395.reset +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_dfrobot_sen0395 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -dfrobot_sen0395: - - id: mmwave - -binary_sensor: - - platform: dfrobot_sen0395 - id: mmwave_detected +<<: !include common.yaml diff --git a/tests/components/dht12/common.yaml b/tests/components/dht12/common.yaml new file mode 100644 index 0000000000..91346e0e27 --- /dev/null +++ b/tests/components/dht12/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_dht12 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: dht12 + temperature: + name: DHT12 Temperature + humidity: + name: DHT12 Humidity + update_interval: 15s diff --git a/tests/components/dht12/test.esp32-ard.yaml b/tests/components/dht12/test.esp32-ard.yaml index 02a00f5df7..63c3bd6afd 100644 --- a/tests/components/dht12/test.esp32-ard.yaml +++ b/tests/components/dht12/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dht12 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: dht12 - temperature: - name: DHT12 Temperature - humidity: - name: DHT12 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/dht12/test.esp32-c3-ard.yaml b/tests/components/dht12/test.esp32-c3-ard.yaml index c06c20fd9f..ee2c29ca4e 100644 --- a/tests/components/dht12/test.esp32-c3-ard.yaml +++ b/tests/components/dht12/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dht12 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: dht12 - temperature: - name: DHT12 Temperature - humidity: - name: DHT12 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/dht12/test.esp32-c3-idf.yaml b/tests/components/dht12/test.esp32-c3-idf.yaml index c06c20fd9f..ee2c29ca4e 100644 --- a/tests/components/dht12/test.esp32-c3-idf.yaml +++ b/tests/components/dht12/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dht12 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: dht12 - temperature: - name: DHT12 Temperature - humidity: - name: DHT12 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/dht12/test.esp32-idf.yaml b/tests/components/dht12/test.esp32-idf.yaml index 02a00f5df7..63c3bd6afd 100644 --- a/tests/components/dht12/test.esp32-idf.yaml +++ b/tests/components/dht12/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dht12 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: dht12 - temperature: - name: DHT12 Temperature - humidity: - name: DHT12 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/dht12/test.esp8266-ard.yaml b/tests/components/dht12/test.esp8266-ard.yaml index c06c20fd9f..ee2c29ca4e 100644 --- a/tests/components/dht12/test.esp8266-ard.yaml +++ b/tests/components/dht12/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dht12 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: dht12 - temperature: - name: DHT12 Temperature - humidity: - name: DHT12 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/dht12/test.rp2040-ard.yaml b/tests/components/dht12/test.rp2040-ard.yaml index c06c20fd9f..ee2c29ca4e 100644 --- a/tests/components/dht12/test.rp2040-ard.yaml +++ b/tests/components/dht12/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dht12 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: dht12 - temperature: - name: DHT12 Temperature - humidity: - name: DHT12 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/dps310/common.yaml b/tests/components/dps310/common.yaml new file mode 100644 index 0000000000..e6c0c9fab8 --- /dev/null +++ b/tests/components/dps310/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_dps310 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: dps310 + temperature: + name: DPS310 Temperature + pressure: + name: DPS310 Pressure + address: 0x77 diff --git a/tests/components/dps310/test.esp32-ard.yaml b/tests/components/dps310/test.esp32-ard.yaml index 417cab5c40..63c3bd6afd 100644 --- a/tests/components/dps310/test.esp32-ard.yaml +++ b/tests/components/dps310/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dps310 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: dps310 - temperature: - name: DPS310 Temperature - pressure: - name: DPS310 Pressure - address: 0x77 +<<: !include common.yaml diff --git a/tests/components/dps310/test.esp32-c3-ard.yaml b/tests/components/dps310/test.esp32-c3-ard.yaml index 0e15e9ccc5..ee2c29ca4e 100644 --- a/tests/components/dps310/test.esp32-c3-ard.yaml +++ b/tests/components/dps310/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dps310 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: dps310 - temperature: - name: DPS310 Temperature - pressure: - name: DPS310 Pressure - address: 0x77 +<<: !include common.yaml diff --git a/tests/components/dps310/test.esp32-c3-idf.yaml b/tests/components/dps310/test.esp32-c3-idf.yaml index 0e15e9ccc5..ee2c29ca4e 100644 --- a/tests/components/dps310/test.esp32-c3-idf.yaml +++ b/tests/components/dps310/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dps310 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: dps310 - temperature: - name: DPS310 Temperature - pressure: - name: DPS310 Pressure - address: 0x77 +<<: !include common.yaml diff --git a/tests/components/dps310/test.esp32-idf.yaml b/tests/components/dps310/test.esp32-idf.yaml index 417cab5c40..63c3bd6afd 100644 --- a/tests/components/dps310/test.esp32-idf.yaml +++ b/tests/components/dps310/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dps310 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: dps310 - temperature: - name: DPS310 Temperature - pressure: - name: DPS310 Pressure - address: 0x77 +<<: !include common.yaml diff --git a/tests/components/dps310/test.esp8266-ard.yaml b/tests/components/dps310/test.esp8266-ard.yaml index 0e15e9ccc5..ee2c29ca4e 100644 --- a/tests/components/dps310/test.esp8266-ard.yaml +++ b/tests/components/dps310/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dps310 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: dps310 - temperature: - name: DPS310 Temperature - pressure: - name: DPS310 Pressure - address: 0x77 +<<: !include common.yaml diff --git a/tests/components/dps310/test.rp2040-ard.yaml b/tests/components/dps310/test.rp2040-ard.yaml index 0e15e9ccc5..ee2c29ca4e 100644 --- a/tests/components/dps310/test.rp2040-ard.yaml +++ b/tests/components/dps310/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_dps310 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: dps310 - temperature: - name: DPS310 Temperature - pressure: - name: DPS310 Pressure - address: 0x77 +<<: !include common.yaml diff --git a/tests/components/ds1307/common.yaml b/tests/components/ds1307/common.yaml new file mode 100644 index 0000000000..3466a9eec8 --- /dev/null +++ b/tests/components/ds1307/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_ds1307 + scl: ${scl_pin} + sda: ${sda_pin} + +time: + - platform: ds1307 + id: ds1307_time + update_interval: never diff --git a/tests/components/ds1307/test.esp32-ard.yaml b/tests/components/ds1307/test.esp32-ard.yaml index 017c7aac92..63c3bd6afd 100644 --- a/tests/components/ds1307/test.esp32-ard.yaml +++ b/tests/components/ds1307/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_ds1307 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -time: - - platform: ds1307 - id: ds1307_time - update_interval: never +<<: !include common.yaml diff --git a/tests/components/ds1307/test.esp32-c3-ard.yaml b/tests/components/ds1307/test.esp32-c3-ard.yaml index c309b9c212..ee2c29ca4e 100644 --- a/tests/components/ds1307/test.esp32-c3-ard.yaml +++ b/tests/components/ds1307/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_ds1307 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -time: - - platform: ds1307 - id: ds1307_time - update_interval: never +<<: !include common.yaml diff --git a/tests/components/ds1307/test.esp32-c3-idf.yaml b/tests/components/ds1307/test.esp32-c3-idf.yaml index c309b9c212..ee2c29ca4e 100644 --- a/tests/components/ds1307/test.esp32-c3-idf.yaml +++ b/tests/components/ds1307/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_ds1307 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -time: - - platform: ds1307 - id: ds1307_time - update_interval: never +<<: !include common.yaml diff --git a/tests/components/ds1307/test.esp32-idf.yaml b/tests/components/ds1307/test.esp32-idf.yaml index 017c7aac92..63c3bd6afd 100644 --- a/tests/components/ds1307/test.esp32-idf.yaml +++ b/tests/components/ds1307/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_ds1307 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -time: - - platform: ds1307 - id: ds1307_time - update_interval: never +<<: !include common.yaml diff --git a/tests/components/ds1307/test.esp8266-ard.yaml b/tests/components/ds1307/test.esp8266-ard.yaml index c309b9c212..ee2c29ca4e 100644 --- a/tests/components/ds1307/test.esp8266-ard.yaml +++ b/tests/components/ds1307/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_ds1307 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -time: - - platform: ds1307 - id: ds1307_time - update_interval: never +<<: !include common.yaml diff --git a/tests/components/ds1307/test.rp2040-ard.yaml b/tests/components/ds1307/test.rp2040-ard.yaml index c309b9c212..ee2c29ca4e 100644 --- a/tests/components/ds1307/test.rp2040-ard.yaml +++ b/tests/components/ds1307/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_ds1307 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -time: - - platform: ds1307 - id: ds1307_time - update_interval: never +<<: !include common.yaml diff --git a/tests/components/dsmr/common.yaml b/tests/components/dsmr/common.yaml new file mode 100644 index 0000000000..2901b811fe --- /dev/null +++ b/tests/components/dsmr/common.yaml @@ -0,0 +1,12 @@ +uart: + - id: uart_dsmr + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +dsmr: + decryption_key: 00112233445566778899aabbccddeeff + max_telegram_length: 1000 + request_pin: ${request_pin} + request_interval: 20s + receive_timeout: 100ms diff --git a/tests/components/dsmr/test.esp32-ard.yaml b/tests/components/dsmr/test.esp32-ard.yaml index 1fd0448ab3..7a65a48ec0 100644 --- a/tests/components/dsmr/test.esp32-ard.yaml +++ b/tests/components/dsmr/test.esp32-ard.yaml @@ -1,12 +1,6 @@ -uart: - - id: uart_dsmr - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + request_pin: GPIO15 -dsmr: - decryption_key: 00112233445566778899aabbccddeeff - max_telegram_length: 1000 - request_pin: 15 - request_interval: 20s - receive_timeout: 100ms +<<: !include common.yaml diff --git a/tests/components/dsmr/test.esp32-c3-ard.yaml b/tests/components/dsmr/test.esp32-c3-ard.yaml index e813556be8..72998506ac 100644 --- a/tests/components/dsmr/test.esp32-c3-ard.yaml +++ b/tests/components/dsmr/test.esp32-c3-ard.yaml @@ -1,12 +1,6 @@ -uart: - - id: uart_dsmr - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + request_pin: GPIO6 -dsmr: - decryption_key: 00112233445566778899aabbccddeeff - max_telegram_length: 1000 - request_pin: 6 - request_interval: 20s - receive_timeout: 100ms +<<: !include common.yaml diff --git a/tests/components/dsmr/test.esp8266-ard.yaml b/tests/components/dsmr/test.esp8266-ard.yaml index 8037fb4b1a..a47bd58806 100644 --- a/tests/components/dsmr/test.esp8266-ard.yaml +++ b/tests/components/dsmr/test.esp8266-ard.yaml @@ -1,12 +1,6 @@ -uart: - - id: uart_dsmr - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + request_pin: GPIO15 -dsmr: - decryption_key: 00112233445566778899aabbccddeeff - max_telegram_length: 1000 - request_pin: 15 - request_interval: 20s - receive_timeout: 100ms +<<: !include common.yaml diff --git a/tests/components/dsmr/test.rp2040-ard.yaml b/tests/components/dsmr/test.rp2040-ard.yaml index e813556be8..72998506ac 100644 --- a/tests/components/dsmr/test.rp2040-ard.yaml +++ b/tests/components/dsmr/test.rp2040-ard.yaml @@ -1,12 +1,6 @@ -uart: - - id: uart_dsmr - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + request_pin: GPIO6 -dsmr: - decryption_key: 00112233445566778899aabbccddeeff - max_telegram_length: 1000 - request_pin: 6 - request_interval: 20s - receive_timeout: 100ms +<<: !include common.yaml From 06f9764f5180cc75dca186491fe24710a53b4942 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:05:24 -0600 Subject: [PATCH 148/194] [CI] Consolidate some tests (E) (#8191) --- tests/components/e131/common-ard.yaml | 14 ++++ tests/components/e131/common-idf.yaml | 13 ++++ tests/components/e131/common.yaml | 5 ++ tests/components/e131/test.esp32-ard.yaml | 21 ++---- tests/components/e131/test.esp32-c3-ard.yaml | 21 ++---- tests/components/e131/test.esp32-c3-idf.yaml | 20 ++---- tests/components/e131/test.esp32-idf.yaml | 20 ++---- tests/components/e131/test.esp8266-ard.yaml | 6 +- tests/components/e131/test.rp2040-ard.yaml | 6 +- tests/components/ee895/common.yaml | 14 ++++ tests/components/ee895/test.esp32-ard.yaml | 17 ++--- tests/components/ee895/test.esp32-c3-ard.yaml | 17 ++--- tests/components/ee895/test.esp32-c3-idf.yaml | 17 ++--- tests/components/ee895/test.esp32-idf.yaml | 17 ++--- tests/components/ee895/test.esp8266-ard.yaml | 17 ++--- tests/components/ee895/test.rp2040-ard.yaml | 17 ++--- tests/components/ektf2232/common.yaml | 24 +++++++ tests/components/ektf2232/test.esp32-ard.yaml | 30 ++------- .../ektf2232/test.esp32-c3-ard.yaml | 30 ++------- .../ektf2232/test.esp32-c3-idf.yaml | 30 ++------- tests/components/ektf2232/test.esp32-idf.yaml | 30 ++------- .../components/ektf2232/test.esp8266-ard.yaml | 30 ++------- .../components/ektf2232/test.rp2040-ard.yaml | 30 ++------- tests/components/emc2101/common.yaml | 25 ++++++++ tests/components/emc2101/test.esp32-ard.yaml | 28 ++------ .../components/emc2101/test.esp32-c3-ard.yaml | 28 ++------ .../components/emc2101/test.esp32-c3-idf.yaml | 28 ++------ tests/components/emc2101/test.esp32-idf.yaml | 28 ++------ .../components/emc2101/test.esp8266-ard.yaml | 28 ++------ tests/components/emc2101/test.rp2040-ard.yaml | 28 ++------ tests/components/ens210/common.yaml | 12 ++++ tests/components/ens210/test.esp32-ard.yaml | 15 ++--- .../components/ens210/test.esp32-c3-ard.yaml | 15 ++--- .../components/ens210/test.esp32-c3-idf.yaml | 15 ++--- tests/components/ens210/test.esp32-idf.yaml | 15 ++--- tests/components/ens210/test.esp8266-ard.yaml | 15 ++--- tests/components/ens210/test.rp2040-ard.yaml | 15 ++--- tests/components/esp32_can/common.yaml | 45 +++++++++++++ .../components/esp32_can/test.esp32-ard.yaml | 48 ++------------ .../esp32_can/test.esp32-c3-ard.yaml | 48 ++------------ .../esp32_can/test.esp32-c3-idf.yaml | 48 ++------------ .../components/esp32_can/test.esp32-idf.yaml | 48 ++------------ .../esp32_rmt_led_strip/common-ard.yaml | 18 ++++++ .../esp32_rmt_led_strip/common-idf.yaml | 16 +++++ .../esp32_rmt_led_strip/test.esp32-ard.yaml | 23 ++----- .../test.esp32-c3-ard.yaml | 23 ++----- .../test.esp32-c3-idf.yaml | 21 ++---- .../esp32_rmt_led_strip/test.esp32-idf.yaml | 21 ++---- tests/components/ezo/common.yaml | 10 +++ tests/components/ezo/test.esp32-ard.yaml | 13 ++-- tests/components/ezo/test.esp32-c3-ard.yaml | 13 ++-- tests/components/ezo/test.esp32-c3-idf.yaml | 13 ++-- tests/components/ezo/test.esp32-idf.yaml | 13 ++-- tests/components/ezo/test.esp8266-ard.yaml | 13 ++-- tests/components/ezo/test.rp2040-ard.yaml | 13 ++-- tests/components/ezo_pmp/common.yaml | 61 ++++++++++++++++++ tests/components/ezo_pmp/test.esp32-ard.yaml | 64 ++----------------- .../components/ezo_pmp/test.esp32-c3-ard.yaml | 64 ++----------------- .../components/ezo_pmp/test.esp32-c3-idf.yaml | 64 ++----------------- tests/components/ezo_pmp/test.esp32-idf.yaml | 64 ++----------------- .../components/ezo_pmp/test.esp8266-ard.yaml | 64 ++----------------- tests/components/ezo_pmp/test.rp2040-ard.yaml | 64 ++----------------- 62 files changed, 473 insertions(+), 1160 deletions(-) create mode 100644 tests/components/e131/common-ard.yaml create mode 100644 tests/components/e131/common-idf.yaml create mode 100644 tests/components/e131/common.yaml create mode 100644 tests/components/ee895/common.yaml create mode 100644 tests/components/ektf2232/common.yaml create mode 100644 tests/components/emc2101/common.yaml create mode 100644 tests/components/ens210/common.yaml create mode 100644 tests/components/esp32_can/common.yaml create mode 100644 tests/components/esp32_rmt_led_strip/common-ard.yaml create mode 100644 tests/components/esp32_rmt_led_strip/common-idf.yaml create mode 100644 tests/components/ezo/common.yaml create mode 100644 tests/components/ezo_pmp/common.yaml diff --git a/tests/components/e131/common-ard.yaml b/tests/components/e131/common-ard.yaml new file mode 100644 index 0000000000..418453d6ef --- /dev/null +++ b/tests/components/e131/common-ard.yaml @@ -0,0 +1,14 @@ +<<: !include common.yaml + +light: + - platform: ${light_platform} + id: led_matrix_32x8 + default_transition_length: 500ms + chipset: ws2812 + rgb_order: GRB + num_leds: 256 + pin: ${pin} + rmt_channel: 0 + effects: + - e131: + universe: 1 diff --git a/tests/components/e131/common-idf.yaml b/tests/components/e131/common-idf.yaml new file mode 100644 index 0000000000..8300dbb01b --- /dev/null +++ b/tests/components/e131/common-idf.yaml @@ -0,0 +1,13 @@ +<<: !include common.yaml + +light: + - platform: ${light_platform} + id: led_matrix_32x8 + default_transition_length: 500ms + chipset: ws2812 + rgb_order: GRB + num_leds: 256 + pin: ${pin} + effects: + - e131: + universe: 1 diff --git a/tests/components/e131/common.yaml b/tests/components/e131/common.yaml new file mode 100644 index 0000000000..55e42dbc5a --- /dev/null +++ b/tests/components/e131/common.yaml @@ -0,0 +1,5 @@ +wifi: + ssid: MySSID + password: password1 + +e131: diff --git a/tests/components/e131/test.esp32-ard.yaml b/tests/components/e131/test.esp32-ard.yaml index 25304cd3b4..32cf2a64ba 100644 --- a/tests/components/e131/test.esp32-ard.yaml +++ b/tests/components/e131/test.esp32-ard.yaml @@ -1,18 +1,5 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + light_platform: esp32_rmt_led_strip + pin: GPIO2 -e131: - -light: - - platform: esp32_rmt_led_strip - id: led_matrix_32x8 - default_transition_length: 500ms - chipset: ws2812 - rgb_order: GRB - num_leds: 256 - pin: 2 - rmt_channel: 0 - effects: - - e131: - universe: 1 +<<: !include common-ard.yaml diff --git a/tests/components/e131/test.esp32-c3-ard.yaml b/tests/components/e131/test.esp32-c3-ard.yaml index 25304cd3b4..32cf2a64ba 100644 --- a/tests/components/e131/test.esp32-c3-ard.yaml +++ b/tests/components/e131/test.esp32-c3-ard.yaml @@ -1,18 +1,5 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + light_platform: esp32_rmt_led_strip + pin: GPIO2 -e131: - -light: - - platform: esp32_rmt_led_strip - id: led_matrix_32x8 - default_transition_length: 500ms - chipset: ws2812 - rgb_order: GRB - num_leds: 256 - pin: 2 - rmt_channel: 0 - effects: - - e131: - universe: 1 +<<: !include common-ard.yaml diff --git a/tests/components/e131/test.esp32-c3-idf.yaml b/tests/components/e131/test.esp32-c3-idf.yaml index a27e62c1fb..d9dc4f6804 100644 --- a/tests/components/e131/test.esp32-c3-idf.yaml +++ b/tests/components/e131/test.esp32-c3-idf.yaml @@ -1,17 +1,5 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + light_platform: esp32_rmt_led_strip + pin: GPIO2 -e131: - -light: - - platform: esp32_rmt_led_strip - id: led_matrix_32x8 - default_transition_length: 500ms - chipset: ws2812 - rgb_order: GRB - num_leds: 256 - pin: 2 - effects: - - e131: - universe: 1 +<<: !include common-idf.yaml diff --git a/tests/components/e131/test.esp32-idf.yaml b/tests/components/e131/test.esp32-idf.yaml index a27e62c1fb..d9dc4f6804 100644 --- a/tests/components/e131/test.esp32-idf.yaml +++ b/tests/components/e131/test.esp32-idf.yaml @@ -1,17 +1,5 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + light_platform: esp32_rmt_led_strip + pin: GPIO2 -e131: - -light: - - platform: esp32_rmt_led_strip - id: led_matrix_32x8 - default_transition_length: 500ms - chipset: ws2812 - rgb_order: GRB - num_leds: 256 - pin: 2 - effects: - - e131: - universe: 1 +<<: !include common-idf.yaml diff --git a/tests/components/e131/test.esp8266-ard.yaml b/tests/components/e131/test.esp8266-ard.yaml index 54245014a5..277928626e 100644 --- a/tests/components/e131/test.esp8266-ard.yaml +++ b/tests/components/e131/test.esp8266-ard.yaml @@ -1,8 +1,4 @@ -wifi: - ssid: MySSID - password: password1 - -e131: +<<: !include common.yaml light: - platform: neopixelbus diff --git a/tests/components/e131/test.rp2040-ard.yaml b/tests/components/e131/test.rp2040-ard.yaml index 0ae31f5403..25fe3b6796 100644 --- a/tests/components/e131/test.rp2040-ard.yaml +++ b/tests/components/e131/test.rp2040-ard.yaml @@ -1,8 +1,4 @@ -wifi: - ssid: MySSID - password: password1 - -e131: +<<: !include common.yaml light: - platform: rp2040_pio_led_strip diff --git a/tests/components/ee895/common.yaml b/tests/components/ee895/common.yaml new file mode 100644 index 0000000000..63d77abcaf --- /dev/null +++ b/tests/components/ee895/common.yaml @@ -0,0 +1,14 @@ +i2c: + - id: i2c_ee895 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ee895 + address: 0x5F + co2: + name: EE895 CO2 + temperature: + name: EE895 Temperature + pressure: + name: EE895 Pressure diff --git a/tests/components/ee895/test.esp32-ard.yaml b/tests/components/ee895/test.esp32-ard.yaml index 241bdb9574..63c3bd6afd 100644 --- a/tests/components/ee895/test.esp32-ard.yaml +++ b/tests/components/ee895/test.esp32-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ee895 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ee895 - address: 0x5F - co2: - name: EE895 CO2 - temperature: - name: EE895 Temperature - pressure: - name: EE895 Pressure +<<: !include common.yaml diff --git a/tests/components/ee895/test.esp32-c3-ard.yaml b/tests/components/ee895/test.esp32-c3-ard.yaml index 4a36117fab..ee2c29ca4e 100644 --- a/tests/components/ee895/test.esp32-c3-ard.yaml +++ b/tests/components/ee895/test.esp32-c3-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ee895 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ee895 - address: 0x5F - co2: - name: EE895 CO2 - temperature: - name: EE895 Temperature - pressure: - name: EE895 Pressure +<<: !include common.yaml diff --git a/tests/components/ee895/test.esp32-c3-idf.yaml b/tests/components/ee895/test.esp32-c3-idf.yaml index 4a36117fab..ee2c29ca4e 100644 --- a/tests/components/ee895/test.esp32-c3-idf.yaml +++ b/tests/components/ee895/test.esp32-c3-idf.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ee895 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ee895 - address: 0x5F - co2: - name: EE895 CO2 - temperature: - name: EE895 Temperature - pressure: - name: EE895 Pressure +<<: !include common.yaml diff --git a/tests/components/ee895/test.esp32-idf.yaml b/tests/components/ee895/test.esp32-idf.yaml index 241bdb9574..63c3bd6afd 100644 --- a/tests/components/ee895/test.esp32-idf.yaml +++ b/tests/components/ee895/test.esp32-idf.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ee895 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ee895 - address: 0x5F - co2: - name: EE895 CO2 - temperature: - name: EE895 Temperature - pressure: - name: EE895 Pressure +<<: !include common.yaml diff --git a/tests/components/ee895/test.esp8266-ard.yaml b/tests/components/ee895/test.esp8266-ard.yaml index 4a36117fab..ee2c29ca4e 100644 --- a/tests/components/ee895/test.esp8266-ard.yaml +++ b/tests/components/ee895/test.esp8266-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ee895 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ee895 - address: 0x5F - co2: - name: EE895 CO2 - temperature: - name: EE895 Temperature - pressure: - name: EE895 Pressure +<<: !include common.yaml diff --git a/tests/components/ee895/test.rp2040-ard.yaml b/tests/components/ee895/test.rp2040-ard.yaml index 4a36117fab..ee2c29ca4e 100644 --- a/tests/components/ee895/test.rp2040-ard.yaml +++ b/tests/components/ee895/test.rp2040-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_ee895 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ee895 - address: 0x5F - co2: - name: EE895 CO2 - temperature: - name: EE895 Temperature - pressure: - name: EE895 Pressure +<<: !include common.yaml diff --git a/tests/components/ektf2232/common.yaml b/tests/components/ektf2232/common.yaml new file mode 100644 index 0000000000..3271839fd4 --- /dev/null +++ b/tests/components/ektf2232/common.yaml @@ -0,0 +1,24 @@ +i2c: + - id: i2c_ektf2232 + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1306_i2c + id: ssd1306_display + model: SSD1306_128X64 + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + +touchscreen: + - platform: ektf2232 + interrupt_pin: ${interrupt_pin} + rts_pin: ${rts_pin} + display: ssd1306_display + on_touch: + - logger.log: + format: Touch at (%d, %d) + args: [touch.x, touch.y] diff --git a/tests/components/ektf2232/test.esp32-ard.yaml b/tests/components/ektf2232/test.esp32-ard.yaml index 9c6eef8bb3..b8f491c0c3 100644 --- a/tests/components/ektf2232/test.esp32-ard.yaml +++ b/tests/components/ektf2232/test.esp32-ard.yaml @@ -1,24 +1,8 @@ -i2c: - - id: i2c_ektf2232 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO13 + interrupt_pin: GPIO14 + rts_pin: GPIO15 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ektf2232 - interrupt_pin: 14 - rts_pin: 15 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ektf2232/test.esp32-c3-ard.yaml b/tests/components/ektf2232/test.esp32-c3-ard.yaml index 371f2795a2..9f2149b9d7 100644 --- a/tests/components/ektf2232/test.esp32-c3-ard.yaml +++ b/tests/components/ektf2232/test.esp32-c3-ard.yaml @@ -1,24 +1,8 @@ -i2c: - - id: i2c_ektf2232 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 + interrupt_pin: GPIO6 + rts_pin: GPIO7 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ektf2232 - interrupt_pin: 6 - rts_pin: 7 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ektf2232/test.esp32-c3-idf.yaml b/tests/components/ektf2232/test.esp32-c3-idf.yaml index 371f2795a2..9f2149b9d7 100644 --- a/tests/components/ektf2232/test.esp32-c3-idf.yaml +++ b/tests/components/ektf2232/test.esp32-c3-idf.yaml @@ -1,24 +1,8 @@ -i2c: - - id: i2c_ektf2232 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 + interrupt_pin: GPIO6 + rts_pin: GPIO7 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ektf2232 - interrupt_pin: 6 - rts_pin: 7 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ektf2232/test.esp32-idf.yaml b/tests/components/ektf2232/test.esp32-idf.yaml index 9c6eef8bb3..b8f491c0c3 100644 --- a/tests/components/ektf2232/test.esp32-idf.yaml +++ b/tests/components/ektf2232/test.esp32-idf.yaml @@ -1,24 +1,8 @@ -i2c: - - id: i2c_ektf2232 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO13 + interrupt_pin: GPIO14 + rts_pin: GPIO15 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ektf2232 - interrupt_pin: 14 - rts_pin: 15 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ektf2232/test.esp8266-ard.yaml b/tests/components/ektf2232/test.esp8266-ard.yaml index 03f18f7184..6d91a6533f 100644 --- a/tests/components/ektf2232/test.esp8266-ard.yaml +++ b/tests/components/ektf2232/test.esp8266-ard.yaml @@ -1,24 +1,8 @@ -i2c: - - id: i2c_ektf2232 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 + interrupt_pin: GPIO12 + rts_pin: GPIO13 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ektf2232 - interrupt_pin: 12 - rts_pin: 13 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ektf2232/test.rp2040-ard.yaml b/tests/components/ektf2232/test.rp2040-ard.yaml index 371f2795a2..9f2149b9d7 100644 --- a/tests/components/ektf2232/test.rp2040-ard.yaml +++ b/tests/components/ektf2232/test.rp2040-ard.yaml @@ -1,24 +1,8 @@ -i2c: - - id: i2c_ektf2232 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 + interrupt_pin: GPIO6 + rts_pin: GPIO7 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ektf2232 - interrupt_pin: 6 - rts_pin: 7 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/emc2101/common.yaml b/tests/components/emc2101/common.yaml new file mode 100644 index 0000000000..795b02c6d3 --- /dev/null +++ b/tests/components/emc2101/common.yaml @@ -0,0 +1,25 @@ +i2c: + - id: i2c_emc2101 + scl: ${scl_pin} + sda: ${sda_pin} + +emc2101: + pwm: + resolution: 8 + +output: + - platform: emc2101 + id: fan_duty_cycle + +sensor: + - platform: emc2101 + internal_temperature: + id: internal_temperature_sensor + name: Internal Temperature Sensor + speed: + id: speed_sensor + name: Speed Sensor + duty_cycle: + id: duty_cycle_sensor + name: Duty Cycle Sensor + update_interval: 5s diff --git a/tests/components/emc2101/test.esp32-ard.yaml b/tests/components/emc2101/test.esp32-ard.yaml index 34a7d22b71..63c3bd6afd 100644 --- a/tests/components/emc2101/test.esp32-ard.yaml +++ b/tests/components/emc2101/test.esp32-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_emc2101 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -emc2101: - pwm: - resolution: 8 - -output: - - platform: emc2101 - id: fan_duty_cycle - -sensor: - - platform: emc2101 - internal_temperature: - id: internal_temperature_sensor - name: Internal Temperature Sensor - speed: - id: speed_sensor - name: Speed Sensor - duty_cycle: - id: duty_cycle_sensor - name: Duty Cycle Sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/emc2101/test.esp32-c3-ard.yaml b/tests/components/emc2101/test.esp32-c3-ard.yaml index d95bc1b001..ee2c29ca4e 100644 --- a/tests/components/emc2101/test.esp32-c3-ard.yaml +++ b/tests/components/emc2101/test.esp32-c3-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_emc2101 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -emc2101: - pwm: - resolution: 8 - -output: - - platform: emc2101 - id: fan_duty_cycle - -sensor: - - platform: emc2101 - internal_temperature: - id: internal_temperature_sensor - name: Internal Temperature Sensor - speed: - id: speed_sensor - name: Speed Sensor - duty_cycle: - id: duty_cycle_sensor - name: Duty Cycle Sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/emc2101/test.esp32-c3-idf.yaml b/tests/components/emc2101/test.esp32-c3-idf.yaml index d95bc1b001..ee2c29ca4e 100644 --- a/tests/components/emc2101/test.esp32-c3-idf.yaml +++ b/tests/components/emc2101/test.esp32-c3-idf.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_emc2101 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -emc2101: - pwm: - resolution: 8 - -output: - - platform: emc2101 - id: fan_duty_cycle - -sensor: - - platform: emc2101 - internal_temperature: - id: internal_temperature_sensor - name: Internal Temperature Sensor - speed: - id: speed_sensor - name: Speed Sensor - duty_cycle: - id: duty_cycle_sensor - name: Duty Cycle Sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/emc2101/test.esp32-idf.yaml b/tests/components/emc2101/test.esp32-idf.yaml index 34a7d22b71..63c3bd6afd 100644 --- a/tests/components/emc2101/test.esp32-idf.yaml +++ b/tests/components/emc2101/test.esp32-idf.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_emc2101 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -emc2101: - pwm: - resolution: 8 - -output: - - platform: emc2101 - id: fan_duty_cycle - -sensor: - - platform: emc2101 - internal_temperature: - id: internal_temperature_sensor - name: Internal Temperature Sensor - speed: - id: speed_sensor - name: Speed Sensor - duty_cycle: - id: duty_cycle_sensor - name: Duty Cycle Sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/emc2101/test.esp8266-ard.yaml b/tests/components/emc2101/test.esp8266-ard.yaml index d95bc1b001..ee2c29ca4e 100644 --- a/tests/components/emc2101/test.esp8266-ard.yaml +++ b/tests/components/emc2101/test.esp8266-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_emc2101 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -emc2101: - pwm: - resolution: 8 - -output: - - platform: emc2101 - id: fan_duty_cycle - -sensor: - - platform: emc2101 - internal_temperature: - id: internal_temperature_sensor - name: Internal Temperature Sensor - speed: - id: speed_sensor - name: Speed Sensor - duty_cycle: - id: duty_cycle_sensor - name: Duty Cycle Sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/emc2101/test.rp2040-ard.yaml b/tests/components/emc2101/test.rp2040-ard.yaml index d95bc1b001..ee2c29ca4e 100644 --- a/tests/components/emc2101/test.rp2040-ard.yaml +++ b/tests/components/emc2101/test.rp2040-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_emc2101 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -emc2101: - pwm: - resolution: 8 - -output: - - platform: emc2101 - id: fan_duty_cycle - -sensor: - - platform: emc2101 - internal_temperature: - id: internal_temperature_sensor - name: Internal Temperature Sensor - speed: - id: speed_sensor - name: Speed Sensor - duty_cycle: - id: duty_cycle_sensor - name: Duty Cycle Sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/ens210/common.yaml b/tests/components/ens210/common.yaml new file mode 100644 index 0000000000..b276154449 --- /dev/null +++ b/tests/components/ens210/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_ens210 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ens210 + temperature: + name: ENS210 Temperature + humidity: + name: ENS210 Humidity + update_interval: 15s diff --git a/tests/components/ens210/test.esp32-ard.yaml b/tests/components/ens210/test.esp32-ard.yaml index 8b2d29cc25..63c3bd6afd 100644 --- a/tests/components/ens210/test.esp32-ard.yaml +++ b/tests/components/ens210/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ens210 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ens210 - temperature: - name: ENS210 Temperature - humidity: - name: ENS210 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ens210/test.esp32-c3-ard.yaml b/tests/components/ens210/test.esp32-c3-ard.yaml index bacb71f9f8..ee2c29ca4e 100644 --- a/tests/components/ens210/test.esp32-c3-ard.yaml +++ b/tests/components/ens210/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ens210 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ens210 - temperature: - name: ENS210 Temperature - humidity: - name: ENS210 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ens210/test.esp32-c3-idf.yaml b/tests/components/ens210/test.esp32-c3-idf.yaml index bacb71f9f8..ee2c29ca4e 100644 --- a/tests/components/ens210/test.esp32-c3-idf.yaml +++ b/tests/components/ens210/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ens210 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ens210 - temperature: - name: ENS210 Temperature - humidity: - name: ENS210 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ens210/test.esp32-idf.yaml b/tests/components/ens210/test.esp32-idf.yaml index 8b2d29cc25..63c3bd6afd 100644 --- a/tests/components/ens210/test.esp32-idf.yaml +++ b/tests/components/ens210/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ens210 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ens210 - temperature: - name: ENS210 Temperature - humidity: - name: ENS210 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ens210/test.esp8266-ard.yaml b/tests/components/ens210/test.esp8266-ard.yaml index bacb71f9f8..ee2c29ca4e 100644 --- a/tests/components/ens210/test.esp8266-ard.yaml +++ b/tests/components/ens210/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ens210 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ens210 - temperature: - name: ENS210 Temperature - humidity: - name: ENS210 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ens210/test.rp2040-ard.yaml b/tests/components/ens210/test.rp2040-ard.yaml index bacb71f9f8..ee2c29ca4e 100644 --- a/tests/components/ens210/test.rp2040-ard.yaml +++ b/tests/components/ens210/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_ens210 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ens210 - temperature: - name: ENS210 Temperature - humidity: - name: ENS210 Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/esp32_can/common.yaml b/tests/components/esp32_can/common.yaml new file mode 100644 index 0000000000..4349c470f3 --- /dev/null +++ b/tests/components/esp32_can/common.yaml @@ -0,0 +1,45 @@ +esphome: + on_boot: + then: + - canbus.send: + # Extended ID explicit + use_extended_id: true + can_id: 0x100 + data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] + - canbus.send: + # Standard ID by default + can_id: 0x100 + data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] + +canbus: + - platform: esp32_can + id: esp32_internal_can + rx_pin: ${rx_pin} + tx_pin: ${tx_pin} + can_id: 4 + bit_rate: 50kbps + on_frame: + - can_id: 500 + then: + - lambda: |- + std::string b(x.begin(), x.end()); + ESP_LOGD("canid 500", "%s", b.c_str() ); + - can_id: 0b00000000000000000000001000000 + can_id_mask: 0b11111000000000011111111000000 + use_extended_id: true + then: + - lambda: |- + auto pdo_id = can_id >> 14; + switch (pdo_id) + { + case 117: + ESP_LOGD("canbus", "exhaust_fan_duty"); + break; + case 118: + ESP_LOGD("canbus", "supply_fan_duty"); + break; + case 119: + ESP_LOGD("canbus", "supply_fan_flow"); + break; + // to be continued... + } diff --git a/tests/components/esp32_can/test.esp32-ard.yaml b/tests/components/esp32_can/test.esp32-ard.yaml index 159a695853..811f6b72a6 100644 --- a/tests/components/esp32_can/test.esp32-ard.yaml +++ b/tests/components/esp32_can/test.esp32-ard.yaml @@ -1,45 +1,5 @@ -esphome: - on_boot: - then: - - canbus.send: - # Extended ID explicit - use_extended_id: true - can_id: 0x100 - data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] - - canbus.send: - # Standard ID by default - can_id: 0x100 - data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -canbus: - - platform: esp32_can - id: esp32_internal_can - rx_pin: 13 - tx_pin: 14 - can_id: 4 - bit_rate: 50kbps - on_frame: - - can_id: 500 - then: - - lambda: |- - std::string b(x.begin(), x.end()); - ESP_LOGD("canid 500", "%s", b.c_str() ); - - can_id: 0b00000000000000000000001000000 - can_id_mask: 0b11111000000000011111111000000 - use_extended_id: true - then: - - lambda: |- - auto pdo_id = can_id >> 14; - switch (pdo_id) - { - case 117: - ESP_LOGD("canbus", "exhaust_fan_duty"); - break; - case 118: - ESP_LOGD("canbus", "supply_fan_duty"); - break; - case 119: - ESP_LOGD("canbus", "supply_fan_flow"); - break; - // to be continued... - } +<<: !include common.yaml diff --git a/tests/components/esp32_can/test.esp32-c3-ard.yaml b/tests/components/esp32_can/test.esp32-c3-ard.yaml index b4fd34cf51..c79d14c740 100644 --- a/tests/components/esp32_can/test.esp32-c3-ard.yaml +++ b/tests/components/esp32_can/test.esp32-c3-ard.yaml @@ -1,45 +1,5 @@ -esphome: - on_boot: - then: - - canbus.send: - # Extended ID explicit - use_extended_id: true - can_id: 0x100 - data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] - - canbus.send: - # Standard ID by default - can_id: 0x100 - data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -canbus: - - platform: esp32_can - id: esp32_internal_can - rx_pin: 4 - tx_pin: 5 - can_id: 4 - bit_rate: 50kbps - on_frame: - - can_id: 500 - then: - - lambda: |- - std::string b(x.begin(), x.end()); - ESP_LOGD("canid 500", "%s", b.c_str() ); - - can_id: 0b00000000000000000000001000000 - can_id_mask: 0b11111000000000011111111000000 - use_extended_id: true - then: - - lambda: |- - auto pdo_id = can_id >> 14; - switch (pdo_id) - { - case 117: - ESP_LOGD("canbus", "exhaust_fan_duty"); - break; - case 118: - ESP_LOGD("canbus", "supply_fan_duty"); - break; - case 119: - ESP_LOGD("canbus", "supply_fan_flow"); - break; - // to be continued... - } +<<: !include common.yaml diff --git a/tests/components/esp32_can/test.esp32-c3-idf.yaml b/tests/components/esp32_can/test.esp32-c3-idf.yaml index b4fd34cf51..c79d14c740 100644 --- a/tests/components/esp32_can/test.esp32-c3-idf.yaml +++ b/tests/components/esp32_can/test.esp32-c3-idf.yaml @@ -1,45 +1,5 @@ -esphome: - on_boot: - then: - - canbus.send: - # Extended ID explicit - use_extended_id: true - can_id: 0x100 - data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] - - canbus.send: - # Standard ID by default - can_id: 0x100 - data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] +substitutions: + tx_pin: GPIO7 + rx_pin: GPIO8 -canbus: - - platform: esp32_can - id: esp32_internal_can - rx_pin: 4 - tx_pin: 5 - can_id: 4 - bit_rate: 50kbps - on_frame: - - can_id: 500 - then: - - lambda: |- - std::string b(x.begin(), x.end()); - ESP_LOGD("canid 500", "%s", b.c_str() ); - - can_id: 0b00000000000000000000001000000 - can_id_mask: 0b11111000000000011111111000000 - use_extended_id: true - then: - - lambda: |- - auto pdo_id = can_id >> 14; - switch (pdo_id) - { - case 117: - ESP_LOGD("canbus", "exhaust_fan_duty"); - break; - case 118: - ESP_LOGD("canbus", "supply_fan_duty"); - break; - case 119: - ESP_LOGD("canbus", "supply_fan_flow"); - break; - // to be continued... - } +<<: !include common.yaml diff --git a/tests/components/esp32_can/test.esp32-idf.yaml b/tests/components/esp32_can/test.esp32-idf.yaml index 159a695853..811f6b72a6 100644 --- a/tests/components/esp32_can/test.esp32-idf.yaml +++ b/tests/components/esp32_can/test.esp32-idf.yaml @@ -1,45 +1,5 @@ -esphome: - on_boot: - then: - - canbus.send: - # Extended ID explicit - use_extended_id: true - can_id: 0x100 - data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] - - canbus.send: - # Standard ID by default - can_id: 0x100 - data: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -canbus: - - platform: esp32_can - id: esp32_internal_can - rx_pin: 13 - tx_pin: 14 - can_id: 4 - bit_rate: 50kbps - on_frame: - - can_id: 500 - then: - - lambda: |- - std::string b(x.begin(), x.end()); - ESP_LOGD("canid 500", "%s", b.c_str() ); - - can_id: 0b00000000000000000000001000000 - can_id_mask: 0b11111000000000011111111000000 - use_extended_id: true - then: - - lambda: |- - auto pdo_id = can_id >> 14; - switch (pdo_id) - { - case 117: - ESP_LOGD("canbus", "exhaust_fan_duty"); - break; - case 118: - ESP_LOGD("canbus", "supply_fan_duty"); - break; - case 119: - ESP_LOGD("canbus", "supply_fan_flow"); - break; - // to be continued... - } +<<: !include common.yaml diff --git a/tests/components/esp32_rmt_led_strip/common-ard.yaml b/tests/components/esp32_rmt_led_strip/common-ard.yaml new file mode 100644 index 0000000000..287690e86e --- /dev/null +++ b/tests/components/esp32_rmt_led_strip/common-ard.yaml @@ -0,0 +1,18 @@ +light: + - platform: esp32_rmt_led_strip + id: led_strip1 + pin: ${pin1} + num_leds: 60 + rmt_channel: 0 + rgb_order: GRB + chipset: ws2812 + - platform: esp32_rmt_led_strip + id: led_strip2 + pin: ${pin2} + num_leds: 60 + rmt_channel: 1 + rgb_order: RGB + bit0_high: 100us + bit0_low: 100us + bit1_high: 100us + bit1_low: 100us diff --git a/tests/components/esp32_rmt_led_strip/common-idf.yaml b/tests/components/esp32_rmt_led_strip/common-idf.yaml new file mode 100644 index 0000000000..f3ee86bcce --- /dev/null +++ b/tests/components/esp32_rmt_led_strip/common-idf.yaml @@ -0,0 +1,16 @@ +light: + - platform: esp32_rmt_led_strip + id: led_strip1 + pin: ${pin1} + num_leds: 60 + rgb_order: GRB + chipset: ws2812 + - platform: esp32_rmt_led_strip + id: led_strip2 + pin: ${pin2} + num_leds: 60 + rgb_order: RGB + bit0_high: 100us + bit0_low: 100us + bit1_high: 100us + bit1_low: 100us diff --git a/tests/components/esp32_rmt_led_strip/test.esp32-ard.yaml b/tests/components/esp32_rmt_led_strip/test.esp32-ard.yaml index d51a66451f..c75ac73ace 100644 --- a/tests/components/esp32_rmt_led_strip/test.esp32-ard.yaml +++ b/tests/components/esp32_rmt_led_strip/test.esp32-ard.yaml @@ -1,18 +1,5 @@ -light: - - platform: esp32_rmt_led_strip - id: led_strip - pin: 13 - num_leds: 60 - rmt_channel: 6 - rgb_order: GRB - chipset: ws2812 - - platform: esp32_rmt_led_strip - id: led_strip2 - pin: 14 - num_leds: 60 - rmt_channel: 2 - rgb_order: RGB - bit0_high: 100us - bit0_low: 100us - bit1_high: 100us - bit1_low: 100us +substitutions: + pin1: GPIO13 + pin2: GPIO14 + +<<: !include common-ard.yaml diff --git a/tests/components/esp32_rmt_led_strip/test.esp32-c3-ard.yaml b/tests/components/esp32_rmt_led_strip/test.esp32-c3-ard.yaml index b226d1de06..7b4560a0d7 100644 --- a/tests/components/esp32_rmt_led_strip/test.esp32-c3-ard.yaml +++ b/tests/components/esp32_rmt_led_strip/test.esp32-c3-ard.yaml @@ -1,18 +1,5 @@ -light: - - platform: esp32_rmt_led_strip - id: led_strip - pin: 4 - num_leds: 60 - rmt_channel: 0 - rgb_order: GRB - chipset: ws2812 - - platform: esp32_rmt_led_strip - id: led_strip2 - pin: 5 - num_leds: 60 - rmt_channel: 1 - rgb_order: RGB - bit0_high: 100us - bit0_low: 100us - bit1_high: 100us - bit1_low: 100us +substitutions: + pin1: GPIO3 + pin2: GPIO4 + +<<: !include common-ard.yaml diff --git a/tests/components/esp32_rmt_led_strip/test.esp32-c3-idf.yaml b/tests/components/esp32_rmt_led_strip/test.esp32-c3-idf.yaml index 93318d0581..b4110199f1 100644 --- a/tests/components/esp32_rmt_led_strip/test.esp32-c3-idf.yaml +++ b/tests/components/esp32_rmt_led_strip/test.esp32-c3-idf.yaml @@ -1,16 +1,5 @@ -light: - - platform: esp32_rmt_led_strip - id: led_strip - pin: 4 - num_leds: 60 - rgb_order: GRB - chipset: ws2812 - - platform: esp32_rmt_led_strip - id: led_strip2 - pin: 5 - num_leds: 60 - rgb_order: RGB - bit0_high: 100µs - bit0_low: 100µs - bit1_high: 100µs - bit1_low: 100µs +substitutions: + pin1: GPIO3 + pin2: GPIO4 + +<<: !include common-idf.yaml diff --git a/tests/components/esp32_rmt_led_strip/test.esp32-idf.yaml b/tests/components/esp32_rmt_led_strip/test.esp32-idf.yaml index 228af17189..5adeba4f8c 100644 --- a/tests/components/esp32_rmt_led_strip/test.esp32-idf.yaml +++ b/tests/components/esp32_rmt_led_strip/test.esp32-idf.yaml @@ -1,16 +1,5 @@ -light: - - platform: esp32_rmt_led_strip - id: led_strip - pin: 13 - num_leds: 60 - rgb_order: GRB - chipset: ws2812 - - platform: esp32_rmt_led_strip - id: led_strip2 - pin: 14 - num_leds: 60 - rgb_order: RGB - bit0_high: 100µs - bit0_low: 100µs - bit1_high: 100µs - bit1_low: 100µs +substitutions: + pin1: GPIO13 + pin2: GPIO14 + +<<: !include common-idf.yaml diff --git a/tests/components/ezo/common.yaml b/tests/components/ezo/common.yaml new file mode 100644 index 0000000000..edeebd1a12 --- /dev/null +++ b/tests/components/ezo/common.yaml @@ -0,0 +1,10 @@ +i2c: + - id: i2c_ezo + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ezo + id: ph_ezo + address: 99 + unit_of_measurement: pH diff --git a/tests/components/ezo/test.esp32-ard.yaml b/tests/components/ezo/test.esp32-ard.yaml index 61a8d2b25f..63c3bd6afd 100644 --- a/tests/components/ezo/test.esp32-ard.yaml +++ b/tests/components/ezo/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_ezo - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ezo - id: ph_ezo - address: 99 - unit_of_measurement: pH +<<: !include common.yaml diff --git a/tests/components/ezo/test.esp32-c3-ard.yaml b/tests/components/ezo/test.esp32-c3-ard.yaml index 93ceb9efd3..ee2c29ca4e 100644 --- a/tests/components/ezo/test.esp32-c3-ard.yaml +++ b/tests/components/ezo/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_ezo - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ezo - id: ph_ezo - address: 99 - unit_of_measurement: pH +<<: !include common.yaml diff --git a/tests/components/ezo/test.esp32-c3-idf.yaml b/tests/components/ezo/test.esp32-c3-idf.yaml index 93ceb9efd3..ee2c29ca4e 100644 --- a/tests/components/ezo/test.esp32-c3-idf.yaml +++ b/tests/components/ezo/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_ezo - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ezo - id: ph_ezo - address: 99 - unit_of_measurement: pH +<<: !include common.yaml diff --git a/tests/components/ezo/test.esp32-idf.yaml b/tests/components/ezo/test.esp32-idf.yaml index 61a8d2b25f..63c3bd6afd 100644 --- a/tests/components/ezo/test.esp32-idf.yaml +++ b/tests/components/ezo/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_ezo - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ezo - id: ph_ezo - address: 99 - unit_of_measurement: pH +<<: !include common.yaml diff --git a/tests/components/ezo/test.esp8266-ard.yaml b/tests/components/ezo/test.esp8266-ard.yaml index 93ceb9efd3..ee2c29ca4e 100644 --- a/tests/components/ezo/test.esp8266-ard.yaml +++ b/tests/components/ezo/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_ezo - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ezo - id: ph_ezo - address: 99 - unit_of_measurement: pH +<<: !include common.yaml diff --git a/tests/components/ezo/test.rp2040-ard.yaml b/tests/components/ezo/test.rp2040-ard.yaml index 93ceb9efd3..ee2c29ca4e 100644 --- a/tests/components/ezo/test.rp2040-ard.yaml +++ b/tests/components/ezo/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_ezo - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ezo - id: ph_ezo - address: 99 - unit_of_measurement: pH +<<: !include common.yaml diff --git a/tests/components/ezo_pmp/common.yaml b/tests/components/ezo_pmp/common.yaml new file mode 100644 index 0000000000..00919797be --- /dev/null +++ b/tests/components/ezo_pmp/common.yaml @@ -0,0 +1,61 @@ +i2c: + - id: i2c_ezo_pmp + scl: ${scl_pin} + sda: ${sda_pin} + +ezo_pmp: + id: hcl_pump + update_interval: 1s + +binary_sensor: + - platform: ezo_pmp + pump_state: + name: Pump State + is_paused: + name: Is Paused + +sensor: + - platform: ezo_pmp + current_volume_dosed: + name: Current Volume Dosed + total_volume_dosed: + name: Total Volume Dosed + absolute_total_volume_dosed: + name: Absolute Total Volume Dosed + pump_voltage: + name: Pump Voltage + last_volume_requested: + name: Last Volume Requested + max_flow_rate: + name: Max Flow Rate + +text_sensor: + - platform: ezo_pmp + dosing_mode: + name: Dosing Mode + calibration_status: + name: Calibration Status + on_value: + - ezo_pmp.dose_volume: + id: hcl_pump + volume: 10 + - ezo_pmp.dose_volume_over_time: + id: hcl_pump + volume: 10 + duration: 2 + - ezo_pmp.dose_with_constant_flow_rate: + id: hcl_pump + volume_per_minute: 10 + duration: 2 + - ezo_pmp.set_calibration_volume: + id: hcl_pump + volume: 10 + - ezo_pmp.find: hcl_pump + - ezo_pmp.dose_continuously: hcl_pump + - ezo_pmp.clear_total_volume_dosed: hcl_pump + - ezo_pmp.clear_calibration: hcl_pump + - ezo_pmp.pause_dosing: hcl_pump + - ezo_pmp.stop_dosing: hcl_pump + - ezo_pmp.arbitrary_command: + id: hcl_pump + command: D,? diff --git a/tests/components/ezo_pmp/test.esp32-ard.yaml b/tests/components/ezo_pmp/test.esp32-ard.yaml index 9fc929b365..63c3bd6afd 100644 --- a/tests/components/ezo_pmp/test.esp32-ard.yaml +++ b/tests/components/ezo_pmp/test.esp32-ard.yaml @@ -1,61 +1,5 @@ -i2c: - - id: i2c_ezo_pmp - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -ezo_pmp: - id: hcl_pump - update_interval: 1s - -binary_sensor: - - platform: ezo_pmp - pump_state: - name: Pump State - is_paused: - name: Is Paused - -sensor: - - platform: ezo_pmp - current_volume_dosed: - name: Current Volume Dosed - total_volume_dosed: - name: Total Volume Dosed - absolute_total_volume_dosed: - name: Absolute Total Volume Dosed - pump_voltage: - name: Pump Voltage - last_volume_requested: - name: Last Volume Requested - max_flow_rate: - name: Max Flow Rate - -text_sensor: - - platform: ezo_pmp - dosing_mode: - name: Dosing Mode - calibration_status: - name: Calibration Status - on_value: - - ezo_pmp.dose_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.dose_volume_over_time: - id: hcl_pump - volume: 10 - duration: 2 - - ezo_pmp.dose_with_constant_flow_rate: - id: hcl_pump - volume_per_minute: 10 - duration: 2 - - ezo_pmp.set_calibration_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.find: hcl_pump - - ezo_pmp.dose_continuously: hcl_pump - - ezo_pmp.clear_total_volume_dosed: hcl_pump - - ezo_pmp.clear_calibration: hcl_pump - - ezo_pmp.pause_dosing: hcl_pump - - ezo_pmp.stop_dosing: hcl_pump - - ezo_pmp.arbitrary_command: - id: hcl_pump - command: D,? +<<: !include common.yaml diff --git a/tests/components/ezo_pmp/test.esp32-c3-ard.yaml b/tests/components/ezo_pmp/test.esp32-c3-ard.yaml index fa047de3de..ee2c29ca4e 100644 --- a/tests/components/ezo_pmp/test.esp32-c3-ard.yaml +++ b/tests/components/ezo_pmp/test.esp32-c3-ard.yaml @@ -1,61 +1,5 @@ -i2c: - - id: i2c_ezo_pmp - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ezo_pmp: - id: hcl_pump - update_interval: 1s - -binary_sensor: - - platform: ezo_pmp - pump_state: - name: Pump State - is_paused: - name: Is Paused - -sensor: - - platform: ezo_pmp - current_volume_dosed: - name: Current Volume Dosed - total_volume_dosed: - name: Total Volume Dosed - absolute_total_volume_dosed: - name: Absolute Total Volume Dosed - pump_voltage: - name: Pump Voltage - last_volume_requested: - name: Last Volume Requested - max_flow_rate: - name: Max Flow Rate - -text_sensor: - - platform: ezo_pmp - dosing_mode: - name: Dosing Mode - calibration_status: - name: Calibration Status - on_value: - - ezo_pmp.dose_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.dose_volume_over_time: - id: hcl_pump - volume: 10 - duration: 2 - - ezo_pmp.dose_with_constant_flow_rate: - id: hcl_pump - volume_per_minute: 10 - duration: 2 - - ezo_pmp.set_calibration_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.find: hcl_pump - - ezo_pmp.dose_continuously: hcl_pump - - ezo_pmp.clear_total_volume_dosed: hcl_pump - - ezo_pmp.clear_calibration: hcl_pump - - ezo_pmp.pause_dosing: hcl_pump - - ezo_pmp.stop_dosing: hcl_pump - - ezo_pmp.arbitrary_command: - id: hcl_pump - command: D,? +<<: !include common.yaml diff --git a/tests/components/ezo_pmp/test.esp32-c3-idf.yaml b/tests/components/ezo_pmp/test.esp32-c3-idf.yaml index fa047de3de..ee2c29ca4e 100644 --- a/tests/components/ezo_pmp/test.esp32-c3-idf.yaml +++ b/tests/components/ezo_pmp/test.esp32-c3-idf.yaml @@ -1,61 +1,5 @@ -i2c: - - id: i2c_ezo_pmp - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ezo_pmp: - id: hcl_pump - update_interval: 1s - -binary_sensor: - - platform: ezo_pmp - pump_state: - name: Pump State - is_paused: - name: Is Paused - -sensor: - - platform: ezo_pmp - current_volume_dosed: - name: Current Volume Dosed - total_volume_dosed: - name: Total Volume Dosed - absolute_total_volume_dosed: - name: Absolute Total Volume Dosed - pump_voltage: - name: Pump Voltage - last_volume_requested: - name: Last Volume Requested - max_flow_rate: - name: Max Flow Rate - -text_sensor: - - platform: ezo_pmp - dosing_mode: - name: Dosing Mode - calibration_status: - name: Calibration Status - on_value: - - ezo_pmp.dose_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.dose_volume_over_time: - id: hcl_pump - volume: 10 - duration: 2 - - ezo_pmp.dose_with_constant_flow_rate: - id: hcl_pump - volume_per_minute: 10 - duration: 2 - - ezo_pmp.set_calibration_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.find: hcl_pump - - ezo_pmp.dose_continuously: hcl_pump - - ezo_pmp.clear_total_volume_dosed: hcl_pump - - ezo_pmp.clear_calibration: hcl_pump - - ezo_pmp.pause_dosing: hcl_pump - - ezo_pmp.stop_dosing: hcl_pump - - ezo_pmp.arbitrary_command: - id: hcl_pump - command: D,? +<<: !include common.yaml diff --git a/tests/components/ezo_pmp/test.esp32-idf.yaml b/tests/components/ezo_pmp/test.esp32-idf.yaml index 9fc929b365..63c3bd6afd 100644 --- a/tests/components/ezo_pmp/test.esp32-idf.yaml +++ b/tests/components/ezo_pmp/test.esp32-idf.yaml @@ -1,61 +1,5 @@ -i2c: - - id: i2c_ezo_pmp - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -ezo_pmp: - id: hcl_pump - update_interval: 1s - -binary_sensor: - - platform: ezo_pmp - pump_state: - name: Pump State - is_paused: - name: Is Paused - -sensor: - - platform: ezo_pmp - current_volume_dosed: - name: Current Volume Dosed - total_volume_dosed: - name: Total Volume Dosed - absolute_total_volume_dosed: - name: Absolute Total Volume Dosed - pump_voltage: - name: Pump Voltage - last_volume_requested: - name: Last Volume Requested - max_flow_rate: - name: Max Flow Rate - -text_sensor: - - platform: ezo_pmp - dosing_mode: - name: Dosing Mode - calibration_status: - name: Calibration Status - on_value: - - ezo_pmp.dose_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.dose_volume_over_time: - id: hcl_pump - volume: 10 - duration: 2 - - ezo_pmp.dose_with_constant_flow_rate: - id: hcl_pump - volume_per_minute: 10 - duration: 2 - - ezo_pmp.set_calibration_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.find: hcl_pump - - ezo_pmp.dose_continuously: hcl_pump - - ezo_pmp.clear_total_volume_dosed: hcl_pump - - ezo_pmp.clear_calibration: hcl_pump - - ezo_pmp.pause_dosing: hcl_pump - - ezo_pmp.stop_dosing: hcl_pump - - ezo_pmp.arbitrary_command: - id: hcl_pump - command: D,? +<<: !include common.yaml diff --git a/tests/components/ezo_pmp/test.esp8266-ard.yaml b/tests/components/ezo_pmp/test.esp8266-ard.yaml index fa047de3de..ee2c29ca4e 100644 --- a/tests/components/ezo_pmp/test.esp8266-ard.yaml +++ b/tests/components/ezo_pmp/test.esp8266-ard.yaml @@ -1,61 +1,5 @@ -i2c: - - id: i2c_ezo_pmp - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ezo_pmp: - id: hcl_pump - update_interval: 1s - -binary_sensor: - - platform: ezo_pmp - pump_state: - name: Pump State - is_paused: - name: Is Paused - -sensor: - - platform: ezo_pmp - current_volume_dosed: - name: Current Volume Dosed - total_volume_dosed: - name: Total Volume Dosed - absolute_total_volume_dosed: - name: Absolute Total Volume Dosed - pump_voltage: - name: Pump Voltage - last_volume_requested: - name: Last Volume Requested - max_flow_rate: - name: Max Flow Rate - -text_sensor: - - platform: ezo_pmp - dosing_mode: - name: Dosing Mode - calibration_status: - name: Calibration Status - on_value: - - ezo_pmp.dose_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.dose_volume_over_time: - id: hcl_pump - volume: 10 - duration: 2 - - ezo_pmp.dose_with_constant_flow_rate: - id: hcl_pump - volume_per_minute: 10 - duration: 2 - - ezo_pmp.set_calibration_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.find: hcl_pump - - ezo_pmp.dose_continuously: hcl_pump - - ezo_pmp.clear_total_volume_dosed: hcl_pump - - ezo_pmp.clear_calibration: hcl_pump - - ezo_pmp.pause_dosing: hcl_pump - - ezo_pmp.stop_dosing: hcl_pump - - ezo_pmp.arbitrary_command: - id: hcl_pump - command: D,? +<<: !include common.yaml diff --git a/tests/components/ezo_pmp/test.rp2040-ard.yaml b/tests/components/ezo_pmp/test.rp2040-ard.yaml index fa047de3de..ee2c29ca4e 100644 --- a/tests/components/ezo_pmp/test.rp2040-ard.yaml +++ b/tests/components/ezo_pmp/test.rp2040-ard.yaml @@ -1,61 +1,5 @@ -i2c: - - id: i2c_ezo_pmp - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ezo_pmp: - id: hcl_pump - update_interval: 1s - -binary_sensor: - - platform: ezo_pmp - pump_state: - name: Pump State - is_paused: - name: Is Paused - -sensor: - - platform: ezo_pmp - current_volume_dosed: - name: Current Volume Dosed - total_volume_dosed: - name: Total Volume Dosed - absolute_total_volume_dosed: - name: Absolute Total Volume Dosed - pump_voltage: - name: Pump Voltage - last_volume_requested: - name: Last Volume Requested - max_flow_rate: - name: Max Flow Rate - -text_sensor: - - platform: ezo_pmp - dosing_mode: - name: Dosing Mode - calibration_status: - name: Calibration Status - on_value: - - ezo_pmp.dose_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.dose_volume_over_time: - id: hcl_pump - volume: 10 - duration: 2 - - ezo_pmp.dose_with_constant_flow_rate: - id: hcl_pump - volume_per_minute: 10 - duration: 2 - - ezo_pmp.set_calibration_volume: - id: hcl_pump - volume: 10 - - ezo_pmp.find: hcl_pump - - ezo_pmp.dose_continuously: hcl_pump - - ezo_pmp.clear_total_volume_dosed: hcl_pump - - ezo_pmp.clear_calibration: hcl_pump - - ezo_pmp.pause_dosing: hcl_pump - - ezo_pmp.stop_dosing: hcl_pump - - ezo_pmp.arbitrary_command: - id: hcl_pump - command: D,? +<<: !include common.yaml From 6e3527a88b295874111e8ef2abf6cb0ed33bb442 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:05:35 -0600 Subject: [PATCH 149/194] [CI] Consolidate some tests (F) (#8195) --- tests/components/fingerprint_grow/common.yaml | 56 +++++++++++++++++ .../fingerprint_grow/test.esp32-ard.yaml | 60 ++----------------- .../fingerprint_grow/test.esp32-c3-ard.yaml | 60 ++----------------- .../fingerprint_grow/test.esp32-c3-idf.yaml | 60 ++----------------- .../fingerprint_grow/test.esp32-idf.yaml | 60 ++----------------- .../fingerprint_grow/test.esp8266-ard.yaml | 60 ++----------------- .../fingerprint_grow/test.rp2040-ard.yaml | 60 ++----------------- tests/components/fs3000/common.yaml | 10 ++++ tests/components/fs3000/test.esp32-ard.yaml | 13 ++-- .../components/fs3000/test.esp32-c3-ard.yaml | 13 ++-- .../components/fs3000/test.esp32-c3-idf.yaml | 13 ++-- tests/components/fs3000/test.esp32-idf.yaml | 13 ++-- tests/components/fs3000/test.esp8266-ard.yaml | 13 ++-- tests/components/fs3000/test.rp2040-ard.yaml | 13 ++-- tests/components/ft5x06/common.yaml | 21 +++++++ tests/components/ft5x06/test.esp32-ard.yaml | 25 ++------ .../components/ft5x06/test.esp32-c3-ard.yaml | 25 ++------ .../components/ft5x06/test.esp32-c3-idf.yaml | 25 ++------ tests/components/ft5x06/test.esp32-idf.yaml | 25 ++------ tests/components/ft5x06/test.esp8266-ard.yaml | 25 ++------ tests/components/ft5x06/test.rp2040-ard.yaml | 25 ++------ tests/components/ft63x6/common.yaml | 36 +++++++++++ tests/components/ft63x6/test.esp32-ard.yaml | 46 +++----------- .../components/ft63x6/test.esp32-c3-ard.yaml | 28 +++------ .../components/ft63x6/test.esp32-c3-idf.yaml | 28 +++------ tests/components/ft63x6/test.esp32-idf.yaml | 28 +++------ tests/components/ft63x6/test.esp8266-ard.yaml | 28 +++------ tests/components/ft63x6/test.rp2040-ard.yaml | 28 +++------ tests/components/fujitsu_general/common.yaml | 7 +++ .../fujitsu_general/test.esp32-ard.yaml | 9 +-- .../fujitsu_general/test.esp32-c3-ard.yaml | 9 +-- .../fujitsu_general/test.esp32-c3-idf.yaml | 9 +-- .../fujitsu_general/test.esp32-idf.yaml | 9 +-- .../fujitsu_general/test.esp8266-ard.yaml | 9 +-- 34 files changed, 277 insertions(+), 672 deletions(-) create mode 100644 tests/components/fingerprint_grow/common.yaml create mode 100644 tests/components/fs3000/common.yaml create mode 100644 tests/components/ft5x06/common.yaml create mode 100644 tests/components/ft63x6/common.yaml create mode 100644 tests/components/fujitsu_general/common.yaml diff --git a/tests/components/fingerprint_grow/common.yaml b/tests/components/fingerprint_grow/common.yaml new file mode 100644 index 0000000000..e759ea5a02 --- /dev/null +++ b/tests/components/fingerprint_grow/common.yaml @@ -0,0 +1,56 @@ +esphome: + on_boot: + then: + - fingerprint_grow.enroll: + finger_id: 2 + num_scans: 2 + - fingerprint_grow.cancel_enroll: + - fingerprint_grow.delete: + finger_id: 2 + - fingerprint_grow.delete_all: + +uart: + - id: uart_fingerprint_grow + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 57600 + +fingerprint_grow: + sensing_pin: ${sensing_pin} + password: 0x12FE37DC + new_password: 0xA65B9840 + on_finger_scan_start: + - logger.log: test_fingerprint_grow_finger_scan_start + on_finger_scan_invalid: + - logger.log: test_fingerprint_grow_finger_scan_invalid + on_finger_scan_matched: + - logger.log: test_fingerprint_grow_finger_scan_matched + on_finger_scan_unmatched: + - logger.log: test_fingerprint_grow_finger_scan_unmatched + on_finger_scan_misplaced: + - logger.log: test_fingerprint_grow_finger_scan_misplaced + on_enrollment_scan: + - logger.log: test_fingerprint_grow_enrollment_scan + on_enrollment_done: + - logger.log: test_fingerprint_grow_node_enrollment_done + on_enrollment_failed: + - logger.log: test_fingerprint_grow_enrollment_failed + +binary_sensor: + - platform: fingerprint_grow + name: Fingerprint Enrolling + +sensor: + - platform: fingerprint_grow + fingerprint_count: + name: Fingerprint Count + status: + name: Fingerprint Status + capacity: + name: Fingerprint Capacity + security_level: + name: Fingerprint Security Level + last_finger_id: + name: Fingerprint Last Finger ID + last_confidence: + name: Fingerprint Last Confidence diff --git a/tests/components/fingerprint_grow/test.esp32-ard.yaml b/tests/components/fingerprint_grow/test.esp32-ard.yaml index 0950145a05..4aef3d8be6 100644 --- a/tests/components/fingerprint_grow/test.esp32-ard.yaml +++ b/tests/components/fingerprint_grow/test.esp32-ard.yaml @@ -1,56 +1,6 @@ -esphome: - on_boot: - then: - - fingerprint_grow.enroll: - finger_id: 2 - num_scans: 2 - - fingerprint_grow.cancel_enroll: - - fingerprint_grow.delete: - finger_id: 2 - - fingerprint_grow.delete_all: +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + sensing_pin: GPIO15 -uart: - - id: uart_fingerprint_grow - tx_pin: 17 - rx_pin: 16 - baud_rate: 57600 - -fingerprint_grow: - sensing_pin: 18 - password: 0x12FE37DC - new_password: 0xA65B9840 - on_finger_scan_start: - - logger.log: test_fingerprint_grow_finger_scan_start - on_finger_scan_invalid: - - logger.log: test_fingerprint_grow_finger_scan_invalid - on_finger_scan_matched: - - logger.log: test_fingerprint_grow_finger_scan_matched - on_finger_scan_unmatched: - - logger.log: test_fingerprint_grow_finger_scan_unmatched - on_finger_scan_misplaced: - - logger.log: test_fingerprint_grow_finger_scan_misplaced - on_enrollment_scan: - - logger.log: test_fingerprint_grow_enrollment_scan - on_enrollment_done: - - logger.log: test_fingerprint_grow_node_enrollment_done - on_enrollment_failed: - - logger.log: test_fingerprint_grow_enrollment_failed - -binary_sensor: - - platform: fingerprint_grow - name: Fingerprint Enrolling - -sensor: - - platform: fingerprint_grow - fingerprint_count: - name: Fingerprint Count - status: - name: Fingerprint Status - capacity: - name: Fingerprint Capacity - security_level: - name: Fingerprint Security Level - last_finger_id: - name: Fingerprint Last Finger ID - last_confidence: - name: Fingerprint Last Confidence +<<: !include common.yaml diff --git a/tests/components/fingerprint_grow/test.esp32-c3-ard.yaml b/tests/components/fingerprint_grow/test.esp32-c3-ard.yaml index e7ac08eb28..faab50e152 100644 --- a/tests/components/fingerprint_grow/test.esp32-c3-ard.yaml +++ b/tests/components/fingerprint_grow/test.esp32-c3-ard.yaml @@ -1,56 +1,6 @@ -esphome: - on_boot: - then: - - fingerprint_grow.enroll: - finger_id: 2 - num_scans: 2 - - fingerprint_grow.cancel_enroll: - - fingerprint_grow.delete: - finger_id: 2 - - fingerprint_grow.delete_all: +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + sensing_pin: GPIO6 -uart: - - id: uart_fingerprint_grow - tx_pin: 4 - rx_pin: 5 - baud_rate: 57600 - -fingerprint_grow: - sensing_pin: 6 - password: 0x12FE37DC - new_password: 0xA65B9840 - on_finger_scan_start: - - logger.log: test_fingerprint_grow_finger_scan_start - on_finger_scan_invalid: - - logger.log: test_fingerprint_grow_finger_scan_invalid - on_finger_scan_matched: - - logger.log: test_fingerprint_grow_finger_scan_matched - on_finger_scan_unmatched: - - logger.log: test_fingerprint_grow_finger_scan_unmatched - on_finger_scan_misplaced: - - logger.log: test_fingerprint_grow_finger_scan_misplaced - on_enrollment_scan: - - logger.log: test_fingerprint_grow_enrollment_scan - on_enrollment_done: - - logger.log: test_fingerprint_grow_node_enrollment_done - on_enrollment_failed: - - logger.log: test_fingerprint_grow_enrollment_failed - -binary_sensor: - - platform: fingerprint_grow - name: Fingerprint Enrolling - -sensor: - - platform: fingerprint_grow - fingerprint_count: - name: Fingerprint Count - status: - name: Fingerprint Status - capacity: - name: Fingerprint Capacity - security_level: - name: Fingerprint Security Level - last_finger_id: - name: Fingerprint Last Finger ID - last_confidence: - name: Fingerprint Last Confidence +<<: !include common.yaml diff --git a/tests/components/fingerprint_grow/test.esp32-c3-idf.yaml b/tests/components/fingerprint_grow/test.esp32-c3-idf.yaml index e7ac08eb28..faab50e152 100644 --- a/tests/components/fingerprint_grow/test.esp32-c3-idf.yaml +++ b/tests/components/fingerprint_grow/test.esp32-c3-idf.yaml @@ -1,56 +1,6 @@ -esphome: - on_boot: - then: - - fingerprint_grow.enroll: - finger_id: 2 - num_scans: 2 - - fingerprint_grow.cancel_enroll: - - fingerprint_grow.delete: - finger_id: 2 - - fingerprint_grow.delete_all: +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + sensing_pin: GPIO6 -uart: - - id: uart_fingerprint_grow - tx_pin: 4 - rx_pin: 5 - baud_rate: 57600 - -fingerprint_grow: - sensing_pin: 6 - password: 0x12FE37DC - new_password: 0xA65B9840 - on_finger_scan_start: - - logger.log: test_fingerprint_grow_finger_scan_start - on_finger_scan_invalid: - - logger.log: test_fingerprint_grow_finger_scan_invalid - on_finger_scan_matched: - - logger.log: test_fingerprint_grow_finger_scan_matched - on_finger_scan_unmatched: - - logger.log: test_fingerprint_grow_finger_scan_unmatched - on_finger_scan_misplaced: - - logger.log: test_fingerprint_grow_finger_scan_misplaced - on_enrollment_scan: - - logger.log: test_fingerprint_grow_enrollment_scan - on_enrollment_done: - - logger.log: test_fingerprint_grow_node_enrollment_done - on_enrollment_failed: - - logger.log: test_fingerprint_grow_enrollment_failed - -binary_sensor: - - platform: fingerprint_grow - name: Fingerprint Enrolling - -sensor: - - platform: fingerprint_grow - fingerprint_count: - name: Fingerprint Count - status: - name: Fingerprint Status - capacity: - name: Fingerprint Capacity - security_level: - name: Fingerprint Security Level - last_finger_id: - name: Fingerprint Last Finger ID - last_confidence: - name: Fingerprint Last Confidence +<<: !include common.yaml diff --git a/tests/components/fingerprint_grow/test.esp32-idf.yaml b/tests/components/fingerprint_grow/test.esp32-idf.yaml index 0950145a05..4aef3d8be6 100644 --- a/tests/components/fingerprint_grow/test.esp32-idf.yaml +++ b/tests/components/fingerprint_grow/test.esp32-idf.yaml @@ -1,56 +1,6 @@ -esphome: - on_boot: - then: - - fingerprint_grow.enroll: - finger_id: 2 - num_scans: 2 - - fingerprint_grow.cancel_enroll: - - fingerprint_grow.delete: - finger_id: 2 - - fingerprint_grow.delete_all: +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + sensing_pin: GPIO15 -uart: - - id: uart_fingerprint_grow - tx_pin: 17 - rx_pin: 16 - baud_rate: 57600 - -fingerprint_grow: - sensing_pin: 18 - password: 0x12FE37DC - new_password: 0xA65B9840 - on_finger_scan_start: - - logger.log: test_fingerprint_grow_finger_scan_start - on_finger_scan_invalid: - - logger.log: test_fingerprint_grow_finger_scan_invalid - on_finger_scan_matched: - - logger.log: test_fingerprint_grow_finger_scan_matched - on_finger_scan_unmatched: - - logger.log: test_fingerprint_grow_finger_scan_unmatched - on_finger_scan_misplaced: - - logger.log: test_fingerprint_grow_finger_scan_misplaced - on_enrollment_scan: - - logger.log: test_fingerprint_grow_enrollment_scan - on_enrollment_done: - - logger.log: test_fingerprint_grow_node_enrollment_done - on_enrollment_failed: - - logger.log: test_fingerprint_grow_enrollment_failed - -binary_sensor: - - platform: fingerprint_grow - name: Fingerprint Enrolling - -sensor: - - platform: fingerprint_grow - fingerprint_count: - name: Fingerprint Count - status: - name: Fingerprint Status - capacity: - name: Fingerprint Capacity - security_level: - name: Fingerprint Security Level - last_finger_id: - name: Fingerprint Last Finger ID - last_confidence: - name: Fingerprint Last Confidence +<<: !include common.yaml diff --git a/tests/components/fingerprint_grow/test.esp8266-ard.yaml b/tests/components/fingerprint_grow/test.esp8266-ard.yaml index 1d00d977b9..f2a864596a 100644 --- a/tests/components/fingerprint_grow/test.esp8266-ard.yaml +++ b/tests/components/fingerprint_grow/test.esp8266-ard.yaml @@ -1,56 +1,6 @@ -esphome: - on_boot: - then: - - fingerprint_grow.enroll: - finger_id: 2 - num_scans: 2 - - fingerprint_grow.cancel_enroll: - - fingerprint_grow.delete: - finger_id: 2 - - fingerprint_grow.delete_all: +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + sensing_pin: GPIO15 -uart: - - id: uart_fingerprint_grow - tx_pin: 4 - rx_pin: 5 - baud_rate: 57600 - -fingerprint_grow: - sensing_pin: 16 - password: 0x12FE37DC - new_password: 0xA65B9840 - on_finger_scan_start: - - logger.log: test_fingerprint_grow_finger_scan_start - on_finger_scan_invalid: - - logger.log: test_fingerprint_grow_finger_scan_invalid - on_finger_scan_matched: - - logger.log: test_fingerprint_grow_finger_scan_matched - on_finger_scan_unmatched: - - logger.log: test_fingerprint_grow_finger_scan_unmatched - on_finger_scan_misplaced: - - logger.log: test_fingerprint_grow_finger_scan_misplaced - on_enrollment_scan: - - logger.log: test_fingerprint_grow_enrollment_scan - on_enrollment_done: - - logger.log: test_fingerprint_grow_node_enrollment_done - on_enrollment_failed: - - logger.log: test_fingerprint_grow_enrollment_failed - -binary_sensor: - - platform: fingerprint_grow - name: Fingerprint Enrolling - -sensor: - - platform: fingerprint_grow - fingerprint_count: - name: Fingerprint Count - status: - name: Fingerprint Status - capacity: - name: Fingerprint Capacity - security_level: - name: Fingerprint Security Level - last_finger_id: - name: Fingerprint Last Finger ID - last_confidence: - name: Fingerprint Last Confidence +<<: !include common.yaml diff --git a/tests/components/fingerprint_grow/test.rp2040-ard.yaml b/tests/components/fingerprint_grow/test.rp2040-ard.yaml index e7ac08eb28..faab50e152 100644 --- a/tests/components/fingerprint_grow/test.rp2040-ard.yaml +++ b/tests/components/fingerprint_grow/test.rp2040-ard.yaml @@ -1,56 +1,6 @@ -esphome: - on_boot: - then: - - fingerprint_grow.enroll: - finger_id: 2 - num_scans: 2 - - fingerprint_grow.cancel_enroll: - - fingerprint_grow.delete: - finger_id: 2 - - fingerprint_grow.delete_all: +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + sensing_pin: GPIO6 -uart: - - id: uart_fingerprint_grow - tx_pin: 4 - rx_pin: 5 - baud_rate: 57600 - -fingerprint_grow: - sensing_pin: 6 - password: 0x12FE37DC - new_password: 0xA65B9840 - on_finger_scan_start: - - logger.log: test_fingerprint_grow_finger_scan_start - on_finger_scan_invalid: - - logger.log: test_fingerprint_grow_finger_scan_invalid - on_finger_scan_matched: - - logger.log: test_fingerprint_grow_finger_scan_matched - on_finger_scan_unmatched: - - logger.log: test_fingerprint_grow_finger_scan_unmatched - on_finger_scan_misplaced: - - logger.log: test_fingerprint_grow_finger_scan_misplaced - on_enrollment_scan: - - logger.log: test_fingerprint_grow_enrollment_scan - on_enrollment_done: - - logger.log: test_fingerprint_grow_node_enrollment_done - on_enrollment_failed: - - logger.log: test_fingerprint_grow_enrollment_failed - -binary_sensor: - - platform: fingerprint_grow - name: Fingerprint Enrolling - -sensor: - - platform: fingerprint_grow - fingerprint_count: - name: Fingerprint Count - status: - name: Fingerprint Status - capacity: - name: Fingerprint Capacity - security_level: - name: Fingerprint Security Level - last_finger_id: - name: Fingerprint Last Finger ID - last_confidence: - name: Fingerprint Last Confidence +<<: !include common.yaml diff --git a/tests/components/fs3000/common.yaml b/tests/components/fs3000/common.yaml new file mode 100644 index 0000000000..e87ac28aa9 --- /dev/null +++ b/tests/components/fs3000/common.yaml @@ -0,0 +1,10 @@ +i2c: + - id: i2c_fs3000 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: fs3000 + name: Air Velocity + model: 1005 + update_interval: 60s diff --git a/tests/components/fs3000/test.esp32-ard.yaml b/tests/components/fs3000/test.esp32-ard.yaml index 53b49cc9a2..63c3bd6afd 100644 --- a/tests/components/fs3000/test.esp32-ard.yaml +++ b/tests/components/fs3000/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_fs3000 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: fs3000 - name: Air Velocity - model: 1005 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/fs3000/test.esp32-c3-ard.yaml b/tests/components/fs3000/test.esp32-c3-ard.yaml index 69de83b463..ee2c29ca4e 100644 --- a/tests/components/fs3000/test.esp32-c3-ard.yaml +++ b/tests/components/fs3000/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_fs3000 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: fs3000 - name: Air Velocity - model: 1005 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/fs3000/test.esp32-c3-idf.yaml b/tests/components/fs3000/test.esp32-c3-idf.yaml index 69de83b463..ee2c29ca4e 100644 --- a/tests/components/fs3000/test.esp32-c3-idf.yaml +++ b/tests/components/fs3000/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_fs3000 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: fs3000 - name: Air Velocity - model: 1005 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/fs3000/test.esp32-idf.yaml b/tests/components/fs3000/test.esp32-idf.yaml index 53b49cc9a2..63c3bd6afd 100644 --- a/tests/components/fs3000/test.esp32-idf.yaml +++ b/tests/components/fs3000/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_fs3000 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: fs3000 - name: Air Velocity - model: 1005 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/fs3000/test.esp8266-ard.yaml b/tests/components/fs3000/test.esp8266-ard.yaml index 69de83b463..ee2c29ca4e 100644 --- a/tests/components/fs3000/test.esp8266-ard.yaml +++ b/tests/components/fs3000/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_fs3000 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: fs3000 - name: Air Velocity - model: 1005 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/fs3000/test.rp2040-ard.yaml b/tests/components/fs3000/test.rp2040-ard.yaml index 69de83b463..ee2c29ca4e 100644 --- a/tests/components/fs3000/test.rp2040-ard.yaml +++ b/tests/components/fs3000/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_fs3000 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: fs3000 - name: Air Velocity - model: 1005 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ft5x06/common.yaml b/tests/components/ft5x06/common.yaml new file mode 100644 index 0000000000..322ee88b6d --- /dev/null +++ b/tests/components/ft5x06/common.yaml @@ -0,0 +1,21 @@ +i2c: + - id: i2c_ft5x06 + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1306_i2c + id: ssd1306_display + model: SSD1306_128X64 + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + +touchscreen: + - platform: ft5x06 + on_touch: + - logger.log: + format: Touch at (%d, %d) + args: [touch.x, touch.y] diff --git a/tests/components/ft5x06/test.esp32-ard.yaml b/tests/components/ft5x06/test.esp32-ard.yaml index 648929896d..1ca773e06c 100644 --- a/tests/components/ft5x06/test.esp32-ard.yaml +++ b/tests/components/ft5x06/test.esp32-ard.yaml @@ -1,21 +1,6 @@ -i2c: - - id: i2c_ft5x06 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 18 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft5x06 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ft5x06/test.esp32-c3-ard.yaml b/tests/components/ft5x06/test.esp32-c3-ard.yaml index 4fa9532f53..1e6670c196 100644 --- a/tests/components/ft5x06/test.esp32-c3-ard.yaml +++ b/tests/components/ft5x06/test.esp32-c3-ard.yaml @@ -1,21 +1,6 @@ -i2c: - - id: i2c_ft5x06 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft5x06 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ft5x06/test.esp32-c3-idf.yaml b/tests/components/ft5x06/test.esp32-c3-idf.yaml index 4fa9532f53..1e6670c196 100644 --- a/tests/components/ft5x06/test.esp32-c3-idf.yaml +++ b/tests/components/ft5x06/test.esp32-c3-idf.yaml @@ -1,21 +1,6 @@ -i2c: - - id: i2c_ft5x06 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft5x06 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ft5x06/test.esp32-idf.yaml b/tests/components/ft5x06/test.esp32-idf.yaml index 648929896d..1ca773e06c 100644 --- a/tests/components/ft5x06/test.esp32-idf.yaml +++ b/tests/components/ft5x06/test.esp32-idf.yaml @@ -1,21 +1,6 @@ -i2c: - - id: i2c_ft5x06 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 18 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft5x06 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ft5x06/test.esp8266-ard.yaml b/tests/components/ft5x06/test.esp8266-ard.yaml index 4fa9532f53..dfdc12a3d1 100644 --- a/tests/components/ft5x06/test.esp8266-ard.yaml +++ b/tests/components/ft5x06/test.esp8266-ard.yaml @@ -1,21 +1,6 @@ -i2c: - - id: i2c_ft5x06 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO15 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft5x06 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ft5x06/test.rp2040-ard.yaml b/tests/components/ft5x06/test.rp2040-ard.yaml index 4fa9532f53..1e6670c196 100644 --- a/tests/components/ft5x06/test.rp2040-ard.yaml +++ b/tests/components/ft5x06/test.rp2040-ard.yaml @@ -1,21 +1,6 @@ -i2c: - - id: i2c_ft5x06 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft5x06 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ft63x6/common.yaml b/tests/components/ft63x6/common.yaml new file mode 100644 index 0000000000..e91266123e --- /dev/null +++ b/tests/components/ft63x6/common.yaml @@ -0,0 +1,36 @@ +spi: + - id: spi_ft63x6 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +i2c: + - id: i2c_ft63x6 + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1306_i2c + id: ssd1306_display + model: SSD1306_128X64 + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + +touchscreen: + - platform: ft63x6 + interrupt_pin: ${interrupt_pin} + transform: + swap_xy: true + mirror_x: false + mirror_y: true + on_touch: + - logger.log: + format: tp touched + on_update: + - logger.log: + format: to updated + on_release: + - logger.log: + format: to released diff --git a/tests/components/ft63x6/test.esp32-ard.yaml b/tests/components/ft63x6/test.esp32-ard.yaml index 5c43cdff45..47b5796e8b 100644 --- a/tests/components/ft63x6/test.esp32-ard.yaml +++ b/tests/components/ft63x6/test.esp32-ard.yaml @@ -1,39 +1,9 @@ -spi: - clk_pin: 14 - mosi_pin: 13 +substitutions: + clk_pin: GPIO0 + mosi_pin: GPIO2 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 -i2c: - sda: GPIO18 - scl: GPIO19 - -display: - - id: my_display - platform: ili9xxx - dimensions: 480x320 - model: ST7796 - cs_pin: 15 - dc_pin: 21 - reset_pin: 22 - transform: - swap_xy: true - mirror_x: true - mirror_y: true - auto_clear_enabled: false - invert_colors: false - -touchscreen: - - platform: ft63x6 - interrupt_pin: GPIO39 - transform: - swap_xy: true - mirror_x: false - mirror_y: true - on_touch: - - logger.log: - format: tp touched - on_update: - - logger.log: - format: to updated - on_release: - - logger.log: - format: to released +<<: !include common.yaml diff --git a/tests/components/ft63x6/test.esp32-c3-ard.yaml b/tests/components/ft63x6/test.esp32-c3-ard.yaml index 19ca4cfc19..397ac1e464 100644 --- a/tests/components/ft63x6/test.esp32-c3-ard.yaml +++ b/tests/components/ft63x6/test.esp32-c3-ard.yaml @@ -1,21 +1,9 @@ -i2c: - - id: i2c_ft63x6 - scl: 5 - sda: 4 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft63x6 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ft63x6/test.esp32-c3-idf.yaml b/tests/components/ft63x6/test.esp32-c3-idf.yaml index 19ca4cfc19..397ac1e464 100644 --- a/tests/components/ft63x6/test.esp32-c3-idf.yaml +++ b/tests/components/ft63x6/test.esp32-c3-idf.yaml @@ -1,21 +1,9 @@ -i2c: - - id: i2c_ft63x6 - scl: 5 - sda: 4 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft63x6 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ft63x6/test.esp32-idf.yaml b/tests/components/ft63x6/test.esp32-idf.yaml index 5ceb107e31..47b5796e8b 100644 --- a/tests/components/ft63x6/test.esp32-idf.yaml +++ b/tests/components/ft63x6/test.esp32-idf.yaml @@ -1,21 +1,9 @@ -i2c: - - id: i2c_ft63x6 - scl: 16 - sda: 17 +substitutions: + clk_pin: GPIO0 + mosi_pin: GPIO2 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 18 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft63x6 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ft63x6/test.esp8266-ard.yaml b/tests/components/ft63x6/test.esp8266-ard.yaml index 19ca4cfc19..a4223733af 100644 --- a/tests/components/ft63x6/test.esp8266-ard.yaml +++ b/tests/components/ft63x6/test.esp8266-ard.yaml @@ -1,21 +1,9 @@ -i2c: - - id: i2c_ft63x6 - scl: 5 - sda: 4 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + scl_pin: GPIO5 + sda_pin: GPIO4 + interrupt_pin: GPIO12 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft63x6 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ft63x6/test.rp2040-ard.yaml b/tests/components/ft63x6/test.rp2040-ard.yaml index 19ca4cfc19..397ac1e464 100644 --- a/tests/components/ft63x6/test.rp2040-ard.yaml +++ b/tests/components/ft63x6/test.rp2040-ard.yaml @@ -1,21 +1,9 @@ -i2c: - - id: i2c_ft63x6 - scl: 5 - sda: 4 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: ft63x6 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/fujitsu_general/common.yaml b/tests/components/fujitsu_general/common.yaml new file mode 100644 index 0000000000..3359b89f2a --- /dev/null +++ b/tests/components/fujitsu_general/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: fujitsu_general + name: Fujitsu General Climate diff --git a/tests/components/fujitsu_general/test.esp32-ard.yaml b/tests/components/fujitsu_general/test.esp32-ard.yaml index b4146f2a18..7b012aa64c 100644 --- a/tests/components/fujitsu_general/test.esp32-ard.yaml +++ b/tests/components/fujitsu_general/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: fujitsu_general - name: Fujitsu General Climate +<<: !include common.yaml diff --git a/tests/components/fujitsu_general/test.esp32-c3-ard.yaml b/tests/components/fujitsu_general/test.esp32-c3-ard.yaml index b4146f2a18..7b012aa64c 100644 --- a/tests/components/fujitsu_general/test.esp32-c3-ard.yaml +++ b/tests/components/fujitsu_general/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: fujitsu_general - name: Fujitsu General Climate +<<: !include common.yaml diff --git a/tests/components/fujitsu_general/test.esp32-c3-idf.yaml b/tests/components/fujitsu_general/test.esp32-c3-idf.yaml index b4146f2a18..7b012aa64c 100644 --- a/tests/components/fujitsu_general/test.esp32-c3-idf.yaml +++ b/tests/components/fujitsu_general/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: fujitsu_general - name: Fujitsu General Climate +<<: !include common.yaml diff --git a/tests/components/fujitsu_general/test.esp32-idf.yaml b/tests/components/fujitsu_general/test.esp32-idf.yaml index b4146f2a18..7b012aa64c 100644 --- a/tests/components/fujitsu_general/test.esp32-idf.yaml +++ b/tests/components/fujitsu_general/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: fujitsu_general - name: Fujitsu General Climate +<<: !include common.yaml diff --git a/tests/components/fujitsu_general/test.esp8266-ard.yaml b/tests/components/fujitsu_general/test.esp8266-ard.yaml index 2a05bdde6b..f5097fcf5f 100644 --- a/tests/components/fujitsu_general/test.esp8266-ard.yaml +++ b/tests/components/fujitsu_general/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: fujitsu_general - name: Fujitsu General Climate +<<: !include common.yaml From 211aee91e53db1923611c422b3f5ae795ba06aee Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:05:45 -0600 Subject: [PATCH 150/194] [CI] Consolidate some tests (G) (#8196) --- tests/components/gcja5/common.yaml | 25 ++++ tests/components/gcja5/test.esp32-ard.yaml | 28 +--- tests/components/gcja5/test.esp32-c3-ard.yaml | 28 +--- tests/components/gcja5/test.esp32-c3-idf.yaml | 28 +--- tests/components/gcja5/test.esp32-idf.yaml | 28 +--- tests/components/gcja5/test.esp8266-ard.yaml | 28 +--- tests/components/gcja5/test.rp2040-ard.yaml | 28 +--- tests/components/gdk101/common.yaml | 7 +- tests/components/gdk101/test.esp32-ard.yaml | 4 +- tests/components/gdk101/test.esp32-idf.yaml | 4 +- tests/components/gdk101/test.esp8266-ard.yaml | 4 +- tests/components/gdk101/test.rp2040-ard.yaml | 4 +- tests/components/gp2y1010au0f/common.yaml | 15 +++ .../gp2y1010au0f/test.esp32-ard.yaml | 5 + .../gp2y1010au0f/test.esp32-c3-ard.yaml | 5 + .../gp2y1010au0f/test.esp32-c3-idf.yaml | 5 + .../gp2y1010au0f/test.esp32-idf.yaml | 19 +-- .../gp2y1010au0f/test.esp8266-ard.yaml | 5 + .../gp2y1010au0f/test.rp2040-ard.yaml | 5 + tests/components/gp8403/common.yaml | 20 +++ tests/components/gp8403/test.esp32-ard.yaml | 23 +--- .../components/gp8403/test.esp32-c3-ard.yaml | 23 +--- .../components/gp8403/test.esp32-c3-idf.yaml | 23 +--- tests/components/gp8403/test.esp32-idf.yaml | 23 +--- tests/components/gp8403/test.esp8266-ard.yaml | 23 +--- tests/components/gp8403/test.rp2040-ard.yaml | 23 +--- tests/components/gpio/common.yaml | 14 ++ tests/components/gpio/test.esp32-ard.yaml | 18 +-- tests/components/gpio/test.esp32-c3-ard.yaml | 18 +-- tests/components/gpio/test.esp32-c3-idf.yaml | 18 +-- tests/components/gpio/test.esp32-idf.yaml | 18 +-- tests/components/gpio/test.esp8266-ard.yaml | 18 +-- tests/components/gpio/test.rp2040-ard.yaml | 18 +-- tests/components/gps/common.yaml | 14 ++ tests/components/gps/test.esp32-ard.yaml | 17 +-- tests/components/gps/test.esp32-c3-ard.yaml | 17 +-- tests/components/gps/test.esp8266-ard.yaml | 17 +-- tests/components/gps/test.rp2040-ard.yaml | 17 +-- tests/components/graph/common.yaml | 25 ++++ tests/components/graph/test.esp32-ard.yaml | 29 +--- tests/components/graph/test.esp32-c3-ard.yaml | 29 +--- tests/components/graph/test.esp32-c3-idf.yaml | 29 +--- tests/components/graph/test.esp32-idf.yaml | 29 +--- tests/components/graph/test.esp8266-ard.yaml | 29 +--- tests/components/graph/test.rp2040-ard.yaml | 29 +--- .../graphical_display_menu/common.yaml | 120 +++++++++++++++++ .../test.esp32-ard.yaml | 124 +----------------- .../test.esp32-c3-ard.yaml | 124 +----------------- .../test.esp32-c3-idf.yaml | 124 +----------------- .../test.esp32-idf.yaml | 124 +----------------- .../test.esp8266-ard.yaml | 124 +----------------- .../test.rp2040-ard.yaml | 124 +----------------- tests/components/gree/common.yaml | 8 ++ tests/components/gree/test.esp32-ard.yaml | 10 +- tests/components/gree/test.esp32-c3-ard.yaml | 10 +- tests/components/gree/test.esp32-c3-idf.yaml | 10 +- tests/components/gree/test.esp32-idf.yaml | 10 +- tests/components/gree/test.esp8266-ard.yaml | 10 +- tests/components/grove_gas_mc_v2/common.yaml | 6 +- .../grove_gas_mc_v2/test.esp32-ard.yaml | 7 +- .../grove_gas_mc_v2/test.esp32-c3-ard.yaml | 5 + .../grove_gas_mc_v2/test.esp32-c3-idf.yaml | 5 + .../grove_gas_mc_v2/test.esp32-idf.yaml | 7 +- .../grove_gas_mc_v2/test.esp8266-ard.yaml | 7 +- .../grove_gas_mc_v2/test.rp2040-ard.yaml | 7 +- tests/components/grove_tb6612fng/common.yaml | 23 ++++ .../grove_tb6612fng/test.esp32-ard.yaml | 26 +--- .../grove_tb6612fng/test.esp32-c3-ard.yaml | 26 +--- .../grove_tb6612fng/test.esp32-c3-idf.yaml | 26 +--- .../grove_tb6612fng/test.esp32-idf.yaml | 26 +--- .../grove_tb6612fng/test.esp8266-ard.yaml | 26 +--- .../grove_tb6612fng/test.rp2040-ard.yaml | 26 +--- tests/components/growatt_solar/common.yaml | 62 +++++++++ .../growatt_solar/test.esp32-ard.yaml | 66 +--------- .../growatt_solar/test.esp32-c3-ard.yaml | 66 +--------- .../growatt_solar/test.esp32-c3-idf.yaml | 66 +--------- .../growatt_solar/test.esp32-idf.yaml | 66 +--------- .../growatt_solar/test.esp8266-ard.yaml | 66 +--------- .../growatt_solar/test.rp2040-ard.yaml | 66 +--------- 79 files changed, 616 insertions(+), 1823 deletions(-) create mode 100644 tests/components/gcja5/common.yaml create mode 100644 tests/components/gp2y1010au0f/common.yaml create mode 100644 tests/components/gp2y1010au0f/test.esp32-ard.yaml create mode 100644 tests/components/gp2y1010au0f/test.esp32-c3-ard.yaml create mode 100644 tests/components/gp2y1010au0f/test.esp32-c3-idf.yaml create mode 100644 tests/components/gp2y1010au0f/test.esp8266-ard.yaml create mode 100644 tests/components/gp2y1010au0f/test.rp2040-ard.yaml create mode 100644 tests/components/gp8403/common.yaml create mode 100644 tests/components/gpio/common.yaml create mode 100644 tests/components/gps/common.yaml create mode 100644 tests/components/graph/common.yaml create mode 100644 tests/components/graphical_display_menu/common.yaml create mode 100644 tests/components/gree/common.yaml create mode 100644 tests/components/grove_gas_mc_v2/test.esp32-c3-ard.yaml create mode 100644 tests/components/grove_gas_mc_v2/test.esp32-c3-idf.yaml create mode 100644 tests/components/grove_tb6612fng/common.yaml create mode 100644 tests/components/growatt_solar/common.yaml diff --git a/tests/components/gcja5/common.yaml b/tests/components/gcja5/common.yaml new file mode 100644 index 0000000000..8f6250045d --- /dev/null +++ b/tests/components/gcja5/common.yaml @@ -0,0 +1,25 @@ +uart: + - id: uart_gcja5 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + parity: EVEN + +sensor: + - platform: gcja5 + pm_1_0: + name: "Particulate Matter <1.0µm Concentration" + pm_2_5: + name: "Particulate Matter <2.5µm Concentration" + pm_10_0: + name: "Particulate Matter <10.0µm Concentration" + pmc_0_5: + name: "PMC 0.5" + pmc_1_0: + name: "PMC 1.0" + pmc_2_5: + name: "PMC 2.5" + pmc_5_0: + name: "PMC 5.0" + pmc_10_0: + name: "PMC 10.0" diff --git a/tests/components/gcja5/test.esp32-ard.yaml b/tests/components/gcja5/test.esp32-ard.yaml index bc0f89eb9e..811f6b72a6 100644 --- a/tests/components/gcja5/test.esp32-ard.yaml +++ b/tests/components/gcja5/test.esp32-ard.yaml @@ -1,25 +1,5 @@ -uart: - - id: uart_gcja5 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - parity: EVEN +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: gcja5 - pm_1_0: - name: "Particulate Matter <1.0µm Concentration" - pm_2_5: - name: "Particulate Matter <2.5µm Concentration" - pm_10_0: - name: "Particulate Matter <10.0µm Concentration" - pmc_0_5: - name: "PMC 0.5" - pmc_1_0: - name: "PMC 1.0" - pmc_2_5: - name: "PMC 2.5" - pmc_5_0: - name: "PMC 5.0" - pmc_10_0: - name: "PMC 10.0" +<<: !include common.yaml diff --git a/tests/components/gcja5/test.esp32-c3-ard.yaml b/tests/components/gcja5/test.esp32-c3-ard.yaml index ec8765be52..b516342f3b 100644 --- a/tests/components/gcja5/test.esp32-c3-ard.yaml +++ b/tests/components/gcja5/test.esp32-c3-ard.yaml @@ -1,25 +1,5 @@ -uart: - - id: uart_gcja5 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: gcja5 - pm_1_0: - name: "Particulate Matter <1.0µm Concentration" - pm_2_5: - name: "Particulate Matter <2.5µm Concentration" - pm_10_0: - name: "Particulate Matter <10.0µm Concentration" - pmc_0_5: - name: "PMC 0.5" - pmc_1_0: - name: "PMC 1.0" - pmc_2_5: - name: "PMC 2.5" - pmc_5_0: - name: "PMC 5.0" - pmc_10_0: - name: "PMC 10.0" +<<: !include common.yaml diff --git a/tests/components/gcja5/test.esp32-c3-idf.yaml b/tests/components/gcja5/test.esp32-c3-idf.yaml index ec8765be52..b516342f3b 100644 --- a/tests/components/gcja5/test.esp32-c3-idf.yaml +++ b/tests/components/gcja5/test.esp32-c3-idf.yaml @@ -1,25 +1,5 @@ -uart: - - id: uart_gcja5 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: gcja5 - pm_1_0: - name: "Particulate Matter <1.0µm Concentration" - pm_2_5: - name: "Particulate Matter <2.5µm Concentration" - pm_10_0: - name: "Particulate Matter <10.0µm Concentration" - pmc_0_5: - name: "PMC 0.5" - pmc_1_0: - name: "PMC 1.0" - pmc_2_5: - name: "PMC 2.5" - pmc_5_0: - name: "PMC 5.0" - pmc_10_0: - name: "PMC 10.0" +<<: !include common.yaml diff --git a/tests/components/gcja5/test.esp32-idf.yaml b/tests/components/gcja5/test.esp32-idf.yaml index bc0f89eb9e..811f6b72a6 100644 --- a/tests/components/gcja5/test.esp32-idf.yaml +++ b/tests/components/gcja5/test.esp32-idf.yaml @@ -1,25 +1,5 @@ -uart: - - id: uart_gcja5 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - parity: EVEN +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: gcja5 - pm_1_0: - name: "Particulate Matter <1.0µm Concentration" - pm_2_5: - name: "Particulate Matter <2.5µm Concentration" - pm_10_0: - name: "Particulate Matter <10.0µm Concentration" - pmc_0_5: - name: "PMC 0.5" - pmc_1_0: - name: "PMC 1.0" - pmc_2_5: - name: "PMC 2.5" - pmc_5_0: - name: "PMC 5.0" - pmc_10_0: - name: "PMC 10.0" +<<: !include common.yaml diff --git a/tests/components/gcja5/test.esp8266-ard.yaml b/tests/components/gcja5/test.esp8266-ard.yaml index ec8765be52..b516342f3b 100644 --- a/tests/components/gcja5/test.esp8266-ard.yaml +++ b/tests/components/gcja5/test.esp8266-ard.yaml @@ -1,25 +1,5 @@ -uart: - - id: uart_gcja5 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: gcja5 - pm_1_0: - name: "Particulate Matter <1.0µm Concentration" - pm_2_5: - name: "Particulate Matter <2.5µm Concentration" - pm_10_0: - name: "Particulate Matter <10.0µm Concentration" - pmc_0_5: - name: "PMC 0.5" - pmc_1_0: - name: "PMC 1.0" - pmc_2_5: - name: "PMC 2.5" - pmc_5_0: - name: "PMC 5.0" - pmc_10_0: - name: "PMC 10.0" +<<: !include common.yaml diff --git a/tests/components/gcja5/test.rp2040-ard.yaml b/tests/components/gcja5/test.rp2040-ard.yaml index ec8765be52..b516342f3b 100644 --- a/tests/components/gcja5/test.rp2040-ard.yaml +++ b/tests/components/gcja5/test.rp2040-ard.yaml @@ -1,25 +1,5 @@ -uart: - - id: uart_gcja5 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: gcja5 - pm_1_0: - name: "Particulate Matter <1.0µm Concentration" - pm_2_5: - name: "Particulate Matter <2.5µm Concentration" - pm_10_0: - name: "Particulate Matter <10.0µm Concentration" - pmc_0_5: - name: "PMC 0.5" - pmc_1_0: - name: "PMC 1.0" - pmc_2_5: - name: "PMC 2.5" - pmc_5_0: - name: "PMC 5.0" - pmc_10_0: - name: "PMC 10.0" +<<: !include common.yaml diff --git a/tests/components/gdk101/common.yaml b/tests/components/gdk101/common.yaml index f886fc415b..7805ad43f0 100644 --- a/tests/components/gdk101/common.yaml +++ b/tests/components/gdk101/common.yaml @@ -1,11 +1,10 @@ i2c: - id: i2c_bus - sda: ${i2c_sda} - scl: ${i2c_scl} + - id: i2c_gdk101 + scl: ${scl_pin} + sda: ${sda_pin} gdk101: id: my_gdk101 - i2c_id: i2c_bus sensor: - platform: gdk101 diff --git a/tests/components/gdk101/test.esp32-ard.yaml b/tests/components/gdk101/test.esp32-ard.yaml index 1037d5d35b..63c3bd6afd 100644 --- a/tests/components/gdk101/test.esp32-ard.yaml +++ b/tests/components/gdk101/test.esp32-ard.yaml @@ -1,5 +1,5 @@ substitutions: - i2c_scl: GPIO16 - i2c_sda: GPIO17 + scl_pin: GPIO16 + sda_pin: GPIO17 <<: !include common.yaml diff --git a/tests/components/gdk101/test.esp32-idf.yaml b/tests/components/gdk101/test.esp32-idf.yaml index 1037d5d35b..63c3bd6afd 100644 --- a/tests/components/gdk101/test.esp32-idf.yaml +++ b/tests/components/gdk101/test.esp32-idf.yaml @@ -1,5 +1,5 @@ substitutions: - i2c_scl: GPIO16 - i2c_sda: GPIO17 + scl_pin: GPIO16 + sda_pin: GPIO17 <<: !include common.yaml diff --git a/tests/components/gdk101/test.esp8266-ard.yaml b/tests/components/gdk101/test.esp8266-ard.yaml index d7ae0d5161..ee2c29ca4e 100644 --- a/tests/components/gdk101/test.esp8266-ard.yaml +++ b/tests/components/gdk101/test.esp8266-ard.yaml @@ -1,5 +1,5 @@ substitutions: - i2c_scl: GPIO5 - i2c_sda: GPIO4 + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/gdk101/test.rp2040-ard.yaml b/tests/components/gdk101/test.rp2040-ard.yaml index d7ae0d5161..ee2c29ca4e 100644 --- a/tests/components/gdk101/test.rp2040-ard.yaml +++ b/tests/components/gdk101/test.rp2040-ard.yaml @@ -1,5 +1,5 @@ substitutions: - i2c_scl: GPIO5 - i2c_sda: GPIO4 + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/gp2y1010au0f/common.yaml b/tests/components/gp2y1010au0f/common.yaml new file mode 100644 index 0000000000..95112fa712 --- /dev/null +++ b/tests/components/gp2y1010au0f/common.yaml @@ -0,0 +1,15 @@ +sensor: + - platform: adc + id: adc_sensor + pin: ${adc_pin} + - platform: gp2y1010au0f + sensor: adc_sensor + name: Dust Sensor + adc_voltage_offset: 0.2 + adc_voltage_multiplier: 3.3 + output: dust_sensor_led + +output: + - platform: gpio + id: dust_sensor_led + pin: ${output_pin} diff --git a/tests/components/gp2y1010au0f/test.esp32-ard.yaml b/tests/components/gp2y1010au0f/test.esp32-ard.yaml new file mode 100644 index 0000000000..d9494a95b7 --- /dev/null +++ b/tests/components/gp2y1010au0f/test.esp32-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + adc_pin: A0 + output_pin: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/gp2y1010au0f/test.esp32-c3-ard.yaml b/tests/components/gp2y1010au0f/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..0e331c893c --- /dev/null +++ b/tests/components/gp2y1010au0f/test.esp32-c3-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + adc_pin: GPIO0 + output_pin: GPIO1 + +<<: !include common.yaml diff --git a/tests/components/gp2y1010au0f/test.esp32-c3-idf.yaml b/tests/components/gp2y1010au0f/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..0e331c893c --- /dev/null +++ b/tests/components/gp2y1010au0f/test.esp32-c3-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + adc_pin: GPIO0 + output_pin: GPIO1 + +<<: !include common.yaml diff --git a/tests/components/gp2y1010au0f/test.esp32-idf.yaml b/tests/components/gp2y1010au0f/test.esp32-idf.yaml index eb5ad0ea67..d9494a95b7 100644 --- a/tests/components/gp2y1010au0f/test.esp32-idf.yaml +++ b/tests/components/gp2y1010au0f/test.esp32-idf.yaml @@ -1,16 +1,5 @@ -sensor: - - platform: adc - pin: GPIO36 - id: adc_sensor +substitutions: + adc_pin: A0 + output_pin: GPIO14 - - platform: gp2y1010au0f - sensor: adc_sensor - name: Dust Sensor - adc_voltage_offset: 0.2 - adc_voltage_multiplier: 3.3 - output: dust_sensor_led - -output: - - platform: gpio - id: dust_sensor_led - pin: GPIO32 +<<: !include common.yaml diff --git a/tests/components/gp2y1010au0f/test.esp8266-ard.yaml b/tests/components/gp2y1010au0f/test.esp8266-ard.yaml new file mode 100644 index 0000000000..a61053426a --- /dev/null +++ b/tests/components/gp2y1010au0f/test.esp8266-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + adc_pin: A0 + output_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/gp2y1010au0f/test.rp2040-ard.yaml b/tests/components/gp2y1010au0f/test.rp2040-ard.yaml new file mode 100644 index 0000000000..e00f19941c --- /dev/null +++ b/tests/components/gp2y1010au0f/test.rp2040-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + adc_pin: GPIO26 + output_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/gp8403/common.yaml b/tests/components/gp8403/common.yaml new file mode 100644 index 0000000000..7074185273 --- /dev/null +++ b/tests/components/gp8403/common.yaml @@ -0,0 +1,20 @@ +i2c: + - id: i2c_gp8403 + scl: ${scl_pin} + sda: ${sda_pin} + +gp8403: + - id: gp8403_5v + voltage: 5V + - id: gp8403_10v + voltage: 10V + +output: + - platform: gp8403 + id: gp8403_output_0 + gp8403_id: gp8403_5v + channel: 0 + - platform: gp8403 + gp8403_id: gp8403_10v + id: gp8403_output_1 + channel: 1 diff --git a/tests/components/gp8403/test.esp32-ard.yaml b/tests/components/gp8403/test.esp32-ard.yaml index 8470a303e1..63c3bd6afd 100644 --- a/tests/components/gp8403/test.esp32-ard.yaml +++ b/tests/components/gp8403/test.esp32-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_gp8403 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -gp8403: - - id: gp8403_5v - voltage: 5V - - id: gp8403_10v - voltage: 10V - -output: - - platform: gp8403 - id: gp8403_output_0 - gp8403_id: gp8403_5v - channel: 0 - - platform: gp8403 - gp8403_id: gp8403_10v - id: gp8403_output_1 - channel: 1 +<<: !include common.yaml diff --git a/tests/components/gp8403/test.esp32-c3-ard.yaml b/tests/components/gp8403/test.esp32-c3-ard.yaml index fbc40b948b..ee2c29ca4e 100644 --- a/tests/components/gp8403/test.esp32-c3-ard.yaml +++ b/tests/components/gp8403/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_gp8403 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -gp8403: - - id: gp8403_5v - voltage: 5V - - id: gp8403_10v - voltage: 10V - -output: - - platform: gp8403 - id: gp8403_output_0 - gp8403_id: gp8403_5v - channel: 0 - - platform: gp8403 - gp8403_id: gp8403_10v - id: gp8403_output_1 - channel: 1 +<<: !include common.yaml diff --git a/tests/components/gp8403/test.esp32-c3-idf.yaml b/tests/components/gp8403/test.esp32-c3-idf.yaml index fbc40b948b..ee2c29ca4e 100644 --- a/tests/components/gp8403/test.esp32-c3-idf.yaml +++ b/tests/components/gp8403/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_gp8403 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -gp8403: - - id: gp8403_5v - voltage: 5V - - id: gp8403_10v - voltage: 10V - -output: - - platform: gp8403 - id: gp8403_output_0 - gp8403_id: gp8403_5v - channel: 0 - - platform: gp8403 - gp8403_id: gp8403_10v - id: gp8403_output_1 - channel: 1 +<<: !include common.yaml diff --git a/tests/components/gp8403/test.esp32-idf.yaml b/tests/components/gp8403/test.esp32-idf.yaml index 8470a303e1..63c3bd6afd 100644 --- a/tests/components/gp8403/test.esp32-idf.yaml +++ b/tests/components/gp8403/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_gp8403 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -gp8403: - - id: gp8403_5v - voltage: 5V - - id: gp8403_10v - voltage: 10V - -output: - - platform: gp8403 - id: gp8403_output_0 - gp8403_id: gp8403_5v - channel: 0 - - platform: gp8403 - gp8403_id: gp8403_10v - id: gp8403_output_1 - channel: 1 +<<: !include common.yaml diff --git a/tests/components/gp8403/test.esp8266-ard.yaml b/tests/components/gp8403/test.esp8266-ard.yaml index fbc40b948b..ee2c29ca4e 100644 --- a/tests/components/gp8403/test.esp8266-ard.yaml +++ b/tests/components/gp8403/test.esp8266-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_gp8403 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -gp8403: - - id: gp8403_5v - voltage: 5V - - id: gp8403_10v - voltage: 10V - -output: - - platform: gp8403 - id: gp8403_output_0 - gp8403_id: gp8403_5v - channel: 0 - - platform: gp8403 - gp8403_id: gp8403_10v - id: gp8403_output_1 - channel: 1 +<<: !include common.yaml diff --git a/tests/components/gp8403/test.rp2040-ard.yaml b/tests/components/gp8403/test.rp2040-ard.yaml index fbc40b948b..ee2c29ca4e 100644 --- a/tests/components/gp8403/test.rp2040-ard.yaml +++ b/tests/components/gp8403/test.rp2040-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_gp8403 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -gp8403: - - id: gp8403_5v - voltage: 5V - - id: gp8403_10v - voltage: 10V - -output: - - platform: gp8403 - id: gp8403_output_0 - gp8403_id: gp8403_5v - channel: 0 - - platform: gp8403 - gp8403_id: gp8403_10v - id: gp8403_output_1 - channel: 1 +<<: !include common.yaml diff --git a/tests/components/gpio/common.yaml b/tests/components/gpio/common.yaml new file mode 100644 index 0000000000..4e237349d9 --- /dev/null +++ b/tests/components/gpio/common.yaml @@ -0,0 +1,14 @@ +binary_sensor: + - platform: gpio + pin: ${binary_sensor_pin} + id: gpio_binary_sensor + +output: + - platform: gpio + pin: ${output_pin} + id: gpio_output + +switch: + - platform: gpio + pin: ${switch_pin} + id: gpio_switch diff --git a/tests/components/gpio/test.esp32-ard.yaml b/tests/components/gpio/test.esp32-ard.yaml index 30dfa94b68..09f41abb79 100644 --- a/tests/components/gpio/test.esp32-ard.yaml +++ b/tests/components/gpio/test.esp32-ard.yaml @@ -1,14 +1,6 @@ -binary_sensor: - - platform: gpio - pin: 12 - id: gpio_binary_sensor +substitutions: + binary_sensor_pin: GPIO12 + output_pin: GPIO13 + switch_pin: GPIO14 -output: - - platform: gpio - pin: 13 - id: gpio_output - -switch: - - platform: gpio - pin: 14 - id: gpio_switch +<<: !include common.yaml diff --git a/tests/components/gpio/test.esp32-c3-ard.yaml b/tests/components/gpio/test.esp32-c3-ard.yaml index 3ca285117d..fc7c9942d0 100644 --- a/tests/components/gpio/test.esp32-c3-ard.yaml +++ b/tests/components/gpio/test.esp32-c3-ard.yaml @@ -1,14 +1,6 @@ -binary_sensor: - - platform: gpio - pin: 2 - id: gpio_binary_sensor +substitutions: + binary_sensor_pin: GPIO2 + output_pin: GPIO3 + switch_pin: GPIO4 -output: - - platform: gpio - pin: 3 - id: gpio_output - -switch: - - platform: gpio - pin: 4 - id: gpio_switch +<<: !include common.yaml diff --git a/tests/components/gpio/test.esp32-c3-idf.yaml b/tests/components/gpio/test.esp32-c3-idf.yaml index 3ca285117d..fc7c9942d0 100644 --- a/tests/components/gpio/test.esp32-c3-idf.yaml +++ b/tests/components/gpio/test.esp32-c3-idf.yaml @@ -1,14 +1,6 @@ -binary_sensor: - - platform: gpio - pin: 2 - id: gpio_binary_sensor +substitutions: + binary_sensor_pin: GPIO2 + output_pin: GPIO3 + switch_pin: GPIO4 -output: - - platform: gpio - pin: 3 - id: gpio_output - -switch: - - platform: gpio - pin: 4 - id: gpio_switch +<<: !include common.yaml diff --git a/tests/components/gpio/test.esp32-idf.yaml b/tests/components/gpio/test.esp32-idf.yaml index 30dfa94b68..09f41abb79 100644 --- a/tests/components/gpio/test.esp32-idf.yaml +++ b/tests/components/gpio/test.esp32-idf.yaml @@ -1,14 +1,6 @@ -binary_sensor: - - platform: gpio - pin: 12 - id: gpio_binary_sensor +substitutions: + binary_sensor_pin: GPIO12 + output_pin: GPIO13 + switch_pin: GPIO14 -output: - - platform: gpio - pin: 13 - id: gpio_output - -switch: - - platform: gpio - pin: 14 - id: gpio_switch +<<: !include common.yaml diff --git a/tests/components/gpio/test.esp8266-ard.yaml b/tests/components/gpio/test.esp8266-ard.yaml index 30dfa94b68..09f41abb79 100644 --- a/tests/components/gpio/test.esp8266-ard.yaml +++ b/tests/components/gpio/test.esp8266-ard.yaml @@ -1,14 +1,6 @@ -binary_sensor: - - platform: gpio - pin: 12 - id: gpio_binary_sensor +substitutions: + binary_sensor_pin: GPIO12 + output_pin: GPIO13 + switch_pin: GPIO14 -output: - - platform: gpio - pin: 13 - id: gpio_output - -switch: - - platform: gpio - pin: 14 - id: gpio_switch +<<: !include common.yaml diff --git a/tests/components/gpio/test.rp2040-ard.yaml b/tests/components/gpio/test.rp2040-ard.yaml index 3ca285117d..fc7c9942d0 100644 --- a/tests/components/gpio/test.rp2040-ard.yaml +++ b/tests/components/gpio/test.rp2040-ard.yaml @@ -1,14 +1,6 @@ -binary_sensor: - - platform: gpio - pin: 2 - id: gpio_binary_sensor +substitutions: + binary_sensor_pin: GPIO2 + output_pin: GPIO3 + switch_pin: GPIO4 -output: - - platform: gpio - pin: 3 - id: gpio_output - -switch: - - platform: gpio - pin: 4 - id: gpio_switch +<<: !include common.yaml diff --git a/tests/components/gps/common.yaml b/tests/components/gps/common.yaml new file mode 100644 index 0000000000..fc8228c909 --- /dev/null +++ b/tests/components/gps/common.yaml @@ -0,0 +1,14 @@ +uart: + - id: uart_gps + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + parity: EVEN + +gps: + +time: + - platform: gps + on_time_sync: + then: + logger.log: "It's time!" diff --git a/tests/components/gps/test.esp32-ard.yaml b/tests/components/gps/test.esp32-ard.yaml index c4e4cf9f6f..811f6b72a6 100644 --- a/tests/components/gps/test.esp32-ard.yaml +++ b/tests/components/gps/test.esp32-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_gps - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - parity: EVEN +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -gps: - -time: - - platform: gps - on_time_sync: - then: - logger.log: "It's time!" +<<: !include common.yaml diff --git a/tests/components/gps/test.esp32-c3-ard.yaml b/tests/components/gps/test.esp32-c3-ard.yaml index 031f45b873..b516342f3b 100644 --- a/tests/components/gps/test.esp32-c3-ard.yaml +++ b/tests/components/gps/test.esp32-c3-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_gps - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -gps: - -time: - - platform: gps - on_time_sync: - then: - logger.log: "It's time!" +<<: !include common.yaml diff --git a/tests/components/gps/test.esp8266-ard.yaml b/tests/components/gps/test.esp8266-ard.yaml index 031f45b873..b516342f3b 100644 --- a/tests/components/gps/test.esp8266-ard.yaml +++ b/tests/components/gps/test.esp8266-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_gps - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -gps: - -time: - - platform: gps - on_time_sync: - then: - logger.log: "It's time!" +<<: !include common.yaml diff --git a/tests/components/gps/test.rp2040-ard.yaml b/tests/components/gps/test.rp2040-ard.yaml index 031f45b873..b516342f3b 100644 --- a/tests/components/gps/test.rp2040-ard.yaml +++ b/tests/components/gps/test.rp2040-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_gps - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -gps: - -time: - - platform: gps - on_time_sync: - then: - logger.log: "It's time!" +<<: !include common.yaml diff --git a/tests/components/graph/common.yaml b/tests/components/graph/common.yaml new file mode 100644 index 0000000000..d2a6a9422d --- /dev/null +++ b/tests/components/graph/common.yaml @@ -0,0 +1,25 @@ +i2c: + - id: i2c_graph + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: template + id: some_sensor + +graph: + - id: some_graph + sensor: some_sensor + duration: 1h + width: 100 + height: 100 + +display: + - platform: ssd1306_i2c + id: ssd1306_display + model: SSD1306_128X64 + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); diff --git a/tests/components/graph/test.esp32-ard.yaml b/tests/components/graph/test.esp32-ard.yaml index 8c0c0d4c9e..1ca773e06c 100644 --- a/tests/components/graph/test.esp32-ard.yaml +++ b/tests/components/graph/test.esp32-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_graph - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -sensor: - - platform: template - id: some_sensor - -graph: - - id: some_graph - sensor: some_sensor - duration: 1h - width: 100 - height: 100 - -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/graph/test.esp32-c3-ard.yaml b/tests/components/graph/test.esp32-c3-ard.yaml index 8ce40e84ac..1e6670c196 100644 --- a/tests/components/graph/test.esp32-c3-ard.yaml +++ b/tests/components/graph/test.esp32-c3-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_graph - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -sensor: - - platform: template - id: some_sensor - -graph: - - id: some_graph - sensor: some_sensor - duration: 1h - width: 100 - height: 100 - -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/graph/test.esp32-c3-idf.yaml b/tests/components/graph/test.esp32-c3-idf.yaml index 8ce40e84ac..1e6670c196 100644 --- a/tests/components/graph/test.esp32-c3-idf.yaml +++ b/tests/components/graph/test.esp32-c3-idf.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_graph - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -sensor: - - platform: template - id: some_sensor - -graph: - - id: some_graph - sensor: some_sensor - duration: 1h - width: 100 - height: 100 - -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/graph/test.esp32-idf.yaml b/tests/components/graph/test.esp32-idf.yaml index 8c0c0d4c9e..1ca773e06c 100644 --- a/tests/components/graph/test.esp32-idf.yaml +++ b/tests/components/graph/test.esp32-idf.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_graph - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -sensor: - - platform: template - id: some_sensor - -graph: - - id: some_graph - sensor: some_sensor - duration: 1h - width: 100 - height: 100 - -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/graph/test.esp8266-ard.yaml b/tests/components/graph/test.esp8266-ard.yaml index 33318355d5..dfdc12a3d1 100644 --- a/tests/components/graph/test.esp8266-ard.yaml +++ b/tests/components/graph/test.esp8266-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_graph - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO15 -sensor: - - platform: template - id: some_sensor - -graph: - - id: some_graph - sensor: some_sensor - duration: 1h - width: 100 - height: 100 - -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/graph/test.rp2040-ard.yaml b/tests/components/graph/test.rp2040-ard.yaml index 8ce40e84ac..1e6670c196 100644 --- a/tests/components/graph/test.rp2040-ard.yaml +++ b/tests/components/graph/test.rp2040-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_graph - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -sensor: - - platform: template - id: some_sensor - -graph: - - id: some_graph - sensor: some_sensor - duration: 1h - width: 100 - height: 100 - -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/graphical_display_menu/common.yaml b/tests/components/graphical_display_menu/common.yaml new file mode 100644 index 0000000000..d979a6a30e --- /dev/null +++ b/tests/components/graphical_display_menu/common.yaml @@ -0,0 +1,120 @@ +i2c: + - id: i2c_graphical_display_menu + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1306_i2c + id: ssd1306_display + model: SSD1306_128X64 + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + +font: + - file: "gfonts://Roboto" + id: roboto + size: 20 + +number: + - platform: template + id: test_number + min_value: 0 + step: 1 + max_value: 10 + optimistic: true + +select: + - platform: template + id: test_select + options: + - one + - two + optimistic: true + +switch: + - platform: template + id: test_switch + optimistic: true + +graphical_display_menu: + id: test_graphical_display_menu + display: ssd1306_display + font: roboto + active: false + mode: rotary + on_enter: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "root enter");' + on_leave: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "root leave");' + items: + - type: back + text: "Back" + - type: label + - type: menu + text: "Submenu 1" + items: + - type: back + text: "Back" + - type: menu + text: "Submenu 21" + items: + - type: back + text: "Back" + - type: command + text: "Show Main" + on_value: + then: + - display_menu.show_main: test_graphical_display_menu + - type: select + text: "Enum Item" + immediate_edit: true + select: test_select + on_enter: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + on_leave: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + on_value: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + - type: number + text: "Number" + number: test_number + on_enter: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + on_leave: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + on_value: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + - type: command + text: "Hide" + on_value: + then: + - display_menu.hide: test_graphical_display_menu + - type: switch + text: "Switch" + switch: test_switch + on_text: "Bright" + off_text: "Dark" + immediate_edit: false + on_value: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "switch value: %s", it->get_value_text().c_str());' + - type: custom + text: !lambda 'return "Custom";' + value_lambda: 'return "Val";' + on_next: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "custom next: %s", it->get_text().c_str());' + on_prev: + then: + lambda: 'ESP_LOGI("graphical_display_menu", "custom prev: %s", it->get_text().c_str());' diff --git a/tests/components/graphical_display_menu/test.esp32-ard.yaml b/tests/components/graphical_display_menu/test.esp32-ard.yaml index a0897536d7..1ca773e06c 100644 --- a/tests/components/graphical_display_menu/test.esp32-ard.yaml +++ b/tests/components/graphical_display_menu/test.esp32-ard.yaml @@ -1,120 +1,6 @@ -i2c: - - id: i2c_graphical_display_menu - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -font: - - file: "gfonts://Roboto" - id: roboto - size: 20 - -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - id: test_switch - optimistic: true - -graphical_display_menu: - id: test_graphical_display_menu - display: ssd1306_display - font: roboto - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root leave");' - items: - - type: back - text: "Back" - - type: label - - type: menu - text: "Submenu 1" - items: - - type: back - text: "Back" - - type: menu - text: "Submenu 21" - items: - - type: back - text: "Back" - - type: command - text: "Show Main" - on_value: - then: - - display_menu.show_main: test_graphical_display_menu - - type: select - text: "Enum Item" - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: "Number" - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: "Hide" - on_value: - then: - - display_menu.hide: test_graphical_display_menu - - type: switch - text: "Switch" - switch: test_switch - on_text: "Bright" - off_text: "Dark" - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/graphical_display_menu/test.esp32-c3-ard.yaml b/tests/components/graphical_display_menu/test.esp32-c3-ard.yaml index 23acd4e4d9..1e6670c196 100644 --- a/tests/components/graphical_display_menu/test.esp32-c3-ard.yaml +++ b/tests/components/graphical_display_menu/test.esp32-c3-ard.yaml @@ -1,120 +1,6 @@ -i2c: - - id: i2c_graphical_display_menu - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -font: - - file: "gfonts://Roboto" - id: roboto - size: 20 - -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - id: test_switch - optimistic: true - -graphical_display_menu: - id: test_graphical_display_menu - display: ssd1306_display - font: roboto - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root leave");' - items: - - type: back - text: "Back" - - type: label - - type: menu - text: "Submenu 1" - items: - - type: back - text: "Back" - - type: menu - text: "Submenu 21" - items: - - type: back - text: "Back" - - type: command - text: "Show Main" - on_value: - then: - - display_menu.show_main: test_graphical_display_menu - - type: select - text: "Enum Item" - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: "Number" - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: "Hide" - on_value: - then: - - display_menu.hide: test_graphical_display_menu - - type: switch - text: "Switch" - switch: test_switch - on_text: "Bright" - off_text: "Dark" - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/graphical_display_menu/test.esp32-c3-idf.yaml b/tests/components/graphical_display_menu/test.esp32-c3-idf.yaml index 23acd4e4d9..1e6670c196 100644 --- a/tests/components/graphical_display_menu/test.esp32-c3-idf.yaml +++ b/tests/components/graphical_display_menu/test.esp32-c3-idf.yaml @@ -1,120 +1,6 @@ -i2c: - - id: i2c_graphical_display_menu - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -font: - - file: "gfonts://Roboto" - id: roboto - size: 20 - -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - id: test_switch - optimistic: true - -graphical_display_menu: - id: test_graphical_display_menu - display: ssd1306_display - font: roboto - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root leave");' - items: - - type: back - text: "Back" - - type: label - - type: menu - text: "Submenu 1" - items: - - type: back - text: "Back" - - type: menu - text: "Submenu 21" - items: - - type: back - text: "Back" - - type: command - text: "Show Main" - on_value: - then: - - display_menu.show_main: test_graphical_display_menu - - type: select - text: "Enum Item" - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: "Number" - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: "Hide" - on_value: - then: - - display_menu.hide: test_graphical_display_menu - - type: switch - text: "Switch" - switch: test_switch - on_text: "Bright" - off_text: "Dark" - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/graphical_display_menu/test.esp32-idf.yaml b/tests/components/graphical_display_menu/test.esp32-idf.yaml index a0897536d7..1ca773e06c 100644 --- a/tests/components/graphical_display_menu/test.esp32-idf.yaml +++ b/tests/components/graphical_display_menu/test.esp32-idf.yaml @@ -1,120 +1,6 @@ -i2c: - - id: i2c_graphical_display_menu - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -font: - - file: "gfonts://Roboto" - id: roboto - size: 20 - -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - id: test_switch - optimistic: true - -graphical_display_menu: - id: test_graphical_display_menu - display: ssd1306_display - font: roboto - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root leave");' - items: - - type: back - text: "Back" - - type: label - - type: menu - text: "Submenu 1" - items: - - type: back - text: "Back" - - type: menu - text: "Submenu 21" - items: - - type: back - text: "Back" - - type: command - text: "Show Main" - on_value: - then: - - display_menu.show_main: test_graphical_display_menu - - type: select - text: "Enum Item" - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: "Number" - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: "Hide" - on_value: - then: - - display_menu.hide: test_graphical_display_menu - - type: switch - text: "Switch" - switch: test_switch - on_text: "Bright" - off_text: "Dark" - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/graphical_display_menu/test.esp8266-ard.yaml b/tests/components/graphical_display_menu/test.esp8266-ard.yaml index 28c1a7298d..dfdc12a3d1 100644 --- a/tests/components/graphical_display_menu/test.esp8266-ard.yaml +++ b/tests/components/graphical_display_menu/test.esp8266-ard.yaml @@ -1,120 +1,6 @@ -i2c: - - id: i2c_graphical_display_menu - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO15 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -font: - - file: "gfonts://Roboto" - id: roboto - size: 20 - -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - id: test_switch - optimistic: true - -graphical_display_menu: - id: test_graphical_display_menu - display: ssd1306_display - font: roboto - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root leave");' - items: - - type: back - text: "Back" - - type: label - - type: menu - text: "Submenu 1" - items: - - type: back - text: "Back" - - type: menu - text: "Submenu 21" - items: - - type: back - text: "Back" - - type: command - text: "Show Main" - on_value: - then: - - display_menu.show_main: test_graphical_display_menu - - type: select - text: "Enum Item" - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: "Number" - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: "Hide" - on_value: - then: - - display_menu.hide: test_graphical_display_menu - - type: switch - text: "Switch" - switch: test_switch - on_text: "Bright" - off_text: "Dark" - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/graphical_display_menu/test.rp2040-ard.yaml b/tests/components/graphical_display_menu/test.rp2040-ard.yaml index 23acd4e4d9..1e6670c196 100644 --- a/tests/components/graphical_display_menu/test.rp2040-ard.yaml +++ b/tests/components/graphical_display_menu/test.rp2040-ard.yaml @@ -1,120 +1,6 @@ -i2c: - - id: i2c_graphical_display_menu - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO6 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -font: - - file: "gfonts://Roboto" - id: roboto - size: 20 - -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true - -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - id: test_switch - optimistic: true - -graphical_display_menu: - id: test_graphical_display_menu - display: ssd1306_display - font: roboto - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "root leave");' - items: - - type: back - text: "Back" - - type: label - - type: menu - text: "Submenu 1" - items: - - type: back - text: "Back" - - type: menu - text: "Submenu 21" - items: - - type: back - text: "Back" - - type: command - text: "Show Main" - on_value: - then: - - display_menu.show_main: test_graphical_display_menu - - type: select - text: "Enum Item" - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: "Number" - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: "Hide" - on_value: - then: - - display_menu.hide: test_graphical_display_menu - - type: switch - text: "Switch" - switch: test_switch - on_text: "Bright" - off_text: "Dark" - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("graphical_display_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/gree/common.yaml b/tests/components/gree/common.yaml new file mode 100644 index 0000000000..c221184bbf --- /dev/null +++ b/tests/components/gree/common.yaml @@ -0,0 +1,8 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: gree + name: GREE + model: generic diff --git a/tests/components/gree/test.esp32-ard.yaml b/tests/components/gree/test.esp32-ard.yaml index 91491d7e16..7b012aa64c 100644 --- a/tests/components/gree/test.esp32-ard.yaml +++ b/tests/components/gree/test.esp32-ard.yaml @@ -1,8 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: gree - name: GREE - model: generic +<<: !include common.yaml diff --git a/tests/components/gree/test.esp32-c3-ard.yaml b/tests/components/gree/test.esp32-c3-ard.yaml index 91491d7e16..7b012aa64c 100644 --- a/tests/components/gree/test.esp32-c3-ard.yaml +++ b/tests/components/gree/test.esp32-c3-ard.yaml @@ -1,8 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: gree - name: GREE - model: generic +<<: !include common.yaml diff --git a/tests/components/gree/test.esp32-c3-idf.yaml b/tests/components/gree/test.esp32-c3-idf.yaml index 91491d7e16..7b012aa64c 100644 --- a/tests/components/gree/test.esp32-c3-idf.yaml +++ b/tests/components/gree/test.esp32-c3-idf.yaml @@ -1,8 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: gree - name: GREE - model: generic +<<: !include common.yaml diff --git a/tests/components/gree/test.esp32-idf.yaml b/tests/components/gree/test.esp32-idf.yaml index 91491d7e16..7b012aa64c 100644 --- a/tests/components/gree/test.esp32-idf.yaml +++ b/tests/components/gree/test.esp32-idf.yaml @@ -1,8 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: gree - name: GREE - model: generic +<<: !include common.yaml diff --git a/tests/components/gree/test.esp8266-ard.yaml b/tests/components/gree/test.esp8266-ard.yaml index d0542973ce..f5097fcf5f 100644 --- a/tests/components/gree/test.esp8266-ard.yaml +++ b/tests/components/gree/test.esp8266-ard.yaml @@ -1,8 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: gree - name: GREE - model: generic +<<: !include common.yaml diff --git a/tests/components/grove_gas_mc_v2/common.yaml b/tests/components/grove_gas_mc_v2/common.yaml index 0729e6b9c7..dbdb950033 100644 --- a/tests/components/grove_gas_mc_v2/common.yaml +++ b/tests/components/grove_gas_mc_v2/common.yaml @@ -1,6 +1,10 @@ +i2c: + - id: i2c_grove_gas_mc_v2 + scl: ${scl_pin} + sda: ${sda_pin} + sensor: - platform: grove_gas_mc_v2 - i2c_id: i2c_bus nitrogen_dioxide: name: "Nitrogen Dioxide" ethanol: diff --git a/tests/components/grove_gas_mc_v2/test.esp32-ard.yaml b/tests/components/grove_gas_mc_v2/test.esp32-ard.yaml index 00c7856c36..63c3bd6afd 100644 --- a/tests/components/grove_gas_mc_v2/test.esp32-ard.yaml +++ b/tests/components/grove_gas_mc_v2/test.esp32-ard.yaml @@ -1,6 +1,5 @@ -i2c: - sda: 21 - scl: 22 - id: i2c_bus +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 <<: !include common.yaml diff --git a/tests/components/grove_gas_mc_v2/test.esp32-c3-ard.yaml b/tests/components/grove_gas_mc_v2/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/grove_gas_mc_v2/test.esp32-c3-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/grove_gas_mc_v2/test.esp32-c3-idf.yaml b/tests/components/grove_gas_mc_v2/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/grove_gas_mc_v2/test.esp32-c3-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/grove_gas_mc_v2/test.esp32-idf.yaml b/tests/components/grove_gas_mc_v2/test.esp32-idf.yaml index 00c7856c36..63c3bd6afd 100644 --- a/tests/components/grove_gas_mc_v2/test.esp32-idf.yaml +++ b/tests/components/grove_gas_mc_v2/test.esp32-idf.yaml @@ -1,6 +1,5 @@ -i2c: - sda: 21 - scl: 22 - id: i2c_bus +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 <<: !include common.yaml diff --git a/tests/components/grove_gas_mc_v2/test.esp8266-ard.yaml b/tests/components/grove_gas_mc_v2/test.esp8266-ard.yaml index 2de18bdf39..ee2c29ca4e 100644 --- a/tests/components/grove_gas_mc_v2/test.esp8266-ard.yaml +++ b/tests/components/grove_gas_mc_v2/test.esp8266-ard.yaml @@ -1,6 +1,5 @@ -i2c: - sda: 4 - scl: 5 - id: i2c_bus +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/grove_gas_mc_v2/test.rp2040-ard.yaml b/tests/components/grove_gas_mc_v2/test.rp2040-ard.yaml index 00c7856c36..ee2c29ca4e 100644 --- a/tests/components/grove_gas_mc_v2/test.rp2040-ard.yaml +++ b/tests/components/grove_gas_mc_v2/test.rp2040-ard.yaml @@ -1,6 +1,5 @@ -i2c: - sda: 21 - scl: 22 - id: i2c_bus +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/grove_tb6612fng/common.yaml b/tests/components/grove_tb6612fng/common.yaml new file mode 100644 index 0000000000..0db6c00bf7 --- /dev/null +++ b/tests/components/grove_tb6612fng/common.yaml @@ -0,0 +1,23 @@ +esphome: + on_boot: + then: + - grove_tb6612fng.run: + channel: 1 + speed: 255 + direction: BACKWARD + id: test_motor + - grove_tb6612fng.stop: + channel: 1 + id: test_motor + - grove_tb6612fng.break: + channel: 1 + id: test_motor + +i2c: + - id: i2c_grove_tb6612fng + scl: ${scl_pin} + sda: ${sda_pin} + +grove_tb6612fng: + id: test_motor + address: 0x14 diff --git a/tests/components/grove_tb6612fng/test.esp32-ard.yaml b/tests/components/grove_tb6612fng/test.esp32-ard.yaml index 3271fb754f..63c3bd6afd 100644 --- a/tests/components/grove_tb6612fng/test.esp32-ard.yaml +++ b/tests/components/grove_tb6612fng/test.esp32-ard.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - grove_tb6612fng.run: - channel: 1 - speed: 255 - direction: BACKWARD - id: test_motor - - grove_tb6612fng.stop: - channel: 1 - id: test_motor - - grove_tb6612fng.break: - channel: 1 - id: test_motor +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_grove_tb6612fng - scl: 16 - sda: 17 - -grove_tb6612fng: - id: test_motor - address: 0x14 +<<: !include common.yaml diff --git a/tests/components/grove_tb6612fng/test.esp32-c3-ard.yaml b/tests/components/grove_tb6612fng/test.esp32-c3-ard.yaml index ef6dff6539..ee2c29ca4e 100644 --- a/tests/components/grove_tb6612fng/test.esp32-c3-ard.yaml +++ b/tests/components/grove_tb6612fng/test.esp32-c3-ard.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - grove_tb6612fng.run: - channel: 1 - speed: 255 - direction: BACKWARD - id: test_motor - - grove_tb6612fng.stop: - channel: 1 - id: test_motor - - grove_tb6612fng.break: - channel: 1 - id: test_motor +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_grove_tb6612fng - scl: 5 - sda: 4 - -grove_tb6612fng: - id: test_motor - address: 0x14 +<<: !include common.yaml diff --git a/tests/components/grove_tb6612fng/test.esp32-c3-idf.yaml b/tests/components/grove_tb6612fng/test.esp32-c3-idf.yaml index ef6dff6539..ee2c29ca4e 100644 --- a/tests/components/grove_tb6612fng/test.esp32-c3-idf.yaml +++ b/tests/components/grove_tb6612fng/test.esp32-c3-idf.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - grove_tb6612fng.run: - channel: 1 - speed: 255 - direction: BACKWARD - id: test_motor - - grove_tb6612fng.stop: - channel: 1 - id: test_motor - - grove_tb6612fng.break: - channel: 1 - id: test_motor +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_grove_tb6612fng - scl: 5 - sda: 4 - -grove_tb6612fng: - id: test_motor - address: 0x14 +<<: !include common.yaml diff --git a/tests/components/grove_tb6612fng/test.esp32-idf.yaml b/tests/components/grove_tb6612fng/test.esp32-idf.yaml index 3271fb754f..63c3bd6afd 100644 --- a/tests/components/grove_tb6612fng/test.esp32-idf.yaml +++ b/tests/components/grove_tb6612fng/test.esp32-idf.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - grove_tb6612fng.run: - channel: 1 - speed: 255 - direction: BACKWARD - id: test_motor - - grove_tb6612fng.stop: - channel: 1 - id: test_motor - - grove_tb6612fng.break: - channel: 1 - id: test_motor +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_grove_tb6612fng - scl: 16 - sda: 17 - -grove_tb6612fng: - id: test_motor - address: 0x14 +<<: !include common.yaml diff --git a/tests/components/grove_tb6612fng/test.esp8266-ard.yaml b/tests/components/grove_tb6612fng/test.esp8266-ard.yaml index ef6dff6539..ee2c29ca4e 100644 --- a/tests/components/grove_tb6612fng/test.esp8266-ard.yaml +++ b/tests/components/grove_tb6612fng/test.esp8266-ard.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - grove_tb6612fng.run: - channel: 1 - speed: 255 - direction: BACKWARD - id: test_motor - - grove_tb6612fng.stop: - channel: 1 - id: test_motor - - grove_tb6612fng.break: - channel: 1 - id: test_motor +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_grove_tb6612fng - scl: 5 - sda: 4 - -grove_tb6612fng: - id: test_motor - address: 0x14 +<<: !include common.yaml diff --git a/tests/components/grove_tb6612fng/test.rp2040-ard.yaml b/tests/components/grove_tb6612fng/test.rp2040-ard.yaml index ef6dff6539..ee2c29ca4e 100644 --- a/tests/components/grove_tb6612fng/test.rp2040-ard.yaml +++ b/tests/components/grove_tb6612fng/test.rp2040-ard.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - grove_tb6612fng.run: - channel: 1 - speed: 255 - direction: BACKWARD - id: test_motor - - grove_tb6612fng.stop: - channel: 1 - id: test_motor - - grove_tb6612fng.break: - channel: 1 - id: test_motor +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_grove_tb6612fng - scl: 5 - sda: 4 - -grove_tb6612fng: - id: test_motor - address: 0x14 +<<: !include common.yaml diff --git a/tests/components/growatt_solar/common.yaml b/tests/components/growatt_solar/common.yaml new file mode 100644 index 0000000000..7cc6b2a139 --- /dev/null +++ b/tests/components/growatt_solar/common.yaml @@ -0,0 +1,62 @@ +uart: + - id: uart_growatt_solar + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +modbus: + flow_control_pin: ${flow_control_pin} + +sensor: + - platform: growatt_solar + update_interval: 10s + protocol_version: RTU + inverter_status: + name: Growatt Status Code + phase_a: + voltage: + name: Growatt Voltage Phase A + current: + name: Growatt Current Phase A + active_power: + name: Growatt Power Phase A + phase_b: + voltage: + name: Growatt Voltage Phase B + current: + name: Growatt Current Phase B + active_power: + name: Growatt Power Phase B + phase_c: + voltage: + name: Growatt Voltage Phase C + current: + name: Growatt Current Phase C + active_power: + name: Growatt Power Phase C + pv1: + voltage: + name: Growatt PV1 Voltage + current: + name: Growatt PV1 Current + active_power: + name: Growatt PV1 Active Power + pv2: + voltage: + name: Growatt PV2 Voltage + current: + name: Growatt PV2 Current + active_power: + name: Growatt PV2 Active Power + active_power: + name: Growatt Grid Active Power + pv_active_power: + name: Growatt PV Active Power + frequency: + name: Growatt Frequency + energy_production_day: + name: Growatt Today's Generation + total_energy_production: + name: Growatt Total Energy Production + inverter_module_temp: + name: Growatt Inverter Module Temp diff --git a/tests/components/growatt_solar/test.esp32-ard.yaml b/tests/components/growatt_solar/test.esp32-ard.yaml index 654f2ccedf..bd767a8ece 100644 --- a/tests/components/growatt_solar/test.esp32-ard.yaml +++ b/tests/components/growatt_solar/test.esp32-ard.yaml @@ -1,62 +1,6 @@ -uart: - - id: uart_growatt_solar - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + flow_control_pin: GPIO13 -modbus: - flow_control_pin: 13 - -sensor: - - platform: growatt_solar - update_interval: 10s - protocol_version: RTU - inverter_status: - name: Growatt Status Code - phase_a: - voltage: - name: Growatt Voltage Phase A - current: - name: Growatt Current Phase A - active_power: - name: Growatt Power Phase A - phase_b: - voltage: - name: Growatt Voltage Phase B - current: - name: Growatt Current Phase B - active_power: - name: Growatt Power Phase B - phase_c: - voltage: - name: Growatt Voltage Phase C - current: - name: Growatt Current Phase C - active_power: - name: Growatt Power Phase C - pv1: - voltage: - name: Growatt PV1 Voltage - current: - name: Growatt PV1 Current - active_power: - name: Growatt PV1 Active Power - pv2: - voltage: - name: Growatt PV2 Voltage - current: - name: Growatt PV2 Current - active_power: - name: Growatt PV2 Active Power - active_power: - name: Growatt Grid Active Power - pv_active_power: - name: Growatt PV Active Power - frequency: - name: Growatt Frequency - energy_production_day: - name: Growatt Today's Generation - total_energy_production: - name: Growatt Total Energy Production - inverter_module_temp: - name: Growatt Inverter Module Temp +<<: !include common.yaml diff --git a/tests/components/growatt_solar/test.esp32-c3-ard.yaml b/tests/components/growatt_solar/test.esp32-c3-ard.yaml index 7e73897856..452031a5aa 100644 --- a/tests/components/growatt_solar/test.esp32-c3-ard.yaml +++ b/tests/components/growatt_solar/test.esp32-c3-ard.yaml @@ -1,62 +1,6 @@ -uart: - - id: uart_growatt_solar - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - flow_control_pin: 3 - -sensor: - - platform: growatt_solar - update_interval: 10s - protocol_version: RTU - inverter_status: - name: Growatt Status Code - phase_a: - voltage: - name: Growatt Voltage Phase A - current: - name: Growatt Current Phase A - active_power: - name: Growatt Power Phase A - phase_b: - voltage: - name: Growatt Voltage Phase B - current: - name: Growatt Current Phase B - active_power: - name: Growatt Power Phase B - phase_c: - voltage: - name: Growatt Voltage Phase C - current: - name: Growatt Current Phase C - active_power: - name: Growatt Power Phase C - pv1: - voltage: - name: Growatt PV1 Voltage - current: - name: Growatt PV1 Current - active_power: - name: Growatt PV1 Active Power - pv2: - voltage: - name: Growatt PV2 Voltage - current: - name: Growatt PV2 Current - active_power: - name: Growatt PV2 Active Power - active_power: - name: Growatt Grid Active Power - pv_active_power: - name: Growatt PV Active Power - frequency: - name: Growatt Frequency - energy_production_day: - name: Growatt Today's Generation - total_energy_production: - name: Growatt Total Energy Production - inverter_module_temp: - name: Growatt Inverter Module Temp +<<: !include common.yaml diff --git a/tests/components/growatt_solar/test.esp32-c3-idf.yaml b/tests/components/growatt_solar/test.esp32-c3-idf.yaml index 7e73897856..452031a5aa 100644 --- a/tests/components/growatt_solar/test.esp32-c3-idf.yaml +++ b/tests/components/growatt_solar/test.esp32-c3-idf.yaml @@ -1,62 +1,6 @@ -uart: - - id: uart_growatt_solar - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - flow_control_pin: 3 - -sensor: - - platform: growatt_solar - update_interval: 10s - protocol_version: RTU - inverter_status: - name: Growatt Status Code - phase_a: - voltage: - name: Growatt Voltage Phase A - current: - name: Growatt Current Phase A - active_power: - name: Growatt Power Phase A - phase_b: - voltage: - name: Growatt Voltage Phase B - current: - name: Growatt Current Phase B - active_power: - name: Growatt Power Phase B - phase_c: - voltage: - name: Growatt Voltage Phase C - current: - name: Growatt Current Phase C - active_power: - name: Growatt Power Phase C - pv1: - voltage: - name: Growatt PV1 Voltage - current: - name: Growatt PV1 Current - active_power: - name: Growatt PV1 Active Power - pv2: - voltage: - name: Growatt PV2 Voltage - current: - name: Growatt PV2 Current - active_power: - name: Growatt PV2 Active Power - active_power: - name: Growatt Grid Active Power - pv_active_power: - name: Growatt PV Active Power - frequency: - name: Growatt Frequency - energy_production_day: - name: Growatt Today's Generation - total_energy_production: - name: Growatt Total Energy Production - inverter_module_temp: - name: Growatt Inverter Module Temp +<<: !include common.yaml diff --git a/tests/components/growatt_solar/test.esp32-idf.yaml b/tests/components/growatt_solar/test.esp32-idf.yaml index 654f2ccedf..bd767a8ece 100644 --- a/tests/components/growatt_solar/test.esp32-idf.yaml +++ b/tests/components/growatt_solar/test.esp32-idf.yaml @@ -1,62 +1,6 @@ -uart: - - id: uart_growatt_solar - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + flow_control_pin: GPIO13 -modbus: - flow_control_pin: 13 - -sensor: - - platform: growatt_solar - update_interval: 10s - protocol_version: RTU - inverter_status: - name: Growatt Status Code - phase_a: - voltage: - name: Growatt Voltage Phase A - current: - name: Growatt Current Phase A - active_power: - name: Growatt Power Phase A - phase_b: - voltage: - name: Growatt Voltage Phase B - current: - name: Growatt Current Phase B - active_power: - name: Growatt Power Phase B - phase_c: - voltage: - name: Growatt Voltage Phase C - current: - name: Growatt Current Phase C - active_power: - name: Growatt Power Phase C - pv1: - voltage: - name: Growatt PV1 Voltage - current: - name: Growatt PV1 Current - active_power: - name: Growatt PV1 Active Power - pv2: - voltage: - name: Growatt PV2 Voltage - current: - name: Growatt PV2 Current - active_power: - name: Growatt PV2 Active Power - active_power: - name: Growatt Grid Active Power - pv_active_power: - name: Growatt PV Active Power - frequency: - name: Growatt Frequency - energy_production_day: - name: Growatt Today's Generation - total_energy_production: - name: Growatt Total Energy Production - inverter_module_temp: - name: Growatt Inverter Module Temp +<<: !include common.yaml diff --git a/tests/components/growatt_solar/test.esp8266-ard.yaml b/tests/components/growatt_solar/test.esp8266-ard.yaml index a1cf8267ae..29c98d0957 100644 --- a/tests/components/growatt_solar/test.esp8266-ard.yaml +++ b/tests/components/growatt_solar/test.esp8266-ard.yaml @@ -1,62 +1,6 @@ -uart: - - id: uart_growatt_solar - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO13 -modbus: - flow_control_pin: 13 - -sensor: - - platform: growatt_solar - update_interval: 10s - protocol_version: RTU - inverter_status: - name: Growatt Status Code - phase_a: - voltage: - name: Growatt Voltage Phase A - current: - name: Growatt Current Phase A - active_power: - name: Growatt Power Phase A - phase_b: - voltage: - name: Growatt Voltage Phase B - current: - name: Growatt Current Phase B - active_power: - name: Growatt Power Phase B - phase_c: - voltage: - name: Growatt Voltage Phase C - current: - name: Growatt Current Phase C - active_power: - name: Growatt Power Phase C - pv1: - voltage: - name: Growatt PV1 Voltage - current: - name: Growatt PV1 Current - active_power: - name: Growatt PV1 Active Power - pv2: - voltage: - name: Growatt PV2 Voltage - current: - name: Growatt PV2 Current - active_power: - name: Growatt PV2 Active Power - active_power: - name: Growatt Grid Active Power - pv_active_power: - name: Growatt PV Active Power - frequency: - name: Growatt Frequency - energy_production_day: - name: Growatt Today's Generation - total_energy_production: - name: Growatt Total Energy Production - inverter_module_temp: - name: Growatt Inverter Module Temp +<<: !include common.yaml diff --git a/tests/components/growatt_solar/test.rp2040-ard.yaml b/tests/components/growatt_solar/test.rp2040-ard.yaml index 7e73897856..452031a5aa 100644 --- a/tests/components/growatt_solar/test.rp2040-ard.yaml +++ b/tests/components/growatt_solar/test.rp2040-ard.yaml @@ -1,62 +1,6 @@ -uart: - - id: uart_growatt_solar - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - flow_control_pin: 3 - -sensor: - - platform: growatt_solar - update_interval: 10s - protocol_version: RTU - inverter_status: - name: Growatt Status Code - phase_a: - voltage: - name: Growatt Voltage Phase A - current: - name: Growatt Current Phase A - active_power: - name: Growatt Power Phase A - phase_b: - voltage: - name: Growatt Voltage Phase B - current: - name: Growatt Current Phase B - active_power: - name: Growatt Power Phase B - phase_c: - voltage: - name: Growatt Voltage Phase C - current: - name: Growatt Current Phase C - active_power: - name: Growatt Power Phase C - pv1: - voltage: - name: Growatt PV1 Voltage - current: - name: Growatt PV1 Current - active_power: - name: Growatt PV1 Active Power - pv2: - voltage: - name: Growatt PV2 Voltage - current: - name: Growatt PV2 Current - active_power: - name: Growatt PV2 Active Power - active_power: - name: Growatt Grid Active Power - pv_active_power: - name: Growatt PV Active Power - frequency: - name: Growatt Frequency - energy_production_day: - name: Growatt Today's Generation - total_energy_production: - name: Growatt Total Energy Production - inverter_module_temp: - name: Growatt Inverter Module Temp +<<: !include common.yaml From f8fae676b1464162d0623fc5369e7ae710c5e60d Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:05:50 -0600 Subject: [PATCH 151/194] [CI] Consolidate some tests (H) (#8198) --- tests/components/havells_solar/common.yaml | 79 ++++++++++++++++++ .../havells_solar/test.esp32-ard.yaml | 83 ++----------------- .../havells_solar/test.esp32-c3-ard.yaml | 83 ++----------------- .../havells_solar/test.esp32-c3-idf.yaml | 83 ++----------------- .../havells_solar/test.esp32-idf.yaml | 83 ++----------------- .../havells_solar/test.esp8266-ard.yaml | 83 ++----------------- .../havells_solar/test.rp2040-ard.yaml | 83 ++----------------- tests/components/hdc1080/common.yaml | 12 +++ tests/components/hdc1080/test.esp32-ard.yaml | 15 +--- .../components/hdc1080/test.esp32-c3-ard.yaml | 15 +--- .../components/hdc1080/test.esp32-c3-idf.yaml | 15 +--- tests/components/hdc1080/test.esp32-idf.yaml | 15 +--- .../components/hdc1080/test.esp8266-ard.yaml | 15 +--- tests/components/hdc1080/test.rp2040-ard.yaml | 15 +--- tests/components/he60r/common.yaml | 13 +++ tests/components/he60r/test.esp32-ard.yaml | 16 +--- tests/components/he60r/test.esp32-c3-ard.yaml | 16 +--- tests/components/he60r/test.esp32-c3-idf.yaml | 16 +--- tests/components/he60r/test.esp32-idf.yaml | 16 +--- tests/components/he60r/test.esp8266-ard.yaml | 16 +--- tests/components/he60r/test.rp2040-ard.yaml | 16 +--- tests/components/heatpumpir/common.yaml | 26 ++++++ .../heatpumpir/test.bk72xx-ard.yaml | 28 +------ .../components/heatpumpir/test.esp32-ard.yaml | 21 +---- .../heatpumpir/test.esp32-c3-ard.yaml | 4 + .../heatpumpir/test.esp8266-ard.yaml | 21 +---- tests/components/hitachi_ac344/common.yaml | 7 ++ .../hitachi_ac344/test.bk72xx-ard.yaml | 4 + .../hitachi_ac344/test.esp32-ard.yaml | 9 +- .../hitachi_ac344/test.esp32-c3-ard.yaml | 9 +- .../hitachi_ac344/test.esp32-c3-idf.yaml | 9 +- .../hitachi_ac344/test.esp32-idf.yaml | 9 +- .../hitachi_ac344/test.esp8266-ard.yaml | 9 +- tests/components/hitachi_ac424/common.yaml | 7 ++ .../hitachi_ac424/test.bk72xx-ard.yaml | 4 + .../hitachi_ac424/test.esp32-ard.yaml | 9 +- .../hitachi_ac424/test.esp32-c3-ard.yaml | 9 +- .../hitachi_ac424/test.esp32-c3-idf.yaml | 9 +- .../hitachi_ac424/test.esp32-idf.yaml | 9 +- .../hitachi_ac424/test.esp8266-ard.yaml | 9 +- tests/components/hlw8012/common.yaml | 21 +++++ tests/components/hlw8012/test.esp32-ard.yaml | 27 ++---- .../components/hlw8012/test.esp32-c3-ard.yaml | 27 ++---- .../components/hlw8012/test.esp32-c3-idf.yaml | 27 ++---- tests/components/hlw8012/test.esp32-idf.yaml | 27 ++---- .../components/hlw8012/test.esp8266-ard.yaml | 27 ++---- tests/components/hlw8012/test.rp2040-ard.yaml | 27 ++---- tests/components/hm3301/common.yaml | 16 ++++ tests/components/hm3301/test.esp32-ard.yaml | 19 +---- .../components/hm3301/test.esp32-c3-ard.yaml | 19 +---- .../components/hm3301/test.esp32-c3-idf.yaml | 19 +---- tests/components/hm3301/test.esp32-idf.yaml | 19 +---- tests/components/hm3301/test.esp8266-ard.yaml | 19 +---- tests/components/hm3301/test.rp2040-ard.yaml | 19 +---- tests/components/hmc5883l/common.yaml | 19 +++++ tests/components/hmc5883l/test.esp32-ard.yaml | 22 +---- .../hmc5883l/test.esp32-c3-ard.yaml | 22 +---- .../hmc5883l/test.esp32-c3-idf.yaml | 22 +---- tests/components/hmc5883l/test.esp32-idf.yaml | 22 +---- .../components/hmc5883l/test.esp8266-ard.yaml | 22 +---- .../components/hmc5883l/test.rp2040-ard.yaml | 22 +---- .../components/honeywell_hih_i2c/common.yaml | 12 +++ .../honeywell_hih_i2c/test.esp32-ard.yaml | 15 +--- .../honeywell_hih_i2c/test.esp32-c3-ard.yaml | 15 +--- .../honeywell_hih_i2c/test.esp32-c3-idf.yaml | 15 +--- .../honeywell_hih_i2c/test.esp32-idf.yaml | 15 +--- .../honeywell_hih_i2c/test.esp8266-ard.yaml | 15 +--- .../honeywell_hih_i2c/test.rp2040-ard.yaml | 15 +--- tests/components/honeywellabp/common.yaml | 15 ++++ .../honeywellabp/test.esp32-ard.yaml | 20 ++--- .../honeywellabp/test.esp32-c3-ard.yaml | 20 ++--- .../honeywellabp/test.esp32-c3-idf.yaml | 20 ++--- .../honeywellabp/test.esp32-idf.yaml | 20 ++--- .../honeywellabp/test.esp8266-ard.yaml | 20 ++--- .../honeywellabp/test.rp2040-ard.yaml | 20 ++--- .../components/honeywellabp2_i2c/common.yaml | 15 ++++ .../honeywellabp2_i2c/test.esp32-ard.yaml | 18 +--- .../honeywellabp2_i2c/test.esp32-c3-ard.yaml | 18 +--- .../honeywellabp2_i2c/test.esp32-c3-idf.yaml | 18 +--- .../honeywellabp2_i2c/test.esp32-idf.yaml | 18 +--- .../honeywellabp2_i2c/test.esp8266-ard.yaml | 18 +--- .../honeywellabp2_i2c/test.rp2040-ard.yaml | 18 +--- tests/components/hrxl_maxsonar_wr/common.yaml | 10 +++ .../hrxl_maxsonar_wr/test.esp32-ard.yaml | 13 +-- .../hrxl_maxsonar_wr/test.esp32-c3-ard.yaml | 13 +-- .../hrxl_maxsonar_wr/test.esp32-c3-idf.yaml | 13 +-- .../hrxl_maxsonar_wr/test.esp32-idf.yaml | 13 +-- .../hrxl_maxsonar_wr/test.esp8266-ard.yaml | 13 +-- .../hrxl_maxsonar_wr/test.rp2040-ard.yaml | 13 +-- tests/components/hte501/common.yaml | 12 +++ tests/components/hte501/test.esp32-ard.yaml | 15 +--- .../components/hte501/test.esp32-c3-ard.yaml | 15 +--- .../components/hte501/test.esp32-c3-idf.yaml | 15 +--- tests/components/hte501/test.esp32-idf.yaml | 15 +--- tests/components/hte501/test.esp8266-ard.yaml | 15 +--- tests/components/hte501/test.rp2040-ard.yaml | 15 +--- tests/components/htu21d/common.yaml | 15 ++++ tests/components/htu21d/test.esp32-ard.yaml | 18 +--- .../components/htu21d/test.esp32-c3-ard.yaml | 18 +--- .../components/htu21d/test.esp32-c3-idf.yaml | 18 +--- tests/components/htu21d/test.esp32-idf.yaml | 18 +--- tests/components/htu21d/test.esp8266-ard.yaml | 18 +--- tests/components/htu21d/test.rp2040-ard.yaml | 18 +--- tests/components/htu31d/common.yaml | 7 +- tests/components/htu31d/test.esp32-ard.yaml | 4 + .../components/htu31d/test.esp32-c3-ard.yaml | 5 ++ .../components/htu31d/test.esp32-c3-idf.yaml | 5 ++ tests/components/htu31d/test.esp32-idf.yaml | 4 + tests/components/htu31d/test.esp8266-ard.yaml | 4 + tests/components/htu31d/test.rp2040-ard.yaml | 5 ++ tests/components/hx711/common.yaml | 7 ++ tests/components/hx711/test.esp32-ard.yaml | 12 ++- tests/components/hx711/test.esp32-c3-ard.yaml | 12 ++- tests/components/hx711/test.esp32-c3-idf.yaml | 12 ++- tests/components/hx711/test.esp32-idf.yaml | 12 ++- tests/components/hx711/test.esp8266-ard.yaml | 12 ++- tests/components/hx711/test.rp2040-ard.yaml | 12 ++- tests/components/hydreon_rgxx/common.yaml | 37 +++++++++ .../hydreon_rgxx/test.esp32-ard.yaml | 40 +-------- .../hydreon_rgxx/test.esp32-c3-ard.yaml | 40 +-------- .../hydreon_rgxx/test.esp32-c3-idf.yaml | 40 +-------- .../hydreon_rgxx/test.esp32-idf.yaml | 40 +-------- .../hydreon_rgxx/test.esp8266-ard.yaml | 40 +-------- .../hydreon_rgxx/test.rp2040-ard.yaml | 40 +-------- tests/components/hyt271/common.yaml | 11 +++ tests/components/hyt271/test.esp32-ard.yaml | 14 +--- .../components/hyt271/test.esp32-c3-ard.yaml | 14 +--- .../components/hyt271/test.esp32-c3-idf.yaml | 14 +--- tests/components/hyt271/test.esp32-idf.yaml | 14 +--- tests/components/hyt271/test.esp8266-ard.yaml | 14 +--- tests/components/hyt271/test.rp2040-ard.yaml | 14 +--- 131 files changed, 813 insertions(+), 1809 deletions(-) create mode 100644 tests/components/havells_solar/common.yaml create mode 100644 tests/components/hdc1080/common.yaml create mode 100644 tests/components/he60r/common.yaml create mode 100644 tests/components/heatpumpir/common.yaml create mode 100644 tests/components/heatpumpir/test.esp32-c3-ard.yaml create mode 100644 tests/components/hitachi_ac344/common.yaml create mode 100644 tests/components/hitachi_ac344/test.bk72xx-ard.yaml create mode 100644 tests/components/hitachi_ac424/common.yaml create mode 100644 tests/components/hitachi_ac424/test.bk72xx-ard.yaml create mode 100644 tests/components/hlw8012/common.yaml create mode 100644 tests/components/hm3301/common.yaml create mode 100644 tests/components/hmc5883l/common.yaml create mode 100644 tests/components/honeywell_hih_i2c/common.yaml create mode 100644 tests/components/honeywellabp/common.yaml create mode 100644 tests/components/honeywellabp2_i2c/common.yaml create mode 100644 tests/components/hrxl_maxsonar_wr/common.yaml create mode 100644 tests/components/hte501/common.yaml create mode 100644 tests/components/htu21d/common.yaml create mode 100644 tests/components/htu31d/test.esp32-c3-ard.yaml create mode 100644 tests/components/htu31d/test.esp32-c3-idf.yaml create mode 100644 tests/components/htu31d/test.rp2040-ard.yaml create mode 100644 tests/components/hx711/common.yaml create mode 100644 tests/components/hydreon_rgxx/common.yaml create mode 100644 tests/components/hyt271/common.yaml diff --git a/tests/components/havells_solar/common.yaml b/tests/components/havells_solar/common.yaml new file mode 100644 index 0000000000..370b0d357d --- /dev/null +++ b/tests/components/havells_solar/common.yaml @@ -0,0 +1,79 @@ +uart: + - id: uart_havells_solar + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +modbus: + flow_control_pin: ${flow_control_pin} + +sensor: + - platform: havells_solar + update_interval: 60s + phase_a: + voltage: + name: Phase A Voltage + current: + name: Phase A Current + phase_b: + voltage: + name: Voltage Phase B + current: + name: Current Phase B + phase_c: + voltage: + name: Voltage Phase C + current: + name: Current Phase C + pv1: + voltage: + name: PV1 Voltage + current: + name: PV1 Current + active_power: + name: PV1 Active Power + voltage_sampled_by_secondary_cpu: + name: PV1 Voltage Sampled By Secondary CPU + insulation_of_p_to_ground: + name: PV1 Insulation Of +VE To Ground + pv2: + voltage: + name: PV2 Voltage + current: + name: PV2 Current + active_power: + name: PV2 Active Power + voltage_sampled_by_secondary_cpu: + name: PV2 Voltage Sampled By Secondary CPU + insulation_of_p_to_ground: + name: PV2 Insulation Of +VE To Ground + active_power: + name: Active Power + reactive_power: + name: Reactive Power + frequency: + name: Frequency + energy_production_day: + name: Today's Generation + total_energy_production: + name: Total Energy Production + total_generation_time: + name: Total Generation Time + today_generation_time: + name: Today Generation Time + inverter_module_temp: + name: Inverter Module Temp + inverter_inner_temp: + name: Inverter Inner Temp + inverter_bus_voltage: + name: Inverter BUS Voltage + insulation_of_pv_n_to_ground: + name: Insulation Of PV- To Ground + gfci_value: + name: GFCI Value + dci_of_r: + name: DCI Of R + dci_of_s: + name: DCI Of S + dci_of_t: + name: DCI Of T diff --git a/tests/components/havells_solar/test.esp32-ard.yaml b/tests/components/havells_solar/test.esp32-ard.yaml index 2cda8e37be..bd767a8ece 100644 --- a/tests/components/havells_solar/test.esp32-ard.yaml +++ b/tests/components/havells_solar/test.esp32-ard.yaml @@ -1,79 +1,6 @@ -uart: - - id: uart_havells_solar - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + flow_control_pin: GPIO13 -modbus: - flow_control_pin: 3 - -sensor: - - platform: havells_solar - update_interval: 60s - phase_a: - voltage: - name: Phase A Voltage - current: - name: Phase A Current - phase_b: - voltage: - name: Voltage Phase B - current: - name: Current Phase B - phase_c: - voltage: - name: Voltage Phase C - current: - name: Current Phase C - pv1: - voltage: - name: PV1 Voltage - current: - name: PV1 Current - active_power: - name: PV1 Active Power - voltage_sampled_by_secondary_cpu: - name: PV1 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV1 Insulation Of +VE To Ground - pv2: - voltage: - name: PV2 Voltage - current: - name: PV2 Current - active_power: - name: PV2 Active Power - voltage_sampled_by_secondary_cpu: - name: PV2 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV2 Insulation Of +VE To Ground - active_power: - name: Active Power - reactive_power: - name: Reactive Power - frequency: - name: Frequency - energy_production_day: - name: Today's Generation - total_energy_production: - name: Total Energy Production - total_generation_time: - name: Total Generation Time - today_generation_time: - name: Today Generation Time - inverter_module_temp: - name: Inverter Module Temp - inverter_inner_temp: - name: Inverter Inner Temp - inverter_bus_voltage: - name: Inverter BUS Voltage - insulation_of_pv_n_to_ground: - name: Insulation Of PV- To Ground - gfci_value: - name: GFCI Value - dci_of_r: - name: DCI Of R - dci_of_s: - name: DCI Of S - dci_of_t: - name: DCI Of T +<<: !include common.yaml diff --git a/tests/components/havells_solar/test.esp32-c3-ard.yaml b/tests/components/havells_solar/test.esp32-c3-ard.yaml index 5cb911cf71..452031a5aa 100644 --- a/tests/components/havells_solar/test.esp32-c3-ard.yaml +++ b/tests/components/havells_solar/test.esp32-c3-ard.yaml @@ -1,79 +1,6 @@ -uart: - - id: uart_havells_solar - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - flow_control_pin: 3 - -sensor: - - platform: havells_solar - update_interval: 60s - phase_a: - voltage: - name: Phase A Voltage - current: - name: Phase A Current - phase_b: - voltage: - name: Voltage Phase B - current: - name: Current Phase B - phase_c: - voltage: - name: Voltage Phase C - current: - name: Current Phase C - pv1: - voltage: - name: PV1 Voltage - current: - name: PV1 Current - active_power: - name: PV1 Active Power - voltage_sampled_by_secondary_cpu: - name: PV1 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV1 Insulation Of +VE To Ground - pv2: - voltage: - name: PV2 Voltage - current: - name: PV2 Current - active_power: - name: PV2 Active Power - voltage_sampled_by_secondary_cpu: - name: PV2 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV2 Insulation Of +VE To Ground - active_power: - name: Active Power - reactive_power: - name: Reactive Power - frequency: - name: Frequency - energy_production_day: - name: Today's Generation - total_energy_production: - name: Total Energy Production - total_generation_time: - name: Total Generation Time - today_generation_time: - name: Today Generation Time - inverter_module_temp: - name: Inverter Module Temp - inverter_inner_temp: - name: Inverter Inner Temp - inverter_bus_voltage: - name: Inverter BUS Voltage - insulation_of_pv_n_to_ground: - name: Insulation Of PV- To Ground - gfci_value: - name: GFCI Value - dci_of_r: - name: DCI Of R - dci_of_s: - name: DCI Of S - dci_of_t: - name: DCI Of T +<<: !include common.yaml diff --git a/tests/components/havells_solar/test.esp32-c3-idf.yaml b/tests/components/havells_solar/test.esp32-c3-idf.yaml index 5cb911cf71..452031a5aa 100644 --- a/tests/components/havells_solar/test.esp32-c3-idf.yaml +++ b/tests/components/havells_solar/test.esp32-c3-idf.yaml @@ -1,79 +1,6 @@ -uart: - - id: uart_havells_solar - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - flow_control_pin: 3 - -sensor: - - platform: havells_solar - update_interval: 60s - phase_a: - voltage: - name: Phase A Voltage - current: - name: Phase A Current - phase_b: - voltage: - name: Voltage Phase B - current: - name: Current Phase B - phase_c: - voltage: - name: Voltage Phase C - current: - name: Current Phase C - pv1: - voltage: - name: PV1 Voltage - current: - name: PV1 Current - active_power: - name: PV1 Active Power - voltage_sampled_by_secondary_cpu: - name: PV1 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV1 Insulation Of +VE To Ground - pv2: - voltage: - name: PV2 Voltage - current: - name: PV2 Current - active_power: - name: PV2 Active Power - voltage_sampled_by_secondary_cpu: - name: PV2 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV2 Insulation Of +VE To Ground - active_power: - name: Active Power - reactive_power: - name: Reactive Power - frequency: - name: Frequency - energy_production_day: - name: Today's Generation - total_energy_production: - name: Total Energy Production - total_generation_time: - name: Total Generation Time - today_generation_time: - name: Today Generation Time - inverter_module_temp: - name: Inverter Module Temp - inverter_inner_temp: - name: Inverter Inner Temp - inverter_bus_voltage: - name: Inverter BUS Voltage - insulation_of_pv_n_to_ground: - name: Insulation Of PV- To Ground - gfci_value: - name: GFCI Value - dci_of_r: - name: DCI Of R - dci_of_s: - name: DCI Of S - dci_of_t: - name: DCI Of T +<<: !include common.yaml diff --git a/tests/components/havells_solar/test.esp32-idf.yaml b/tests/components/havells_solar/test.esp32-idf.yaml index 2cda8e37be..bd767a8ece 100644 --- a/tests/components/havells_solar/test.esp32-idf.yaml +++ b/tests/components/havells_solar/test.esp32-idf.yaml @@ -1,79 +1,6 @@ -uart: - - id: uart_havells_solar - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + flow_control_pin: GPIO13 -modbus: - flow_control_pin: 3 - -sensor: - - platform: havells_solar - update_interval: 60s - phase_a: - voltage: - name: Phase A Voltage - current: - name: Phase A Current - phase_b: - voltage: - name: Voltage Phase B - current: - name: Current Phase B - phase_c: - voltage: - name: Voltage Phase C - current: - name: Current Phase C - pv1: - voltage: - name: PV1 Voltage - current: - name: PV1 Current - active_power: - name: PV1 Active Power - voltage_sampled_by_secondary_cpu: - name: PV1 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV1 Insulation Of +VE To Ground - pv2: - voltage: - name: PV2 Voltage - current: - name: PV2 Current - active_power: - name: PV2 Active Power - voltage_sampled_by_secondary_cpu: - name: PV2 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV2 Insulation Of +VE To Ground - active_power: - name: Active Power - reactive_power: - name: Reactive Power - frequency: - name: Frequency - energy_production_day: - name: Today's Generation - total_energy_production: - name: Total Energy Production - total_generation_time: - name: Total Generation Time - today_generation_time: - name: Today Generation Time - inverter_module_temp: - name: Inverter Module Temp - inverter_inner_temp: - name: Inverter Inner Temp - inverter_bus_voltage: - name: Inverter BUS Voltage - insulation_of_pv_n_to_ground: - name: Insulation Of PV- To Ground - gfci_value: - name: GFCI Value - dci_of_r: - name: DCI Of R - dci_of_s: - name: DCI Of S - dci_of_t: - name: DCI Of T +<<: !include common.yaml diff --git a/tests/components/havells_solar/test.esp8266-ard.yaml b/tests/components/havells_solar/test.esp8266-ard.yaml index 5cb911cf71..29c98d0957 100644 --- a/tests/components/havells_solar/test.esp8266-ard.yaml +++ b/tests/components/havells_solar/test.esp8266-ard.yaml @@ -1,79 +1,6 @@ -uart: - - id: uart_havells_solar - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO13 -modbus: - flow_control_pin: 3 - -sensor: - - platform: havells_solar - update_interval: 60s - phase_a: - voltage: - name: Phase A Voltage - current: - name: Phase A Current - phase_b: - voltage: - name: Voltage Phase B - current: - name: Current Phase B - phase_c: - voltage: - name: Voltage Phase C - current: - name: Current Phase C - pv1: - voltage: - name: PV1 Voltage - current: - name: PV1 Current - active_power: - name: PV1 Active Power - voltage_sampled_by_secondary_cpu: - name: PV1 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV1 Insulation Of +VE To Ground - pv2: - voltage: - name: PV2 Voltage - current: - name: PV2 Current - active_power: - name: PV2 Active Power - voltage_sampled_by_secondary_cpu: - name: PV2 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV2 Insulation Of +VE To Ground - active_power: - name: Active Power - reactive_power: - name: Reactive Power - frequency: - name: Frequency - energy_production_day: - name: Today's Generation - total_energy_production: - name: Total Energy Production - total_generation_time: - name: Total Generation Time - today_generation_time: - name: Today Generation Time - inverter_module_temp: - name: Inverter Module Temp - inverter_inner_temp: - name: Inverter Inner Temp - inverter_bus_voltage: - name: Inverter BUS Voltage - insulation_of_pv_n_to_ground: - name: Insulation Of PV- To Ground - gfci_value: - name: GFCI Value - dci_of_r: - name: DCI Of R - dci_of_s: - name: DCI Of S - dci_of_t: - name: DCI Of T +<<: !include common.yaml diff --git a/tests/components/havells_solar/test.rp2040-ard.yaml b/tests/components/havells_solar/test.rp2040-ard.yaml index 5cb911cf71..452031a5aa 100644 --- a/tests/components/havells_solar/test.rp2040-ard.yaml +++ b/tests/components/havells_solar/test.rp2040-ard.yaml @@ -1,79 +1,6 @@ -uart: - - id: uart_havells_solar - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - flow_control_pin: 3 - -sensor: - - platform: havells_solar - update_interval: 60s - phase_a: - voltage: - name: Phase A Voltage - current: - name: Phase A Current - phase_b: - voltage: - name: Voltage Phase B - current: - name: Current Phase B - phase_c: - voltage: - name: Voltage Phase C - current: - name: Current Phase C - pv1: - voltage: - name: PV1 Voltage - current: - name: PV1 Current - active_power: - name: PV1 Active Power - voltage_sampled_by_secondary_cpu: - name: PV1 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV1 Insulation Of +VE To Ground - pv2: - voltage: - name: PV2 Voltage - current: - name: PV2 Current - active_power: - name: PV2 Active Power - voltage_sampled_by_secondary_cpu: - name: PV2 Voltage Sampled By Secondary CPU - insulation_of_p_to_ground: - name: PV2 Insulation Of +VE To Ground - active_power: - name: Active Power - reactive_power: - name: Reactive Power - frequency: - name: Frequency - energy_production_day: - name: Today's Generation - total_energy_production: - name: Total Energy Production - total_generation_time: - name: Total Generation Time - today_generation_time: - name: Today Generation Time - inverter_module_temp: - name: Inverter Module Temp - inverter_inner_temp: - name: Inverter Inner Temp - inverter_bus_voltage: - name: Inverter BUS Voltage - insulation_of_pv_n_to_ground: - name: Insulation Of PV- To Ground - gfci_value: - name: GFCI Value - dci_of_r: - name: DCI Of R - dci_of_s: - name: DCI Of S - dci_of_t: - name: DCI Of T +<<: !include common.yaml diff --git a/tests/components/hdc1080/common.yaml b/tests/components/hdc1080/common.yaml new file mode 100644 index 0000000000..d260d4737c --- /dev/null +++ b/tests/components/hdc1080/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_hdc1080 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: hdc1080 + temperature: + name: Temperature + humidity: + name: Humidity + update_interval: 15s diff --git a/tests/components/hdc1080/test.esp32-ard.yaml b/tests/components/hdc1080/test.esp32-ard.yaml index 8e313dfa40..63c3bd6afd 100644 --- a/tests/components/hdc1080/test.esp32-ard.yaml +++ b/tests/components/hdc1080/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hdc1080 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: hdc1080 - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/hdc1080/test.esp32-c3-ard.yaml b/tests/components/hdc1080/test.esp32-c3-ard.yaml index 7bf7af6fa7..ee2c29ca4e 100644 --- a/tests/components/hdc1080/test.esp32-c3-ard.yaml +++ b/tests/components/hdc1080/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hdc1080 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hdc1080 - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/hdc1080/test.esp32-c3-idf.yaml b/tests/components/hdc1080/test.esp32-c3-idf.yaml index 7bf7af6fa7..ee2c29ca4e 100644 --- a/tests/components/hdc1080/test.esp32-c3-idf.yaml +++ b/tests/components/hdc1080/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hdc1080 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hdc1080 - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/hdc1080/test.esp32-idf.yaml b/tests/components/hdc1080/test.esp32-idf.yaml index 8e313dfa40..63c3bd6afd 100644 --- a/tests/components/hdc1080/test.esp32-idf.yaml +++ b/tests/components/hdc1080/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hdc1080 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: hdc1080 - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/hdc1080/test.esp8266-ard.yaml b/tests/components/hdc1080/test.esp8266-ard.yaml index 7bf7af6fa7..ee2c29ca4e 100644 --- a/tests/components/hdc1080/test.esp8266-ard.yaml +++ b/tests/components/hdc1080/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hdc1080 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hdc1080 - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/hdc1080/test.rp2040-ard.yaml b/tests/components/hdc1080/test.rp2040-ard.yaml index 7bf7af6fa7..ee2c29ca4e 100644 --- a/tests/components/hdc1080/test.rp2040-ard.yaml +++ b/tests/components/hdc1080/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hdc1080 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hdc1080 - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/he60r/common.yaml b/tests/components/he60r/common.yaml new file mode 100644 index 0000000000..e10e745f57 --- /dev/null +++ b/tests/components/he60r/common.yaml @@ -0,0 +1,13 @@ +uart: + - id: uart_he60r + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 1200 + parity: EVEN + +cover: + - platform: he60r + id: garage_door + name: Garage Door + open_duration: 14s + close_duration: 14s diff --git a/tests/components/he60r/test.esp32-ard.yaml b/tests/components/he60r/test.esp32-ard.yaml index 840387ae36..f486544afa 100644 --- a/tests/components/he60r/test.esp32-ard.yaml +++ b/tests/components/he60r/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_he60r - tx_pin: 17 - rx_pin: 16 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -cover: - - platform: he60r - id: garage_door - name: Garage Door - open_duration: 14s - close_duration: 14s +<<: !include common.yaml diff --git a/tests/components/he60r/test.esp32-c3-ard.yaml b/tests/components/he60r/test.esp32-c3-ard.yaml index bcbb544442..b516342f3b 100644 --- a/tests/components/he60r/test.esp32-c3-ard.yaml +++ b/tests/components/he60r/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_he60r - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -cover: - - platform: he60r - id: garage_door - name: Garage Door - open_duration: 14s - close_duration: 14s +<<: !include common.yaml diff --git a/tests/components/he60r/test.esp32-c3-idf.yaml b/tests/components/he60r/test.esp32-c3-idf.yaml index bcbb544442..b516342f3b 100644 --- a/tests/components/he60r/test.esp32-c3-idf.yaml +++ b/tests/components/he60r/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_he60r - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -cover: - - platform: he60r - id: garage_door - name: Garage Door - open_duration: 14s - close_duration: 14s +<<: !include common.yaml diff --git a/tests/components/he60r/test.esp32-idf.yaml b/tests/components/he60r/test.esp32-idf.yaml index 840387ae36..f486544afa 100644 --- a/tests/components/he60r/test.esp32-idf.yaml +++ b/tests/components/he60r/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_he60r - tx_pin: 17 - rx_pin: 16 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -cover: - - platform: he60r - id: garage_door - name: Garage Door - open_duration: 14s - close_duration: 14s +<<: !include common.yaml diff --git a/tests/components/he60r/test.esp8266-ard.yaml b/tests/components/he60r/test.esp8266-ard.yaml index bcbb544442..b516342f3b 100644 --- a/tests/components/he60r/test.esp8266-ard.yaml +++ b/tests/components/he60r/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_he60r - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -cover: - - platform: he60r - id: garage_door - name: Garage Door - open_duration: 14s - close_duration: 14s +<<: !include common.yaml diff --git a/tests/components/he60r/test.rp2040-ard.yaml b/tests/components/he60r/test.rp2040-ard.yaml index bcbb544442..b516342f3b 100644 --- a/tests/components/he60r/test.rp2040-ard.yaml +++ b/tests/components/he60r/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -uart: - - id: uart_he60r - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -cover: - - platform: he60r - id: garage_door - name: Garage Door - open_duration: 14s - close_duration: 14s +<<: !include common.yaml diff --git a/tests/components/heatpumpir/common.yaml b/tests/components/heatpumpir/common.yaml new file mode 100644 index 0000000000..2df195c5de --- /dev/null +++ b/tests/components/heatpumpir/common.yaml @@ -0,0 +1,26 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: heatpumpir + protocol: mitsubishi_heavy_zm + horizontal_default: left + vertical_default: up + name: HeatpumpIR Climate + min_temperature: 18 + max_temperature: 30 + - platform: heatpumpir + protocol: daikin + horizontal_default: mleft + vertical_default: mup + name: HeatpumpIR Climate + min_temperature: 18 + max_temperature: 30 + - platform: heatpumpir + protocol: panasonic_altdke + horizontal_default: mright + vertical_default: mdown + name: HeatpumpIR Climate + min_temperature: 18 + max_temperature: 30 diff --git a/tests/components/heatpumpir/test.bk72xx-ard.yaml b/tests/components/heatpumpir/test.bk72xx-ard.yaml index b616f9157c..06e1aea364 100644 --- a/tests/components/heatpumpir/test.bk72xx-ard.yaml +++ b/tests/components/heatpumpir/test.bk72xx-ard.yaml @@ -1,26 +1,4 @@ -remote_transmitter: - pin: 6 - carrier_duty_percent: 50% +substitutions: + pin: GPIO6 -climate: - - platform: heatpumpir - protocol: mitsubishi_heavy_zm - horizontal_default: left - vertical_default: up - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 - - platform: heatpumpir - protocol: daikin - horizontal_default: mleft - vertical_default: mup - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 - - platform: heatpumpir - protocol: panasonic_altdke - horizontal_default: mright - vertical_default: mdown - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 +<<: !include common.yaml diff --git a/tests/components/heatpumpir/test.esp32-ard.yaml b/tests/components/heatpumpir/test.esp32-ard.yaml index db3f81f6a0..7b012aa64c 100644 --- a/tests/components/heatpumpir/test.esp32-ard.yaml +++ b/tests/components/heatpumpir/test.esp32-ard.yaml @@ -1,19 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: heatpumpir - protocol: mitsubishi_heavy_zm - horizontal_default: left - vertical_default: up - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 - - platform: heatpumpir - protocol: greeyt - horizontal_default: left - vertical_default: up - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 +<<: !include common.yaml diff --git a/tests/components/heatpumpir/test.esp32-c3-ard.yaml b/tests/components/heatpumpir/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..7b012aa64c --- /dev/null +++ b/tests/components/heatpumpir/test.esp32-c3-ard.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO2 + +<<: !include common.yaml diff --git a/tests/components/heatpumpir/test.esp8266-ard.yaml b/tests/components/heatpumpir/test.esp8266-ard.yaml index 26a01cb198..f5097fcf5f 100644 --- a/tests/components/heatpumpir/test.esp8266-ard.yaml +++ b/tests/components/heatpumpir/test.esp8266-ard.yaml @@ -1,19 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: heatpumpir - protocol: mitsubishi_heavy_zm - horizontal_default: left - vertical_default: up - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 - - platform: heatpumpir - protocol: greeyt - horizontal_default: left - vertical_default: up - name: HeatpumpIR Climate - min_temperature: 18 - max_temperature: 30 +<<: !include common.yaml diff --git a/tests/components/hitachi_ac344/common.yaml b/tests/components/hitachi_ac344/common.yaml new file mode 100644 index 0000000000..960f032035 --- /dev/null +++ b/tests/components/hitachi_ac344/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: hitachi_ac344 + name: Hitachi Climate diff --git a/tests/components/hitachi_ac344/test.bk72xx-ard.yaml b/tests/components/hitachi_ac344/test.bk72xx-ard.yaml new file mode 100644 index 0000000000..06e1aea364 --- /dev/null +++ b/tests/components/hitachi_ac344/test.bk72xx-ard.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO6 + +<<: !include common.yaml diff --git a/tests/components/hitachi_ac344/test.esp32-ard.yaml b/tests/components/hitachi_ac344/test.esp32-ard.yaml index 684d5899de..7b012aa64c 100644 --- a/tests/components/hitachi_ac344/test.esp32-ard.yaml +++ b/tests/components/hitachi_ac344/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: hitachi_ac344 - name: Hitachi Climate +<<: !include common.yaml diff --git a/tests/components/hitachi_ac344/test.esp32-c3-ard.yaml b/tests/components/hitachi_ac344/test.esp32-c3-ard.yaml index 684d5899de..7b012aa64c 100644 --- a/tests/components/hitachi_ac344/test.esp32-c3-ard.yaml +++ b/tests/components/hitachi_ac344/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: hitachi_ac344 - name: Hitachi Climate +<<: !include common.yaml diff --git a/tests/components/hitachi_ac344/test.esp32-c3-idf.yaml b/tests/components/hitachi_ac344/test.esp32-c3-idf.yaml index 684d5899de..7b012aa64c 100644 --- a/tests/components/hitachi_ac344/test.esp32-c3-idf.yaml +++ b/tests/components/hitachi_ac344/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: hitachi_ac344 - name: Hitachi Climate +<<: !include common.yaml diff --git a/tests/components/hitachi_ac344/test.esp32-idf.yaml b/tests/components/hitachi_ac344/test.esp32-idf.yaml index 684d5899de..7b012aa64c 100644 --- a/tests/components/hitachi_ac344/test.esp32-idf.yaml +++ b/tests/components/hitachi_ac344/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: hitachi_ac344 - name: Hitachi Climate +<<: !include common.yaml diff --git a/tests/components/hitachi_ac344/test.esp8266-ard.yaml b/tests/components/hitachi_ac344/test.esp8266-ard.yaml index e6203e3084..f5097fcf5f 100644 --- a/tests/components/hitachi_ac344/test.esp8266-ard.yaml +++ b/tests/components/hitachi_ac344/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: hitachi_ac344 - name: Hitachi Climate +<<: !include common.yaml diff --git a/tests/components/hitachi_ac424/common.yaml b/tests/components/hitachi_ac424/common.yaml new file mode 100644 index 0000000000..ad904c73a3 --- /dev/null +++ b/tests/components/hitachi_ac424/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: hitachi_ac424 + name: Hitachi Climate diff --git a/tests/components/hitachi_ac424/test.bk72xx-ard.yaml b/tests/components/hitachi_ac424/test.bk72xx-ard.yaml new file mode 100644 index 0000000000..06e1aea364 --- /dev/null +++ b/tests/components/hitachi_ac424/test.bk72xx-ard.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO6 + +<<: !include common.yaml diff --git a/tests/components/hitachi_ac424/test.esp32-ard.yaml b/tests/components/hitachi_ac424/test.esp32-ard.yaml index a09821b9c6..7b012aa64c 100644 --- a/tests/components/hitachi_ac424/test.esp32-ard.yaml +++ b/tests/components/hitachi_ac424/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: hitachi_ac424 - name: Hitachi Climate +<<: !include common.yaml diff --git a/tests/components/hitachi_ac424/test.esp32-c3-ard.yaml b/tests/components/hitachi_ac424/test.esp32-c3-ard.yaml index a09821b9c6..7b012aa64c 100644 --- a/tests/components/hitachi_ac424/test.esp32-c3-ard.yaml +++ b/tests/components/hitachi_ac424/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: hitachi_ac424 - name: Hitachi Climate +<<: !include common.yaml diff --git a/tests/components/hitachi_ac424/test.esp32-c3-idf.yaml b/tests/components/hitachi_ac424/test.esp32-c3-idf.yaml index a09821b9c6..7b012aa64c 100644 --- a/tests/components/hitachi_ac424/test.esp32-c3-idf.yaml +++ b/tests/components/hitachi_ac424/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: hitachi_ac424 - name: Hitachi Climate +<<: !include common.yaml diff --git a/tests/components/hitachi_ac424/test.esp32-idf.yaml b/tests/components/hitachi_ac424/test.esp32-idf.yaml index a09821b9c6..7b012aa64c 100644 --- a/tests/components/hitachi_ac424/test.esp32-idf.yaml +++ b/tests/components/hitachi_ac424/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: hitachi_ac424 - name: Hitachi Climate +<<: !include common.yaml diff --git a/tests/components/hitachi_ac424/test.esp8266-ard.yaml b/tests/components/hitachi_ac424/test.esp8266-ard.yaml index 78b9e7c98c..f5097fcf5f 100644 --- a/tests/components/hitachi_ac424/test.esp8266-ard.yaml +++ b/tests/components/hitachi_ac424/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: hitachi_ac424 - name: Hitachi Climate +<<: !include common.yaml diff --git a/tests/components/hlw8012/common.yaml b/tests/components/hlw8012/common.yaml new file mode 100644 index 0000000000..d0d376a43a --- /dev/null +++ b/tests/components/hlw8012/common.yaml @@ -0,0 +1,21 @@ +sensor: + - platform: hlw8012 + model: hlw8012 + sel_pin: ${sel_pin} + cf_pin: ${cf_pin} + cf1_pin: ${cf1_pin} + current: + name: HLW8012 Current + voltage: + name: HLW8012 Voltage + power: + name: HLW8012 Power + id: hlw8012_power + energy: + name: HLW8012 Energy + id: hlw8012_energy + update_interval: 15s + current_resistor: 0.001 ohm + voltage_divider: 2351 + change_mode_every: "never" + initial_mode: VOLTAGE diff --git a/tests/components/hlw8012/test.esp32-ard.yaml b/tests/components/hlw8012/test.esp32-ard.yaml index 5b2d865722..8b42b21b54 100644 --- a/tests/components/hlw8012/test.esp32-ard.yaml +++ b/tests/components/hlw8012/test.esp32-ard.yaml @@ -1,21 +1,6 @@ -sensor: - - platform: hlw8012 - model: hlw8012 - sel_pin: 12 - cf_pin: 14 - cf1_pin: 13 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE +substitutions: + sel_pin: GPIO12 + cf_pin: GPIO13 + cf1_pin: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/hlw8012/test.esp32-c3-ard.yaml b/tests/components/hlw8012/test.esp32-c3-ard.yaml index da6053a1b9..8b0d069ce2 100644 --- a/tests/components/hlw8012/test.esp32-c3-ard.yaml +++ b/tests/components/hlw8012/test.esp32-c3-ard.yaml @@ -1,21 +1,6 @@ -sensor: - - platform: hlw8012 - model: hlw8012 - sel_pin: 2 - cf_pin: 4 - cf1_pin: 3 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE +substitutions: + sel_pin: GPIO2 + cf_pin: GPIO3 + cf1_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/hlw8012/test.esp32-c3-idf.yaml b/tests/components/hlw8012/test.esp32-c3-idf.yaml index da6053a1b9..8b0d069ce2 100644 --- a/tests/components/hlw8012/test.esp32-c3-idf.yaml +++ b/tests/components/hlw8012/test.esp32-c3-idf.yaml @@ -1,21 +1,6 @@ -sensor: - - platform: hlw8012 - model: hlw8012 - sel_pin: 2 - cf_pin: 4 - cf1_pin: 3 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE +substitutions: + sel_pin: GPIO2 + cf_pin: GPIO3 + cf1_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/hlw8012/test.esp32-idf.yaml b/tests/components/hlw8012/test.esp32-idf.yaml index 5b2d865722..8b42b21b54 100644 --- a/tests/components/hlw8012/test.esp32-idf.yaml +++ b/tests/components/hlw8012/test.esp32-idf.yaml @@ -1,21 +1,6 @@ -sensor: - - platform: hlw8012 - model: hlw8012 - sel_pin: 12 - cf_pin: 14 - cf1_pin: 13 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE +substitutions: + sel_pin: GPIO12 + cf_pin: GPIO13 + cf1_pin: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/hlw8012/test.esp8266-ard.yaml b/tests/components/hlw8012/test.esp8266-ard.yaml index 5b2d865722..8b42b21b54 100644 --- a/tests/components/hlw8012/test.esp8266-ard.yaml +++ b/tests/components/hlw8012/test.esp8266-ard.yaml @@ -1,21 +1,6 @@ -sensor: - - platform: hlw8012 - model: hlw8012 - sel_pin: 12 - cf_pin: 14 - cf1_pin: 13 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE +substitutions: + sel_pin: GPIO12 + cf_pin: GPIO13 + cf1_pin: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/hlw8012/test.rp2040-ard.yaml b/tests/components/hlw8012/test.rp2040-ard.yaml index da6053a1b9..8b0d069ce2 100644 --- a/tests/components/hlw8012/test.rp2040-ard.yaml +++ b/tests/components/hlw8012/test.rp2040-ard.yaml @@ -1,21 +1,6 @@ -sensor: - - platform: hlw8012 - model: hlw8012 - sel_pin: 2 - cf_pin: 4 - cf1_pin: 3 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE +substitutions: + sel_pin: GPIO2 + cf_pin: GPIO3 + cf1_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/hm3301/common.yaml b/tests/components/hm3301/common.yaml new file mode 100644 index 0000000000..b533130569 --- /dev/null +++ b/tests/components/hm3301/common.yaml @@ -0,0 +1,16 @@ +i2c: + - id: i2c_hm3301 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: hm3301 + pm_1_0: + name: PM1.0 + pm_2_5: + name: PM2.5 + pm_10_0: + name: PM10.0 + aqi: + name: AQI + calculation_type: CAQI diff --git a/tests/components/hm3301/test.esp32-ard.yaml b/tests/components/hm3301/test.esp32-ard.yaml index 413e88a265..63c3bd6afd 100644 --- a/tests/components/hm3301/test.esp32-ard.yaml +++ b/tests/components/hm3301/test.esp32-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_hm3301 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: hm3301 - pm_1_0: - name: PM1.0 - pm_2_5: - name: PM2.5 - pm_10_0: - name: PM10.0 - aqi: - name: AQI - calculation_type: CAQI +<<: !include common.yaml diff --git a/tests/components/hm3301/test.esp32-c3-ard.yaml b/tests/components/hm3301/test.esp32-c3-ard.yaml index eb6c4a14e6..ee2c29ca4e 100644 --- a/tests/components/hm3301/test.esp32-c3-ard.yaml +++ b/tests/components/hm3301/test.esp32-c3-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_hm3301 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hm3301 - pm_1_0: - name: PM1.0 - pm_2_5: - name: PM2.5 - pm_10_0: - name: PM10.0 - aqi: - name: AQI - calculation_type: CAQI +<<: !include common.yaml diff --git a/tests/components/hm3301/test.esp32-c3-idf.yaml b/tests/components/hm3301/test.esp32-c3-idf.yaml index eb6c4a14e6..ee2c29ca4e 100644 --- a/tests/components/hm3301/test.esp32-c3-idf.yaml +++ b/tests/components/hm3301/test.esp32-c3-idf.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_hm3301 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hm3301 - pm_1_0: - name: PM1.0 - pm_2_5: - name: PM2.5 - pm_10_0: - name: PM10.0 - aqi: - name: AQI - calculation_type: CAQI +<<: !include common.yaml diff --git a/tests/components/hm3301/test.esp32-idf.yaml b/tests/components/hm3301/test.esp32-idf.yaml index 413e88a265..63c3bd6afd 100644 --- a/tests/components/hm3301/test.esp32-idf.yaml +++ b/tests/components/hm3301/test.esp32-idf.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_hm3301 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: hm3301 - pm_1_0: - name: PM1.0 - pm_2_5: - name: PM2.5 - pm_10_0: - name: PM10.0 - aqi: - name: AQI - calculation_type: CAQI +<<: !include common.yaml diff --git a/tests/components/hm3301/test.esp8266-ard.yaml b/tests/components/hm3301/test.esp8266-ard.yaml index eb6c4a14e6..ee2c29ca4e 100644 --- a/tests/components/hm3301/test.esp8266-ard.yaml +++ b/tests/components/hm3301/test.esp8266-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_hm3301 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hm3301 - pm_1_0: - name: PM1.0 - pm_2_5: - name: PM2.5 - pm_10_0: - name: PM10.0 - aqi: - name: AQI - calculation_type: CAQI +<<: !include common.yaml diff --git a/tests/components/hm3301/test.rp2040-ard.yaml b/tests/components/hm3301/test.rp2040-ard.yaml index eb6c4a14e6..ee2c29ca4e 100644 --- a/tests/components/hm3301/test.rp2040-ard.yaml +++ b/tests/components/hm3301/test.rp2040-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_hm3301 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hm3301 - pm_1_0: - name: PM1.0 - pm_2_5: - name: PM2.5 - pm_10_0: - name: PM10.0 - aqi: - name: AQI - calculation_type: CAQI +<<: !include common.yaml diff --git a/tests/components/hmc5883l/common.yaml b/tests/components/hmc5883l/common.yaml new file mode 100644 index 0000000000..1c90f5f1c6 --- /dev/null +++ b/tests/components/hmc5883l/common.yaml @@ -0,0 +1,19 @@ +i2c: + - id: i2c_hmc5883l + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: hmc5883l + address: 0x68 + field_strength_x: + name: HMC5883L Field Strength X + field_strength_y: + name: HMC5883L Field Strength Y + field_strength_z: + name: HMC5883L Field Strength Z + heading: + name: HMC5883L Heading + range: 130uT + oversampling: 8x + update_interval: 15s diff --git a/tests/components/hmc5883l/test.esp32-ard.yaml b/tests/components/hmc5883l/test.esp32-ard.yaml index db632fc411..63c3bd6afd 100644 --- a/tests/components/hmc5883l/test.esp32-ard.yaml +++ b/tests/components/hmc5883l/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_hmc5883l - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: hmc5883l - address: 0x68 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z - heading: - name: HMC5883L Heading - range: 130uT - oversampling: 8x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/hmc5883l/test.esp32-c3-ard.yaml b/tests/components/hmc5883l/test.esp32-c3-ard.yaml index e65b2e5c5b..ee2c29ca4e 100644 --- a/tests/components/hmc5883l/test.esp32-c3-ard.yaml +++ b/tests/components/hmc5883l/test.esp32-c3-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_hmc5883l - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hmc5883l - address: 0x68 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z - heading: - name: HMC5883L Heading - range: 130uT - oversampling: 8x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/hmc5883l/test.esp32-c3-idf.yaml b/tests/components/hmc5883l/test.esp32-c3-idf.yaml index e65b2e5c5b..ee2c29ca4e 100644 --- a/tests/components/hmc5883l/test.esp32-c3-idf.yaml +++ b/tests/components/hmc5883l/test.esp32-c3-idf.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_hmc5883l - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hmc5883l - address: 0x68 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z - heading: - name: HMC5883L Heading - range: 130uT - oversampling: 8x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/hmc5883l/test.esp32-idf.yaml b/tests/components/hmc5883l/test.esp32-idf.yaml index db632fc411..63c3bd6afd 100644 --- a/tests/components/hmc5883l/test.esp32-idf.yaml +++ b/tests/components/hmc5883l/test.esp32-idf.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_hmc5883l - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: hmc5883l - address: 0x68 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z - heading: - name: HMC5883L Heading - range: 130uT - oversampling: 8x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/hmc5883l/test.esp8266-ard.yaml b/tests/components/hmc5883l/test.esp8266-ard.yaml index e65b2e5c5b..ee2c29ca4e 100644 --- a/tests/components/hmc5883l/test.esp8266-ard.yaml +++ b/tests/components/hmc5883l/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_hmc5883l - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hmc5883l - address: 0x68 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z - heading: - name: HMC5883L Heading - range: 130uT - oversampling: 8x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/hmc5883l/test.rp2040-ard.yaml b/tests/components/hmc5883l/test.rp2040-ard.yaml index e65b2e5c5b..ee2c29ca4e 100644 --- a/tests/components/hmc5883l/test.rp2040-ard.yaml +++ b/tests/components/hmc5883l/test.rp2040-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_hmc5883l - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hmc5883l - address: 0x68 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z - heading: - name: HMC5883L Heading - range: 130uT - oversampling: 8x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/honeywell_hih_i2c/common.yaml b/tests/components/honeywell_hih_i2c/common.yaml new file mode 100644 index 0000000000..a5f3eef187 --- /dev/null +++ b/tests/components/honeywell_hih_i2c/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_honeywell_hih + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: honeywell_hih_i2c + temperature: + name: Temperature + humidity: + name: Humidity + update_interval: 15s diff --git a/tests/components/honeywell_hih_i2c/test.esp32-ard.yaml b/tests/components/honeywell_hih_i2c/test.esp32-ard.yaml index 0119aec3f3..63c3bd6afd 100644 --- a/tests/components/honeywell_hih_i2c/test.esp32-ard.yaml +++ b/tests/components/honeywell_hih_i2c/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_honeywell_hih - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: honeywell_hih_i2c - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/honeywell_hih_i2c/test.esp32-c3-ard.yaml b/tests/components/honeywell_hih_i2c/test.esp32-c3-ard.yaml index 5dae3d5d52..ee2c29ca4e 100644 --- a/tests/components/honeywell_hih_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/honeywell_hih_i2c/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_honeywell_hih - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: honeywell_hih_i2c - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/honeywell_hih_i2c/test.esp32-c3-idf.yaml b/tests/components/honeywell_hih_i2c/test.esp32-c3-idf.yaml index 5dae3d5d52..ee2c29ca4e 100644 --- a/tests/components/honeywell_hih_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/honeywell_hih_i2c/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_honeywell_hih - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: honeywell_hih_i2c - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/honeywell_hih_i2c/test.esp32-idf.yaml b/tests/components/honeywell_hih_i2c/test.esp32-idf.yaml index 0119aec3f3..63c3bd6afd 100644 --- a/tests/components/honeywell_hih_i2c/test.esp32-idf.yaml +++ b/tests/components/honeywell_hih_i2c/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_honeywell_hih - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: honeywell_hih_i2c - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/honeywell_hih_i2c/test.esp8266-ard.yaml b/tests/components/honeywell_hih_i2c/test.esp8266-ard.yaml index 5dae3d5d52..ee2c29ca4e 100644 --- a/tests/components/honeywell_hih_i2c/test.esp8266-ard.yaml +++ b/tests/components/honeywell_hih_i2c/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_honeywell_hih - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: honeywell_hih_i2c - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/honeywell_hih_i2c/test.rp2040-ard.yaml b/tests/components/honeywell_hih_i2c/test.rp2040-ard.yaml index 5dae3d5d52..ee2c29ca4e 100644 --- a/tests/components/honeywell_hih_i2c/test.rp2040-ard.yaml +++ b/tests/components/honeywell_hih_i2c/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_honeywell_hih - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: honeywell_hih_i2c - temperature: - name: Temperature - humidity: - name: Humidity - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/honeywellabp/common.yaml b/tests/components/honeywellabp/common.yaml new file mode 100644 index 0000000000..21a3ef6ee3 --- /dev/null +++ b/tests/components/honeywellabp/common.yaml @@ -0,0 +1,15 @@ +spi: + - id: spi_bme280 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sensor: + - platform: honeywellabp + cs_pin: ${cs_pin} + pressure: + name: Honeywell pressure + min_pressure: 0 + max_pressure: 15 + temperature: + name: Honeywell temperature diff --git a/tests/components/honeywellabp/test.esp32-ard.yaml b/tests/components/honeywellabp/test.esp32-ard.yaml index 6bf9fa0f4d..54e027a614 100644 --- a/tests/components/honeywellabp/test.esp32-ard.yaml +++ b/tests/components/honeywellabp/test.esp32-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_bme280 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: honeywellabp - cs_pin: 12 - pressure: - name: Honeywell pressure - min_pressure: 0 - max_pressure: 15 - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp/test.esp32-c3-ard.yaml b/tests/components/honeywellabp/test.esp32-c3-ard.yaml index a53e3296dd..2415ba5dc6 100644 --- a/tests/components/honeywellabp/test.esp32-c3-ard.yaml +++ b/tests/components/honeywellabp/test.esp32-c3-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_honeywellabp - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: honeywellabp - cs_pin: 8 - pressure: - name: Honeywell pressure - min_pressure: 0 - max_pressure: 15 - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp/test.esp32-c3-idf.yaml b/tests/components/honeywellabp/test.esp32-c3-idf.yaml index a53e3296dd..2415ba5dc6 100644 --- a/tests/components/honeywellabp/test.esp32-c3-idf.yaml +++ b/tests/components/honeywellabp/test.esp32-c3-idf.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_honeywellabp - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: honeywellabp - cs_pin: 8 - pressure: - name: Honeywell pressure - min_pressure: 0 - max_pressure: 15 - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp/test.esp32-idf.yaml b/tests/components/honeywellabp/test.esp32-idf.yaml index 6bf9fa0f4d..54e027a614 100644 --- a/tests/components/honeywellabp/test.esp32-idf.yaml +++ b/tests/components/honeywellabp/test.esp32-idf.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_bme280 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: honeywellabp - cs_pin: 12 - pressure: - name: Honeywell pressure - min_pressure: 0 - max_pressure: 15 - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp/test.esp8266-ard.yaml b/tests/components/honeywellabp/test.esp8266-ard.yaml index 31988c035e..dbd158d030 100644 --- a/tests/components/honeywellabp/test.esp8266-ard.yaml +++ b/tests/components/honeywellabp/test.esp8266-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_bme280 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -sensor: - - platform: honeywellabp - cs_pin: 15 - pressure: - name: Honeywell pressure - min_pressure: 0 - max_pressure: 15 - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp/test.rp2040-ard.yaml b/tests/components/honeywellabp/test.rp2040-ard.yaml index 2e0c471fa0..f6c3f1eeca 100644 --- a/tests/components/honeywellabp/test.rp2040-ard.yaml +++ b/tests/components/honeywellabp/test.rp2040-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_bme280 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -sensor: - - platform: honeywellabp - cs_pin: 6 - pressure: - name: Honeywell pressure - min_pressure: 0 - max_pressure: 15 - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp2_i2c/common.yaml b/tests/components/honeywellabp2_i2c/common.yaml new file mode 100644 index 0000000000..6752a69866 --- /dev/null +++ b/tests/components/honeywellabp2_i2c/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_honeywellabp2 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: honeywellabp2_i2c + address: 0x28 + pressure: + name: Honeywell2 pressure + min_pressure: 0 + max_pressure: 16000 + transfer_function: A + temperature: + name: Honeywell temperature diff --git a/tests/components/honeywellabp2_i2c/test.esp32-ard.yaml b/tests/components/honeywellabp2_i2c/test.esp32-ard.yaml index 0f0d61ca06..63c3bd6afd 100644 --- a/tests/components/honeywellabp2_i2c/test.esp32-ard.yaml +++ b/tests/components/honeywellabp2_i2c/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_honeywellabp2 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: honeywellabp2_i2c - address: 0x28 - pressure: - name: Honeywell2 pressure - min_pressure: 0 - max_pressure: 16000 - transfer_function: A - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp2_i2c/test.esp32-c3-ard.yaml b/tests/components/honeywellabp2_i2c/test.esp32-c3-ard.yaml index b47411c238..ee2c29ca4e 100644 --- a/tests/components/honeywellabp2_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/honeywellabp2_i2c/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_honeywellabp2 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: honeywellabp2_i2c - address: 0x28 - pressure: - name: Honeywell2 pressure - min_pressure: 0 - max_pressure: 16000 - transfer_function: A - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp2_i2c/test.esp32-c3-idf.yaml b/tests/components/honeywellabp2_i2c/test.esp32-c3-idf.yaml index b47411c238..ee2c29ca4e 100644 --- a/tests/components/honeywellabp2_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/honeywellabp2_i2c/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_honeywellabp2 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: honeywellabp2_i2c - address: 0x28 - pressure: - name: Honeywell2 pressure - min_pressure: 0 - max_pressure: 16000 - transfer_function: A - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp2_i2c/test.esp32-idf.yaml b/tests/components/honeywellabp2_i2c/test.esp32-idf.yaml index 0f0d61ca06..63c3bd6afd 100644 --- a/tests/components/honeywellabp2_i2c/test.esp32-idf.yaml +++ b/tests/components/honeywellabp2_i2c/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_honeywellabp2 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: honeywellabp2_i2c - address: 0x28 - pressure: - name: Honeywell2 pressure - min_pressure: 0 - max_pressure: 16000 - transfer_function: A - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp2_i2c/test.esp8266-ard.yaml b/tests/components/honeywellabp2_i2c/test.esp8266-ard.yaml index b47411c238..ee2c29ca4e 100644 --- a/tests/components/honeywellabp2_i2c/test.esp8266-ard.yaml +++ b/tests/components/honeywellabp2_i2c/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_honeywellabp2 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: honeywellabp2_i2c - address: 0x28 - pressure: - name: Honeywell2 pressure - min_pressure: 0 - max_pressure: 16000 - transfer_function: A - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/honeywellabp2_i2c/test.rp2040-ard.yaml b/tests/components/honeywellabp2_i2c/test.rp2040-ard.yaml index b47411c238..ee2c29ca4e 100644 --- a/tests/components/honeywellabp2_i2c/test.rp2040-ard.yaml +++ b/tests/components/honeywellabp2_i2c/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_honeywellabp2 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: honeywellabp2_i2c - address: 0x28 - pressure: - name: Honeywell2 pressure - min_pressure: 0 - max_pressure: 16000 - transfer_function: A - temperature: - name: Honeywell temperature +<<: !include common.yaml diff --git a/tests/components/hrxl_maxsonar_wr/common.yaml b/tests/components/hrxl_maxsonar_wr/common.yaml new file mode 100644 index 0000000000..d74ada716d --- /dev/null +++ b/tests/components/hrxl_maxsonar_wr/common.yaml @@ -0,0 +1,10 @@ +uart: + - id: uart_hrxl_maxsonar_wr + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 115200 + +sensor: + - platform: hrxl_maxsonar_wr + id: hrxl_maxsonar_wr_sensor + name: Rainwater Tank Level diff --git a/tests/components/hrxl_maxsonar_wr/test.esp32-ard.yaml b/tests/components/hrxl_maxsonar_wr/test.esp32-ard.yaml index da283cc072..811f6b72a6 100644 --- a/tests/components/hrxl_maxsonar_wr/test.esp32-ard.yaml +++ b/tests/components/hrxl_maxsonar_wr/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_hrxl_maxsonar_wr - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: hrxl_maxsonar_wr - id: hrxl_maxsonar_wr_sensor - name: Rainwater Tank Level +<<: !include common.yaml diff --git a/tests/components/hrxl_maxsonar_wr/test.esp32-c3-ard.yaml b/tests/components/hrxl_maxsonar_wr/test.esp32-c3-ard.yaml index 729cb96120..b516342f3b 100644 --- a/tests/components/hrxl_maxsonar_wr/test.esp32-c3-ard.yaml +++ b/tests/components/hrxl_maxsonar_wr/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_hrxl_maxsonar_wr - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: hrxl_maxsonar_wr - id: hrxl_maxsonar_wr_sensor - name: Rainwater Tank Level +<<: !include common.yaml diff --git a/tests/components/hrxl_maxsonar_wr/test.esp32-c3-idf.yaml b/tests/components/hrxl_maxsonar_wr/test.esp32-c3-idf.yaml index 729cb96120..b516342f3b 100644 --- a/tests/components/hrxl_maxsonar_wr/test.esp32-c3-idf.yaml +++ b/tests/components/hrxl_maxsonar_wr/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_hrxl_maxsonar_wr - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: hrxl_maxsonar_wr - id: hrxl_maxsonar_wr_sensor - name: Rainwater Tank Level +<<: !include common.yaml diff --git a/tests/components/hrxl_maxsonar_wr/test.esp32-idf.yaml b/tests/components/hrxl_maxsonar_wr/test.esp32-idf.yaml index da283cc072..811f6b72a6 100644 --- a/tests/components/hrxl_maxsonar_wr/test.esp32-idf.yaml +++ b/tests/components/hrxl_maxsonar_wr/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_hrxl_maxsonar_wr - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 -sensor: - - platform: hrxl_maxsonar_wr - id: hrxl_maxsonar_wr_sensor - name: Rainwater Tank Level +<<: !include common.yaml diff --git a/tests/components/hrxl_maxsonar_wr/test.esp8266-ard.yaml b/tests/components/hrxl_maxsonar_wr/test.esp8266-ard.yaml index 729cb96120..b516342f3b 100644 --- a/tests/components/hrxl_maxsonar_wr/test.esp8266-ard.yaml +++ b/tests/components/hrxl_maxsonar_wr/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_hrxl_maxsonar_wr - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: hrxl_maxsonar_wr - id: hrxl_maxsonar_wr_sensor - name: Rainwater Tank Level +<<: !include common.yaml diff --git a/tests/components/hrxl_maxsonar_wr/test.rp2040-ard.yaml b/tests/components/hrxl_maxsonar_wr/test.rp2040-ard.yaml index 729cb96120..b516342f3b 100644 --- a/tests/components/hrxl_maxsonar_wr/test.rp2040-ard.yaml +++ b/tests/components/hrxl_maxsonar_wr/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_hrxl_maxsonar_wr - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: hrxl_maxsonar_wr - id: hrxl_maxsonar_wr_sensor - name: Rainwater Tank Level +<<: !include common.yaml diff --git a/tests/components/hte501/common.yaml b/tests/components/hte501/common.yaml new file mode 100644 index 0000000000..7c57b5bc6a --- /dev/null +++ b/tests/components/hte501/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_hte501 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: hte501 + address: 0x40 + temperature: + name: Temperature + humidity: + name: Humidity diff --git a/tests/components/hte501/test.esp32-ard.yaml b/tests/components/hte501/test.esp32-ard.yaml index 83e4d26603..63c3bd6afd 100644 --- a/tests/components/hte501/test.esp32-ard.yaml +++ b/tests/components/hte501/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hte501 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: hte501 - address: 0x40 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/hte501/test.esp32-c3-ard.yaml b/tests/components/hte501/test.esp32-c3-ard.yaml index e14b589dbd..ee2c29ca4e 100644 --- a/tests/components/hte501/test.esp32-c3-ard.yaml +++ b/tests/components/hte501/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hte501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hte501 - address: 0x40 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/hte501/test.esp32-c3-idf.yaml b/tests/components/hte501/test.esp32-c3-idf.yaml index e14b589dbd..ee2c29ca4e 100644 --- a/tests/components/hte501/test.esp32-c3-idf.yaml +++ b/tests/components/hte501/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hte501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hte501 - address: 0x40 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/hte501/test.esp32-idf.yaml b/tests/components/hte501/test.esp32-idf.yaml index 83e4d26603..63c3bd6afd 100644 --- a/tests/components/hte501/test.esp32-idf.yaml +++ b/tests/components/hte501/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hte501 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: hte501 - address: 0x40 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/hte501/test.esp8266-ard.yaml b/tests/components/hte501/test.esp8266-ard.yaml index e14b589dbd..ee2c29ca4e 100644 --- a/tests/components/hte501/test.esp8266-ard.yaml +++ b/tests/components/hte501/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hte501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hte501 - address: 0x40 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/hte501/test.rp2040-ard.yaml b/tests/components/hte501/test.rp2040-ard.yaml index e14b589dbd..ee2c29ca4e 100644 --- a/tests/components/hte501/test.rp2040-ard.yaml +++ b/tests/components/hte501/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_hte501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hte501 - address: 0x40 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/htu21d/common.yaml b/tests/components/htu21d/common.yaml new file mode 100644 index 0000000000..f12c1ca46e --- /dev/null +++ b/tests/components/htu21d/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_htu21d + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: htu21d + model: htu21d + temperature: + name: Temperature + humidity: + name: Humidity + heater: + name: Heater + update_interval: 15s diff --git a/tests/components/htu21d/test.esp32-ard.yaml b/tests/components/htu21d/test.esp32-ard.yaml index 6655a1cc1a..63c3bd6afd 100644 --- a/tests/components/htu21d/test.esp32-ard.yaml +++ b/tests/components/htu21d/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_htu21d - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: htu21d - model: htu21d - temperature: - name: Temperature - humidity: - name: Humidity - heater: - name: Heater - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/htu21d/test.esp32-c3-ard.yaml b/tests/components/htu21d/test.esp32-c3-ard.yaml index 8131d13661..ee2c29ca4e 100644 --- a/tests/components/htu21d/test.esp32-c3-ard.yaml +++ b/tests/components/htu21d/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_htu21d - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: htu21d - model: htu21d - temperature: - name: Temperature - humidity: - name: Humidity - heater: - name: Heater - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/htu21d/test.esp32-c3-idf.yaml b/tests/components/htu21d/test.esp32-c3-idf.yaml index 8131d13661..ee2c29ca4e 100644 --- a/tests/components/htu21d/test.esp32-c3-idf.yaml +++ b/tests/components/htu21d/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_htu21d - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: htu21d - model: htu21d - temperature: - name: Temperature - humidity: - name: Humidity - heater: - name: Heater - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/htu21d/test.esp32-idf.yaml b/tests/components/htu21d/test.esp32-idf.yaml index 6655a1cc1a..63c3bd6afd 100644 --- a/tests/components/htu21d/test.esp32-idf.yaml +++ b/tests/components/htu21d/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_htu21d - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: htu21d - model: htu21d - temperature: - name: Temperature - humidity: - name: Humidity - heater: - name: Heater - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/htu21d/test.esp8266-ard.yaml b/tests/components/htu21d/test.esp8266-ard.yaml index 8131d13661..ee2c29ca4e 100644 --- a/tests/components/htu21d/test.esp8266-ard.yaml +++ b/tests/components/htu21d/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_htu21d - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: htu21d - model: htu21d - temperature: - name: Temperature - humidity: - name: Humidity - heater: - name: Heater - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/htu21d/test.rp2040-ard.yaml b/tests/components/htu21d/test.rp2040-ard.yaml index 8131d13661..ee2c29ca4e 100644 --- a/tests/components/htu21d/test.rp2040-ard.yaml +++ b/tests/components/htu21d/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_htu21d - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: htu21d - model: htu21d - temperature: - name: Temperature - humidity: - name: Humidity - heater: - name: Heater - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/htu31d/common.yaml b/tests/components/htu31d/common.yaml index c8ef2fede9..735cdc7cbf 100644 --- a/tests/components/htu31d/common.yaml +++ b/tests/components/htu31d/common.yaml @@ -1,9 +1,12 @@ i2c: + - id: i2c_htu31d + scl: ${scl_pin} + sda: ${sda_pin} sensor: - platform: htu31d temperature: - name: Living Room Temperature 7 + name: Living Room Temperature humidity: - name: Living Room Humidity 7 + name: Living Room Humidity update_interval: 15s diff --git a/tests/components/htu31d/test.esp32-ard.yaml b/tests/components/htu31d/test.esp32-ard.yaml index dade44d145..63c3bd6afd 100644 --- a/tests/components/htu31d/test.esp32-ard.yaml +++ b/tests/components/htu31d/test.esp32-ard.yaml @@ -1 +1,5 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/htu31d/test.esp32-c3-ard.yaml b/tests/components/htu31d/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/htu31d/test.esp32-c3-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/htu31d/test.esp32-c3-idf.yaml b/tests/components/htu31d/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/htu31d/test.esp32-c3-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/htu31d/test.esp32-idf.yaml b/tests/components/htu31d/test.esp32-idf.yaml index dade44d145..63c3bd6afd 100644 --- a/tests/components/htu31d/test.esp32-idf.yaml +++ b/tests/components/htu31d/test.esp32-idf.yaml @@ -1 +1,5 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/htu31d/test.esp8266-ard.yaml b/tests/components/htu31d/test.esp8266-ard.yaml index dade44d145..ee2c29ca4e 100644 --- a/tests/components/htu31d/test.esp8266-ard.yaml +++ b/tests/components/htu31d/test.esp8266-ard.yaml @@ -1 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/htu31d/test.rp2040-ard.yaml b/tests/components/htu31d/test.rp2040-ard.yaml new file mode 100644 index 0000000000..ee2c29ca4e --- /dev/null +++ b/tests/components/htu31d/test.rp2040-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/hx711/common.yaml b/tests/components/hx711/common.yaml new file mode 100644 index 0000000000..be22fca678 --- /dev/null +++ b/tests/components/hx711/common.yaml @@ -0,0 +1,7 @@ +sensor: + - platform: hx711 + name: HX711 Value + clk_pin: ${clk_pin} + dout_pin: ${dout_pin} + gain: 128 + update_interval: 15s diff --git a/tests/components/hx711/test.esp32-ard.yaml b/tests/components/hx711/test.esp32-ard.yaml index 554b184422..6423867395 100644 --- a/tests/components/hx711/test.esp32-ard.yaml +++ b/tests/components/hx711/test.esp32-ard.yaml @@ -1,7 +1,5 @@ -sensor: - - platform: hx711 - name: HX711 Value - dout_pin: 14 - clk_pin: 15 - gain: 128 - update_interval: 15s +substitutions: + clk_pin: GPIO16 + dout_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/hx711/test.esp32-c3-ard.yaml b/tests/components/hx711/test.esp32-c3-ard.yaml index 9850417440..08a6e705c0 100644 --- a/tests/components/hx711/test.esp32-c3-ard.yaml +++ b/tests/components/hx711/test.esp32-c3-ard.yaml @@ -1,7 +1,5 @@ -sensor: - - platform: hx711 - name: HX711 Value - dout_pin: 4 - clk_pin: 5 - gain: 128 - update_interval: 15s +substitutions: + clk_pin: GPIO5 + dout_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/hx711/test.esp32-c3-idf.yaml b/tests/components/hx711/test.esp32-c3-idf.yaml index 9850417440..08a6e705c0 100644 --- a/tests/components/hx711/test.esp32-c3-idf.yaml +++ b/tests/components/hx711/test.esp32-c3-idf.yaml @@ -1,7 +1,5 @@ -sensor: - - platform: hx711 - name: HX711 Value - dout_pin: 4 - clk_pin: 5 - gain: 128 - update_interval: 15s +substitutions: + clk_pin: GPIO5 + dout_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/hx711/test.esp32-idf.yaml b/tests/components/hx711/test.esp32-idf.yaml index 554b184422..6423867395 100644 --- a/tests/components/hx711/test.esp32-idf.yaml +++ b/tests/components/hx711/test.esp32-idf.yaml @@ -1,7 +1,5 @@ -sensor: - - platform: hx711 - name: HX711 Value - dout_pin: 14 - clk_pin: 15 - gain: 128 - update_interval: 15s +substitutions: + clk_pin: GPIO16 + dout_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/hx711/test.esp8266-ard.yaml b/tests/components/hx711/test.esp8266-ard.yaml index 9850417440..08a6e705c0 100644 --- a/tests/components/hx711/test.esp8266-ard.yaml +++ b/tests/components/hx711/test.esp8266-ard.yaml @@ -1,7 +1,5 @@ -sensor: - - platform: hx711 - name: HX711 Value - dout_pin: 4 - clk_pin: 5 - gain: 128 - update_interval: 15s +substitutions: + clk_pin: GPIO5 + dout_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/hx711/test.rp2040-ard.yaml b/tests/components/hx711/test.rp2040-ard.yaml index 9850417440..08a6e705c0 100644 --- a/tests/components/hx711/test.rp2040-ard.yaml +++ b/tests/components/hx711/test.rp2040-ard.yaml @@ -1,7 +1,5 @@ -sensor: - - platform: hx711 - name: HX711 Value - dout_pin: 4 - clk_pin: 5 - gain: 128 - update_interval: 15s +substitutions: + clk_pin: GPIO5 + dout_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/hydreon_rgxx/common.yaml b/tests/components/hydreon_rgxx/common.yaml new file mode 100644 index 0000000000..e11c6c91c9 --- /dev/null +++ b/tests/components/hydreon_rgxx/common.yaml @@ -0,0 +1,37 @@ +uart: + - id: uart_hydreon_rgxx + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 115200 + +binary_sensor: + - platform: hydreon_rgxx + hydreon_rgxx_id: hydreon_rg9 + too_cold: + name: rg9_toocold + em_sat: + name: rg9_emsat + lens_bad: + name: rg9_lens_bad + +sensor: + - platform: hydreon_rgxx + id: hydreon_rg9 + model: RG 9 + moisture: + name: hydreon_rain + id: hydreon_rain + temperature: + name: hydreon_temperature + disable_led: true + - platform: hydreon_rgxx + id: hydreon_rg15 + model: RG_15 + acc: + name: hydreon_acc + event_acc: + name: hydreon_event_acc + total_acc: + name: hydreon_total_acc + r_int: + name: hydreon_r_int diff --git a/tests/components/hydreon_rgxx/test.esp32-ard.yaml b/tests/components/hydreon_rgxx/test.esp32-ard.yaml index b6f9486d86..f486544afa 100644 --- a/tests/components/hydreon_rgxx/test.esp32-ard.yaml +++ b/tests/components/hydreon_rgxx/test.esp32-ard.yaml @@ -1,37 +1,5 @@ -uart: - - id: uart_hydreon_rgxx - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -binary_sensor: - - platform: hydreon_rgxx - hydreon_rgxx_id: hydreon_rg9 - too_cold: - name: rg9_toocold - em_sat: - name: rg9_emsat - lens_bad: - name: rg9_lens_bad - -sensor: - - platform: hydreon_rgxx - id: hydreon_rg9 - model: RG 9 - moisture: - name: hydreon_rain - id: hydreon_rain - temperature: - name: hydreon_temperature - disable_led: true - - platform: hydreon_rgxx - id: hydreon_rg15 - model: RG_15 - acc: - name: hydreon_acc - event_acc: - name: hydreon_event_acc - total_acc: - name: hydreon_total_acc - r_int: - name: hydreon_r_int +<<: !include common.yaml diff --git a/tests/components/hydreon_rgxx/test.esp32-c3-ard.yaml b/tests/components/hydreon_rgxx/test.esp32-c3-ard.yaml index f62f4942db..b516342f3b 100644 --- a/tests/components/hydreon_rgxx/test.esp32-c3-ard.yaml +++ b/tests/components/hydreon_rgxx/test.esp32-c3-ard.yaml @@ -1,37 +1,5 @@ -uart: - - id: uart_hydreon_rgxx - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -binary_sensor: - - platform: hydreon_rgxx - hydreon_rgxx_id: hydreon_rg9 - too_cold: - name: rg9_toocold - em_sat: - name: rg9_emsat - lens_bad: - name: rg9_lens_bad - -sensor: - - platform: hydreon_rgxx - id: hydreon_rg9 - model: RG 9 - moisture: - name: hydreon_rain - id: hydreon_rain - temperature: - name: hydreon_temperature - disable_led: true - - platform: hydreon_rgxx - id: hydreon_rg15 - model: RG_15 - acc: - name: hydreon_acc - event_acc: - name: hydreon_event_acc - total_acc: - name: hydreon_total_acc - r_int: - name: hydreon_r_int +<<: !include common.yaml diff --git a/tests/components/hydreon_rgxx/test.esp32-c3-idf.yaml b/tests/components/hydreon_rgxx/test.esp32-c3-idf.yaml index f62f4942db..b516342f3b 100644 --- a/tests/components/hydreon_rgxx/test.esp32-c3-idf.yaml +++ b/tests/components/hydreon_rgxx/test.esp32-c3-idf.yaml @@ -1,37 +1,5 @@ -uart: - - id: uart_hydreon_rgxx - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -binary_sensor: - - platform: hydreon_rgxx - hydreon_rgxx_id: hydreon_rg9 - too_cold: - name: rg9_toocold - em_sat: - name: rg9_emsat - lens_bad: - name: rg9_lens_bad - -sensor: - - platform: hydreon_rgxx - id: hydreon_rg9 - model: RG 9 - moisture: - name: hydreon_rain - id: hydreon_rain - temperature: - name: hydreon_temperature - disable_led: true - - platform: hydreon_rgxx - id: hydreon_rg15 - model: RG_15 - acc: - name: hydreon_acc - event_acc: - name: hydreon_event_acc - total_acc: - name: hydreon_total_acc - r_int: - name: hydreon_r_int +<<: !include common.yaml diff --git a/tests/components/hydreon_rgxx/test.esp32-idf.yaml b/tests/components/hydreon_rgxx/test.esp32-idf.yaml index b6f9486d86..f486544afa 100644 --- a/tests/components/hydreon_rgxx/test.esp32-idf.yaml +++ b/tests/components/hydreon_rgxx/test.esp32-idf.yaml @@ -1,37 +1,5 @@ -uart: - - id: uart_hydreon_rgxx - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -binary_sensor: - - platform: hydreon_rgxx - hydreon_rgxx_id: hydreon_rg9 - too_cold: - name: rg9_toocold - em_sat: - name: rg9_emsat - lens_bad: - name: rg9_lens_bad - -sensor: - - platform: hydreon_rgxx - id: hydreon_rg9 - model: RG 9 - moisture: - name: hydreon_rain - id: hydreon_rain - temperature: - name: hydreon_temperature - disable_led: true - - platform: hydreon_rgxx - id: hydreon_rg15 - model: RG_15 - acc: - name: hydreon_acc - event_acc: - name: hydreon_event_acc - total_acc: - name: hydreon_total_acc - r_int: - name: hydreon_r_int +<<: !include common.yaml diff --git a/tests/components/hydreon_rgxx/test.esp8266-ard.yaml b/tests/components/hydreon_rgxx/test.esp8266-ard.yaml index f62f4942db..b516342f3b 100644 --- a/tests/components/hydreon_rgxx/test.esp8266-ard.yaml +++ b/tests/components/hydreon_rgxx/test.esp8266-ard.yaml @@ -1,37 +1,5 @@ -uart: - - id: uart_hydreon_rgxx - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -binary_sensor: - - platform: hydreon_rgxx - hydreon_rgxx_id: hydreon_rg9 - too_cold: - name: rg9_toocold - em_sat: - name: rg9_emsat - lens_bad: - name: rg9_lens_bad - -sensor: - - platform: hydreon_rgxx - id: hydreon_rg9 - model: RG 9 - moisture: - name: hydreon_rain - id: hydreon_rain - temperature: - name: hydreon_temperature - disable_led: true - - platform: hydreon_rgxx - id: hydreon_rg15 - model: RG_15 - acc: - name: hydreon_acc - event_acc: - name: hydreon_event_acc - total_acc: - name: hydreon_total_acc - r_int: - name: hydreon_r_int +<<: !include common.yaml diff --git a/tests/components/hydreon_rgxx/test.rp2040-ard.yaml b/tests/components/hydreon_rgxx/test.rp2040-ard.yaml index f62f4942db..b516342f3b 100644 --- a/tests/components/hydreon_rgxx/test.rp2040-ard.yaml +++ b/tests/components/hydreon_rgxx/test.rp2040-ard.yaml @@ -1,37 +1,5 @@ -uart: - - id: uart_hydreon_rgxx - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -binary_sensor: - - platform: hydreon_rgxx - hydreon_rgxx_id: hydreon_rg9 - too_cold: - name: rg9_toocold - em_sat: - name: rg9_emsat - lens_bad: - name: rg9_lens_bad - -sensor: - - platform: hydreon_rgxx - id: hydreon_rg9 - model: RG 9 - moisture: - name: hydreon_rain - id: hydreon_rain - temperature: - name: hydreon_temperature - disable_led: true - - platform: hydreon_rgxx - id: hydreon_rg15 - model: RG_15 - acc: - name: hydreon_acc - event_acc: - name: hydreon_event_acc - total_acc: - name: hydreon_total_acc - r_int: - name: hydreon_r_int +<<: !include common.yaml diff --git a/tests/components/hyt271/common.yaml b/tests/components/hyt271/common.yaml new file mode 100644 index 0000000000..7a4371173f --- /dev/null +++ b/tests/components/hyt271/common.yaml @@ -0,0 +1,11 @@ +i2c: + - id: i2c_hyt271 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: hyt271 + temperature: + name: Temperature + humidity: + name: Humidity diff --git a/tests/components/hyt271/test.esp32-ard.yaml b/tests/components/hyt271/test.esp32-ard.yaml index 297611a89b..63c3bd6afd 100644 --- a/tests/components/hyt271/test.esp32-ard.yaml +++ b/tests/components/hyt271/test.esp32-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_hyt271 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: hyt271 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/hyt271/test.esp32-c3-ard.yaml b/tests/components/hyt271/test.esp32-c3-ard.yaml index c44f0a1f5d..ee2c29ca4e 100644 --- a/tests/components/hyt271/test.esp32-c3-ard.yaml +++ b/tests/components/hyt271/test.esp32-c3-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_hyt271 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hyt271 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/hyt271/test.esp32-c3-idf.yaml b/tests/components/hyt271/test.esp32-c3-idf.yaml index c44f0a1f5d..ee2c29ca4e 100644 --- a/tests/components/hyt271/test.esp32-c3-idf.yaml +++ b/tests/components/hyt271/test.esp32-c3-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_hyt271 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hyt271 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/hyt271/test.esp32-idf.yaml b/tests/components/hyt271/test.esp32-idf.yaml index 297611a89b..63c3bd6afd 100644 --- a/tests/components/hyt271/test.esp32-idf.yaml +++ b/tests/components/hyt271/test.esp32-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_hyt271 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: hyt271 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/hyt271/test.esp8266-ard.yaml b/tests/components/hyt271/test.esp8266-ard.yaml index c44f0a1f5d..ee2c29ca4e 100644 --- a/tests/components/hyt271/test.esp8266-ard.yaml +++ b/tests/components/hyt271/test.esp8266-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_hyt271 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hyt271 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/hyt271/test.rp2040-ard.yaml b/tests/components/hyt271/test.rp2040-ard.yaml index c44f0a1f5d..ee2c29ca4e 100644 --- a/tests/components/hyt271/test.rp2040-ard.yaml +++ b/tests/components/hyt271/test.rp2040-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_hyt271 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: hyt271 - temperature: - name: Temperature - humidity: - name: Humidity +<<: !include common.yaml From 4273449003d8387c4c26d14d54983f432b540a14 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:05:53 -0600 Subject: [PATCH 152/194] [CI] Consolidate some tests (K, L) (#8201) --- tests/components/key_collector/common.yaml | 28 +++ .../key_collector/test.esp32-ard.yaml | 33 +--- .../key_collector/test.esp32-c3-ard.yaml | 33 +--- .../key_collector/test.esp32-c3-idf.yaml | 33 +--- .../key_collector/test.esp32-idf.yaml | 33 +--- .../key_collector/test.esp8266-ard.yaml | 33 +--- .../key_collector/test.rp2040-ard.yaml | 33 +--- tests/components/kmeteriso/common.yaml | 12 ++ .../components/kmeteriso/test.esp32-ard.yaml | 15 +- .../kmeteriso/test.esp32-c3-ard.yaml | 15 +- .../kmeteriso/test.esp32-c3-idf.yaml | 15 +- .../components/kmeteriso/test.esp32-idf.yaml | 15 +- .../kmeteriso/test.esp8266-ard.yaml | 15 +- .../components/kmeteriso/test.rp2040-ard.yaml | 15 +- tests/components/kuntze/common.yaml | 15 ++ tests/components/kuntze/test.esp32-ard.yaml | 19 +- .../components/kuntze/test.esp32-c3-ard.yaml | 19 +- .../components/kuntze/test.esp32-c3-idf.yaml | 19 +- tests/components/kuntze/test.esp32-idf.yaml | 19 +- tests/components/kuntze/test.esp8266-ard.yaml | 19 +- tests/components/kuntze/test.rp2040-ard.yaml | 19 +- tests/components/lcd_gpio/common.yaml | 13 ++ tests/components/lcd_gpio/test.esp32-ard.yaml | 22 +-- .../lcd_gpio/test.esp32-c3-ard.yaml | 22 +-- .../lcd_gpio/test.esp32-c3-idf.yaml | 22 +-- tests/components/lcd_gpio/test.esp32-idf.yaml | 22 +-- .../components/lcd_gpio/test.esp8266-ard.yaml | 22 +-- .../components/lcd_gpio/test.rp2040-ard.yaml | 22 +-- tests/components/lcd_menu/common.yaml | 118 ++++++++++++ tests/components/lcd_menu/test.esp32-ard.yaml | 125 +------------ .../lcd_menu/test.esp32-c3-ard.yaml | 125 +------------ .../lcd_menu/test.esp32-c3-idf.yaml | 125 +------------ tests/components/lcd_menu/test.esp32-idf.yaml | 125 +------------ .../components/lcd_menu/test.esp8266-ard.yaml | 125 +------------ .../components/lcd_menu/test.rp2040-ard.yaml | 125 +------------ tests/components/lcd_pcf8574/common.yaml | 22 +++ .../lcd_pcf8574/test.esp32-ard.yaml | 25 +-- .../lcd_pcf8574/test.esp32-c3-ard.yaml | 25 +-- .../lcd_pcf8574/test.esp32-c3-idf.yaml | 25 +-- .../lcd_pcf8574/test.esp32-idf.yaml | 25 +-- .../lcd_pcf8574/test.esp8266-ard.yaml | 25 +-- .../lcd_pcf8574/test.rp2040-ard.yaml | 25 +-- tests/components/ld2410/common.yaml | 169 +++++++++++++++++ tests/components/ld2410/test.esp32-ard.yaml | 172 +----------------- .../components/ld2410/test.esp32-c3-ard.yaml | 172 +----------------- .../components/ld2410/test.esp32-c3-idf.yaml | 172 +----------------- tests/components/ld2410/test.esp32-idf.yaml | 172 +----------------- tests/components/ld2410/test.esp8266-ard.yaml | 172 +----------------- tests/components/ld2410/test.rp2040-ard.yaml | 172 +----------------- tests/components/ld2420/common.yaml | 132 ++++++++++++++ tests/components/ld2420/test.esp32-ard.yaml | 135 +------------- .../components/ld2420/test.esp32-c3-ard.yaml | 135 +------------- .../components/ld2420/test.esp32-c3-idf.yaml | 135 +------------- tests/components/ld2420/test.esp32-idf.yaml | 135 +------------- tests/components/ld2420/test.esp8266-ard.yaml | 135 +------------- tests/components/ld2420/test.rp2040-ard.yaml | 135 +------------- tests/components/lilygo_t5_47/common.yaml | 24 +++ .../lilygo_t5_47/test.esp32-ard.yaml | 29 +-- .../lilygo_t5_47/test.esp32-c3-ard.yaml | 29 +-- .../lilygo_t5_47/test.esp32-c3-idf.yaml | 29 +-- .../lilygo_t5_47/test.esp32-idf.yaml | 29 +-- .../lilygo_t5_47/test.esp8266-ard.yaml | 29 +-- .../lilygo_t5_47/test.rp2040-ard.yaml | 29 +-- tests/components/ltr390/common.yaml | 38 ++++ tests/components/ltr390/test.esp32-ard.yaml | 41 +---- .../components/ltr390/test.esp32-c3-ard.yaml | 23 +-- .../components/ltr390/test.esp32-c3-idf.yaml | 23 +-- tests/components/ltr390/test.esp32-idf.yaml | 23 +-- tests/components/ltr390/test.esp8266-ard.yaml | 25 +-- tests/components/ltr390/test.rp2040-ard.yaml | 23 +-- 70 files changed, 895 insertions(+), 3284 deletions(-) create mode 100644 tests/components/key_collector/common.yaml create mode 100644 tests/components/kmeteriso/common.yaml create mode 100644 tests/components/kuntze/common.yaml create mode 100644 tests/components/lcd_gpio/common.yaml create mode 100644 tests/components/lcd_menu/common.yaml create mode 100644 tests/components/lcd_pcf8574/common.yaml create mode 100644 tests/components/ld2410/common.yaml create mode 100644 tests/components/ld2420/common.yaml create mode 100644 tests/components/lilygo_t5_47/common.yaml create mode 100644 tests/components/ltr390/common.yaml diff --git a/tests/components/key_collector/common.yaml b/tests/components/key_collector/common.yaml new file mode 100644 index 0000000000..d58922ca91 --- /dev/null +++ b/tests/components/key_collector/common.yaml @@ -0,0 +1,28 @@ +matrix_keypad: + id: keypad + rows: + - pin: ${pin_r0} + - pin: ${pin_r1} + columns: + - pin: ${pin_c0} + - pin: ${pin_c1} + keys: "1234" + has_pulldowns: true + +key_collector: + - id: reader + source_id: keypad + min_length: 4 + max_length: 4 + on_progress: + - logger.log: + format: "input progress: '%s', started by '%c'" + args: ['x.c_str()', "(start == 0 ? '~' : start)"] + on_result: + - logger.log: + format: "input result: '%s', started by '%c', ended by '%c'" + args: ['x.c_str()', "(start == 0 ? '~' : start)", "(end == 0 ? '~' : end)"] + on_timeout: + - logger.log: + format: "input timeout: '%s', started by '%c'" + args: ['x.c_str()', "(start == 0 ? '~' : start)"] diff --git a/tests/components/key_collector/test.esp32-ard.yaml b/tests/components/key_collector/test.esp32-ard.yaml index 7cbe9c0fc1..de144aa46b 100644 --- a/tests/components/key_collector/test.esp32-ard.yaml +++ b/tests/components/key_collector/test.esp32-ard.yaml @@ -1,28 +1,7 @@ -matrix_keypad: - id: keypad - rows: - - pin: 12 - - pin: 13 - columns: - - pin: 14 - - pin: 15 - keys: "1234" - has_pulldowns: true +substitutions: + pin_r0: GPIO12 + pin_r1: GPIO13 + pin_c0: GPIO14 + pin_c1: GPIO15 -key_collector: - - id: reader - source_id: keypad - min_length: 4 - max_length: 4 - on_progress: - - logger.log: - format: "input progress: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] - on_result: - - logger.log: - format: "input result: '%s', started by '%c', ended by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)", "(end == 0 ? '~' : end)"] - on_timeout: - - logger.log: - format: "input timeout: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] +<<: !include common.yaml diff --git a/tests/components/key_collector/test.esp32-c3-ard.yaml b/tests/components/key_collector/test.esp32-c3-ard.yaml index 1f133c5cd8..b580ab7843 100644 --- a/tests/components/key_collector/test.esp32-c3-ard.yaml +++ b/tests/components/key_collector/test.esp32-c3-ard.yaml @@ -1,28 +1,7 @@ -matrix_keypad: - id: keypad - rows: - - pin: 1 - - pin: 2 - columns: - - pin: 3 - - pin: 4 - keys: "1234" - has_pulldowns: true +substitutions: + pin_r0: GPIO2 + pin_r1: GPIO3 + pin_c0: GPIO4 + pin_c1: GPIO5 -key_collector: - - id: reader - source_id: keypad - min_length: 4 - max_length: 4 - on_progress: - - logger.log: - format: "input progress: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] - on_result: - - logger.log: - format: "input result: '%s', started by '%c', ended by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)", "(end == 0 ? '~' : end)"] - on_timeout: - - logger.log: - format: "input timeout: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] +<<: !include common.yaml diff --git a/tests/components/key_collector/test.esp32-c3-idf.yaml b/tests/components/key_collector/test.esp32-c3-idf.yaml index 1f133c5cd8..b580ab7843 100644 --- a/tests/components/key_collector/test.esp32-c3-idf.yaml +++ b/tests/components/key_collector/test.esp32-c3-idf.yaml @@ -1,28 +1,7 @@ -matrix_keypad: - id: keypad - rows: - - pin: 1 - - pin: 2 - columns: - - pin: 3 - - pin: 4 - keys: "1234" - has_pulldowns: true +substitutions: + pin_r0: GPIO2 + pin_r1: GPIO3 + pin_c0: GPIO4 + pin_c1: GPIO5 -key_collector: - - id: reader - source_id: keypad - min_length: 4 - max_length: 4 - on_progress: - - logger.log: - format: "input progress: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] - on_result: - - logger.log: - format: "input result: '%s', started by '%c', ended by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)", "(end == 0 ? '~' : end)"] - on_timeout: - - logger.log: - format: "input timeout: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] +<<: !include common.yaml diff --git a/tests/components/key_collector/test.esp32-idf.yaml b/tests/components/key_collector/test.esp32-idf.yaml index 7cbe9c0fc1..de144aa46b 100644 --- a/tests/components/key_collector/test.esp32-idf.yaml +++ b/tests/components/key_collector/test.esp32-idf.yaml @@ -1,28 +1,7 @@ -matrix_keypad: - id: keypad - rows: - - pin: 12 - - pin: 13 - columns: - - pin: 14 - - pin: 15 - keys: "1234" - has_pulldowns: true +substitutions: + pin_r0: GPIO12 + pin_r1: GPIO13 + pin_c0: GPIO14 + pin_c1: GPIO15 -key_collector: - - id: reader - source_id: keypad - min_length: 4 - max_length: 4 - on_progress: - - logger.log: - format: "input progress: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] - on_result: - - logger.log: - format: "input result: '%s', started by '%c', ended by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)", "(end == 0 ? '~' : end)"] - on_timeout: - - logger.log: - format: "input timeout: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] +<<: !include common.yaml diff --git a/tests/components/key_collector/test.esp8266-ard.yaml b/tests/components/key_collector/test.esp8266-ard.yaml index 7cbe9c0fc1..de144aa46b 100644 --- a/tests/components/key_collector/test.esp8266-ard.yaml +++ b/tests/components/key_collector/test.esp8266-ard.yaml @@ -1,28 +1,7 @@ -matrix_keypad: - id: keypad - rows: - - pin: 12 - - pin: 13 - columns: - - pin: 14 - - pin: 15 - keys: "1234" - has_pulldowns: true +substitutions: + pin_r0: GPIO12 + pin_r1: GPIO13 + pin_c0: GPIO14 + pin_c1: GPIO15 -key_collector: - - id: reader - source_id: keypad - min_length: 4 - max_length: 4 - on_progress: - - logger.log: - format: "input progress: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] - on_result: - - logger.log: - format: "input result: '%s', started by '%c', ended by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)", "(end == 0 ? '~' : end)"] - on_timeout: - - logger.log: - format: "input timeout: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] +<<: !include common.yaml diff --git a/tests/components/key_collector/test.rp2040-ard.yaml b/tests/components/key_collector/test.rp2040-ard.yaml index 1f133c5cd8..b580ab7843 100644 --- a/tests/components/key_collector/test.rp2040-ard.yaml +++ b/tests/components/key_collector/test.rp2040-ard.yaml @@ -1,28 +1,7 @@ -matrix_keypad: - id: keypad - rows: - - pin: 1 - - pin: 2 - columns: - - pin: 3 - - pin: 4 - keys: "1234" - has_pulldowns: true +substitutions: + pin_r0: GPIO2 + pin_r1: GPIO3 + pin_c0: GPIO4 + pin_c1: GPIO5 -key_collector: - - id: reader - source_id: keypad - min_length: 4 - max_length: 4 - on_progress: - - logger.log: - format: "input progress: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] - on_result: - - logger.log: - format: "input result: '%s', started by '%c', ended by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)", "(end == 0 ? '~' : end)"] - on_timeout: - - logger.log: - format: "input timeout: '%s', started by '%c'" - args: ['x.c_str()', "(start == 0 ? '~' : start)"] +<<: !include common.yaml diff --git a/tests/components/kmeteriso/common.yaml b/tests/components/kmeteriso/common.yaml new file mode 100644 index 0000000000..6b68175904 --- /dev/null +++ b/tests/components/kmeteriso/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_kmeteriso + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: kmeteriso + temperature: + name: Outside Temperature + internal_temperature: + name: Internal Temperature + update_interval: 15s diff --git a/tests/components/kmeteriso/test.esp32-ard.yaml b/tests/components/kmeteriso/test.esp32-ard.yaml index 2c375dda31..63c3bd6afd 100644 --- a/tests/components/kmeteriso/test.esp32-ard.yaml +++ b/tests/components/kmeteriso/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_kmeteriso - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: kmeteriso - temperature: - name: Outside Temperature - internal_temperature: - name: Internal Temperature - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/kmeteriso/test.esp32-c3-ard.yaml b/tests/components/kmeteriso/test.esp32-c3-ard.yaml index 7780cfea32..ee2c29ca4e 100644 --- a/tests/components/kmeteriso/test.esp32-c3-ard.yaml +++ b/tests/components/kmeteriso/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_kmeteriso - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: kmeteriso - temperature: - name: Outside Temperature - internal_temperature: - name: Internal Temperature - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/kmeteriso/test.esp32-c3-idf.yaml b/tests/components/kmeteriso/test.esp32-c3-idf.yaml index 7780cfea32..ee2c29ca4e 100644 --- a/tests/components/kmeteriso/test.esp32-c3-idf.yaml +++ b/tests/components/kmeteriso/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_kmeteriso - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: kmeteriso - temperature: - name: Outside Temperature - internal_temperature: - name: Internal Temperature - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/kmeteriso/test.esp32-idf.yaml b/tests/components/kmeteriso/test.esp32-idf.yaml index 2c375dda31..63c3bd6afd 100644 --- a/tests/components/kmeteriso/test.esp32-idf.yaml +++ b/tests/components/kmeteriso/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_kmeteriso - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: kmeteriso - temperature: - name: Outside Temperature - internal_temperature: - name: Internal Temperature - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/kmeteriso/test.esp8266-ard.yaml b/tests/components/kmeteriso/test.esp8266-ard.yaml index 7780cfea32..ee2c29ca4e 100644 --- a/tests/components/kmeteriso/test.esp8266-ard.yaml +++ b/tests/components/kmeteriso/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_kmeteriso - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: kmeteriso - temperature: - name: Outside Temperature - internal_temperature: - name: Internal Temperature - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/kmeteriso/test.rp2040-ard.yaml b/tests/components/kmeteriso/test.rp2040-ard.yaml index 7780cfea32..ee2c29ca4e 100644 --- a/tests/components/kmeteriso/test.rp2040-ard.yaml +++ b/tests/components/kmeteriso/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_kmeteriso - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: kmeteriso - temperature: - name: Outside Temperature - internal_temperature: - name: Internal Temperature - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/kuntze/common.yaml b/tests/components/kuntze/common.yaml new file mode 100644 index 0000000000..4daecea242 --- /dev/null +++ b/tests/components/kuntze/common.yaml @@ -0,0 +1,15 @@ +uart: + - id: uart_kuntze + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +modbus: + flow_control_pin: ${flow_control_pin} + +sensor: + - platform: kuntze + ph: + name: Kuntze pH + temperature: + name: Kuntze temperature diff --git a/tests/components/kuntze/test.esp32-ard.yaml b/tests/components/kuntze/test.esp32-ard.yaml index 6b6c638971..bd767a8ece 100644 --- a/tests/components/kuntze/test.esp32-ard.yaml +++ b/tests/components/kuntze/test.esp32-ard.yaml @@ -1,15 +1,6 @@ -uart: - - id: uart_kuntze - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + flow_control_pin: GPIO13 -modbus: - flow_control_pin: 13 - -sensor: - - platform: kuntze - ph: - name: Kuntze pH - temperature: - name: Kuntze temperature +<<: !include common.yaml diff --git a/tests/components/kuntze/test.esp32-c3-ard.yaml b/tests/components/kuntze/test.esp32-c3-ard.yaml index 08278c3c82..452031a5aa 100644 --- a/tests/components/kuntze/test.esp32-c3-ard.yaml +++ b/tests/components/kuntze/test.esp32-c3-ard.yaml @@ -1,15 +1,6 @@ -uart: - - id: uart_kuntze - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - flow_control_pin: 3 - -sensor: - - platform: kuntze - ph: - name: Kuntze pH - temperature: - name: Kuntze temperature +<<: !include common.yaml diff --git a/tests/components/kuntze/test.esp32-c3-idf.yaml b/tests/components/kuntze/test.esp32-c3-idf.yaml index 08278c3c82..452031a5aa 100644 --- a/tests/components/kuntze/test.esp32-c3-idf.yaml +++ b/tests/components/kuntze/test.esp32-c3-idf.yaml @@ -1,15 +1,6 @@ -uart: - - id: uart_kuntze - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - flow_control_pin: 3 - -sensor: - - platform: kuntze - ph: - name: Kuntze pH - temperature: - name: Kuntze temperature +<<: !include common.yaml diff --git a/tests/components/kuntze/test.esp32-idf.yaml b/tests/components/kuntze/test.esp32-idf.yaml index 6b6c638971..bd767a8ece 100644 --- a/tests/components/kuntze/test.esp32-idf.yaml +++ b/tests/components/kuntze/test.esp32-idf.yaml @@ -1,15 +1,6 @@ -uart: - - id: uart_kuntze - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + flow_control_pin: GPIO13 -modbus: - flow_control_pin: 13 - -sensor: - - platform: kuntze - ph: - name: Kuntze pH - temperature: - name: Kuntze temperature +<<: !include common.yaml diff --git a/tests/components/kuntze/test.esp8266-ard.yaml b/tests/components/kuntze/test.esp8266-ard.yaml index eba6cddc2d..29c98d0957 100644 --- a/tests/components/kuntze/test.esp8266-ard.yaml +++ b/tests/components/kuntze/test.esp8266-ard.yaml @@ -1,15 +1,6 @@ -uart: - - id: uart_kuntze - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO13 -modbus: - flow_control_pin: 13 - -sensor: - - platform: kuntze - ph: - name: Kuntze pH - temperature: - name: Kuntze temperature +<<: !include common.yaml diff --git a/tests/components/kuntze/test.rp2040-ard.yaml b/tests/components/kuntze/test.rp2040-ard.yaml index 08278c3c82..452031a5aa 100644 --- a/tests/components/kuntze/test.rp2040-ard.yaml +++ b/tests/components/kuntze/test.rp2040-ard.yaml @@ -1,15 +1,6 @@ -uart: - - id: uart_kuntze - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - flow_control_pin: 3 - -sensor: - - platform: kuntze - ph: - name: Kuntze pH - temperature: - name: Kuntze temperature +<<: !include common.yaml diff --git a/tests/components/lcd_gpio/common.yaml b/tests/components/lcd_gpio/common.yaml new file mode 100644 index 0000000000..bd842454a1 --- /dev/null +++ b/tests/components/lcd_gpio/common.yaml @@ -0,0 +1,13 @@ +display: + - platform: lcd_gpio + id: my_lcd_gpio + dimensions: 18x4 + data_pins: + - number: ${d0_pin} + - number: ${d1_pin} + - number: ${d2_pin} + - number: ${d3_pin} + enable_pin: ${enable_pin} + rs_pin: ${rs_pin} + lambda: |- + it.print("Hello World!"); diff --git a/tests/components/lcd_gpio/test.esp32-ard.yaml b/tests/components/lcd_gpio/test.esp32-ard.yaml index d2b33aeb3a..9c2af456b5 100644 --- a/tests/components/lcd_gpio/test.esp32-ard.yaml +++ b/tests/components/lcd_gpio/test.esp32-ard.yaml @@ -1,13 +1,9 @@ -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 12 - - number: 13 - - number: 14 - - number: 15 - enable_pin: 16 - rs_pin: 5 - lambda: |- - it.print("Hello World!"); +substitutions: + d0_pin: GPIO12 + d1_pin: GPIO13 + d2_pin: GPIO14 + d3_pin: GPIO15 + enable_pin: GPIO16 + rs_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/lcd_gpio/test.esp32-c3-ard.yaml b/tests/components/lcd_gpio/test.esp32-c3-ard.yaml index b89715a755..b6b05f3ab4 100644 --- a/tests/components/lcd_gpio/test.esp32-c3-ard.yaml +++ b/tests/components/lcd_gpio/test.esp32-c3-ard.yaml @@ -1,13 +1,9 @@ -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 1 - - number: 2 - - number: 3 - - number: 4 - enable_pin: 5 - rs_pin: 6 - lambda: |- - it.print("Hello World!"); +substitutions: + d0_pin: GPIO1 + d1_pin: GPIO2 + d2_pin: GPIO3 + d3_pin: GPIO4 + enable_pin: GPIO5 + rs_pin: GPIO6 + +<<: !include common.yaml diff --git a/tests/components/lcd_gpio/test.esp32-c3-idf.yaml b/tests/components/lcd_gpio/test.esp32-c3-idf.yaml index b89715a755..b6b05f3ab4 100644 --- a/tests/components/lcd_gpio/test.esp32-c3-idf.yaml +++ b/tests/components/lcd_gpio/test.esp32-c3-idf.yaml @@ -1,13 +1,9 @@ -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 1 - - number: 2 - - number: 3 - - number: 4 - enable_pin: 5 - rs_pin: 6 - lambda: |- - it.print("Hello World!"); +substitutions: + d0_pin: GPIO1 + d1_pin: GPIO2 + d2_pin: GPIO3 + d3_pin: GPIO4 + enable_pin: GPIO5 + rs_pin: GPIO6 + +<<: !include common.yaml diff --git a/tests/components/lcd_gpio/test.esp32-idf.yaml b/tests/components/lcd_gpio/test.esp32-idf.yaml index d2b33aeb3a..9c2af456b5 100644 --- a/tests/components/lcd_gpio/test.esp32-idf.yaml +++ b/tests/components/lcd_gpio/test.esp32-idf.yaml @@ -1,13 +1,9 @@ -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 12 - - number: 13 - - number: 14 - - number: 15 - enable_pin: 16 - rs_pin: 5 - lambda: |- - it.print("Hello World!"); +substitutions: + d0_pin: GPIO12 + d1_pin: GPIO13 + d2_pin: GPIO14 + d3_pin: GPIO15 + enable_pin: GPIO16 + rs_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/lcd_gpio/test.esp8266-ard.yaml b/tests/components/lcd_gpio/test.esp8266-ard.yaml index d2b33aeb3a..9c2af456b5 100644 --- a/tests/components/lcd_gpio/test.esp8266-ard.yaml +++ b/tests/components/lcd_gpio/test.esp8266-ard.yaml @@ -1,13 +1,9 @@ -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 12 - - number: 13 - - number: 14 - - number: 15 - enable_pin: 16 - rs_pin: 5 - lambda: |- - it.print("Hello World!"); +substitutions: + d0_pin: GPIO12 + d1_pin: GPIO13 + d2_pin: GPIO14 + d3_pin: GPIO15 + enable_pin: GPIO16 + rs_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/lcd_gpio/test.rp2040-ard.yaml b/tests/components/lcd_gpio/test.rp2040-ard.yaml index b89715a755..b6b05f3ab4 100644 --- a/tests/components/lcd_gpio/test.rp2040-ard.yaml +++ b/tests/components/lcd_gpio/test.rp2040-ard.yaml @@ -1,13 +1,9 @@ -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 1 - - number: 2 - - number: 3 - - number: 4 - enable_pin: 5 - rs_pin: 6 - lambda: |- - it.print("Hello World!"); +substitutions: + d0_pin: GPIO1 + d1_pin: GPIO2 + d2_pin: GPIO3 + d3_pin: GPIO4 + enable_pin: GPIO5 + rs_pin: GPIO6 + +<<: !include common.yaml diff --git a/tests/components/lcd_menu/common.yaml b/tests/components/lcd_menu/common.yaml new file mode 100644 index 0000000000..970c18e0d2 --- /dev/null +++ b/tests/components/lcd_menu/common.yaml @@ -0,0 +1,118 @@ +number: + - platform: template + id: test_number + min_value: 0 + step: 1 + max_value: 10 + optimistic: true + +select: + - platform: template + id: test_select + options: + - one + - two + optimistic: true + +switch: + - platform: template + name: Template Switch + id: my_switch + optimistic: true + +display: + - platform: lcd_gpio + id: my_lcd_gpio + dimensions: 18x4 + data_pins: + - number: ${d0_pin} + - number: ${d1_pin} + - number: ${d2_pin} + - number: ${d3_pin} + enable_pin: ${enable_pin} + rs_pin: ${rs_pin} + lambda: |- + it.print("Hello World!"); + +lcd_menu: + id: test_lcd_menu + display_id: my_lcd_gpio + mark_back: 0x5e + mark_selected: 0x3e + mark_editing: 0x2a + mark_submenu: 0x7e + active: false + mode: rotary + on_enter: + then: + lambda: 'ESP_LOGI("lcd_menu", "root enter");' + on_leave: + then: + lambda: 'ESP_LOGI("lcd_menu", "root leave");' + items: + - type: back + text: Back + - type: label + - type: menu + text: Submenu 1 + items: + - type: back + text: Back + - type: menu + text: Submenu 21 + items: + - type: back + text: Back + - type: command + text: Show Main + on_value: + then: + - display_menu.show_main: test_lcd_menu + - type: select + text: Enum Item + immediate_edit: true + select: test_select + on_enter: + then: + lambda: 'ESP_LOGI("lcd_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + on_leave: + then: + lambda: 'ESP_LOGI("lcd_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + on_value: + then: + lambda: 'ESP_LOGI("lcd_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + - type: number + text: Number + number: test_number + on_enter: + then: + lambda: 'ESP_LOGI("lcd_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + on_leave: + then: + lambda: 'ESP_LOGI("lcd_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + on_value: + then: + lambda: 'ESP_LOGI("lcd_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' + - type: command + text: Hide + on_value: + then: + - display_menu.hide: test_lcd_menu + - type: switch + text: Switch + switch: my_switch + on_text: Bright + off_text: Dark + immediate_edit: false + on_value: + then: + lambda: 'ESP_LOGI("lcd_menu", "switch value: %s", it->get_value_text().c_str());' + - type: custom + text: !lambda 'return "Custom";' + value_lambda: 'return "Val";' + on_next: + then: + lambda: 'ESP_LOGI("lcd_menu", "custom next: %s", it->get_text().c_str());' + on_prev: + then: + lambda: 'ESP_LOGI("lcd_menu", "custom prev: %s", it->get_text().c_str());' diff --git a/tests/components/lcd_menu/test.esp32-ard.yaml b/tests/components/lcd_menu/test.esp32-ard.yaml index 833ea2169a..9c2af456b5 100644 --- a/tests/components/lcd_menu/test.esp32-ard.yaml +++ b/tests/components/lcd_menu/test.esp32-ard.yaml @@ -1,118 +1,9 @@ -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true +substitutions: + d0_pin: GPIO12 + d1_pin: GPIO13 + d2_pin: GPIO14 + d3_pin: GPIO15 + enable_pin: GPIO16 + rs_pin: GPIO5 -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - name: Template Switch - id: my_switch - optimistic: true - -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 12 - - number: 13 - - number: 14 - - number: 15 - enable_pin: 16 - rs_pin: 5 - lambda: |- - it.print("Hello World!"); - -lcd_menu: - id: test_lcd_menu - display_id: my_lcd_gpio - mark_back: 0x5e - mark_selected: 0x3e - mark_editing: 0x2a - mark_submenu: 0x7e - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "root leave");' - items: - - type: back - text: Back - - type: label - - type: menu - text: Submenu 1 - items: - - type: back - text: Back - - type: menu - text: Submenu 21 - items: - - type: back - text: Back - - type: command - text: Show Main - on_value: - then: - - display_menu.show_main: test_lcd_menu - - type: select - text: Enum Item - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: Number - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: Hide - on_value: - then: - - display_menu.hide: test_lcd_menu - - type: switch - text: Switch - switch: my_switch - on_text: Bright - off_text: Dark - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/lcd_menu/test.esp32-c3-ard.yaml b/tests/components/lcd_menu/test.esp32-c3-ard.yaml index 39d2278d3d..b6b05f3ab4 100644 --- a/tests/components/lcd_menu/test.esp32-c3-ard.yaml +++ b/tests/components/lcd_menu/test.esp32-c3-ard.yaml @@ -1,118 +1,9 @@ -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true +substitutions: + d0_pin: GPIO1 + d1_pin: GPIO2 + d2_pin: GPIO3 + d3_pin: GPIO4 + enable_pin: GPIO5 + rs_pin: GPIO6 -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - name: Template Switch - id: my_switch - optimistic: true - -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 1 - - number: 2 - - number: 3 - - number: 4 - enable_pin: 5 - rs_pin: 6 - lambda: |- - it.print("Hello World!"); - -lcd_menu: - id: test_lcd_menu - display_id: my_lcd_gpio - mark_back: 0x5e - mark_selected: 0x3e - mark_editing: 0x2a - mark_submenu: 0x7e - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "root leave");' - items: - - type: back - text: Back - - type: label - - type: menu - text: Submenu 1 - items: - - type: back - text: Back - - type: menu - text: Submenu 21 - items: - - type: back - text: Back - - type: command - text: Show Main - on_value: - then: - - display_menu.show_main: test_lcd_menu - - type: select - text: Enum Item - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: Number - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: Hide - on_value: - then: - - display_menu.hide: test_lcd_menu - - type: switch - text: Switch - switch: my_switch - on_text: Bright - off_text: Dark - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/lcd_menu/test.esp32-c3-idf.yaml b/tests/components/lcd_menu/test.esp32-c3-idf.yaml index 39d2278d3d..b6b05f3ab4 100644 --- a/tests/components/lcd_menu/test.esp32-c3-idf.yaml +++ b/tests/components/lcd_menu/test.esp32-c3-idf.yaml @@ -1,118 +1,9 @@ -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true +substitutions: + d0_pin: GPIO1 + d1_pin: GPIO2 + d2_pin: GPIO3 + d3_pin: GPIO4 + enable_pin: GPIO5 + rs_pin: GPIO6 -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - name: Template Switch - id: my_switch - optimistic: true - -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 1 - - number: 2 - - number: 3 - - number: 4 - enable_pin: 5 - rs_pin: 6 - lambda: |- - it.print("Hello World!"); - -lcd_menu: - id: test_lcd_menu - display_id: my_lcd_gpio - mark_back: 0x5e - mark_selected: 0x3e - mark_editing: 0x2a - mark_submenu: 0x7e - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "root leave");' - items: - - type: back - text: Back - - type: label - - type: menu - text: Submenu 1 - items: - - type: back - text: Back - - type: menu - text: Submenu 21 - items: - - type: back - text: Back - - type: command - text: Show Main - on_value: - then: - - display_menu.show_main: test_lcd_menu - - type: select - text: Enum Item - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: Number - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: Hide - on_value: - then: - - display_menu.hide: test_lcd_menu - - type: switch - text: Switch - switch: my_switch - on_text: Bright - off_text: Dark - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/lcd_menu/test.esp32-idf.yaml b/tests/components/lcd_menu/test.esp32-idf.yaml index 833ea2169a..9c2af456b5 100644 --- a/tests/components/lcd_menu/test.esp32-idf.yaml +++ b/tests/components/lcd_menu/test.esp32-idf.yaml @@ -1,118 +1,9 @@ -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true +substitutions: + d0_pin: GPIO12 + d1_pin: GPIO13 + d2_pin: GPIO14 + d3_pin: GPIO15 + enable_pin: GPIO16 + rs_pin: GPIO5 -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - name: Template Switch - id: my_switch - optimistic: true - -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 12 - - number: 13 - - number: 14 - - number: 15 - enable_pin: 16 - rs_pin: 5 - lambda: |- - it.print("Hello World!"); - -lcd_menu: - id: test_lcd_menu - display_id: my_lcd_gpio - mark_back: 0x5e - mark_selected: 0x3e - mark_editing: 0x2a - mark_submenu: 0x7e - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "root leave");' - items: - - type: back - text: Back - - type: label - - type: menu - text: Submenu 1 - items: - - type: back - text: Back - - type: menu - text: Submenu 21 - items: - - type: back - text: Back - - type: command - text: Show Main - on_value: - then: - - display_menu.show_main: test_lcd_menu - - type: select - text: Enum Item - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: Number - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: Hide - on_value: - then: - - display_menu.hide: test_lcd_menu - - type: switch - text: Switch - switch: my_switch - on_text: Bright - off_text: Dark - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/lcd_menu/test.esp8266-ard.yaml b/tests/components/lcd_menu/test.esp8266-ard.yaml index 833ea2169a..9c2af456b5 100644 --- a/tests/components/lcd_menu/test.esp8266-ard.yaml +++ b/tests/components/lcd_menu/test.esp8266-ard.yaml @@ -1,118 +1,9 @@ -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true +substitutions: + d0_pin: GPIO12 + d1_pin: GPIO13 + d2_pin: GPIO14 + d3_pin: GPIO15 + enable_pin: GPIO16 + rs_pin: GPIO5 -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - name: Template Switch - id: my_switch - optimistic: true - -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 12 - - number: 13 - - number: 14 - - number: 15 - enable_pin: 16 - rs_pin: 5 - lambda: |- - it.print("Hello World!"); - -lcd_menu: - id: test_lcd_menu - display_id: my_lcd_gpio - mark_back: 0x5e - mark_selected: 0x3e - mark_editing: 0x2a - mark_submenu: 0x7e - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "root leave");' - items: - - type: back - text: Back - - type: label - - type: menu - text: Submenu 1 - items: - - type: back - text: Back - - type: menu - text: Submenu 21 - items: - - type: back - text: Back - - type: command - text: Show Main - on_value: - then: - - display_menu.show_main: test_lcd_menu - - type: select - text: Enum Item - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: Number - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: Hide - on_value: - then: - - display_menu.hide: test_lcd_menu - - type: switch - text: Switch - switch: my_switch - on_text: Bright - off_text: Dark - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/lcd_menu/test.rp2040-ard.yaml b/tests/components/lcd_menu/test.rp2040-ard.yaml index 39d2278d3d..b6b05f3ab4 100644 --- a/tests/components/lcd_menu/test.rp2040-ard.yaml +++ b/tests/components/lcd_menu/test.rp2040-ard.yaml @@ -1,118 +1,9 @@ -number: - - platform: template - id: test_number - min_value: 0 - step: 1 - max_value: 10 - optimistic: true +substitutions: + d0_pin: GPIO1 + d1_pin: GPIO2 + d2_pin: GPIO3 + d3_pin: GPIO4 + enable_pin: GPIO5 + rs_pin: GPIO6 -select: - - platform: template - id: test_select - options: - - one - - two - optimistic: true - -switch: - - platform: template - name: Template Switch - id: my_switch - optimistic: true - -display: - - platform: lcd_gpio - id: my_lcd_gpio - dimensions: 18x4 - data_pins: - - number: 1 - - number: 2 - - number: 3 - - number: 4 - enable_pin: 5 - rs_pin: 6 - lambda: |- - it.print("Hello World!"); - -lcd_menu: - id: test_lcd_menu - display_id: my_lcd_gpio - mark_back: 0x5e - mark_selected: 0x3e - mark_editing: 0x2a - mark_submenu: 0x7e - active: false - mode: rotary - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "root enter");' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "root leave");' - items: - - type: back - text: Back - - type: label - - type: menu - text: Submenu 1 - items: - - type: back - text: Back - - type: menu - text: Submenu 21 - items: - - type: back - text: Back - - type: command - text: Show Main - on_value: - then: - - display_menu.show_main: test_lcd_menu - - type: select - text: Enum Item - immediate_edit: true - select: test_select - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "select enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "select leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "select value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: number - text: Number - number: test_number - on_enter: - then: - lambda: 'ESP_LOGI("lcd_menu", "number enter: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_leave: - then: - lambda: 'ESP_LOGI("lcd_menu", "number leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "number value: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());' - - type: command - text: Hide - on_value: - then: - - display_menu.hide: test_lcd_menu - - type: switch - text: Switch - switch: my_switch - on_text: Bright - off_text: Dark - immediate_edit: false - on_value: - then: - lambda: 'ESP_LOGI("lcd_menu", "switch value: %s", it->get_value_text().c_str());' - - type: custom - text: !lambda 'return "Custom";' - value_lambda: 'return "Val";' - on_next: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom next: %s", it->get_text().c_str());' - on_prev: - then: - lambda: 'ESP_LOGI("lcd_menu", "custom prev: %s", it->get_text().c_str());' +<<: !include common.yaml diff --git a/tests/components/lcd_pcf8574/common.yaml b/tests/components/lcd_pcf8574/common.yaml new file mode 100644 index 0000000000..8b03cf5497 --- /dev/null +++ b/tests/components/lcd_pcf8574/common.yaml @@ -0,0 +1,22 @@ +i2c: + - id: i2c_lcd_pcf8574 + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: lcd_pcf8574 + dimensions: 18x4 + address: 0x3F + user_characters: + - position: 0 + data: + - 0b00000 + - 0b01010 + - 0b00000 + - 0b00100 + - 0b00100 + - 0b10001 + - 0b01110 + - 0b00000 + lambda: |- + it.print("Hello World!"); diff --git a/tests/components/lcd_pcf8574/test.esp32-ard.yaml b/tests/components/lcd_pcf8574/test.esp32-ard.yaml index 9d7d475f30..63c3bd6afd 100644 --- a/tests/components/lcd_pcf8574/test.esp32-ard.yaml +++ b/tests/components/lcd_pcf8574/test.esp32-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_lcd_pcf8574 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -display: - - platform: lcd_pcf8574 - dimensions: 18x4 - address: 0x3F - user_characters: - - position: 0 - data: - - 0b00000 - - 0b01010 - - 0b00000 - - 0b00100 - - 0b00100 - - 0b10001 - - 0b01110 - - 0b00000 - lambda: |- - it.print("Hello World!"); +<<: !include common.yaml diff --git a/tests/components/lcd_pcf8574/test.esp32-c3-ard.yaml b/tests/components/lcd_pcf8574/test.esp32-c3-ard.yaml index 41eba26950..ee2c29ca4e 100644 --- a/tests/components/lcd_pcf8574/test.esp32-c3-ard.yaml +++ b/tests/components/lcd_pcf8574/test.esp32-c3-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_lcd_pcf8574 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -display: - - platform: lcd_pcf8574 - dimensions: 18x4 - address: 0x3F - user_characters: - - position: 0 - data: - - 0b00000 - - 0b01010 - - 0b00000 - - 0b00100 - - 0b00100 - - 0b10001 - - 0b01110 - - 0b00000 - lambda: |- - it.print("Hello World!"); +<<: !include common.yaml diff --git a/tests/components/lcd_pcf8574/test.esp32-c3-idf.yaml b/tests/components/lcd_pcf8574/test.esp32-c3-idf.yaml index 41eba26950..ee2c29ca4e 100644 --- a/tests/components/lcd_pcf8574/test.esp32-c3-idf.yaml +++ b/tests/components/lcd_pcf8574/test.esp32-c3-idf.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_lcd_pcf8574 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -display: - - platform: lcd_pcf8574 - dimensions: 18x4 - address: 0x3F - user_characters: - - position: 0 - data: - - 0b00000 - - 0b01010 - - 0b00000 - - 0b00100 - - 0b00100 - - 0b10001 - - 0b01110 - - 0b00000 - lambda: |- - it.print("Hello World!"); +<<: !include common.yaml diff --git a/tests/components/lcd_pcf8574/test.esp32-idf.yaml b/tests/components/lcd_pcf8574/test.esp32-idf.yaml index 9d7d475f30..63c3bd6afd 100644 --- a/tests/components/lcd_pcf8574/test.esp32-idf.yaml +++ b/tests/components/lcd_pcf8574/test.esp32-idf.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_lcd_pcf8574 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -display: - - platform: lcd_pcf8574 - dimensions: 18x4 - address: 0x3F - user_characters: - - position: 0 - data: - - 0b00000 - - 0b01010 - - 0b00000 - - 0b00100 - - 0b00100 - - 0b10001 - - 0b01110 - - 0b00000 - lambda: |- - it.print("Hello World!"); +<<: !include common.yaml diff --git a/tests/components/lcd_pcf8574/test.esp8266-ard.yaml b/tests/components/lcd_pcf8574/test.esp8266-ard.yaml index 41eba26950..ee2c29ca4e 100644 --- a/tests/components/lcd_pcf8574/test.esp8266-ard.yaml +++ b/tests/components/lcd_pcf8574/test.esp8266-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_lcd_pcf8574 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -display: - - platform: lcd_pcf8574 - dimensions: 18x4 - address: 0x3F - user_characters: - - position: 0 - data: - - 0b00000 - - 0b01010 - - 0b00000 - - 0b00100 - - 0b00100 - - 0b10001 - - 0b01110 - - 0b00000 - lambda: |- - it.print("Hello World!"); +<<: !include common.yaml diff --git a/tests/components/lcd_pcf8574/test.rp2040-ard.yaml b/tests/components/lcd_pcf8574/test.rp2040-ard.yaml index 41eba26950..ee2c29ca4e 100644 --- a/tests/components/lcd_pcf8574/test.rp2040-ard.yaml +++ b/tests/components/lcd_pcf8574/test.rp2040-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_lcd_pcf8574 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -display: - - platform: lcd_pcf8574 - dimensions: 18x4 - address: 0x3F - user_characters: - - position: 0 - data: - - 0b00000 - - 0b01010 - - 0b00000 - - 0b00100 - - 0b00100 - - 0b10001 - - 0b01110 - - 0b00000 - lambda: |- - it.print("Hello World!"); +<<: !include common.yaml diff --git a/tests/components/ld2410/common.yaml b/tests/components/ld2410/common.yaml new file mode 100644 index 0000000000..e975fcf757 --- /dev/null +++ b/tests/components/ld2410/common.yaml @@ -0,0 +1,169 @@ +uart: + - id: uart_ld2410 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +ld2410: + id: my_ld2410 + +binary_sensor: + - platform: ld2410 + has_target: + name: presence + has_moving_target: + name: movement + has_still_target: + name: still + out_pin_presence_status: + name: out pin presence status + +button: + - platform: ld2410 + factory_reset: + name: factory reset + restart: + name: restart + query_params: + name: query params + +number: + - platform: ld2410 + light_threshold: + name: light threshold + timeout: + name: timeout + max_move_distance_gate: + name: max move distance gate + max_still_distance_gate: + name: max still distance gate + g0: + move_threshold: + name: g0 move threshold + still_threshold: + name: g0 still threshold + g1: + move_threshold: + name: g1 move threshold + still_threshold: + name: g1 still threshold + g2: + move_threshold: + name: g2 move threshold + still_threshold: + name: g2 still threshold + g3: + move_threshold: + name: g3 move threshold + still_threshold: + name: g3 still threshold + g4: + move_threshold: + name: g4 move threshold + still_threshold: + name: g4 still threshold + g5: + move_threshold: + name: g5 move threshold + still_threshold: + name: g5 still threshold + g6: + move_threshold: + name: g6 move threshold + still_threshold: + name: g6 still threshold + g7: + move_threshold: + name: g7 move threshold + still_threshold: + name: g7 still threshold + g8: + move_threshold: + name: g8 move threshold + still_threshold: + name: g8 still threshold + +select: + - platform: ld2410 + distance_resolution: + name: distance resolution + baud_rate: + name: baud rate + light_function: + name: light function + out_pin_level: + name: out ping level + +sensor: + - platform: ld2410 + light: + name: light + moving_distance: + name: Moving distance + still_distance: + name: Still Distance + moving_energy: + name: Move Energy + still_energy: + name: Still Energy + detection_distance: + name: Distance Detection + g0: + move_energy: + name: g0 move energy + still_energy: + name: g0 still energy + g1: + move_energy: + name: g1 move energy + still_energy: + name: g1 still energy + g2: + move_energy: + name: g2 move energy + still_energy: + name: g2 still energy + g3: + move_energy: + name: g3 move energy + still_energy: + name: g3 still energy + g4: + move_energy: + name: g4 move energy + still_energy: + name: g4 still energy + g5: + move_energy: + name: g5 move energy + still_energy: + name: g5 still energy + g6: + move_energy: + name: g6 move energy + still_energy: + name: g6 still energy + g7: + move_energy: + name: g7 move energy + still_energy: + name: g7 still energy + g8: + move_energy: + name: g8 move energy + still_energy: + name: g8 still energy + +switch: + - platform: ld2410 + engineering_mode: + name: control ld2410 engineering mode + bluetooth: + name: control ld2410 bluetooth + +text_sensor: + - platform: ld2410 + version: + name: presenece sensor version + mac_address: + name: presenece sensor mac address diff --git a/tests/components/ld2410/test.esp32-ard.yaml b/tests/components/ld2410/test.esp32-ard.yaml index 48ed179d93..f486544afa 100644 --- a/tests/components/ld2410/test.esp32-ard.yaml +++ b/tests/components/ld2410/test.esp32-ard.yaml @@ -1,169 +1,5 @@ -uart: - - id: uart_ld2410 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -ld2410: - id: my_ld2410 - -binary_sensor: - - platform: ld2410 - has_target: - name: presence - has_moving_target: - name: movement - has_still_target: - name: still - out_pin_presence_status: - name: out pin presence status - -button: - - platform: ld2410 - factory_reset: - name: factory reset - restart: - name: restart - query_params: - name: query params - -number: - - platform: ld2410 - light_threshold: - name: light threshold - timeout: - name: timeout - max_move_distance_gate: - name: max move distance gate - max_still_distance_gate: - name: max still distance gate - g0: - move_threshold: - name: g0 move threshold - still_threshold: - name: g0 still threshold - g1: - move_threshold: - name: g1 move threshold - still_threshold: - name: g1 still threshold - g2: - move_threshold: - name: g2 move threshold - still_threshold: - name: g2 still threshold - g3: - move_threshold: - name: g3 move threshold - still_threshold: - name: g3 still threshold - g4: - move_threshold: - name: g4 move threshold - still_threshold: - name: g4 still threshold - g5: - move_threshold: - name: g5 move threshold - still_threshold: - name: g5 still threshold - g6: - move_threshold: - name: g6 move threshold - still_threshold: - name: g6 still threshold - g7: - move_threshold: - name: g7 move threshold - still_threshold: - name: g7 still threshold - g8: - move_threshold: - name: g8 move threshold - still_threshold: - name: g8 still threshold - -select: - - platform: ld2410 - distance_resolution: - name: distance resolution - baud_rate: - name: baud rate - light_function: - name: light function - out_pin_level: - name: out ping level - -sensor: - - platform: ld2410 - light: - name: light - moving_distance: - name: Moving distance - still_distance: - name: Still Distance - moving_energy: - name: Move Energy - still_energy: - name: Still Energy - detection_distance: - name: Distance Detection - g0: - move_energy: - name: g0 move energy - still_energy: - name: g0 still energy - g1: - move_energy: - name: g1 move energy - still_energy: - name: g1 still energy - g2: - move_energy: - name: g2 move energy - still_energy: - name: g2 still energy - g3: - move_energy: - name: g3 move energy - still_energy: - name: g3 still energy - g4: - move_energy: - name: g4 move energy - still_energy: - name: g4 still energy - g5: - move_energy: - name: g5 move energy - still_energy: - name: g5 still energy - g6: - move_energy: - name: g6 move energy - still_energy: - name: g6 still energy - g7: - move_energy: - name: g7 move energy - still_energy: - name: g7 still energy - g8: - move_energy: - name: g8 move energy - still_energy: - name: g8 still energy - -switch: - - platform: ld2410 - engineering_mode: - name: control ld2410 engineering mode - bluetooth: - name: control ld2410 bluetooth - -text_sensor: - - platform: ld2410 - version: - name: presenece sensor version - mac_address: - name: presenece sensor mac address +<<: !include common.yaml diff --git a/tests/components/ld2410/test.esp32-c3-ard.yaml b/tests/components/ld2410/test.esp32-c3-ard.yaml index afcaa81b3e..b516342f3b 100644 --- a/tests/components/ld2410/test.esp32-c3-ard.yaml +++ b/tests/components/ld2410/test.esp32-c3-ard.yaml @@ -1,169 +1,5 @@ -uart: - - id: uart_ld2410 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -ld2410: - id: my_ld2410 - -binary_sensor: - - platform: ld2410 - has_target: - name: presence - has_moving_target: - name: movement - has_still_target: - name: still - out_pin_presence_status: - name: out pin presence status - -button: - - platform: ld2410 - factory_reset: - name: factory reset - restart: - name: restart - query_params: - name: query params - -number: - - platform: ld2410 - light_threshold: - name: light threshold - timeout: - name: timeout - max_move_distance_gate: - name: max move distance gate - max_still_distance_gate: - name: max still distance gate - g0: - move_threshold: - name: g0 move threshold - still_threshold: - name: g0 still threshold - g1: - move_threshold: - name: g1 move threshold - still_threshold: - name: g1 still threshold - g2: - move_threshold: - name: g2 move threshold - still_threshold: - name: g2 still threshold - g3: - move_threshold: - name: g3 move threshold - still_threshold: - name: g3 still threshold - g4: - move_threshold: - name: g4 move threshold - still_threshold: - name: g4 still threshold - g5: - move_threshold: - name: g5 move threshold - still_threshold: - name: g5 still threshold - g6: - move_threshold: - name: g6 move threshold - still_threshold: - name: g6 still threshold - g7: - move_threshold: - name: g7 move threshold - still_threshold: - name: g7 still threshold - g8: - move_threshold: - name: g8 move threshold - still_threshold: - name: g8 still threshold - -select: - - platform: ld2410 - distance_resolution: - name: distance resolution - baud_rate: - name: baud rate - light_function: - name: light function - out_pin_level: - name: out ping level - -sensor: - - platform: ld2410 - light: - name: light - moving_distance: - name: Moving distance - still_distance: - name: Still Distance - moving_energy: - name: Move Energy - still_energy: - name: Still Energy - detection_distance: - name: Distance Detection - g0: - move_energy: - name: g0 move energy - still_energy: - name: g0 still energy - g1: - move_energy: - name: g1 move energy - still_energy: - name: g1 still energy - g2: - move_energy: - name: g2 move energy - still_energy: - name: g2 still energy - g3: - move_energy: - name: g3 move energy - still_energy: - name: g3 still energy - g4: - move_energy: - name: g4 move energy - still_energy: - name: g4 still energy - g5: - move_energy: - name: g5 move energy - still_energy: - name: g5 still energy - g6: - move_energy: - name: g6 move energy - still_energy: - name: g6 still energy - g7: - move_energy: - name: g7 move energy - still_energy: - name: g7 still energy - g8: - move_energy: - name: g8 move energy - still_energy: - name: g8 still energy - -switch: - - platform: ld2410 - engineering_mode: - name: control ld2410 engineering mode - bluetooth: - name: control ld2410 bluetooth - -text_sensor: - - platform: ld2410 - version: - name: presenece sensor version - mac_address: - name: presenece sensor mac address +<<: !include common.yaml diff --git a/tests/components/ld2410/test.esp32-c3-idf.yaml b/tests/components/ld2410/test.esp32-c3-idf.yaml index afcaa81b3e..b516342f3b 100644 --- a/tests/components/ld2410/test.esp32-c3-idf.yaml +++ b/tests/components/ld2410/test.esp32-c3-idf.yaml @@ -1,169 +1,5 @@ -uart: - - id: uart_ld2410 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -ld2410: - id: my_ld2410 - -binary_sensor: - - platform: ld2410 - has_target: - name: presence - has_moving_target: - name: movement - has_still_target: - name: still - out_pin_presence_status: - name: out pin presence status - -button: - - platform: ld2410 - factory_reset: - name: factory reset - restart: - name: restart - query_params: - name: query params - -number: - - platform: ld2410 - light_threshold: - name: light threshold - timeout: - name: timeout - max_move_distance_gate: - name: max move distance gate - max_still_distance_gate: - name: max still distance gate - g0: - move_threshold: - name: g0 move threshold - still_threshold: - name: g0 still threshold - g1: - move_threshold: - name: g1 move threshold - still_threshold: - name: g1 still threshold - g2: - move_threshold: - name: g2 move threshold - still_threshold: - name: g2 still threshold - g3: - move_threshold: - name: g3 move threshold - still_threshold: - name: g3 still threshold - g4: - move_threshold: - name: g4 move threshold - still_threshold: - name: g4 still threshold - g5: - move_threshold: - name: g5 move threshold - still_threshold: - name: g5 still threshold - g6: - move_threshold: - name: g6 move threshold - still_threshold: - name: g6 still threshold - g7: - move_threshold: - name: g7 move threshold - still_threshold: - name: g7 still threshold - g8: - move_threshold: - name: g8 move threshold - still_threshold: - name: g8 still threshold - -select: - - platform: ld2410 - distance_resolution: - name: distance resolution - baud_rate: - name: baud rate - light_function: - name: light function - out_pin_level: - name: out ping level - -sensor: - - platform: ld2410 - light: - name: light - moving_distance: - name: Moving distance - still_distance: - name: Still Distance - moving_energy: - name: Move Energy - still_energy: - name: Still Energy - detection_distance: - name: Distance Detection - g0: - move_energy: - name: g0 move energy - still_energy: - name: g0 still energy - g1: - move_energy: - name: g1 move energy - still_energy: - name: g1 still energy - g2: - move_energy: - name: g2 move energy - still_energy: - name: g2 still energy - g3: - move_energy: - name: g3 move energy - still_energy: - name: g3 still energy - g4: - move_energy: - name: g4 move energy - still_energy: - name: g4 still energy - g5: - move_energy: - name: g5 move energy - still_energy: - name: g5 still energy - g6: - move_energy: - name: g6 move energy - still_energy: - name: g6 still energy - g7: - move_energy: - name: g7 move energy - still_energy: - name: g7 still energy - g8: - move_energy: - name: g8 move energy - still_energy: - name: g8 still energy - -switch: - - platform: ld2410 - engineering_mode: - name: control ld2410 engineering mode - bluetooth: - name: control ld2410 bluetooth - -text_sensor: - - platform: ld2410 - version: - name: presenece sensor version - mac_address: - name: presenece sensor mac address +<<: !include common.yaml diff --git a/tests/components/ld2410/test.esp32-idf.yaml b/tests/components/ld2410/test.esp32-idf.yaml index 48ed179d93..f486544afa 100644 --- a/tests/components/ld2410/test.esp32-idf.yaml +++ b/tests/components/ld2410/test.esp32-idf.yaml @@ -1,169 +1,5 @@ -uart: - - id: uart_ld2410 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -ld2410: - id: my_ld2410 - -binary_sensor: - - platform: ld2410 - has_target: - name: presence - has_moving_target: - name: movement - has_still_target: - name: still - out_pin_presence_status: - name: out pin presence status - -button: - - platform: ld2410 - factory_reset: - name: factory reset - restart: - name: restart - query_params: - name: query params - -number: - - platform: ld2410 - light_threshold: - name: light threshold - timeout: - name: timeout - max_move_distance_gate: - name: max move distance gate - max_still_distance_gate: - name: max still distance gate - g0: - move_threshold: - name: g0 move threshold - still_threshold: - name: g0 still threshold - g1: - move_threshold: - name: g1 move threshold - still_threshold: - name: g1 still threshold - g2: - move_threshold: - name: g2 move threshold - still_threshold: - name: g2 still threshold - g3: - move_threshold: - name: g3 move threshold - still_threshold: - name: g3 still threshold - g4: - move_threshold: - name: g4 move threshold - still_threshold: - name: g4 still threshold - g5: - move_threshold: - name: g5 move threshold - still_threshold: - name: g5 still threshold - g6: - move_threshold: - name: g6 move threshold - still_threshold: - name: g6 still threshold - g7: - move_threshold: - name: g7 move threshold - still_threshold: - name: g7 still threshold - g8: - move_threshold: - name: g8 move threshold - still_threshold: - name: g8 still threshold - -select: - - platform: ld2410 - distance_resolution: - name: distance resolution - baud_rate: - name: baud rate - light_function: - name: light function - out_pin_level: - name: out ping level - -sensor: - - platform: ld2410 - light: - name: light - moving_distance: - name: Moving distance - still_distance: - name: Still Distance - moving_energy: - name: Move Energy - still_energy: - name: Still Energy - detection_distance: - name: Distance Detection - g0: - move_energy: - name: g0 move energy - still_energy: - name: g0 still energy - g1: - move_energy: - name: g1 move energy - still_energy: - name: g1 still energy - g2: - move_energy: - name: g2 move energy - still_energy: - name: g2 still energy - g3: - move_energy: - name: g3 move energy - still_energy: - name: g3 still energy - g4: - move_energy: - name: g4 move energy - still_energy: - name: g4 still energy - g5: - move_energy: - name: g5 move energy - still_energy: - name: g5 still energy - g6: - move_energy: - name: g6 move energy - still_energy: - name: g6 still energy - g7: - move_energy: - name: g7 move energy - still_energy: - name: g7 still energy - g8: - move_energy: - name: g8 move energy - still_energy: - name: g8 still energy - -switch: - - platform: ld2410 - engineering_mode: - name: control ld2410 engineering mode - bluetooth: - name: control ld2410 bluetooth - -text_sensor: - - platform: ld2410 - version: - name: presenece sensor version - mac_address: - name: presenece sensor mac address +<<: !include common.yaml diff --git a/tests/components/ld2410/test.esp8266-ard.yaml b/tests/components/ld2410/test.esp8266-ard.yaml index afcaa81b3e..b516342f3b 100644 --- a/tests/components/ld2410/test.esp8266-ard.yaml +++ b/tests/components/ld2410/test.esp8266-ard.yaml @@ -1,169 +1,5 @@ -uart: - - id: uart_ld2410 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -ld2410: - id: my_ld2410 - -binary_sensor: - - platform: ld2410 - has_target: - name: presence - has_moving_target: - name: movement - has_still_target: - name: still - out_pin_presence_status: - name: out pin presence status - -button: - - platform: ld2410 - factory_reset: - name: factory reset - restart: - name: restart - query_params: - name: query params - -number: - - platform: ld2410 - light_threshold: - name: light threshold - timeout: - name: timeout - max_move_distance_gate: - name: max move distance gate - max_still_distance_gate: - name: max still distance gate - g0: - move_threshold: - name: g0 move threshold - still_threshold: - name: g0 still threshold - g1: - move_threshold: - name: g1 move threshold - still_threshold: - name: g1 still threshold - g2: - move_threshold: - name: g2 move threshold - still_threshold: - name: g2 still threshold - g3: - move_threshold: - name: g3 move threshold - still_threshold: - name: g3 still threshold - g4: - move_threshold: - name: g4 move threshold - still_threshold: - name: g4 still threshold - g5: - move_threshold: - name: g5 move threshold - still_threshold: - name: g5 still threshold - g6: - move_threshold: - name: g6 move threshold - still_threshold: - name: g6 still threshold - g7: - move_threshold: - name: g7 move threshold - still_threshold: - name: g7 still threshold - g8: - move_threshold: - name: g8 move threshold - still_threshold: - name: g8 still threshold - -select: - - platform: ld2410 - distance_resolution: - name: distance resolution - baud_rate: - name: baud rate - light_function: - name: light function - out_pin_level: - name: out ping level - -sensor: - - platform: ld2410 - light: - name: light - moving_distance: - name: Moving distance - still_distance: - name: Still Distance - moving_energy: - name: Move Energy - still_energy: - name: Still Energy - detection_distance: - name: Distance Detection - g0: - move_energy: - name: g0 move energy - still_energy: - name: g0 still energy - g1: - move_energy: - name: g1 move energy - still_energy: - name: g1 still energy - g2: - move_energy: - name: g2 move energy - still_energy: - name: g2 still energy - g3: - move_energy: - name: g3 move energy - still_energy: - name: g3 still energy - g4: - move_energy: - name: g4 move energy - still_energy: - name: g4 still energy - g5: - move_energy: - name: g5 move energy - still_energy: - name: g5 still energy - g6: - move_energy: - name: g6 move energy - still_energy: - name: g6 still energy - g7: - move_energy: - name: g7 move energy - still_energy: - name: g7 still energy - g8: - move_energy: - name: g8 move energy - still_energy: - name: g8 still energy - -switch: - - platform: ld2410 - engineering_mode: - name: control ld2410 engineering mode - bluetooth: - name: control ld2410 bluetooth - -text_sensor: - - platform: ld2410 - version: - name: presenece sensor version - mac_address: - name: presenece sensor mac address +<<: !include common.yaml diff --git a/tests/components/ld2410/test.rp2040-ard.yaml b/tests/components/ld2410/test.rp2040-ard.yaml index afcaa81b3e..b516342f3b 100644 --- a/tests/components/ld2410/test.rp2040-ard.yaml +++ b/tests/components/ld2410/test.rp2040-ard.yaml @@ -1,169 +1,5 @@ -uart: - - id: uart_ld2410 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -ld2410: - id: my_ld2410 - -binary_sensor: - - platform: ld2410 - has_target: - name: presence - has_moving_target: - name: movement - has_still_target: - name: still - out_pin_presence_status: - name: out pin presence status - -button: - - platform: ld2410 - factory_reset: - name: factory reset - restart: - name: restart - query_params: - name: query params - -number: - - platform: ld2410 - light_threshold: - name: light threshold - timeout: - name: timeout - max_move_distance_gate: - name: max move distance gate - max_still_distance_gate: - name: max still distance gate - g0: - move_threshold: - name: g0 move threshold - still_threshold: - name: g0 still threshold - g1: - move_threshold: - name: g1 move threshold - still_threshold: - name: g1 still threshold - g2: - move_threshold: - name: g2 move threshold - still_threshold: - name: g2 still threshold - g3: - move_threshold: - name: g3 move threshold - still_threshold: - name: g3 still threshold - g4: - move_threshold: - name: g4 move threshold - still_threshold: - name: g4 still threshold - g5: - move_threshold: - name: g5 move threshold - still_threshold: - name: g5 still threshold - g6: - move_threshold: - name: g6 move threshold - still_threshold: - name: g6 still threshold - g7: - move_threshold: - name: g7 move threshold - still_threshold: - name: g7 still threshold - g8: - move_threshold: - name: g8 move threshold - still_threshold: - name: g8 still threshold - -select: - - platform: ld2410 - distance_resolution: - name: distance resolution - baud_rate: - name: baud rate - light_function: - name: light function - out_pin_level: - name: out ping level - -sensor: - - platform: ld2410 - light: - name: light - moving_distance: - name: Moving distance - still_distance: - name: Still Distance - moving_energy: - name: Move Energy - still_energy: - name: Still Energy - detection_distance: - name: Distance Detection - g0: - move_energy: - name: g0 move energy - still_energy: - name: g0 still energy - g1: - move_energy: - name: g1 move energy - still_energy: - name: g1 still energy - g2: - move_energy: - name: g2 move energy - still_energy: - name: g2 still energy - g3: - move_energy: - name: g3 move energy - still_energy: - name: g3 still energy - g4: - move_energy: - name: g4 move energy - still_energy: - name: g4 still energy - g5: - move_energy: - name: g5 move energy - still_energy: - name: g5 still energy - g6: - move_energy: - name: g6 move energy - still_energy: - name: g6 still energy - g7: - move_energy: - name: g7 move energy - still_energy: - name: g7 still energy - g8: - move_energy: - name: g8 move energy - still_energy: - name: g8 still energy - -switch: - - platform: ld2410 - engineering_mode: - name: control ld2410 engineering mode - bluetooth: - name: control ld2410 bluetooth - -text_sensor: - - platform: ld2410 - version: - name: presenece sensor version - mac_address: - name: presenece sensor mac address +<<: !include common.yaml diff --git a/tests/components/ld2420/common.yaml b/tests/components/ld2420/common.yaml new file mode 100644 index 0000000000..76748aa8f0 --- /dev/null +++ b/tests/components/ld2420/common.yaml @@ -0,0 +1,132 @@ +uart: + - id: uart_ld2420 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +ld2420: + id: my_ld2420 + +binary_sensor: + - platform: ld2420 + has_target: + name: Presence + +button: + - platform: ld2420 + apply_config: + name: Apply Config + factory_reset: + name: Factory Reset + restart_module: + name: Restart Module + revert_config: + name: Undo Edits + +number: + - platform: ld2420 + presence_timeout: + name: Detection Presence Timeout + min_gate_distance: + name: Detection Gate Minimum + max_gate_distance: + name: Detection Gate Maximum + gate_move_sensitivity: + name: Move Calibration Sensitivity Factor + gate_still_sensitivity: + name: Still Calibration Sensitivity Factor + gate_0: + move_threshold: + name: Gate 0 Move Threshold + still_threshold: + name: Gate 0 Still Threshold + gate_1: + move_threshold: + name: Gate 1 Move Threshold + still_threshold: + name: Gate 1 Still Threshold + gate_2: + move_threshold: + name: Gate 2 Move Threshold + still_threshold: + name: Gate 2 Still Threshold + gate_3: + move_threshold: + name: Gate 3 Move Threshold + still_threshold: + name: Gate 3 Still Threshold + gate_4: + move_threshold: + name: Gate 4 Move Threshold + still_threshold: + name: Gate 4 Still Threshold + gate_5: + move_threshold: + name: Gate 5 Move Threshold + still_threshold: + name: Gate 5 Still Threshold + gate_6: + move_threshold: + name: Gate 6 Move Threshold + still_threshold: + name: Gate 6 Still Threshold + gate_7: + move_threshold: + name: Gate 7 Move Threshold + still_threshold: + name: Gate 7 Still Threshold + gate_8: + move_threshold: + name: Gate 8 Move Threshold + still_threshold: + name: Gate 8 Still Threshold + gate_9: + move_threshold: + name: Gate 9 Move Threshold + still_threshold: + name: Gate 9 Still Threshold + gate_10: + move_threshold: + name: Gate 10 Move Threshold + still_threshold: + name: Gate 10 Still Threshold + gate_11: + move_threshold: + name: Gate 11 Move Threshold + still_threshold: + name: Gate 11 Still Threshold + gate_12: + move_threshold: + name: Gate 12 Move Threshold + still_threshold: + name: Gate 12 Still Threshold + gate_13: + move_threshold: + name: Gate 13 Move Threshold + still_threshold: + name: Gate 13 Still Threshold + gate_14: + move_threshold: + name: Gate 14 Move Threshold + still_threshold: + name: Gate 14 Still Threshold + gate_15: + move_threshold: + name: Gate 15 Move Threshold + still_threshold: + name: Gate 15 Still Threshold + +select: + - platform: ld2420 + operating_mode: + name: Operating Mode + +sensor: + - platform: ld2420 + moving_distance: + name: "Moving distance (cm)" + +text_sensor: + - platform: ld2420 + fw_version: + name: LD2420 Firmware diff --git a/tests/components/ld2420/test.esp32-ard.yaml b/tests/components/ld2420/test.esp32-ard.yaml index 8c883664ec..f486544afa 100644 --- a/tests/components/ld2420/test.esp32-ard.yaml +++ b/tests/components/ld2420/test.esp32-ard.yaml @@ -1,132 +1,5 @@ -uart: - - id: uart_ld2420 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -ld2420: - id: my_ld2420 - -binary_sensor: - - platform: ld2420 - has_target: - name: Presence - -button: - - platform: ld2420 - apply_config: - name: Apply Config - factory_reset: - name: Factory Reset - restart_module: - name: Restart Module - revert_config: - name: Undo Edits - -number: - - platform: ld2420 - presence_timeout: - name: Detection Presence Timeout - min_gate_distance: - name: Detection Gate Minimum - max_gate_distance: - name: Detection Gate Maximum - gate_move_sensitivity: - name: Move Calibration Sensitivity Factor - gate_still_sensitivity: - name: Still Calibration Sensitivity Factor - gate_0: - move_threshold: - name: Gate 0 Move Threshold - still_threshold: - name: Gate 0 Still Threshold - gate_1: - move_threshold: - name: Gate 1 Move Threshold - still_threshold: - name: Gate 1 Still Threshold - gate_2: - move_threshold: - name: Gate 2 Move Threshold - still_threshold: - name: Gate 2 Still Threshold - gate_3: - move_threshold: - name: Gate 3 Move Threshold - still_threshold: - name: Gate 3 Still Threshold - gate_4: - move_threshold: - name: Gate 4 Move Threshold - still_threshold: - name: Gate 4 Still Threshold - gate_5: - move_threshold: - name: Gate 5 Move Threshold - still_threshold: - name: Gate 5 Still Threshold - gate_6: - move_threshold: - name: Gate 6 Move Threshold - still_threshold: - name: Gate 6 Still Threshold - gate_7: - move_threshold: - name: Gate 7 Move Threshold - still_threshold: - name: Gate 7 Still Threshold - gate_8: - move_threshold: - name: Gate 8 Move Threshold - still_threshold: - name: Gate 8 Still Threshold - gate_9: - move_threshold: - name: Gate 9 Move Threshold - still_threshold: - name: Gate 9 Still Threshold - gate_10: - move_threshold: - name: Gate 10 Move Threshold - still_threshold: - name: Gate 10 Still Threshold - gate_11: - move_threshold: - name: Gate 11 Move Threshold - still_threshold: - name: Gate 11 Still Threshold - gate_12: - move_threshold: - name: Gate 12 Move Threshold - still_threshold: - name: Gate 12 Still Threshold - gate_13: - move_threshold: - name: Gate 13 Move Threshold - still_threshold: - name: Gate 13 Still Threshold - gate_14: - move_threshold: - name: Gate 14 Move Threshold - still_threshold: - name: Gate 14 Still Threshold - gate_15: - move_threshold: - name: Gate 15 Move Threshold - still_threshold: - name: Gate 15 Still Threshold - -select: - - platform: ld2420 - operating_mode: - name: Operating Mode - -sensor: - - platform: ld2420 - moving_distance: - name: "Moving distance (cm)" - -text_sensor: - - platform: ld2420 - fw_version: - name: LD2420 Firmware +<<: !include common.yaml diff --git a/tests/components/ld2420/test.esp32-c3-ard.yaml b/tests/components/ld2420/test.esp32-c3-ard.yaml index 5e0b9db1c2..b516342f3b 100644 --- a/tests/components/ld2420/test.esp32-c3-ard.yaml +++ b/tests/components/ld2420/test.esp32-c3-ard.yaml @@ -1,132 +1,5 @@ -uart: - - id: uart_ld2420 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -ld2420: - id: my_ld2420 - -binary_sensor: - - platform: ld2420 - has_target: - name: Presence - -button: - - platform: ld2420 - apply_config: - name: Apply Config - factory_reset: - name: Factory Reset - restart_module: - name: Restart Module - revert_config: - name: Undo Edits - -number: - - platform: ld2420 - presence_timeout: - name: Detection Presence Timeout - min_gate_distance: - name: Detection Gate Minimum - max_gate_distance: - name: Detection Gate Maximum - gate_move_sensitivity: - name: Move Calibration Sensitivity Factor - gate_still_sensitivity: - name: Still Calibration Sensitivity Factor - gate_0: - move_threshold: - name: Gate 0 Move Threshold - still_threshold: - name: Gate 0 Still Threshold - gate_1: - move_threshold: - name: Gate 1 Move Threshold - still_threshold: - name: Gate 1 Still Threshold - gate_2: - move_threshold: - name: Gate 2 Move Threshold - still_threshold: - name: Gate 2 Still Threshold - gate_3: - move_threshold: - name: Gate 3 Move Threshold - still_threshold: - name: Gate 3 Still Threshold - gate_4: - move_threshold: - name: Gate 4 Move Threshold - still_threshold: - name: Gate 4 Still Threshold - gate_5: - move_threshold: - name: Gate 5 Move Threshold - still_threshold: - name: Gate 5 Still Threshold - gate_6: - move_threshold: - name: Gate 6 Move Threshold - still_threshold: - name: Gate 6 Still Threshold - gate_7: - move_threshold: - name: Gate 7 Move Threshold - still_threshold: - name: Gate 7 Still Threshold - gate_8: - move_threshold: - name: Gate 8 Move Threshold - still_threshold: - name: Gate 8 Still Threshold - gate_9: - move_threshold: - name: Gate 9 Move Threshold - still_threshold: - name: Gate 9 Still Threshold - gate_10: - move_threshold: - name: Gate 10 Move Threshold - still_threshold: - name: Gate 10 Still Threshold - gate_11: - move_threshold: - name: Gate 11 Move Threshold - still_threshold: - name: Gate 11 Still Threshold - gate_12: - move_threshold: - name: Gate 12 Move Threshold - still_threshold: - name: Gate 12 Still Threshold - gate_13: - move_threshold: - name: Gate 13 Move Threshold - still_threshold: - name: Gate 13 Still Threshold - gate_14: - move_threshold: - name: Gate 14 Move Threshold - still_threshold: - name: Gate 14 Still Threshold - gate_15: - move_threshold: - name: Gate 15 Move Threshold - still_threshold: - name: Gate 15 Still Threshold - -select: - - platform: ld2420 - operating_mode: - name: Operating Mode - -sensor: - - platform: ld2420 - moving_distance: - name: "Moving distance (cm)" - -text_sensor: - - platform: ld2420 - fw_version: - name: LD2420 Firmware +<<: !include common.yaml diff --git a/tests/components/ld2420/test.esp32-c3-idf.yaml b/tests/components/ld2420/test.esp32-c3-idf.yaml index 5e0b9db1c2..b516342f3b 100644 --- a/tests/components/ld2420/test.esp32-c3-idf.yaml +++ b/tests/components/ld2420/test.esp32-c3-idf.yaml @@ -1,132 +1,5 @@ -uart: - - id: uart_ld2420 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -ld2420: - id: my_ld2420 - -binary_sensor: - - platform: ld2420 - has_target: - name: Presence - -button: - - platform: ld2420 - apply_config: - name: Apply Config - factory_reset: - name: Factory Reset - restart_module: - name: Restart Module - revert_config: - name: Undo Edits - -number: - - platform: ld2420 - presence_timeout: - name: Detection Presence Timeout - min_gate_distance: - name: Detection Gate Minimum - max_gate_distance: - name: Detection Gate Maximum - gate_move_sensitivity: - name: Move Calibration Sensitivity Factor - gate_still_sensitivity: - name: Still Calibration Sensitivity Factor - gate_0: - move_threshold: - name: Gate 0 Move Threshold - still_threshold: - name: Gate 0 Still Threshold - gate_1: - move_threshold: - name: Gate 1 Move Threshold - still_threshold: - name: Gate 1 Still Threshold - gate_2: - move_threshold: - name: Gate 2 Move Threshold - still_threshold: - name: Gate 2 Still Threshold - gate_3: - move_threshold: - name: Gate 3 Move Threshold - still_threshold: - name: Gate 3 Still Threshold - gate_4: - move_threshold: - name: Gate 4 Move Threshold - still_threshold: - name: Gate 4 Still Threshold - gate_5: - move_threshold: - name: Gate 5 Move Threshold - still_threshold: - name: Gate 5 Still Threshold - gate_6: - move_threshold: - name: Gate 6 Move Threshold - still_threshold: - name: Gate 6 Still Threshold - gate_7: - move_threshold: - name: Gate 7 Move Threshold - still_threshold: - name: Gate 7 Still Threshold - gate_8: - move_threshold: - name: Gate 8 Move Threshold - still_threshold: - name: Gate 8 Still Threshold - gate_9: - move_threshold: - name: Gate 9 Move Threshold - still_threshold: - name: Gate 9 Still Threshold - gate_10: - move_threshold: - name: Gate 10 Move Threshold - still_threshold: - name: Gate 10 Still Threshold - gate_11: - move_threshold: - name: Gate 11 Move Threshold - still_threshold: - name: Gate 11 Still Threshold - gate_12: - move_threshold: - name: Gate 12 Move Threshold - still_threshold: - name: Gate 12 Still Threshold - gate_13: - move_threshold: - name: Gate 13 Move Threshold - still_threshold: - name: Gate 13 Still Threshold - gate_14: - move_threshold: - name: Gate 14 Move Threshold - still_threshold: - name: Gate 14 Still Threshold - gate_15: - move_threshold: - name: Gate 15 Move Threshold - still_threshold: - name: Gate 15 Still Threshold - -select: - - platform: ld2420 - operating_mode: - name: Operating Mode - -sensor: - - platform: ld2420 - moving_distance: - name: "Moving distance (cm)" - -text_sensor: - - platform: ld2420 - fw_version: - name: LD2420 Firmware +<<: !include common.yaml diff --git a/tests/components/ld2420/test.esp32-idf.yaml b/tests/components/ld2420/test.esp32-idf.yaml index 8c883664ec..f486544afa 100644 --- a/tests/components/ld2420/test.esp32-idf.yaml +++ b/tests/components/ld2420/test.esp32-idf.yaml @@ -1,132 +1,5 @@ -uart: - - id: uart_ld2420 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -ld2420: - id: my_ld2420 - -binary_sensor: - - platform: ld2420 - has_target: - name: Presence - -button: - - platform: ld2420 - apply_config: - name: Apply Config - factory_reset: - name: Factory Reset - restart_module: - name: Restart Module - revert_config: - name: Undo Edits - -number: - - platform: ld2420 - presence_timeout: - name: Detection Presence Timeout - min_gate_distance: - name: Detection Gate Minimum - max_gate_distance: - name: Detection Gate Maximum - gate_move_sensitivity: - name: Move Calibration Sensitivity Factor - gate_still_sensitivity: - name: Still Calibration Sensitivity Factor - gate_0: - move_threshold: - name: Gate 0 Move Threshold - still_threshold: - name: Gate 0 Still Threshold - gate_1: - move_threshold: - name: Gate 1 Move Threshold - still_threshold: - name: Gate 1 Still Threshold - gate_2: - move_threshold: - name: Gate 2 Move Threshold - still_threshold: - name: Gate 2 Still Threshold - gate_3: - move_threshold: - name: Gate 3 Move Threshold - still_threshold: - name: Gate 3 Still Threshold - gate_4: - move_threshold: - name: Gate 4 Move Threshold - still_threshold: - name: Gate 4 Still Threshold - gate_5: - move_threshold: - name: Gate 5 Move Threshold - still_threshold: - name: Gate 5 Still Threshold - gate_6: - move_threshold: - name: Gate 6 Move Threshold - still_threshold: - name: Gate 6 Still Threshold - gate_7: - move_threshold: - name: Gate 7 Move Threshold - still_threshold: - name: Gate 7 Still Threshold - gate_8: - move_threshold: - name: Gate 8 Move Threshold - still_threshold: - name: Gate 8 Still Threshold - gate_9: - move_threshold: - name: Gate 9 Move Threshold - still_threshold: - name: Gate 9 Still Threshold - gate_10: - move_threshold: - name: Gate 10 Move Threshold - still_threshold: - name: Gate 10 Still Threshold - gate_11: - move_threshold: - name: Gate 11 Move Threshold - still_threshold: - name: Gate 11 Still Threshold - gate_12: - move_threshold: - name: Gate 12 Move Threshold - still_threshold: - name: Gate 12 Still Threshold - gate_13: - move_threshold: - name: Gate 13 Move Threshold - still_threshold: - name: Gate 13 Still Threshold - gate_14: - move_threshold: - name: Gate 14 Move Threshold - still_threshold: - name: Gate 14 Still Threshold - gate_15: - move_threshold: - name: Gate 15 Move Threshold - still_threshold: - name: Gate 15 Still Threshold - -select: - - platform: ld2420 - operating_mode: - name: Operating Mode - -sensor: - - platform: ld2420 - moving_distance: - name: "Moving distance (cm)" - -text_sensor: - - platform: ld2420 - fw_version: - name: LD2420 Firmware +<<: !include common.yaml diff --git a/tests/components/ld2420/test.esp8266-ard.yaml b/tests/components/ld2420/test.esp8266-ard.yaml index 5e0b9db1c2..b516342f3b 100644 --- a/tests/components/ld2420/test.esp8266-ard.yaml +++ b/tests/components/ld2420/test.esp8266-ard.yaml @@ -1,132 +1,5 @@ -uart: - - id: uart_ld2420 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -ld2420: - id: my_ld2420 - -binary_sensor: - - platform: ld2420 - has_target: - name: Presence - -button: - - platform: ld2420 - apply_config: - name: Apply Config - factory_reset: - name: Factory Reset - restart_module: - name: Restart Module - revert_config: - name: Undo Edits - -number: - - platform: ld2420 - presence_timeout: - name: Detection Presence Timeout - min_gate_distance: - name: Detection Gate Minimum - max_gate_distance: - name: Detection Gate Maximum - gate_move_sensitivity: - name: Move Calibration Sensitivity Factor - gate_still_sensitivity: - name: Still Calibration Sensitivity Factor - gate_0: - move_threshold: - name: Gate 0 Move Threshold - still_threshold: - name: Gate 0 Still Threshold - gate_1: - move_threshold: - name: Gate 1 Move Threshold - still_threshold: - name: Gate 1 Still Threshold - gate_2: - move_threshold: - name: Gate 2 Move Threshold - still_threshold: - name: Gate 2 Still Threshold - gate_3: - move_threshold: - name: Gate 3 Move Threshold - still_threshold: - name: Gate 3 Still Threshold - gate_4: - move_threshold: - name: Gate 4 Move Threshold - still_threshold: - name: Gate 4 Still Threshold - gate_5: - move_threshold: - name: Gate 5 Move Threshold - still_threshold: - name: Gate 5 Still Threshold - gate_6: - move_threshold: - name: Gate 6 Move Threshold - still_threshold: - name: Gate 6 Still Threshold - gate_7: - move_threshold: - name: Gate 7 Move Threshold - still_threshold: - name: Gate 7 Still Threshold - gate_8: - move_threshold: - name: Gate 8 Move Threshold - still_threshold: - name: Gate 8 Still Threshold - gate_9: - move_threshold: - name: Gate 9 Move Threshold - still_threshold: - name: Gate 9 Still Threshold - gate_10: - move_threshold: - name: Gate 10 Move Threshold - still_threshold: - name: Gate 10 Still Threshold - gate_11: - move_threshold: - name: Gate 11 Move Threshold - still_threshold: - name: Gate 11 Still Threshold - gate_12: - move_threshold: - name: Gate 12 Move Threshold - still_threshold: - name: Gate 12 Still Threshold - gate_13: - move_threshold: - name: Gate 13 Move Threshold - still_threshold: - name: Gate 13 Still Threshold - gate_14: - move_threshold: - name: Gate 14 Move Threshold - still_threshold: - name: Gate 14 Still Threshold - gate_15: - move_threshold: - name: Gate 15 Move Threshold - still_threshold: - name: Gate 15 Still Threshold - -select: - - platform: ld2420 - operating_mode: - name: Operating Mode - -sensor: - - platform: ld2420 - moving_distance: - name: "Moving distance (cm)" - -text_sensor: - - platform: ld2420 - fw_version: - name: LD2420 Firmware +<<: !include common.yaml diff --git a/tests/components/ld2420/test.rp2040-ard.yaml b/tests/components/ld2420/test.rp2040-ard.yaml index 5e0b9db1c2..b516342f3b 100644 --- a/tests/components/ld2420/test.rp2040-ard.yaml +++ b/tests/components/ld2420/test.rp2040-ard.yaml @@ -1,132 +1,5 @@ -uart: - - id: uart_ld2420 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -ld2420: - id: my_ld2420 - -binary_sensor: - - platform: ld2420 - has_target: - name: Presence - -button: - - platform: ld2420 - apply_config: - name: Apply Config - factory_reset: - name: Factory Reset - restart_module: - name: Restart Module - revert_config: - name: Undo Edits - -number: - - platform: ld2420 - presence_timeout: - name: Detection Presence Timeout - min_gate_distance: - name: Detection Gate Minimum - max_gate_distance: - name: Detection Gate Maximum - gate_move_sensitivity: - name: Move Calibration Sensitivity Factor - gate_still_sensitivity: - name: Still Calibration Sensitivity Factor - gate_0: - move_threshold: - name: Gate 0 Move Threshold - still_threshold: - name: Gate 0 Still Threshold - gate_1: - move_threshold: - name: Gate 1 Move Threshold - still_threshold: - name: Gate 1 Still Threshold - gate_2: - move_threshold: - name: Gate 2 Move Threshold - still_threshold: - name: Gate 2 Still Threshold - gate_3: - move_threshold: - name: Gate 3 Move Threshold - still_threshold: - name: Gate 3 Still Threshold - gate_4: - move_threshold: - name: Gate 4 Move Threshold - still_threshold: - name: Gate 4 Still Threshold - gate_5: - move_threshold: - name: Gate 5 Move Threshold - still_threshold: - name: Gate 5 Still Threshold - gate_6: - move_threshold: - name: Gate 6 Move Threshold - still_threshold: - name: Gate 6 Still Threshold - gate_7: - move_threshold: - name: Gate 7 Move Threshold - still_threshold: - name: Gate 7 Still Threshold - gate_8: - move_threshold: - name: Gate 8 Move Threshold - still_threshold: - name: Gate 8 Still Threshold - gate_9: - move_threshold: - name: Gate 9 Move Threshold - still_threshold: - name: Gate 9 Still Threshold - gate_10: - move_threshold: - name: Gate 10 Move Threshold - still_threshold: - name: Gate 10 Still Threshold - gate_11: - move_threshold: - name: Gate 11 Move Threshold - still_threshold: - name: Gate 11 Still Threshold - gate_12: - move_threshold: - name: Gate 12 Move Threshold - still_threshold: - name: Gate 12 Still Threshold - gate_13: - move_threshold: - name: Gate 13 Move Threshold - still_threshold: - name: Gate 13 Still Threshold - gate_14: - move_threshold: - name: Gate 14 Move Threshold - still_threshold: - name: Gate 14 Still Threshold - gate_15: - move_threshold: - name: Gate 15 Move Threshold - still_threshold: - name: Gate 15 Still Threshold - -select: - - platform: ld2420 - operating_mode: - name: Operating Mode - -sensor: - - platform: ld2420 - moving_distance: - name: "Moving distance (cm)" - -text_sensor: - - platform: ld2420 - fw_version: - name: LD2420 Firmware +<<: !include common.yaml diff --git a/tests/components/lilygo_t5_47/common.yaml b/tests/components/lilygo_t5_47/common.yaml new file mode 100644 index 0000000000..f539c58d74 --- /dev/null +++ b/tests/components/lilygo_t5_47/common.yaml @@ -0,0 +1,24 @@ +i2c: + - id: i2c_lilygo_t5_47 + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1306_i2c + id: ssd1306_display + model: SSD1306_128X64 + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + +touchscreen: + - platform: lilygo_t5_47 + id: lilygo_touchscreen + interrupt_pin: ${interrupt_pin} + display: ssd1306_display + on_touch: + - logger.log: + format: Touch at (%d, %d) + args: [touch.x, touch.y] diff --git a/tests/components/lilygo_t5_47/test.esp32-ard.yaml b/tests/components/lilygo_t5_47/test.esp32-ard.yaml index 35eb3df022..342f0b6d8b 100644 --- a/tests/components/lilygo_t5_47/test.esp32-ard.yaml +++ b/tests/components/lilygo_t5_47/test.esp32-ard.yaml @@ -1,24 +1,7 @@ -i2c: - - id: i2c_lilygo_t5_47 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: lilygo_t5_47 - id: lilygo_touchscreen - interrupt_pin: 14 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/lilygo_t5_47/test.esp32-c3-ard.yaml b/tests/components/lilygo_t5_47/test.esp32-c3-ard.yaml index 41e81103ac..061a98ce24 100644 --- a/tests/components/lilygo_t5_47/test.esp32-c3-ard.yaml +++ b/tests/components/lilygo_t5_47/test.esp32-c3-ard.yaml @@ -1,24 +1,7 @@ -i2c: - - id: i2c_lilygo_t5_47 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: lilygo_t5_47 - id: lilygo_touchscreen - interrupt_pin: 6 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/lilygo_t5_47/test.esp32-c3-idf.yaml b/tests/components/lilygo_t5_47/test.esp32-c3-idf.yaml index 41e81103ac..061a98ce24 100644 --- a/tests/components/lilygo_t5_47/test.esp32-c3-idf.yaml +++ b/tests/components/lilygo_t5_47/test.esp32-c3-idf.yaml @@ -1,24 +1,7 @@ -i2c: - - id: i2c_lilygo_t5_47 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: lilygo_t5_47 - id: lilygo_touchscreen - interrupt_pin: 6 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/lilygo_t5_47/test.esp32-idf.yaml b/tests/components/lilygo_t5_47/test.esp32-idf.yaml index 35eb3df022..342f0b6d8b 100644 --- a/tests/components/lilygo_t5_47/test.esp32-idf.yaml +++ b/tests/components/lilygo_t5_47/test.esp32-idf.yaml @@ -1,24 +1,7 @@ -i2c: - - id: i2c_lilygo_t5_47 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: lilygo_t5_47 - id: lilygo_touchscreen - interrupt_pin: 14 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/lilygo_t5_47/test.esp8266-ard.yaml b/tests/components/lilygo_t5_47/test.esp8266-ard.yaml index 766c492b12..b446a75f13 100644 --- a/tests/components/lilygo_t5_47/test.esp8266-ard.yaml +++ b/tests/components/lilygo_t5_47/test.esp8266-ard.yaml @@ -1,24 +1,7 @@ -i2c: - - id: i2c_lilygo_t5_47 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + interrupt_pin: GPIO12 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: lilygo_t5_47 - id: lilygo_touchscreen - interrupt_pin: 12 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/lilygo_t5_47/test.rp2040-ard.yaml b/tests/components/lilygo_t5_47/test.rp2040-ard.yaml index 41e81103ac..061a98ce24 100644 --- a/tests/components/lilygo_t5_47/test.rp2040-ard.yaml +++ b/tests/components/lilygo_t5_47/test.rp2040-ard.yaml @@ -1,24 +1,7 @@ -i2c: - - id: i2c_lilygo_t5_47 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: lilygo_t5_47 - id: lilygo_touchscreen - interrupt_pin: 6 - display: ssd1306_display - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/ltr390/common.yaml b/tests/components/ltr390/common.yaml new file mode 100644 index 0000000000..2eebe9d1c3 --- /dev/null +++ b/tests/components/ltr390/common.yaml @@ -0,0 +1,38 @@ +i2c: + - id: i2c_ltr390 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ltr390 + uv: + name: LTR390 UV + uv_index: + name: LTR390 UVI + light: + name: LTR390 Light + ambient_light: + name: LTR390 ALS + gain: X3 + resolution: 18 + window_correction_factor: 1.0 + address: 0x53 + update_interval: 60s + - platform: ltr390 + uv: + name: LTR390 UV + uv_index: + name: LTR390 UVI + light: + name: LTR390 Light + ambient_light: + name: LTR390 ALS + gain: + ambient_light: X9 + uv: X3 + resolution: + ambient_light: 18 + uv: 13 + window_correction_factor: 1.0 + address: 0x53 + update_interval: 60s diff --git a/tests/components/ltr390/test.esp32-ard.yaml b/tests/components/ltr390/test.esp32-ard.yaml index bdfe349b77..63c3bd6afd 100644 --- a/tests/components/ltr390/test.esp32-ard.yaml +++ b/tests/components/ltr390/test.esp32-ard.yaml @@ -1,38 +1,5 @@ -i2c: - - id: i2c_ltr390 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ltr390 - uv: - name: LTR390 UV - uv_index: - name: LTR390 UVI - light: - name: LTR390 Light - ambient_light: - name: LTR390 ALS - gain: X3 - resolution: 18 - window_correction_factor: 1.0 - address: 0x53 - update_interval: 60s - - platform: ltr390 - uv: - name: LTR390 UV - uv_index: - name: LTR390 UVI - light: - name: LTR390 Light - ambient_light: - name: LTR390 ALS - gain: - ambient_light: X9 - uv: X3 - resolution: - ambient_light: 18 - uv: 13 - window_correction_factor: 1.0 - address: 0x53 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ltr390/test.esp32-c3-ard.yaml b/tests/components/ltr390/test.esp32-c3-ard.yaml index fee0f37ce1..ee2c29ca4e 100644 --- a/tests/components/ltr390/test.esp32-c3-ard.yaml +++ b/tests/components/ltr390/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_ltr390 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ltr390 - uv: - name: LTR390 UV - uv_index: - name: LTR390 UVI - light: - name: LTR390 Light - ambient_light: - name: LTR390 ALS - gain: X3 - resolution: 18 - window_correction_factor: 1.0 - address: 0x53 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ltr390/test.esp32-c3-idf.yaml b/tests/components/ltr390/test.esp32-c3-idf.yaml index fee0f37ce1..ee2c29ca4e 100644 --- a/tests/components/ltr390/test.esp32-c3-idf.yaml +++ b/tests/components/ltr390/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_ltr390 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ltr390 - uv: - name: LTR390 UV - uv_index: - name: LTR390 UVI - light: - name: LTR390 Light - ambient_light: - name: LTR390 ALS - gain: X3 - resolution: 18 - window_correction_factor: 1.0 - address: 0x53 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ltr390/test.esp32-idf.yaml b/tests/components/ltr390/test.esp32-idf.yaml index 9786c7dac3..63c3bd6afd 100644 --- a/tests/components/ltr390/test.esp32-idf.yaml +++ b/tests/components/ltr390/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_ltr390 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ltr390 - uv: - name: LTR390 UV - uv_index: - name: LTR390 UVI - light: - name: LTR390 Light - ambient_light: - name: LTR390 ALS - gain: X3 - resolution: 18 - window_correction_factor: 1.0 - address: 0x53 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ltr390/test.esp8266-ard.yaml b/tests/components/ltr390/test.esp8266-ard.yaml index 149f46f9c8..ee2c29ca4e 100644 --- a/tests/components/ltr390/test.esp8266-ard.yaml +++ b/tests/components/ltr390/test.esp8266-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_ltr390 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ltr390 - uv: - name: LTR390 UV - uv_index: - name: LTR390 UVI - light: - name: LTR390 Light - ambient_light: - name: LTR390 ALS - gain: - ambient_light: X9 - uv: X3 - resolution: 18 - window_correction_factor: 1.0 - address: 0x53 - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ltr390/test.rp2040-ard.yaml b/tests/components/ltr390/test.rp2040-ard.yaml index fee0f37ce1..ee2c29ca4e 100644 --- a/tests/components/ltr390/test.rp2040-ard.yaml +++ b/tests/components/ltr390/test.rp2040-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_ltr390 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ltr390 - uv: - name: LTR390 UV - uv_index: - name: LTR390 UVI - light: - name: LTR390 Light - ambient_light: - name: LTR390 ALS - gain: X3 - resolution: 18 - window_correction_factor: 1.0 - address: 0x53 - update_interval: 60s +<<: !include common.yaml From 4e4566361f074cbcd33b5462cafad81bc6b96275 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:05:59 -0600 Subject: [PATCH 153/194] [CI] Consolidate some tests (M) (#8202) --- tests/components/max31855/common.yaml | 13 ++++ tests/components/max31855/test.esp32-ard.yaml | 18 ++---- .../max31855/test.esp32-c3-ard.yaml | 18 ++---- .../max31855/test.esp32-c3-idf.yaml | 18 ++---- tests/components/max31855/test.esp32-idf.yaml | 18 ++---- .../components/max31855/test.esp8266-ard.yaml | 18 ++---- .../components/max31855/test.rp2040-ard.yaml | 18 ++---- tests/components/max31856/common.yaml | 13 ++++ tests/components/max31856/test.esp32-ard.yaml | 18 ++---- .../max31856/test.esp32-c3-ard.yaml | 19 ++---- .../max31856/test.esp32-c3-idf.yaml | 19 ++---- tests/components/max31856/test.esp32-idf.yaml | 18 ++---- .../components/max31856/test.esp8266-ard.yaml | 19 ++---- .../components/max31856/test.rp2040-ard.yaml | 19 ++---- tests/components/max31865/common.yaml | 13 ++++ tests/components/max31865/test.esp32-ard.yaml | 18 ++---- .../max31865/test.esp32-c3-ard.yaml | 18 ++---- .../max31865/test.esp32-c3-idf.yaml | 18 ++---- tests/components/max31865/test.esp32-idf.yaml | 18 ++---- .../components/max31865/test.esp8266-ard.yaml | 18 ++---- .../components/max31865/test.rp2040-ard.yaml | 18 ++---- tests/components/max44009/common.yaml | 12 ++++ tests/components/max44009/test.esp32-ard.yaml | 15 ++--- .../max44009/test.esp32-c3-ard.yaml | 15 ++--- .../max44009/test.esp32-c3-idf.yaml | 15 ++--- tests/components/max44009/test.esp32-idf.yaml | 15 ++--- .../components/max44009/test.esp8266-ard.yaml | 15 ++--- .../components/max44009/test.rp2040-ard.yaml | 15 ++--- tests/components/max6675/common.yaml | 11 ++++ tests/components/max6675/test.esp32-ard.yaml | 16 ++--- .../components/max6675/test.esp32-c3-ard.yaml | 16 ++--- .../components/max6675/test.esp32-c3-idf.yaml | 16 ++--- tests/components/max6675/test.esp32-idf.yaml | 16 ++--- .../components/max6675/test.esp8266-ard.yaml | 16 ++--- tests/components/max6675/test.rp2040-ard.yaml | 16 ++--- tests/components/max6956/common.yaml | 19 ++++++ tests/components/max6956/test.esp32-ard.yaml | 22 ++----- .../components/max6956/test.esp32-c3-ard.yaml | 22 ++----- .../components/max6956/test.esp32-c3-idf.yaml | 22 ++----- tests/components/max6956/test.esp32-idf.yaml | 22 ++----- .../components/max6956/test.esp8266-ard.yaml | 22 ++----- tests/components/max6956/test.rp2040-ard.yaml | 22 ++----- tests/components/max7219/common.yaml | 12 ++++ tests/components/max7219/test.esp32-ard.yaml | 17 ++--- .../components/max7219/test.esp32-c3-ard.yaml | 17 ++--- .../components/max7219/test.esp32-c3-idf.yaml | 17 ++--- tests/components/max7219/test.esp32-idf.yaml | 17 ++--- .../components/max7219/test.esp8266-ard.yaml | 17 ++--- tests/components/max7219/test.rp2040-ard.yaml | 17 ++--- tests/components/max7219digit/common.yaml | 16 +++++ .../max7219digit/test.esp32-ard.yaml | 21 ++----- .../max7219digit/test.esp32-c3-ard.yaml | 21 ++----- .../max7219digit/test.esp32-c3-idf.yaml | 21 ++----- .../max7219digit/test.esp32-idf.yaml | 21 ++----- .../max7219digit/test.esp8266-ard.yaml | 21 ++----- .../max7219digit/test.rp2040-ard.yaml | 21 ++----- tests/components/max9611/common.yaml | 18 ++++++ tests/components/max9611/test.esp32-ard.yaml | 21 ++----- .../components/max9611/test.esp32-c3-ard.yaml | 21 ++----- .../components/max9611/test.esp32-c3-idf.yaml | 21 ++----- tests/components/max9611/test.esp32-idf.yaml | 21 ++----- .../components/max9611/test.esp8266-ard.yaml | 21 ++----- tests/components/max9611/test.rp2040-ard.yaml | 21 ++----- tests/components/mcp23008/common.yaml | 23 +++++++ tests/components/mcp23008/test.esp32-ard.yaml | 26 ++------ .../mcp23008/test.esp32-c3-ard.yaml | 26 ++------ .../mcp23008/test.esp32-c3-idf.yaml | 26 ++------ tests/components/mcp23008/test.esp32-idf.yaml | 26 ++------ .../components/mcp23008/test.esp8266-ard.yaml | 26 ++------ .../components/mcp23008/test.rp2040-ard.yaml | 26 ++------ tests/components/mcp23016/common.yaml | 23 +++++++ tests/components/mcp23016/test.esp32-ard.yaml | 26 ++------ .../mcp23016/test.esp32-c3-ard.yaml | 26 ++------ .../mcp23016/test.esp32-c3-idf.yaml | 26 ++------ tests/components/mcp23016/test.esp32-idf.yaml | 26 ++------ .../components/mcp23016/test.esp8266-ard.yaml | 26 ++------ .../components/mcp23016/test.rp2040-ard.yaml | 26 ++------ tests/components/mcp23017/common.yaml | 23 +++++++ tests/components/mcp23017/test.esp32-ard.yaml | 26 ++------ .../mcp23017/test.esp32-c3-ard.yaml | 26 ++------ .../mcp23017/test.esp32-c3-idf.yaml | 26 ++------ tests/components/mcp23017/test.esp32-idf.yaml | 26 ++------ .../components/mcp23017/test.esp8266-ard.yaml | 26 ++------ .../components/mcp23017/test.rp2040-ard.yaml | 26 ++------ tests/components/mcp23s08/common.yaml | 10 +++ tests/components/mcp23s08/test.esp32-ard.yaml | 15 ++--- .../mcp23s08/test.esp32-c3-ard.yaml | 15 ++--- .../mcp23s08/test.esp32-c3-idf.yaml | 15 ++--- tests/components/mcp23s08/test.esp32-idf.yaml | 15 ++--- .../components/mcp23s08/test.esp8266-ard.yaml | 15 ++--- .../components/mcp23s08/test.rp2040-ard.yaml | 15 ++--- tests/components/mcp23s17/common.yaml | 10 +++ tests/components/mcp23s17/test.esp32-ard.yaml | 15 ++--- .../mcp23s17/test.esp32-c3-ard.yaml | 15 ++--- .../mcp23s17/test.esp32-c3-idf.yaml | 15 ++--- tests/components/mcp23s17/test.esp32-idf.yaml | 15 ++--- .../components/mcp23s17/test.esp8266-ard.yaml | 15 ++--- .../components/mcp23s17/test.rp2040-ard.yaml | 15 ++--- tests/components/mcp2515/common.yaml | 44 +++++++++++++ tests/components/mcp2515/test.esp32-ard.yaml | 49 ++------------- .../components/mcp2515/test.esp32-c3-ard.yaml | 49 ++------------- .../components/mcp2515/test.esp32-c3-idf.yaml | 49 ++------------- tests/components/mcp2515/test.esp32-idf.yaml | 49 ++------------- .../components/mcp2515/test.esp8266-ard.yaml | 49 ++------------- tests/components/mcp2515/test.rp2040-ard.yaml | 49 ++------------- tests/components/mcp3008/common.yaml | 17 +++++ tests/components/mcp3008/test.esp32-ard.yaml | 22 ++----- .../components/mcp3008/test.esp32-c3-ard.yaml | 22 ++----- .../components/mcp3008/test.esp32-c3-idf.yaml | 22 ++----- tests/components/mcp3008/test.esp32-idf.yaml | 22 ++----- .../components/mcp3008/test.esp8266-ard.yaml | 22 ++----- tests/components/mcp3008/test.rp2040-ard.yaml | 22 ++----- tests/components/mcp3204/common.yaml | 16 +++++ tests/components/mcp3204/test.esp32-ard.yaml | 21 ++----- .../components/mcp3204/test.esp32-c3-ard.yaml | 21 ++----- .../components/mcp3204/test.esp32-c3-idf.yaml | 21 ++----- tests/components/mcp3204/test.esp32-idf.yaml | 21 ++----- .../components/mcp3204/test.esp8266-ard.yaml | 21 ++----- tests/components/mcp3204/test.rp2040-ard.yaml | 21 ++----- tests/components/mcp4725/common.yaml | 8 +++ tests/components/mcp4725/test.esp32-ard.yaml | 11 ++-- .../components/mcp4725/test.esp32-c3-ard.yaml | 11 ++-- .../components/mcp4725/test.esp32-c3-idf.yaml | 11 ++-- tests/components/mcp4725/test.esp32-idf.yaml | 11 ++-- .../components/mcp4725/test.esp8266-ard.yaml | 11 ++-- tests/components/mcp4725/test.rp2040-ard.yaml | 11 ++-- tests/components/mcp4728/common.yaml | 31 +++++++++ tests/components/mcp4728/test.esp32-ard.yaml | 34 ++-------- .../components/mcp4728/test.esp32-c3-ard.yaml | 34 ++-------- .../components/mcp4728/test.esp32-c3-idf.yaml | 34 ++-------- tests/components/mcp4728/test.esp32-idf.yaml | 34 ++-------- .../components/mcp4728/test.esp8266-ard.yaml | 34 ++-------- tests/components/mcp4728/test.rp2040-ard.yaml | 34 ++-------- tests/components/mcp47a1/common.yaml | 8 +++ tests/components/mcp47a1/test.esp32-ard.yaml | 11 ++-- .../components/mcp47a1/test.esp32-c3-ard.yaml | 11 ++-- .../components/mcp47a1/test.esp32-c3-idf.yaml | 11 ++-- tests/components/mcp47a1/test.esp32-idf.yaml | 11 ++-- .../components/mcp47a1/test.esp8266-ard.yaml | 11 ++-- tests/components/mcp47a1/test.rp2040-ard.yaml | 11 ++-- tests/components/mcp9600/common.yaml | 12 ++++ tests/components/mcp9600/test.esp32-ard.yaml | 15 ++--- .../components/mcp9600/test.esp32-c3-ard.yaml | 15 ++--- .../components/mcp9600/test.esp32-c3-idf.yaml | 15 ++--- tests/components/mcp9600/test.esp32-idf.yaml | 15 ++--- .../components/mcp9600/test.esp8266-ard.yaml | 15 ++--- tests/components/mcp9600/test.rp2040-ard.yaml | 15 ++--- tests/components/mcp9808/common.yaml | 8 +++ tests/components/mcp9808/test.esp32-ard.yaml | 11 ++-- .../components/mcp9808/test.esp32-c3-ard.yaml | 11 ++-- .../components/mcp9808/test.esp32-c3-idf.yaml | 11 ++-- tests/components/mcp9808/test.esp32-idf.yaml | 11 ++-- .../components/mcp9808/test.esp8266-ard.yaml | 11 ++-- tests/components/mcp9808/test.rp2040-ard.yaml | 11 ++-- tests/components/mhz19/common.yaml | 14 +++++ tests/components/mhz19/test.esp32-ard.yaml | 17 ++--- tests/components/mhz19/test.esp32-c3-ard.yaml | 17 ++--- tests/components/mhz19/test.esp32-c3-idf.yaml | 17 ++--- tests/components/mhz19/test.esp32-idf.yaml | 17 ++--- tests/components/mhz19/test.esp8266-ard.yaml | 17 ++--- tests/components/mhz19/test.rp2040-ard.yaml | 17 ++--- tests/components/micronova/common.yaml | 49 +++++++++++++++ .../components/micronova/test.esp32-ard.yaml | 53 ++-------------- .../micronova/test.esp32-c3-ard.yaml | 53 ++-------------- .../micronova/test.esp32-c3-idf.yaml | 53 ++-------------- .../components/micronova/test.esp32-idf.yaml | 53 ++-------------- .../micronova/test.esp8266-ard.yaml | 53 ++-------------- .../components/micronova/test.rp2040-ard.yaml | 53 ++-------------- tests/components/microphone/common.yaml | 11 ++++ .../components/microphone/test.esp32-ard.yaml | 16 +++-- .../microphone/test.esp32-c3-ard.yaml | 16 ++--- .../microphone/test.esp32-c3-idf.yaml | 16 ++--- .../components/microphone/test.esp32-idf.yaml | 16 +++-- tests/components/mics_4514/common.yaml | 20 ++++++ .../components/mics_4514/test.esp32-ard.yaml | 23 ++----- .../mics_4514/test.esp32-c3-ard.yaml | 23 ++----- .../mics_4514/test.esp32-c3-idf.yaml | 23 ++----- .../components/mics_4514/test.esp32-idf.yaml | 23 ++----- .../mics_4514/test.esp8266-ard.yaml | 23 ++----- .../components/mics_4514/test.rp2040-ard.yaml | 23 ++----- tests/components/midea/common.yaml | 59 +++++++++++++++++ tests/components/midea/test.esp32-ard.yaml | 63 ++----------------- tests/components/midea/test.esp32-c3-ard.yaml | 63 ++----------------- tests/components/midea/test.esp8266-ard.yaml | 63 ++----------------- tests/components/mlx90393/common.yaml | 20 ++++++ tests/components/mlx90393/test.esp32-ard.yaml | 23 ++----- .../mlx90393/test.esp32-c3-ard.yaml | 23 ++----- .../mlx90393/test.esp32-c3-idf.yaml | 23 ++----- tests/components/mlx90393/test.esp32-idf.yaml | 23 ++----- .../components/mlx90393/test.esp8266-ard.yaml | 23 ++----- .../components/mlx90393/test.rp2040-ard.yaml | 23 ++----- tests/components/mlx90614/common.yaml | 12 ++++ tests/components/mlx90614/test.esp32-ard.yaml | 15 ++--- .../mlx90614/test.esp32-c3-ard.yaml | 15 ++--- .../mlx90614/test.esp32-c3-idf.yaml | 15 ++--- tests/components/mlx90614/test.esp32-idf.yaml | 15 ++--- .../components/mlx90614/test.esp8266-ard.yaml | 15 ++--- .../components/mlx90614/test.rp2040-ard.yaml | 15 ++--- tests/components/mmc5603/common.yaml | 14 +++++ tests/components/mmc5603/test.esp32-ard.yaml | 17 ++--- .../components/mmc5603/test.esp32-c3-ard.yaml | 17 ++--- .../components/mmc5603/test.esp32-c3-idf.yaml | 17 ++--- tests/components/mmc5603/test.esp32-idf.yaml | 17 ++--- .../components/mmc5603/test.esp8266-ard.yaml | 17 ++--- tests/components/mmc5603/test.rp2040-ard.yaml | 17 ++--- tests/components/mmc5983/common.yaml | 16 +++++ tests/components/mmc5983/test.esp32-ard.yaml | 19 ++---- .../components/mmc5983/test.esp32-c3-ard.yaml | 19 ++---- .../components/mmc5983/test.esp32-c3-idf.yaml | 19 ++---- tests/components/mmc5983/test.esp32-idf.yaml | 19 ++---- .../components/mmc5983/test.esp8266-ard.yaml | 19 ++---- tests/components/mmc5983/test.rp2040-ard.yaml | 19 ++---- tests/components/modbus/common.yaml | 9 +++ tests/components/modbus/test.esp32-ard.yaml | 13 ++-- .../components/modbus/test.esp32-c3-ard.yaml | 13 ++-- .../components/modbus/test.esp32-c3-idf.yaml | 13 ++-- tests/components/modbus/test.esp32-idf.yaml | 13 ++-- tests/components/modbus/test.esp8266-ard.yaml | 13 ++-- tests/components/modbus/test.rp2040-ard.yaml | 13 ++-- .../components/modbus_controller/common.yaml | 35 +++++++++++ .../modbus_controller/test.esp32-ard.yaml | 41 +++--------- .../modbus_controller/test.esp32-c3-ard.yaml | 20 +++--- .../modbus_controller/test.esp32-c3-idf.yaml | 20 +++--- .../modbus_controller/test.esp32-idf.yaml | 25 +++----- .../modbus_controller/test.esp8266-ard.yaml | 20 +++--- .../modbus_controller/test.rp2040-ard.yaml | 20 +++--- tests/components/monochromatic/common.yaml | 40 ++++++++++++ .../monochromatic/test.esp32-ard.yaml | 43 ++----------- .../monochromatic/test.esp32-c3-ard.yaml | 43 ++----------- .../monochromatic/test.esp32-c3-idf.yaml | 43 ++----------- .../monochromatic/test.esp32-idf.yaml | 43 ++----------- .../monochromatic/test.esp8266-ard.yaml | 43 ++----------- .../monochromatic/test.rp2040-ard.yaml | 43 ++----------- tests/components/mpl3115a2/common.yaml | 12 ++++ .../components/mpl3115a2/test.esp32-ard.yaml | 15 ++--- .../mpl3115a2/test.esp32-c3-ard.yaml | 15 ++--- .../mpl3115a2/test.esp32-c3-idf.yaml | 15 ++--- .../components/mpl3115a2/test.esp32-idf.yaml | 15 ++--- .../mpl3115a2/test.esp8266-ard.yaml | 15 ++--- .../components/mpl3115a2/test.rp2040-ard.yaml | 15 ++--- tests/components/mpu6050/common.yaml | 22 +++++++ tests/components/mpu6050/test.esp32-ard.yaml | 25 ++------ .../components/mpu6050/test.esp32-c3-ard.yaml | 25 ++------ .../components/mpu6050/test.esp32-c3-idf.yaml | 25 ++------ tests/components/mpu6050/test.esp32-idf.yaml | 25 ++------ .../components/mpu6050/test.esp8266-ard.yaml | 25 ++------ tests/components/mpu6050/test.rp2040-ard.yaml | 25 ++------ tests/components/mpu6886/common.yaml | 22 +++++++ tests/components/mpu6886/test.esp32-ard.yaml | 25 ++------ .../components/mpu6886/test.esp32-c3-ard.yaml | 25 ++------ .../components/mpu6886/test.esp32-c3-idf.yaml | 25 ++------ tests/components/mpu6886/test.esp32-idf.yaml | 25 ++------ .../components/mpu6886/test.esp8266-ard.yaml | 25 ++------ tests/components/mpu6886/test.rp2040-ard.yaml | 25 ++------ .../components/mqtt_subscribe/common-ard.yaml | 36 +++++++++++ .../components/mqtt_subscribe/common-idf.yaml | 37 +++++++++++ .../mqtt_subscribe/test.esp32-ard.yaml | 37 +---------- .../mqtt_subscribe/test.esp32-c3-ard.yaml | 37 +---------- .../mqtt_subscribe/test.esp32-c3-idf.yaml | 38 +---------- .../mqtt_subscribe/test.esp32-idf.yaml | 38 +---------- .../mqtt_subscribe/test.esp8266-ard.yaml | 37 +---------- tests/components/ms5611/common.yaml | 13 ++++ tests/components/ms5611/test.esp32-ard.yaml | 16 ++--- .../components/ms5611/test.esp32-c3-ard.yaml | 16 ++--- .../components/ms5611/test.esp32-c3-idf.yaml | 16 ++--- tests/components/ms5611/test.esp32-idf.yaml | 16 ++--- tests/components/ms5611/test.esp8266-ard.yaml | 16 ++--- tests/components/ms5611/test.rp2040-ard.yaml | 16 ++--- 268 files changed, 1873 insertions(+), 4030 deletions(-) create mode 100644 tests/components/max31855/common.yaml create mode 100644 tests/components/max31856/common.yaml create mode 100644 tests/components/max31865/common.yaml create mode 100644 tests/components/max44009/common.yaml create mode 100644 tests/components/max6675/common.yaml create mode 100644 tests/components/max6956/common.yaml create mode 100644 tests/components/max7219/common.yaml create mode 100644 tests/components/max7219digit/common.yaml create mode 100644 tests/components/max9611/common.yaml create mode 100644 tests/components/mcp23008/common.yaml create mode 100644 tests/components/mcp23016/common.yaml create mode 100644 tests/components/mcp23017/common.yaml create mode 100644 tests/components/mcp23s08/common.yaml create mode 100644 tests/components/mcp23s17/common.yaml create mode 100644 tests/components/mcp2515/common.yaml create mode 100644 tests/components/mcp3008/common.yaml create mode 100644 tests/components/mcp3204/common.yaml create mode 100644 tests/components/mcp4725/common.yaml create mode 100644 tests/components/mcp4728/common.yaml create mode 100644 tests/components/mcp47a1/common.yaml create mode 100644 tests/components/mcp9600/common.yaml create mode 100644 tests/components/mcp9808/common.yaml create mode 100644 tests/components/mhz19/common.yaml create mode 100644 tests/components/micronova/common.yaml create mode 100644 tests/components/microphone/common.yaml create mode 100644 tests/components/mics_4514/common.yaml create mode 100644 tests/components/midea/common.yaml create mode 100644 tests/components/mlx90393/common.yaml create mode 100644 tests/components/mlx90614/common.yaml create mode 100644 tests/components/mmc5603/common.yaml create mode 100644 tests/components/mmc5983/common.yaml create mode 100644 tests/components/modbus/common.yaml create mode 100644 tests/components/modbus_controller/common.yaml create mode 100644 tests/components/monochromatic/common.yaml create mode 100644 tests/components/mpl3115a2/common.yaml create mode 100644 tests/components/mpu6050/common.yaml create mode 100644 tests/components/mpu6886/common.yaml create mode 100644 tests/components/mqtt_subscribe/common-ard.yaml create mode 100644 tests/components/mqtt_subscribe/common-idf.yaml create mode 100644 tests/components/ms5611/common.yaml diff --git a/tests/components/max31855/common.yaml b/tests/components/max31855/common.yaml new file mode 100644 index 0000000000..7136c597d5 --- /dev/null +++ b/tests/components/max31855/common.yaml @@ -0,0 +1,13 @@ +spi: + - id: spi_max31855 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sensor: + - platform: max31855 + name: MAX31855 Temperature + cs_pin: ${cs_pin} + update_interval: 15s + reference_temperature: + name: MAX31855 Internal Temperature diff --git a/tests/components/max31855/test.esp32-ard.yaml b/tests/components/max31855/test.esp32-ard.yaml index 25fee986d2..54e027a614 100644 --- a/tests/components/max31855/test.esp32-ard.yaml +++ b/tests/components/max31855/test.esp32-ard.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31855 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: max31855 - name: MAX31855 Temperature - cs_pin: 12 - update_interval: 15s - reference_temperature: - name: MAX31855 Internal Temperature +<<: !include common.yaml diff --git a/tests/components/max31855/test.esp32-c3-ard.yaml b/tests/components/max31855/test.esp32-c3-ard.yaml index e7c8f3f824..2415ba5dc6 100644 --- a/tests/components/max31855/test.esp32-c3-ard.yaml +++ b/tests/components/max31855/test.esp32-c3-ard.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31855 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: max31855 - name: MAX31855 Temperature - cs_pin: 8 - update_interval: 15s - reference_temperature: - name: MAX31855 Internal Temperature +<<: !include common.yaml diff --git a/tests/components/max31855/test.esp32-c3-idf.yaml b/tests/components/max31855/test.esp32-c3-idf.yaml index e7c8f3f824..2415ba5dc6 100644 --- a/tests/components/max31855/test.esp32-c3-idf.yaml +++ b/tests/components/max31855/test.esp32-c3-idf.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31855 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: max31855 - name: MAX31855 Temperature - cs_pin: 8 - update_interval: 15s - reference_temperature: - name: MAX31855 Internal Temperature +<<: !include common.yaml diff --git a/tests/components/max31855/test.esp32-idf.yaml b/tests/components/max31855/test.esp32-idf.yaml index 25fee986d2..54e027a614 100644 --- a/tests/components/max31855/test.esp32-idf.yaml +++ b/tests/components/max31855/test.esp32-idf.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31855 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: max31855 - name: MAX31855 Temperature - cs_pin: 12 - update_interval: 15s - reference_temperature: - name: MAX31855 Internal Temperature +<<: !include common.yaml diff --git a/tests/components/max31855/test.esp8266-ard.yaml b/tests/components/max31855/test.esp8266-ard.yaml index 7e02d41fce..dbd158d030 100644 --- a/tests/components/max31855/test.esp8266-ard.yaml +++ b/tests/components/max31855/test.esp8266-ard.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31855 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -sensor: - - platform: max31855 - name: MAX31855 Temperature - cs_pin: 15 - update_interval: 15s - reference_temperature: - name: MAX31855 Internal Temperature +<<: !include common.yaml diff --git a/tests/components/max31855/test.rp2040-ard.yaml b/tests/components/max31855/test.rp2040-ard.yaml index 379d4d33d6..f6c3f1eeca 100644 --- a/tests/components/max31855/test.rp2040-ard.yaml +++ b/tests/components/max31855/test.rp2040-ard.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31855 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -sensor: - - platform: max31855 - name: MAX31855 Temperature - cs_pin: 6 - update_interval: 15s - reference_temperature: - name: MAX31855 Internal Temperature +<<: !include common.yaml diff --git a/tests/components/max31856/common.yaml b/tests/components/max31856/common.yaml new file mode 100644 index 0000000000..4f7c3ad408 --- /dev/null +++ b/tests/components/max31856/common.yaml @@ -0,0 +1,13 @@ +spi: + - id: spi_max31856 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sensor: + - platform: max31856 + name: MAX31856 Temperature + cs_pin: ${cs_pin} + update_interval: 15s + mains_filter: 50Hz + thermocouple_type: N diff --git a/tests/components/max31856/test.esp32-ard.yaml b/tests/components/max31856/test.esp32-ard.yaml index 9a4da6b2a2..54e027a614 100644 --- a/tests/components/max31856/test.esp32-ard.yaml +++ b/tests/components/max31856/test.esp32-ard.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31856 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: max31856 - name: MAX31856 Temperature - cs_pin: 12 - update_interval: 15s - mains_filter: 50Hz - thermocouple_type: N +<<: !include common.yaml diff --git a/tests/components/max31856/test.esp32-c3-ard.yaml b/tests/components/max31856/test.esp32-c3-ard.yaml index 71bbfffb7b..2415ba5dc6 100644 --- a/tests/components/max31856/test.esp32-c3-ard.yaml +++ b/tests/components/max31856/test.esp32-c3-ard.yaml @@ -1,14 +1,7 @@ -spi: - - id: spi_max31856 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 - -sensor: - - platform: max31856 - name: MAX31856 Temperature - cs_pin: 8 - update_interval: 15s - mains_filter: 50Hz - thermocouple_type: N +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 +<<: !include common.yaml diff --git a/tests/components/max31856/test.esp32-c3-idf.yaml b/tests/components/max31856/test.esp32-c3-idf.yaml index 71bbfffb7b..2415ba5dc6 100644 --- a/tests/components/max31856/test.esp32-c3-idf.yaml +++ b/tests/components/max31856/test.esp32-c3-idf.yaml @@ -1,14 +1,7 @@ -spi: - - id: spi_max31856 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 - -sensor: - - platform: max31856 - name: MAX31856 Temperature - cs_pin: 8 - update_interval: 15s - mains_filter: 50Hz - thermocouple_type: N +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 +<<: !include common.yaml diff --git a/tests/components/max31856/test.esp32-idf.yaml b/tests/components/max31856/test.esp32-idf.yaml index 9a4da6b2a2..54e027a614 100644 --- a/tests/components/max31856/test.esp32-idf.yaml +++ b/tests/components/max31856/test.esp32-idf.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31856 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: max31856 - name: MAX31856 Temperature - cs_pin: 12 - update_interval: 15s - mains_filter: 50Hz - thermocouple_type: N +<<: !include common.yaml diff --git a/tests/components/max31856/test.esp8266-ard.yaml b/tests/components/max31856/test.esp8266-ard.yaml index b9c42542fd..dbd158d030 100644 --- a/tests/components/max31856/test.esp8266-ard.yaml +++ b/tests/components/max31856/test.esp8266-ard.yaml @@ -1,14 +1,7 @@ -spi: - - id: spi_max31856 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 - -sensor: - - platform: max31856 - name: MAX31856 Temperature - cs_pin: 15 - update_interval: 15s - mains_filter: 50Hz - thermocouple_type: N +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 +<<: !include common.yaml diff --git a/tests/components/max31856/test.rp2040-ard.yaml b/tests/components/max31856/test.rp2040-ard.yaml index 8607eb18cf..f6c3f1eeca 100644 --- a/tests/components/max31856/test.rp2040-ard.yaml +++ b/tests/components/max31856/test.rp2040-ard.yaml @@ -1,14 +1,7 @@ -spi: - - id: spi_max31856 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 - -sensor: - - platform: max31856 - name: MAX31856 Temperature - cs_pin: 6 - update_interval: 15s - mains_filter: 50Hz - thermocouple_type: N +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 +<<: !include common.yaml diff --git a/tests/components/max31865/common.yaml b/tests/components/max31865/common.yaml new file mode 100644 index 0000000000..5bb7bda5aa --- /dev/null +++ b/tests/components/max31865/common.yaml @@ -0,0 +1,13 @@ +spi: + - id: spi_max31865 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sensor: + - platform: max31865 + name: MAX31865 Temperature + cs_pin: ${cs_pin} + update_interval: 15s + reference_resistance: 430 Ω + rtd_nominal_resistance: 100 Ω diff --git a/tests/components/max31865/test.esp32-ard.yaml b/tests/components/max31865/test.esp32-ard.yaml index 8326a578ee..54e027a614 100644 --- a/tests/components/max31865/test.esp32-ard.yaml +++ b/tests/components/max31865/test.esp32-ard.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31865 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: max31865 - name: MAX31865 Temperature - cs_pin: 12 - update_interval: 15s - reference_resistance: 430 Ω - rtd_nominal_resistance: 100 Ω +<<: !include common.yaml diff --git a/tests/components/max31865/test.esp32-c3-ard.yaml b/tests/components/max31865/test.esp32-c3-ard.yaml index 45de22331e..2415ba5dc6 100644 --- a/tests/components/max31865/test.esp32-c3-ard.yaml +++ b/tests/components/max31865/test.esp32-c3-ard.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31865 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: max31865 - name: MAX31865 Temperature - cs_pin: 8 - update_interval: 15s - reference_resistance: 430 Ω - rtd_nominal_resistance: 100 Ω +<<: !include common.yaml diff --git a/tests/components/max31865/test.esp32-c3-idf.yaml b/tests/components/max31865/test.esp32-c3-idf.yaml index 45de22331e..2415ba5dc6 100644 --- a/tests/components/max31865/test.esp32-c3-idf.yaml +++ b/tests/components/max31865/test.esp32-c3-idf.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31865 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: max31865 - name: MAX31865 Temperature - cs_pin: 8 - update_interval: 15s - reference_resistance: 430 Ω - rtd_nominal_resistance: 100 Ω +<<: !include common.yaml diff --git a/tests/components/max31865/test.esp32-idf.yaml b/tests/components/max31865/test.esp32-idf.yaml index 8326a578ee..54e027a614 100644 --- a/tests/components/max31865/test.esp32-idf.yaml +++ b/tests/components/max31865/test.esp32-idf.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31865 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: max31865 - name: MAX31865 Temperature - cs_pin: 12 - update_interval: 15s - reference_resistance: 430 Ω - rtd_nominal_resistance: 100 Ω +<<: !include common.yaml diff --git a/tests/components/max31865/test.esp8266-ard.yaml b/tests/components/max31865/test.esp8266-ard.yaml index 4828019acc..dbd158d030 100644 --- a/tests/components/max31865/test.esp8266-ard.yaml +++ b/tests/components/max31865/test.esp8266-ard.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31865 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -sensor: - - platform: max31865 - name: MAX31865 Temperature - cs_pin: 15 - update_interval: 15s - reference_resistance: 430 Ω - rtd_nominal_resistance: 100 Ω +<<: !include common.yaml diff --git a/tests/components/max31865/test.rp2040-ard.yaml b/tests/components/max31865/test.rp2040-ard.yaml index 5af64b41ad..f6c3f1eeca 100644 --- a/tests/components/max31865/test.rp2040-ard.yaml +++ b/tests/components/max31865/test.rp2040-ard.yaml @@ -1,13 +1,7 @@ -spi: - - id: spi_max31865 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -sensor: - - platform: max31865 - name: MAX31865 Temperature - cs_pin: 6 - update_interval: 15s - reference_resistance: 430 Ω - rtd_nominal_resistance: 100 Ω +<<: !include common.yaml diff --git a/tests/components/max44009/common.yaml b/tests/components/max44009/common.yaml new file mode 100644 index 0000000000..ef51740895 --- /dev/null +++ b/tests/components/max44009/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_max44009 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: max44009 + name: MAX44009 Brightness + internal: true + mode: low_power + address: 0x4A + update_interval: 30s diff --git a/tests/components/max44009/test.esp32-ard.yaml b/tests/components/max44009/test.esp32-ard.yaml index 56eecebc4a..63c3bd6afd 100644 --- a/tests/components/max44009/test.esp32-ard.yaml +++ b/tests/components/max44009/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_max44009 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: max44009 - name: MAX44009 Brightness - internal: true - mode: low_power - address: 0x4A - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/max44009/test.esp32-c3-ard.yaml b/tests/components/max44009/test.esp32-c3-ard.yaml index 593d4bd48c..ee2c29ca4e 100644 --- a/tests/components/max44009/test.esp32-c3-ard.yaml +++ b/tests/components/max44009/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_max44009 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: max44009 - name: MAX44009 Brightness - internal: true - mode: low_power - address: 0x4A - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/max44009/test.esp32-c3-idf.yaml b/tests/components/max44009/test.esp32-c3-idf.yaml index 593d4bd48c..ee2c29ca4e 100644 --- a/tests/components/max44009/test.esp32-c3-idf.yaml +++ b/tests/components/max44009/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_max44009 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: max44009 - name: MAX44009 Brightness - internal: true - mode: low_power - address: 0x4A - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/max44009/test.esp32-idf.yaml b/tests/components/max44009/test.esp32-idf.yaml index 56eecebc4a..63c3bd6afd 100644 --- a/tests/components/max44009/test.esp32-idf.yaml +++ b/tests/components/max44009/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_max44009 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: max44009 - name: MAX44009 Brightness - internal: true - mode: low_power - address: 0x4A - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/max44009/test.esp8266-ard.yaml b/tests/components/max44009/test.esp8266-ard.yaml index 593d4bd48c..ee2c29ca4e 100644 --- a/tests/components/max44009/test.esp8266-ard.yaml +++ b/tests/components/max44009/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_max44009 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: max44009 - name: MAX44009 Brightness - internal: true - mode: low_power - address: 0x4A - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/max44009/test.rp2040-ard.yaml b/tests/components/max44009/test.rp2040-ard.yaml index 593d4bd48c..ee2c29ca4e 100644 --- a/tests/components/max44009/test.rp2040-ard.yaml +++ b/tests/components/max44009/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_max44009 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: max44009 - name: MAX44009 Brightness - internal: true - mode: low_power - address: 0x4A - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/max6675/common.yaml b/tests/components/max6675/common.yaml new file mode 100644 index 0000000000..5b4e04b317 --- /dev/null +++ b/tests/components/max6675/common.yaml @@ -0,0 +1,11 @@ +spi: + - id: spi_max6675 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sensor: + - platform: max6675 + name: Temperature + cs_pin: ${cs_pin} + update_interval: 15s diff --git a/tests/components/max6675/test.esp32-ard.yaml b/tests/components/max6675/test.esp32-ard.yaml index 9771bf9d5f..54e027a614 100644 --- a/tests/components/max6675/test.esp32-ard.yaml +++ b/tests/components/max6675/test.esp32-ard.yaml @@ -1,11 +1,7 @@ -spi: - - id: spi_max6675 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: max6675 - name: Temperature - cs_pin: 12 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/max6675/test.esp32-c3-ard.yaml b/tests/components/max6675/test.esp32-c3-ard.yaml index 2f05102ca1..2415ba5dc6 100644 --- a/tests/components/max6675/test.esp32-c3-ard.yaml +++ b/tests/components/max6675/test.esp32-c3-ard.yaml @@ -1,11 +1,7 @@ -spi: - - id: spi_max6675 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: max6675 - name: Temperature - cs_pin: 8 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/max6675/test.esp32-c3-idf.yaml b/tests/components/max6675/test.esp32-c3-idf.yaml index 2f05102ca1..2415ba5dc6 100644 --- a/tests/components/max6675/test.esp32-c3-idf.yaml +++ b/tests/components/max6675/test.esp32-c3-idf.yaml @@ -1,11 +1,7 @@ -spi: - - id: spi_max6675 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -sensor: - - platform: max6675 - name: Temperature - cs_pin: 8 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/max6675/test.esp32-idf.yaml b/tests/components/max6675/test.esp32-idf.yaml index 9771bf9d5f..54e027a614 100644 --- a/tests/components/max6675/test.esp32-idf.yaml +++ b/tests/components/max6675/test.esp32-idf.yaml @@ -1,11 +1,7 @@ -spi: - - id: spi_max6675 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -sensor: - - platform: max6675 - name: Temperature - cs_pin: 12 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/max6675/test.esp8266-ard.yaml b/tests/components/max6675/test.esp8266-ard.yaml index f67e9e04a8..dbd158d030 100644 --- a/tests/components/max6675/test.esp8266-ard.yaml +++ b/tests/components/max6675/test.esp8266-ard.yaml @@ -1,11 +1,7 @@ -spi: - - id: spi_max6675 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -sensor: - - platform: max6675 - name: Temperature - cs_pin: 15 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/max6675/test.rp2040-ard.yaml b/tests/components/max6675/test.rp2040-ard.yaml index 89c0932f94..f6c3f1eeca 100644 --- a/tests/components/max6675/test.rp2040-ard.yaml +++ b/tests/components/max6675/test.rp2040-ard.yaml @@ -1,11 +1,7 @@ -spi: - - id: spi_max6675 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -sensor: - - platform: max6675 - name: Temperature - cs_pin: 6 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/max6956/common.yaml b/tests/components/max6956/common.yaml new file mode 100644 index 0000000000..e44e3464f8 --- /dev/null +++ b/tests/components/max6956/common.yaml @@ -0,0 +1,19 @@ +i2c: + - id: i2c_max6956 + scl: ${scl_pin} + sda: ${sda_pin} + +max6956: + - id: max6956_1 + address: 0x40 + +binary_sensor: + - platform: gpio + name: Max Input Pin + pin: + max6956: max6956_1 + number: 4 + mode: + input: true + pullup: true + inverted: false diff --git a/tests/components/max6956/test.esp32-ard.yaml b/tests/components/max6956/test.esp32-ard.yaml index abd1404634..63c3bd6afd 100644 --- a/tests/components/max6956/test.esp32-ard.yaml +++ b/tests/components/max6956/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_max6956 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -max6956: - - id: max6956_1 - address: 0x40 - -binary_sensor: - - platform: gpio - name: Max Input Pin 4 - pin: - max6956: max6956_1 - number: 4 - mode: - input: true - pullup: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/max6956/test.esp32-c3-ard.yaml b/tests/components/max6956/test.esp32-c3-ard.yaml index 690941784c..ee2c29ca4e 100644 --- a/tests/components/max6956/test.esp32-c3-ard.yaml +++ b/tests/components/max6956/test.esp32-c3-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_max6956 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -max6956: - - id: max6956_1 - address: 0x40 - -binary_sensor: - - platform: gpio - name: Max Input Pin 4 - pin: - max6956: max6956_1 - number: 4 - mode: - input: true - pullup: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/max6956/test.esp32-c3-idf.yaml b/tests/components/max6956/test.esp32-c3-idf.yaml index 690941784c..ee2c29ca4e 100644 --- a/tests/components/max6956/test.esp32-c3-idf.yaml +++ b/tests/components/max6956/test.esp32-c3-idf.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_max6956 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -max6956: - - id: max6956_1 - address: 0x40 - -binary_sensor: - - platform: gpio - name: Max Input Pin 4 - pin: - max6956: max6956_1 - number: 4 - mode: - input: true - pullup: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/max6956/test.esp32-idf.yaml b/tests/components/max6956/test.esp32-idf.yaml index abd1404634..63c3bd6afd 100644 --- a/tests/components/max6956/test.esp32-idf.yaml +++ b/tests/components/max6956/test.esp32-idf.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_max6956 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -max6956: - - id: max6956_1 - address: 0x40 - -binary_sensor: - - platform: gpio - name: Max Input Pin 4 - pin: - max6956: max6956_1 - number: 4 - mode: - input: true - pullup: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/max6956/test.esp8266-ard.yaml b/tests/components/max6956/test.esp8266-ard.yaml index 690941784c..ee2c29ca4e 100644 --- a/tests/components/max6956/test.esp8266-ard.yaml +++ b/tests/components/max6956/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_max6956 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -max6956: - - id: max6956_1 - address: 0x40 - -binary_sensor: - - platform: gpio - name: Max Input Pin 4 - pin: - max6956: max6956_1 - number: 4 - mode: - input: true - pullup: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/max6956/test.rp2040-ard.yaml b/tests/components/max6956/test.rp2040-ard.yaml index 690941784c..ee2c29ca4e 100644 --- a/tests/components/max6956/test.rp2040-ard.yaml +++ b/tests/components/max6956/test.rp2040-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_max6956 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -max6956: - - id: max6956_1 - address: 0x40 - -binary_sensor: - - platform: gpio - name: Max Input Pin 4 - pin: - max6956: max6956_1 - number: 4 - mode: - input: true - pullup: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/max7219/common.yaml b/tests/components/max7219/common.yaml new file mode 100644 index 0000000000..0060db191e --- /dev/null +++ b/tests/components/max7219/common.yaml @@ -0,0 +1,12 @@ +spi: + - id: spi_max6675 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +display: + - platform: max7219 + cs_pin: ${cs_pin} + num_chips: 1 + lambda: |- + it.print("01234567"); diff --git a/tests/components/max7219/test.esp32-ard.yaml b/tests/components/max7219/test.esp32-ard.yaml index 2985345a48..54e027a614 100644 --- a/tests/components/max7219/test.esp32-ard.yaml +++ b/tests/components/max7219/test.esp32-ard.yaml @@ -1,12 +1,7 @@ -spi: - - id: spi_max6675 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -display: - - platform: max7219 - cs_pin: 12 - num_chips: 1 - lambda: |- - it.print("01234567"); +<<: !include common.yaml diff --git a/tests/components/max7219/test.esp32-c3-ard.yaml b/tests/components/max7219/test.esp32-c3-ard.yaml index fa1ac15f33..2415ba5dc6 100644 --- a/tests/components/max7219/test.esp32-c3-ard.yaml +++ b/tests/components/max7219/test.esp32-c3-ard.yaml @@ -1,12 +1,7 @@ -spi: - - id: spi_max7219 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -display: - - platform: max7219 - cs_pin: 8 - num_chips: 1 - lambda: |- - it.print("01234567"); +<<: !include common.yaml diff --git a/tests/components/max7219/test.esp32-c3-idf.yaml b/tests/components/max7219/test.esp32-c3-idf.yaml index fa1ac15f33..2415ba5dc6 100644 --- a/tests/components/max7219/test.esp32-c3-idf.yaml +++ b/tests/components/max7219/test.esp32-c3-idf.yaml @@ -1,12 +1,7 @@ -spi: - - id: spi_max7219 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -display: - - platform: max7219 - cs_pin: 8 - num_chips: 1 - lambda: |- - it.print("01234567"); +<<: !include common.yaml diff --git a/tests/components/max7219/test.esp32-idf.yaml b/tests/components/max7219/test.esp32-idf.yaml index 2985345a48..54e027a614 100644 --- a/tests/components/max7219/test.esp32-idf.yaml +++ b/tests/components/max7219/test.esp32-idf.yaml @@ -1,12 +1,7 @@ -spi: - - id: spi_max6675 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -display: - - platform: max7219 - cs_pin: 12 - num_chips: 1 - lambda: |- - it.print("01234567"); +<<: !include common.yaml diff --git a/tests/components/max7219/test.esp8266-ard.yaml b/tests/components/max7219/test.esp8266-ard.yaml index a8c280daff..dbd158d030 100644 --- a/tests/components/max7219/test.esp8266-ard.yaml +++ b/tests/components/max7219/test.esp8266-ard.yaml @@ -1,12 +1,7 @@ -spi: - - id: spi_max6675 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -display: - - platform: max7219 - cs_pin: 15 - num_chips: 1 - lambda: |- - it.print("01234567"); +<<: !include common.yaml diff --git a/tests/components/max7219/test.rp2040-ard.yaml b/tests/components/max7219/test.rp2040-ard.yaml index 37b2220649..f6c3f1eeca 100644 --- a/tests/components/max7219/test.rp2040-ard.yaml +++ b/tests/components/max7219/test.rp2040-ard.yaml @@ -1,12 +1,7 @@ -spi: - - id: spi_max6675 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -display: - - platform: max7219 - cs_pin: 6 - num_chips: 1 - lambda: |- - it.print("01234567"); +<<: !include common.yaml diff --git a/tests/components/max7219digit/common.yaml b/tests/components/max7219digit/common.yaml new file mode 100644 index 0000000000..a5a3bd57fb --- /dev/null +++ b/tests/components/max7219digit/common.yaml @@ -0,0 +1,16 @@ +spi: + - id: spi_max7219digit + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +display: + - platform: max7219digit + cs_pin: ${cs_pin} + num_chips: 4 + rotate_chip: 0 + intensity: 10 + scroll_mode: STOP + id: my_matrix + lambda: |- + it.printdigit("hello"); diff --git a/tests/components/max7219digit/test.esp32-ard.yaml b/tests/components/max7219digit/test.esp32-ard.yaml index 7f3aed964a..54e027a614 100644 --- a/tests/components/max7219digit/test.esp32-ard.yaml +++ b/tests/components/max7219digit/test.esp32-ard.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_max7219digit - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -display: - - platform: max7219digit - cs_pin: 12 - num_chips: 4 - rotate_chip: 0 - intensity: 10 - scroll_mode: STOP - id: my_matrix - lambda: |- - it.printdigit("hello"); +<<: !include common.yaml diff --git a/tests/components/max7219digit/test.esp32-c3-ard.yaml b/tests/components/max7219digit/test.esp32-c3-ard.yaml index 0c04784380..2415ba5dc6 100644 --- a/tests/components/max7219digit/test.esp32-c3-ard.yaml +++ b/tests/components/max7219digit/test.esp32-c3-ard.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_max7219digit - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -display: - - platform: max7219digit - cs_pin: 8 - num_chips: 4 - rotate_chip: 0 - intensity: 10 - scroll_mode: STOP - id: my_matrix - lambda: |- - it.printdigit("hello"); +<<: !include common.yaml diff --git a/tests/components/max7219digit/test.esp32-c3-idf.yaml b/tests/components/max7219digit/test.esp32-c3-idf.yaml index 0c04784380..2415ba5dc6 100644 --- a/tests/components/max7219digit/test.esp32-c3-idf.yaml +++ b/tests/components/max7219digit/test.esp32-c3-idf.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_max7219digit - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -display: - - platform: max7219digit - cs_pin: 8 - num_chips: 4 - rotate_chip: 0 - intensity: 10 - scroll_mode: STOP - id: my_matrix - lambda: |- - it.printdigit("hello"); +<<: !include common.yaml diff --git a/tests/components/max7219digit/test.esp32-idf.yaml b/tests/components/max7219digit/test.esp32-idf.yaml index 7f3aed964a..54e027a614 100644 --- a/tests/components/max7219digit/test.esp32-idf.yaml +++ b/tests/components/max7219digit/test.esp32-idf.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_max7219digit - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -display: - - platform: max7219digit - cs_pin: 12 - num_chips: 4 - rotate_chip: 0 - intensity: 10 - scroll_mode: STOP - id: my_matrix - lambda: |- - it.printdigit("hello"); +<<: !include common.yaml diff --git a/tests/components/max7219digit/test.esp8266-ard.yaml b/tests/components/max7219digit/test.esp8266-ard.yaml index 52587e8b0e..dbd158d030 100644 --- a/tests/components/max7219digit/test.esp8266-ard.yaml +++ b/tests/components/max7219digit/test.esp8266-ard.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_max7219digit - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -display: - - platform: max7219digit - cs_pin: 15 - num_chips: 4 - rotate_chip: 0 - intensity: 10 - scroll_mode: STOP - id: my_matrix - lambda: |- - it.printdigit("hello"); +<<: !include common.yaml diff --git a/tests/components/max7219digit/test.rp2040-ard.yaml b/tests/components/max7219digit/test.rp2040-ard.yaml index f986483ec2..f6c3f1eeca 100644 --- a/tests/components/max7219digit/test.rp2040-ard.yaml +++ b/tests/components/max7219digit/test.rp2040-ard.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_max7219digit - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -display: - - platform: max7219digit - cs_pin: 6 - num_chips: 4 - rotate_chip: 0 - intensity: 10 - scroll_mode: STOP - id: my_matrix - lambda: |- - it.printdigit("hello"); +<<: !include common.yaml diff --git a/tests/components/max9611/common.yaml b/tests/components/max9611/common.yaml new file mode 100644 index 0000000000..c3c00fdf85 --- /dev/null +++ b/tests/components/max9611/common.yaml @@ -0,0 +1,18 @@ +i2c: + - id: i2c_max9611 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: max9611 + shunt_resistance: 0.2 ohm + gain: 1X + voltage: + name: Max9611 Voltage + current: + name: Max9611 Current + power: + name: Max9611 Watts + temperature: + name: Max9611 Temperature + update_interval: 1s diff --git a/tests/components/max9611/test.esp32-ard.yaml b/tests/components/max9611/test.esp32-ard.yaml index 5c480cc815..63c3bd6afd 100644 --- a/tests/components/max9611/test.esp32-ard.yaml +++ b/tests/components/max9611/test.esp32-ard.yaml @@ -1,18 +1,5 @@ -i2c: - - id: i2c_max9611 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: max9611 - shunt_resistance: 0.2 ohm - gain: 1X - voltage: - name: Max9611 Voltage - current: - name: Max9611 Current - power: - name: Max9611 Watts - temperature: - name: Max9611 Temp - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/max9611/test.esp32-c3-ard.yaml b/tests/components/max9611/test.esp32-c3-ard.yaml index 00f8330280..ee2c29ca4e 100644 --- a/tests/components/max9611/test.esp32-c3-ard.yaml +++ b/tests/components/max9611/test.esp32-c3-ard.yaml @@ -1,18 +1,5 @@ -i2c: - - id: i2c_max9611 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: max9611 - shunt_resistance: 0.2 ohm - gain: 1X - voltage: - name: Max9611 Voltage - current: - name: Max9611 Current - power: - name: Max9611 Watts - temperature: - name: Max9611 Temp - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/max9611/test.esp32-c3-idf.yaml b/tests/components/max9611/test.esp32-c3-idf.yaml index 00f8330280..ee2c29ca4e 100644 --- a/tests/components/max9611/test.esp32-c3-idf.yaml +++ b/tests/components/max9611/test.esp32-c3-idf.yaml @@ -1,18 +1,5 @@ -i2c: - - id: i2c_max9611 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: max9611 - shunt_resistance: 0.2 ohm - gain: 1X - voltage: - name: Max9611 Voltage - current: - name: Max9611 Current - power: - name: Max9611 Watts - temperature: - name: Max9611 Temp - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/max9611/test.esp32-idf.yaml b/tests/components/max9611/test.esp32-idf.yaml index 5c480cc815..63c3bd6afd 100644 --- a/tests/components/max9611/test.esp32-idf.yaml +++ b/tests/components/max9611/test.esp32-idf.yaml @@ -1,18 +1,5 @@ -i2c: - - id: i2c_max9611 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: max9611 - shunt_resistance: 0.2 ohm - gain: 1X - voltage: - name: Max9611 Voltage - current: - name: Max9611 Current - power: - name: Max9611 Watts - temperature: - name: Max9611 Temp - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/max9611/test.esp8266-ard.yaml b/tests/components/max9611/test.esp8266-ard.yaml index 00f8330280..ee2c29ca4e 100644 --- a/tests/components/max9611/test.esp8266-ard.yaml +++ b/tests/components/max9611/test.esp8266-ard.yaml @@ -1,18 +1,5 @@ -i2c: - - id: i2c_max9611 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: max9611 - shunt_resistance: 0.2 ohm - gain: 1X - voltage: - name: Max9611 Voltage - current: - name: Max9611 Current - power: - name: Max9611 Watts - temperature: - name: Max9611 Temp - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/max9611/test.rp2040-ard.yaml b/tests/components/max9611/test.rp2040-ard.yaml index 00f8330280..ee2c29ca4e 100644 --- a/tests/components/max9611/test.rp2040-ard.yaml +++ b/tests/components/max9611/test.rp2040-ard.yaml @@ -1,18 +1,5 @@ -i2c: - - id: i2c_max9611 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: max9611 - shunt_resistance: 0.2 ohm - gain: 1X - voltage: - name: Max9611 Voltage - current: - name: Max9611 Current - power: - name: Max9611 Watts - temperature: - name: Max9611 Temp - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/mcp23008/common.yaml b/tests/components/mcp23008/common.yaml new file mode 100644 index 0000000000..1954766d25 --- /dev/null +++ b/tests/components/mcp23008/common.yaml @@ -0,0 +1,23 @@ +i2c: + - id: i2c_mcp23008 + scl: ${scl_pin} + sda: ${sda_pin} + +mcp23008: + id: mcp23008_hub + +binary_sensor: + - platform: gpio + id: mcp23008_binary_sensor + pin: + mcp23xxx: mcp23008_hub + number: 0 + mode: INPUT + +switch: + - platform: gpio + id: mcp23008_switch + pin: + mcp23xxx: mcp23008_hub + number: 1 + mode: OUTPUT diff --git a/tests/components/mcp23008/test.esp32-ard.yaml b/tests/components/mcp23008/test.esp32-ard.yaml index cbf03f371c..63c3bd6afd 100644 --- a/tests/components/mcp23008/test.esp32-ard.yaml +++ b/tests/components/mcp23008/test.esp32-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23008 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -mcp23008: - id: mcp23008_hub - -binary_sensor: - - platform: gpio - id: mcp23008_binary_sensor - pin: - mcp23xxx: mcp23008_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23008_switch - pin: - mcp23xxx: mcp23008_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23008/test.esp32-c3-ard.yaml b/tests/components/mcp23008/test.esp32-c3-ard.yaml index eabd5a7311..ee2c29ca4e 100644 --- a/tests/components/mcp23008/test.esp32-c3-ard.yaml +++ b/tests/components/mcp23008/test.esp32-c3-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23008 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23008: - id: mcp23008_hub - -binary_sensor: - - platform: gpio - id: mcp23008_binary_sensor - pin: - mcp23xxx: mcp23008_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23008_switch - pin: - mcp23xxx: mcp23008_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23008/test.esp32-c3-idf.yaml b/tests/components/mcp23008/test.esp32-c3-idf.yaml index eabd5a7311..ee2c29ca4e 100644 --- a/tests/components/mcp23008/test.esp32-c3-idf.yaml +++ b/tests/components/mcp23008/test.esp32-c3-idf.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23008 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23008: - id: mcp23008_hub - -binary_sensor: - - platform: gpio - id: mcp23008_binary_sensor - pin: - mcp23xxx: mcp23008_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23008_switch - pin: - mcp23xxx: mcp23008_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23008/test.esp32-idf.yaml b/tests/components/mcp23008/test.esp32-idf.yaml index cbf03f371c..63c3bd6afd 100644 --- a/tests/components/mcp23008/test.esp32-idf.yaml +++ b/tests/components/mcp23008/test.esp32-idf.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23008 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -mcp23008: - id: mcp23008_hub - -binary_sensor: - - platform: gpio - id: mcp23008_binary_sensor - pin: - mcp23xxx: mcp23008_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23008_switch - pin: - mcp23xxx: mcp23008_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23008/test.esp8266-ard.yaml b/tests/components/mcp23008/test.esp8266-ard.yaml index eabd5a7311..ee2c29ca4e 100644 --- a/tests/components/mcp23008/test.esp8266-ard.yaml +++ b/tests/components/mcp23008/test.esp8266-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23008 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23008: - id: mcp23008_hub - -binary_sensor: - - platform: gpio - id: mcp23008_binary_sensor - pin: - mcp23xxx: mcp23008_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23008_switch - pin: - mcp23xxx: mcp23008_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23008/test.rp2040-ard.yaml b/tests/components/mcp23008/test.rp2040-ard.yaml index eabd5a7311..ee2c29ca4e 100644 --- a/tests/components/mcp23008/test.rp2040-ard.yaml +++ b/tests/components/mcp23008/test.rp2040-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23008 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23008: - id: mcp23008_hub - -binary_sensor: - - platform: gpio - id: mcp23008_binary_sensor - pin: - mcp23xxx: mcp23008_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23008_switch - pin: - mcp23xxx: mcp23008_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23016/common.yaml b/tests/components/mcp23016/common.yaml new file mode 100644 index 0000000000..109cb34b21 --- /dev/null +++ b/tests/components/mcp23016/common.yaml @@ -0,0 +1,23 @@ +i2c: + - id: i2c_mcp23016 + scl: ${scl_pin} + sda: ${sda_pin} + +mcp23016: + id: mcp23016_hub + +binary_sensor: + - platform: gpio + id: mcp23016_binary_sensor + pin: + mcp23016: mcp23016_hub + number: 0 + mode: INPUT + +switch: + - platform: gpio + id: mcp23016_switch + pin: + mcp23016: mcp23016_hub + number: 1 + mode: OUTPUT diff --git a/tests/components/mcp23016/test.esp32-ard.yaml b/tests/components/mcp23016/test.esp32-ard.yaml index 48574a9b01..63c3bd6afd 100644 --- a/tests/components/mcp23016/test.esp32-ard.yaml +++ b/tests/components/mcp23016/test.esp32-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23016 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -mcp23016: - id: mcp23016_hub - -binary_sensor: - - platform: gpio - id: mcp23016_binary_sensor - pin: - mcp23016: mcp23016_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23016_switch - pin: - mcp23016: mcp23016_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23016/test.esp32-c3-ard.yaml b/tests/components/mcp23016/test.esp32-c3-ard.yaml index 2211931e3d..ee2c29ca4e 100644 --- a/tests/components/mcp23016/test.esp32-c3-ard.yaml +++ b/tests/components/mcp23016/test.esp32-c3-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23016 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23016: - id: mcp23016_hub - -binary_sensor: - - platform: gpio - id: mcp23016_binary_sensor - pin: - mcp23016: mcp23016_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23016_switch - pin: - mcp23016: mcp23016_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23016/test.esp32-c3-idf.yaml b/tests/components/mcp23016/test.esp32-c3-idf.yaml index 2211931e3d..ee2c29ca4e 100644 --- a/tests/components/mcp23016/test.esp32-c3-idf.yaml +++ b/tests/components/mcp23016/test.esp32-c3-idf.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23016 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23016: - id: mcp23016_hub - -binary_sensor: - - platform: gpio - id: mcp23016_binary_sensor - pin: - mcp23016: mcp23016_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23016_switch - pin: - mcp23016: mcp23016_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23016/test.esp32-idf.yaml b/tests/components/mcp23016/test.esp32-idf.yaml index 48574a9b01..63c3bd6afd 100644 --- a/tests/components/mcp23016/test.esp32-idf.yaml +++ b/tests/components/mcp23016/test.esp32-idf.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23016 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -mcp23016: - id: mcp23016_hub - -binary_sensor: - - platform: gpio - id: mcp23016_binary_sensor - pin: - mcp23016: mcp23016_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23016_switch - pin: - mcp23016: mcp23016_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23016/test.esp8266-ard.yaml b/tests/components/mcp23016/test.esp8266-ard.yaml index 2211931e3d..ee2c29ca4e 100644 --- a/tests/components/mcp23016/test.esp8266-ard.yaml +++ b/tests/components/mcp23016/test.esp8266-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23016 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23016: - id: mcp23016_hub - -binary_sensor: - - platform: gpio - id: mcp23016_binary_sensor - pin: - mcp23016: mcp23016_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23016_switch - pin: - mcp23016: mcp23016_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23016/test.rp2040-ard.yaml b/tests/components/mcp23016/test.rp2040-ard.yaml index 2211931e3d..ee2c29ca4e 100644 --- a/tests/components/mcp23016/test.rp2040-ard.yaml +++ b/tests/components/mcp23016/test.rp2040-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23016 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23016: - id: mcp23016_hub - -binary_sensor: - - platform: gpio - id: mcp23016_binary_sensor - pin: - mcp23016: mcp23016_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23016_switch - pin: - mcp23016: mcp23016_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23017/common.yaml b/tests/components/mcp23017/common.yaml new file mode 100644 index 0000000000..74949bba76 --- /dev/null +++ b/tests/components/mcp23017/common.yaml @@ -0,0 +1,23 @@ +i2c: + - id: i2c_mcp23017 + scl: ${scl_pin} + sda: ${sda_pin} + +mcp23017: + id: mcp23017_hub + +binary_sensor: + - platform: gpio + id: mcp23017_binary_sensor + pin: + mcp23xxx: mcp23017_hub + number: 0 + mode: INPUT + +switch: + - platform: gpio + id: mcp23017_switch + pin: + mcp23xxx: mcp23017_hub + number: 1 + mode: OUTPUT diff --git a/tests/components/mcp23017/test.esp32-ard.yaml b/tests/components/mcp23017/test.esp32-ard.yaml index 9b7c45eb8a..63c3bd6afd 100644 --- a/tests/components/mcp23017/test.esp32-ard.yaml +++ b/tests/components/mcp23017/test.esp32-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23017 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -mcp23017: - id: mcp23017_hub - -binary_sensor: - - platform: gpio - id: mcp23017_binary_sensor - pin: - mcp23xxx: mcp23017_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23017_switch - pin: - mcp23xxx: mcp23017_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23017/test.esp32-c3-ard.yaml b/tests/components/mcp23017/test.esp32-c3-ard.yaml index 863b2b8f0b..ee2c29ca4e 100644 --- a/tests/components/mcp23017/test.esp32-c3-ard.yaml +++ b/tests/components/mcp23017/test.esp32-c3-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23017 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23017: - id: mcp23017_hub - -binary_sensor: - - platform: gpio - id: mcp23017_binary_sensor - pin: - mcp23xxx: mcp23017_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23017_switch - pin: - mcp23xxx: mcp23017_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23017/test.esp32-c3-idf.yaml b/tests/components/mcp23017/test.esp32-c3-idf.yaml index 863b2b8f0b..ee2c29ca4e 100644 --- a/tests/components/mcp23017/test.esp32-c3-idf.yaml +++ b/tests/components/mcp23017/test.esp32-c3-idf.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23017 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23017: - id: mcp23017_hub - -binary_sensor: - - platform: gpio - id: mcp23017_binary_sensor - pin: - mcp23xxx: mcp23017_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23017_switch - pin: - mcp23xxx: mcp23017_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23017/test.esp32-idf.yaml b/tests/components/mcp23017/test.esp32-idf.yaml index 9b7c45eb8a..63c3bd6afd 100644 --- a/tests/components/mcp23017/test.esp32-idf.yaml +++ b/tests/components/mcp23017/test.esp32-idf.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23017 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -mcp23017: - id: mcp23017_hub - -binary_sensor: - - platform: gpio - id: mcp23017_binary_sensor - pin: - mcp23xxx: mcp23017_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23017_switch - pin: - mcp23xxx: mcp23017_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23017/test.esp8266-ard.yaml b/tests/components/mcp23017/test.esp8266-ard.yaml index 863b2b8f0b..ee2c29ca4e 100644 --- a/tests/components/mcp23017/test.esp8266-ard.yaml +++ b/tests/components/mcp23017/test.esp8266-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23017 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23017: - id: mcp23017_hub - -binary_sensor: - - platform: gpio - id: mcp23017_binary_sensor - pin: - mcp23xxx: mcp23017_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23017_switch - pin: - mcp23xxx: mcp23017_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23017/test.rp2040-ard.yaml b/tests/components/mcp23017/test.rp2040-ard.yaml index 863b2b8f0b..ee2c29ca4e 100644 --- a/tests/components/mcp23017/test.rp2040-ard.yaml +++ b/tests/components/mcp23017/test.rp2040-ard.yaml @@ -1,23 +1,5 @@ -i2c: - - id: i2c_mcp23017 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp23017: - id: mcp23017_hub - -binary_sensor: - - platform: gpio - id: mcp23017_binary_sensor - pin: - mcp23xxx: mcp23017_hub - number: 0 - mode: INPUT - -switch: - - platform: gpio - id: mcp23017_switch - pin: - mcp23xxx: mcp23017_hub - number: 1 - mode: OUTPUT +<<: !include common.yaml diff --git a/tests/components/mcp23s08/common.yaml b/tests/components/mcp23s08/common.yaml new file mode 100644 index 0000000000..b89088fe15 --- /dev/null +++ b/tests/components/mcp23s08/common.yaml @@ -0,0 +1,10 @@ +spi: + - id: spi_mcp23s08 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +mcp23s08: + - id: mcp23s08_hub + cs_pin: ${cs_pin} + deviceaddress: 0 diff --git a/tests/components/mcp23s08/test.esp32-ard.yaml b/tests/components/mcp23s08/test.esp32-ard.yaml index 0b26035c3e..54e027a614 100644 --- a/tests/components/mcp23s08/test.esp32-ard.yaml +++ b/tests/components/mcp23s08/test.esp32-ard.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s08 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -mcp23s08: - - id: mcp23s08_hub - cs_pin: 12 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s08/test.esp32-c3-ard.yaml b/tests/components/mcp23s08/test.esp32-c3-ard.yaml index f1af8a71a9..2415ba5dc6 100644 --- a/tests/components/mcp23s08/test.esp32-c3-ard.yaml +++ b/tests/components/mcp23s08/test.esp32-c3-ard.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s08 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -mcp23s08: - - id: mcp23s08_hub - cs_pin: 8 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s08/test.esp32-c3-idf.yaml b/tests/components/mcp23s08/test.esp32-c3-idf.yaml index f1af8a71a9..2415ba5dc6 100644 --- a/tests/components/mcp23s08/test.esp32-c3-idf.yaml +++ b/tests/components/mcp23s08/test.esp32-c3-idf.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s08 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -mcp23s08: - - id: mcp23s08_hub - cs_pin: 8 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s08/test.esp32-idf.yaml b/tests/components/mcp23s08/test.esp32-idf.yaml index 0b26035c3e..54e027a614 100644 --- a/tests/components/mcp23s08/test.esp32-idf.yaml +++ b/tests/components/mcp23s08/test.esp32-idf.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s08 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -mcp23s08: - - id: mcp23s08_hub - cs_pin: 12 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s08/test.esp8266-ard.yaml b/tests/components/mcp23s08/test.esp8266-ard.yaml index eff856aca9..dbd158d030 100644 --- a/tests/components/mcp23s08/test.esp8266-ard.yaml +++ b/tests/components/mcp23s08/test.esp8266-ard.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s08 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -mcp23s08: - - id: mcp23s08_hub - cs_pin: 15 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s08/test.rp2040-ard.yaml b/tests/components/mcp23s08/test.rp2040-ard.yaml index 1b23d2d3b5..f6c3f1eeca 100644 --- a/tests/components/mcp23s08/test.rp2040-ard.yaml +++ b/tests/components/mcp23s08/test.rp2040-ard.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s08 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -mcp23s08: - - id: mcp23s08_hub - cs_pin: 6 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s17/common.yaml b/tests/components/mcp23s17/common.yaml new file mode 100644 index 0000000000..3fb27ef625 --- /dev/null +++ b/tests/components/mcp23s17/common.yaml @@ -0,0 +1,10 @@ +spi: + - id: spi_mcp23s17 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +mcp23s17: + - id: mcp23s17_hub + cs_pin: ${cs_pin} + deviceaddress: 0 diff --git a/tests/components/mcp23s17/test.esp32-ard.yaml b/tests/components/mcp23s17/test.esp32-ard.yaml index 9a42c12e85..54e027a614 100644 --- a/tests/components/mcp23s17/test.esp32-ard.yaml +++ b/tests/components/mcp23s17/test.esp32-ard.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s17 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -mcp23s17: - - id: mcp23s17_hub - cs_pin: 12 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s17/test.esp32-c3-ard.yaml b/tests/components/mcp23s17/test.esp32-c3-ard.yaml index d83f66d3b1..2415ba5dc6 100644 --- a/tests/components/mcp23s17/test.esp32-c3-ard.yaml +++ b/tests/components/mcp23s17/test.esp32-c3-ard.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s17 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -mcp23s17: - - id: mcp23s17_hub - cs_pin: 8 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s17/test.esp32-c3-idf.yaml b/tests/components/mcp23s17/test.esp32-c3-idf.yaml index d83f66d3b1..2415ba5dc6 100644 --- a/tests/components/mcp23s17/test.esp32-c3-idf.yaml +++ b/tests/components/mcp23s17/test.esp32-c3-idf.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s17 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -mcp23s17: - - id: mcp23s17_hub - cs_pin: 8 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s17/test.esp32-idf.yaml b/tests/components/mcp23s17/test.esp32-idf.yaml index 9a42c12e85..54e027a614 100644 --- a/tests/components/mcp23s17/test.esp32-idf.yaml +++ b/tests/components/mcp23s17/test.esp32-idf.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s17 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -mcp23s17: - - id: mcp23s17_hub - cs_pin: 12 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s17/test.esp8266-ard.yaml b/tests/components/mcp23s17/test.esp8266-ard.yaml index 36dac63f6f..dbd158d030 100644 --- a/tests/components/mcp23s17/test.esp8266-ard.yaml +++ b/tests/components/mcp23s17/test.esp8266-ard.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s17 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -mcp23s17: - - id: mcp23s17_hub - cs_pin: 15 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp23s17/test.rp2040-ard.yaml b/tests/components/mcp23s17/test.rp2040-ard.yaml index 2730f6a9d6..f6c3f1eeca 100644 --- a/tests/components/mcp23s17/test.rp2040-ard.yaml +++ b/tests/components/mcp23s17/test.rp2040-ard.yaml @@ -1,10 +1,7 @@ -spi: - - id: spi_mcp23s17 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -mcp23s17: - - id: mcp23s17_hub - cs_pin: 6 - deviceaddress: 0 +<<: !include common.yaml diff --git a/tests/components/mcp2515/common.yaml b/tests/components/mcp2515/common.yaml new file mode 100644 index 0000000000..96a72a3ec3 --- /dev/null +++ b/tests/components/mcp2515/common.yaml @@ -0,0 +1,44 @@ +spi: + - id: spi_mcp2515 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +canbus: + - platform: mcp2515 + id: mcp2515_can + cs_pin: ${cs_pin} + can_id: 4 + bit_rate: 50kbps + on_frame: + - can_id: 500 + then: + - lambda: |- + std::string b(x.begin(), x.end()); + ESP_LOGD("can_id 500", "%s", b.c_str()); + - can_id: 23 + then: + - if: + condition: + lambda: "return x[0] == 0x11;" + then: + logger.log: "x[0] == 0x11" + - can_id: 0b00000000000000000000001000000 + can_id_mask: 0b11111000000000011111111000000 + use_extended_id: true + then: + - lambda: |- + auto pdo_id = can_id >> 14; + switch (pdo_id) + { + case 117: + ESP_LOGD("canbus", "exhaust_fan_duty"); + break; + case 118: + ESP_LOGD("canbus", "supply_fan_duty"); + break; + case 119: + ESP_LOGD("canbus", "supply_fan_flow"); + break; + // to be continued... + } diff --git a/tests/components/mcp2515/test.esp32-ard.yaml b/tests/components/mcp2515/test.esp32-ard.yaml index 07fae36cc3..54e027a614 100644 --- a/tests/components/mcp2515/test.esp32-ard.yaml +++ b/tests/components/mcp2515/test.esp32-ard.yaml @@ -1,44 +1,7 @@ -spi: - - id: spi_mcp2515 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -canbus: - - platform: mcp2515 - id: mcp2515_can - cs_pin: 12 - can_id: 4 - bit_rate: 50kbps - on_frame: - - can_id: 500 - then: - - lambda: |- - std::string b(x.begin(), x.end()); - ESP_LOGD("can_id 500", "%s", b.c_str()); - - can_id: 23 - then: - - if: - condition: - lambda: "return x[0] == 0x11;" - then: - logger.log: "x[0] == 0x11" - - can_id: 0b00000000000000000000001000000 - can_id_mask: 0b11111000000000011111111000000 - use_extended_id: true - then: - - lambda: |- - auto pdo_id = can_id >> 14; - switch (pdo_id) - { - case 117: - ESP_LOGD("canbus", "exhaust_fan_duty"); - break; - case 118: - ESP_LOGD("canbus", "supply_fan_duty"); - break; - case 119: - ESP_LOGD("canbus", "supply_fan_flow"); - break; - // to be continued... - } +<<: !include common.yaml diff --git a/tests/components/mcp2515/test.esp32-c3-ard.yaml b/tests/components/mcp2515/test.esp32-c3-ard.yaml index 3ceeea268f..2415ba5dc6 100644 --- a/tests/components/mcp2515/test.esp32-c3-ard.yaml +++ b/tests/components/mcp2515/test.esp32-c3-ard.yaml @@ -1,44 +1,7 @@ -spi: - - id: spi_mcp2515 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -canbus: - - platform: mcp2515 - id: mcp2515_can - cs_pin: 8 - can_id: 4 - bit_rate: 50kbps - on_frame: - - can_id: 500 - then: - - lambda: |- - std::string b(x.begin(), x.end()); - ESP_LOGD("can_id 500", "%s", b.c_str()); - - can_id: 23 - then: - - if: - condition: - lambda: "return x[0] == 0x11;" - then: - logger.log: "x[0] == 0x11" - - can_id: 0b00000000000000000000001000000 - can_id_mask: 0b11111000000000011111111000000 - use_extended_id: true - then: - - lambda: |- - auto pdo_id = can_id >> 14; - switch (pdo_id) - { - case 117: - ESP_LOGD("canbus", "exhaust_fan_duty"); - break; - case 118: - ESP_LOGD("canbus", "supply_fan_duty"); - break; - case 119: - ESP_LOGD("canbus", "supply_fan_flow"); - break; - // to be continued... - } +<<: !include common.yaml diff --git a/tests/components/mcp2515/test.esp32-c3-idf.yaml b/tests/components/mcp2515/test.esp32-c3-idf.yaml index 3ceeea268f..2415ba5dc6 100644 --- a/tests/components/mcp2515/test.esp32-c3-idf.yaml +++ b/tests/components/mcp2515/test.esp32-c3-idf.yaml @@ -1,44 +1,7 @@ -spi: - - id: spi_mcp2515 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -canbus: - - platform: mcp2515 - id: mcp2515_can - cs_pin: 8 - can_id: 4 - bit_rate: 50kbps - on_frame: - - can_id: 500 - then: - - lambda: |- - std::string b(x.begin(), x.end()); - ESP_LOGD("can_id 500", "%s", b.c_str()); - - can_id: 23 - then: - - if: - condition: - lambda: "return x[0] == 0x11;" - then: - logger.log: "x[0] == 0x11" - - can_id: 0b00000000000000000000001000000 - can_id_mask: 0b11111000000000011111111000000 - use_extended_id: true - then: - - lambda: |- - auto pdo_id = can_id >> 14; - switch (pdo_id) - { - case 117: - ESP_LOGD("canbus", "exhaust_fan_duty"); - break; - case 118: - ESP_LOGD("canbus", "supply_fan_duty"); - break; - case 119: - ESP_LOGD("canbus", "supply_fan_flow"); - break; - // to be continued... - } +<<: !include common.yaml diff --git a/tests/components/mcp2515/test.esp32-idf.yaml b/tests/components/mcp2515/test.esp32-idf.yaml index 07fae36cc3..54e027a614 100644 --- a/tests/components/mcp2515/test.esp32-idf.yaml +++ b/tests/components/mcp2515/test.esp32-idf.yaml @@ -1,44 +1,7 @@ -spi: - - id: spi_mcp2515 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -canbus: - - platform: mcp2515 - id: mcp2515_can - cs_pin: 12 - can_id: 4 - bit_rate: 50kbps - on_frame: - - can_id: 500 - then: - - lambda: |- - std::string b(x.begin(), x.end()); - ESP_LOGD("can_id 500", "%s", b.c_str()); - - can_id: 23 - then: - - if: - condition: - lambda: "return x[0] == 0x11;" - then: - logger.log: "x[0] == 0x11" - - can_id: 0b00000000000000000000001000000 - can_id_mask: 0b11111000000000011111111000000 - use_extended_id: true - then: - - lambda: |- - auto pdo_id = can_id >> 14; - switch (pdo_id) - { - case 117: - ESP_LOGD("canbus", "exhaust_fan_duty"); - break; - case 118: - ESP_LOGD("canbus", "supply_fan_duty"); - break; - case 119: - ESP_LOGD("canbus", "supply_fan_flow"); - break; - // to be continued... - } +<<: !include common.yaml diff --git a/tests/components/mcp2515/test.esp8266-ard.yaml b/tests/components/mcp2515/test.esp8266-ard.yaml index 1096a0e809..dbd158d030 100644 --- a/tests/components/mcp2515/test.esp8266-ard.yaml +++ b/tests/components/mcp2515/test.esp8266-ard.yaml @@ -1,44 +1,7 @@ -spi: - - id: spi_mcp2515 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -canbus: - - platform: mcp2515 - id: mcp2515_can - cs_pin: 15 - can_id: 4 - bit_rate: 50kbps - on_frame: - - can_id: 500 - then: - - lambda: |- - std::string b(x.begin(), x.end()); - ESP_LOGD("can_id 500", "%s", b.c_str()); - - can_id: 23 - then: - - if: - condition: - lambda: "return x[0] == 0x11;" - then: - logger.log: "x[0] == 0x11" - - can_id: 0b00000000000000000000001000000 - can_id_mask: 0b11111000000000011111111000000 - use_extended_id: true - then: - - lambda: |- - auto pdo_id = can_id >> 14; - switch (pdo_id) - { - case 117: - ESP_LOGD("canbus", "exhaust_fan_duty"); - break; - case 118: - ESP_LOGD("canbus", "supply_fan_duty"); - break; - case 119: - ESP_LOGD("canbus", "supply_fan_flow"); - break; - // to be continued... - } +<<: !include common.yaml diff --git a/tests/components/mcp2515/test.rp2040-ard.yaml b/tests/components/mcp2515/test.rp2040-ard.yaml index 678c817d3d..f6c3f1eeca 100644 --- a/tests/components/mcp2515/test.rp2040-ard.yaml +++ b/tests/components/mcp2515/test.rp2040-ard.yaml @@ -1,44 +1,7 @@ -spi: - - id: spi_mcp2515 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -canbus: - - platform: mcp2515 - id: mcp2515_can - cs_pin: 6 - can_id: 4 - bit_rate: 50kbps - on_frame: - - can_id: 500 - then: - - lambda: |- - std::string b(x.begin(), x.end()); - ESP_LOGD("can_id 500", "%s", b.c_str()); - - can_id: 23 - then: - - if: - condition: - lambda: "return x[0] == 0x11;" - then: - logger.log: "x[0] == 0x11" - - can_id: 0b00000000000000000000001000000 - can_id_mask: 0b11111000000000011111111000000 - use_extended_id: true - then: - - lambda: |- - auto pdo_id = can_id >> 14; - switch (pdo_id) - { - case 117: - ESP_LOGD("canbus", "exhaust_fan_duty"); - break; - case 118: - ESP_LOGD("canbus", "supply_fan_duty"); - break; - case 119: - ESP_LOGD("canbus", "supply_fan_flow"); - break; - // to be continued... - } +<<: !include common.yaml diff --git a/tests/components/mcp3008/common.yaml b/tests/components/mcp3008/common.yaml new file mode 100644 index 0000000000..646d3a20e9 --- /dev/null +++ b/tests/components/mcp3008/common.yaml @@ -0,0 +1,17 @@ +spi: + - id: spi_mcp3008 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +mcp3008: + - id: mcp3008_hub + cs_pin: ${cs_pin} + +sensor: + - platform: mcp3008 + id: mcp3008_sensor + mcp3008_id: mcp3008_hub + number: 0 + reference_voltage: 3.19 + update_interval: 5s diff --git a/tests/components/mcp3008/test.esp32-ard.yaml b/tests/components/mcp3008/test.esp32-ard.yaml index a66fbeb7a1..54e027a614 100644 --- a/tests/components/mcp3008/test.esp32-ard.yaml +++ b/tests/components/mcp3008/test.esp32-ard.yaml @@ -1,17 +1,7 @@ -spi: - - id: spi_mcp3008 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -mcp3008: - - id: mcp3008_hub - cs_pin: 12 - -sensor: - - platform: mcp3008 - id: mcp3008_sensor - mcp3008_id: mcp3008_hub - number: 0 - reference_voltage: 3.19 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3008/test.esp32-c3-ard.yaml b/tests/components/mcp3008/test.esp32-c3-ard.yaml index 9e66372e4f..2415ba5dc6 100644 --- a/tests/components/mcp3008/test.esp32-c3-ard.yaml +++ b/tests/components/mcp3008/test.esp32-c3-ard.yaml @@ -1,17 +1,7 @@ -spi: - - id: spi_mcp3008 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -mcp3008: - - id: mcp3008_hub - cs_pin: 8 - -sensor: - - platform: mcp3008 - id: mcp3008_sensor - mcp3008_id: mcp3008_hub - number: 0 - reference_voltage: 3.19 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3008/test.esp32-c3-idf.yaml b/tests/components/mcp3008/test.esp32-c3-idf.yaml index 9e66372e4f..2415ba5dc6 100644 --- a/tests/components/mcp3008/test.esp32-c3-idf.yaml +++ b/tests/components/mcp3008/test.esp32-c3-idf.yaml @@ -1,17 +1,7 @@ -spi: - - id: spi_mcp3008 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -mcp3008: - - id: mcp3008_hub - cs_pin: 8 - -sensor: - - platform: mcp3008 - id: mcp3008_sensor - mcp3008_id: mcp3008_hub - number: 0 - reference_voltage: 3.19 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3008/test.esp32-idf.yaml b/tests/components/mcp3008/test.esp32-idf.yaml index a66fbeb7a1..54e027a614 100644 --- a/tests/components/mcp3008/test.esp32-idf.yaml +++ b/tests/components/mcp3008/test.esp32-idf.yaml @@ -1,17 +1,7 @@ -spi: - - id: spi_mcp3008 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -mcp3008: - - id: mcp3008_hub - cs_pin: 12 - -sensor: - - platform: mcp3008 - id: mcp3008_sensor - mcp3008_id: mcp3008_hub - number: 0 - reference_voltage: 3.19 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3008/test.esp8266-ard.yaml b/tests/components/mcp3008/test.esp8266-ard.yaml index eaccca0765..dbd158d030 100644 --- a/tests/components/mcp3008/test.esp8266-ard.yaml +++ b/tests/components/mcp3008/test.esp8266-ard.yaml @@ -1,17 +1,7 @@ -spi: - - id: spi_mcp3008 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -mcp3008: - - id: mcp3008_hub - cs_pin: 15 - -sensor: - - platform: mcp3008 - id: mcp3008_sensor - mcp3008_id: mcp3008_hub - number: 0 - reference_voltage: 3.19 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3008/test.rp2040-ard.yaml b/tests/components/mcp3008/test.rp2040-ard.yaml index 8ab9630553..f6c3f1eeca 100644 --- a/tests/components/mcp3008/test.rp2040-ard.yaml +++ b/tests/components/mcp3008/test.rp2040-ard.yaml @@ -1,17 +1,7 @@ -spi: - - id: spi_mcp3008 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -mcp3008: - - id: mcp3008_hub - cs_pin: 6 - -sensor: - - platform: mcp3008 - id: mcp3008_sensor - mcp3008_id: mcp3008_hub - number: 0 - reference_voltage: 3.19 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3204/common.yaml b/tests/components/mcp3204/common.yaml new file mode 100644 index 0000000000..f102500c81 --- /dev/null +++ b/tests/components/mcp3204/common.yaml @@ -0,0 +1,16 @@ +spi: + - id: spi_mcp3204 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +mcp3204: + - id: mcp3204_hub + cs_pin: ${cs_pin} + +sensor: + - platform: mcp3204 + id: mcp3204_sensor + mcp3204_id: mcp3204_hub + number: 0 + update_interval: 5s diff --git a/tests/components/mcp3204/test.esp32-ard.yaml b/tests/components/mcp3204/test.esp32-ard.yaml index c340797c8e..54e027a614 100644 --- a/tests/components/mcp3204/test.esp32-ard.yaml +++ b/tests/components/mcp3204/test.esp32-ard.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_mcp3204 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -mcp3204: - - id: mcp3204_hub - cs_pin: 12 - -sensor: - - platform: mcp3204 - id: mcp3204_sensor - mcp3204_id: mcp3204_hub - number: 0 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3204/test.esp32-c3-ard.yaml b/tests/components/mcp3204/test.esp32-c3-ard.yaml index 5bf5ba81e1..2415ba5dc6 100644 --- a/tests/components/mcp3204/test.esp32-c3-ard.yaml +++ b/tests/components/mcp3204/test.esp32-c3-ard.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_mcp3204 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -mcp3204: - - id: mcp3204_hub - cs_pin: 8 - -sensor: - - platform: mcp3204 - id: mcp3204_sensor - mcp3204_id: mcp3204_hub - number: 0 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3204/test.esp32-c3-idf.yaml b/tests/components/mcp3204/test.esp32-c3-idf.yaml index 5bf5ba81e1..2415ba5dc6 100644 --- a/tests/components/mcp3204/test.esp32-c3-idf.yaml +++ b/tests/components/mcp3204/test.esp32-c3-idf.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_mcp3204 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -mcp3204: - - id: mcp3204_hub - cs_pin: 8 - -sensor: - - platform: mcp3204 - id: mcp3204_sensor - mcp3204_id: mcp3204_hub - number: 0 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3204/test.esp32-idf.yaml b/tests/components/mcp3204/test.esp32-idf.yaml index c340797c8e..54e027a614 100644 --- a/tests/components/mcp3204/test.esp32-idf.yaml +++ b/tests/components/mcp3204/test.esp32-idf.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_mcp3204 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -mcp3204: - - id: mcp3204_hub - cs_pin: 12 - -sensor: - - platform: mcp3204 - id: mcp3204_sensor - mcp3204_id: mcp3204_hub - number: 0 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3204/test.esp8266-ard.yaml b/tests/components/mcp3204/test.esp8266-ard.yaml index d208e3e06c..dbd158d030 100644 --- a/tests/components/mcp3204/test.esp8266-ard.yaml +++ b/tests/components/mcp3204/test.esp8266-ard.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_mcp3204 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -mcp3204: - - id: mcp3204_hub - cs_pin: 15 - -sensor: - - platform: mcp3204 - id: mcp3204_sensor - mcp3204_id: mcp3204_hub - number: 0 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp3204/test.rp2040-ard.yaml b/tests/components/mcp3204/test.rp2040-ard.yaml index 63f30e3621..f6c3f1eeca 100644 --- a/tests/components/mcp3204/test.rp2040-ard.yaml +++ b/tests/components/mcp3204/test.rp2040-ard.yaml @@ -1,16 +1,7 @@ -spi: - - id: spi_mcp3204 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -mcp3204: - - id: mcp3204_hub - cs_pin: 6 - -sensor: - - platform: mcp3204 - id: mcp3204_sensor - mcp3204_id: mcp3204_hub - number: 0 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/mcp4725/common.yaml b/tests/components/mcp4725/common.yaml new file mode 100644 index 0000000000..0ccc649f2e --- /dev/null +++ b/tests/components/mcp4725/common.yaml @@ -0,0 +1,8 @@ +i2c: + - id: i2c_mcp4725 + scl: ${scl_pin} + sda: ${sda_pin} + +output: + - platform: mcp4725 + id: mcp4725_dac_output diff --git a/tests/components/mcp4725/test.esp32-ard.yaml b/tests/components/mcp4725/test.esp32-ard.yaml index a523ad95e1..63c3bd6afd 100644 --- a/tests/components/mcp4725/test.esp32-ard.yaml +++ b/tests/components/mcp4725/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp4725 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -output: - - platform: mcp4725 - id: mcp4725_dac_output +<<: !include common.yaml diff --git a/tests/components/mcp4725/test.esp32-c3-ard.yaml b/tests/components/mcp4725/test.esp32-c3-ard.yaml index 5fc799203d..ee2c29ca4e 100644 --- a/tests/components/mcp4725/test.esp32-c3-ard.yaml +++ b/tests/components/mcp4725/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp4725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -output: - - platform: mcp4725 - id: mcp4725_dac_output +<<: !include common.yaml diff --git a/tests/components/mcp4725/test.esp32-c3-idf.yaml b/tests/components/mcp4725/test.esp32-c3-idf.yaml index 5fc799203d..ee2c29ca4e 100644 --- a/tests/components/mcp4725/test.esp32-c3-idf.yaml +++ b/tests/components/mcp4725/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp4725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -output: - - platform: mcp4725 - id: mcp4725_dac_output +<<: !include common.yaml diff --git a/tests/components/mcp4725/test.esp32-idf.yaml b/tests/components/mcp4725/test.esp32-idf.yaml index a523ad95e1..63c3bd6afd 100644 --- a/tests/components/mcp4725/test.esp32-idf.yaml +++ b/tests/components/mcp4725/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp4725 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -output: - - platform: mcp4725 - id: mcp4725_dac_output +<<: !include common.yaml diff --git a/tests/components/mcp4725/test.esp8266-ard.yaml b/tests/components/mcp4725/test.esp8266-ard.yaml index 5fc799203d..ee2c29ca4e 100644 --- a/tests/components/mcp4725/test.esp8266-ard.yaml +++ b/tests/components/mcp4725/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp4725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -output: - - platform: mcp4725 - id: mcp4725_dac_output +<<: !include common.yaml diff --git a/tests/components/mcp4725/test.rp2040-ard.yaml b/tests/components/mcp4725/test.rp2040-ard.yaml index 5fc799203d..ee2c29ca4e 100644 --- a/tests/components/mcp4725/test.rp2040-ard.yaml +++ b/tests/components/mcp4725/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp4725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -output: - - platform: mcp4725 - id: mcp4725_dac_output +<<: !include common.yaml diff --git a/tests/components/mcp4728/common.yaml b/tests/components/mcp4728/common.yaml new file mode 100644 index 0000000000..b42818e4e6 --- /dev/null +++ b/tests/components/mcp4728/common.yaml @@ -0,0 +1,31 @@ +i2c: + - id: i2c_mcp4728 + scl: ${scl_pin} + sda: ${sda_pin} + +mcp4728: + - id: mcp4728_dac + +output: + - platform: mcp4728 + id: mcp4728_dac_output_a + channel: A + vref: vdd + power_down: normal + - platform: mcp4728 + id: mcp4728_dac_output_b + channel: B + vref: internal + gain: X1 + power_down: gnd_1k + - platform: mcp4728 + id: mcp4728_dac_output_c + channel: C + vref: vdd + power_down: gnd_100k + - platform: mcp4728 + id: mcp4728_dac_output_d + channel: D + vref: internal + gain: X2 + power_down: gnd_500k diff --git a/tests/components/mcp4728/test.esp32-ard.yaml b/tests/components/mcp4728/test.esp32-ard.yaml index b29a6ee53c..63c3bd6afd 100644 --- a/tests/components/mcp4728/test.esp32-ard.yaml +++ b/tests/components/mcp4728/test.esp32-ard.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_mcp4728 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -mcp4728: - - id: mcp4728_dac - -output: - - platform: mcp4728 - id: mcp4728_dac_output_a - channel: A - vref: vdd - power_down: normal - - platform: mcp4728 - id: mcp4728_dac_output_b - channel: B - vref: internal - gain: X1 - power_down: gnd_1k - - platform: mcp4728 - id: mcp4728_dac_output_c - channel: C - vref: vdd - power_down: gnd_100k - - platform: mcp4728 - id: mcp4728_dac_output_d - channel: D - vref: internal - gain: X2 - power_down: gnd_500k +<<: !include common.yaml diff --git a/tests/components/mcp4728/test.esp32-c3-ard.yaml b/tests/components/mcp4728/test.esp32-c3-ard.yaml index 2f24dd0b8c..ee2c29ca4e 100644 --- a/tests/components/mcp4728/test.esp32-c3-ard.yaml +++ b/tests/components/mcp4728/test.esp32-c3-ard.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_mcp4728 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp4728: - - id: mcp4728_dac - -output: - - platform: mcp4728 - id: mcp4728_dac_output_a - channel: A - vref: vdd - power_down: normal - - platform: mcp4728 - id: mcp4728_dac_output_b - channel: B - vref: internal - gain: X1 - power_down: gnd_1k - - platform: mcp4728 - id: mcp4728_dac_output_c - channel: C - vref: vdd - power_down: gnd_100k - - platform: mcp4728 - id: mcp4728_dac_output_d - channel: D - vref: internal - gain: X2 - power_down: gnd_500k +<<: !include common.yaml diff --git a/tests/components/mcp4728/test.esp32-c3-idf.yaml b/tests/components/mcp4728/test.esp32-c3-idf.yaml index 2f24dd0b8c..ee2c29ca4e 100644 --- a/tests/components/mcp4728/test.esp32-c3-idf.yaml +++ b/tests/components/mcp4728/test.esp32-c3-idf.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_mcp4728 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp4728: - - id: mcp4728_dac - -output: - - platform: mcp4728 - id: mcp4728_dac_output_a - channel: A - vref: vdd - power_down: normal - - platform: mcp4728 - id: mcp4728_dac_output_b - channel: B - vref: internal - gain: X1 - power_down: gnd_1k - - platform: mcp4728 - id: mcp4728_dac_output_c - channel: C - vref: vdd - power_down: gnd_100k - - platform: mcp4728 - id: mcp4728_dac_output_d - channel: D - vref: internal - gain: X2 - power_down: gnd_500k +<<: !include common.yaml diff --git a/tests/components/mcp4728/test.esp32-idf.yaml b/tests/components/mcp4728/test.esp32-idf.yaml index b29a6ee53c..63c3bd6afd 100644 --- a/tests/components/mcp4728/test.esp32-idf.yaml +++ b/tests/components/mcp4728/test.esp32-idf.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_mcp4728 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -mcp4728: - - id: mcp4728_dac - -output: - - platform: mcp4728 - id: mcp4728_dac_output_a - channel: A - vref: vdd - power_down: normal - - platform: mcp4728 - id: mcp4728_dac_output_b - channel: B - vref: internal - gain: X1 - power_down: gnd_1k - - platform: mcp4728 - id: mcp4728_dac_output_c - channel: C - vref: vdd - power_down: gnd_100k - - platform: mcp4728 - id: mcp4728_dac_output_d - channel: D - vref: internal - gain: X2 - power_down: gnd_500k +<<: !include common.yaml diff --git a/tests/components/mcp4728/test.esp8266-ard.yaml b/tests/components/mcp4728/test.esp8266-ard.yaml index 2f24dd0b8c..ee2c29ca4e 100644 --- a/tests/components/mcp4728/test.esp8266-ard.yaml +++ b/tests/components/mcp4728/test.esp8266-ard.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_mcp4728 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp4728: - - id: mcp4728_dac - -output: - - platform: mcp4728 - id: mcp4728_dac_output_a - channel: A - vref: vdd - power_down: normal - - platform: mcp4728 - id: mcp4728_dac_output_b - channel: B - vref: internal - gain: X1 - power_down: gnd_1k - - platform: mcp4728 - id: mcp4728_dac_output_c - channel: C - vref: vdd - power_down: gnd_100k - - platform: mcp4728 - id: mcp4728_dac_output_d - channel: D - vref: internal - gain: X2 - power_down: gnd_500k +<<: !include common.yaml diff --git a/tests/components/mcp4728/test.rp2040-ard.yaml b/tests/components/mcp4728/test.rp2040-ard.yaml index 2f24dd0b8c..ee2c29ca4e 100644 --- a/tests/components/mcp4728/test.rp2040-ard.yaml +++ b/tests/components/mcp4728/test.rp2040-ard.yaml @@ -1,31 +1,5 @@ -i2c: - - id: i2c_mcp4728 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -mcp4728: - - id: mcp4728_dac - -output: - - platform: mcp4728 - id: mcp4728_dac_output_a - channel: A - vref: vdd - power_down: normal - - platform: mcp4728 - id: mcp4728_dac_output_b - channel: B - vref: internal - gain: X1 - power_down: gnd_1k - - platform: mcp4728 - id: mcp4728_dac_output_c - channel: C - vref: vdd - power_down: gnd_100k - - platform: mcp4728 - id: mcp4728_dac_output_d - channel: D - vref: internal - gain: X2 - power_down: gnd_500k +<<: !include common.yaml diff --git a/tests/components/mcp47a1/common.yaml b/tests/components/mcp47a1/common.yaml new file mode 100644 index 0000000000..59e28d37b3 --- /dev/null +++ b/tests/components/mcp47a1/common.yaml @@ -0,0 +1,8 @@ +i2c: + - id: i2c_mcp47a1 + scl: ${scl_pin} + sda: ${sda_pin} + +output: + - platform: mcp47a1 + id: output_mcp47a1 diff --git a/tests/components/mcp47a1/test.esp32-ard.yaml b/tests/components/mcp47a1/test.esp32-ard.yaml index 9e2133de66..63c3bd6afd 100644 --- a/tests/components/mcp47a1/test.esp32-ard.yaml +++ b/tests/components/mcp47a1/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp47a1 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -output: - - platform: mcp47a1 - id: output_mcp47a1 +<<: !include common.yaml diff --git a/tests/components/mcp47a1/test.esp32-c3-ard.yaml b/tests/components/mcp47a1/test.esp32-c3-ard.yaml index 68273e00eb..ee2c29ca4e 100644 --- a/tests/components/mcp47a1/test.esp32-c3-ard.yaml +++ b/tests/components/mcp47a1/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp47a1 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -output: - - platform: mcp47a1 - id: output_mcp47a1 +<<: !include common.yaml diff --git a/tests/components/mcp47a1/test.esp32-c3-idf.yaml b/tests/components/mcp47a1/test.esp32-c3-idf.yaml index 68273e00eb..ee2c29ca4e 100644 --- a/tests/components/mcp47a1/test.esp32-c3-idf.yaml +++ b/tests/components/mcp47a1/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp47a1 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -output: - - platform: mcp47a1 - id: output_mcp47a1 +<<: !include common.yaml diff --git a/tests/components/mcp47a1/test.esp32-idf.yaml b/tests/components/mcp47a1/test.esp32-idf.yaml index 9e2133de66..63c3bd6afd 100644 --- a/tests/components/mcp47a1/test.esp32-idf.yaml +++ b/tests/components/mcp47a1/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp47a1 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -output: - - platform: mcp47a1 - id: output_mcp47a1 +<<: !include common.yaml diff --git a/tests/components/mcp47a1/test.esp8266-ard.yaml b/tests/components/mcp47a1/test.esp8266-ard.yaml index 68273e00eb..ee2c29ca4e 100644 --- a/tests/components/mcp47a1/test.esp8266-ard.yaml +++ b/tests/components/mcp47a1/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp47a1 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -output: - - platform: mcp47a1 - id: output_mcp47a1 +<<: !include common.yaml diff --git a/tests/components/mcp47a1/test.rp2040-ard.yaml b/tests/components/mcp47a1/test.rp2040-ard.yaml index 68273e00eb..ee2c29ca4e 100644 --- a/tests/components/mcp47a1/test.rp2040-ard.yaml +++ b/tests/components/mcp47a1/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp47a1 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -output: - - platform: mcp47a1 - id: output_mcp47a1 +<<: !include common.yaml diff --git a/tests/components/mcp9600/common.yaml b/tests/components/mcp9600/common.yaml new file mode 100644 index 0000000000..e3c9df79e4 --- /dev/null +++ b/tests/components/mcp9600/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_mcp9600 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: mcp9600 + thermocouple_type: K + hot_junction: + name: Thermocouple Temperature + cold_junction: + name: Ambient Temperature diff --git a/tests/components/mcp9600/test.esp32-ard.yaml b/tests/components/mcp9600/test.esp32-ard.yaml index 0c94f099ae..63c3bd6afd 100644 --- a/tests/components/mcp9600/test.esp32-ard.yaml +++ b/tests/components/mcp9600/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mcp9600 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mcp9600 - thermocouple_type: K - hot_junction: - name: Thermocouple Temperature - cold_junction: - name: Ambient Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9600/test.esp32-c3-ard.yaml b/tests/components/mcp9600/test.esp32-c3-ard.yaml index b07f4589ce..ee2c29ca4e 100644 --- a/tests/components/mcp9600/test.esp32-c3-ard.yaml +++ b/tests/components/mcp9600/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mcp9600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mcp9600 - thermocouple_type: K - hot_junction: - name: Thermocouple Temperature - cold_junction: - name: Ambient Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9600/test.esp32-c3-idf.yaml b/tests/components/mcp9600/test.esp32-c3-idf.yaml index b07f4589ce..ee2c29ca4e 100644 --- a/tests/components/mcp9600/test.esp32-c3-idf.yaml +++ b/tests/components/mcp9600/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mcp9600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mcp9600 - thermocouple_type: K - hot_junction: - name: Thermocouple Temperature - cold_junction: - name: Ambient Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9600/test.esp32-idf.yaml b/tests/components/mcp9600/test.esp32-idf.yaml index 0c94f099ae..63c3bd6afd 100644 --- a/tests/components/mcp9600/test.esp32-idf.yaml +++ b/tests/components/mcp9600/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mcp9600 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mcp9600 - thermocouple_type: K - hot_junction: - name: Thermocouple Temperature - cold_junction: - name: Ambient Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9600/test.esp8266-ard.yaml b/tests/components/mcp9600/test.esp8266-ard.yaml index b07f4589ce..ee2c29ca4e 100644 --- a/tests/components/mcp9600/test.esp8266-ard.yaml +++ b/tests/components/mcp9600/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mcp9600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mcp9600 - thermocouple_type: K - hot_junction: - name: Thermocouple Temperature - cold_junction: - name: Ambient Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9600/test.rp2040-ard.yaml b/tests/components/mcp9600/test.rp2040-ard.yaml index b07f4589ce..ee2c29ca4e 100644 --- a/tests/components/mcp9600/test.rp2040-ard.yaml +++ b/tests/components/mcp9600/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mcp9600 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mcp9600 - thermocouple_type: K - hot_junction: - name: Thermocouple Temperature - cold_junction: - name: Ambient Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9808/common.yaml b/tests/components/mcp9808/common.yaml new file mode 100644 index 0000000000..ccfd5d13ce --- /dev/null +++ b/tests/components/mcp9808/common.yaml @@ -0,0 +1,8 @@ +i2c: + - id: i2c_mcp9808 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: mcp9808 + name: MCP9808 Temperature diff --git a/tests/components/mcp9808/test.esp32-ard.yaml b/tests/components/mcp9808/test.esp32-ard.yaml index 1e5affdac0..63c3bd6afd 100644 --- a/tests/components/mcp9808/test.esp32-ard.yaml +++ b/tests/components/mcp9808/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp9808 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mcp9808 - name: MCP9808 Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9808/test.esp32-c3-ard.yaml b/tests/components/mcp9808/test.esp32-c3-ard.yaml index 86b4d7f181..ee2c29ca4e 100644 --- a/tests/components/mcp9808/test.esp32-c3-ard.yaml +++ b/tests/components/mcp9808/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp9808 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mcp9808 - name: MCP9808 Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9808/test.esp32-c3-idf.yaml b/tests/components/mcp9808/test.esp32-c3-idf.yaml index 86b4d7f181..ee2c29ca4e 100644 --- a/tests/components/mcp9808/test.esp32-c3-idf.yaml +++ b/tests/components/mcp9808/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp9808 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mcp9808 - name: MCP9808 Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9808/test.esp32-idf.yaml b/tests/components/mcp9808/test.esp32-idf.yaml index 1e5affdac0..63c3bd6afd 100644 --- a/tests/components/mcp9808/test.esp32-idf.yaml +++ b/tests/components/mcp9808/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp9808 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mcp9808 - name: MCP9808 Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9808/test.esp8266-ard.yaml b/tests/components/mcp9808/test.esp8266-ard.yaml index 86b4d7f181..ee2c29ca4e 100644 --- a/tests/components/mcp9808/test.esp8266-ard.yaml +++ b/tests/components/mcp9808/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp9808 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mcp9808 - name: MCP9808 Temperature +<<: !include common.yaml diff --git a/tests/components/mcp9808/test.rp2040-ard.yaml b/tests/components/mcp9808/test.rp2040-ard.yaml index 86b4d7f181..ee2c29ca4e 100644 --- a/tests/components/mcp9808/test.rp2040-ard.yaml +++ b/tests/components/mcp9808/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_mcp9808 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mcp9808 - name: MCP9808 Temperature +<<: !include common.yaml diff --git a/tests/components/mhz19/common.yaml b/tests/components/mhz19/common.yaml new file mode 100644 index 0000000000..8b7e732068 --- /dev/null +++ b/tests/components/mhz19/common.yaml @@ -0,0 +1,14 @@ +uart: + - id: uart_mhz19 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: mhz19 + co2: + name: MH-Z19 CO2 Value + temperature: + name: MH-Z19 Temperature + automatic_baseline_calibration: false + update_interval: 15s diff --git a/tests/components/mhz19/test.esp32-ard.yaml b/tests/components/mhz19/test.esp32-ard.yaml index 0e30713b54..f486544afa 100644 --- a/tests/components/mhz19/test.esp32-ard.yaml +++ b/tests/components/mhz19/test.esp32-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_mhz19 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: mhz19 - co2: - name: MH-Z19 CO2 Value - temperature: - name: MH-Z19 Temperature - automatic_baseline_calibration: false - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/mhz19/test.esp32-c3-ard.yaml b/tests/components/mhz19/test.esp32-c3-ard.yaml index 1edfa49c23..b516342f3b 100644 --- a/tests/components/mhz19/test.esp32-c3-ard.yaml +++ b/tests/components/mhz19/test.esp32-c3-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_mhz19 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: mhz19 - co2: - name: MH-Z19 CO2 Value - temperature: - name: MH-Z19 Temperature - automatic_baseline_calibration: false - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/mhz19/test.esp32-c3-idf.yaml b/tests/components/mhz19/test.esp32-c3-idf.yaml index 1edfa49c23..b516342f3b 100644 --- a/tests/components/mhz19/test.esp32-c3-idf.yaml +++ b/tests/components/mhz19/test.esp32-c3-idf.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_mhz19 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: mhz19 - co2: - name: MH-Z19 CO2 Value - temperature: - name: MH-Z19 Temperature - automatic_baseline_calibration: false - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/mhz19/test.esp32-idf.yaml b/tests/components/mhz19/test.esp32-idf.yaml index 0e30713b54..f486544afa 100644 --- a/tests/components/mhz19/test.esp32-idf.yaml +++ b/tests/components/mhz19/test.esp32-idf.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_mhz19 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: mhz19 - co2: - name: MH-Z19 CO2 Value - temperature: - name: MH-Z19 Temperature - automatic_baseline_calibration: false - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/mhz19/test.esp8266-ard.yaml b/tests/components/mhz19/test.esp8266-ard.yaml index 1edfa49c23..b516342f3b 100644 --- a/tests/components/mhz19/test.esp8266-ard.yaml +++ b/tests/components/mhz19/test.esp8266-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_mhz19 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: mhz19 - co2: - name: MH-Z19 CO2 Value - temperature: - name: MH-Z19 Temperature - automatic_baseline_calibration: false - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/mhz19/test.rp2040-ard.yaml b/tests/components/mhz19/test.rp2040-ard.yaml index 1edfa49c23..b516342f3b 100644 --- a/tests/components/mhz19/test.rp2040-ard.yaml +++ b/tests/components/mhz19/test.rp2040-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_mhz19 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: mhz19 - co2: - name: MH-Z19 CO2 Value - temperature: - name: MH-Z19 Temperature - automatic_baseline_calibration: false - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/micronova/common.yaml b/tests/components/micronova/common.yaml new file mode 100644 index 0000000000..661c9330c6 --- /dev/null +++ b/tests/components/micronova/common.yaml @@ -0,0 +1,49 @@ +uart: + - id: uart_micronova + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +micronova: + enable_rx_pin: ${enable_rx_pin} + +button: + - platform: micronova + custom_button: + name: Custom Micronova Button + memory_location: 0xA0 + memory_address: 0x7D + memory_data: 0x0F + +number: + - platform: micronova + thermostat_temperature: + name: Micronova Thermostaat + step: 1 + power_level: + name: Micronova Power level + +sensor: + - platform: micronova + room_temperature: + name: Room Temperature + fumes_temperature: + name: Fumes Temperature + water_temperature: + name: Water temperature + water_pressure: + name: Water pressure + stove_power: + name: Stove Power + fan_speed: + fan_rpm_offset: 240 + name: Fan RPM + memory_address_sensor: + memory_location: 0x20 + memory_address: 0x7d + name: Adres sensor + +switch: + - platform: micronova + stove: + name: Stove on/off diff --git a/tests/components/micronova/test.esp32-ard.yaml b/tests/components/micronova/test.esp32-ard.yaml index 9156f7d6a9..35d041e047 100644 --- a/tests/components/micronova/test.esp32-ard.yaml +++ b/tests/components/micronova/test.esp32-ard.yaml @@ -1,49 +1,6 @@ -uart: - - id: uart_micronova - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + enable_rx_pin: GPIO13 -micronova: - enable_rx_pin: 18 - -button: - - platform: micronova - custom_button: - name: Custom Micronova Button - memory_location: 0xA0 - memory_address: 0x7D - memory_data: 0x0F - -number: - - platform: micronova - thermostat_temperature: - name: Micronova Thermostaat - step: 1 - power_level: - name: Micronova Power level - -sensor: - - platform: micronova - room_temperature: - name: Room Temperature - fumes_temperature: - name: Fumes Temperature - water_temperature: - name: Water temperature - water_pressure: - name: Water pressure - stove_power: - name: Stove Power - fan_speed: - fan_rpm_offset: 240 - name: Fan RPM - memory_address_sensor: - memory_location: 0x20 - memory_address: 0x7d - name: Adres sensor - -switch: - - platform: micronova - stove: - name: Stove on/off +<<: !include common.yaml diff --git a/tests/components/micronova/test.esp32-c3-ard.yaml b/tests/components/micronova/test.esp32-c3-ard.yaml index ec9699909e..993071999f 100644 --- a/tests/components/micronova/test.esp32-c3-ard.yaml +++ b/tests/components/micronova/test.esp32-c3-ard.yaml @@ -1,49 +1,6 @@ -uart: - - id: uart_micronova - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + enable_rx_pin: GPIO3 -micronova: - enable_rx_pin: 6 - -button: - - platform: micronova - custom_button: - name: Custom Micronova Button - memory_location: 0xA0 - memory_address: 0x7D - memory_data: 0x0F - -number: - - platform: micronova - thermostat_temperature: - name: Micronova Thermostaat - step: 1 - power_level: - name: Micronova Power level - -sensor: - - platform: micronova - room_temperature: - name: Room Temperature - fumes_temperature: - name: Fumes Temperature - water_temperature: - name: Water temperature - water_pressure: - name: Water pressure - stove_power: - name: Stove Power - fan_speed: - fan_rpm_offset: 240 - name: Fan RPM - memory_address_sensor: - memory_location: 0x20 - memory_address: 0x7d - name: Adres sensor - -switch: - - platform: micronova - stove: - name: Stove on/off +<<: !include common.yaml diff --git a/tests/components/micronova/test.esp32-c3-idf.yaml b/tests/components/micronova/test.esp32-c3-idf.yaml index ec9699909e..993071999f 100644 --- a/tests/components/micronova/test.esp32-c3-idf.yaml +++ b/tests/components/micronova/test.esp32-c3-idf.yaml @@ -1,49 +1,6 @@ -uart: - - id: uart_micronova - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + enable_rx_pin: GPIO3 -micronova: - enable_rx_pin: 6 - -button: - - platform: micronova - custom_button: - name: Custom Micronova Button - memory_location: 0xA0 - memory_address: 0x7D - memory_data: 0x0F - -number: - - platform: micronova - thermostat_temperature: - name: Micronova Thermostaat - step: 1 - power_level: - name: Micronova Power level - -sensor: - - platform: micronova - room_temperature: - name: Room Temperature - fumes_temperature: - name: Fumes Temperature - water_temperature: - name: Water temperature - water_pressure: - name: Water pressure - stove_power: - name: Stove Power - fan_speed: - fan_rpm_offset: 240 - name: Fan RPM - memory_address_sensor: - memory_location: 0x20 - memory_address: 0x7d - name: Adres sensor - -switch: - - platform: micronova - stove: - name: Stove on/off +<<: !include common.yaml diff --git a/tests/components/micronova/test.esp32-idf.yaml b/tests/components/micronova/test.esp32-idf.yaml index 9156f7d6a9..35d041e047 100644 --- a/tests/components/micronova/test.esp32-idf.yaml +++ b/tests/components/micronova/test.esp32-idf.yaml @@ -1,49 +1,6 @@ -uart: - - id: uart_micronova - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + enable_rx_pin: GPIO13 -micronova: - enable_rx_pin: 18 - -button: - - platform: micronova - custom_button: - name: Custom Micronova Button - memory_location: 0xA0 - memory_address: 0x7D - memory_data: 0x0F - -number: - - platform: micronova - thermostat_temperature: - name: Micronova Thermostaat - step: 1 - power_level: - name: Micronova Power level - -sensor: - - platform: micronova - room_temperature: - name: Room Temperature - fumes_temperature: - name: Fumes Temperature - water_temperature: - name: Water temperature - water_pressure: - name: Water pressure - stove_power: - name: Stove Power - fan_speed: - fan_rpm_offset: 240 - name: Fan RPM - memory_address_sensor: - memory_location: 0x20 - memory_address: 0x7d - name: Adres sensor - -switch: - - platform: micronova - stove: - name: Stove on/off +<<: !include common.yaml diff --git a/tests/components/micronova/test.esp8266-ard.yaml b/tests/components/micronova/test.esp8266-ard.yaml index d10ab7ad7a..048fb82d72 100644 --- a/tests/components/micronova/test.esp8266-ard.yaml +++ b/tests/components/micronova/test.esp8266-ard.yaml @@ -1,49 +1,6 @@ -uart: - - id: uart_micronova - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + enable_rx_pin: GPIO13 -micronova: - enable_rx_pin: 16 - -button: - - platform: micronova - custom_button: - name: Custom Micronova Button - memory_location: 0xA0 - memory_address: 0x7D - memory_data: 0x0F - -number: - - platform: micronova - thermostat_temperature: - name: Micronova Thermostaat - step: 1 - power_level: - name: Micronova Power level - -sensor: - - platform: micronova - room_temperature: - name: Room Temperature - fumes_temperature: - name: Fumes Temperature - water_temperature: - name: Water temperature - water_pressure: - name: Water pressure - stove_power: - name: Stove Power - fan_speed: - fan_rpm_offset: 240 - name: Fan RPM - memory_address_sensor: - memory_location: 0x20 - memory_address: 0x7d - name: Adres sensor - -switch: - - platform: micronova - stove: - name: Stove on/off +<<: !include common.yaml diff --git a/tests/components/micronova/test.rp2040-ard.yaml b/tests/components/micronova/test.rp2040-ard.yaml index ec9699909e..993071999f 100644 --- a/tests/components/micronova/test.rp2040-ard.yaml +++ b/tests/components/micronova/test.rp2040-ard.yaml @@ -1,49 +1,6 @@ -uart: - - id: uart_micronova - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + enable_rx_pin: GPIO3 -micronova: - enable_rx_pin: 6 - -button: - - platform: micronova - custom_button: - name: Custom Micronova Button - memory_location: 0xA0 - memory_address: 0x7D - memory_data: 0x0F - -number: - - platform: micronova - thermostat_temperature: - name: Micronova Thermostaat - step: 1 - power_level: - name: Micronova Power level - -sensor: - - platform: micronova - room_temperature: - name: Room Temperature - fumes_temperature: - name: Fumes Temperature - water_temperature: - name: Water temperature - water_pressure: - name: Water pressure - stove_power: - name: Stove Power - fan_speed: - fan_rpm_offset: 240 - name: Fan RPM - memory_address_sensor: - memory_location: 0x20 - memory_address: 0x7d - name: Adres sensor - -switch: - - platform: micronova - stove: - name: Stove on/off +<<: !include common.yaml diff --git a/tests/components/microphone/common.yaml b/tests/components/microphone/common.yaml new file mode 100644 index 0000000000..ea79266281 --- /dev/null +++ b/tests/components/microphone/common.yaml @@ -0,0 +1,11 @@ +i2s_audio: + i2s_bclk_pin: ${i2s_bclk_pin} + i2s_lrclk_pin: ${i2s_lrclk_pin} + i2s_mclk_pin: ${i2s_mclk_pin} + +microphone: + - platform: i2s_audio + id: mic_id_external + i2s_din_pin: ${i2s_din_pin} + adc_type: external + pdm: false diff --git a/tests/components/microphone/test.esp32-ard.yaml b/tests/components/microphone/test.esp32-ard.yaml index 166eedb54d..392df582cc 100644 --- a/tests/components/microphone/test.esp32-ard.yaml +++ b/tests/components/microphone/test.esp32-ard.yaml @@ -1,15 +1,13 @@ -i2s_audio: - i2s_lrclk_pin: 13 - i2s_bclk_pin: 14 - i2s_mclk_pin: 15 +substitutions: + i2s_bclk_pin: GPIO15 + i2s_lrclk_pin: GPIO16 + i2s_mclk_pin: GPIO17 + i2s_din_pin: GPIO33 + +<<: !include common.yaml microphone: - platform: i2s_audio id: mic_id_adc adc_pin: 32 adc_type: internal - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 33 - adc_type: external - pdm: false diff --git a/tests/components/microphone/test.esp32-c3-ard.yaml b/tests/components/microphone/test.esp32-c3-ard.yaml index 706a38f910..c28dc553f5 100644 --- a/tests/components/microphone/test.esp32-c3-ard.yaml +++ b/tests/components/microphone/test.esp32-c3-ard.yaml @@ -1,11 +1,7 @@ -i2s_audio: - i2s_lrclk_pin: 6 - i2s_bclk_pin: 7 - i2s_mclk_pin: 8 +substitutions: + i2s_bclk_pin: GPIO6 + i2s_lrclk_pin: GPIO7 + i2s_mclk_pin: GPIO8 + i2s_din_pin: GPIO3 -microphone: - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 3 - adc_type: external - pdm: false +<<: !include common.yaml diff --git a/tests/components/microphone/test.esp32-c3-idf.yaml b/tests/components/microphone/test.esp32-c3-idf.yaml index 706a38f910..c28dc553f5 100644 --- a/tests/components/microphone/test.esp32-c3-idf.yaml +++ b/tests/components/microphone/test.esp32-c3-idf.yaml @@ -1,11 +1,7 @@ -i2s_audio: - i2s_lrclk_pin: 6 - i2s_bclk_pin: 7 - i2s_mclk_pin: 8 +substitutions: + i2s_bclk_pin: GPIO6 + i2s_lrclk_pin: GPIO7 + i2s_mclk_pin: GPIO8 + i2s_din_pin: GPIO3 -microphone: - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 3 - adc_type: external - pdm: false +<<: !include common.yaml diff --git a/tests/components/microphone/test.esp32-idf.yaml b/tests/components/microphone/test.esp32-idf.yaml index 166eedb54d..392df582cc 100644 --- a/tests/components/microphone/test.esp32-idf.yaml +++ b/tests/components/microphone/test.esp32-idf.yaml @@ -1,15 +1,13 @@ -i2s_audio: - i2s_lrclk_pin: 13 - i2s_bclk_pin: 14 - i2s_mclk_pin: 15 +substitutions: + i2s_bclk_pin: GPIO15 + i2s_lrclk_pin: GPIO16 + i2s_mclk_pin: GPIO17 + i2s_din_pin: GPIO33 + +<<: !include common.yaml microphone: - platform: i2s_audio id: mic_id_adc adc_pin: 32 adc_type: internal - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 33 - adc_type: external - pdm: false diff --git a/tests/components/mics_4514/common.yaml b/tests/components/mics_4514/common.yaml new file mode 100644 index 0000000000..0bc3f3e654 --- /dev/null +++ b/tests/components/mics_4514/common.yaml @@ -0,0 +1,20 @@ +i2c: + - id: i2c_mics_4514 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: mics_4514 + update_interval: 60s + nitrogen_dioxide: + name: MICS-4514 NO2 + carbon_monoxide: + name: MICS-4514 CO + methane: + name: MICS-4514 CH4 + hydrogen: + name: MICS-4514 H2 + ethanol: + name: MICS-4514 C2H5OH + ammonia: + name: MICS-4514 NH3 diff --git a/tests/components/mics_4514/test.esp32-ard.yaml b/tests/components/mics_4514/test.esp32-ard.yaml index 234839c91c..63c3bd6afd 100644 --- a/tests/components/mics_4514/test.esp32-ard.yaml +++ b/tests/components/mics_4514/test.esp32-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mics_4514 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mics_4514 - update_interval: 60s - nitrogen_dioxide: - name: MICS-4514 NO2 - carbon_monoxide: - name: MICS-4514 CO - methane: - name: MICS-4514 CH4 - hydrogen: - name: MICS-4514 H2 - ethanol: - name: MICS-4514 C2H5OH - ammonia: - name: MICS-4514 NH3 +<<: !include common.yaml diff --git a/tests/components/mics_4514/test.esp32-c3-ard.yaml b/tests/components/mics_4514/test.esp32-c3-ard.yaml index 72369bec01..ee2c29ca4e 100644 --- a/tests/components/mics_4514/test.esp32-c3-ard.yaml +++ b/tests/components/mics_4514/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mics_4514 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mics_4514 - update_interval: 60s - nitrogen_dioxide: - name: MICS-4514 NO2 - carbon_monoxide: - name: MICS-4514 CO - methane: - name: MICS-4514 CH4 - hydrogen: - name: MICS-4514 H2 - ethanol: - name: MICS-4514 C2H5OH - ammonia: - name: MICS-4514 NH3 +<<: !include common.yaml diff --git a/tests/components/mics_4514/test.esp32-c3-idf.yaml b/tests/components/mics_4514/test.esp32-c3-idf.yaml index 72369bec01..ee2c29ca4e 100644 --- a/tests/components/mics_4514/test.esp32-c3-idf.yaml +++ b/tests/components/mics_4514/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mics_4514 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mics_4514 - update_interval: 60s - nitrogen_dioxide: - name: MICS-4514 NO2 - carbon_monoxide: - name: MICS-4514 CO - methane: - name: MICS-4514 CH4 - hydrogen: - name: MICS-4514 H2 - ethanol: - name: MICS-4514 C2H5OH - ammonia: - name: MICS-4514 NH3 +<<: !include common.yaml diff --git a/tests/components/mics_4514/test.esp32-idf.yaml b/tests/components/mics_4514/test.esp32-idf.yaml index 234839c91c..63c3bd6afd 100644 --- a/tests/components/mics_4514/test.esp32-idf.yaml +++ b/tests/components/mics_4514/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mics_4514 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mics_4514 - update_interval: 60s - nitrogen_dioxide: - name: MICS-4514 NO2 - carbon_monoxide: - name: MICS-4514 CO - methane: - name: MICS-4514 CH4 - hydrogen: - name: MICS-4514 H2 - ethanol: - name: MICS-4514 C2H5OH - ammonia: - name: MICS-4514 NH3 +<<: !include common.yaml diff --git a/tests/components/mics_4514/test.esp8266-ard.yaml b/tests/components/mics_4514/test.esp8266-ard.yaml index 72369bec01..ee2c29ca4e 100644 --- a/tests/components/mics_4514/test.esp8266-ard.yaml +++ b/tests/components/mics_4514/test.esp8266-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mics_4514 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mics_4514 - update_interval: 60s - nitrogen_dioxide: - name: MICS-4514 NO2 - carbon_monoxide: - name: MICS-4514 CO - methane: - name: MICS-4514 CH4 - hydrogen: - name: MICS-4514 H2 - ethanol: - name: MICS-4514 C2H5OH - ammonia: - name: MICS-4514 NH3 +<<: !include common.yaml diff --git a/tests/components/mics_4514/test.rp2040-ard.yaml b/tests/components/mics_4514/test.rp2040-ard.yaml index 72369bec01..ee2c29ca4e 100644 --- a/tests/components/mics_4514/test.rp2040-ard.yaml +++ b/tests/components/mics_4514/test.rp2040-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mics_4514 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mics_4514 - update_interval: 60s - nitrogen_dioxide: - name: MICS-4514 NO2 - carbon_monoxide: - name: MICS-4514 CO - methane: - name: MICS-4514 CH4 - hydrogen: - name: MICS-4514 H2 - ethanol: - name: MICS-4514 C2H5OH - ammonia: - name: MICS-4514 NH3 +<<: !include common.yaml diff --git a/tests/components/midea/common.yaml b/tests/components/midea/common.yaml new file mode 100644 index 0000000000..07385e29a1 --- /dev/null +++ b/tests/components/midea/common.yaml @@ -0,0 +1,59 @@ +wifi: + ssid: MySSID + password: password1 + +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +uart: + - id: uart_midea + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +climate: + - platform: midea + id: midea_unit + name: Midea Climate + on_control: + - logger.log: Control message received! + - lambda: |- + x.set_mode(CLIMATE_MODE_FAN_ONLY); + on_state: + - logger.log: State changed! + transmitter_id: + period: 1s + num_attempts: 5 + timeout: 2s + beeper: false + autoconf: true + visual: + min_temperature: 17 °C + max_temperature: 30 °C + temperature_step: 0.5 °C + supported_modes: + - FAN_ONLY + - HEAT_COOL + - COOL + - HEAT + - DRY + custom_fan_modes: + - SILENT + - TURBO + supported_presets: + - ECO + - BOOST + - SLEEP + custom_presets: + - FREEZE_PROTECTION + supported_swing_modes: + - VERTICAL + - HORIZONTAL + - BOTH + outdoor_temperature: + name: Temp + power_usage: + name: Power + humidity_setpoint: + name: Humidity diff --git a/tests/components/midea/test.esp32-ard.yaml b/tests/components/midea/test.esp32-ard.yaml index 5c638b9613..7f55d6a52d 100644 --- a/tests/components/midea/test.esp32-ard.yaml +++ b/tests/components/midea/test.esp32-ard.yaml @@ -1,59 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + pin: GPIO2 -remote_transmitter: - pin: 18 - carrier_duty_percent: 50% - -uart: - - id: uart_midea - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -climate: - - platform: midea - id: midea_unit - name: Midea Climate - on_control: - - logger.log: Control message received! - - lambda: |- - x.set_mode(CLIMATE_MODE_FAN_ONLY); - on_state: - - logger.log: State changed! - transmitter_id: - period: 1s - num_attempts: 5 - timeout: 2s - beeper: false - autoconf: true - visual: - min_temperature: 17 °C - max_temperature: 30 °C - temperature_step: 0.5 °C - supported_modes: - - FAN_ONLY - - HEAT_COOL - - COOL - - HEAT - - DRY - custom_fan_modes: - - SILENT - - TURBO - supported_presets: - - ECO - - BOOST - - SLEEP - custom_presets: - - FREEZE_PROTECTION - supported_swing_modes: - - VERTICAL - - HORIZONTAL - - BOTH - outdoor_temperature: - name: Temp - power_usage: - name: Power - humidity_setpoint: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/midea/test.esp32-c3-ard.yaml b/tests/components/midea/test.esp32-c3-ard.yaml index bcb8635eaf..a879df3ca4 100644 --- a/tests/components/midea/test.esp32-c3-ard.yaml +++ b/tests/components/midea/test.esp32-c3-ard.yaml @@ -1,59 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + pin: GPIO2 -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% - -uart: - - id: uart_midea - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -climate: - - platform: midea - id: midea_unit - name: Midea Climate - on_control: - - logger.log: Control message received! - - lambda: |- - x.set_mode(CLIMATE_MODE_FAN_ONLY); - on_state: - - logger.log: State changed! - transmitter_id: - period: 1s - num_attempts: 5 - timeout: 2s - beeper: false - autoconf: true - visual: - min_temperature: 17 °C - max_temperature: 30 °C - temperature_step: 0.5 °C - supported_modes: - - FAN_ONLY - - HEAT_COOL - - COOL - - HEAT - - DRY - custom_fan_modes: - - SILENT - - TURBO - supported_presets: - - ECO - - BOOST - - SLEEP - custom_presets: - - FREEZE_PROTECTION - supported_swing_modes: - - VERTICAL - - HORIZONTAL - - BOTH - outdoor_temperature: - name: Temp - power_usage: - name: Power - humidity_setpoint: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/midea/test.esp8266-ard.yaml b/tests/components/midea/test.esp8266-ard.yaml index b0ed7eb472..4f50bd7e5e 100644 --- a/tests/components/midea/test.esp8266-ard.yaml +++ b/tests/components/midea/test.esp8266-ard.yaml @@ -1,59 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + pin: GPIO15 -remote_transmitter: - pin: 12 - carrier_duty_percent: 50% - -uart: - - id: uart_midea - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -climate: - - platform: midea - id: midea_unit - name: Midea Climate - on_control: - - logger.log: Control message received! - - lambda: |- - x.set_mode(CLIMATE_MODE_FAN_ONLY); - on_state: - - logger.log: State changed! - transmitter_id: - period: 1s - num_attempts: 5 - timeout: 2s - beeper: false - autoconf: true - visual: - min_temperature: 17 °C - max_temperature: 30 °C - temperature_step: 0.5 °C - supported_modes: - - FAN_ONLY - - HEAT_COOL - - COOL - - HEAT - - DRY - custom_fan_modes: - - SILENT - - TURBO - supported_presets: - - ECO - - BOOST - - SLEEP - custom_presets: - - FREEZE_PROTECTION - supported_swing_modes: - - VERTICAL - - HORIZONTAL - - BOTH - outdoor_temperature: - name: Temp - power_usage: - name: Power - humidity_setpoint: - name: Humidity +<<: !include common.yaml diff --git a/tests/components/mlx90393/common.yaml b/tests/components/mlx90393/common.yaml new file mode 100644 index 0000000000..a7ab0867cc --- /dev/null +++ b/tests/components/mlx90393/common.yaml @@ -0,0 +1,20 @@ +i2c: + - id: i2c_mlx90393 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: mlx90393 + oversampling: 1 + filter: 0 + gain: 3X + x_axis: + name: mlxxaxis + y_axis: + name: mlxyaxis + z_axis: + name: mlxzaxis + resolution: 17BIT + temperature: + name: mlxtemp + oversampling: 2 diff --git a/tests/components/mlx90393/test.esp32-ard.yaml b/tests/components/mlx90393/test.esp32-ard.yaml index 089fd136f4..63c3bd6afd 100644 --- a/tests/components/mlx90393/test.esp32-ard.yaml +++ b/tests/components/mlx90393/test.esp32-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mlx90393 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mlx90393 - oversampling: 1 - filter: 0 - gain: 3X - x_axis: - name: mlxxaxis - y_axis: - name: mlxyaxis - z_axis: - name: mlxzaxis - resolution: 17BIT - temperature: - name: mlxtemp - oversampling: 2 +<<: !include common.yaml diff --git a/tests/components/mlx90393/test.esp32-c3-ard.yaml b/tests/components/mlx90393/test.esp32-c3-ard.yaml index 549eea8032..ee2c29ca4e 100644 --- a/tests/components/mlx90393/test.esp32-c3-ard.yaml +++ b/tests/components/mlx90393/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mlx90393 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mlx90393 - oversampling: 1 - filter: 0 - gain: 3X - x_axis: - name: mlxxaxis - y_axis: - name: mlxyaxis - z_axis: - name: mlxzaxis - resolution: 17BIT - temperature: - name: mlxtemp - oversampling: 2 +<<: !include common.yaml diff --git a/tests/components/mlx90393/test.esp32-c3-idf.yaml b/tests/components/mlx90393/test.esp32-c3-idf.yaml index 549eea8032..ee2c29ca4e 100644 --- a/tests/components/mlx90393/test.esp32-c3-idf.yaml +++ b/tests/components/mlx90393/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mlx90393 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mlx90393 - oversampling: 1 - filter: 0 - gain: 3X - x_axis: - name: mlxxaxis - y_axis: - name: mlxyaxis - z_axis: - name: mlxzaxis - resolution: 17BIT - temperature: - name: mlxtemp - oversampling: 2 +<<: !include common.yaml diff --git a/tests/components/mlx90393/test.esp32-idf.yaml b/tests/components/mlx90393/test.esp32-idf.yaml index 089fd136f4..63c3bd6afd 100644 --- a/tests/components/mlx90393/test.esp32-idf.yaml +++ b/tests/components/mlx90393/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mlx90393 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mlx90393 - oversampling: 1 - filter: 0 - gain: 3X - x_axis: - name: mlxxaxis - y_axis: - name: mlxyaxis - z_axis: - name: mlxzaxis - resolution: 17BIT - temperature: - name: mlxtemp - oversampling: 2 +<<: !include common.yaml diff --git a/tests/components/mlx90393/test.esp8266-ard.yaml b/tests/components/mlx90393/test.esp8266-ard.yaml index 549eea8032..ee2c29ca4e 100644 --- a/tests/components/mlx90393/test.esp8266-ard.yaml +++ b/tests/components/mlx90393/test.esp8266-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mlx90393 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mlx90393 - oversampling: 1 - filter: 0 - gain: 3X - x_axis: - name: mlxxaxis - y_axis: - name: mlxyaxis - z_axis: - name: mlxzaxis - resolution: 17BIT - temperature: - name: mlxtemp - oversampling: 2 +<<: !include common.yaml diff --git a/tests/components/mlx90393/test.rp2040-ard.yaml b/tests/components/mlx90393/test.rp2040-ard.yaml index 549eea8032..ee2c29ca4e 100644 --- a/tests/components/mlx90393/test.rp2040-ard.yaml +++ b/tests/components/mlx90393/test.rp2040-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_mlx90393 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mlx90393 - oversampling: 1 - filter: 0 - gain: 3X - x_axis: - name: mlxxaxis - y_axis: - name: mlxyaxis - z_axis: - name: mlxzaxis - resolution: 17BIT - temperature: - name: mlxtemp - oversampling: 2 +<<: !include common.yaml diff --git a/tests/components/mlx90614/common.yaml b/tests/components/mlx90614/common.yaml new file mode 100644 index 0000000000..03279e6e14 --- /dev/null +++ b/tests/components/mlx90614/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_mlx90614 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: mlx90614 + ambient: + name: Ambient + object: + name: Object + emissivity: 1.0 diff --git a/tests/components/mlx90614/test.esp32-ard.yaml b/tests/components/mlx90614/test.esp32-ard.yaml index 8c1ee68f42..63c3bd6afd 100644 --- a/tests/components/mlx90614/test.esp32-ard.yaml +++ b/tests/components/mlx90614/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mlx90614 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mlx90614 - ambient: - name: Ambient - object: - name: Object - emissivity: 1.0 +<<: !include common.yaml diff --git a/tests/components/mlx90614/test.esp32-c3-ard.yaml b/tests/components/mlx90614/test.esp32-c3-ard.yaml index a863e0ee2e..ee2c29ca4e 100644 --- a/tests/components/mlx90614/test.esp32-c3-ard.yaml +++ b/tests/components/mlx90614/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mlx90614 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mlx90614 - ambient: - name: Ambient - object: - name: Object - emissivity: 1.0 +<<: !include common.yaml diff --git a/tests/components/mlx90614/test.esp32-c3-idf.yaml b/tests/components/mlx90614/test.esp32-c3-idf.yaml index a863e0ee2e..ee2c29ca4e 100644 --- a/tests/components/mlx90614/test.esp32-c3-idf.yaml +++ b/tests/components/mlx90614/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mlx90614 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mlx90614 - ambient: - name: Ambient - object: - name: Object - emissivity: 1.0 +<<: !include common.yaml diff --git a/tests/components/mlx90614/test.esp32-idf.yaml b/tests/components/mlx90614/test.esp32-idf.yaml index 8c1ee68f42..63c3bd6afd 100644 --- a/tests/components/mlx90614/test.esp32-idf.yaml +++ b/tests/components/mlx90614/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mlx90614 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mlx90614 - ambient: - name: Ambient - object: - name: Object - emissivity: 1.0 +<<: !include common.yaml diff --git a/tests/components/mlx90614/test.esp8266-ard.yaml b/tests/components/mlx90614/test.esp8266-ard.yaml index a863e0ee2e..ee2c29ca4e 100644 --- a/tests/components/mlx90614/test.esp8266-ard.yaml +++ b/tests/components/mlx90614/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mlx90614 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mlx90614 - ambient: - name: Ambient - object: - name: Object - emissivity: 1.0 +<<: !include common.yaml diff --git a/tests/components/mlx90614/test.rp2040-ard.yaml b/tests/components/mlx90614/test.rp2040-ard.yaml index a863e0ee2e..ee2c29ca4e 100644 --- a/tests/components/mlx90614/test.rp2040-ard.yaml +++ b/tests/components/mlx90614/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mlx90614 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mlx90614 - ambient: - name: Ambient - object: - name: Object - emissivity: 1.0 +<<: !include common.yaml diff --git a/tests/components/mmc5603/common.yaml b/tests/components/mmc5603/common.yaml new file mode 100644 index 0000000000..83235f596e --- /dev/null +++ b/tests/components/mmc5603/common.yaml @@ -0,0 +1,14 @@ +i2c: + - id: i2c_mmc5603 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: mmc5603 + address: 0x30 + field_strength_x: + name: HMC5883L Field Strength X + field_strength_y: + name: HMC5883L Field Strength Y + field_strength_z: + name: HMC5883L Field Strength Z diff --git a/tests/components/mmc5603/test.esp32-ard.yaml b/tests/components/mmc5603/test.esp32-ard.yaml index fbb83cd9f8..63c3bd6afd 100644 --- a/tests/components/mmc5603/test.esp32-ard.yaml +++ b/tests/components/mmc5603/test.esp32-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_mmc5603 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mmc5603 - address: 0x30 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z +<<: !include common.yaml diff --git a/tests/components/mmc5603/test.esp32-c3-ard.yaml b/tests/components/mmc5603/test.esp32-c3-ard.yaml index 834591bb39..ee2c29ca4e 100644 --- a/tests/components/mmc5603/test.esp32-c3-ard.yaml +++ b/tests/components/mmc5603/test.esp32-c3-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_mmc5603 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mmc5603 - address: 0x30 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z +<<: !include common.yaml diff --git a/tests/components/mmc5603/test.esp32-c3-idf.yaml b/tests/components/mmc5603/test.esp32-c3-idf.yaml index 834591bb39..ee2c29ca4e 100644 --- a/tests/components/mmc5603/test.esp32-c3-idf.yaml +++ b/tests/components/mmc5603/test.esp32-c3-idf.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_mmc5603 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mmc5603 - address: 0x30 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z +<<: !include common.yaml diff --git a/tests/components/mmc5603/test.esp32-idf.yaml b/tests/components/mmc5603/test.esp32-idf.yaml index fbb83cd9f8..63c3bd6afd 100644 --- a/tests/components/mmc5603/test.esp32-idf.yaml +++ b/tests/components/mmc5603/test.esp32-idf.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_mmc5603 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mmc5603 - address: 0x30 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z +<<: !include common.yaml diff --git a/tests/components/mmc5603/test.esp8266-ard.yaml b/tests/components/mmc5603/test.esp8266-ard.yaml index 834591bb39..ee2c29ca4e 100644 --- a/tests/components/mmc5603/test.esp8266-ard.yaml +++ b/tests/components/mmc5603/test.esp8266-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_mmc5603 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mmc5603 - address: 0x30 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z +<<: !include common.yaml diff --git a/tests/components/mmc5603/test.rp2040-ard.yaml b/tests/components/mmc5603/test.rp2040-ard.yaml index 834591bb39..ee2c29ca4e 100644 --- a/tests/components/mmc5603/test.rp2040-ard.yaml +++ b/tests/components/mmc5603/test.rp2040-ard.yaml @@ -1,14 +1,5 @@ -i2c: - - id: i2c_mmc5603 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mmc5603 - address: 0x30 - field_strength_x: - name: HMC5883L Field Strength X - field_strength_y: - name: HMC5883L Field Strength Y - field_strength_z: - name: HMC5883L Field Strength Z +<<: !include common.yaml diff --git a/tests/components/mmc5983/common.yaml b/tests/components/mmc5983/common.yaml new file mode 100644 index 0000000000..949ff527e7 --- /dev/null +++ b/tests/components/mmc5983/common.yaml @@ -0,0 +1,16 @@ +i2c: + - id: i2c_mmc5983 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: mmc5983 + field_strength_x: + name: "Magnet X" + id: magnet_x + field_strength_y: + name: "Magnet Y" + id: magnet_y + field_strength_z: + name: "Magnet Z" + id: magnet_z diff --git a/tests/components/mmc5983/test.esp32-ard.yaml b/tests/components/mmc5983/test.esp32-ard.yaml index 6104be9b83..63c3bd6afd 100644 --- a/tests/components/mmc5983/test.esp32-ard.yaml +++ b/tests/components/mmc5983/test.esp32-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_mmc5983 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mmc5983 - field_strength_x: - name: "Magnet X" - id: magnet_x - field_strength_y: - name: "Magnet Y" - id: magnet_y - field_strength_z: - name: "Magnet Z" - id: magnet_z +<<: !include common.yaml diff --git a/tests/components/mmc5983/test.esp32-c3-ard.yaml b/tests/components/mmc5983/test.esp32-c3-ard.yaml index 68d821e9a5..ee2c29ca4e 100644 --- a/tests/components/mmc5983/test.esp32-c3-ard.yaml +++ b/tests/components/mmc5983/test.esp32-c3-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_mmc5983 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mmc5983 - field_strength_x: - name: "Magnet X" - id: magnet_x - field_strength_y: - name: "Magnet Y" - id: magnet_y - field_strength_z: - name: "Magnet Z" - id: magnet_z +<<: !include common.yaml diff --git a/tests/components/mmc5983/test.esp32-c3-idf.yaml b/tests/components/mmc5983/test.esp32-c3-idf.yaml index 68d821e9a5..ee2c29ca4e 100644 --- a/tests/components/mmc5983/test.esp32-c3-idf.yaml +++ b/tests/components/mmc5983/test.esp32-c3-idf.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_mmc5983 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mmc5983 - field_strength_x: - name: "Magnet X" - id: magnet_x - field_strength_y: - name: "Magnet Y" - id: magnet_y - field_strength_z: - name: "Magnet Z" - id: magnet_z +<<: !include common.yaml diff --git a/tests/components/mmc5983/test.esp32-idf.yaml b/tests/components/mmc5983/test.esp32-idf.yaml index 6104be9b83..63c3bd6afd 100644 --- a/tests/components/mmc5983/test.esp32-idf.yaml +++ b/tests/components/mmc5983/test.esp32-idf.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_mmc5983 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mmc5983 - field_strength_x: - name: "Magnet X" - id: magnet_x - field_strength_y: - name: "Magnet Y" - id: magnet_y - field_strength_z: - name: "Magnet Z" - id: magnet_z +<<: !include common.yaml diff --git a/tests/components/mmc5983/test.esp8266-ard.yaml b/tests/components/mmc5983/test.esp8266-ard.yaml index 68d821e9a5..ee2c29ca4e 100644 --- a/tests/components/mmc5983/test.esp8266-ard.yaml +++ b/tests/components/mmc5983/test.esp8266-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_mmc5983 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mmc5983 - field_strength_x: - name: "Magnet X" - id: magnet_x - field_strength_y: - name: "Magnet Y" - id: magnet_y - field_strength_z: - name: "Magnet Z" - id: magnet_z +<<: !include common.yaml diff --git a/tests/components/mmc5983/test.rp2040-ard.yaml b/tests/components/mmc5983/test.rp2040-ard.yaml index 68d821e9a5..ee2c29ca4e 100644 --- a/tests/components/mmc5983/test.rp2040-ard.yaml +++ b/tests/components/mmc5983/test.rp2040-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_mmc5983 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mmc5983 - field_strength_x: - name: "Magnet X" - id: magnet_x - field_strength_y: - name: "Magnet Y" - id: magnet_y - field_strength_z: - name: "Magnet Z" - id: magnet_z +<<: !include common.yaml diff --git a/tests/components/modbus/common.yaml b/tests/components/modbus/common.yaml new file mode 100644 index 0000000000..3ec9518585 --- /dev/null +++ b/tests/components/modbus/common.yaml @@ -0,0 +1,9 @@ +uart: + - id: uart_modbus + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +modbus: + id: mod_bus1 + flow_control_pin: ${flow_control_pin} diff --git a/tests/components/modbus/test.esp32-ard.yaml b/tests/components/modbus/test.esp32-ard.yaml index 20cf238b1b..bd767a8ece 100644 --- a/tests/components/modbus/test.esp32-ard.yaml +++ b/tests/components/modbus/test.esp32-ard.yaml @@ -1,9 +1,6 @@ -uart: - - id: uart_modbus - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + flow_control_pin: GPIO13 -modbus: - id: mod_bus1 - flow_control_pin: 15 +<<: !include common.yaml diff --git a/tests/components/modbus/test.esp32-c3-ard.yaml b/tests/components/modbus/test.esp32-c3-ard.yaml index d22b507be0..452031a5aa 100644 --- a/tests/components/modbus/test.esp32-c3-ard.yaml +++ b/tests/components/modbus/test.esp32-c3-ard.yaml @@ -1,9 +1,6 @@ -uart: - - id: uart_modbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - id: mod_bus1 - flow_control_pin: 6 +<<: !include common.yaml diff --git a/tests/components/modbus/test.esp32-c3-idf.yaml b/tests/components/modbus/test.esp32-c3-idf.yaml index d22b507be0..452031a5aa 100644 --- a/tests/components/modbus/test.esp32-c3-idf.yaml +++ b/tests/components/modbus/test.esp32-c3-idf.yaml @@ -1,9 +1,6 @@ -uart: - - id: uart_modbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - id: mod_bus1 - flow_control_pin: 6 +<<: !include common.yaml diff --git a/tests/components/modbus/test.esp32-idf.yaml b/tests/components/modbus/test.esp32-idf.yaml index 20cf238b1b..bd767a8ece 100644 --- a/tests/components/modbus/test.esp32-idf.yaml +++ b/tests/components/modbus/test.esp32-idf.yaml @@ -1,9 +1,6 @@ -uart: - - id: uart_modbus - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO12 + rx_pin: GPIO14 + flow_control_pin: GPIO13 -modbus: - id: mod_bus1 - flow_control_pin: 15 +<<: !include common.yaml diff --git a/tests/components/modbus/test.esp8266-ard.yaml b/tests/components/modbus/test.esp8266-ard.yaml index 560c044766..29c98d0957 100644 --- a/tests/components/modbus/test.esp8266-ard.yaml +++ b/tests/components/modbus/test.esp8266-ard.yaml @@ -1,9 +1,6 @@ -uart: - - id: uart_modbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO13 -modbus: - id: mod_bus1 - flow_control_pin: 12 +<<: !include common.yaml diff --git a/tests/components/modbus/test.rp2040-ard.yaml b/tests/components/modbus/test.rp2040-ard.yaml index d22b507be0..452031a5aa 100644 --- a/tests/components/modbus/test.rp2040-ard.yaml +++ b/tests/components/modbus/test.rp2040-ard.yaml @@ -1,9 +1,6 @@ -uart: - - id: uart_modbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + flow_control_pin: GPIO3 -modbus: - id: mod_bus1 - flow_control_pin: 6 +<<: !include common.yaml diff --git a/tests/components/modbus_controller/common.yaml b/tests/components/modbus_controller/common.yaml new file mode 100644 index 0000000000..93d8391ff5 --- /dev/null +++ b/tests/components/modbus_controller/common.yaml @@ -0,0 +1,35 @@ +uart: + - id: uart_modbus_client + tx_pin: ${client_tx_pin} + rx_pin: ${client_rx_pin} + baud_rate: 9600 + - id: uart_modbus_server + tx_pin: ${server_tx_pin} + rx_pin: ${server_rx_pin} + baud_rate: 9600 + +modbus: + - id: mod_bus1 + uart_id: uart_modbus_client + flow_control_pin: ${flow_control_pin} + - id: mod_bus2 + uart_id: uart_modbus_server + role: server + +modbus_controller: + - id: modbus_controller1 + address: 0x2 + modbus_id: mod_bus1 + allow_duplicate_commands: false + on_online: + then: + logger.log: "Module Online" + - id: modbus_controller2 + address: 0x2 + modbus_id: mod_bus2 + server_registers: + - address: 0x0000 + value_type: S_DWORD_R + read_lambda: |- + return 42.3; + max_cmd_retries: 0 diff --git a/tests/components/modbus_controller/test.esp32-ard.yaml b/tests/components/modbus_controller/test.esp32-ard.yaml index f5c5c10125..548b8c0666 100644 --- a/tests/components/modbus_controller/test.esp32-ard.yaml +++ b/tests/components/modbus_controller/test.esp32-ard.yaml @@ -1,35 +1,8 @@ -uart: - - id: uart_modbus_client - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - - id: uart_modbus_server - tx_pin: 1 - rx_pin: 3 - baud_rate: 9600 +substitutions: + client_tx_pin: GPIO12 + client_rx_pin: GPIO14 + server_tx_pin: GPIO16 + server_rx_pin: GPIO17 + flow_control_pin: GPIO13 -modbus: - - id: mod_bus1 - uart_id: uart_modbus_client - flow_control_pin: 15 - - id: mod_bus2 - uart_id: uart_modbus_server - role: server - -modbus_controller: - - id: modbus_controller1 - address: 0x2 - modbus_id: mod_bus1 - allow_duplicate_commands: false - on_online: - then: - logger.log: "Module Online" - - id: modbus_controller2 - address: 0x2 - modbus_id: mod_bus2 - server_registers: - - address: 0x0000 - value_type: S_DWORD_R - read_lambda: |- - return 42.3; - max_cmd_retries: 0 +<<: !include common.yaml diff --git a/tests/components/modbus_controller/test.esp32-c3-ard.yaml b/tests/components/modbus_controller/test.esp32-c3-ard.yaml index 476e65ecb0..f5b770ff58 100644 --- a/tests/components/modbus_controller/test.esp32-c3-ard.yaml +++ b/tests/components/modbus_controller/test.esp32-c3-ard.yaml @@ -1,14 +1,8 @@ -uart: - - id: uart_modbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + client_tx_pin: GPIO4 + client_rx_pin: GPIO5 + server_tx_pin: GPIO6 + server_rx_pin: GPIO7 + flow_control_pin: GPIO3 -modbus: - id: mod_bus1 - flow_control_pin: 6 - -modbus_controller: - - id: modbus_controller1 - address: 0x2 - modbus_id: mod_bus1 +<<: !include common.yaml diff --git a/tests/components/modbus_controller/test.esp32-c3-idf.yaml b/tests/components/modbus_controller/test.esp32-c3-idf.yaml index 476e65ecb0..f5b770ff58 100644 --- a/tests/components/modbus_controller/test.esp32-c3-idf.yaml +++ b/tests/components/modbus_controller/test.esp32-c3-idf.yaml @@ -1,14 +1,8 @@ -uart: - - id: uart_modbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + client_tx_pin: GPIO4 + client_rx_pin: GPIO5 + server_tx_pin: GPIO6 + server_rx_pin: GPIO7 + flow_control_pin: GPIO3 -modbus: - id: mod_bus1 - flow_control_pin: 6 - -modbus_controller: - - id: modbus_controller1 - address: 0x2 - modbus_id: mod_bus1 +<<: !include common.yaml diff --git a/tests/components/modbus_controller/test.esp32-idf.yaml b/tests/components/modbus_controller/test.esp32-idf.yaml index 0e1849dd88..548b8c0666 100644 --- a/tests/components/modbus_controller/test.esp32-idf.yaml +++ b/tests/components/modbus_controller/test.esp32-idf.yaml @@ -1,19 +1,8 @@ -uart: - - id: uart_modbus - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + client_tx_pin: GPIO12 + client_rx_pin: GPIO14 + server_tx_pin: GPIO16 + server_rx_pin: GPIO17 + flow_control_pin: GPIO13 -modbus: - id: mod_bus1 - flow_control_pin: 15 - -modbus_controller: - - id: modbus_controller1 - address: 0x2 - modbus_id: mod_bus1 - allow_duplicate_commands: true - on_offline: - then: - logger.log: "Module Offline" - max_cmd_retries: 10 +<<: !include common.yaml diff --git a/tests/components/modbus_controller/test.esp8266-ard.yaml b/tests/components/modbus_controller/test.esp8266-ard.yaml index 67cac65d1b..c68a57cbde 100644 --- a/tests/components/modbus_controller/test.esp8266-ard.yaml +++ b/tests/components/modbus_controller/test.esp8266-ard.yaml @@ -1,14 +1,8 @@ -uart: - - id: uart_modbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + client_tx_pin: GPIO1 + client_rx_pin: GPIO3 + server_tx_pin: GPIO4 + server_rx_pin: GPIO5 + flow_control_pin: GPIO13 -modbus: - id: mod_bus1 - flow_control_pin: 12 - -modbus_controller: - - id: modbus_controller1 - address: 0x2 - modbus_id: mod_bus1 +<<: !include common.yaml diff --git a/tests/components/modbus_controller/test.rp2040-ard.yaml b/tests/components/modbus_controller/test.rp2040-ard.yaml index 476e65ecb0..80528bc12b 100644 --- a/tests/components/modbus_controller/test.rp2040-ard.yaml +++ b/tests/components/modbus_controller/test.rp2040-ard.yaml @@ -1,14 +1,8 @@ -uart: - - id: uart_modbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + client_tx_pin: GPIO2 + client_rx_pin: GPIO3 + server_tx_pin: GPIO4 + server_rx_pin: GPIO5 + flow_control_pin: GPIO6 -modbus: - id: mod_bus1 - flow_control_pin: 6 - -modbus_controller: - - id: modbus_controller1 - address: 0x2 - modbus_id: mod_bus1 +<<: !include common.yaml diff --git a/tests/components/monochromatic/common.yaml b/tests/components/monochromatic/common.yaml new file mode 100644 index 0000000000..9915e086eb --- /dev/null +++ b/tests/components/monochromatic/common.yaml @@ -0,0 +1,40 @@ +output: + - platform: ${light_platform} + id: light_output_1 + pin: ${pin} + +light: + - platform: monochromatic + name: Monochromatic Light + id: monochromatic_light + output: light_output_1 + gamma_correct: 2.8 + default_transition_length: 2s + effects: + - strobe: + - flicker: + - flicker: + name: My Flicker + alpha: 98% + intensity: 1.5% + - lambda: + name: My Custom Effect + update_interval: 1s + lambda: |- + static int state = 0; + state += 1; + if (state == 4) + state = 0; + - pulse: + transition_length: 10s + update_interval: 20s + min_brightness: 10% + max_brightness: 90% + - pulse: + name: pulse2 + transition_length: + on_length: 10s + off_length: 5s + update_interval: 15s + min_brightness: 10% + max_brightness: 90% diff --git a/tests/components/monochromatic/test.esp32-ard.yaml b/tests/components/monochromatic/test.esp32-ard.yaml index 9524efcb2d..feabf013fd 100644 --- a/tests/components/monochromatic/test.esp32-ard.yaml +++ b/tests/components/monochromatic/test.esp32-ard.yaml @@ -1,40 +1,5 @@ -output: - - platform: ledc - id: light_output_1 - pin: 4 +substitutions: + light_platform: ledc + pin: GPIO2 -light: - - platform: monochromatic - name: Monochromatic Light - id: monochromatic_light - output: light_output_1 - gamma_correct: 2.8 - default_transition_length: 2s - effects: - - strobe: - - flicker: - - flicker: - name: My Flicker - alpha: 98% - intensity: 1.5% - - lambda: - name: My Custom Effect - update_interval: 1s - lambda: |- - static int state = 0; - state += 1; - if (state == 4) - state = 0; - - pulse: - transition_length: 10s - update_interval: 20s - min_brightness: 10% - max_brightness: 90% - - pulse: - name: pulse2 - transition_length: - on_length: 10s - off_length: 5s - update_interval: 15s - min_brightness: 10% - max_brightness: 90% +<<: !include common.yaml diff --git a/tests/components/monochromatic/test.esp32-c3-ard.yaml b/tests/components/monochromatic/test.esp32-c3-ard.yaml index 9524efcb2d..feabf013fd 100644 --- a/tests/components/monochromatic/test.esp32-c3-ard.yaml +++ b/tests/components/monochromatic/test.esp32-c3-ard.yaml @@ -1,40 +1,5 @@ -output: - - platform: ledc - id: light_output_1 - pin: 4 +substitutions: + light_platform: ledc + pin: GPIO2 -light: - - platform: monochromatic - name: Monochromatic Light - id: monochromatic_light - output: light_output_1 - gamma_correct: 2.8 - default_transition_length: 2s - effects: - - strobe: - - flicker: - - flicker: - name: My Flicker - alpha: 98% - intensity: 1.5% - - lambda: - name: My Custom Effect - update_interval: 1s - lambda: |- - static int state = 0; - state += 1; - if (state == 4) - state = 0; - - pulse: - transition_length: 10s - update_interval: 20s - min_brightness: 10% - max_brightness: 90% - - pulse: - name: pulse2 - transition_length: - on_length: 10s - off_length: 5s - update_interval: 15s - min_brightness: 10% - max_brightness: 90% +<<: !include common.yaml diff --git a/tests/components/monochromatic/test.esp32-c3-idf.yaml b/tests/components/monochromatic/test.esp32-c3-idf.yaml index 9524efcb2d..feabf013fd 100644 --- a/tests/components/monochromatic/test.esp32-c3-idf.yaml +++ b/tests/components/monochromatic/test.esp32-c3-idf.yaml @@ -1,40 +1,5 @@ -output: - - platform: ledc - id: light_output_1 - pin: 4 +substitutions: + light_platform: ledc + pin: GPIO2 -light: - - platform: monochromatic - name: Monochromatic Light - id: monochromatic_light - output: light_output_1 - gamma_correct: 2.8 - default_transition_length: 2s - effects: - - strobe: - - flicker: - - flicker: - name: My Flicker - alpha: 98% - intensity: 1.5% - - lambda: - name: My Custom Effect - update_interval: 1s - lambda: |- - static int state = 0; - state += 1; - if (state == 4) - state = 0; - - pulse: - transition_length: 10s - update_interval: 20s - min_brightness: 10% - max_brightness: 90% - - pulse: - name: pulse2 - transition_length: - on_length: 10s - off_length: 5s - update_interval: 15s - min_brightness: 10% - max_brightness: 90% +<<: !include common.yaml diff --git a/tests/components/monochromatic/test.esp32-idf.yaml b/tests/components/monochromatic/test.esp32-idf.yaml index 9524efcb2d..feabf013fd 100644 --- a/tests/components/monochromatic/test.esp32-idf.yaml +++ b/tests/components/monochromatic/test.esp32-idf.yaml @@ -1,40 +1,5 @@ -output: - - platform: ledc - id: light_output_1 - pin: 4 +substitutions: + light_platform: ledc + pin: GPIO2 -light: - - platform: monochromatic - name: Monochromatic Light - id: monochromatic_light - output: light_output_1 - gamma_correct: 2.8 - default_transition_length: 2s - effects: - - strobe: - - flicker: - - flicker: - name: My Flicker - alpha: 98% - intensity: 1.5% - - lambda: - name: My Custom Effect - update_interval: 1s - lambda: |- - static int state = 0; - state += 1; - if (state == 4) - state = 0; - - pulse: - transition_length: 10s - update_interval: 20s - min_brightness: 10% - max_brightness: 90% - - pulse: - name: pulse2 - transition_length: - on_length: 10s - off_length: 5s - update_interval: 15s - min_brightness: 10% - max_brightness: 90% +<<: !include common.yaml diff --git a/tests/components/monochromatic/test.esp8266-ard.yaml b/tests/components/monochromatic/test.esp8266-ard.yaml index 94d849581d..65bfb329f1 100644 --- a/tests/components/monochromatic/test.esp8266-ard.yaml +++ b/tests/components/monochromatic/test.esp8266-ard.yaml @@ -1,40 +1,5 @@ -output: - - platform: esp8266_pwm - id: light_output_1 - pin: 4 +substitutions: + light_platform: esp8266_pwm + pin: GPIO5 -light: - - platform: monochromatic - name: Monochromatic Light - id: monochromatic_light - output: light_output_1 - gamma_correct: 2.8 - default_transition_length: 2s - effects: - - strobe: - - flicker: - - flicker: - name: My Flicker - alpha: 98% - intensity: 1.5% - - lambda: - name: My Custom Effect - update_interval: 1s - lambda: |- - static int state = 0; - state += 1; - if (state == 4) - state = 0; - - pulse: - transition_length: 10s - update_interval: 20s - min_brightness: 10% - max_brightness: 90% - - pulse: - name: pulse2 - transition_length: - on_length: 10s - off_length: 5s - update_interval: 15s - min_brightness: 10% - max_brightness: 90% +<<: !include common.yaml diff --git a/tests/components/monochromatic/test.rp2040-ard.yaml b/tests/components/monochromatic/test.rp2040-ard.yaml index 093577e256..d329597d46 100644 --- a/tests/components/monochromatic/test.rp2040-ard.yaml +++ b/tests/components/monochromatic/test.rp2040-ard.yaml @@ -1,40 +1,5 @@ -output: - - platform: rp2040_pwm - id: light_output_1 - pin: 4 +substitutions: + light_platform: rp2040_pwm + pin: GPIO2 -light: - - platform: monochromatic - name: Monochromatic Light - id: monochromatic_light - output: light_output_1 - gamma_correct: 2.8 - default_transition_length: 2s - effects: - - strobe: - - flicker: - - flicker: - name: My Flicker - alpha: 98% - intensity: 1.5% - - lambda: - name: My Custom Effect - update_interval: 1s - lambda: |- - static int state = 0; - state += 1; - if (state == 4) - state = 0; - - pulse: - transition_length: 10s - update_interval: 20s - min_brightness: 10% - max_brightness: 90% - - pulse: - name: pulse2 - transition_length: - on_length: 10s - off_length: 5s - update_interval: 15s - min_brightness: 10% - max_brightness: 90% +<<: !include common.yaml diff --git a/tests/components/mpl3115a2/common.yaml b/tests/components/mpl3115a2/common.yaml new file mode 100644 index 0000000000..f2f65885b3 --- /dev/null +++ b/tests/components/mpl3115a2/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_mpl3115a2 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: mpl3115a2 + temperature: + name: MPL3115A2 Temperature + pressure: + name: MPL3115A2 Pressure + update_interval: 10s diff --git a/tests/components/mpl3115a2/test.esp32-ard.yaml b/tests/components/mpl3115a2/test.esp32-ard.yaml index 5e9d6d190d..63c3bd6afd 100644 --- a/tests/components/mpl3115a2/test.esp32-ard.yaml +++ b/tests/components/mpl3115a2/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mpl3115a2 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mpl3115a2 - temperature: - name: MPL3115A2 Temperature - pressure: - name: MPL3115A2 Pressure - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/mpl3115a2/test.esp32-c3-ard.yaml b/tests/components/mpl3115a2/test.esp32-c3-ard.yaml index 9cbe08d920..ee2c29ca4e 100644 --- a/tests/components/mpl3115a2/test.esp32-c3-ard.yaml +++ b/tests/components/mpl3115a2/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mpl3115a2 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpl3115a2 - temperature: - name: MPL3115A2 Temperature - pressure: - name: MPL3115A2 Pressure - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/mpl3115a2/test.esp32-c3-idf.yaml b/tests/components/mpl3115a2/test.esp32-c3-idf.yaml index 9cbe08d920..ee2c29ca4e 100644 --- a/tests/components/mpl3115a2/test.esp32-c3-idf.yaml +++ b/tests/components/mpl3115a2/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mpl3115a2 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpl3115a2 - temperature: - name: MPL3115A2 Temperature - pressure: - name: MPL3115A2 Pressure - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/mpl3115a2/test.esp32-idf.yaml b/tests/components/mpl3115a2/test.esp32-idf.yaml index 5e9d6d190d..63c3bd6afd 100644 --- a/tests/components/mpl3115a2/test.esp32-idf.yaml +++ b/tests/components/mpl3115a2/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mpl3115a2 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mpl3115a2 - temperature: - name: MPL3115A2 Temperature - pressure: - name: MPL3115A2 Pressure - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/mpl3115a2/test.esp8266-ard.yaml b/tests/components/mpl3115a2/test.esp8266-ard.yaml index 9cbe08d920..ee2c29ca4e 100644 --- a/tests/components/mpl3115a2/test.esp8266-ard.yaml +++ b/tests/components/mpl3115a2/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mpl3115a2 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpl3115a2 - temperature: - name: MPL3115A2 Temperature - pressure: - name: MPL3115A2 Pressure - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/mpl3115a2/test.rp2040-ard.yaml b/tests/components/mpl3115a2/test.rp2040-ard.yaml index 9cbe08d920..ee2c29ca4e 100644 --- a/tests/components/mpl3115a2/test.rp2040-ard.yaml +++ b/tests/components/mpl3115a2/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_mpl3115a2 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpl3115a2 - temperature: - name: MPL3115A2 Temperature - pressure: - name: MPL3115A2 Pressure - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/mpu6050/common.yaml b/tests/components/mpu6050/common.yaml new file mode 100644 index 0000000000..e9d4995534 --- /dev/null +++ b/tests/components/mpu6050/common.yaml @@ -0,0 +1,22 @@ +i2c: + - id: i2c_mpu6050 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: mpu6050 + address: 0x68 + accel_x: + name: MPU6050 Accel X + accel_y: + name: MPU6050 Accel Y + accel_z: + name: MPU6050 Accel z + gyro_x: + name: MPU6050 Gyro X + gyro_y: + name: MPU6050 Gyro Y + gyro_z: + name: MPU6050 Gyro z + temperature: + name: MPU6050 Temperature diff --git a/tests/components/mpu6050/test.esp32-ard.yaml b/tests/components/mpu6050/test.esp32-ard.yaml index 45bca55dea..63c3bd6afd 100644 --- a/tests/components/mpu6050/test.esp32-ard.yaml +++ b/tests/components/mpu6050/test.esp32-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6050 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mpu6050 - address: 0x68 - accel_x: - name: MPU6050 Accel X - accel_y: - name: MPU6050 Accel Y - accel_z: - name: MPU6050 Accel z - gyro_x: - name: MPU6050 Gyro X - gyro_y: - name: MPU6050 Gyro Y - gyro_z: - name: MPU6050 Gyro z - temperature: - name: MPU6050 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6050/test.esp32-c3-ard.yaml b/tests/components/mpu6050/test.esp32-c3-ard.yaml index 39c8506d2b..ee2c29ca4e 100644 --- a/tests/components/mpu6050/test.esp32-c3-ard.yaml +++ b/tests/components/mpu6050/test.esp32-c3-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6050 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpu6050 - address: 0x68 - accel_x: - name: MPU6050 Accel X - accel_y: - name: MPU6050 Accel Y - accel_z: - name: MPU6050 Accel z - gyro_x: - name: MPU6050 Gyro X - gyro_y: - name: MPU6050 Gyro Y - gyro_z: - name: MPU6050 Gyro z - temperature: - name: MPU6050 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6050/test.esp32-c3-idf.yaml b/tests/components/mpu6050/test.esp32-c3-idf.yaml index 39c8506d2b..ee2c29ca4e 100644 --- a/tests/components/mpu6050/test.esp32-c3-idf.yaml +++ b/tests/components/mpu6050/test.esp32-c3-idf.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6050 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpu6050 - address: 0x68 - accel_x: - name: MPU6050 Accel X - accel_y: - name: MPU6050 Accel Y - accel_z: - name: MPU6050 Accel z - gyro_x: - name: MPU6050 Gyro X - gyro_y: - name: MPU6050 Gyro Y - gyro_z: - name: MPU6050 Gyro z - temperature: - name: MPU6050 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6050/test.esp32-idf.yaml b/tests/components/mpu6050/test.esp32-idf.yaml index 45bca55dea..63c3bd6afd 100644 --- a/tests/components/mpu6050/test.esp32-idf.yaml +++ b/tests/components/mpu6050/test.esp32-idf.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6050 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mpu6050 - address: 0x68 - accel_x: - name: MPU6050 Accel X - accel_y: - name: MPU6050 Accel Y - accel_z: - name: MPU6050 Accel z - gyro_x: - name: MPU6050 Gyro X - gyro_y: - name: MPU6050 Gyro Y - gyro_z: - name: MPU6050 Gyro z - temperature: - name: MPU6050 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6050/test.esp8266-ard.yaml b/tests/components/mpu6050/test.esp8266-ard.yaml index 39c8506d2b..ee2c29ca4e 100644 --- a/tests/components/mpu6050/test.esp8266-ard.yaml +++ b/tests/components/mpu6050/test.esp8266-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6050 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpu6050 - address: 0x68 - accel_x: - name: MPU6050 Accel X - accel_y: - name: MPU6050 Accel Y - accel_z: - name: MPU6050 Accel z - gyro_x: - name: MPU6050 Gyro X - gyro_y: - name: MPU6050 Gyro Y - gyro_z: - name: MPU6050 Gyro z - temperature: - name: MPU6050 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6050/test.rp2040-ard.yaml b/tests/components/mpu6050/test.rp2040-ard.yaml index 39c8506d2b..ee2c29ca4e 100644 --- a/tests/components/mpu6050/test.rp2040-ard.yaml +++ b/tests/components/mpu6050/test.rp2040-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6050 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpu6050 - address: 0x68 - accel_x: - name: MPU6050 Accel X - accel_y: - name: MPU6050 Accel Y - accel_z: - name: MPU6050 Accel z - gyro_x: - name: MPU6050 Gyro X - gyro_y: - name: MPU6050 Gyro Y - gyro_z: - name: MPU6050 Gyro z - temperature: - name: MPU6050 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6886/common.yaml b/tests/components/mpu6886/common.yaml new file mode 100644 index 0000000000..9c3e283cc3 --- /dev/null +++ b/tests/components/mpu6886/common.yaml @@ -0,0 +1,22 @@ +i2c: + - id: i2c_mpu6886 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: mpu6886 + address: 0x68 + accel_x: + name: MPU6886 Accel X + accel_y: + name: MPU6886 Accel Y + accel_z: + name: MPU6886 Accel z + gyro_x: + name: MPU6886 Gyro X + gyro_y: + name: MPU6886 Gyro Y + gyro_z: + name: MPU6886 Gyro z + temperature: + name: MPU6886 Temperature diff --git a/tests/components/mpu6886/test.esp32-ard.yaml b/tests/components/mpu6886/test.esp32-ard.yaml index 84e4d56739..63c3bd6afd 100644 --- a/tests/components/mpu6886/test.esp32-ard.yaml +++ b/tests/components/mpu6886/test.esp32-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6886 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mpu6886 - address: 0x68 - accel_x: - name: MPU6886 Accel X - accel_y: - name: MPU6886 Accel Y - accel_z: - name: MPU6886 Accel z - gyro_x: - name: MPU6886 Gyro X - gyro_y: - name: MPU6886 Gyro Y - gyro_z: - name: MPU6886 Gyro z - temperature: - name: MPU6886 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6886/test.esp32-c3-ard.yaml b/tests/components/mpu6886/test.esp32-c3-ard.yaml index fad51a80b4..ee2c29ca4e 100644 --- a/tests/components/mpu6886/test.esp32-c3-ard.yaml +++ b/tests/components/mpu6886/test.esp32-c3-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6886 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpu6886 - address: 0x68 - accel_x: - name: MPU6886 Accel X - accel_y: - name: MPU6886 Accel Y - accel_z: - name: MPU6886 Accel z - gyro_x: - name: MPU6886 Gyro X - gyro_y: - name: MPU6886 Gyro Y - gyro_z: - name: MPU6886 Gyro z - temperature: - name: MPU6886 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6886/test.esp32-c3-idf.yaml b/tests/components/mpu6886/test.esp32-c3-idf.yaml index fad51a80b4..ee2c29ca4e 100644 --- a/tests/components/mpu6886/test.esp32-c3-idf.yaml +++ b/tests/components/mpu6886/test.esp32-c3-idf.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6886 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpu6886 - address: 0x68 - accel_x: - name: MPU6886 Accel X - accel_y: - name: MPU6886 Accel Y - accel_z: - name: MPU6886 Accel z - gyro_x: - name: MPU6886 Gyro X - gyro_y: - name: MPU6886 Gyro Y - gyro_z: - name: MPU6886 Gyro z - temperature: - name: MPU6886 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6886/test.esp32-idf.yaml b/tests/components/mpu6886/test.esp32-idf.yaml index 84e4d56739..63c3bd6afd 100644 --- a/tests/components/mpu6886/test.esp32-idf.yaml +++ b/tests/components/mpu6886/test.esp32-idf.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6886 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: mpu6886 - address: 0x68 - accel_x: - name: MPU6886 Accel X - accel_y: - name: MPU6886 Accel Y - accel_z: - name: MPU6886 Accel z - gyro_x: - name: MPU6886 Gyro X - gyro_y: - name: MPU6886 Gyro Y - gyro_z: - name: MPU6886 Gyro z - temperature: - name: MPU6886 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6886/test.esp8266-ard.yaml b/tests/components/mpu6886/test.esp8266-ard.yaml index fad51a80b4..ee2c29ca4e 100644 --- a/tests/components/mpu6886/test.esp8266-ard.yaml +++ b/tests/components/mpu6886/test.esp8266-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6886 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpu6886 - address: 0x68 - accel_x: - name: MPU6886 Accel X - accel_y: - name: MPU6886 Accel Y - accel_z: - name: MPU6886 Accel z - gyro_x: - name: MPU6886 Gyro X - gyro_y: - name: MPU6886 Gyro Y - gyro_z: - name: MPU6886 Gyro z - temperature: - name: MPU6886 Temperature +<<: !include common.yaml diff --git a/tests/components/mpu6886/test.rp2040-ard.yaml b/tests/components/mpu6886/test.rp2040-ard.yaml index fad51a80b4..ee2c29ca4e 100644 --- a/tests/components/mpu6886/test.rp2040-ard.yaml +++ b/tests/components/mpu6886/test.rp2040-ard.yaml @@ -1,22 +1,5 @@ -i2c: - - id: i2c_mpu6886 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: mpu6886 - address: 0x68 - accel_x: - name: MPU6886 Accel X - accel_y: - name: MPU6886 Accel Y - accel_z: - name: MPU6886 Accel z - gyro_x: - name: MPU6886 Gyro X - gyro_y: - name: MPU6886 Gyro Y - gyro_z: - name: MPU6886 Gyro z - temperature: - name: MPU6886 Temperature +<<: !include common.yaml diff --git a/tests/components/mqtt_subscribe/common-ard.yaml b/tests/components/mqtt_subscribe/common-ard.yaml new file mode 100644 index 0000000000..13ed311b17 --- /dev/null +++ b/tests/components/mqtt_subscribe/common-ard.yaml @@ -0,0 +1,36 @@ +wifi: + ssid: MySSID + password: password1 + +mqtt: + broker: test.mosquitto.org + port: 1883 + discovery: true + discovery_prefix: homeassistant + log_topic: + on_message: + topic: testing/sensor/testing_sensor/state + qos: 0 + then: + - logger.log: Mqtt Test + +sensor: + - platform: mqtt_subscribe + name: MQTT Subscribe Sensor + topic: mqtt/topic + id: the_sensor + qos: 2 + on_value: + - mqtt.publish_json: + topic: the/topic + payload: |- + root["key"] = id(the_sensor).state; + root["greeting"] = "Hello World"; + +text_sensor: + - platform: mqtt_subscribe + name: MQTT Subscribe Text + topic: "the/topic" + qos: 2 + on_value: + - logger.log: "Text sensor got value" diff --git a/tests/components/mqtt_subscribe/common-idf.yaml b/tests/components/mqtt_subscribe/common-idf.yaml new file mode 100644 index 0000000000..070672f15c --- /dev/null +++ b/tests/components/mqtt_subscribe/common-idf.yaml @@ -0,0 +1,37 @@ +wifi: + ssid: MySSID + password: password1 + +mqtt: + broker: test.mosquitto.org + port: 1883 + discovery: true + discovery_prefix: homeassistant + idf_send_async: false + log_topic: + on_message: + topic: testing/sensor/testing_sensor/state + qos: 0 + then: + - logger.log: Mqtt Test + +sensor: + - platform: mqtt_subscribe + name: MQTT Subscribe Sensor + topic: mqtt/topic + id: the_sensor + qos: 2 + on_value: + - mqtt.publish_json: + topic: the/topic + payload: |- + root["key"] = id(the_sensor).state; + root["greeting"] = "Hello World"; + +text_sensor: + - platform: mqtt_subscribe + name: MQTT Subscribe Text + topic: "the/topic" + qos: 2 + on_value: + - logger.log: "Text sensor got value" diff --git a/tests/components/mqtt_subscribe/test.esp32-ard.yaml b/tests/components/mqtt_subscribe/test.esp32-ard.yaml index 13ed311b17..28589ee06c 100644 --- a/tests/components/mqtt_subscribe/test.esp32-ard.yaml +++ b/tests/components/mqtt_subscribe/test.esp32-ard.yaml @@ -1,36 +1 @@ -wifi: - ssid: MySSID - password: password1 - -mqtt: - broker: test.mosquitto.org - port: 1883 - discovery: true - discovery_prefix: homeassistant - log_topic: - on_message: - topic: testing/sensor/testing_sensor/state - qos: 0 - then: - - logger.log: Mqtt Test - -sensor: - - platform: mqtt_subscribe - name: MQTT Subscribe Sensor - topic: mqtt/topic - id: the_sensor - qos: 2 - on_value: - - mqtt.publish_json: - topic: the/topic - payload: |- - root["key"] = id(the_sensor).state; - root["greeting"] = "Hello World"; - -text_sensor: - - platform: mqtt_subscribe - name: MQTT Subscribe Text - topic: "the/topic" - qos: 2 - on_value: - - logger.log: "Text sensor got value" +<<: !include common-ard.yaml diff --git a/tests/components/mqtt_subscribe/test.esp32-c3-ard.yaml b/tests/components/mqtt_subscribe/test.esp32-c3-ard.yaml index 13ed311b17..28589ee06c 100644 --- a/tests/components/mqtt_subscribe/test.esp32-c3-ard.yaml +++ b/tests/components/mqtt_subscribe/test.esp32-c3-ard.yaml @@ -1,36 +1 @@ -wifi: - ssid: MySSID - password: password1 - -mqtt: - broker: test.mosquitto.org - port: 1883 - discovery: true - discovery_prefix: homeassistant - log_topic: - on_message: - topic: testing/sensor/testing_sensor/state - qos: 0 - then: - - logger.log: Mqtt Test - -sensor: - - platform: mqtt_subscribe - name: MQTT Subscribe Sensor - topic: mqtt/topic - id: the_sensor - qos: 2 - on_value: - - mqtt.publish_json: - topic: the/topic - payload: |- - root["key"] = id(the_sensor).state; - root["greeting"] = "Hello World"; - -text_sensor: - - platform: mqtt_subscribe - name: MQTT Subscribe Text - topic: "the/topic" - qos: 2 - on_value: - - logger.log: "Text sensor got value" +<<: !include common-ard.yaml diff --git a/tests/components/mqtt_subscribe/test.esp32-c3-idf.yaml b/tests/components/mqtt_subscribe/test.esp32-c3-idf.yaml index 070672f15c..2cb6d82536 100644 --- a/tests/components/mqtt_subscribe/test.esp32-c3-idf.yaml +++ b/tests/components/mqtt_subscribe/test.esp32-c3-idf.yaml @@ -1,37 +1 @@ -wifi: - ssid: MySSID - password: password1 - -mqtt: - broker: test.mosquitto.org - port: 1883 - discovery: true - discovery_prefix: homeassistant - idf_send_async: false - log_topic: - on_message: - topic: testing/sensor/testing_sensor/state - qos: 0 - then: - - logger.log: Mqtt Test - -sensor: - - platform: mqtt_subscribe - name: MQTT Subscribe Sensor - topic: mqtt/topic - id: the_sensor - qos: 2 - on_value: - - mqtt.publish_json: - topic: the/topic - payload: |- - root["key"] = id(the_sensor).state; - root["greeting"] = "Hello World"; - -text_sensor: - - platform: mqtt_subscribe - name: MQTT Subscribe Text - topic: "the/topic" - qos: 2 - on_value: - - logger.log: "Text sensor got value" +<<: !include common-idf.yaml diff --git a/tests/components/mqtt_subscribe/test.esp32-idf.yaml b/tests/components/mqtt_subscribe/test.esp32-idf.yaml index 070672f15c..2cb6d82536 100644 --- a/tests/components/mqtt_subscribe/test.esp32-idf.yaml +++ b/tests/components/mqtt_subscribe/test.esp32-idf.yaml @@ -1,37 +1 @@ -wifi: - ssid: MySSID - password: password1 - -mqtt: - broker: test.mosquitto.org - port: 1883 - discovery: true - discovery_prefix: homeassistant - idf_send_async: false - log_topic: - on_message: - topic: testing/sensor/testing_sensor/state - qos: 0 - then: - - logger.log: Mqtt Test - -sensor: - - platform: mqtt_subscribe - name: MQTT Subscribe Sensor - topic: mqtt/topic - id: the_sensor - qos: 2 - on_value: - - mqtt.publish_json: - topic: the/topic - payload: |- - root["key"] = id(the_sensor).state; - root["greeting"] = "Hello World"; - -text_sensor: - - platform: mqtt_subscribe - name: MQTT Subscribe Text - topic: "the/topic" - qos: 2 - on_value: - - logger.log: "Text sensor got value" +<<: !include common-idf.yaml diff --git a/tests/components/mqtt_subscribe/test.esp8266-ard.yaml b/tests/components/mqtt_subscribe/test.esp8266-ard.yaml index 13ed311b17..28589ee06c 100644 --- a/tests/components/mqtt_subscribe/test.esp8266-ard.yaml +++ b/tests/components/mqtt_subscribe/test.esp8266-ard.yaml @@ -1,36 +1 @@ -wifi: - ssid: MySSID - password: password1 - -mqtt: - broker: test.mosquitto.org - port: 1883 - discovery: true - discovery_prefix: homeassistant - log_topic: - on_message: - topic: testing/sensor/testing_sensor/state - qos: 0 - then: - - logger.log: Mqtt Test - -sensor: - - platform: mqtt_subscribe - name: MQTT Subscribe Sensor - topic: mqtt/topic - id: the_sensor - qos: 2 - on_value: - - mqtt.publish_json: - topic: the/topic - payload: |- - root["key"] = id(the_sensor).state; - root["greeting"] = "Hello World"; - -text_sensor: - - platform: mqtt_subscribe - name: MQTT Subscribe Text - topic: "the/topic" - qos: 2 - on_value: - - logger.log: "Text sensor got value" +<<: !include common-ard.yaml diff --git a/tests/components/ms5611/common.yaml b/tests/components/ms5611/common.yaml new file mode 100644 index 0000000000..d0417faa86 --- /dev/null +++ b/tests/components/ms5611/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_ms5611 + scl: ${i2c_scl} + sda: ${i2c_sda} + +sensor: + - platform: ms5611 + temperature: + name: Outside Temperature + pressure: + name: Outside Pressure + address: 0x77 + update_interval: 15s diff --git a/tests/components/ms5611/test.esp32-ard.yaml b/tests/components/ms5611/test.esp32-ard.yaml index b090eeaa93..1037d5d35b 100644 --- a/tests/components/ms5611/test.esp32-ard.yaml +++ b/tests/components/ms5611/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ms5611 - scl: 16 - sda: 17 +substitutions: + i2c_scl: GPIO16 + i2c_sda: GPIO17 -sensor: - - platform: ms5611 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - address: 0x77 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ms5611/test.esp32-c3-ard.yaml b/tests/components/ms5611/test.esp32-c3-ard.yaml index 8f18501eef..d7ae0d5161 100644 --- a/tests/components/ms5611/test.esp32-c3-ard.yaml +++ b/tests/components/ms5611/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ms5611 - scl: 5 - sda: 4 +substitutions: + i2c_scl: GPIO5 + i2c_sda: GPIO4 -sensor: - - platform: ms5611 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - address: 0x77 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ms5611/test.esp32-c3-idf.yaml b/tests/components/ms5611/test.esp32-c3-idf.yaml index 8f18501eef..d7ae0d5161 100644 --- a/tests/components/ms5611/test.esp32-c3-idf.yaml +++ b/tests/components/ms5611/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ms5611 - scl: 5 - sda: 4 +substitutions: + i2c_scl: GPIO5 + i2c_sda: GPIO4 -sensor: - - platform: ms5611 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - address: 0x77 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ms5611/test.esp32-idf.yaml b/tests/components/ms5611/test.esp32-idf.yaml index b090eeaa93..1037d5d35b 100644 --- a/tests/components/ms5611/test.esp32-idf.yaml +++ b/tests/components/ms5611/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ms5611 - scl: 16 - sda: 17 +substitutions: + i2c_scl: GPIO16 + i2c_sda: GPIO17 -sensor: - - platform: ms5611 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - address: 0x77 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ms5611/test.esp8266-ard.yaml b/tests/components/ms5611/test.esp8266-ard.yaml index 8f18501eef..d7ae0d5161 100644 --- a/tests/components/ms5611/test.esp8266-ard.yaml +++ b/tests/components/ms5611/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ms5611 - scl: 5 - sda: 4 +substitutions: + i2c_scl: GPIO5 + i2c_sda: GPIO4 -sensor: - - platform: ms5611 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - address: 0x77 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ms5611/test.rp2040-ard.yaml b/tests/components/ms5611/test.rp2040-ard.yaml index 8f18501eef..d7ae0d5161 100644 --- a/tests/components/ms5611/test.rp2040-ard.yaml +++ b/tests/components/ms5611/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_ms5611 - scl: 5 - sda: 4 +substitutions: + i2c_scl: GPIO5 + i2c_sda: GPIO4 -sensor: - - platform: ms5611 - temperature: - name: Outside Temperature - pressure: - name: Outside Pressure - address: 0x77 - update_interval: 15s +<<: !include common.yaml From 55203143dfb057ff78fcfff6e0cce16e7ce8d391 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 17:06:08 -0600 Subject: [PATCH 154/194] [CI] Consolidate some tests (I, J) (#8200) --- tests/components/i2c/common.yaml | 4 ++ tests/components/i2c/test.esp32-ard.yaml | 9 ++-- tests/components/i2c/test.esp32-c3-ard.yaml | 9 ++-- tests/components/i2c/test.esp32-c3-idf.yaml | 9 ++-- tests/components/i2c/test.esp32-idf.yaml | 9 ++-- tests/components/i2c/test.esp8266-ard.yaml | 9 ++-- tests/components/i2c/test.rp2040-ard.yaml | 9 ++-- tests/components/i2c_device/common.yaml | 8 ++++ .../components/i2c_device/test.esp32-ard.yaml | 11 ++--- .../i2c_device/test.esp32-c3-ard.yaml | 11 ++--- .../i2c_device/test.esp32-c3-idf.yaml | 11 ++--- .../components/i2c_device/test.esp32-idf.yaml | 11 ++--- .../i2c_device/test.esp8266-ard.yaml | 11 ++--- .../i2c_device/test.rp2040-ard.yaml | 11 ++--- tests/components/i2s_audio/common.yaml | 4 ++ .../components/i2s_audio/test.esp32-ard.yaml | 10 ++-- .../i2s_audio/test.esp32-c3-ard.yaml | 10 ++-- .../i2s_audio/test.esp32-c3-idf.yaml | 10 ++-- .../components/i2s_audio/test.esp32-idf.yaml | 10 ++-- tests/components/iaqcore/common.yaml | 11 +++++ tests/components/iaqcore/test.esp32-ard.yaml | 14 ++---- .../components/iaqcore/test.esp32-c3-ard.yaml | 14 ++---- .../components/iaqcore/test.esp32-c3-idf.yaml | 14 ++---- tests/components/iaqcore/test.esp32-idf.yaml | 14 ++---- .../components/iaqcore/test.esp8266-ard.yaml | 14 ++---- tests/components/iaqcore/test.rp2040-ard.yaml | 14 ++---- tests/components/ili9xxx/common.yaml | 36 +++++++++++++++ tests/components/ili9xxx/test.esp32-ard.yaml | 45 ++++-------------- .../components/ili9xxx/test.esp32-c3-ard.yaml | 46 +++++-------------- .../components/ili9xxx/test.esp32-c3-idf.yaml | 46 +++++-------------- tests/components/ili9xxx/test.esp32-idf.yaml | 32 ++++--------- .../components/ili9xxx/test.esp8266-ard.yaml | 46 +++++-------------- tests/components/ili9xxx/test.rp2040-ard.yaml | 46 +++++-------------- tests/components/ina219/common.yaml | 20 ++++++++ tests/components/ina219/test.esp32-ard.yaml | 23 ++-------- .../components/ina219/test.esp32-c3-ard.yaml | 23 ++-------- .../components/ina219/test.esp32-c3-idf.yaml | 23 ++-------- tests/components/ina219/test.esp32-idf.yaml | 23 ++-------- tests/components/ina219/test.esp8266-ard.yaml | 23 ++-------- tests/components/ina219/test.rp2040-ard.yaml | 23 ++-------- tests/components/ina226/common.yaml | 19 ++++++++ tests/components/ina226/test.esp32-ard.yaml | 22 ++------- .../components/ina226/test.esp32-c3-ard.yaml | 22 ++------- .../components/ina226/test.esp32-c3-idf.yaml | 22 ++------- tests/components/ina226/test.esp32-idf.yaml | 22 ++------- tests/components/ina226/test.esp8266-ard.yaml | 22 ++------- tests/components/ina226/test.rp2040-ard.yaml | 22 ++------- tests/components/ina260/common.yaml | 15 ++++++ tests/components/ina260/test.esp32-ard.yaml | 18 ++------ .../components/ina260/test.esp32-c3-ard.yaml | 18 ++------ .../components/ina260/test.esp32-c3-idf.yaml | 18 ++------ tests/components/ina260/test.esp32-idf.yaml | 18 ++------ tests/components/ina260/test.esp8266-ard.yaml | 18 ++------ tests/components/ina260/test.rp2040-ard.yaml | 18 ++------ tests/components/ina3221/common.yaml | 19 ++++++++ tests/components/ina3221/test.esp32-ard.yaml | 22 ++------- .../components/ina3221/test.esp32-c3-ard.yaml | 22 ++------- .../components/ina3221/test.esp32-c3-idf.yaml | 22 ++------- tests/components/ina3221/test.esp32-idf.yaml | 22 ++------- .../components/ina3221/test.esp8266-ard.yaml | 22 ++------- tests/components/ina3221/test.rp2040-ard.yaml | 22 ++------- ...st.esp32-s2-ard.yaml => common-esp32.yaml} | 4 +- .../integration/test.esp32-ard.yaml | 13 ++---- .../integration/test.esp32-c3-ard.yaml | 13 ++---- .../integration/test.esp32-c3-idf.yaml | 4 ++ .../integration/test.esp32-idf.yaml | 13 ++---- .../integration/test.esp32-s3-ard.yaml | 9 ---- .../internal_temperature/common.yaml | 3 ++ .../internal_temperature/test.bk72xx-ard.yaml | 4 +- .../internal_temperature/test.esp32-ard.yaml | 4 +- .../test.esp32-c3-ard.yaml | 4 +- .../test.esp32-c3-idf.yaml | 4 +- .../internal_temperature/test.esp32-idf.yaml | 4 +- .../test.esp32-s2-ard.yaml | 4 +- .../test.esp32-s2-idf.yaml | 1 + .../test.esp32-s3-ard.yaml | 4 +- .../test.esp32-s3-idf.yaml | 1 + .../internal_temperature/test.rp2040-ard.yaml | 4 +- tests/components/jsn_sr04t/common.yaml | 11 +++++ .../components/jsn_sr04t/test.esp32-ard.yaml | 17 ++----- .../jsn_sr04t/test.esp32-c3-ard.yaml | 17 ++----- .../jsn_sr04t/test.esp32-c3-idf.yaml | 17 ++----- .../components/jsn_sr04t/test.esp32-idf.yaml | 17 ++----- .../jsn_sr04t/test.esp8266-ard.yaml | 17 ++----- .../components/jsn_sr04t/test.rp2040-ard.yaml | 17 ++----- 85 files changed, 464 insertions(+), 893 deletions(-) create mode 100644 tests/components/i2c/common.yaml create mode 100644 tests/components/i2c_device/common.yaml create mode 100644 tests/components/i2s_audio/common.yaml create mode 100644 tests/components/iaqcore/common.yaml create mode 100644 tests/components/ili9xxx/common.yaml create mode 100644 tests/components/ina219/common.yaml create mode 100644 tests/components/ina226/common.yaml create mode 100644 tests/components/ina260/common.yaml create mode 100644 tests/components/ina3221/common.yaml rename tests/components/integration/{test.esp32-s2-ard.yaml => common-esp32.yaml} (78%) create mode 100644 tests/components/integration/test.esp32-c3-idf.yaml delete mode 100644 tests/components/integration/test.esp32-s3-ard.yaml create mode 100644 tests/components/internal_temperature/common.yaml create mode 100644 tests/components/internal_temperature/test.esp32-s2-idf.yaml create mode 100644 tests/components/internal_temperature/test.esp32-s3-idf.yaml create mode 100644 tests/components/jsn_sr04t/common.yaml diff --git a/tests/components/i2c/common.yaml b/tests/components/i2c/common.yaml new file mode 100644 index 0000000000..d70cd595ad --- /dev/null +++ b/tests/components/i2c/common.yaml @@ -0,0 +1,4 @@ +i2c: + - id: i2c_i2c + scl: ${scl_pin} + sda: ${sda_pin} diff --git a/tests/components/i2c/test.esp32-ard.yaml b/tests/components/i2c/test.esp32-ard.yaml index 19114a9e5d..63c3bd6afd 100644 --- a/tests/components/i2c/test.esp32-ard.yaml +++ b/tests/components/i2c/test.esp32-ard.yaml @@ -1,4 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/i2c/test.esp32-c3-ard.yaml b/tests/components/i2c/test.esp32-c3-ard.yaml index a881438faa..ee2c29ca4e 100644 --- a/tests/components/i2c/test.esp32-c3-ard.yaml +++ b/tests/components/i2c/test.esp32-c3-ard.yaml @@ -1,4 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/i2c/test.esp32-c3-idf.yaml b/tests/components/i2c/test.esp32-c3-idf.yaml index a881438faa..ee2c29ca4e 100644 --- a/tests/components/i2c/test.esp32-c3-idf.yaml +++ b/tests/components/i2c/test.esp32-c3-idf.yaml @@ -1,4 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/i2c/test.esp32-idf.yaml b/tests/components/i2c/test.esp32-idf.yaml index 19114a9e5d..63c3bd6afd 100644 --- a/tests/components/i2c/test.esp32-idf.yaml +++ b/tests/components/i2c/test.esp32-idf.yaml @@ -1,4 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/i2c/test.esp8266-ard.yaml b/tests/components/i2c/test.esp8266-ard.yaml index a881438faa..ee2c29ca4e 100644 --- a/tests/components/i2c/test.esp8266-ard.yaml +++ b/tests/components/i2c/test.esp8266-ard.yaml @@ -1,4 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/i2c/test.rp2040-ard.yaml b/tests/components/i2c/test.rp2040-ard.yaml index a881438faa..ee2c29ca4e 100644 --- a/tests/components/i2c/test.rp2040-ard.yaml +++ b/tests/components/i2c/test.rp2040-ard.yaml @@ -1,4 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/i2c_device/common.yaml b/tests/components/i2c_device/common.yaml new file mode 100644 index 0000000000..35a6f8f7f0 --- /dev/null +++ b/tests/components/i2c_device/common.yaml @@ -0,0 +1,8 @@ +i2c: + - id: i2c_i2c_device + scl: ${scl_pin} + sda: ${sda_pin} + +i2c_device: + id: i2cdev + address: 0x2C diff --git a/tests/components/i2c_device/test.esp32-ard.yaml b/tests/components/i2c_device/test.esp32-ard.yaml index 6169d113f8..63c3bd6afd 100644 --- a/tests/components/i2c_device/test.esp32-ard.yaml +++ b/tests/components/i2c_device/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c_device: - id: i2cdev - address: 0x2C +<<: !include common.yaml diff --git a/tests/components/i2c_device/test.esp32-c3-ard.yaml b/tests/components/i2c_device/test.esp32-c3-ard.yaml index 5d53d12208..ee2c29ca4e 100644 --- a/tests/components/i2c_device/test.esp32-c3-ard.yaml +++ b/tests/components/i2c_device/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c_device: - id: i2cdev - address: 0x2C +<<: !include common.yaml diff --git a/tests/components/i2c_device/test.esp32-c3-idf.yaml b/tests/components/i2c_device/test.esp32-c3-idf.yaml index 5d53d12208..ee2c29ca4e 100644 --- a/tests/components/i2c_device/test.esp32-c3-idf.yaml +++ b/tests/components/i2c_device/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c_device: - id: i2cdev - address: 0x2C +<<: !include common.yaml diff --git a/tests/components/i2c_device/test.esp32-idf.yaml b/tests/components/i2c_device/test.esp32-idf.yaml index 6169d113f8..63c3bd6afd 100644 --- a/tests/components/i2c_device/test.esp32-idf.yaml +++ b/tests/components/i2c_device/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c_device: - id: i2cdev - address: 0x2C +<<: !include common.yaml diff --git a/tests/components/i2c_device/test.esp8266-ard.yaml b/tests/components/i2c_device/test.esp8266-ard.yaml index 5d53d12208..ee2c29ca4e 100644 --- a/tests/components/i2c_device/test.esp8266-ard.yaml +++ b/tests/components/i2c_device/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c_device: - id: i2cdev - address: 0x2C +<<: !include common.yaml diff --git a/tests/components/i2c_device/test.rp2040-ard.yaml b/tests/components/i2c_device/test.rp2040-ard.yaml index 5d53d12208..ee2c29ca4e 100644 --- a/tests/components/i2c_device/test.rp2040-ard.yaml +++ b/tests/components/i2c_device/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c_device: - id: i2cdev - address: 0x2C +<<: !include common.yaml diff --git a/tests/components/i2s_audio/common.yaml b/tests/components/i2s_audio/common.yaml new file mode 100644 index 0000000000..2cecdc93b7 --- /dev/null +++ b/tests/components/i2s_audio/common.yaml @@ -0,0 +1,4 @@ +i2s_audio: + i2s_bclk_pin: ${i2s_bclk_pin} + i2s_lrclk_pin: ${i2s_lrclk_pin} + i2s_mclk_pin: ${i2s_mclk_pin} diff --git a/tests/components/i2s_audio/test.esp32-ard.yaml b/tests/components/i2s_audio/test.esp32-ard.yaml index 938dd5c25f..ce751d7d4a 100644 --- a/tests/components/i2s_audio/test.esp32-ard.yaml +++ b/tests/components/i2s_audio/test.esp32-ard.yaml @@ -1,4 +1,6 @@ -i2s_audio: - i2s_bclk_pin: 27 - i2s_lrclk_pin: 26 - i2s_mclk_pin: 25 +substitutions: + i2s_bclk_pin: GPIO15 + i2s_lrclk_pin: GPIO16 + i2s_mclk_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/i2s_audio/test.esp32-c3-ard.yaml b/tests/components/i2s_audio/test.esp32-c3-ard.yaml index 08cd56b1a7..5490846ae9 100644 --- a/tests/components/i2s_audio/test.esp32-c3-ard.yaml +++ b/tests/components/i2s_audio/test.esp32-c3-ard.yaml @@ -1,4 +1,6 @@ -i2s_audio: - i2s_bclk_pin: 7 - i2s_lrclk_pin: 6 - i2s_mclk_pin: 5 +substitutions: + i2s_bclk_pin: GPIO5 + i2s_lrclk_pin: GPIO6 + i2s_mclk_pin: GPIO7 + +<<: !include common.yaml diff --git a/tests/components/i2s_audio/test.esp32-c3-idf.yaml b/tests/components/i2s_audio/test.esp32-c3-idf.yaml index 08cd56b1a7..5490846ae9 100644 --- a/tests/components/i2s_audio/test.esp32-c3-idf.yaml +++ b/tests/components/i2s_audio/test.esp32-c3-idf.yaml @@ -1,4 +1,6 @@ -i2s_audio: - i2s_bclk_pin: 7 - i2s_lrclk_pin: 6 - i2s_mclk_pin: 5 +substitutions: + i2s_bclk_pin: GPIO5 + i2s_lrclk_pin: GPIO6 + i2s_mclk_pin: GPIO7 + +<<: !include common.yaml diff --git a/tests/components/i2s_audio/test.esp32-idf.yaml b/tests/components/i2s_audio/test.esp32-idf.yaml index 938dd5c25f..ce751d7d4a 100644 --- a/tests/components/i2s_audio/test.esp32-idf.yaml +++ b/tests/components/i2s_audio/test.esp32-idf.yaml @@ -1,4 +1,6 @@ -i2s_audio: - i2s_bclk_pin: 27 - i2s_lrclk_pin: 26 - i2s_mclk_pin: 25 +substitutions: + i2s_bclk_pin: GPIO15 + i2s_lrclk_pin: GPIO16 + i2s_mclk_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/iaqcore/common.yaml b/tests/components/iaqcore/common.yaml new file mode 100644 index 0000000000..927b836c52 --- /dev/null +++ b/tests/components/iaqcore/common.yaml @@ -0,0 +1,11 @@ +i2c: + - id: i2c_iaqcore + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: iaqcore + co2: + name: iAQ Core CO2 Sensor + tvoc: + name: iAQ Core TVOC Sensor diff --git a/tests/components/iaqcore/test.esp32-ard.yaml b/tests/components/iaqcore/test.esp32-ard.yaml index 26b01dadf9..63c3bd6afd 100644 --- a/tests/components/iaqcore/test.esp32-ard.yaml +++ b/tests/components/iaqcore/test.esp32-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_iaqcore - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: iaqcore - co2: - name: iAQ Core CO2 Sensor - tvoc: - name: iAQ Core TVOC Sensor +<<: !include common.yaml diff --git a/tests/components/iaqcore/test.esp32-c3-ard.yaml b/tests/components/iaqcore/test.esp32-c3-ard.yaml index a1809dffd7..ee2c29ca4e 100644 --- a/tests/components/iaqcore/test.esp32-c3-ard.yaml +++ b/tests/components/iaqcore/test.esp32-c3-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_iaqcore - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: iaqcore - co2: - name: iAQ Core CO2 Sensor - tvoc: - name: iAQ Core TVOC Sensor +<<: !include common.yaml diff --git a/tests/components/iaqcore/test.esp32-c3-idf.yaml b/tests/components/iaqcore/test.esp32-c3-idf.yaml index a1809dffd7..ee2c29ca4e 100644 --- a/tests/components/iaqcore/test.esp32-c3-idf.yaml +++ b/tests/components/iaqcore/test.esp32-c3-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_iaqcore - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: iaqcore - co2: - name: iAQ Core CO2 Sensor - tvoc: - name: iAQ Core TVOC Sensor +<<: !include common.yaml diff --git a/tests/components/iaqcore/test.esp32-idf.yaml b/tests/components/iaqcore/test.esp32-idf.yaml index 26b01dadf9..63c3bd6afd 100644 --- a/tests/components/iaqcore/test.esp32-idf.yaml +++ b/tests/components/iaqcore/test.esp32-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_iaqcore - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: iaqcore - co2: - name: iAQ Core CO2 Sensor - tvoc: - name: iAQ Core TVOC Sensor +<<: !include common.yaml diff --git a/tests/components/iaqcore/test.esp8266-ard.yaml b/tests/components/iaqcore/test.esp8266-ard.yaml index a1809dffd7..ee2c29ca4e 100644 --- a/tests/components/iaqcore/test.esp8266-ard.yaml +++ b/tests/components/iaqcore/test.esp8266-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_iaqcore - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: iaqcore - co2: - name: iAQ Core CO2 Sensor - tvoc: - name: iAQ Core TVOC Sensor +<<: !include common.yaml diff --git a/tests/components/iaqcore/test.rp2040-ard.yaml b/tests/components/iaqcore/test.rp2040-ard.yaml index a1809dffd7..ee2c29ca4e 100644 --- a/tests/components/iaqcore/test.rp2040-ard.yaml +++ b/tests/components/iaqcore/test.rp2040-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_iaqcore - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: iaqcore - co2: - name: iAQ Core CO2 Sensor - tvoc: - name: iAQ Core TVOC Sensor +<<: !include common.yaml diff --git a/tests/components/ili9xxx/common.yaml b/tests/components/ili9xxx/common.yaml new file mode 100644 index 0000000000..b182d110cd --- /dev/null +++ b/tests/components/ili9xxx/common.yaml @@ -0,0 +1,36 @@ +spi: + - id: spi_main_lcd + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ili9xxx + invert_colors: true + dimensions: 320x240 + transform: + swap_xy: true + mirror_x: true + mirror_y: false + model: TFT 2.4 + color_palette: GRAYSCALE + cs_pin: ${cs_pin1} + dc_pin: ${dc_pin1} + reset_pin: ${reset_pin1} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: ili9xxx + invert_colors: false + color_palette: 8bit + dimensions: + width: 320 + height: 240 + offset_width: 20 + offset_height: 10 + model: TFT 2.4 + cs_pin: ${cs_pin2} + dc_pin: ${dc_pin2} + reset_pin: ${reset_pin2} + auto_clear_enabled: false + rotation: 90 + lambda: |- + it.fill(Color::WHITE); diff --git a/tests/components/ili9xxx/test.esp32-ard.yaml b/tests/components/ili9xxx/test.esp32-ard.yaml index c00c38ce3e..2e006d2521 100644 --- a/tests/components/ili9xxx/test.esp32-ard.yaml +++ b/tests/components/ili9xxx/test.esp32-ard.yaml @@ -1,36 +1,11 @@ -spi: - - id: spi_main_lcd - clk_pin: 16 - mosi_pin: 17 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin1: GPIO12 + dc_pin1: GPIO13 + reset_pin1: GPIO14 + cs_pin2: GPIO25 + dc_pin2: GPIO26 + reset_pin2: GPIO27 -display: - - platform: ili9xxx - invert_colors: true - dimensions: 320x240 - transform: - swap_xy: true - mirror_x: true - mirror_y: false - model: TFT 2.4 - color_palette: GRAYSCALE - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: ili9xxx - invert_colors: false - color_palette: 8bit - dimensions: - width: 320 - height: 240 - offset_width: 20 - offset_height: 10 - model: TFT 2.4 - cs_pin: 25 - dc_pin: 26 - reset_pin: 27 - auto_clear_enabled: false - rotation: 90 - lambda: |- - it.fill(Color::WHITE); +<<: !include common.yaml diff --git a/tests/components/ili9xxx/test.esp32-c3-ard.yaml b/tests/components/ili9xxx/test.esp32-c3-ard.yaml index fd03bd54b7..3037785e81 100644 --- a/tests/components/ili9xxx/test.esp32-c3-ard.yaml +++ b/tests/components/ili9xxx/test.esp32-c3-ard.yaml @@ -1,36 +1,12 @@ -spi: - - id: spi_main_lcd - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin1: GPIO8 + dc_pin1: GPIO9 + reset_pin1: GPIO10 + cs_pin2: GPIO2 + dc_pin2: GPIO3 + reset_pin2: GPIO4 -display: - - platform: ili9xxx - invert_colors: true - dimensions: 320x240 - transform: - swap_xy: true - mirror_x: true - mirror_y: false - model: TFT 2.4 - color_palette: GRAYSCALE - cs_pin: 8 - dc_pin: 9 - reset_pin: 10 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: ili9xxx - invert_colors: false - dimensions: - width: 320 - height: 240 - offset_width: 20 - offset_height: 10 - model: TFT 2.4 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - auto_clear_enabled: false - rotation: 90 - lambda: |- - it.fill(Color::WHITE); +<<: !include common.yaml diff --git a/tests/components/ili9xxx/test.esp32-c3-idf.yaml b/tests/components/ili9xxx/test.esp32-c3-idf.yaml index fd03bd54b7..3037785e81 100644 --- a/tests/components/ili9xxx/test.esp32-c3-idf.yaml +++ b/tests/components/ili9xxx/test.esp32-c3-idf.yaml @@ -1,36 +1,12 @@ -spi: - - id: spi_main_lcd - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin1: GPIO8 + dc_pin1: GPIO9 + reset_pin1: GPIO10 + cs_pin2: GPIO2 + dc_pin2: GPIO3 + reset_pin2: GPIO4 -display: - - platform: ili9xxx - invert_colors: true - dimensions: 320x240 - transform: - swap_xy: true - mirror_x: true - mirror_y: false - model: TFT 2.4 - color_palette: GRAYSCALE - cs_pin: 8 - dc_pin: 9 - reset_pin: 10 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: ili9xxx - invert_colors: false - dimensions: - width: 320 - height: 240 - offset_width: 20 - offset_height: 10 - model: TFT 2.4 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - auto_clear_enabled: false - rotation: 90 - lambda: |- - it.fill(Color::WHITE); +<<: !include common.yaml diff --git a/tests/components/ili9xxx/test.esp32-idf.yaml b/tests/components/ili9xxx/test.esp32-idf.yaml index 6da62f69d2..2e006d2521 100644 --- a/tests/components/ili9xxx/test.esp32-idf.yaml +++ b/tests/components/ili9xxx/test.esp32-idf.yaml @@ -1,23 +1,11 @@ -spi: - - id: spi_main_lcd - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin1: GPIO12 + dc_pin1: GPIO13 + reset_pin1: GPIO14 + cs_pin2: GPIO25 + dc_pin2: GPIO26 + reset_pin2: GPIO27 -display: - - platform: ili9xxx - invert_colors: true - dimensions: 320x240 - transform: - swap_xy: true - mirror_x: true - mirror_y: false - model: custom - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - init_sequence: - - [0xFF, 0x77, 0x01, 0x00, 0x00, 0x10] - - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/ili9xxx/test.esp8266-ard.yaml b/tests/components/ili9xxx/test.esp8266-ard.yaml index b8192e69d1..5dee055fd4 100644 --- a/tests/components/ili9xxx/test.esp8266-ard.yaml +++ b/tests/components/ili9xxx/test.esp8266-ard.yaml @@ -1,36 +1,12 @@ -spi: - - id: spi_main_lcd - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin1: GPIO5 + dc_pin1: GPIO15 + reset_pin1: GPIO16 + cs_pin2: GPIO2 + dc_pin2: GPIO4 + reset_pin2: GPIO0 -display: - - platform: ili9xxx - invert_colors: true - dimensions: 320x240 - transform: - swap_xy: true - mirror_x: true - mirror_y: false - model: TFT 2.4 - color_palette: GRAYSCALE - cs_pin: 5 - dc_pin: 15 - reset_pin: 16 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: ili9xxx - invert_colors: false - dimensions: - width: 320 - height: 240 - offset_width: 20 - offset_height: 10 - model: TFT 2.4 - cs_pin: 2 - dc_pin: 4 - reset_pin: 0 - auto_clear_enabled: false - rotation: 90 - lambda: |- - it.fill(Color::WHITE); +<<: !include common.yaml diff --git a/tests/components/ili9xxx/test.rp2040-ard.yaml b/tests/components/ili9xxx/test.rp2040-ard.yaml index 0423f41a1c..74c9b906e9 100644 --- a/tests/components/ili9xxx/test.rp2040-ard.yaml +++ b/tests/components/ili9xxx/test.rp2040-ard.yaml @@ -1,36 +1,12 @@ -spi: - - id: spi_main_lcd - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin1: GPIO5 + dc_pin1: GPIO15 + reset_pin1: GPIO16 + cs_pin2: GPIO20 + dc_pin2: GPIO21 + reset_pin2: GPIO22 -display: - - platform: ili9xxx - invert_colors: true - dimensions: 320x240 - transform: - swap_xy: true - mirror_x: true - mirror_y: false - model: TFT 2.4 - color_palette: GRAYSCALE - cs_pin: 5 - dc_pin: 15 - reset_pin: 16 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: ili9xxx - invert_colors: false - dimensions: - width: 320 - height: 240 - offset_width: 20 - offset_height: 10 - model: TFT 2.4 - cs_pin: 20 - dc_pin: 21 - reset_pin: 22 - auto_clear_enabled: false - rotation: 90 - lambda: |- - it.fill(Color::WHITE); +<<: !include common.yaml diff --git a/tests/components/ina219/common.yaml b/tests/components/ina219/common.yaml new file mode 100644 index 0000000000..4ca4c9ed8f --- /dev/null +++ b/tests/components/ina219/common.yaml @@ -0,0 +1,20 @@ +i2c: + - id: i2c_ina219 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ina219 + address: 0x40 + shunt_resistance: 0.1 ohm + current: + name: INA219 Current + power: + name: INA219 Power + bus_voltage: + name: INA219 Bus Voltage + shunt_voltage: + name: INA219 Shunt Voltage + max_voltage: 32.0V + max_current: 3.2A + update_interval: 15s diff --git a/tests/components/ina219/test.esp32-ard.yaml b/tests/components/ina219/test.esp32-ard.yaml index affbec67c4..63c3bd6afd 100644 --- a/tests/components/ina219/test.esp32-ard.yaml +++ b/tests/components/ina219/test.esp32-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_ina219 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ina219 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA219 Current - power: - name: INA219 Power - bus_voltage: - name: INA219 Bus Voltage - shunt_voltage: - name: INA219 Shunt Voltage - max_voltage: 32.0V - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina219/test.esp32-c3-ard.yaml b/tests/components/ina219/test.esp32-c3-ard.yaml index 586add9d16..ee2c29ca4e 100644 --- a/tests/components/ina219/test.esp32-c3-ard.yaml +++ b/tests/components/ina219/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_ina219 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina219 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA219 Current - power: - name: INA219 Power - bus_voltage: - name: INA219 Bus Voltage - shunt_voltage: - name: INA219 Shunt Voltage - max_voltage: 32.0V - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina219/test.esp32-c3-idf.yaml b/tests/components/ina219/test.esp32-c3-idf.yaml index 586add9d16..ee2c29ca4e 100644 --- a/tests/components/ina219/test.esp32-c3-idf.yaml +++ b/tests/components/ina219/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_ina219 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina219 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA219 Current - power: - name: INA219 Power - bus_voltage: - name: INA219 Bus Voltage - shunt_voltage: - name: INA219 Shunt Voltage - max_voltage: 32.0V - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina219/test.esp32-idf.yaml b/tests/components/ina219/test.esp32-idf.yaml index affbec67c4..63c3bd6afd 100644 --- a/tests/components/ina219/test.esp32-idf.yaml +++ b/tests/components/ina219/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_ina219 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ina219 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA219 Current - power: - name: INA219 Power - bus_voltage: - name: INA219 Bus Voltage - shunt_voltage: - name: INA219 Shunt Voltage - max_voltage: 32.0V - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina219/test.esp8266-ard.yaml b/tests/components/ina219/test.esp8266-ard.yaml index 586add9d16..ee2c29ca4e 100644 --- a/tests/components/ina219/test.esp8266-ard.yaml +++ b/tests/components/ina219/test.esp8266-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_ina219 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina219 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA219 Current - power: - name: INA219 Power - bus_voltage: - name: INA219 Bus Voltage - shunt_voltage: - name: INA219 Shunt Voltage - max_voltage: 32.0V - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina219/test.rp2040-ard.yaml b/tests/components/ina219/test.rp2040-ard.yaml index 586add9d16..ee2c29ca4e 100644 --- a/tests/components/ina219/test.rp2040-ard.yaml +++ b/tests/components/ina219/test.rp2040-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_ina219 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina219 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA219 Current - power: - name: INA219 Power - bus_voltage: - name: INA219 Bus Voltage - shunt_voltage: - name: INA219 Shunt Voltage - max_voltage: 32.0V - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina226/common.yaml b/tests/components/ina226/common.yaml new file mode 100644 index 0000000000..8bcd038e50 --- /dev/null +++ b/tests/components/ina226/common.yaml @@ -0,0 +1,19 @@ +i2c: + - id: i2c_ina226 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ina226 + address: 0x40 + shunt_resistance: 0.1 ohm + current: + name: INA226 Current + power: + name: INA226 Power + bus_voltage: + name: INA226 Bus Voltage + shunt_voltage: + name: INA226 Shunt Voltage + max_current: 3.2A + update_interval: 15s diff --git a/tests/components/ina226/test.esp32-ard.yaml b/tests/components/ina226/test.esp32-ard.yaml index feab5e146c..63c3bd6afd 100644 --- a/tests/components/ina226/test.esp32-ard.yaml +++ b/tests/components/ina226/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina226 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ina226 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA226 Current - power: - name: INA226 Power - bus_voltage: - name: INA226 Bus Voltage - shunt_voltage: - name: INA226 Shunt Voltage - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina226/test.esp32-c3-ard.yaml b/tests/components/ina226/test.esp32-c3-ard.yaml index 6581763294..ee2c29ca4e 100644 --- a/tests/components/ina226/test.esp32-c3-ard.yaml +++ b/tests/components/ina226/test.esp32-c3-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina226 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina226 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA226 Current - power: - name: INA226 Power - bus_voltage: - name: INA226 Bus Voltage - shunt_voltage: - name: INA226 Shunt Voltage - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina226/test.esp32-c3-idf.yaml b/tests/components/ina226/test.esp32-c3-idf.yaml index 6581763294..ee2c29ca4e 100644 --- a/tests/components/ina226/test.esp32-c3-idf.yaml +++ b/tests/components/ina226/test.esp32-c3-idf.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina226 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina226 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA226 Current - power: - name: INA226 Power - bus_voltage: - name: INA226 Bus Voltage - shunt_voltage: - name: INA226 Shunt Voltage - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina226/test.esp32-idf.yaml b/tests/components/ina226/test.esp32-idf.yaml index feab5e146c..63c3bd6afd 100644 --- a/tests/components/ina226/test.esp32-idf.yaml +++ b/tests/components/ina226/test.esp32-idf.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina226 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ina226 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA226 Current - power: - name: INA226 Power - bus_voltage: - name: INA226 Bus Voltage - shunt_voltage: - name: INA226 Shunt Voltage - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina226/test.esp8266-ard.yaml b/tests/components/ina226/test.esp8266-ard.yaml index 6581763294..ee2c29ca4e 100644 --- a/tests/components/ina226/test.esp8266-ard.yaml +++ b/tests/components/ina226/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina226 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina226 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA226 Current - power: - name: INA226 Power - bus_voltage: - name: INA226 Bus Voltage - shunt_voltage: - name: INA226 Shunt Voltage - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina226/test.rp2040-ard.yaml b/tests/components/ina226/test.rp2040-ard.yaml index 6581763294..ee2c29ca4e 100644 --- a/tests/components/ina226/test.rp2040-ard.yaml +++ b/tests/components/ina226/test.rp2040-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina226 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina226 - address: 0x40 - shunt_resistance: 0.1 ohm - current: - name: INA226 Current - power: - name: INA226 Power - bus_voltage: - name: INA226 Bus Voltage - shunt_voltage: - name: INA226 Shunt Voltage - max_current: 3.2A - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina260/common.yaml b/tests/components/ina260/common.yaml new file mode 100644 index 0000000000..ab94b2e509 --- /dev/null +++ b/tests/components/ina260/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_ina260 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ina260 + address: 0x40 + current: + name: INA260 Current + power: + name: INA260 Power + bus_voltage: + name: INA260 Voltage + update_interval: 60s diff --git a/tests/components/ina260/test.esp32-ard.yaml b/tests/components/ina260/test.esp32-ard.yaml index be6cf73bff..63c3bd6afd 100644 --- a/tests/components/ina260/test.esp32-ard.yaml +++ b/tests/components/ina260/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_ina260 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ina260 - address: 0x40 - current: - name: INA260 Current - power: - name: INA260 Power - bus_voltage: - name: INA260 Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ina260/test.esp32-c3-ard.yaml b/tests/components/ina260/test.esp32-c3-ard.yaml index a1da63351d..ee2c29ca4e 100644 --- a/tests/components/ina260/test.esp32-c3-ard.yaml +++ b/tests/components/ina260/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_ina260 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina260 - address: 0x40 - current: - name: INA260 Current - power: - name: INA260 Power - bus_voltage: - name: INA260 Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ina260/test.esp32-c3-idf.yaml b/tests/components/ina260/test.esp32-c3-idf.yaml index a1da63351d..ee2c29ca4e 100644 --- a/tests/components/ina260/test.esp32-c3-idf.yaml +++ b/tests/components/ina260/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_ina260 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina260 - address: 0x40 - current: - name: INA260 Current - power: - name: INA260 Power - bus_voltage: - name: INA260 Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ina260/test.esp32-idf.yaml b/tests/components/ina260/test.esp32-idf.yaml index be6cf73bff..63c3bd6afd 100644 --- a/tests/components/ina260/test.esp32-idf.yaml +++ b/tests/components/ina260/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_ina260 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ina260 - address: 0x40 - current: - name: INA260 Current - power: - name: INA260 Power - bus_voltage: - name: INA260 Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ina260/test.esp8266-ard.yaml b/tests/components/ina260/test.esp8266-ard.yaml index a1da63351d..ee2c29ca4e 100644 --- a/tests/components/ina260/test.esp8266-ard.yaml +++ b/tests/components/ina260/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_ina260 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina260 - address: 0x40 - current: - name: INA260 Current - power: - name: INA260 Power - bus_voltage: - name: INA260 Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ina260/test.rp2040-ard.yaml b/tests/components/ina260/test.rp2040-ard.yaml index a1da63351d..ee2c29ca4e 100644 --- a/tests/components/ina260/test.rp2040-ard.yaml +++ b/tests/components/ina260/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_ina260 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina260 - address: 0x40 - current: - name: INA260 Current - power: - name: INA260 Power - bus_voltage: - name: INA260 Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/ina3221/common.yaml b/tests/components/ina3221/common.yaml new file mode 100644 index 0000000000..ba1abdfe3a --- /dev/null +++ b/tests/components/ina3221/common.yaml @@ -0,0 +1,19 @@ +i2c: + - id: i2c_ina3221 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: ina3221 + address: 0x40 + channel_1: + shunt_resistance: 0.1 ohm + current: + name: INA3221 Channel 1 Current + power: + name: INA3221 Channel 1 Power + bus_voltage: + name: INA3221 Channel 1 Bus Voltage + shunt_voltage: + name: INA3221 Channel 1 Shunt Voltage + update_interval: 15s diff --git a/tests/components/ina3221/test.esp32-ard.yaml b/tests/components/ina3221/test.esp32-ard.yaml index ad9cf79e38..63c3bd6afd 100644 --- a/tests/components/ina3221/test.esp32-ard.yaml +++ b/tests/components/ina3221/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina3221 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ina3221 - address: 0x40 - channel_1: - shunt_resistance: 0.1 ohm - current: - name: INA3221 Channel 1 Current - power: - name: INA3221 Channel 1 Power - bus_voltage: - name: INA3221 Channel 1 Bus Voltage - shunt_voltage: - name: INA3221 Channel 1 Shunt Voltage - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina3221/test.esp32-c3-ard.yaml b/tests/components/ina3221/test.esp32-c3-ard.yaml index 55990871a0..ee2c29ca4e 100644 --- a/tests/components/ina3221/test.esp32-c3-ard.yaml +++ b/tests/components/ina3221/test.esp32-c3-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina3221 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina3221 - address: 0x40 - channel_1: - shunt_resistance: 0.1 ohm - current: - name: INA3221 Channel 1 Current - power: - name: INA3221 Channel 1 Power - bus_voltage: - name: INA3221 Channel 1 Bus Voltage - shunt_voltage: - name: INA3221 Channel 1 Shunt Voltage - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina3221/test.esp32-c3-idf.yaml b/tests/components/ina3221/test.esp32-c3-idf.yaml index 55990871a0..ee2c29ca4e 100644 --- a/tests/components/ina3221/test.esp32-c3-idf.yaml +++ b/tests/components/ina3221/test.esp32-c3-idf.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina3221 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina3221 - address: 0x40 - channel_1: - shunt_resistance: 0.1 ohm - current: - name: INA3221 Channel 1 Current - power: - name: INA3221 Channel 1 Power - bus_voltage: - name: INA3221 Channel 1 Bus Voltage - shunt_voltage: - name: INA3221 Channel 1 Shunt Voltage - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina3221/test.esp32-idf.yaml b/tests/components/ina3221/test.esp32-idf.yaml index ad9cf79e38..63c3bd6afd 100644 --- a/tests/components/ina3221/test.esp32-idf.yaml +++ b/tests/components/ina3221/test.esp32-idf.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina3221 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: ina3221 - address: 0x40 - channel_1: - shunt_resistance: 0.1 ohm - current: - name: INA3221 Channel 1 Current - power: - name: INA3221 Channel 1 Power - bus_voltage: - name: INA3221 Channel 1 Bus Voltage - shunt_voltage: - name: INA3221 Channel 1 Shunt Voltage - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina3221/test.esp8266-ard.yaml b/tests/components/ina3221/test.esp8266-ard.yaml index 55990871a0..ee2c29ca4e 100644 --- a/tests/components/ina3221/test.esp8266-ard.yaml +++ b/tests/components/ina3221/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina3221 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina3221 - address: 0x40 - channel_1: - shunt_resistance: 0.1 ohm - current: - name: INA3221 Channel 1 Current - power: - name: INA3221 Channel 1 Power - bus_voltage: - name: INA3221 Channel 1 Bus Voltage - shunt_voltage: - name: INA3221 Channel 1 Shunt Voltage - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/ina3221/test.rp2040-ard.yaml b/tests/components/ina3221/test.rp2040-ard.yaml index 55990871a0..ee2c29ca4e 100644 --- a/tests/components/ina3221/test.rp2040-ard.yaml +++ b/tests/components/ina3221/test.rp2040-ard.yaml @@ -1,19 +1,5 @@ -i2c: - - id: i2c_ina3221 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: ina3221 - address: 0x40 - channel_1: - shunt_resistance: 0.1 ohm - current: - name: INA3221 Channel 1 Current - power: - name: INA3221 Channel 1 Power - bus_voltage: - name: INA3221 Channel 1 Bus Voltage - shunt_voltage: - name: INA3221 Channel 1 Shunt Voltage - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/integration/test.esp32-s2-ard.yaml b/tests/components/integration/common-esp32.yaml similarity index 78% rename from tests/components/integration/test.esp32-s2-ard.yaml rename to tests/components/integration/common-esp32.yaml index 1415952571..248106fd60 100644 --- a/tests/components/integration/test.esp32-s2-ard.yaml +++ b/tests/components/integration/common-esp32.yaml @@ -1,8 +1,8 @@ sensor: - platform: adc id: my_sensor - pin: 1 - attenuation: 11db + pin: ${pin} + attenuation: 12db - platform: integration sensor: my_sensor name: Integration Sensor diff --git a/tests/components/integration/test.esp32-ard.yaml b/tests/components/integration/test.esp32-ard.yaml index 0095fdb1ff..f84495e521 100644 --- a/tests/components/integration/test.esp32-ard.yaml +++ b/tests/components/integration/test.esp32-ard.yaml @@ -1,9 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: A0 - attenuation: 2.5db - - platform: integration - sensor: my_sensor - name: Integration Sensor - time_unit: s +substitutions: + pin: A0 + +<<: !include common-esp32.yaml diff --git a/tests/components/integration/test.esp32-c3-ard.yaml b/tests/components/integration/test.esp32-c3-ard.yaml index b68cb9f87d..5105e645f3 100644 --- a/tests/components/integration/test.esp32-c3-ard.yaml +++ b/tests/components/integration/test.esp32-c3-ard.yaml @@ -1,9 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 4 - attenuation: 11db - - platform: integration - sensor: my_sensor - name: Integration Sensor - time_unit: s +substitutions: + pin: GPIO1 + +<<: !include common-esp32.yaml diff --git a/tests/components/integration/test.esp32-c3-idf.yaml b/tests/components/integration/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..5105e645f3 --- /dev/null +++ b/tests/components/integration/test.esp32-c3-idf.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO1 + +<<: !include common-esp32.yaml diff --git a/tests/components/integration/test.esp32-idf.yaml b/tests/components/integration/test.esp32-idf.yaml index 0095fdb1ff..f84495e521 100644 --- a/tests/components/integration/test.esp32-idf.yaml +++ b/tests/components/integration/test.esp32-idf.yaml @@ -1,9 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: A0 - attenuation: 2.5db - - platform: integration - sensor: my_sensor - name: Integration Sensor - time_unit: s +substitutions: + pin: A0 + +<<: !include common-esp32.yaml diff --git a/tests/components/integration/test.esp32-s3-ard.yaml b/tests/components/integration/test.esp32-s3-ard.yaml deleted file mode 100644 index 1415952571..0000000000 --- a/tests/components/integration/test.esp32-s3-ard.yaml +++ /dev/null @@ -1,9 +0,0 @@ -sensor: - - platform: adc - id: my_sensor - pin: 1 - attenuation: 11db - - platform: integration - sensor: my_sensor - name: Integration Sensor - time_unit: s diff --git a/tests/components/internal_temperature/common.yaml b/tests/components/internal_temperature/common.yaml new file mode 100644 index 0000000000..19f740339d --- /dev/null +++ b/tests/components/internal_temperature/common.yaml @@ -0,0 +1,3 @@ +sensor: + - platform: internal_temperature + name: Internal Temperature diff --git a/tests/components/internal_temperature/test.bk72xx-ard.yaml b/tests/components/internal_temperature/test.bk72xx-ard.yaml index 28df4a6d9f..dade44d145 100644 --- a/tests/components/internal_temperature/test.bk72xx-ard.yaml +++ b/tests/components/internal_temperature/test.bk72xx-ard.yaml @@ -1,3 +1 @@ -sensor: - - platform: internal_temperature - name: "Internal Temperature" +<<: !include common.yaml diff --git a/tests/components/internal_temperature/test.esp32-ard.yaml b/tests/components/internal_temperature/test.esp32-ard.yaml index 19f740339d..dade44d145 100644 --- a/tests/components/internal_temperature/test.esp32-ard.yaml +++ b/tests/components/internal_temperature/test.esp32-ard.yaml @@ -1,3 +1 @@ -sensor: - - platform: internal_temperature - name: Internal Temperature +<<: !include common.yaml diff --git a/tests/components/internal_temperature/test.esp32-c3-ard.yaml b/tests/components/internal_temperature/test.esp32-c3-ard.yaml index 19f740339d..dade44d145 100644 --- a/tests/components/internal_temperature/test.esp32-c3-ard.yaml +++ b/tests/components/internal_temperature/test.esp32-c3-ard.yaml @@ -1,3 +1 @@ -sensor: - - platform: internal_temperature - name: Internal Temperature +<<: !include common.yaml diff --git a/tests/components/internal_temperature/test.esp32-c3-idf.yaml b/tests/components/internal_temperature/test.esp32-c3-idf.yaml index 28df4a6d9f..dade44d145 100644 --- a/tests/components/internal_temperature/test.esp32-c3-idf.yaml +++ b/tests/components/internal_temperature/test.esp32-c3-idf.yaml @@ -1,3 +1 @@ -sensor: - - platform: internal_temperature - name: "Internal Temperature" +<<: !include common.yaml diff --git a/tests/components/internal_temperature/test.esp32-idf.yaml b/tests/components/internal_temperature/test.esp32-idf.yaml index 19f740339d..dade44d145 100644 --- a/tests/components/internal_temperature/test.esp32-idf.yaml +++ b/tests/components/internal_temperature/test.esp32-idf.yaml @@ -1,3 +1 @@ -sensor: - - platform: internal_temperature - name: Internal Temperature +<<: !include common.yaml diff --git a/tests/components/internal_temperature/test.esp32-s2-ard.yaml b/tests/components/internal_temperature/test.esp32-s2-ard.yaml index 19f740339d..dade44d145 100644 --- a/tests/components/internal_temperature/test.esp32-s2-ard.yaml +++ b/tests/components/internal_temperature/test.esp32-s2-ard.yaml @@ -1,3 +1 @@ -sensor: - - platform: internal_temperature - name: Internal Temperature +<<: !include common.yaml diff --git a/tests/components/internal_temperature/test.esp32-s2-idf.yaml b/tests/components/internal_temperature/test.esp32-s2-idf.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/internal_temperature/test.esp32-s2-idf.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/internal_temperature/test.esp32-s3-ard.yaml b/tests/components/internal_temperature/test.esp32-s3-ard.yaml index 9eb1ec0b0f..bdd704756c 100644 --- a/tests/components/internal_temperature/test.esp32-s3-ard.yaml +++ b/tests/components/internal_temperature/test.esp32-s3-ard.yaml @@ -1,6 +1,4 @@ -sensor: - - platform: internal_temperature - name: Internal Temperature +<<: !include common.yaml esp32: framework: diff --git a/tests/components/internal_temperature/test.esp32-s3-idf.yaml b/tests/components/internal_temperature/test.esp32-s3-idf.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/internal_temperature/test.esp32-s3-idf.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/internal_temperature/test.rp2040-ard.yaml b/tests/components/internal_temperature/test.rp2040-ard.yaml index 19f740339d..dade44d145 100644 --- a/tests/components/internal_temperature/test.rp2040-ard.yaml +++ b/tests/components/internal_temperature/test.rp2040-ard.yaml @@ -1,3 +1 @@ -sensor: - - platform: internal_temperature - name: Internal Temperature +<<: !include common.yaml diff --git a/tests/components/jsn_sr04t/common.yaml b/tests/components/jsn_sr04t/common.yaml new file mode 100644 index 0000000000..d6871d5e91 --- /dev/null +++ b/tests/components/jsn_sr04t/common.yaml @@ -0,0 +1,11 @@ +uart: + - id: uart_jsn_sr04t + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: jsn_sr04t + id: jsn_sr04t_sensor + name: jsn_sr04t Distance + update_interval: 1s diff --git a/tests/components/jsn_sr04t/test.esp32-ard.yaml b/tests/components/jsn_sr04t/test.esp32-ard.yaml index 32b4221b3f..f486544afa 100644 --- a/tests/components/jsn_sr04t/test.esp32-ard.yaml +++ b/tests/components/jsn_sr04t/test.esp32-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_jsn_sr04t - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: jsn_sr04t - id: jsn_sr04t_sensor - name: "jsn_sr04t Distance" - uart_id: uart_jsn_sr04t - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/jsn_sr04t/test.esp32-c3-ard.yaml b/tests/components/jsn_sr04t/test.esp32-c3-ard.yaml index 5a37418a7d..b516342f3b 100644 --- a/tests/components/jsn_sr04t/test.esp32-c3-ard.yaml +++ b/tests/components/jsn_sr04t/test.esp32-c3-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_jsn_sr04t - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: jsn_sr04t - id: jsn_sr04t_sensor - name: "jsn_sr04t Distance" - uart_id: uart_jsn_sr04t - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/jsn_sr04t/test.esp32-c3-idf.yaml b/tests/components/jsn_sr04t/test.esp32-c3-idf.yaml index 5a37418a7d..b516342f3b 100644 --- a/tests/components/jsn_sr04t/test.esp32-c3-idf.yaml +++ b/tests/components/jsn_sr04t/test.esp32-c3-idf.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_jsn_sr04t - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: jsn_sr04t - id: jsn_sr04t_sensor - name: "jsn_sr04t Distance" - uart_id: uart_jsn_sr04t - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/jsn_sr04t/test.esp32-idf.yaml b/tests/components/jsn_sr04t/test.esp32-idf.yaml index 32b4221b3f..f486544afa 100644 --- a/tests/components/jsn_sr04t/test.esp32-idf.yaml +++ b/tests/components/jsn_sr04t/test.esp32-idf.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_jsn_sr04t - tx_pin: - number: 17 - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: jsn_sr04t - id: jsn_sr04t_sensor - name: "jsn_sr04t Distance" - uart_id: uart_jsn_sr04t - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/jsn_sr04t/test.esp8266-ard.yaml b/tests/components/jsn_sr04t/test.esp8266-ard.yaml index 5a37418a7d..b516342f3b 100644 --- a/tests/components/jsn_sr04t/test.esp8266-ard.yaml +++ b/tests/components/jsn_sr04t/test.esp8266-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_jsn_sr04t - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: jsn_sr04t - id: jsn_sr04t_sensor - name: "jsn_sr04t Distance" - uart_id: uart_jsn_sr04t - update_interval: 1s +<<: !include common.yaml diff --git a/tests/components/jsn_sr04t/test.rp2040-ard.yaml b/tests/components/jsn_sr04t/test.rp2040-ard.yaml index 5a37418a7d..b516342f3b 100644 --- a/tests/components/jsn_sr04t/test.rp2040-ard.yaml +++ b/tests/components/jsn_sr04t/test.rp2040-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_jsn_sr04t - tx_pin: - number: 4 - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: jsn_sr04t - id: jsn_sr04t_sensor - name: "jsn_sr04t Distance" - uart_id: uart_jsn_sr04t - update_interval: 1s +<<: !include common.yaml From 2e61229aed75f8db4d3f7e4d36f483e0ed70318b Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Tue, 4 Feb 2025 18:09:37 -0500 Subject: [PATCH 155/194] [i2c] Workaround for i2c on s2 (#8188) --- esphome/components/i2c/i2c_bus_esp_idf.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/i2c/i2c_bus_esp_idf.cpp b/esphome/components/i2c/i2c_bus_esp_idf.cpp index ac3a754024..c7bba70582 100644 --- a/esphome/components/i2c/i2c_bus_esp_idf.cpp +++ b/esphome/components/i2c/i2c_bus_esp_idf.cpp @@ -39,6 +39,10 @@ void IDFI2CBus::setup() { conf.scl_io_num = scl_pin_; conf.scl_pullup_en = scl_pullup_enabled_; conf.master.clk_speed = frequency_; +#ifdef USE_ESP32_VARIANT_ESP32S2 + // workaround for https://github.com/esphome/issues/issues/6718 + conf.clk_flags = I2C_SCLK_SRC_FLAG_AWARE_DFS; +#endif esp_err_t err = i2c_param_config(port_, &conf); if (err != ESP_OK) { ESP_LOGW(TAG, "i2c_param_config failed: %s", esp_err_to_name(err)); From 9b56f9cc6da5216ea342a80e0976d806350e0314 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 5 Feb 2025 10:13:21 +1100 Subject: [PATCH 156/194] [lvgl] add triggers for swipe gestures (#8190) --- esphome/components/lvgl/__init__.py | 13 ++++++++--- esphome/components/lvgl/defines.py | 7 +++++- esphome/components/lvgl/schemas.py | 5 ++--- esphome/components/lvgl/trigger.py | 30 ++++++++++++++++++++++--- tests/components/lvgl/lvgl-package.yaml | 12 ++++++++++ 5 files changed, 57 insertions(+), 10 deletions(-) diff --git a/esphome/components/lvgl/__init__.py b/esphome/components/lvgl/__init__.py index c64ffcb5f2..07f5d94543 100644 --- a/esphome/components/lvgl/__init__.py +++ b/esphome/components/lvgl/__init__.py @@ -61,7 +61,14 @@ from .types import ( lv_style_t, lvgl_ns, ) -from .widgets import Widget, add_widgets, get_scr_act, set_obj_properties, styles_used +from .widgets import ( + LvScrActType, + Widget, + add_widgets, + get_scr_act, + set_obj_properties, + styles_used, +) from .widgets.animimg import animimg_spec from .widgets.arc import arc_spec from .widgets.button import button_spec @@ -318,7 +325,7 @@ async def to_code(configs): config[df.CONF_RESUME_ON_INPUT], ) await cg.register_component(lv_component, config) - Widget.create(config[CONF_ID], lv_component, obj_spec, config) + Widget.create(config[CONF_ID], lv_component, LvScrActType(), config) lv_scr_act = get_scr_act(lv_component) async with LvContext(): @@ -391,7 +398,7 @@ FINAL_VALIDATE_SCHEMA = final_validation LVGL_SCHEMA = ( cv.polling_component_schema("1s") - .extend(obj_schema(obj_spec)) + .extend(obj_schema(LvScrActType())) .extend( { cv.GenerateID(CONF_ID): cv.declare_id(LvglComponent), diff --git a/esphome/components/lvgl/defines.py b/esphome/components/lvgl/defines.py index 733a6bc180..119a358e1d 100644 --- a/esphome/components/lvgl/defines.py +++ b/esphome/components/lvgl/defines.py @@ -146,6 +146,8 @@ TYPE_FLEX = "flex" TYPE_GRID = "grid" TYPE_NONE = "none" +DIRECTIONS = LvConstant("LV_DIR_", "LEFT", "RIGHT", "BOTTOM", "TOP") + LV_FONTS = list(f"montserrat_{s}" for s in range(8, 50, 2)) + [ "dejavu_16_persian_hebrew", "simsun_16_cjk", @@ -169,9 +171,13 @@ LV_EVENT_MAP = { "CANCEL": "CANCEL", "ALL_EVENTS": "ALL", "CHANGE": "VALUE_CHANGED", + "GESTURE": "GESTURE", } LV_EVENT_TRIGGERS = tuple(f"on_{x.lower()}" for x in LV_EVENT_MAP) +SWIPE_TRIGGERS = tuple( + f"on_swipe_{x.lower()}" for x in DIRECTIONS.choices + ("up", "down") +) LV_ANIM = LvConstant( @@ -250,7 +256,6 @@ KEYBOARD_MODES = LvConstant( "NUMBER", ) ROLLER_MODES = LvConstant("LV_ROLLER_MODE_", "NORMAL", "INFINITE") -DIRECTIONS = LvConstant("LV_DIR_", "LEFT", "RIGHT", "BOTTOM", "TOP") TILE_DIRECTIONS = DIRECTIONS.extend("HOR", "VER", "ALL") CHILD_ALIGNMENTS = LvConstant( "LV_ALIGN_", diff --git a/esphome/components/lvgl/schemas.py b/esphome/components/lvgl/schemas.py index f0318dd17a..ae50d5b2e1 100644 --- a/esphome/components/lvgl/schemas.py +++ b/esphome/components/lvgl/schemas.py @@ -211,10 +211,9 @@ def part_schema(parts): def automation_schema(typ: LvType): + events = df.LV_EVENT_TRIGGERS + df.SWIPE_TRIGGERS if typ.has_on_value: - events = df.LV_EVENT_TRIGGERS + (CONF_ON_VALUE,) - else: - events = df.LV_EVENT_TRIGGERS + events = events + (CONF_ON_VALUE,) args = typ.get_arg_type() if isinstance(typ, LvType) else [] args.append(lv_event_t_ptr) return { diff --git a/esphome/components/lvgl/trigger.py b/esphome/components/lvgl/trigger.py index fb856df04e..b76f90fecd 100644 --- a/esphome/components/lvgl/trigger.py +++ b/esphome/components/lvgl/trigger.py @@ -7,8 +7,10 @@ from .defines import ( CONF_ALIGN_TO, CONF_X, CONF_Y, + DIRECTIONS, LV_EVENT_MAP, LV_EVENT_TRIGGERS, + SWIPE_TRIGGERS, literal, ) from .lvcode import ( @@ -23,7 +25,7 @@ from .lvcode import ( lvgl_static, ) from .types import LV_EVENT -from .widgets import widget_map +from .widgets import LvScrActType, get_scr_act, widget_map async def generate_triggers(): @@ -33,6 +35,9 @@ async def generate_triggers(): """ for w in widget_map.values(): + if isinstance(w.type, LvScrActType): + w = get_scr_act(w.var) + if w.config: for event, conf in { event: conf @@ -43,6 +48,24 @@ async def generate_triggers(): w.add_flag("LV_OBJ_FLAG_CLICKABLE") event = literal("LV_EVENT_" + LV_EVENT_MAP[event[3:].upper()]) await add_trigger(conf, w, event) + + for event, conf in { + event: conf + for event, conf in w.config.items() + if event in SWIPE_TRIGGERS + }.items(): + conf = conf[0] + dir = event[9:].upper() + dir = {"UP": "TOP", "DOWN": "BOTTOM"}.get(dir, dir) + dir = DIRECTIONS.mapper(dir) + w.clear_flag("LV_OBJ_FLAG_SCROLLABLE") + selected = literal( + f"lv_indev_get_gesture_dir(lv_indev_get_act()) == {dir}" + ) + await add_trigger( + conf, w, literal("LV_EVENT_GESTURE"), is_selected=selected + ) + for conf in w.config.get(CONF_ON_VALUE, ()): await add_trigger( conf, @@ -61,13 +84,14 @@ async def generate_triggers(): lv.obj_align_to(w.obj, target, align, x, y) -async def add_trigger(conf, w, *events): +async def add_trigger(conf, w, *events, is_selected=None): + is_selected = is_selected or w.is_selected() tid = conf[CONF_TRIGGER_ID] trigger = cg.new_Pvariable(tid) args = w.get_args() + [(lv_event_t_ptr, "event")] value = w.get_values() await automation.build_automation(trigger, args, conf) async with LambdaContext(EVENT_ARG, where=tid) as context: - with LvConditional(w.is_selected()): + with LvConditional(is_selected): lv_add(trigger.trigger(*value, literal("event"))) lv_add(lvgl_static.add_event_cb(w.obj, await context.get_lambda(), *events)) diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index c51a3d03e7..c527f51b1e 100644 --- a/tests/components/lvgl/lvgl-package.yaml +++ b/tests/components/lvgl/lvgl-package.yaml @@ -133,6 +133,18 @@ lvgl: pages: - id: page1 + on_swipe_top: + logger.log: "swiped up" + on_swipe_bottom: + logger.log: "swiped down" + on_swipe_up: + logger.log: "swiped up" + on_swipe_down: + logger.log: "swiped down" + on_swipe_left: + logger.log: "swiped left" + on_swipe_right: + logger.log: "swiped right" bg_image_src: cat_image on_load: - logger.log: page loaded From 1215d2ffeba5c06e3ff33aadddea23842b530fe9 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 5 Feb 2025 10:22:40 +1100 Subject: [PATCH 157/194] [xxtea] Extract encryption functions to separate component (#8183) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- CODEOWNERS | 1 + esphome/components/udp/__init__.py | 2 +- esphome/components/udp/udp_component.cpp | 55 +++--------------------- esphome/components/xxtea/__init__.py | 3 ++ esphome/components/xxtea/xxtea.cpp | 46 ++++++++++++++++++++ esphome/components/xxtea/xxtea.h | 26 +++++++++++ 6 files changed, 82 insertions(+), 51 deletions(-) create mode 100644 esphome/components/xxtea/__init__.py create mode 100644 esphome/components/xxtea/xxtea.cpp create mode 100644 esphome/components/xxtea/xxtea.h diff --git a/CODEOWNERS b/CODEOWNERS index d26e153c1a..03e26bcb84 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -499,5 +499,6 @@ esphome/components/xiaomi_mhoc401/* @vevsvevs esphome/components/xiaomi_rtcgq02lm/* @jesserockz esphome/components/xl9535/* @mreditor97 esphome/components/xpt2046/touchscreen/* @nielsnl68 @numo68 +esphome/components/xxtea/* @clydebarrow esphome/components/zhlt01/* @cfeenstra1024 esphome/components/zio_ultrasonic/* @kahrendt diff --git a/esphome/components/udp/__init__.py b/esphome/components/udp/__init__.py index 5485663f1c..140d1e4236 100644 --- a/esphome/components/udp/__init__.py +++ b/esphome/components/udp/__init__.py @@ -18,7 +18,7 @@ from esphome.cpp_generator import MockObjClass CODEOWNERS = ["@clydebarrow"] DEPENDENCIES = ["network"] -AUTO_LOAD = ["socket"] +AUTO_LOAD = ["socket", "xxtea"] MULTI_CONF = True udp_ns = cg.esphome_ns.namespace("udp") diff --git a/esphome/components/udp/udp_component.cpp b/esphome/components/udp/udp_component.cpp index 30f7356879..59cba8c7fe 100644 --- a/esphome/components/udp/udp_component.cpp +++ b/esphome/components/udp/udp_component.cpp @@ -3,6 +3,8 @@ #include "esphome/components/network/util.h" #include "udp_component.h" +#include "esphome/components/xxtea/xxtea.h" + namespace esphome { namespace udp { @@ -47,54 +49,7 @@ namespace udp { */ static const char *const TAG = "udp"; -/** - * XXTEA implementation, using 256 bit key. - */ - -static const uint32_t DELTA = 0x9e3779b9; -#define MX ((((z >> 5) ^ (y << 2)) + ((y >> 3) ^ (z << 4))) ^ ((sum ^ y) + (k[(p ^ e) & 7] ^ z))) - -/** - * Encrypt a block of data in-place - */ - -static void xxtea_encrypt(uint32_t *v, size_t n, const uint32_t *k) { - uint32_t z, y, sum, e; - size_t p; - size_t q = 6 + 52 / n; - sum = 0; - z = v[n - 1]; - while (q-- != 0) { - sum += DELTA; - e = (sum >> 2); - for (p = 0; p != n - 1; p++) { - y = v[p + 1]; - z = v[p] += MX; - } - y = v[0]; - z = v[n - 1] += MX; - } -} - -static void xxtea_decrypt(uint32_t *v, size_t n, const uint32_t *k) { - uint32_t z, y, sum, e; - size_t p; - size_t q = 6 + 52 / n; - sum = q * DELTA; - y = v[0]; - while (q-- != 0) { - e = (sum >> 2); - for (p = n - 1; p != 0; p--) { - z = v[p - 1]; - y = v[p] -= MX; - } - z = v[n - 1]; - y = v[0] -= MX; - sum -= DELTA; - } -} - -inline static size_t round4(size_t value) { return (value + 3) & ~3; } +static size_t round4(size_t value) { return (value + 3) & ~3; } union FuData { uint32_t u32; @@ -312,7 +267,7 @@ void UDPComponent::flush_() { memcpy(buffer, this->header_.data(), this->header_.size()); memcpy(buffer + header_len, this->data_.data(), this->data_.size()); if (this->is_encrypted_()) { - xxtea_encrypt(buffer + header_len, len, (uint32_t *) this->encryption_key_.data()); + xxtea::encrypt(buffer + header_len, len, (uint32_t *) this->encryption_key_.data()); } auto total_len = (header_len + len) * 4; this->send_packet_(buffer, total_len); @@ -503,7 +458,7 @@ void UDPComponent::process_(uint8_t *buf, const size_t len) { #endif if (!provider.encryption_key.empty()) { - xxtea_decrypt((uint32_t *) buf, (end - buf) / 4, (uint32_t *) provider.encryption_key.data()); + xxtea::decrypt((uint32_t *) buf, (end - buf) / 4, (uint32_t *) provider.encryption_key.data()); } byte = *buf++; if (byte == ROLLING_CODE_KEY) { diff --git a/esphome/components/xxtea/__init__.py b/esphome/components/xxtea/__init__.py new file mode 100644 index 0000000000..7a7bce1781 --- /dev/null +++ b/esphome/components/xxtea/__init__.py @@ -0,0 +1,3 @@ +"""ESPHome XXTEA encryption component.""" + +CODEOWNERS = ["@clydebarrow"] diff --git a/esphome/components/xxtea/xxtea.cpp b/esphome/components/xxtea/xxtea.cpp new file mode 100644 index 0000000000..aae663ee01 --- /dev/null +++ b/esphome/components/xxtea/xxtea.cpp @@ -0,0 +1,46 @@ +#include "xxtea.h" + +namespace esphome { +namespace xxtea { + +static const uint32_t DELTA = 0x9e3779b9; +#define MX ((((z >> 5) ^ (y << 2)) + ((y >> 3) ^ (z << 4))) ^ ((sum ^ y) + (k[(p ^ e) & 7] ^ z))) + +void encrypt(uint32_t *v, size_t n, const uint32_t *k) { + uint32_t z, y, sum, e; + size_t p; + size_t q = 6 + 52 / n; + sum = 0; + z = v[n - 1]; + while (q-- != 0) { + sum += DELTA; + e = (sum >> 2); + for (p = 0; p != n - 1; p++) { + y = v[p + 1]; + z = v[p] += MX; + } + y = v[0]; + z = v[n - 1] += MX; + } +} + +void decrypt(uint32_t *v, size_t n, const uint32_t *k) { + uint32_t z, y, sum, e; + size_t p; + size_t q = 6 + 52 / n; + sum = q * DELTA; + y = v[0]; + while (q-- != 0) { + e = (sum >> 2); + for (p = n - 1; p != 0; p--) { + z = v[p - 1]; + y = v[p] -= MX; + } + z = v[n - 1]; + y = v[0] -= MX; + sum -= DELTA; + } +} + +} // namespace xxtea +} // namespace esphome diff --git a/esphome/components/xxtea/xxtea.h b/esphome/components/xxtea/xxtea.h new file mode 100644 index 0000000000..86afbd1d46 --- /dev/null +++ b/esphome/components/xxtea/xxtea.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +namespace esphome { +namespace xxtea { + +/** + * Encrypt a block of data in-place using XXTEA algorithm with 256-bit key + * @param v Data to encrypt (as array of 32-bit words) + * @param n Number of 32-bit words in data + * @param k Key (array of 8 32-bit words) + */ +void encrypt(uint32_t *v, size_t n, const uint32_t *k); + +/** + * Decrypt a block of data in-place using XXTEA algorithm with 256-bit key + * @param v Data to decrypt (as array of 32-bit words) + * @param n Number of 32-bit words in data + * @param k Key (array of 8 32-bit words) + */ +void decrypt(uint32_t *v, size_t n, const uint32_t *k); + +} // namespace xxtea +} // namespace esphome From 977333a73c1960b3fc5664a4af38721cf8a78285 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 5 Feb 2025 12:44:51 +1100 Subject: [PATCH 158/194] [lvgl] Make layouts work properly on base display (#8193) --- esphome/components/lvgl/__init__.py | 146 +++++++++++++++------------- 1 file changed, 79 insertions(+), 67 deletions(-) diff --git a/esphome/components/lvgl/__init__.py b/esphome/components/lvgl/__init__.py index 07f5d94543..22571c2550 100644 --- a/esphome/components/lvgl/__init__.py +++ b/esphome/components/lvgl/__init__.py @@ -396,75 +396,87 @@ def add_hello_world(config): FINAL_VALIDATE_SCHEMA = final_validation -LVGL_SCHEMA = ( - cv.polling_component_schema("1s") - .extend(obj_schema(LvScrActType())) - .extend( - { - cv.GenerateID(CONF_ID): cv.declare_id(LvglComponent), - cv.GenerateID(df.CONF_DISPLAYS): display_schema, - cv.Optional(df.CONF_COLOR_DEPTH, default=16): cv.one_of(16), - cv.Optional(df.CONF_DEFAULT_FONT, default="montserrat_14"): lvalid.lv_font, - cv.Optional(df.CONF_FULL_REFRESH, default=False): cv.boolean, - cv.Optional(df.CONF_DRAW_ROUNDING, default=2): cv.positive_int, - cv.Optional(CONF_BUFFER_SIZE, default="100%"): cv.percentage, - cv.Optional(df.CONF_LOG_LEVEL, default="WARN"): cv.one_of( - *df.LV_LOG_LEVELS, upper=True - ), - cv.Optional(df.CONF_BYTE_ORDER, default="big_endian"): cv.one_of( - "big_endian", "little_endian" - ), - cv.Optional(df.CONF_STYLE_DEFINITIONS): cv.ensure_list( - cv.Schema({cv.Required(CONF_ID): cv.declare_id(lv_style_t)}) - .extend(STYLE_SCHEMA) - .extend( +LVGL_SCHEMA = cv.All( + container_schema( + obj_spec, + cv.polling_component_schema("1s") + .extend( + { + cv.GenerateID(CONF_ID): cv.declare_id(LvglComponent), + cv.GenerateID(df.CONF_DISPLAYS): display_schema, + cv.Optional(df.CONF_COLOR_DEPTH, default=16): cv.one_of(16), + cv.Optional( + df.CONF_DEFAULT_FONT, default="montserrat_14" + ): lvalid.lv_font, + cv.Optional(df.CONF_FULL_REFRESH, default=False): cv.boolean, + cv.Optional(df.CONF_DRAW_ROUNDING, default=2): cv.positive_int, + cv.Optional(CONF_BUFFER_SIZE, default="100%"): cv.percentage, + cv.Optional(df.CONF_LOG_LEVEL, default="WARN"): cv.one_of( + *df.LV_LOG_LEVELS, upper=True + ), + cv.Optional(df.CONF_BYTE_ORDER, default="big_endian"): cv.one_of( + "big_endian", "little_endian" + ), + cv.Optional(df.CONF_STYLE_DEFINITIONS): cv.ensure_list( + cv.Schema({cv.Required(CONF_ID): cv.declare_id(lv_style_t)}) + .extend(STYLE_SCHEMA) + .extend( + { + cv.Optional(df.CONF_GRID_CELL_X_ALIGN): grid_alignments, + cv.Optional(df.CONF_GRID_CELL_Y_ALIGN): grid_alignments, + cv.Optional(df.CONF_PAD_ROW): lvalid.pixels, + cv.Optional(df.CONF_PAD_COLUMN): lvalid.pixels, + } + ) + ), + cv.Optional(CONF_ON_IDLE): validate_automation( { - cv.Optional(df.CONF_GRID_CELL_X_ALIGN): grid_alignments, - cv.Optional(df.CONF_GRID_CELL_Y_ALIGN): grid_alignments, - cv.Optional(df.CONF_PAD_ROW): lvalid.pixels, - cv.Optional(df.CONF_PAD_COLUMN): lvalid.pixels, + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(IdleTrigger), + cv.Required(CONF_TIMEOUT): cv.templatable( + cv.positive_time_period_milliseconds + ), } - ) - ), - cv.Optional(CONF_ON_IDLE): validate_automation( - { - cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(IdleTrigger), - cv.Required(CONF_TIMEOUT): cv.templatable( - cv.positive_time_period_milliseconds - ), - } - ), - cv.Optional(df.CONF_ON_PAUSE): validate_automation( - { - cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(PauseTrigger), - } - ), - cv.Optional(df.CONF_ON_RESUME): validate_automation( - { - cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(PauseTrigger), - } - ), - cv.Exclusive(df.CONF_WIDGETS, CONF_PAGES): cv.ensure_list(WIDGET_SCHEMA), - cv.Exclusive(CONF_PAGES, CONF_PAGES): cv.ensure_list( - container_schema(page_spec) - ), - cv.Optional(df.CONF_MSGBOXES): cv.ensure_list(MSGBOX_SCHEMA), - cv.Optional(df.CONF_PAGE_WRAP, default=True): lv_bool, - cv.Optional(df.CONF_TOP_LAYER): container_schema(obj_spec), - cv.Optional(df.CONF_TRANSPARENCY_KEY, default=0x000400): lvalid.lv_color, - cv.Optional(df.CONF_THEME): cv.Schema( - {cv.Optional(name): obj_schema(w) for name, w in WIDGET_TYPES.items()} - ), - cv.Optional(df.CONF_GRADIENTS): GRADIENT_SCHEMA, - cv.Optional(df.CONF_TOUCHSCREENS, default=None): touchscreen_schema, - cv.Optional(df.CONF_ENCODERS, default=None): ENCODERS_CONFIG, - cv.Optional(df.CONF_KEYPADS, default=None): KEYPADS_CONFIG, - cv.GenerateID(df.CONF_DEFAULT_GROUP): cv.declare_id(lv_group_t), - cv.Optional(df.CONF_RESUME_ON_INPUT, default=True): cv.boolean, - } - ) - .extend(DISP_BG_SCHEMA) - .add_extra(add_hello_world) + ), + cv.Optional(df.CONF_ON_PAUSE): validate_automation( + { + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(PauseTrigger), + } + ), + cv.Optional(df.CONF_ON_RESUME): validate_automation( + { + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(PauseTrigger), + } + ), + cv.Exclusive(df.CONF_WIDGETS, CONF_PAGES): cv.ensure_list( + WIDGET_SCHEMA + ), + cv.Exclusive(CONF_PAGES, CONF_PAGES): cv.ensure_list( + container_schema(page_spec) + ), + cv.Optional(df.CONF_MSGBOXES): cv.ensure_list(MSGBOX_SCHEMA), + cv.Optional(df.CONF_PAGE_WRAP, default=True): lv_bool, + cv.Optional(df.CONF_TOP_LAYER): container_schema(obj_spec), + cv.Optional( + df.CONF_TRANSPARENCY_KEY, default=0x000400 + ): lvalid.lv_color, + cv.Optional(df.CONF_THEME): cv.Schema( + { + cv.Optional(name): obj_schema(w) + for name, w in WIDGET_TYPES.items() + } + ), + cv.Optional(df.CONF_GRADIENTS): GRADIENT_SCHEMA, + cv.Optional(df.CONF_TOUCHSCREENS, default=None): touchscreen_schema, + cv.Optional(df.CONF_ENCODERS, default=None): ENCODERS_CONFIG, + cv.Optional(df.CONF_KEYPADS, default=None): KEYPADS_CONFIG, + cv.GenerateID(df.CONF_DEFAULT_GROUP): cv.declare_id(lv_group_t), + cv.Optional(df.CONF_RESUME_ON_INPUT, default=True): cv.boolean, + } + ) + .extend(DISP_BG_SCHEMA), + ), + cv.has_at_most_one_key(CONF_PAGES, df.CONF_LAYOUT), + add_hello_world, ) From 4d8f58db94caff2087c96688be72a053b1dccd07 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 5 Feb 2025 13:34:30 +1100 Subject: [PATCH 159/194] [preferences] Better handling of flash_write_interval (#8199) --- esphome/components/preferences/__init__.py | 6 ++---- esphome/components/preferences/syncer.h | 13 ++++++++++--- tests/components/preferences/test.esp32-idf.yaml | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 tests/components/preferences/test.esp32-idf.yaml diff --git a/esphome/components/preferences/__init__.py b/esphome/components/preferences/__init__.py index 4844ad6c02..1da6d02045 100644 --- a/esphome/components/preferences/__init__.py +++ b/esphome/components/preferences/__init__.py @@ -1,6 +1,6 @@ -from esphome.const import CONF_ID import esphome.codegen as cg import esphome.config_validation as cv +from esphome.const import CONF_ID CODEOWNERS = ["@esphome/core"] @@ -11,9 +11,7 @@ CONF_FLASH_WRITE_INTERVAL = "flash_write_interval" CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(): cv.declare_id(IntervalSyncer), - cv.Optional( - CONF_FLASH_WRITE_INTERVAL, default="60s" - ): cv.positive_time_period_milliseconds, + cv.Optional(CONF_FLASH_WRITE_INTERVAL, default="60s"): cv.update_interval, } ).extend(cv.COMPONENT_SCHEMA) diff --git a/esphome/components/preferences/syncer.h b/esphome/components/preferences/syncer.h index af1fe9ba4a..8976a1fe15 100644 --- a/esphome/components/preferences/syncer.h +++ b/esphome/components/preferences/syncer.h @@ -8,15 +8,22 @@ namespace preferences { class IntervalSyncer : public Component { public: - void set_write_interval(uint32_t write_interval) { write_interval_ = write_interval; } + void set_write_interval(uint32_t write_interval) { this->write_interval_ = write_interval; } void setup() override { - set_interval(write_interval_, []() { global_preferences->sync(); }); + if (this->write_interval_ != 0) { + set_interval(this->write_interval_, []() { global_preferences->sync(); }); + } + } + void loop() override { + if (this->write_interval_ == 0) { + global_preferences->sync(); + } } void on_shutdown() override { global_preferences->sync(); } float get_setup_priority() const override { return setup_priority::BUS; } protected: - uint32_t write_interval_; + uint32_t write_interval_{60000}; }; } // namespace preferences diff --git a/tests/components/preferences/test.esp32-idf.yaml b/tests/components/preferences/test.esp32-idf.yaml new file mode 100644 index 0000000000..4c7c176fdc --- /dev/null +++ b/tests/components/preferences/test.esp32-idf.yaml @@ -0,0 +1,2 @@ +preferences: + flash_write_interval: 20s From cecce0f3cbde410b0cd96db63d9648c35b659eaf Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 20:37:15 -0600 Subject: [PATCH 160/194] [CI] Consolidate some tests (N, O, P) (#8204) --- tests/components/ntc/common.yaml | 25 ++ tests/components/ntc/test.esp32-ard.yaml | 30 +-- tests/components/ntc/test.esp32-c3-ard.yaml | 30 +-- tests/components/ntc/test.esp32-c3-idf.yaml | 4 + tests/components/ntc/test.esp32-idf.yaml | 30 +-- tests/components/ntc/test.esp32-s2-ard.yaml | 30 +-- tests/components/ntc/test.esp32-s2-idf.yaml | 4 + tests/components/ntc/test.esp32-s3-ard.yaml | 30 +-- tests/components/ntc/test.esp32-s3-idf.yaml | 4 + tests/components/ntc/test.esp8266-ard.yaml | 29 +- tests/components/ntc/test.rp2040-ard.yaml | 29 +- tests/components/output/common.yaml | 13 + tests/components/output/test.esp32-ard.yaml | 16 +- .../components/output/test.esp32-c3-ard.yaml | 16 +- .../components/output/test.esp32-c3-idf.yaml | 16 +- tests/components/output/test.esp32-idf.yaml | 16 +- tests/components/output/test.esp8266-ard.yaml | 16 +- tests/components/output/test.rp2040-ard.yaml | 16 +- tests/components/partition/common-ard.yaml | 22 ++ tests/components/partition/common-idf.yaml | 21 ++ .../components/partition/test.esp32-ard.yaml | 27 +- .../partition/test.esp32-c3-ard.yaml | 27 +- .../partition/test.esp32-c3-idf.yaml | 26 +- .../components/partition/test.esp32-idf.yaml | 26 +- tests/components/pca6416a/common.yaml | 17 ++ tests/components/pca6416a/test.esp32-ard.yaml | 20 +- .../pca6416a/test.esp32-c3-ard.yaml | 20 +- .../pca6416a/test.esp32-c3-idf.yaml | 20 +- tests/components/pca6416a/test.esp32-idf.yaml | 20 +- .../components/pca6416a/test.esp8266-ard.yaml | 20 +- .../components/pca6416a/test.rp2040-ard.yaml | 20 +- tests/components/pca9554/common.yaml | 26 ++ tests/components/pca9554/test.esp32-ard.yaml | 29 +- .../components/pca9554/test.esp32-c3-ard.yaml | 29 +- .../components/pca9554/test.esp32-c3-idf.yaml | 29 +- tests/components/pca9554/test.esp32-idf.yaml | 29 +- .../components/pca9554/test.esp8266-ard.yaml | 29 +- tests/components/pca9554/test.rp2040-ard.yaml | 29 +- tests/components/pca9685/common.yaml | 34 +++ tests/components/pca9685/test.esp32-ard.yaml | 37 +-- .../components/pca9685/test.esp32-c3-ard.yaml | 37 +-- .../components/pca9685/test.esp32-c3-idf.yaml | 37 +-- tests/components/pca9685/test.esp32-idf.yaml | 37 +-- .../components/pca9685/test.esp8266-ard.yaml | 37 +-- tests/components/pca9685/test.rp2040-ard.yaml | 29 +- tests/components/pcd8544/common.yaml | 14 + tests/components/pcd8544/test.esp32-ard.yaml | 21 +- .../components/pcd8544/test.esp32-c3-ard.yaml | 21 +- .../components/pcd8544/test.esp32-c3-idf.yaml | 21 +- tests/components/pcd8544/test.esp32-idf.yaml | 21 +- .../components/pcd8544/test.esp8266-ard.yaml | 21 +- tests/components/pcd8544/test.rp2040-ard.yaml | 21 +- tests/components/pcf85063/common.yaml | 12 + tests/components/pcf85063/test.esp32-ard.yaml | 15 +- .../pcf85063/test.esp32-c3-ard.yaml | 15 +- .../pcf85063/test.esp32-c3-idf.yaml | 15 +- tests/components/pcf85063/test.esp32-idf.yaml | 15 +- .../components/pcf85063/test.esp8266-ard.yaml | 15 +- .../components/pcf85063/test.rp2040-ard.yaml | 15 +- tests/components/pcf8563/common.yaml | 12 + tests/components/pcf8563/test.esp32-ard.yaml | 15 +- .../components/pcf8563/test.esp32-c3-ard.yaml | 15 +- .../components/pcf8563/test.esp32-c3-idf.yaml | 15 +- tests/components/pcf8563/test.esp32-idf.yaml | 15 +- .../components/pcf8563/test.esp8266-ard.yaml | 15 +- tests/components/pcf8563/test.rp2040-ard.yaml | 15 +- tests/components/pcf8574/common.yaml | 28 ++ tests/components/pcf8574/test.esp32-ard.yaml | 31 +-- .../components/pcf8574/test.esp32-c3-ard.yaml | 31 +-- .../components/pcf8574/test.esp32-c3-idf.yaml | 31 +-- tests/components/pcf8574/test.esp32-idf.yaml | 31 +-- .../components/pcf8574/test.esp8266-ard.yaml | 31 +-- tests/components/pcf8574/test.rp2040-ard.yaml | 31 +-- tests/components/pipsolar/common.yaml | 249 +++++++++++++++++ tests/components/pipsolar/test.esp32-ard.yaml | 252 +----------------- .../pipsolar/test.esp32-c3-ard.yaml | 252 +----------------- .../pipsolar/test.esp32-c3-idf.yaml | 252 +----------------- tests/components/pipsolar/test.esp32-idf.yaml | 252 +----------------- .../components/pipsolar/test.esp8266-ard.yaml | 252 +----------------- .../components/pipsolar/test.rp2040-ard.yaml | 252 +----------------- tests/components/pm1006/common.yaml | 10 + tests/components/pm1006/test.esp32-ard.yaml | 13 +- .../components/pm1006/test.esp32-c3-ard.yaml | 13 +- .../components/pm1006/test.esp32-c3-idf.yaml | 13 +- tests/components/pm1006/test.esp32-idf.yaml | 13 +- tests/components/pm1006/test.esp8266-ard.yaml | 13 +- tests/components/pm1006/test.rp2040-ard.yaml | 13 +- tests/components/pmsa003i/common.yaml | 27 ++ tests/components/pmsa003i/test.esp32-ard.yaml | 30 +-- .../pmsa003i/test.esp32-c3-ard.yaml | 30 +-- .../pmsa003i/test.esp32-c3-idf.yaml | 30 +-- tests/components/pmsa003i/test.esp32-idf.yaml | 30 +-- .../components/pmsa003i/test.esp8266-ard.yaml | 30 +-- .../components/pmsa003i/test.rp2040-ard.yaml | 30 +-- tests/components/pmsx003/common.yaml | 34 +++ tests/components/pmsx003/test.esp32-ard.yaml | 37 +-- .../components/pmsx003/test.esp32-c3-ard.yaml | 37 +-- .../components/pmsx003/test.esp32-c3-idf.yaml | 37 +-- tests/components/pmsx003/test.esp32-idf.yaml | 37 +-- .../components/pmsx003/test.esp8266-ard.yaml | 37 +-- tests/components/pmsx003/test.rp2040-ard.yaml | 37 +-- tests/components/pmwcs3/common.yaml | 15 ++ tests/components/pmwcs3/test.esp32-ard.yaml | 18 +- .../components/pmwcs3/test.esp32-c3-ard.yaml | 18 +- .../components/pmwcs3/test.esp32-c3-idf.yaml | 18 +- tests/components/pmwcs3/test.esp32-idf.yaml | 18 +- tests/components/pmwcs3/test.esp8266-ard.yaml | 18 +- tests/components/pmwcs3/test.rp2040-ard.yaml | 18 +- tests/components/pn532_i2c/common.yaml | 13 + .../components/pn532_i2c/test.esp32-ard.yaml | 16 +- .../pn532_i2c/test.esp32-c3-ard.yaml | 16 +- .../pn532_i2c/test.esp32-c3-idf.yaml | 16 +- .../components/pn532_i2c/test.esp32-idf.yaml | 16 +- .../pn532_i2c/test.esp8266-ard.yaml | 16 +- .../components/pn532_i2c/test.rp2040-ard.yaml | 16 +- tests/components/pn532_spi/common.yaml | 15 ++ .../components/pn532_spi/test.esp32-ard.yaml | 20 +- .../pn532_spi/test.esp32-c3-ard.yaml | 20 +- .../pn532_spi/test.esp32-c3-idf.yaml | 20 +- .../components/pn532_spi/test.esp32-idf.yaml | 20 +- .../pn532_spi/test.esp8266-ard.yaml | 20 +- .../components/pn532_spi/test.rp2040-ard.yaml | 20 +- tests/components/pn7150_i2c/common.yaml | 35 +++ .../components/pn7150_i2c/test.esp32-ard.yaml | 40 +-- .../pn7150_i2c/test.esp32-c3-ard.yaml | 40 +-- .../pn7150_i2c/test.esp32-c3-idf.yaml | 40 +-- .../components/pn7150_i2c/test.esp32-idf.yaml | 40 +-- .../pn7150_i2c/test.esp8266-ard.yaml | 40 +-- .../pn7150_i2c/test.rp2040-ard.yaml | 40 +-- tests/components/pn7160_i2c/common.yaml | 35 +++ .../components/pn7160_i2c/test.esp32-ard.yaml | 40 +-- .../pn7160_i2c/test.esp32-c3-ard.yaml | 40 +-- .../pn7160_i2c/test.esp32-c3-idf.yaml | 40 +-- .../components/pn7160_i2c/test.esp32-idf.yaml | 40 +-- .../pn7160_i2c/test.esp8266-ard.yaml | 40 +-- .../pn7160_i2c/test.rp2040-ard.yaml | 40 +-- tests/components/pn7160_spi/common.yaml | 37 +++ .../components/pn7160_spi/test.esp32-ard.yaml | 44 +-- .../pn7160_spi/test.esp32-c3-ard.yaml | 44 +-- .../pn7160_spi/test.esp32-c3-idf.yaml | 44 +-- .../components/pn7160_spi/test.esp32-idf.yaml | 44 +-- .../pn7160_spi/test.esp8266-ard.yaml | 44 +-- .../pn7160_spi/test.rp2040-ard.yaml | 44 +-- tests/components/pylontech/common.yaml | 48 ++++ .../components/pylontech/test.esp32-ard.yaml | 51 +--- .../pylontech/test.esp32-c3-ard.yaml | 51 +--- .../pylontech/test.esp32-c3-idf.yaml | 51 +--- .../components/pylontech/test.esp32-idf.yaml | 51 +--- .../pylontech/test.esp8266-ard.yaml | 51 +--- .../components/pylontech/test.rp2040-ard.yaml | 51 +--- tests/components/pzem004t/common.yaml | 14 + tests/components/pzem004t/test.esp32-ard.yaml | 17 +- .../pzem004t/test.esp32-c3-ard.yaml | 17 +- .../pzem004t/test.esp32-c3-idf.yaml | 17 +- tests/components/pzem004t/test.esp32-idf.yaml | 17 +- .../components/pzem004t/test.esp8266-ard.yaml | 17 +- .../components/pzem004t/test.rp2040-ard.yaml | 17 +- tests/components/pzemac/common.yaml | 28 ++ tests/components/pzemac/test.esp32-ard.yaml | 31 +-- .../components/pzemac/test.esp32-c3-ard.yaml | 31 +-- .../components/pzemac/test.esp32-c3-idf.yaml | 31 +-- tests/components/pzemac/test.esp32-idf.yaml | 31 +-- tests/components/pzemac/test.esp8266-ard.yaml | 31 +-- tests/components/pzemac/test.rp2040-ard.yaml | 31 +-- tests/components/pzemdc/common.yaml | 23 ++ tests/components/pzemdc/test.esp32-ard.yaml | 26 +- .../components/pzemdc/test.esp32-c3-ard.yaml | 26 +- .../components/pzemdc/test.esp32-c3-idf.yaml | 26 +- tests/components/pzemdc/test.esp32-idf.yaml | 26 +- tests/components/pzemdc/test.esp8266-ard.yaml | 26 +- tests/components/pzemdc/test.rp2040-ard.yaml | 26 +- 171 files changed, 1479 insertions(+), 4560 deletions(-) create mode 100644 tests/components/ntc/common.yaml create mode 100644 tests/components/ntc/test.esp32-c3-idf.yaml create mode 100644 tests/components/ntc/test.esp32-s2-idf.yaml create mode 100644 tests/components/ntc/test.esp32-s3-idf.yaml create mode 100644 tests/components/output/common.yaml create mode 100644 tests/components/partition/common-ard.yaml create mode 100644 tests/components/partition/common-idf.yaml create mode 100644 tests/components/pca6416a/common.yaml create mode 100644 tests/components/pca9554/common.yaml create mode 100644 tests/components/pca9685/common.yaml create mode 100644 tests/components/pcd8544/common.yaml create mode 100644 tests/components/pcf85063/common.yaml create mode 100644 tests/components/pcf8563/common.yaml create mode 100644 tests/components/pcf8574/common.yaml create mode 100644 tests/components/pipsolar/common.yaml create mode 100644 tests/components/pm1006/common.yaml create mode 100644 tests/components/pmsa003i/common.yaml create mode 100644 tests/components/pmsx003/common.yaml create mode 100644 tests/components/pmwcs3/common.yaml create mode 100644 tests/components/pn532_i2c/common.yaml create mode 100644 tests/components/pn532_spi/common.yaml create mode 100644 tests/components/pn7150_i2c/common.yaml create mode 100644 tests/components/pn7160_i2c/common.yaml create mode 100644 tests/components/pn7160_spi/common.yaml create mode 100644 tests/components/pylontech/common.yaml create mode 100644 tests/components/pzem004t/common.yaml create mode 100644 tests/components/pzemac/common.yaml create mode 100644 tests/components/pzemdc/common.yaml diff --git a/tests/components/ntc/common.yaml b/tests/components/ntc/common.yaml new file mode 100644 index 0000000000..79ae7f601d --- /dev/null +++ b/tests/components/ntc/common.yaml @@ -0,0 +1,25 @@ +sensor: + - platform: adc + id: my_sensor + pin: ${pin} + - platform: resistance + sensor: my_sensor + configuration: DOWNSTREAM + resistor: 10kΩ + reference_voltage: 3.3V + name: Resistance + id: resist + - platform: ntc + sensor: resist + name: NTC Sensor + calibration: + b_constant: 3950 + reference_resistance: 10k + reference_temperature: 25°C + - platform: ntc + sensor: resist + name: NTC Sensor2 + calibration: + - 10.0kOhm -> 25°C + - 27.219kOhm -> 0°C + - 14.674kOhm -> 15°C diff --git a/tests/components/ntc/test.esp32-ard.yaml b/tests/components/ntc/test.esp32-ard.yaml index 3e0e901b6e..06864605a6 100644 --- a/tests/components/ntc/test.esp32-ard.yaml +++ b/tests/components/ntc/test.esp32-ard.yaml @@ -1,26 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 32 - attenuation: 11db - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist - - platform: ntc - sensor: resist - name: NTC Sensor - calibration: - b_constant: 3950 - reference_resistance: 10k - reference_temperature: 25°C - - platform: ntc - sensor: resist - name: NTC Sensor2 - calibration: - - 10.0kOhm -> 25°C - - 27.219kOhm -> 0°C - - 14.674kOhm -> 15°C +substitutions: + pin: GPIO32 + +<<: !include common.yaml diff --git a/tests/components/ntc/test.esp32-c3-ard.yaml b/tests/components/ntc/test.esp32-c3-ard.yaml index c0edb83d9d..37fb325f4a 100644 --- a/tests/components/ntc/test.esp32-c3-ard.yaml +++ b/tests/components/ntc/test.esp32-c3-ard.yaml @@ -1,26 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 4 - attenuation: 11db - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist - - platform: ntc - sensor: resist - name: NTC Sensor - calibration: - b_constant: 3950 - reference_resistance: 10k - reference_temperature: 25°C - - platform: ntc - sensor: resist - name: NTC Sensor2 - calibration: - - 10.0kOhm -> 25°C - - 27.219kOhm -> 0°C - - 14.674kOhm -> 15°C +substitutions: + pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/ntc/test.esp32-c3-idf.yaml b/tests/components/ntc/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..37fb325f4a --- /dev/null +++ b/tests/components/ntc/test.esp32-c3-idf.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/ntc/test.esp32-idf.yaml b/tests/components/ntc/test.esp32-idf.yaml index 3e0e901b6e..06864605a6 100644 --- a/tests/components/ntc/test.esp32-idf.yaml +++ b/tests/components/ntc/test.esp32-idf.yaml @@ -1,26 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 32 - attenuation: 11db - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist - - platform: ntc - sensor: resist - name: NTC Sensor - calibration: - b_constant: 3950 - reference_resistance: 10k - reference_temperature: 25°C - - platform: ntc - sensor: resist - name: NTC Sensor2 - calibration: - - 10.0kOhm -> 25°C - - 27.219kOhm -> 0°C - - 14.674kOhm -> 15°C +substitutions: + pin: GPIO32 + +<<: !include common.yaml diff --git a/tests/components/ntc/test.esp32-s2-ard.yaml b/tests/components/ntc/test.esp32-s2-ard.yaml index c0edb83d9d..37fb325f4a 100644 --- a/tests/components/ntc/test.esp32-s2-ard.yaml +++ b/tests/components/ntc/test.esp32-s2-ard.yaml @@ -1,26 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 4 - attenuation: 11db - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist - - platform: ntc - sensor: resist - name: NTC Sensor - calibration: - b_constant: 3950 - reference_resistance: 10k - reference_temperature: 25°C - - platform: ntc - sensor: resist - name: NTC Sensor2 - calibration: - - 10.0kOhm -> 25°C - - 27.219kOhm -> 0°C - - 14.674kOhm -> 15°C +substitutions: + pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/ntc/test.esp32-s2-idf.yaml b/tests/components/ntc/test.esp32-s2-idf.yaml new file mode 100644 index 0000000000..37fb325f4a --- /dev/null +++ b/tests/components/ntc/test.esp32-s2-idf.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/ntc/test.esp32-s3-ard.yaml b/tests/components/ntc/test.esp32-s3-ard.yaml index c0edb83d9d..37fb325f4a 100644 --- a/tests/components/ntc/test.esp32-s3-ard.yaml +++ b/tests/components/ntc/test.esp32-s3-ard.yaml @@ -1,26 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 4 - attenuation: 11db - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist - - platform: ntc - sensor: resist - name: NTC Sensor - calibration: - b_constant: 3950 - reference_resistance: 10k - reference_temperature: 25°C - - platform: ntc - sensor: resist - name: NTC Sensor2 - calibration: - - 10.0kOhm -> 25°C - - 27.219kOhm -> 0°C - - 14.674kOhm -> 15°C +substitutions: + pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/ntc/test.esp32-s3-idf.yaml b/tests/components/ntc/test.esp32-s3-idf.yaml new file mode 100644 index 0000000000..37fb325f4a --- /dev/null +++ b/tests/components/ntc/test.esp32-s3-idf.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/ntc/test.esp8266-ard.yaml b/tests/components/ntc/test.esp8266-ard.yaml index 370d16d3f7..4a6d36cbb4 100644 --- a/tests/components/ntc/test.esp8266-ard.yaml +++ b/tests/components/ntc/test.esp8266-ard.yaml @@ -1,25 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: A0 - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist - - platform: ntc - sensor: resist - name: NTC Sensor - calibration: - b_constant: 3950 - reference_resistance: 10k - reference_temperature: 25°C - - platform: ntc - sensor: resist - name: NTC Sensor2 - calibration: - - 10.0kOhm -> 25°C - - 27.219kOhm -> 0°C - - 14.674kOhm -> 15°C +substitutions: + pin: A0 + +<<: !include common.yaml diff --git a/tests/components/ntc/test.rp2040-ard.yaml b/tests/components/ntc/test.rp2040-ard.yaml index 9c7ba7b539..9479437434 100644 --- a/tests/components/ntc/test.rp2040-ard.yaml +++ b/tests/components/ntc/test.rp2040-ard.yaml @@ -1,25 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 26 - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist - - platform: ntc - sensor: resist - name: NTC Sensor - calibration: - b_constant: 3950 - reference_resistance: 10k - reference_temperature: 25°C - - platform: ntc - sensor: resist - name: NTC Sensor2 - calibration: - - 10.0kOhm -> 25°C - - 27.219kOhm -> 0°C - - 14.674kOhm -> 15°C +substitutions: + pin: GPIO26 + +<<: !include common.yaml diff --git a/tests/components/output/common.yaml b/tests/components/output/common.yaml new file mode 100644 index 0000000000..5f31ae50a8 --- /dev/null +++ b/tests/components/output/common.yaml @@ -0,0 +1,13 @@ +esphome: + on_boot: + then: + - output.turn_off: light_output_1 + - output.turn_on: light_output_1 + - output.set_level: + id: light_output_1 + level: 50% + +output: + - platform: ${output_platform} + id: light_output_1 + pin: ${pin} diff --git a/tests/components/output/test.esp32-ard.yaml b/tests/components/output/test.esp32-ard.yaml index 480f9dfe1f..7687f2a7c8 100644 --- a/tests/components/output/test.esp32-ard.yaml +++ b/tests/components/output/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -esphome: - on_boot: - then: - - output.turn_off: light_output_1 - - output.turn_on: light_output_1 - - output.set_level: - id: light_output_1 - level: 50% +substitutions: + output_platform: ledc + pin: GPIO12 -output: - - platform: ledc - id: light_output_1 - pin: 12 +<<: !include common.yaml diff --git a/tests/components/output/test.esp32-c3-ard.yaml b/tests/components/output/test.esp32-c3-ard.yaml index c56d85c296..2227643703 100644 --- a/tests/components/output/test.esp32-c3-ard.yaml +++ b/tests/components/output/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -esphome: - on_boot: - then: - - output.turn_off: light_output_1 - - output.turn_on: light_output_1 - - output.set_level: - id: light_output_1 - level: 50% +substitutions: + output_platform: ledc + pin: GPIO1 -output: - - platform: ledc - id: light_output_1 - pin: 1 +<<: !include common.yaml diff --git a/tests/components/output/test.esp32-c3-idf.yaml b/tests/components/output/test.esp32-c3-idf.yaml index c56d85c296..2227643703 100644 --- a/tests/components/output/test.esp32-c3-idf.yaml +++ b/tests/components/output/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -esphome: - on_boot: - then: - - output.turn_off: light_output_1 - - output.turn_on: light_output_1 - - output.set_level: - id: light_output_1 - level: 50% +substitutions: + output_platform: ledc + pin: GPIO1 -output: - - platform: ledc - id: light_output_1 - pin: 1 +<<: !include common.yaml diff --git a/tests/components/output/test.esp32-idf.yaml b/tests/components/output/test.esp32-idf.yaml index 480f9dfe1f..7687f2a7c8 100644 --- a/tests/components/output/test.esp32-idf.yaml +++ b/tests/components/output/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -esphome: - on_boot: - then: - - output.turn_off: light_output_1 - - output.turn_on: light_output_1 - - output.set_level: - id: light_output_1 - level: 50% +substitutions: + output_platform: ledc + pin: GPIO12 -output: - - platform: ledc - id: light_output_1 - pin: 12 +<<: !include common.yaml diff --git a/tests/components/output/test.esp8266-ard.yaml b/tests/components/output/test.esp8266-ard.yaml index d9cb353636..34152066ba 100644 --- a/tests/components/output/test.esp8266-ard.yaml +++ b/tests/components/output/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -esphome: - on_boot: - then: - - output.turn_off: light_output_1 - - output.turn_on: light_output_1 - - output.set_level: - id: light_output_1 - level: 50% +substitutions: + output_platform: esp8266_pwm + pin: GPIO12 -output: - - platform: esp8266_pwm - id: light_output_1 - pin: 12 +<<: !include common.yaml diff --git a/tests/components/output/test.rp2040-ard.yaml b/tests/components/output/test.rp2040-ard.yaml index 399259fdd9..cc8d89ee06 100644 --- a/tests/components/output/test.rp2040-ard.yaml +++ b/tests/components/output/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -esphome: - on_boot: - then: - - output.turn_off: light_output_1 - - output.turn_on: light_output_1 - - output.set_level: - id: light_output_1 - level: 50% +substitutions: + output_platform: rp2040_pwm + pin: GPIO12 -output: - - platform: rp2040_pwm - id: light_output_1 - pin: 12 +<<: !include common.yaml diff --git a/tests/components/partition/common-ard.yaml b/tests/components/partition/common-ard.yaml new file mode 100644 index 0000000000..654eacf54f --- /dev/null +++ b/tests/components/partition/common-ard.yaml @@ -0,0 +1,22 @@ +light: + - platform: ${light_platform} + id: part_leds + default_transition_length: 500ms + chipset: ws2812 + num_leds: 256 + rgb_order: GRB + rmt_channel: 1 + pin: ${pin} + - platform: partition + name: Partition Light + segments: + - id: part_leds + from: 0 + to: 0 + - id: part_leds + from: 1 + to: 10 + - id: part_leds + from: 20 + to: 25 + - single_light_id: part_leds diff --git a/tests/components/partition/common-idf.yaml b/tests/components/partition/common-idf.yaml new file mode 100644 index 0000000000..b2ceadd6f7 --- /dev/null +++ b/tests/components/partition/common-idf.yaml @@ -0,0 +1,21 @@ +light: + - platform: ${light_platform} + id: part_leds + default_transition_length: 500ms + chipset: ws2812 + num_leds: 256 + rgb_order: GRB + pin: ${pin} + - platform: partition + name: Partition Light + segments: + - id: part_leds + from: 0 + to: 0 + - id: part_leds + from: 1 + to: 10 + - id: part_leds + from: 20 + to: 25 + - single_light_id: part_leds diff --git a/tests/components/partition/test.esp32-ard.yaml b/tests/components/partition/test.esp32-ard.yaml index c8eae67d40..32cf2a64ba 100644 --- a/tests/components/partition/test.esp32-ard.yaml +++ b/tests/components/partition/test.esp32-ard.yaml @@ -1,22 +1,5 @@ -light: - - platform: fastled_clockless - id: part_leds - chipset: WS2812B - pin: 2 - num_leds: 256 - rgb_order: GRB - default_transition_length: 0s - color_correct: [50%, 50%, 50%] - - platform: partition - name: Partition Light - segments: - - id: part_leds - from: 0 - to: 0 - - id: part_leds - from: 1 - to: 10 - - id: part_leds - from: 20 - to: 25 - - single_light_id: part_leds +substitutions: + light_platform: esp32_rmt_led_strip + pin: GPIO2 + +<<: !include common-ard.yaml diff --git a/tests/components/partition/test.esp32-c3-ard.yaml b/tests/components/partition/test.esp32-c3-ard.yaml index 77cfc5ad44..32cf2a64ba 100644 --- a/tests/components/partition/test.esp32-c3-ard.yaml +++ b/tests/components/partition/test.esp32-c3-ard.yaml @@ -1,22 +1,5 @@ -light: - - platform: esp32_rmt_led_strip - id: part_leds - default_transition_length: 500ms - chipset: ws2812 - rgb_order: GRB - num_leds: 256 - pin: 2 - rmt_channel: 0 - - platform: partition - name: Partition Light - segments: - - id: part_leds - from: 0 - to: 0 - - id: part_leds - from: 1 - to: 10 - - id: part_leds - from: 20 - to: 25 - - single_light_id: part_leds +substitutions: + light_platform: esp32_rmt_led_strip + pin: GPIO2 + +<<: !include common-ard.yaml diff --git a/tests/components/partition/test.esp32-c3-idf.yaml b/tests/components/partition/test.esp32-c3-idf.yaml index 397e1b0642..d9dc4f6804 100644 --- a/tests/components/partition/test.esp32-c3-idf.yaml +++ b/tests/components/partition/test.esp32-c3-idf.yaml @@ -1,21 +1,5 @@ -light: - - platform: esp32_rmt_led_strip - id: part_leds - default_transition_length: 500ms - chipset: ws2812 - rgb_order: GRB - num_leds: 256 - pin: 2 - - platform: partition - name: Partition Light - segments: - - id: part_leds - from: 0 - to: 0 - - id: part_leds - from: 1 - to: 10 - - id: part_leds - from: 20 - to: 25 - - single_light_id: part_leds +substitutions: + light_platform: esp32_rmt_led_strip + pin: GPIO2 + +<<: !include common-idf.yaml diff --git a/tests/components/partition/test.esp32-idf.yaml b/tests/components/partition/test.esp32-idf.yaml index 397e1b0642..7dc7d15553 100644 --- a/tests/components/partition/test.esp32-idf.yaml +++ b/tests/components/partition/test.esp32-idf.yaml @@ -1,21 +1,5 @@ -light: - - platform: esp32_rmt_led_strip - id: part_leds - default_transition_length: 500ms - chipset: ws2812 - rgb_order: GRB - num_leds: 256 - pin: 2 - - platform: partition - name: Partition Light - segments: - - id: part_leds - from: 0 - to: 0 - - id: part_leds - from: 1 - to: 10 - - id: part_leds - from: 20 - to: 25 - - single_light_id: part_leds +substitutions: + light_platform: esp32_rmt_led_strip + pin: GPIO12 + +<<: !include common-idf.yaml diff --git a/tests/components/pca6416a/common.yaml b/tests/components/pca6416a/common.yaml new file mode 100644 index 0000000000..ea538387e4 --- /dev/null +++ b/tests/components/pca6416a/common.yaml @@ -0,0 +1,17 @@ +i2c: + - id: i2c_pca6416a + scl: ${scl_pin} + sda: ${sda_pin} + +pca6416a: + - id: pca6416a_hub + address: 0x21 + +binary_sensor: + - platform: gpio + name: PCA6416A Binary Sensor + pin: + pca6416a: pca6416a_hub + number: 15 + mode: INPUT + inverted: true diff --git a/tests/components/pca6416a/test.esp32-ard.yaml b/tests/components/pca6416a/test.esp32-ard.yaml index 669e9416e4..63c3bd6afd 100644 --- a/tests/components/pca6416a/test.esp32-ard.yaml +++ b/tests/components/pca6416a/test.esp32-ard.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_pca6416a - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -pca6416a: - - id: pca6416a_hub - address: 0x21 - -binary_sensor: - - platform: gpio - name: PCA6416A Binary Sensor - pin: - pca6416a: pca6416a_hub - number: 15 - mode: INPUT - inverted: true +<<: !include common.yaml diff --git a/tests/components/pca6416a/test.esp32-c3-ard.yaml b/tests/components/pca6416a/test.esp32-c3-ard.yaml index fe940c44cc..ee2c29ca4e 100644 --- a/tests/components/pca6416a/test.esp32-c3-ard.yaml +++ b/tests/components/pca6416a/test.esp32-c3-ard.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_pca6416a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca6416a: - - id: pca6416a_hub - address: 0x21 - -binary_sensor: - - platform: gpio - name: PCA6416A Binary Sensor - pin: - pca6416a: pca6416a_hub - number: 15 - mode: INPUT - inverted: true +<<: !include common.yaml diff --git a/tests/components/pca6416a/test.esp32-c3-idf.yaml b/tests/components/pca6416a/test.esp32-c3-idf.yaml index fe940c44cc..ee2c29ca4e 100644 --- a/tests/components/pca6416a/test.esp32-c3-idf.yaml +++ b/tests/components/pca6416a/test.esp32-c3-idf.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_pca6416a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca6416a: - - id: pca6416a_hub - address: 0x21 - -binary_sensor: - - platform: gpio - name: PCA6416A Binary Sensor - pin: - pca6416a: pca6416a_hub - number: 15 - mode: INPUT - inverted: true +<<: !include common.yaml diff --git a/tests/components/pca6416a/test.esp32-idf.yaml b/tests/components/pca6416a/test.esp32-idf.yaml index 669e9416e4..63c3bd6afd 100644 --- a/tests/components/pca6416a/test.esp32-idf.yaml +++ b/tests/components/pca6416a/test.esp32-idf.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_pca6416a - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -pca6416a: - - id: pca6416a_hub - address: 0x21 - -binary_sensor: - - platform: gpio - name: PCA6416A Binary Sensor - pin: - pca6416a: pca6416a_hub - number: 15 - mode: INPUT - inverted: true +<<: !include common.yaml diff --git a/tests/components/pca6416a/test.esp8266-ard.yaml b/tests/components/pca6416a/test.esp8266-ard.yaml index fe940c44cc..ee2c29ca4e 100644 --- a/tests/components/pca6416a/test.esp8266-ard.yaml +++ b/tests/components/pca6416a/test.esp8266-ard.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_pca6416a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca6416a: - - id: pca6416a_hub - address: 0x21 - -binary_sensor: - - platform: gpio - name: PCA6416A Binary Sensor - pin: - pca6416a: pca6416a_hub - number: 15 - mode: INPUT - inverted: true +<<: !include common.yaml diff --git a/tests/components/pca6416a/test.rp2040-ard.yaml b/tests/components/pca6416a/test.rp2040-ard.yaml index fe940c44cc..ee2c29ca4e 100644 --- a/tests/components/pca6416a/test.rp2040-ard.yaml +++ b/tests/components/pca6416a/test.rp2040-ard.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_pca6416a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca6416a: - - id: pca6416a_hub - address: 0x21 - -binary_sensor: - - platform: gpio - name: PCA6416A Binary Sensor - pin: - pca6416a: pca6416a_hub - number: 15 - mode: INPUT - inverted: true +<<: !include common.yaml diff --git a/tests/components/pca9554/common.yaml b/tests/components/pca9554/common.yaml new file mode 100644 index 0000000000..db2ec2b826 --- /dev/null +++ b/tests/components/pca9554/common.yaml @@ -0,0 +1,26 @@ +i2c: + - id: i2c_pca9554 + scl: ${scl_pin} + sda: ${sda_pin} + +pca9554: + - id: pca9554_hub + pin_count: 8 + address: 0x3F + +binary_sensor: + - platform: gpio + id: pca9554_input + name: PCA9554 Binary Sensor + pin: + pca9554: pca9554_hub + number: 1 + mode: INPUT + inverted: true + - platform: gpio + id: pca9554_output + pin: + pca9554: pca9554_hub + number: 0 + mode: OUTPUT + inverted: false diff --git a/tests/components/pca9554/test.esp32-ard.yaml b/tests/components/pca9554/test.esp32-ard.yaml index 8fe9686303..63c3bd6afd 100644 --- a/tests/components/pca9554/test.esp32-ard.yaml +++ b/tests/components/pca9554/test.esp32-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_pca9554 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -pca9554: - - id: pca9554_hub - pin_count: 8 - address: 0x3F - -binary_sensor: - - platform: gpio - id: pca9554_input - name: PCA9554 Binary Sensor - pin: - pca9554: pca9554_hub - number: 1 - mode: INPUT - inverted: true - - platform: gpio - id: pca9554_output - pin: - pca9554: pca9554_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pca9554/test.esp32-c3-ard.yaml b/tests/components/pca9554/test.esp32-c3-ard.yaml index 0ff453e64f..ee2c29ca4e 100644 --- a/tests/components/pca9554/test.esp32-c3-ard.yaml +++ b/tests/components/pca9554/test.esp32-c3-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_pca9554 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca9554: - - id: pca9554_hub - pin_count: 8 - address: 0x3F - -binary_sensor: - - platform: gpio - id: pca9554_input - name: PCA9554 Binary Sensor - pin: - pca9554: pca9554_hub - number: 1 - mode: INPUT - inverted: true - - platform: gpio - id: pca9554_output - pin: - pca9554: pca9554_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pca9554/test.esp32-c3-idf.yaml b/tests/components/pca9554/test.esp32-c3-idf.yaml index 0ff453e64f..ee2c29ca4e 100644 --- a/tests/components/pca9554/test.esp32-c3-idf.yaml +++ b/tests/components/pca9554/test.esp32-c3-idf.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_pca9554 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca9554: - - id: pca9554_hub - pin_count: 8 - address: 0x3F - -binary_sensor: - - platform: gpio - id: pca9554_input - name: PCA9554 Binary Sensor - pin: - pca9554: pca9554_hub - number: 1 - mode: INPUT - inverted: true - - platform: gpio - id: pca9554_output - pin: - pca9554: pca9554_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pca9554/test.esp32-idf.yaml b/tests/components/pca9554/test.esp32-idf.yaml index 8fe9686303..63c3bd6afd 100644 --- a/tests/components/pca9554/test.esp32-idf.yaml +++ b/tests/components/pca9554/test.esp32-idf.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_pca9554 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -pca9554: - - id: pca9554_hub - pin_count: 8 - address: 0x3F - -binary_sensor: - - platform: gpio - id: pca9554_input - name: PCA9554 Binary Sensor - pin: - pca9554: pca9554_hub - number: 1 - mode: INPUT - inverted: true - - platform: gpio - id: pca9554_output - pin: - pca9554: pca9554_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pca9554/test.esp8266-ard.yaml b/tests/components/pca9554/test.esp8266-ard.yaml index 0ff453e64f..ee2c29ca4e 100644 --- a/tests/components/pca9554/test.esp8266-ard.yaml +++ b/tests/components/pca9554/test.esp8266-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_pca9554 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca9554: - - id: pca9554_hub - pin_count: 8 - address: 0x3F - -binary_sensor: - - platform: gpio - id: pca9554_input - name: PCA9554 Binary Sensor - pin: - pca9554: pca9554_hub - number: 1 - mode: INPUT - inverted: true - - platform: gpio - id: pca9554_output - pin: - pca9554: pca9554_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pca9554/test.rp2040-ard.yaml b/tests/components/pca9554/test.rp2040-ard.yaml index 0ff453e64f..ee2c29ca4e 100644 --- a/tests/components/pca9554/test.rp2040-ard.yaml +++ b/tests/components/pca9554/test.rp2040-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_pca9554 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca9554: - - id: pca9554_hub - pin_count: 8 - address: 0x3F - -binary_sensor: - - platform: gpio - id: pca9554_input - name: PCA9554 Binary Sensor - pin: - pca9554: pca9554_hub - number: 1 - mode: INPUT - inverted: true - - platform: gpio - id: pca9554_output - pin: - pca9554: pca9554_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pca9685/common.yaml b/tests/components/pca9685/common.yaml new file mode 100644 index 0000000000..57cdc5de9b --- /dev/null +++ b/tests/components/pca9685/common.yaml @@ -0,0 +1,34 @@ +i2c: + - id: i2c_pca9685 + scl: ${scl_pin} + sda: ${sda_pin} + +pca9685: + frequency: 500 + address: 0x0 + +output: + - platform: pca9685 + id: pca_0 + channel: 0 + - platform: pca9685 + id: pca_1 + channel: 1 + - platform: pca9685 + id: pca_2 + channel: 2 + - platform: pca9685 + id: pca_3 + channel: 3 + - platform: pca9685 + id: pca_4 + channel: 4 + - platform: pca9685 + id: pca_5 + channel: 5 + - platform: pca9685 + id: pca_6 + channel: 6 + - platform: pca9685 + id: pca_7 + channel: 7 diff --git a/tests/components/pca9685/test.esp32-ard.yaml b/tests/components/pca9685/test.esp32-ard.yaml index d02a16bcd1..63c3bd6afd 100644 --- a/tests/components/pca9685/test.esp32-ard.yaml +++ b/tests/components/pca9685/test.esp32-ard.yaml @@ -1,34 +1,5 @@ -i2c: - - id: i2c_pca9685 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -pca9685: - frequency: 500 - address: 0x0 - -output: - - platform: pca9685 - id: pca_0 - channel: 0 - - platform: pca9685 - id: pca_1 - channel: 1 - - platform: pca9685 - id: pca_2 - channel: 2 - - platform: pca9685 - id: pca_3 - channel: 3 - - platform: pca9685 - id: pca_4 - channel: 4 - - platform: pca9685 - id: pca_5 - channel: 5 - - platform: pca9685 - id: pca_6 - channel: 6 - - platform: pca9685 - id: pca_7 - channel: 7 +<<: !include common.yaml diff --git a/tests/components/pca9685/test.esp32-c3-ard.yaml b/tests/components/pca9685/test.esp32-c3-ard.yaml index e532f323be..ee2c29ca4e 100644 --- a/tests/components/pca9685/test.esp32-c3-ard.yaml +++ b/tests/components/pca9685/test.esp32-c3-ard.yaml @@ -1,34 +1,5 @@ -i2c: - - id: i2c_pca9685 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca9685: - frequency: 500 - address: 0x0 - -output: - - platform: pca9685 - id: pca_0 - channel: 0 - - platform: pca9685 - id: pca_1 - channel: 1 - - platform: pca9685 - id: pca_2 - channel: 2 - - platform: pca9685 - id: pca_3 - channel: 3 - - platform: pca9685 - id: pca_4 - channel: 4 - - platform: pca9685 - id: pca_5 - channel: 5 - - platform: pca9685 - id: pca_6 - channel: 6 - - platform: pca9685 - id: pca_7 - channel: 7 +<<: !include common.yaml diff --git a/tests/components/pca9685/test.esp32-c3-idf.yaml b/tests/components/pca9685/test.esp32-c3-idf.yaml index e532f323be..ee2c29ca4e 100644 --- a/tests/components/pca9685/test.esp32-c3-idf.yaml +++ b/tests/components/pca9685/test.esp32-c3-idf.yaml @@ -1,34 +1,5 @@ -i2c: - - id: i2c_pca9685 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca9685: - frequency: 500 - address: 0x0 - -output: - - platform: pca9685 - id: pca_0 - channel: 0 - - platform: pca9685 - id: pca_1 - channel: 1 - - platform: pca9685 - id: pca_2 - channel: 2 - - platform: pca9685 - id: pca_3 - channel: 3 - - platform: pca9685 - id: pca_4 - channel: 4 - - platform: pca9685 - id: pca_5 - channel: 5 - - platform: pca9685 - id: pca_6 - channel: 6 - - platform: pca9685 - id: pca_7 - channel: 7 +<<: !include common.yaml diff --git a/tests/components/pca9685/test.esp32-idf.yaml b/tests/components/pca9685/test.esp32-idf.yaml index d02a16bcd1..63c3bd6afd 100644 --- a/tests/components/pca9685/test.esp32-idf.yaml +++ b/tests/components/pca9685/test.esp32-idf.yaml @@ -1,34 +1,5 @@ -i2c: - - id: i2c_pca9685 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -pca9685: - frequency: 500 - address: 0x0 - -output: - - platform: pca9685 - id: pca_0 - channel: 0 - - platform: pca9685 - id: pca_1 - channel: 1 - - platform: pca9685 - id: pca_2 - channel: 2 - - platform: pca9685 - id: pca_3 - channel: 3 - - platform: pca9685 - id: pca_4 - channel: 4 - - platform: pca9685 - id: pca_5 - channel: 5 - - platform: pca9685 - id: pca_6 - channel: 6 - - platform: pca9685 - id: pca_7 - channel: 7 +<<: !include common.yaml diff --git a/tests/components/pca9685/test.esp8266-ard.yaml b/tests/components/pca9685/test.esp8266-ard.yaml index e532f323be..ee2c29ca4e 100644 --- a/tests/components/pca9685/test.esp8266-ard.yaml +++ b/tests/components/pca9685/test.esp8266-ard.yaml @@ -1,34 +1,5 @@ -i2c: - - id: i2c_pca9685 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca9685: - frequency: 500 - address: 0x0 - -output: - - platform: pca9685 - id: pca_0 - channel: 0 - - platform: pca9685 - id: pca_1 - channel: 1 - - platform: pca9685 - id: pca_2 - channel: 2 - - platform: pca9685 - id: pca_3 - channel: 3 - - platform: pca9685 - id: pca_4 - channel: 4 - - platform: pca9685 - id: pca_5 - channel: 5 - - platform: pca9685 - id: pca_6 - channel: 6 - - platform: pca9685 - id: pca_7 - channel: 7 +<<: !include common.yaml diff --git a/tests/components/pca9685/test.rp2040-ard.yaml b/tests/components/pca9685/test.rp2040-ard.yaml index 0ff453e64f..ee2c29ca4e 100644 --- a/tests/components/pca9685/test.rp2040-ard.yaml +++ b/tests/components/pca9685/test.rp2040-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_pca9554 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pca9554: - - id: pca9554_hub - pin_count: 8 - address: 0x3F - -binary_sensor: - - platform: gpio - id: pca9554_input - name: PCA9554 Binary Sensor - pin: - pca9554: pca9554_hub - number: 1 - mode: INPUT - inverted: true - - platform: gpio - id: pca9554_output - pin: - pca9554: pca9554_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pcd8544/common.yaml b/tests/components/pcd8544/common.yaml new file mode 100644 index 0000000000..0fb969eeb8 --- /dev/null +++ b/tests/components/pcd8544/common.yaml @@ -0,0 +1,14 @@ +spi: + - id: spi_pcd8544 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +display: + - platform: pcd8544 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + contrast: 60 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); diff --git a/tests/components/pcd8544/test.esp32-ard.yaml b/tests/components/pcd8544/test.esp32-ard.yaml index 20c05c407f..09e9db5a38 100644 --- a/tests/components/pcd8544/test.esp32-ard.yaml +++ b/tests/components/pcd8544/test.esp32-ard.yaml @@ -1,14 +1,9 @@ -spi: - - id: spi_pcd8544 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO18 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: pcd8544 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - contrast: 60 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/pcd8544/test.esp32-c3-ard.yaml b/tests/components/pcd8544/test.esp32-c3-ard.yaml index 57771d2d73..c5c932c92c 100644 --- a/tests/components/pcd8544/test.esp32-c3-ard.yaml +++ b/tests/components/pcd8544/test.esp32-c3-ard.yaml @@ -1,14 +1,9 @@ -spi: - - id: spi_pcd8544 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: pcd8544 - cs_pin: 2 - dc_pin: 3 - reset_pin: 1 - contrast: 60 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/pcd8544/test.esp32-c3-idf.yaml b/tests/components/pcd8544/test.esp32-c3-idf.yaml index 57771d2d73..c5c932c92c 100644 --- a/tests/components/pcd8544/test.esp32-c3-idf.yaml +++ b/tests/components/pcd8544/test.esp32-c3-idf.yaml @@ -1,14 +1,9 @@ -spi: - - id: spi_pcd8544 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: pcd8544 - cs_pin: 2 - dc_pin: 3 - reset_pin: 1 - contrast: 60 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/pcd8544/test.esp32-idf.yaml b/tests/components/pcd8544/test.esp32-idf.yaml index 20c05c407f..09e9db5a38 100644 --- a/tests/components/pcd8544/test.esp32-idf.yaml +++ b/tests/components/pcd8544/test.esp32-idf.yaml @@ -1,14 +1,9 @@ -spi: - - id: spi_pcd8544 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO18 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: pcd8544 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - contrast: 60 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/pcd8544/test.esp8266-ard.yaml b/tests/components/pcd8544/test.esp8266-ard.yaml index 6e6022c6d2..3f023a60eb 100644 --- a/tests/components/pcd8544/test.esp8266-ard.yaml +++ b/tests/components/pcd8544/test.esp8266-ard.yaml @@ -1,14 +1,9 @@ -spi: - - id: spi_pcd8544 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: pcd8544 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - contrast: 60 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/pcd8544/test.rp2040-ard.yaml b/tests/components/pcd8544/test.rp2040-ard.yaml index 7181f99fb1..d7fd6ee294 100644 --- a/tests/components/pcd8544/test.rp2040-ard.yaml +++ b/tests/components/pcd8544/test.rp2040-ard.yaml @@ -1,14 +1,9 @@ -spi: - - id: spi_pcd8544 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: pcd8544 - cs_pin: 6 - dc_pin: 5 - reset_pin: 7 - contrast: 60 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/pcf85063/common.yaml b/tests/components/pcf85063/common.yaml new file mode 100644 index 0000000000..f3b68412c5 --- /dev/null +++ b/tests/components/pcf85063/common.yaml @@ -0,0 +1,12 @@ +esphome: + on_boot: + - pcf85063.read_time + - pcf85063.write_time + +i2c: + - id: i2c_pcf85063 + scl: ${scl_pin} + sda: ${sda_pin} + +time: + - platform: pcf85063 diff --git a/tests/components/pcf85063/test.esp32-ard.yaml b/tests/components/pcf85063/test.esp32-ard.yaml index 9cce415103..63c3bd6afd 100644 --- a/tests/components/pcf85063/test.esp32-ard.yaml +++ b/tests/components/pcf85063/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf85063.read_time - - pcf85063.write_time +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_pcf85063 - scl: 16 - sda: 17 - -time: - - platform: pcf85063 +<<: !include common.yaml diff --git a/tests/components/pcf85063/test.esp32-c3-ard.yaml b/tests/components/pcf85063/test.esp32-c3-ard.yaml index 9e1a3da81e..ee2c29ca4e 100644 --- a/tests/components/pcf85063/test.esp32-c3-ard.yaml +++ b/tests/components/pcf85063/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf85063.read_time - - pcf85063.write_time +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_pcf85063 - scl: 5 - sda: 4 - -time: - - platform: pcf85063 +<<: !include common.yaml diff --git a/tests/components/pcf85063/test.esp32-c3-idf.yaml b/tests/components/pcf85063/test.esp32-c3-idf.yaml index 9e1a3da81e..ee2c29ca4e 100644 --- a/tests/components/pcf85063/test.esp32-c3-idf.yaml +++ b/tests/components/pcf85063/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf85063.read_time - - pcf85063.write_time +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_pcf85063 - scl: 5 - sda: 4 - -time: - - platform: pcf85063 +<<: !include common.yaml diff --git a/tests/components/pcf85063/test.esp32-idf.yaml b/tests/components/pcf85063/test.esp32-idf.yaml index 9cce415103..63c3bd6afd 100644 --- a/tests/components/pcf85063/test.esp32-idf.yaml +++ b/tests/components/pcf85063/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf85063.read_time - - pcf85063.write_time +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_pcf85063 - scl: 16 - sda: 17 - -time: - - platform: pcf85063 +<<: !include common.yaml diff --git a/tests/components/pcf85063/test.esp8266-ard.yaml b/tests/components/pcf85063/test.esp8266-ard.yaml index 9e1a3da81e..ee2c29ca4e 100644 --- a/tests/components/pcf85063/test.esp8266-ard.yaml +++ b/tests/components/pcf85063/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf85063.read_time - - pcf85063.write_time +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_pcf85063 - scl: 5 - sda: 4 - -time: - - platform: pcf85063 +<<: !include common.yaml diff --git a/tests/components/pcf85063/test.rp2040-ard.yaml b/tests/components/pcf85063/test.rp2040-ard.yaml index 9e1a3da81e..ee2c29ca4e 100644 --- a/tests/components/pcf85063/test.rp2040-ard.yaml +++ b/tests/components/pcf85063/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf85063.read_time - - pcf85063.write_time +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_pcf85063 - scl: 5 - sda: 4 - -time: - - platform: pcf85063 +<<: !include common.yaml diff --git a/tests/components/pcf8563/common.yaml b/tests/components/pcf8563/common.yaml new file mode 100644 index 0000000000..30be6b893c --- /dev/null +++ b/tests/components/pcf8563/common.yaml @@ -0,0 +1,12 @@ +esphome: + on_boot: + - pcf8563.read_time + - pcf8563.write_time + +i2c: + - id: i2c_pcf8563 + scl: ${scl_pin} + sda: ${sda_pin} + +time: + - platform: pcf8563 diff --git a/tests/components/pcf8563/test.esp32-ard.yaml b/tests/components/pcf8563/test.esp32-ard.yaml index e95b487b19..63c3bd6afd 100644 --- a/tests/components/pcf8563/test.esp32-ard.yaml +++ b/tests/components/pcf8563/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf8563.read_time - - pcf8563.write_time +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_pcf8563 - scl: 16 - sda: 17 - -time: - - platform: pcf8563 +<<: !include common.yaml diff --git a/tests/components/pcf8563/test.esp32-c3-ard.yaml b/tests/components/pcf8563/test.esp32-c3-ard.yaml index f91a465e0f..ee2c29ca4e 100644 --- a/tests/components/pcf8563/test.esp32-c3-ard.yaml +++ b/tests/components/pcf8563/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf8563.read_time - - pcf8563.write_time +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_pcf8563 - scl: 5 - sda: 4 - -time: - - platform: pcf8563 +<<: !include common.yaml diff --git a/tests/components/pcf8563/test.esp32-c3-idf.yaml b/tests/components/pcf8563/test.esp32-c3-idf.yaml index f91a465e0f..ee2c29ca4e 100644 --- a/tests/components/pcf8563/test.esp32-c3-idf.yaml +++ b/tests/components/pcf8563/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf8563.read_time - - pcf8563.write_time +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_pcf8563 - scl: 5 - sda: 4 - -time: - - platform: pcf8563 +<<: !include common.yaml diff --git a/tests/components/pcf8563/test.esp32-idf.yaml b/tests/components/pcf8563/test.esp32-idf.yaml index e95b487b19..63c3bd6afd 100644 --- a/tests/components/pcf8563/test.esp32-idf.yaml +++ b/tests/components/pcf8563/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf8563.read_time - - pcf8563.write_time +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_pcf8563 - scl: 16 - sda: 17 - -time: - - platform: pcf8563 +<<: !include common.yaml diff --git a/tests/components/pcf8563/test.esp8266-ard.yaml b/tests/components/pcf8563/test.esp8266-ard.yaml index f91a465e0f..ee2c29ca4e 100644 --- a/tests/components/pcf8563/test.esp8266-ard.yaml +++ b/tests/components/pcf8563/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf8563.read_time - - pcf8563.write_time +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_pcf8563 - scl: 5 - sda: 4 - -time: - - platform: pcf8563 +<<: !include common.yaml diff --git a/tests/components/pcf8563/test.rp2040-ard.yaml b/tests/components/pcf8563/test.rp2040-ard.yaml index f91a465e0f..ee2c29ca4e 100644 --- a/tests/components/pcf8563/test.rp2040-ard.yaml +++ b/tests/components/pcf8563/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -esphome: - on_boot: - - pcf8563.read_time - - pcf8563.write_time +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_pcf8563 - scl: 5 - sda: 4 - -time: - - platform: pcf8563 +<<: !include common.yaml diff --git a/tests/components/pcf8574/common.yaml b/tests/components/pcf8574/common.yaml new file mode 100644 index 0000000000..f5fcfad64a --- /dev/null +++ b/tests/components/pcf8574/common.yaml @@ -0,0 +1,28 @@ +i2c: + - id: i2c_pcf8574 + scl: ${scl_pin} + sda: ${sda_pin} + +pcf8574: + - id: pcf8574_hub + address: 0x21 + pcf8575: false + +binary_sensor: + - platform: gpio + id: pcf8574_binary_sensor + name: PCF Binary Sensor + pin: + pcf8574: pcf8574_hub + number: 1 + mode: INPUT + inverted: true + +output: + - platform: gpio + id: pcf8574_output + pin: + pcf8574: pcf8574_hub + number: 0 + mode: OUTPUT + inverted: false diff --git a/tests/components/pcf8574/test.esp32-ard.yaml b/tests/components/pcf8574/test.esp32-ard.yaml index aeed55f4fe..63c3bd6afd 100644 --- a/tests/components/pcf8574/test.esp32-ard.yaml +++ b/tests/components/pcf8574/test.esp32-ard.yaml @@ -1,28 +1,5 @@ -i2c: - - id: i2c_pcf8563 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -pcf8574: - - id: pcf8574_hub - address: 0x21 - pcf8575: false - -binary_sensor: - - platform: gpio - id: pcf8574_binary_sensor - name: PCF Binary Sensor - pin: - pcf8574: pcf8574_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: pcf8574_output - pin: - pcf8574: pcf8574_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pcf8574/test.esp32-c3-ard.yaml b/tests/components/pcf8574/test.esp32-c3-ard.yaml index 551e425892..ee2c29ca4e 100644 --- a/tests/components/pcf8574/test.esp32-c3-ard.yaml +++ b/tests/components/pcf8574/test.esp32-c3-ard.yaml @@ -1,28 +1,5 @@ -i2c: - - id: i2c_pcf8563 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pcf8574: - - id: pcf8574_hub - address: 0x21 - pcf8575: false - -binary_sensor: - - platform: gpio - id: pcf8574_binary_sensor - name: PCF Binary Sensor - pin: - pcf8574: pcf8574_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: pcf8574_output - pin: - pcf8574: pcf8574_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pcf8574/test.esp32-c3-idf.yaml b/tests/components/pcf8574/test.esp32-c3-idf.yaml index 551e425892..ee2c29ca4e 100644 --- a/tests/components/pcf8574/test.esp32-c3-idf.yaml +++ b/tests/components/pcf8574/test.esp32-c3-idf.yaml @@ -1,28 +1,5 @@ -i2c: - - id: i2c_pcf8563 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pcf8574: - - id: pcf8574_hub - address: 0x21 - pcf8575: false - -binary_sensor: - - platform: gpio - id: pcf8574_binary_sensor - name: PCF Binary Sensor - pin: - pcf8574: pcf8574_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: pcf8574_output - pin: - pcf8574: pcf8574_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pcf8574/test.esp32-idf.yaml b/tests/components/pcf8574/test.esp32-idf.yaml index aeed55f4fe..63c3bd6afd 100644 --- a/tests/components/pcf8574/test.esp32-idf.yaml +++ b/tests/components/pcf8574/test.esp32-idf.yaml @@ -1,28 +1,5 @@ -i2c: - - id: i2c_pcf8563 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -pcf8574: - - id: pcf8574_hub - address: 0x21 - pcf8575: false - -binary_sensor: - - platform: gpio - id: pcf8574_binary_sensor - name: PCF Binary Sensor - pin: - pcf8574: pcf8574_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: pcf8574_output - pin: - pcf8574: pcf8574_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pcf8574/test.esp8266-ard.yaml b/tests/components/pcf8574/test.esp8266-ard.yaml index 551e425892..ee2c29ca4e 100644 --- a/tests/components/pcf8574/test.esp8266-ard.yaml +++ b/tests/components/pcf8574/test.esp8266-ard.yaml @@ -1,28 +1,5 @@ -i2c: - - id: i2c_pcf8563 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pcf8574: - - id: pcf8574_hub - address: 0x21 - pcf8575: false - -binary_sensor: - - platform: gpio - id: pcf8574_binary_sensor - name: PCF Binary Sensor - pin: - pcf8574: pcf8574_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: pcf8574_output - pin: - pcf8574: pcf8574_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pcf8574/test.rp2040-ard.yaml b/tests/components/pcf8574/test.rp2040-ard.yaml index 551e425892..ee2c29ca4e 100644 --- a/tests/components/pcf8574/test.rp2040-ard.yaml +++ b/tests/components/pcf8574/test.rp2040-ard.yaml @@ -1,28 +1,5 @@ -i2c: - - id: i2c_pcf8563 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pcf8574: - - id: pcf8574_hub - address: 0x21 - pcf8575: false - -binary_sensor: - - platform: gpio - id: pcf8574_binary_sensor - name: PCF Binary Sensor - pin: - pcf8574: pcf8574_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: pcf8574_output - pin: - pcf8574: pcf8574_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/pipsolar/common.yaml b/tests/components/pipsolar/common.yaml new file mode 100644 index 0000000000..64e2c0476d --- /dev/null +++ b/tests/components/pipsolar/common.yaml @@ -0,0 +1,249 @@ +esphome: + on_boot: + then: + - output.pipsolar.set_level: + id: inverter0_battery_recharge_voltage_out + value: 48.0 + +uart: + - id: uart_pipsolar + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 115200 + +pipsolar: + id: inverter0 + +binary_sensor: + - platform: pipsolar + pipsolar_id: inverter0 + add_sbu_priority_version: + id: inverter0_add_sbu_priority_version + name: inverter0_add_sbu_priority_version + configuration_status: + id: inverter0_configuration_status + name: inverter0_configuration_status + scc_firmware_version: + id: inverter0_scc_firmware_version + name: inverter0_scc_firmware_version + load_status: + id: inverter0_load_status + name: inverter0_load_status + battery_voltage_to_steady_while_charging: + id: inverter0_battery_voltage_to_steady_while_charging + name: inverter0_battery_voltage_to_steady_while_charging + charging_status: + id: inverter0_charging_status + name: inverter0_charging_status + scc_charging_status: + id: inverter0_scc_charging_status + name: inverter0_scc_charging_status + ac_charging_status: + id: inverter0_ac_charging_status + name: inverter0_ac_charging_status + charging_to_floating_mode: + id: inverter0_charging_to_floating_mode + name: inverter0_charging_to_floating_mode + switch_on: + id: inverter0_switch_on + name: inverter0_switch_on + dustproof_installed: + id: inverter0_dustproof_installed + name: inverter0_dustproof_installed + silence_buzzer_open_buzzer: + id: inverter0_silence_buzzer_open_buzzer + name: inverter0_silence_buzzer_open_buzzer + overload_bypass_function: + id: inverter0_overload_bypass_function + name: inverter0_overload_bypass_function + lcd_escape_to_default: + id: inverter0_lcd_escape_to_default + name: inverter0_lcd_escape_to_default + overload_restart_function: + id: inverter0_overload_restart_function + name: inverter0_overload_restart_function + over_temperature_restart_function: + id: inverter0_over_temperature_restart_function + name: inverter0_over_temperature_restart_function + backlight_on: + id: inverter0_backlight_on + name: inverter0_backlight_on + +output: + - platform: pipsolar + pipsolar_id: inverter0 + battery_recharge_voltage: + id: inverter0_battery_recharge_voltage_out + +sensor: + - platform: pipsolar + pipsolar_id: inverter0 + grid_rating_voltage: + id: inverter0_grid_rating_voltage + name: inverter0_grid_rating_voltage + grid_rating_current: + id: inverter0_grid_rating_current + name: inverter0_grid_rating_current + ac_output_rating_voltage: + id: inverter0_ac_output_rating_voltage + name: inverter0_ac_output_rating_voltage + ac_output_rating_frequency: + id: inverter0_ac_output_rating_frequency + name: inverter0_ac_output_rating_frequency + ac_output_rating_current: + id: inverter0_ac_output_rating_current + name: inverter0_ac_output_rating_current + ac_output_rating_apparent_power: + id: inverter0_ac_output_rating_apparent_power + name: inverter0_ac_output_rating_apparent_power + ac_output_rating_active_power: + id: inverter0_ac_output_rating_active_power + name: inverter0_ac_output_rating_active_power + battery_rating_voltage: + id: inverter0_battery_rating_voltage + name: inverter0_battery_rating_voltage + battery_recharge_voltage: + id: inverter0_battery_recharge_voltage + name: inverter0_battery_recharge_voltage + battery_under_voltage: + id: inverter0_battery_under_voltage + name: inverter0_battery_under_voltage + battery_bulk_voltage: + id: inverter0_battery_bulk_voltage + name: inverter0_battery_bulk_voltage + battery_float_voltage: + id: inverter0_battery_float_voltage + name: inverter0_battery_float_voltage + battery_type: + id: inverter0_battery_type + name: inverter0_battery_type + current_max_ac_charging_current: + id: inverter0_current_max_ac_charging_current + name: inverter0_current_max_ac_charging_current + current_max_charging_current: + id: inverter0_current_max_charging_current + name: inverter0_current_max_charging_current + input_voltage_range: + id: inverter0_input_voltage_range + name: inverter0_input_voltage_range + output_source_priority: + id: inverter0_output_source_priority + name: inverter0_output_source_priority + charger_source_priority: + id: inverter0_charger_source_priority + name: inverter0_charger_source_priority + parallel_max_num: + id: inverter0_parallel_max_num + name: inverter0_parallel_max_num + machine_type: + id: inverter0_machine_type + name: inverter0_machine_type + topology: + id: inverter0_topology + name: inverter0_topology + output_mode: + id: inverter0_output_mode + name: inverter0_output_mode + battery_redischarge_voltage: + id: inverter0_battery_redischarge_voltage + name: inverter0_battery_redischarge_voltage + pv_ok_condition_for_parallel: + id: inverter0_pv_ok_condition_for_parallel + name: inverter0_pv_ok_condition_for_parallel + pv_power_balance: + id: inverter0_pv_power_balance + name: inverter0_pv_power_balance + grid_voltage: + id: inverter0_grid_voltage + name: inverter0_grid_voltage + grid_frequency: + id: inverter0_grid_frequency + name: inverter0_grid_frequency + ac_output_voltage: + id: inverter0_ac_output_voltage + name: inverter0_ac_output_voltage + ac_output_frequency: + id: inverter0_ac_output_frequency + name: inverter0_ac_output_frequency + ac_output_apparent_power: + id: inverter0_ac_output_apparent_power + name: inverter0_ac_output_apparent_power + ac_output_active_power: + id: inverter0_ac_output_active_power + name: inverter0_ac_output_active_power + output_load_percent: + id: inverter0_output_load_percent + name: inverter0_output_load_percent + bus_voltage: + id: inverter0_bus_voltage + name: inverter0_bus_voltage + battery_voltage: + id: inverter0_battery_voltage + name: inverter0_battery_voltage + battery_charging_current: + id: inverter0_battery_charging_current + name: inverter0_battery_charging_current + battery_capacity_percent: + id: inverter0_battery_capacity_percent + name: inverter0_battery_capacity_percent + inverter_heat_sink_temperature: + id: inverter0_inverter_heat_sink_temperature + name: inverter0_inverter_heat_sink_temperature + pv_input_current_for_battery: + id: inverter0_pv_input_current_for_battery + name: inverter0_pv_input_current_for_battery + pv_input_voltage: + id: inverter0_pv_input_voltage + name: inverter0_pv_input_voltage + battery_voltage_scc: + id: inverter0_battery_voltage_scc + name: inverter0_battery_voltage_scc + battery_discharge_current: + id: inverter0_battery_discharge_current + name: inverter0_battery_discharge_current + battery_voltage_offset_for_fans_on: + id: inverter0_battery_voltage_offset_for_fans_on + name: inverter0_battery_voltage_offset_for_fans_on + eeprom_version: + id: inverter0_eeprom_version + name: inverter0_eeprom_version + pv_charging_power: + id: inverter0_pv_charging_power + name: inverter0_pv_charging_power + +switch: + - platform: pipsolar + pipsolar_id: inverter0 + output_source_priority_utility: + name: inverter0_output_source_priority_utility + output_source_priority_solar: + name: inverter0_output_source_priority_solar + output_source_priority_battery: + name: inverter0_output_source_priority_battery + output_source_priority_hybrid: + name: inverter0_output_source_priority_hybrid + input_voltage_range: + name: inverter0_input_voltage_range + pv_ok_condition_for_parallel: + name: inverter0_pv_ok_condition_for_parallel + pv_power_balance: + name: inverter0_pv_power_balance + +text_sensor: + - platform: pipsolar + pipsolar_id: inverter0 + device_mode: + id: inverter0_device_mode + name: inverter0_device_mode + last_qpigs: + id: inverter0_last_qpigs + name: inverter0_last_qpigs + last_qpiri: + id: inverter0_last_qpiri + name: inverter0_last_qpiri + last_qmod: + id: inverter0_last_qmod + name: inverter0_last_qmod + last_qflag: + id: inverter0_last_qflag + name: inverter0_last_qflag diff --git a/tests/components/pipsolar/test.esp32-ard.yaml b/tests/components/pipsolar/test.esp32-ard.yaml index b7a7e0cbd9..f486544afa 100644 --- a/tests/components/pipsolar/test.esp32-ard.yaml +++ b/tests/components/pipsolar/test.esp32-ard.yaml @@ -1,249 +1,5 @@ -esphome: - on_boot: - then: - - output.pipsolar.set_level: - id: inverter0_battery_recharge_voltage_out - value: 48.0 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -uart: - - id: uart_pipsolar - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 - -pipsolar: - id: inverter0 - -binary_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - add_sbu_priority_version: - id: inverter0_add_sbu_priority_version - name: inverter0_add_sbu_priority_version - configuration_status: - id: inverter0_configuration_status - name: inverter0_configuration_status - scc_firmware_version: - id: inverter0_scc_firmware_version - name: inverter0_scc_firmware_version - load_status: - id: inverter0_load_status - name: inverter0_load_status - battery_voltage_to_steady_while_charging: - id: inverter0_battery_voltage_to_steady_while_charging - name: inverter0_battery_voltage_to_steady_while_charging - charging_status: - id: inverter0_charging_status - name: inverter0_charging_status - scc_charging_status: - id: inverter0_scc_charging_status - name: inverter0_scc_charging_status - ac_charging_status: - id: inverter0_ac_charging_status - name: inverter0_ac_charging_status - charging_to_floating_mode: - id: inverter0_charging_to_floating_mode - name: inverter0_charging_to_floating_mode - switch_on: - id: inverter0_switch_on - name: inverter0_switch_on - dustproof_installed: - id: inverter0_dustproof_installed - name: inverter0_dustproof_installed - silence_buzzer_open_buzzer: - id: inverter0_silence_buzzer_open_buzzer - name: inverter0_silence_buzzer_open_buzzer - overload_bypass_function: - id: inverter0_overload_bypass_function - name: inverter0_overload_bypass_function - lcd_escape_to_default: - id: inverter0_lcd_escape_to_default - name: inverter0_lcd_escape_to_default - overload_restart_function: - id: inverter0_overload_restart_function - name: inverter0_overload_restart_function - over_temperature_restart_function: - id: inverter0_over_temperature_restart_function - name: inverter0_over_temperature_restart_function - backlight_on: - id: inverter0_backlight_on - name: inverter0_backlight_on - -output: - - platform: pipsolar - pipsolar_id: inverter0 - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage_out - -sensor: - - platform: pipsolar - pipsolar_id: inverter0 - grid_rating_voltage: - id: inverter0_grid_rating_voltage - name: inverter0_grid_rating_voltage - grid_rating_current: - id: inverter0_grid_rating_current - name: inverter0_grid_rating_current - ac_output_rating_voltage: - id: inverter0_ac_output_rating_voltage - name: inverter0_ac_output_rating_voltage - ac_output_rating_frequency: - id: inverter0_ac_output_rating_frequency - name: inverter0_ac_output_rating_frequency - ac_output_rating_current: - id: inverter0_ac_output_rating_current - name: inverter0_ac_output_rating_current - ac_output_rating_apparent_power: - id: inverter0_ac_output_rating_apparent_power - name: inverter0_ac_output_rating_apparent_power - ac_output_rating_active_power: - id: inverter0_ac_output_rating_active_power - name: inverter0_ac_output_rating_active_power - battery_rating_voltage: - id: inverter0_battery_rating_voltage - name: inverter0_battery_rating_voltage - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage - name: inverter0_battery_recharge_voltage - battery_under_voltage: - id: inverter0_battery_under_voltage - name: inverter0_battery_under_voltage - battery_bulk_voltage: - id: inverter0_battery_bulk_voltage - name: inverter0_battery_bulk_voltage - battery_float_voltage: - id: inverter0_battery_float_voltage - name: inverter0_battery_float_voltage - battery_type: - id: inverter0_battery_type - name: inverter0_battery_type - current_max_ac_charging_current: - id: inverter0_current_max_ac_charging_current - name: inverter0_current_max_ac_charging_current - current_max_charging_current: - id: inverter0_current_max_charging_current - name: inverter0_current_max_charging_current - input_voltage_range: - id: inverter0_input_voltage_range - name: inverter0_input_voltage_range - output_source_priority: - id: inverter0_output_source_priority - name: inverter0_output_source_priority - charger_source_priority: - id: inverter0_charger_source_priority - name: inverter0_charger_source_priority - parallel_max_num: - id: inverter0_parallel_max_num - name: inverter0_parallel_max_num - machine_type: - id: inverter0_machine_type - name: inverter0_machine_type - topology: - id: inverter0_topology - name: inverter0_topology - output_mode: - id: inverter0_output_mode - name: inverter0_output_mode - battery_redischarge_voltage: - id: inverter0_battery_redischarge_voltage - name: inverter0_battery_redischarge_voltage - pv_ok_condition_for_parallel: - id: inverter0_pv_ok_condition_for_parallel - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - id: inverter0_pv_power_balance - name: inverter0_pv_power_balance - grid_voltage: - id: inverter0_grid_voltage - name: inverter0_grid_voltage - grid_frequency: - id: inverter0_grid_frequency - name: inverter0_grid_frequency - ac_output_voltage: - id: inverter0_ac_output_voltage - name: inverter0_ac_output_voltage - ac_output_frequency: - id: inverter0_ac_output_frequency - name: inverter0_ac_output_frequency - ac_output_apparent_power: - id: inverter0_ac_output_apparent_power - name: inverter0_ac_output_apparent_power - ac_output_active_power: - id: inverter0_ac_output_active_power - name: inverter0_ac_output_active_power - output_load_percent: - id: inverter0_output_load_percent - name: inverter0_output_load_percent - bus_voltage: - id: inverter0_bus_voltage - name: inverter0_bus_voltage - battery_voltage: - id: inverter0_battery_voltage - name: inverter0_battery_voltage - battery_charging_current: - id: inverter0_battery_charging_current - name: inverter0_battery_charging_current - battery_capacity_percent: - id: inverter0_battery_capacity_percent - name: inverter0_battery_capacity_percent - inverter_heat_sink_temperature: - id: inverter0_inverter_heat_sink_temperature - name: inverter0_inverter_heat_sink_temperature - pv_input_current_for_battery: - id: inverter0_pv_input_current_for_battery - name: inverter0_pv_input_current_for_battery - pv_input_voltage: - id: inverter0_pv_input_voltage - name: inverter0_pv_input_voltage - battery_voltage_scc: - id: inverter0_battery_voltage_scc - name: inverter0_battery_voltage_scc - battery_discharge_current: - id: inverter0_battery_discharge_current - name: inverter0_battery_discharge_current - battery_voltage_offset_for_fans_on: - id: inverter0_battery_voltage_offset_for_fans_on - name: inverter0_battery_voltage_offset_for_fans_on - eeprom_version: - id: inverter0_eeprom_version - name: inverter0_eeprom_version - pv_charging_power: - id: inverter0_pv_charging_power - name: inverter0_pv_charging_power - -switch: - - platform: pipsolar - pipsolar_id: inverter0 - output_source_priority_utility: - name: inverter0_output_source_priority_utility - output_source_priority_solar: - name: inverter0_output_source_priority_solar - output_source_priority_battery: - name: inverter0_output_source_priority_battery - output_source_priority_hybrid: - name: inverter0_output_source_priority_hybrid - input_voltage_range: - name: inverter0_input_voltage_range - pv_ok_condition_for_parallel: - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - name: inverter0_pv_power_balance - -text_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - device_mode: - id: inverter0_device_mode - name: inverter0_device_mode - last_qpigs: - id: inverter0_last_qpigs - name: inverter0_last_qpigs - last_qpiri: - id: inverter0_last_qpiri - name: inverter0_last_qpiri - last_qmod: - id: inverter0_last_qmod - name: inverter0_last_qmod - last_qflag: - id: inverter0_last_qflag - name: inverter0_last_qflag +<<: !include common.yaml diff --git a/tests/components/pipsolar/test.esp32-c3-ard.yaml b/tests/components/pipsolar/test.esp32-c3-ard.yaml index 83d7070669..b516342f3b 100644 --- a/tests/components/pipsolar/test.esp32-c3-ard.yaml +++ b/tests/components/pipsolar/test.esp32-c3-ard.yaml @@ -1,249 +1,5 @@ -esphome: - on_boot: - then: - - output.pipsolar.set_level: - id: inverter0_battery_recharge_voltage_out - value: 48.0 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pipsolar - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 - -pipsolar: - id: inverter0 - -binary_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - add_sbu_priority_version: - id: inverter0_add_sbu_priority_version - name: inverter0_add_sbu_priority_version - configuration_status: - id: inverter0_configuration_status - name: inverter0_configuration_status - scc_firmware_version: - id: inverter0_scc_firmware_version - name: inverter0_scc_firmware_version - load_status: - id: inverter0_load_status - name: inverter0_load_status - battery_voltage_to_steady_while_charging: - id: inverter0_battery_voltage_to_steady_while_charging - name: inverter0_battery_voltage_to_steady_while_charging - charging_status: - id: inverter0_charging_status - name: inverter0_charging_status - scc_charging_status: - id: inverter0_scc_charging_status - name: inverter0_scc_charging_status - ac_charging_status: - id: inverter0_ac_charging_status - name: inverter0_ac_charging_status - charging_to_floating_mode: - id: inverter0_charging_to_floating_mode - name: inverter0_charging_to_floating_mode - switch_on: - id: inverter0_switch_on - name: inverter0_switch_on - dustproof_installed: - id: inverter0_dustproof_installed - name: inverter0_dustproof_installed - silence_buzzer_open_buzzer: - id: inverter0_silence_buzzer_open_buzzer - name: inverter0_silence_buzzer_open_buzzer - overload_bypass_function: - id: inverter0_overload_bypass_function - name: inverter0_overload_bypass_function - lcd_escape_to_default: - id: inverter0_lcd_escape_to_default - name: inverter0_lcd_escape_to_default - overload_restart_function: - id: inverter0_overload_restart_function - name: inverter0_overload_restart_function - over_temperature_restart_function: - id: inverter0_over_temperature_restart_function - name: inverter0_over_temperature_restart_function - backlight_on: - id: inverter0_backlight_on - name: inverter0_backlight_on - -output: - - platform: pipsolar - pipsolar_id: inverter0 - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage_out - -sensor: - - platform: pipsolar - pipsolar_id: inverter0 - grid_rating_voltage: - id: inverter0_grid_rating_voltage - name: inverter0_grid_rating_voltage - grid_rating_current: - id: inverter0_grid_rating_current - name: inverter0_grid_rating_current - ac_output_rating_voltage: - id: inverter0_ac_output_rating_voltage - name: inverter0_ac_output_rating_voltage - ac_output_rating_frequency: - id: inverter0_ac_output_rating_frequency - name: inverter0_ac_output_rating_frequency - ac_output_rating_current: - id: inverter0_ac_output_rating_current - name: inverter0_ac_output_rating_current - ac_output_rating_apparent_power: - id: inverter0_ac_output_rating_apparent_power - name: inverter0_ac_output_rating_apparent_power - ac_output_rating_active_power: - id: inverter0_ac_output_rating_active_power - name: inverter0_ac_output_rating_active_power - battery_rating_voltage: - id: inverter0_battery_rating_voltage - name: inverter0_battery_rating_voltage - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage - name: inverter0_battery_recharge_voltage - battery_under_voltage: - id: inverter0_battery_under_voltage - name: inverter0_battery_under_voltage - battery_bulk_voltage: - id: inverter0_battery_bulk_voltage - name: inverter0_battery_bulk_voltage - battery_float_voltage: - id: inverter0_battery_float_voltage - name: inverter0_battery_float_voltage - battery_type: - id: inverter0_battery_type - name: inverter0_battery_type - current_max_ac_charging_current: - id: inverter0_current_max_ac_charging_current - name: inverter0_current_max_ac_charging_current - current_max_charging_current: - id: inverter0_current_max_charging_current - name: inverter0_current_max_charging_current - input_voltage_range: - id: inverter0_input_voltage_range - name: inverter0_input_voltage_range - output_source_priority: - id: inverter0_output_source_priority - name: inverter0_output_source_priority - charger_source_priority: - id: inverter0_charger_source_priority - name: inverter0_charger_source_priority - parallel_max_num: - id: inverter0_parallel_max_num - name: inverter0_parallel_max_num - machine_type: - id: inverter0_machine_type - name: inverter0_machine_type - topology: - id: inverter0_topology - name: inverter0_topology - output_mode: - id: inverter0_output_mode - name: inverter0_output_mode - battery_redischarge_voltage: - id: inverter0_battery_redischarge_voltage - name: inverter0_battery_redischarge_voltage - pv_ok_condition_for_parallel: - id: inverter0_pv_ok_condition_for_parallel - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - id: inverter0_pv_power_balance - name: inverter0_pv_power_balance - grid_voltage: - id: inverter0_grid_voltage - name: inverter0_grid_voltage - grid_frequency: - id: inverter0_grid_frequency - name: inverter0_grid_frequency - ac_output_voltage: - id: inverter0_ac_output_voltage - name: inverter0_ac_output_voltage - ac_output_frequency: - id: inverter0_ac_output_frequency - name: inverter0_ac_output_frequency - ac_output_apparent_power: - id: inverter0_ac_output_apparent_power - name: inverter0_ac_output_apparent_power - ac_output_active_power: - id: inverter0_ac_output_active_power - name: inverter0_ac_output_active_power - output_load_percent: - id: inverter0_output_load_percent - name: inverter0_output_load_percent - bus_voltage: - id: inverter0_bus_voltage - name: inverter0_bus_voltage - battery_voltage: - id: inverter0_battery_voltage - name: inverter0_battery_voltage - battery_charging_current: - id: inverter0_battery_charging_current - name: inverter0_battery_charging_current - battery_capacity_percent: - id: inverter0_battery_capacity_percent - name: inverter0_battery_capacity_percent - inverter_heat_sink_temperature: - id: inverter0_inverter_heat_sink_temperature - name: inverter0_inverter_heat_sink_temperature - pv_input_current_for_battery: - id: inverter0_pv_input_current_for_battery - name: inverter0_pv_input_current_for_battery - pv_input_voltage: - id: inverter0_pv_input_voltage - name: inverter0_pv_input_voltage - battery_voltage_scc: - id: inverter0_battery_voltage_scc - name: inverter0_battery_voltage_scc - battery_discharge_current: - id: inverter0_battery_discharge_current - name: inverter0_battery_discharge_current - battery_voltage_offset_for_fans_on: - id: inverter0_battery_voltage_offset_for_fans_on - name: inverter0_battery_voltage_offset_for_fans_on - eeprom_version: - id: inverter0_eeprom_version - name: inverter0_eeprom_version - pv_charging_power: - id: inverter0_pv_charging_power - name: inverter0_pv_charging_power - -switch: - - platform: pipsolar - pipsolar_id: inverter0 - output_source_priority_utility: - name: inverter0_output_source_priority_utility - output_source_priority_solar: - name: inverter0_output_source_priority_solar - output_source_priority_battery: - name: inverter0_output_source_priority_battery - output_source_priority_hybrid: - name: inverter0_output_source_priority_hybrid - input_voltage_range: - name: inverter0_input_voltage_range - pv_ok_condition_for_parallel: - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - name: inverter0_pv_power_balance - -text_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - device_mode: - id: inverter0_device_mode - name: inverter0_device_mode - last_qpigs: - id: inverter0_last_qpigs - name: inverter0_last_qpigs - last_qpiri: - id: inverter0_last_qpiri - name: inverter0_last_qpiri - last_qmod: - id: inverter0_last_qmod - name: inverter0_last_qmod - last_qflag: - id: inverter0_last_qflag - name: inverter0_last_qflag +<<: !include common.yaml diff --git a/tests/components/pipsolar/test.esp32-c3-idf.yaml b/tests/components/pipsolar/test.esp32-c3-idf.yaml index 83d7070669..b516342f3b 100644 --- a/tests/components/pipsolar/test.esp32-c3-idf.yaml +++ b/tests/components/pipsolar/test.esp32-c3-idf.yaml @@ -1,249 +1,5 @@ -esphome: - on_boot: - then: - - output.pipsolar.set_level: - id: inverter0_battery_recharge_voltage_out - value: 48.0 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pipsolar - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 - -pipsolar: - id: inverter0 - -binary_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - add_sbu_priority_version: - id: inverter0_add_sbu_priority_version - name: inverter0_add_sbu_priority_version - configuration_status: - id: inverter0_configuration_status - name: inverter0_configuration_status - scc_firmware_version: - id: inverter0_scc_firmware_version - name: inverter0_scc_firmware_version - load_status: - id: inverter0_load_status - name: inverter0_load_status - battery_voltage_to_steady_while_charging: - id: inverter0_battery_voltage_to_steady_while_charging - name: inverter0_battery_voltage_to_steady_while_charging - charging_status: - id: inverter0_charging_status - name: inverter0_charging_status - scc_charging_status: - id: inverter0_scc_charging_status - name: inverter0_scc_charging_status - ac_charging_status: - id: inverter0_ac_charging_status - name: inverter0_ac_charging_status - charging_to_floating_mode: - id: inverter0_charging_to_floating_mode - name: inverter0_charging_to_floating_mode - switch_on: - id: inverter0_switch_on - name: inverter0_switch_on - dustproof_installed: - id: inverter0_dustproof_installed - name: inverter0_dustproof_installed - silence_buzzer_open_buzzer: - id: inverter0_silence_buzzer_open_buzzer - name: inverter0_silence_buzzer_open_buzzer - overload_bypass_function: - id: inverter0_overload_bypass_function - name: inverter0_overload_bypass_function - lcd_escape_to_default: - id: inverter0_lcd_escape_to_default - name: inverter0_lcd_escape_to_default - overload_restart_function: - id: inverter0_overload_restart_function - name: inverter0_overload_restart_function - over_temperature_restart_function: - id: inverter0_over_temperature_restart_function - name: inverter0_over_temperature_restart_function - backlight_on: - id: inverter0_backlight_on - name: inverter0_backlight_on - -output: - - platform: pipsolar - pipsolar_id: inverter0 - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage_out - -sensor: - - platform: pipsolar - pipsolar_id: inverter0 - grid_rating_voltage: - id: inverter0_grid_rating_voltage - name: inverter0_grid_rating_voltage - grid_rating_current: - id: inverter0_grid_rating_current - name: inverter0_grid_rating_current - ac_output_rating_voltage: - id: inverter0_ac_output_rating_voltage - name: inverter0_ac_output_rating_voltage - ac_output_rating_frequency: - id: inverter0_ac_output_rating_frequency - name: inverter0_ac_output_rating_frequency - ac_output_rating_current: - id: inverter0_ac_output_rating_current - name: inverter0_ac_output_rating_current - ac_output_rating_apparent_power: - id: inverter0_ac_output_rating_apparent_power - name: inverter0_ac_output_rating_apparent_power - ac_output_rating_active_power: - id: inverter0_ac_output_rating_active_power - name: inverter0_ac_output_rating_active_power - battery_rating_voltage: - id: inverter0_battery_rating_voltage - name: inverter0_battery_rating_voltage - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage - name: inverter0_battery_recharge_voltage - battery_under_voltage: - id: inverter0_battery_under_voltage - name: inverter0_battery_under_voltage - battery_bulk_voltage: - id: inverter0_battery_bulk_voltage - name: inverter0_battery_bulk_voltage - battery_float_voltage: - id: inverter0_battery_float_voltage - name: inverter0_battery_float_voltage - battery_type: - id: inverter0_battery_type - name: inverter0_battery_type - current_max_ac_charging_current: - id: inverter0_current_max_ac_charging_current - name: inverter0_current_max_ac_charging_current - current_max_charging_current: - id: inverter0_current_max_charging_current - name: inverter0_current_max_charging_current - input_voltage_range: - id: inverter0_input_voltage_range - name: inverter0_input_voltage_range - output_source_priority: - id: inverter0_output_source_priority - name: inverter0_output_source_priority - charger_source_priority: - id: inverter0_charger_source_priority - name: inverter0_charger_source_priority - parallel_max_num: - id: inverter0_parallel_max_num - name: inverter0_parallel_max_num - machine_type: - id: inverter0_machine_type - name: inverter0_machine_type - topology: - id: inverter0_topology - name: inverter0_topology - output_mode: - id: inverter0_output_mode - name: inverter0_output_mode - battery_redischarge_voltage: - id: inverter0_battery_redischarge_voltage - name: inverter0_battery_redischarge_voltage - pv_ok_condition_for_parallel: - id: inverter0_pv_ok_condition_for_parallel - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - id: inverter0_pv_power_balance - name: inverter0_pv_power_balance - grid_voltage: - id: inverter0_grid_voltage - name: inverter0_grid_voltage - grid_frequency: - id: inverter0_grid_frequency - name: inverter0_grid_frequency - ac_output_voltage: - id: inverter0_ac_output_voltage - name: inverter0_ac_output_voltage - ac_output_frequency: - id: inverter0_ac_output_frequency - name: inverter0_ac_output_frequency - ac_output_apparent_power: - id: inverter0_ac_output_apparent_power - name: inverter0_ac_output_apparent_power - ac_output_active_power: - id: inverter0_ac_output_active_power - name: inverter0_ac_output_active_power - output_load_percent: - id: inverter0_output_load_percent - name: inverter0_output_load_percent - bus_voltage: - id: inverter0_bus_voltage - name: inverter0_bus_voltage - battery_voltage: - id: inverter0_battery_voltage - name: inverter0_battery_voltage - battery_charging_current: - id: inverter0_battery_charging_current - name: inverter0_battery_charging_current - battery_capacity_percent: - id: inverter0_battery_capacity_percent - name: inverter0_battery_capacity_percent - inverter_heat_sink_temperature: - id: inverter0_inverter_heat_sink_temperature - name: inverter0_inverter_heat_sink_temperature - pv_input_current_for_battery: - id: inverter0_pv_input_current_for_battery - name: inverter0_pv_input_current_for_battery - pv_input_voltage: - id: inverter0_pv_input_voltage - name: inverter0_pv_input_voltage - battery_voltage_scc: - id: inverter0_battery_voltage_scc - name: inverter0_battery_voltage_scc - battery_discharge_current: - id: inverter0_battery_discharge_current - name: inverter0_battery_discharge_current - battery_voltage_offset_for_fans_on: - id: inverter0_battery_voltage_offset_for_fans_on - name: inverter0_battery_voltage_offset_for_fans_on - eeprom_version: - id: inverter0_eeprom_version - name: inverter0_eeprom_version - pv_charging_power: - id: inverter0_pv_charging_power - name: inverter0_pv_charging_power - -switch: - - platform: pipsolar - pipsolar_id: inverter0 - output_source_priority_utility: - name: inverter0_output_source_priority_utility - output_source_priority_solar: - name: inverter0_output_source_priority_solar - output_source_priority_battery: - name: inverter0_output_source_priority_battery - output_source_priority_hybrid: - name: inverter0_output_source_priority_hybrid - input_voltage_range: - name: inverter0_input_voltage_range - pv_ok_condition_for_parallel: - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - name: inverter0_pv_power_balance - -text_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - device_mode: - id: inverter0_device_mode - name: inverter0_device_mode - last_qpigs: - id: inverter0_last_qpigs - name: inverter0_last_qpigs - last_qpiri: - id: inverter0_last_qpiri - name: inverter0_last_qpiri - last_qmod: - id: inverter0_last_qmod - name: inverter0_last_qmod - last_qflag: - id: inverter0_last_qflag - name: inverter0_last_qflag +<<: !include common.yaml diff --git a/tests/components/pipsolar/test.esp32-idf.yaml b/tests/components/pipsolar/test.esp32-idf.yaml index b7a7e0cbd9..f486544afa 100644 --- a/tests/components/pipsolar/test.esp32-idf.yaml +++ b/tests/components/pipsolar/test.esp32-idf.yaml @@ -1,249 +1,5 @@ -esphome: - on_boot: - then: - - output.pipsolar.set_level: - id: inverter0_battery_recharge_voltage_out - value: 48.0 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -uart: - - id: uart_pipsolar - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 - -pipsolar: - id: inverter0 - -binary_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - add_sbu_priority_version: - id: inverter0_add_sbu_priority_version - name: inverter0_add_sbu_priority_version - configuration_status: - id: inverter0_configuration_status - name: inverter0_configuration_status - scc_firmware_version: - id: inverter0_scc_firmware_version - name: inverter0_scc_firmware_version - load_status: - id: inverter0_load_status - name: inverter0_load_status - battery_voltage_to_steady_while_charging: - id: inverter0_battery_voltage_to_steady_while_charging - name: inverter0_battery_voltage_to_steady_while_charging - charging_status: - id: inverter0_charging_status - name: inverter0_charging_status - scc_charging_status: - id: inverter0_scc_charging_status - name: inverter0_scc_charging_status - ac_charging_status: - id: inverter0_ac_charging_status - name: inverter0_ac_charging_status - charging_to_floating_mode: - id: inverter0_charging_to_floating_mode - name: inverter0_charging_to_floating_mode - switch_on: - id: inverter0_switch_on - name: inverter0_switch_on - dustproof_installed: - id: inverter0_dustproof_installed - name: inverter0_dustproof_installed - silence_buzzer_open_buzzer: - id: inverter0_silence_buzzer_open_buzzer - name: inverter0_silence_buzzer_open_buzzer - overload_bypass_function: - id: inverter0_overload_bypass_function - name: inverter0_overload_bypass_function - lcd_escape_to_default: - id: inverter0_lcd_escape_to_default - name: inverter0_lcd_escape_to_default - overload_restart_function: - id: inverter0_overload_restart_function - name: inverter0_overload_restart_function - over_temperature_restart_function: - id: inverter0_over_temperature_restart_function - name: inverter0_over_temperature_restart_function - backlight_on: - id: inverter0_backlight_on - name: inverter0_backlight_on - -output: - - platform: pipsolar - pipsolar_id: inverter0 - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage_out - -sensor: - - platform: pipsolar - pipsolar_id: inverter0 - grid_rating_voltage: - id: inverter0_grid_rating_voltage - name: inverter0_grid_rating_voltage - grid_rating_current: - id: inverter0_grid_rating_current - name: inverter0_grid_rating_current - ac_output_rating_voltage: - id: inverter0_ac_output_rating_voltage - name: inverter0_ac_output_rating_voltage - ac_output_rating_frequency: - id: inverter0_ac_output_rating_frequency - name: inverter0_ac_output_rating_frequency - ac_output_rating_current: - id: inverter0_ac_output_rating_current - name: inverter0_ac_output_rating_current - ac_output_rating_apparent_power: - id: inverter0_ac_output_rating_apparent_power - name: inverter0_ac_output_rating_apparent_power - ac_output_rating_active_power: - id: inverter0_ac_output_rating_active_power - name: inverter0_ac_output_rating_active_power - battery_rating_voltage: - id: inverter0_battery_rating_voltage - name: inverter0_battery_rating_voltage - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage - name: inverter0_battery_recharge_voltage - battery_under_voltage: - id: inverter0_battery_under_voltage - name: inverter0_battery_under_voltage - battery_bulk_voltage: - id: inverter0_battery_bulk_voltage - name: inverter0_battery_bulk_voltage - battery_float_voltage: - id: inverter0_battery_float_voltage - name: inverter0_battery_float_voltage - battery_type: - id: inverter0_battery_type - name: inverter0_battery_type - current_max_ac_charging_current: - id: inverter0_current_max_ac_charging_current - name: inverter0_current_max_ac_charging_current - current_max_charging_current: - id: inverter0_current_max_charging_current - name: inverter0_current_max_charging_current - input_voltage_range: - id: inverter0_input_voltage_range - name: inverter0_input_voltage_range - output_source_priority: - id: inverter0_output_source_priority - name: inverter0_output_source_priority - charger_source_priority: - id: inverter0_charger_source_priority - name: inverter0_charger_source_priority - parallel_max_num: - id: inverter0_parallel_max_num - name: inverter0_parallel_max_num - machine_type: - id: inverter0_machine_type - name: inverter0_machine_type - topology: - id: inverter0_topology - name: inverter0_topology - output_mode: - id: inverter0_output_mode - name: inverter0_output_mode - battery_redischarge_voltage: - id: inverter0_battery_redischarge_voltage - name: inverter0_battery_redischarge_voltage - pv_ok_condition_for_parallel: - id: inverter0_pv_ok_condition_for_parallel - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - id: inverter0_pv_power_balance - name: inverter0_pv_power_balance - grid_voltage: - id: inverter0_grid_voltage - name: inverter0_grid_voltage - grid_frequency: - id: inverter0_grid_frequency - name: inverter0_grid_frequency - ac_output_voltage: - id: inverter0_ac_output_voltage - name: inverter0_ac_output_voltage - ac_output_frequency: - id: inverter0_ac_output_frequency - name: inverter0_ac_output_frequency - ac_output_apparent_power: - id: inverter0_ac_output_apparent_power - name: inverter0_ac_output_apparent_power - ac_output_active_power: - id: inverter0_ac_output_active_power - name: inverter0_ac_output_active_power - output_load_percent: - id: inverter0_output_load_percent - name: inverter0_output_load_percent - bus_voltage: - id: inverter0_bus_voltage - name: inverter0_bus_voltage - battery_voltage: - id: inverter0_battery_voltage - name: inverter0_battery_voltage - battery_charging_current: - id: inverter0_battery_charging_current - name: inverter0_battery_charging_current - battery_capacity_percent: - id: inverter0_battery_capacity_percent - name: inverter0_battery_capacity_percent - inverter_heat_sink_temperature: - id: inverter0_inverter_heat_sink_temperature - name: inverter0_inverter_heat_sink_temperature - pv_input_current_for_battery: - id: inverter0_pv_input_current_for_battery - name: inverter0_pv_input_current_for_battery - pv_input_voltage: - id: inverter0_pv_input_voltage - name: inverter0_pv_input_voltage - battery_voltage_scc: - id: inverter0_battery_voltage_scc - name: inverter0_battery_voltage_scc - battery_discharge_current: - id: inverter0_battery_discharge_current - name: inverter0_battery_discharge_current - battery_voltage_offset_for_fans_on: - id: inverter0_battery_voltage_offset_for_fans_on - name: inverter0_battery_voltage_offset_for_fans_on - eeprom_version: - id: inverter0_eeprom_version - name: inverter0_eeprom_version - pv_charging_power: - id: inverter0_pv_charging_power - name: inverter0_pv_charging_power - -switch: - - platform: pipsolar - pipsolar_id: inverter0 - output_source_priority_utility: - name: inverter0_output_source_priority_utility - output_source_priority_solar: - name: inverter0_output_source_priority_solar - output_source_priority_battery: - name: inverter0_output_source_priority_battery - output_source_priority_hybrid: - name: inverter0_output_source_priority_hybrid - input_voltage_range: - name: inverter0_input_voltage_range - pv_ok_condition_for_parallel: - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - name: inverter0_pv_power_balance - -text_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - device_mode: - id: inverter0_device_mode - name: inverter0_device_mode - last_qpigs: - id: inverter0_last_qpigs - name: inverter0_last_qpigs - last_qpiri: - id: inverter0_last_qpiri - name: inverter0_last_qpiri - last_qmod: - id: inverter0_last_qmod - name: inverter0_last_qmod - last_qflag: - id: inverter0_last_qflag - name: inverter0_last_qflag +<<: !include common.yaml diff --git a/tests/components/pipsolar/test.esp8266-ard.yaml b/tests/components/pipsolar/test.esp8266-ard.yaml index 83d7070669..b516342f3b 100644 --- a/tests/components/pipsolar/test.esp8266-ard.yaml +++ b/tests/components/pipsolar/test.esp8266-ard.yaml @@ -1,249 +1,5 @@ -esphome: - on_boot: - then: - - output.pipsolar.set_level: - id: inverter0_battery_recharge_voltage_out - value: 48.0 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pipsolar - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 - -pipsolar: - id: inverter0 - -binary_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - add_sbu_priority_version: - id: inverter0_add_sbu_priority_version - name: inverter0_add_sbu_priority_version - configuration_status: - id: inverter0_configuration_status - name: inverter0_configuration_status - scc_firmware_version: - id: inverter0_scc_firmware_version - name: inverter0_scc_firmware_version - load_status: - id: inverter0_load_status - name: inverter0_load_status - battery_voltage_to_steady_while_charging: - id: inverter0_battery_voltage_to_steady_while_charging - name: inverter0_battery_voltage_to_steady_while_charging - charging_status: - id: inverter0_charging_status - name: inverter0_charging_status - scc_charging_status: - id: inverter0_scc_charging_status - name: inverter0_scc_charging_status - ac_charging_status: - id: inverter0_ac_charging_status - name: inverter0_ac_charging_status - charging_to_floating_mode: - id: inverter0_charging_to_floating_mode - name: inverter0_charging_to_floating_mode - switch_on: - id: inverter0_switch_on - name: inverter0_switch_on - dustproof_installed: - id: inverter0_dustproof_installed - name: inverter0_dustproof_installed - silence_buzzer_open_buzzer: - id: inverter0_silence_buzzer_open_buzzer - name: inverter0_silence_buzzer_open_buzzer - overload_bypass_function: - id: inverter0_overload_bypass_function - name: inverter0_overload_bypass_function - lcd_escape_to_default: - id: inverter0_lcd_escape_to_default - name: inverter0_lcd_escape_to_default - overload_restart_function: - id: inverter0_overload_restart_function - name: inverter0_overload_restart_function - over_temperature_restart_function: - id: inverter0_over_temperature_restart_function - name: inverter0_over_temperature_restart_function - backlight_on: - id: inverter0_backlight_on - name: inverter0_backlight_on - -output: - - platform: pipsolar - pipsolar_id: inverter0 - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage_out - -sensor: - - platform: pipsolar - pipsolar_id: inverter0 - grid_rating_voltage: - id: inverter0_grid_rating_voltage - name: inverter0_grid_rating_voltage - grid_rating_current: - id: inverter0_grid_rating_current - name: inverter0_grid_rating_current - ac_output_rating_voltage: - id: inverter0_ac_output_rating_voltage - name: inverter0_ac_output_rating_voltage - ac_output_rating_frequency: - id: inverter0_ac_output_rating_frequency - name: inverter0_ac_output_rating_frequency - ac_output_rating_current: - id: inverter0_ac_output_rating_current - name: inverter0_ac_output_rating_current - ac_output_rating_apparent_power: - id: inverter0_ac_output_rating_apparent_power - name: inverter0_ac_output_rating_apparent_power - ac_output_rating_active_power: - id: inverter0_ac_output_rating_active_power - name: inverter0_ac_output_rating_active_power - battery_rating_voltage: - id: inverter0_battery_rating_voltage - name: inverter0_battery_rating_voltage - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage - name: inverter0_battery_recharge_voltage - battery_under_voltage: - id: inverter0_battery_under_voltage - name: inverter0_battery_under_voltage - battery_bulk_voltage: - id: inverter0_battery_bulk_voltage - name: inverter0_battery_bulk_voltage - battery_float_voltage: - id: inverter0_battery_float_voltage - name: inverter0_battery_float_voltage - battery_type: - id: inverter0_battery_type - name: inverter0_battery_type - current_max_ac_charging_current: - id: inverter0_current_max_ac_charging_current - name: inverter0_current_max_ac_charging_current - current_max_charging_current: - id: inverter0_current_max_charging_current - name: inverter0_current_max_charging_current - input_voltage_range: - id: inverter0_input_voltage_range - name: inverter0_input_voltage_range - output_source_priority: - id: inverter0_output_source_priority - name: inverter0_output_source_priority - charger_source_priority: - id: inverter0_charger_source_priority - name: inverter0_charger_source_priority - parallel_max_num: - id: inverter0_parallel_max_num - name: inverter0_parallel_max_num - machine_type: - id: inverter0_machine_type - name: inverter0_machine_type - topology: - id: inverter0_topology - name: inverter0_topology - output_mode: - id: inverter0_output_mode - name: inverter0_output_mode - battery_redischarge_voltage: - id: inverter0_battery_redischarge_voltage - name: inverter0_battery_redischarge_voltage - pv_ok_condition_for_parallel: - id: inverter0_pv_ok_condition_for_parallel - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - id: inverter0_pv_power_balance - name: inverter0_pv_power_balance - grid_voltage: - id: inverter0_grid_voltage - name: inverter0_grid_voltage - grid_frequency: - id: inverter0_grid_frequency - name: inverter0_grid_frequency - ac_output_voltage: - id: inverter0_ac_output_voltage - name: inverter0_ac_output_voltage - ac_output_frequency: - id: inverter0_ac_output_frequency - name: inverter0_ac_output_frequency - ac_output_apparent_power: - id: inverter0_ac_output_apparent_power - name: inverter0_ac_output_apparent_power - ac_output_active_power: - id: inverter0_ac_output_active_power - name: inverter0_ac_output_active_power - output_load_percent: - id: inverter0_output_load_percent - name: inverter0_output_load_percent - bus_voltage: - id: inverter0_bus_voltage - name: inverter0_bus_voltage - battery_voltage: - id: inverter0_battery_voltage - name: inverter0_battery_voltage - battery_charging_current: - id: inverter0_battery_charging_current - name: inverter0_battery_charging_current - battery_capacity_percent: - id: inverter0_battery_capacity_percent - name: inverter0_battery_capacity_percent - inverter_heat_sink_temperature: - id: inverter0_inverter_heat_sink_temperature - name: inverter0_inverter_heat_sink_temperature - pv_input_current_for_battery: - id: inverter0_pv_input_current_for_battery - name: inverter0_pv_input_current_for_battery - pv_input_voltage: - id: inverter0_pv_input_voltage - name: inverter0_pv_input_voltage - battery_voltage_scc: - id: inverter0_battery_voltage_scc - name: inverter0_battery_voltage_scc - battery_discharge_current: - id: inverter0_battery_discharge_current - name: inverter0_battery_discharge_current - battery_voltage_offset_for_fans_on: - id: inverter0_battery_voltage_offset_for_fans_on - name: inverter0_battery_voltage_offset_for_fans_on - eeprom_version: - id: inverter0_eeprom_version - name: inverter0_eeprom_version - pv_charging_power: - id: inverter0_pv_charging_power - name: inverter0_pv_charging_power - -switch: - - platform: pipsolar - pipsolar_id: inverter0 - output_source_priority_utility: - name: inverter0_output_source_priority_utility - output_source_priority_solar: - name: inverter0_output_source_priority_solar - output_source_priority_battery: - name: inverter0_output_source_priority_battery - output_source_priority_hybrid: - name: inverter0_output_source_priority_hybrid - input_voltage_range: - name: inverter0_input_voltage_range - pv_ok_condition_for_parallel: - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - name: inverter0_pv_power_balance - -text_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - device_mode: - id: inverter0_device_mode - name: inverter0_device_mode - last_qpigs: - id: inverter0_last_qpigs - name: inverter0_last_qpigs - last_qpiri: - id: inverter0_last_qpiri - name: inverter0_last_qpiri - last_qmod: - id: inverter0_last_qmod - name: inverter0_last_qmod - last_qflag: - id: inverter0_last_qflag - name: inverter0_last_qflag +<<: !include common.yaml diff --git a/tests/components/pipsolar/test.rp2040-ard.yaml b/tests/components/pipsolar/test.rp2040-ard.yaml index 83d7070669..b516342f3b 100644 --- a/tests/components/pipsolar/test.rp2040-ard.yaml +++ b/tests/components/pipsolar/test.rp2040-ard.yaml @@ -1,249 +1,5 @@ -esphome: - on_boot: - then: - - output.pipsolar.set_level: - id: inverter0_battery_recharge_voltage_out - value: 48.0 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pipsolar - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 - -pipsolar: - id: inverter0 - -binary_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - add_sbu_priority_version: - id: inverter0_add_sbu_priority_version - name: inverter0_add_sbu_priority_version - configuration_status: - id: inverter0_configuration_status - name: inverter0_configuration_status - scc_firmware_version: - id: inverter0_scc_firmware_version - name: inverter0_scc_firmware_version - load_status: - id: inverter0_load_status - name: inverter0_load_status - battery_voltage_to_steady_while_charging: - id: inverter0_battery_voltage_to_steady_while_charging - name: inverter0_battery_voltage_to_steady_while_charging - charging_status: - id: inverter0_charging_status - name: inverter0_charging_status - scc_charging_status: - id: inverter0_scc_charging_status - name: inverter0_scc_charging_status - ac_charging_status: - id: inverter0_ac_charging_status - name: inverter0_ac_charging_status - charging_to_floating_mode: - id: inverter0_charging_to_floating_mode - name: inverter0_charging_to_floating_mode - switch_on: - id: inverter0_switch_on - name: inverter0_switch_on - dustproof_installed: - id: inverter0_dustproof_installed - name: inverter0_dustproof_installed - silence_buzzer_open_buzzer: - id: inverter0_silence_buzzer_open_buzzer - name: inverter0_silence_buzzer_open_buzzer - overload_bypass_function: - id: inverter0_overload_bypass_function - name: inverter0_overload_bypass_function - lcd_escape_to_default: - id: inverter0_lcd_escape_to_default - name: inverter0_lcd_escape_to_default - overload_restart_function: - id: inverter0_overload_restart_function - name: inverter0_overload_restart_function - over_temperature_restart_function: - id: inverter0_over_temperature_restart_function - name: inverter0_over_temperature_restart_function - backlight_on: - id: inverter0_backlight_on - name: inverter0_backlight_on - -output: - - platform: pipsolar - pipsolar_id: inverter0 - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage_out - -sensor: - - platform: pipsolar - pipsolar_id: inverter0 - grid_rating_voltage: - id: inverter0_grid_rating_voltage - name: inverter0_grid_rating_voltage - grid_rating_current: - id: inverter0_grid_rating_current - name: inverter0_grid_rating_current - ac_output_rating_voltage: - id: inverter0_ac_output_rating_voltage - name: inverter0_ac_output_rating_voltage - ac_output_rating_frequency: - id: inverter0_ac_output_rating_frequency - name: inverter0_ac_output_rating_frequency - ac_output_rating_current: - id: inverter0_ac_output_rating_current - name: inverter0_ac_output_rating_current - ac_output_rating_apparent_power: - id: inverter0_ac_output_rating_apparent_power - name: inverter0_ac_output_rating_apparent_power - ac_output_rating_active_power: - id: inverter0_ac_output_rating_active_power - name: inverter0_ac_output_rating_active_power - battery_rating_voltage: - id: inverter0_battery_rating_voltage - name: inverter0_battery_rating_voltage - battery_recharge_voltage: - id: inverter0_battery_recharge_voltage - name: inverter0_battery_recharge_voltage - battery_under_voltage: - id: inverter0_battery_under_voltage - name: inverter0_battery_under_voltage - battery_bulk_voltage: - id: inverter0_battery_bulk_voltage - name: inverter0_battery_bulk_voltage - battery_float_voltage: - id: inverter0_battery_float_voltage - name: inverter0_battery_float_voltage - battery_type: - id: inverter0_battery_type - name: inverter0_battery_type - current_max_ac_charging_current: - id: inverter0_current_max_ac_charging_current - name: inverter0_current_max_ac_charging_current - current_max_charging_current: - id: inverter0_current_max_charging_current - name: inverter0_current_max_charging_current - input_voltage_range: - id: inverter0_input_voltage_range - name: inverter0_input_voltage_range - output_source_priority: - id: inverter0_output_source_priority - name: inverter0_output_source_priority - charger_source_priority: - id: inverter0_charger_source_priority - name: inverter0_charger_source_priority - parallel_max_num: - id: inverter0_parallel_max_num - name: inverter0_parallel_max_num - machine_type: - id: inverter0_machine_type - name: inverter0_machine_type - topology: - id: inverter0_topology - name: inverter0_topology - output_mode: - id: inverter0_output_mode - name: inverter0_output_mode - battery_redischarge_voltage: - id: inverter0_battery_redischarge_voltage - name: inverter0_battery_redischarge_voltage - pv_ok_condition_for_parallel: - id: inverter0_pv_ok_condition_for_parallel - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - id: inverter0_pv_power_balance - name: inverter0_pv_power_balance - grid_voltage: - id: inverter0_grid_voltage - name: inverter0_grid_voltage - grid_frequency: - id: inverter0_grid_frequency - name: inverter0_grid_frequency - ac_output_voltage: - id: inverter0_ac_output_voltage - name: inverter0_ac_output_voltage - ac_output_frequency: - id: inverter0_ac_output_frequency - name: inverter0_ac_output_frequency - ac_output_apparent_power: - id: inverter0_ac_output_apparent_power - name: inverter0_ac_output_apparent_power - ac_output_active_power: - id: inverter0_ac_output_active_power - name: inverter0_ac_output_active_power - output_load_percent: - id: inverter0_output_load_percent - name: inverter0_output_load_percent - bus_voltage: - id: inverter0_bus_voltage - name: inverter0_bus_voltage - battery_voltage: - id: inverter0_battery_voltage - name: inverter0_battery_voltage - battery_charging_current: - id: inverter0_battery_charging_current - name: inverter0_battery_charging_current - battery_capacity_percent: - id: inverter0_battery_capacity_percent - name: inverter0_battery_capacity_percent - inverter_heat_sink_temperature: - id: inverter0_inverter_heat_sink_temperature - name: inverter0_inverter_heat_sink_temperature - pv_input_current_for_battery: - id: inverter0_pv_input_current_for_battery - name: inverter0_pv_input_current_for_battery - pv_input_voltage: - id: inverter0_pv_input_voltage - name: inverter0_pv_input_voltage - battery_voltage_scc: - id: inverter0_battery_voltage_scc - name: inverter0_battery_voltage_scc - battery_discharge_current: - id: inverter0_battery_discharge_current - name: inverter0_battery_discharge_current - battery_voltage_offset_for_fans_on: - id: inverter0_battery_voltage_offset_for_fans_on - name: inverter0_battery_voltage_offset_for_fans_on - eeprom_version: - id: inverter0_eeprom_version - name: inverter0_eeprom_version - pv_charging_power: - id: inverter0_pv_charging_power - name: inverter0_pv_charging_power - -switch: - - platform: pipsolar - pipsolar_id: inverter0 - output_source_priority_utility: - name: inverter0_output_source_priority_utility - output_source_priority_solar: - name: inverter0_output_source_priority_solar - output_source_priority_battery: - name: inverter0_output_source_priority_battery - output_source_priority_hybrid: - name: inverter0_output_source_priority_hybrid - input_voltage_range: - name: inverter0_input_voltage_range - pv_ok_condition_for_parallel: - name: inverter0_pv_ok_condition_for_parallel - pv_power_balance: - name: inverter0_pv_power_balance - -text_sensor: - - platform: pipsolar - pipsolar_id: inverter0 - device_mode: - id: inverter0_device_mode - name: inverter0_device_mode - last_qpigs: - id: inverter0_last_qpigs - name: inverter0_last_qpigs - last_qpiri: - id: inverter0_last_qpiri - name: inverter0_last_qpiri - last_qmod: - id: inverter0_last_qmod - name: inverter0_last_qmod - last_qflag: - id: inverter0_last_qflag - name: inverter0_last_qflag +<<: !include common.yaml diff --git a/tests/components/pm1006/common.yaml b/tests/components/pm1006/common.yaml new file mode 100644 index 0000000000..4e3e880f4e --- /dev/null +++ b/tests/components/pm1006/common.yaml @@ -0,0 +1,10 @@ +uart: + - id: uart_pm1006 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: pm1006 + pm_2_5: + name: Particulate Matter 2.5µm Concentration diff --git a/tests/components/pm1006/test.esp32-ard.yaml b/tests/components/pm1006/test.esp32-ard.yaml index 635af37b25..f486544afa 100644 --- a/tests/components/pm1006/test.esp32-ard.yaml +++ b/tests/components/pm1006/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_pm1006 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: pm1006 - pm_2_5: - name: Particulate Matter 2.5µm Concentration +<<: !include common.yaml diff --git a/tests/components/pm1006/test.esp32-c3-ard.yaml b/tests/components/pm1006/test.esp32-c3-ard.yaml index 15ee077f3e..b516342f3b 100644 --- a/tests/components/pm1006/test.esp32-c3-ard.yaml +++ b/tests/components/pm1006/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_pm1006 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pm1006 - pm_2_5: - name: Particulate Matter 2.5µm Concentration +<<: !include common.yaml diff --git a/tests/components/pm1006/test.esp32-c3-idf.yaml b/tests/components/pm1006/test.esp32-c3-idf.yaml index 15ee077f3e..b516342f3b 100644 --- a/tests/components/pm1006/test.esp32-c3-idf.yaml +++ b/tests/components/pm1006/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_pm1006 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pm1006 - pm_2_5: - name: Particulate Matter 2.5µm Concentration +<<: !include common.yaml diff --git a/tests/components/pm1006/test.esp32-idf.yaml b/tests/components/pm1006/test.esp32-idf.yaml index 635af37b25..f486544afa 100644 --- a/tests/components/pm1006/test.esp32-idf.yaml +++ b/tests/components/pm1006/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_pm1006 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: pm1006 - pm_2_5: - name: Particulate Matter 2.5µm Concentration +<<: !include common.yaml diff --git a/tests/components/pm1006/test.esp8266-ard.yaml b/tests/components/pm1006/test.esp8266-ard.yaml index 15ee077f3e..b516342f3b 100644 --- a/tests/components/pm1006/test.esp8266-ard.yaml +++ b/tests/components/pm1006/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_pm1006 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pm1006 - pm_2_5: - name: Particulate Matter 2.5µm Concentration +<<: !include common.yaml diff --git a/tests/components/pm1006/test.rp2040-ard.yaml b/tests/components/pm1006/test.rp2040-ard.yaml index 15ee077f3e..b516342f3b 100644 --- a/tests/components/pm1006/test.rp2040-ard.yaml +++ b/tests/components/pm1006/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_pm1006 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pm1006 - pm_2_5: - name: Particulate Matter 2.5µm Concentration +<<: !include common.yaml diff --git a/tests/components/pmsa003i/common.yaml b/tests/components/pmsa003i/common.yaml new file mode 100644 index 0000000000..95e62da694 --- /dev/null +++ b/tests/components/pmsa003i/common.yaml @@ -0,0 +1,27 @@ +i2c: + - id: i2c_pmsa003i + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: pmsa003i + pm_1_0: + name: PMSA003i PM1.0 + pm_2_5: + name: PMSA003i PM2.5 + pm_10_0: + name: PMSA003i PM10.0 + pmc_0_3: + name: PMSA003i PMC <0.3µm + pmc_0_5: + name: PMSA003i PMC <0.5µm + pmc_1_0: + name: PMSA003i PMC <1µm + pmc_2_5: + name: PMSA003i PMC <2.5µm + pmc_5_0: + name: PMSA003i PMC <5µm + pmc_10_0: + name: PMSA003i PMC <10µm + address: 0x12 + standard_units: true diff --git a/tests/components/pmsa003i/test.esp32-ard.yaml b/tests/components/pmsa003i/test.esp32-ard.yaml index d8d96400f6..63c3bd6afd 100644 --- a/tests/components/pmsa003i/test.esp32-ard.yaml +++ b/tests/components/pmsa003i/test.esp32-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_pmsa003i - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: pmsa003i - pm_1_0: - name: PMSA003i PM1.0 - pm_2_5: - name: PMSA003i PM2.5 - pm_10_0: - name: PMSA003i PM10.0 - pmc_0_3: - name: PMSA003i PMC <0.3µm - pmc_0_5: - name: PMSA003i PMC <0.5µm - pmc_1_0: - name: PMSA003i PMC <1µm - pmc_2_5: - name: PMSA003i PMC <2.5µm - pmc_5_0: - name: PMSA003i PMC <5µm - pmc_10_0: - name: PMSA003i PMC <10µm - address: 0x12 - standard_units: true +<<: !include common.yaml diff --git a/tests/components/pmsa003i/test.esp32-c3-ard.yaml b/tests/components/pmsa003i/test.esp32-c3-ard.yaml index 70e28303a2..ee2c29ca4e 100644 --- a/tests/components/pmsa003i/test.esp32-c3-ard.yaml +++ b/tests/components/pmsa003i/test.esp32-c3-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_pmsa003i - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: pmsa003i - pm_1_0: - name: PMSA003i PM1.0 - pm_2_5: - name: PMSA003i PM2.5 - pm_10_0: - name: PMSA003i PM10.0 - pmc_0_3: - name: PMSA003i PMC <0.3µm - pmc_0_5: - name: PMSA003i PMC <0.5µm - pmc_1_0: - name: PMSA003i PMC <1µm - pmc_2_5: - name: PMSA003i PMC <2.5µm - pmc_5_0: - name: PMSA003i PMC <5µm - pmc_10_0: - name: PMSA003i PMC <10µm - address: 0x12 - standard_units: true +<<: !include common.yaml diff --git a/tests/components/pmsa003i/test.esp32-c3-idf.yaml b/tests/components/pmsa003i/test.esp32-c3-idf.yaml index 70e28303a2..ee2c29ca4e 100644 --- a/tests/components/pmsa003i/test.esp32-c3-idf.yaml +++ b/tests/components/pmsa003i/test.esp32-c3-idf.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_pmsa003i - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: pmsa003i - pm_1_0: - name: PMSA003i PM1.0 - pm_2_5: - name: PMSA003i PM2.5 - pm_10_0: - name: PMSA003i PM10.0 - pmc_0_3: - name: PMSA003i PMC <0.3µm - pmc_0_5: - name: PMSA003i PMC <0.5µm - pmc_1_0: - name: PMSA003i PMC <1µm - pmc_2_5: - name: PMSA003i PMC <2.5µm - pmc_5_0: - name: PMSA003i PMC <5µm - pmc_10_0: - name: PMSA003i PMC <10µm - address: 0x12 - standard_units: true +<<: !include common.yaml diff --git a/tests/components/pmsa003i/test.esp32-idf.yaml b/tests/components/pmsa003i/test.esp32-idf.yaml index d8d96400f6..63c3bd6afd 100644 --- a/tests/components/pmsa003i/test.esp32-idf.yaml +++ b/tests/components/pmsa003i/test.esp32-idf.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_pmsa003i - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: pmsa003i - pm_1_0: - name: PMSA003i PM1.0 - pm_2_5: - name: PMSA003i PM2.5 - pm_10_0: - name: PMSA003i PM10.0 - pmc_0_3: - name: PMSA003i PMC <0.3µm - pmc_0_5: - name: PMSA003i PMC <0.5µm - pmc_1_0: - name: PMSA003i PMC <1µm - pmc_2_5: - name: PMSA003i PMC <2.5µm - pmc_5_0: - name: PMSA003i PMC <5µm - pmc_10_0: - name: PMSA003i PMC <10µm - address: 0x12 - standard_units: true +<<: !include common.yaml diff --git a/tests/components/pmsa003i/test.esp8266-ard.yaml b/tests/components/pmsa003i/test.esp8266-ard.yaml index 70e28303a2..ee2c29ca4e 100644 --- a/tests/components/pmsa003i/test.esp8266-ard.yaml +++ b/tests/components/pmsa003i/test.esp8266-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_pmsa003i - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: pmsa003i - pm_1_0: - name: PMSA003i PM1.0 - pm_2_5: - name: PMSA003i PM2.5 - pm_10_0: - name: PMSA003i PM10.0 - pmc_0_3: - name: PMSA003i PMC <0.3µm - pmc_0_5: - name: PMSA003i PMC <0.5µm - pmc_1_0: - name: PMSA003i PMC <1µm - pmc_2_5: - name: PMSA003i PMC <2.5µm - pmc_5_0: - name: PMSA003i PMC <5µm - pmc_10_0: - name: PMSA003i PMC <10µm - address: 0x12 - standard_units: true +<<: !include common.yaml diff --git a/tests/components/pmsa003i/test.rp2040-ard.yaml b/tests/components/pmsa003i/test.rp2040-ard.yaml index 70e28303a2..ee2c29ca4e 100644 --- a/tests/components/pmsa003i/test.rp2040-ard.yaml +++ b/tests/components/pmsa003i/test.rp2040-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_pmsa003i - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: pmsa003i - pm_1_0: - name: PMSA003i PM1.0 - pm_2_5: - name: PMSA003i PM2.5 - pm_10_0: - name: PMSA003i PM10.0 - pmc_0_3: - name: PMSA003i PMC <0.3µm - pmc_0_5: - name: PMSA003i PMC <0.5µm - pmc_1_0: - name: PMSA003i PMC <1µm - pmc_2_5: - name: PMSA003i PMC <2.5µm - pmc_5_0: - name: PMSA003i PMC <5µm - pmc_10_0: - name: PMSA003i PMC <10µm - address: 0x12 - standard_units: true +<<: !include common.yaml diff --git a/tests/components/pmsx003/common.yaml b/tests/components/pmsx003/common.yaml new file mode 100644 index 0000000000..7b9ca5b091 --- /dev/null +++ b/tests/components/pmsx003/common.yaml @@ -0,0 +1,34 @@ +uart: + - id: uart_pmsx003 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: pmsx003 + type: PMSX003 + pm_1_0: + name: PM 1.0 Concentration + pm_2_5: + name: PM 2.5 Concentration + pm_10_0: + name: PM 10.0 Concentration + pm_1_0_std: + name: PM 1.0 Standard Atmospher Concentration + pm_2_5_std: + name: PM 2.5 Standard Atmospher Concentration + pm_10_0_std: + name: PM 10.0 Standard Atmospher Concentration + pm_0_3um: + name: Particulate Count >0.3um + pm_0_5um: + name: Particulate Count >0.5um + pm_1_0um: + name: Particulate Count >1.0um + pm_2_5um: + name: Particulate Count >2.5um + pm_5_0um: + name: Particulate Count >5.0um + pm_10_0um: + name: Particulate Count >10.0um + update_interval: 30s diff --git a/tests/components/pmsx003/test.esp32-ard.yaml b/tests/components/pmsx003/test.esp32-ard.yaml index 5e7ebbbb2e..f486544afa 100644 --- a/tests/components/pmsx003/test.esp32-ard.yaml +++ b/tests/components/pmsx003/test.esp32-ard.yaml @@ -1,34 +1,5 @@ -uart: - - id: uart_pmsx003 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: pmsx003 - type: PMSX003 - pm_1_0: - name: PM 1.0 Concentration - pm_2_5: - name: PM 2.5 Concentration - pm_10_0: - name: PM 10.0 Concentration - pm_1_0_std: - name: PM 1.0 Standard Atmospher Concentration - pm_2_5_std: - name: PM 2.5 Standard Atmospher Concentration - pm_10_0_std: - name: PM 10.0 Standard Atmospher Concentration - pm_0_3um: - name: Particulate Count >0.3um - pm_0_5um: - name: Particulate Count >0.5um - pm_1_0um: - name: Particulate Count >1.0um - pm_2_5um: - name: Particulate Count >2.5um - pm_5_0um: - name: Particulate Count >5.0um - pm_10_0um: - name: Particulate Count >10.0um - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/pmsx003/test.esp32-c3-ard.yaml b/tests/components/pmsx003/test.esp32-c3-ard.yaml index 58adc9390a..b516342f3b 100644 --- a/tests/components/pmsx003/test.esp32-c3-ard.yaml +++ b/tests/components/pmsx003/test.esp32-c3-ard.yaml @@ -1,34 +1,5 @@ -uart: - - id: uart_pmsx003 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pmsx003 - type: PMSX003 - pm_1_0: - name: PM 1.0 Concentration - pm_2_5: - name: PM 2.5 Concentration - pm_10_0: - name: PM 10.0 Concentration - pm_1_0_std: - name: PM 1.0 Standard Atmospher Concentration - pm_2_5_std: - name: PM 2.5 Standard Atmospher Concentration - pm_10_0_std: - name: PM 10.0 Standard Atmospher Concentration - pm_0_3um: - name: Particulate Count >0.3um - pm_0_5um: - name: Particulate Count >0.5um - pm_1_0um: - name: Particulate Count >1.0um - pm_2_5um: - name: Particulate Count >2.5um - pm_5_0um: - name: Particulate Count >5.0um - pm_10_0um: - name: Particulate Count >10.0um - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/pmsx003/test.esp32-c3-idf.yaml b/tests/components/pmsx003/test.esp32-c3-idf.yaml index 58adc9390a..b516342f3b 100644 --- a/tests/components/pmsx003/test.esp32-c3-idf.yaml +++ b/tests/components/pmsx003/test.esp32-c3-idf.yaml @@ -1,34 +1,5 @@ -uart: - - id: uart_pmsx003 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pmsx003 - type: PMSX003 - pm_1_0: - name: PM 1.0 Concentration - pm_2_5: - name: PM 2.5 Concentration - pm_10_0: - name: PM 10.0 Concentration - pm_1_0_std: - name: PM 1.0 Standard Atmospher Concentration - pm_2_5_std: - name: PM 2.5 Standard Atmospher Concentration - pm_10_0_std: - name: PM 10.0 Standard Atmospher Concentration - pm_0_3um: - name: Particulate Count >0.3um - pm_0_5um: - name: Particulate Count >0.5um - pm_1_0um: - name: Particulate Count >1.0um - pm_2_5um: - name: Particulate Count >2.5um - pm_5_0um: - name: Particulate Count >5.0um - pm_10_0um: - name: Particulate Count >10.0um - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/pmsx003/test.esp32-idf.yaml b/tests/components/pmsx003/test.esp32-idf.yaml index 5e7ebbbb2e..f486544afa 100644 --- a/tests/components/pmsx003/test.esp32-idf.yaml +++ b/tests/components/pmsx003/test.esp32-idf.yaml @@ -1,34 +1,5 @@ -uart: - - id: uart_pmsx003 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: pmsx003 - type: PMSX003 - pm_1_0: - name: PM 1.0 Concentration - pm_2_5: - name: PM 2.5 Concentration - pm_10_0: - name: PM 10.0 Concentration - pm_1_0_std: - name: PM 1.0 Standard Atmospher Concentration - pm_2_5_std: - name: PM 2.5 Standard Atmospher Concentration - pm_10_0_std: - name: PM 10.0 Standard Atmospher Concentration - pm_0_3um: - name: Particulate Count >0.3um - pm_0_5um: - name: Particulate Count >0.5um - pm_1_0um: - name: Particulate Count >1.0um - pm_2_5um: - name: Particulate Count >2.5um - pm_5_0um: - name: Particulate Count >5.0um - pm_10_0um: - name: Particulate Count >10.0um - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/pmsx003/test.esp8266-ard.yaml b/tests/components/pmsx003/test.esp8266-ard.yaml index 58adc9390a..b516342f3b 100644 --- a/tests/components/pmsx003/test.esp8266-ard.yaml +++ b/tests/components/pmsx003/test.esp8266-ard.yaml @@ -1,34 +1,5 @@ -uart: - - id: uart_pmsx003 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pmsx003 - type: PMSX003 - pm_1_0: - name: PM 1.0 Concentration - pm_2_5: - name: PM 2.5 Concentration - pm_10_0: - name: PM 10.0 Concentration - pm_1_0_std: - name: PM 1.0 Standard Atmospher Concentration - pm_2_5_std: - name: PM 2.5 Standard Atmospher Concentration - pm_10_0_std: - name: PM 10.0 Standard Atmospher Concentration - pm_0_3um: - name: Particulate Count >0.3um - pm_0_5um: - name: Particulate Count >0.5um - pm_1_0um: - name: Particulate Count >1.0um - pm_2_5um: - name: Particulate Count >2.5um - pm_5_0um: - name: Particulate Count >5.0um - pm_10_0um: - name: Particulate Count >10.0um - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/pmsx003/test.rp2040-ard.yaml b/tests/components/pmsx003/test.rp2040-ard.yaml index 58adc9390a..b516342f3b 100644 --- a/tests/components/pmsx003/test.rp2040-ard.yaml +++ b/tests/components/pmsx003/test.rp2040-ard.yaml @@ -1,34 +1,5 @@ -uart: - - id: uart_pmsx003 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pmsx003 - type: PMSX003 - pm_1_0: - name: PM 1.0 Concentration - pm_2_5: - name: PM 2.5 Concentration - pm_10_0: - name: PM 10.0 Concentration - pm_1_0_std: - name: PM 1.0 Standard Atmospher Concentration - pm_2_5_std: - name: PM 2.5 Standard Atmospher Concentration - pm_10_0_std: - name: PM 10.0 Standard Atmospher Concentration - pm_0_3um: - name: Particulate Count >0.3um - pm_0_5um: - name: Particulate Count >0.5um - pm_1_0um: - name: Particulate Count >1.0um - pm_2_5um: - name: Particulate Count >2.5um - pm_5_0um: - name: Particulate Count >5.0um - pm_10_0um: - name: Particulate Count >10.0um - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/pmwcs3/common.yaml b/tests/components/pmwcs3/common.yaml new file mode 100644 index 0000000000..dcf59d0b6e --- /dev/null +++ b/tests/components/pmwcs3/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_pmwcs3 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: pmwcs3 + e25: + name: pmwcs3_e25 + ec: + name: pmwcs3_ec + temperature: + name: pmwcs3_temperature + vwc: + name: pmwcs3_vwc diff --git a/tests/components/pmwcs3/test.esp32-ard.yaml b/tests/components/pmwcs3/test.esp32-ard.yaml index 787eaca650..63c3bd6afd 100644 --- a/tests/components/pmwcs3/test.esp32-ard.yaml +++ b/tests/components/pmwcs3/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_pmwcs3 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: pmwcs3 - e25: - name: pmwcs3_e25 - ec: - name: pmwcs3_ec - temperature: - name: pmwcs3_temperature - vwc: - name: pmwcs3_vwc +<<: !include common.yaml diff --git a/tests/components/pmwcs3/test.esp32-c3-ard.yaml b/tests/components/pmwcs3/test.esp32-c3-ard.yaml index 7e7e72692d..ee2c29ca4e 100644 --- a/tests/components/pmwcs3/test.esp32-c3-ard.yaml +++ b/tests/components/pmwcs3/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_pmwcs3 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: pmwcs3 - e25: - name: pmwcs3_e25 - ec: - name: pmwcs3_ec - temperature: - name: pmwcs3_temperature - vwc: - name: pmwcs3_vwc +<<: !include common.yaml diff --git a/tests/components/pmwcs3/test.esp32-c3-idf.yaml b/tests/components/pmwcs3/test.esp32-c3-idf.yaml index 7e7e72692d..ee2c29ca4e 100644 --- a/tests/components/pmwcs3/test.esp32-c3-idf.yaml +++ b/tests/components/pmwcs3/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_pmwcs3 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: pmwcs3 - e25: - name: pmwcs3_e25 - ec: - name: pmwcs3_ec - temperature: - name: pmwcs3_temperature - vwc: - name: pmwcs3_vwc +<<: !include common.yaml diff --git a/tests/components/pmwcs3/test.esp32-idf.yaml b/tests/components/pmwcs3/test.esp32-idf.yaml index 787eaca650..63c3bd6afd 100644 --- a/tests/components/pmwcs3/test.esp32-idf.yaml +++ b/tests/components/pmwcs3/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_pmwcs3 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: pmwcs3 - e25: - name: pmwcs3_e25 - ec: - name: pmwcs3_ec - temperature: - name: pmwcs3_temperature - vwc: - name: pmwcs3_vwc +<<: !include common.yaml diff --git a/tests/components/pmwcs3/test.esp8266-ard.yaml b/tests/components/pmwcs3/test.esp8266-ard.yaml index 7e7e72692d..ee2c29ca4e 100644 --- a/tests/components/pmwcs3/test.esp8266-ard.yaml +++ b/tests/components/pmwcs3/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_pmwcs3 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: pmwcs3 - e25: - name: pmwcs3_e25 - ec: - name: pmwcs3_ec - temperature: - name: pmwcs3_temperature - vwc: - name: pmwcs3_vwc +<<: !include common.yaml diff --git a/tests/components/pmwcs3/test.rp2040-ard.yaml b/tests/components/pmwcs3/test.rp2040-ard.yaml index 7e7e72692d..ee2c29ca4e 100644 --- a/tests/components/pmwcs3/test.rp2040-ard.yaml +++ b/tests/components/pmwcs3/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_pmwcs3 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: pmwcs3 - e25: - name: pmwcs3_e25 - ec: - name: pmwcs3_ec - temperature: - name: pmwcs3_temperature - vwc: - name: pmwcs3_vwc +<<: !include common.yaml diff --git a/tests/components/pn532_i2c/common.yaml b/tests/components/pn532_i2c/common.yaml new file mode 100644 index 0000000000..db9abd4b13 --- /dev/null +++ b/tests/components/pn532_i2c/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_pn532 + scl: ${scl_pin} + sda: ${sda_pin} + +pn532_i2c: + id: pn532_nfcc + +binary_sensor: + - platform: pn532 + pn532_id: pn532_nfcc + name: PN532 NFC Tag + uid: 74-10-37-94 diff --git a/tests/components/pn532_i2c/test.esp32-ard.yaml b/tests/components/pn532_i2c/test.esp32-ard.yaml index a50533b1d0..63c3bd6afd 100644 --- a/tests/components/pn532_i2c/test.esp32-ard.yaml +++ b/tests/components/pn532_i2c/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_pn532 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -pn532_i2c: - id: pn532_nfcc - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_i2c/test.esp32-c3-ard.yaml b/tests/components/pn532_i2c/test.esp32-c3-ard.yaml index 62816d2ace..ee2c29ca4e 100644 --- a/tests/components/pn532_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/pn532_i2c/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_pn532 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pn532_i2c: - id: pn532_nfcc - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_i2c/test.esp32-c3-idf.yaml b/tests/components/pn532_i2c/test.esp32-c3-idf.yaml index 62816d2ace..ee2c29ca4e 100644 --- a/tests/components/pn532_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/pn532_i2c/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_pn532 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pn532_i2c: - id: pn532_nfcc - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_i2c/test.esp32-idf.yaml b/tests/components/pn532_i2c/test.esp32-idf.yaml index a50533b1d0..63c3bd6afd 100644 --- a/tests/components/pn532_i2c/test.esp32-idf.yaml +++ b/tests/components/pn532_i2c/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_pn532 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -pn532_i2c: - id: pn532_nfcc - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_i2c/test.esp8266-ard.yaml b/tests/components/pn532_i2c/test.esp8266-ard.yaml index 62816d2ace..ee2c29ca4e 100644 --- a/tests/components/pn532_i2c/test.esp8266-ard.yaml +++ b/tests/components/pn532_i2c/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_pn532 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pn532_i2c: - id: pn532_nfcc - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_i2c/test.rp2040-ard.yaml b/tests/components/pn532_i2c/test.rp2040-ard.yaml index 62816d2ace..ee2c29ca4e 100644 --- a/tests/components/pn532_i2c/test.rp2040-ard.yaml +++ b/tests/components/pn532_i2c/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_pn532 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -pn532_i2c: - id: pn532_nfcc - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_spi/common.yaml b/tests/components/pn532_spi/common.yaml new file mode 100644 index 0000000000..d5b8bc405e --- /dev/null +++ b/tests/components/pn532_spi/common.yaml @@ -0,0 +1,15 @@ +spi: + - id: spi_pn532 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +pn532_spi: + id: pn532_nfcc + cs_pin: ${cs_pin} + +binary_sensor: + - platform: pn532 + pn532_id: pn532_nfcc + name: PN532 NFC Tag + uid: 74-10-37-94 diff --git a/tests/components/pn532_spi/test.esp32-ard.yaml b/tests/components/pn532_spi/test.esp32-ard.yaml index 18a382a007..bce56f398a 100644 --- a/tests/components/pn532_spi/test.esp32-ard.yaml +++ b/tests/components/pn532_spi/test.esp32-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_pn532 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO18 + cs_pin: GPIO12 -pn532_spi: - id: pn532_nfcc - cs_pin: 12 - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_spi/test.esp32-c3-ard.yaml b/tests/components/pn532_spi/test.esp32-c3-ard.yaml index d21d50aa5c..2415ba5dc6 100644 --- a/tests/components/pn532_spi/test.esp32-c3-ard.yaml +++ b/tests/components/pn532_spi/test.esp32-c3-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_pn532 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -pn532_spi: - id: pn532_nfcc - cs_pin: 4 - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_spi/test.esp32-c3-idf.yaml b/tests/components/pn532_spi/test.esp32-c3-idf.yaml index d21d50aa5c..2415ba5dc6 100644 --- a/tests/components/pn532_spi/test.esp32-c3-idf.yaml +++ b/tests/components/pn532_spi/test.esp32-c3-idf.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_pn532 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -pn532_spi: - id: pn532_nfcc - cs_pin: 4 - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_spi/test.esp32-idf.yaml b/tests/components/pn532_spi/test.esp32-idf.yaml index 18a382a007..bce56f398a 100644 --- a/tests/components/pn532_spi/test.esp32-idf.yaml +++ b/tests/components/pn532_spi/test.esp32-idf.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_pn532 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO18 + cs_pin: GPIO12 -pn532_spi: - id: pn532_nfcc - cs_pin: 12 - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_spi/test.esp8266-ard.yaml b/tests/components/pn532_spi/test.esp8266-ard.yaml index 1dba38e63e..bd5c203e35 100644 --- a/tests/components/pn532_spi/test.esp8266-ard.yaml +++ b/tests/components/pn532_spi/test.esp8266-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_pn532 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 -pn532_spi: - id: pn532_nfcc - cs_pin: 15 - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn532_spi/test.rp2040-ard.yaml b/tests/components/pn532_spi/test.rp2040-ard.yaml index ab02b2cc47..f6c3f1eeca 100644 --- a/tests/components/pn532_spi/test.rp2040-ard.yaml +++ b/tests/components/pn532_spi/test.rp2040-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_pn532 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -pn532_spi: - id: pn532_nfcc - cs_pin: 6 - -binary_sensor: - - platform: pn532 - pn532_id: pn532_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/pn7150_i2c/common.yaml b/tests/components/pn7150_i2c/common.yaml new file mode 100644 index 0000000000..ef852b7a78 --- /dev/null +++ b/tests/components/pn7150_i2c/common.yaml @@ -0,0 +1,35 @@ +esphome: + on_boot: + then: + - tag.set_clean_mode: nfcc_pn7150 + - tag.set_format_mode: nfcc_pn7150 + - tag.set_read_mode: nfcc_pn7150 + - tag.set_write_message: + message: https://www.home-assistant.io/tag/pulse + include_android_app_record: false + - tag.set_write_mode: nfcc_pn7150 + - tag.set_emulation_message: + message: https://www.home-assistant.io/tag/pulse + include_android_app_record: false + - tag.emulation_off: nfcc_pn7150 + - tag.emulation_on: nfcc_pn7150 + - tag.polling_off: nfcc_pn7150 + - tag.polling_on: nfcc_pn7150 + +i2c: + - id: i2c_pn7150 + scl: ${scl_pin} + sda: ${sda_pin} + +pn7150_i2c: + id: nfcc_pn7150 + irq_pin: ${irq_pin} + ven_pin: ${ven_pin} + emulation_message: https://www.home-assistant.io/tag/pulse_ce + tag_ttl: 1000ms + on_tag: + - logger.log: "Tag" + on_tag_removed: + - logger.log: "Tag removed" + on_emulated_tag_scan: + - logger.log: "Tag emulated" diff --git a/tests/components/pn7150_i2c/test.esp32-ard.yaml b/tests/components/pn7150_i2c/test.esp32-ard.yaml index 23d1061608..1643bec317 100644 --- a/tests/components/pn7150_i2c/test.esp32-ard.yaml +++ b/tests/components/pn7150_i2c/test.esp32-ard.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7150 - - tag.set_format_mode: nfcc_pn7150 - - tag.set_read_mode: nfcc_pn7150 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7150 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7150 - - tag.emulation_on: nfcc_pn7150 - - tag.polling_off: nfcc_pn7150 - - tag.polling_on: nfcc_pn7150 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + irq_pin: GPIO14 + ven_pin: GPIO15 -i2c: - - id: i2c_pn7150 - scl: 16 - sda: 17 - -pn7150_i2c: - id: nfcc_pn7150 - irq_pin: 12 - ven_pin: 13 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7150_i2c/test.esp32-c3-ard.yaml b/tests/components/pn7150_i2c/test.esp32-c3-ard.yaml index aee1886cd4..2067143411 100644 --- a/tests/components/pn7150_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/pn7150_i2c/test.esp32-c3-ard.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7150 - - tag.set_format_mode: nfcc_pn7150 - - tag.set_read_mode: nfcc_pn7150 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7150 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7150 - - tag.emulation_on: nfcc_pn7150 - - tag.polling_off: nfcc_pn7150 - - tag.polling_on: nfcc_pn7150 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 + ven_pin: GPIO7 -i2c: - - id: i2c_pn7150 - scl: 5 - sda: 4 - -pn7150_i2c: - id: nfcc_pn7150 - irq_pin: 2 - ven_pin: 3 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7150_i2c/test.esp32-c3-idf.yaml b/tests/components/pn7150_i2c/test.esp32-c3-idf.yaml index aee1886cd4..2067143411 100644 --- a/tests/components/pn7150_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/pn7150_i2c/test.esp32-c3-idf.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7150 - - tag.set_format_mode: nfcc_pn7150 - - tag.set_read_mode: nfcc_pn7150 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7150 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7150 - - tag.emulation_on: nfcc_pn7150 - - tag.polling_off: nfcc_pn7150 - - tag.polling_on: nfcc_pn7150 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 + ven_pin: GPIO7 -i2c: - - id: i2c_pn7150 - scl: 5 - sda: 4 - -pn7150_i2c: - id: nfcc_pn7150 - irq_pin: 2 - ven_pin: 3 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7150_i2c/test.esp32-idf.yaml b/tests/components/pn7150_i2c/test.esp32-idf.yaml index 23d1061608..1643bec317 100644 --- a/tests/components/pn7150_i2c/test.esp32-idf.yaml +++ b/tests/components/pn7150_i2c/test.esp32-idf.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7150 - - tag.set_format_mode: nfcc_pn7150 - - tag.set_read_mode: nfcc_pn7150 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7150 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7150 - - tag.emulation_on: nfcc_pn7150 - - tag.polling_off: nfcc_pn7150 - - tag.polling_on: nfcc_pn7150 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + irq_pin: GPIO14 + ven_pin: GPIO15 -i2c: - - id: i2c_pn7150 - scl: 16 - sda: 17 - -pn7150_i2c: - id: nfcc_pn7150 - irq_pin: 12 - ven_pin: 13 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7150_i2c/test.esp8266-ard.yaml b/tests/components/pn7150_i2c/test.esp8266-ard.yaml index 6017d548ca..7111fc9e00 100644 --- a/tests/components/pn7150_i2c/test.esp8266-ard.yaml +++ b/tests/components/pn7150_i2c/test.esp8266-ard.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7150 - - tag.set_format_mode: nfcc_pn7150 - - tag.set_read_mode: nfcc_pn7150 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7150 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7150 - - tag.emulation_on: nfcc_pn7150 - - tag.polling_off: nfcc_pn7150 - - tag.polling_on: nfcc_pn7150 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO12 + ven_pin: GPIO13 -i2c: - - id: i2c_pn7150 - scl: 5 - sda: 4 - -pn7150_i2c: - id: nfcc_pn7150 - irq_pin: 12 - ven_pin: 13 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7150_i2c/test.rp2040-ard.yaml b/tests/components/pn7150_i2c/test.rp2040-ard.yaml index aee1886cd4..2067143411 100644 --- a/tests/components/pn7150_i2c/test.rp2040-ard.yaml +++ b/tests/components/pn7150_i2c/test.rp2040-ard.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7150 - - tag.set_format_mode: nfcc_pn7150 - - tag.set_read_mode: nfcc_pn7150 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7150 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7150 - - tag.emulation_on: nfcc_pn7150 - - tag.polling_off: nfcc_pn7150 - - tag.polling_on: nfcc_pn7150 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 + ven_pin: GPIO7 -i2c: - - id: i2c_pn7150 - scl: 5 - sda: 4 - -pn7150_i2c: - id: nfcc_pn7150 - irq_pin: 2 - ven_pin: 3 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_i2c/common.yaml b/tests/components/pn7160_i2c/common.yaml new file mode 100644 index 0000000000..0a7c9bd6bb --- /dev/null +++ b/tests/components/pn7160_i2c/common.yaml @@ -0,0 +1,35 @@ +esphome: + on_boot: + then: + - tag.set_clean_mode: nfcc_pn7160 + - tag.set_format_mode: nfcc_pn7160 + - tag.set_read_mode: nfcc_pn7160 + - tag.set_write_message: + message: https://www.home-assistant.io/tag/pulse + include_android_app_record: false + - tag.set_write_mode: nfcc_pn7160 + - tag.set_emulation_message: + message: https://www.home-assistant.io/tag/pulse + include_android_app_record: false + - tag.emulation_off: nfcc_pn7160 + - tag.emulation_on: nfcc_pn7160 + - tag.polling_off: nfcc_pn7160 + - tag.polling_on: nfcc_pn7160 + +i2c: + - id: i2c_pn7160 + scl: ${scl_pin} + sda: ${sda_pin} + +pn7150_i2c: + id: nfcc_pn7160 + irq_pin: ${irq_pin} + ven_pin: ${ven_pin} + emulation_message: https://www.home-assistant.io/tag/pulse_ce + tag_ttl: 1000ms + on_tag: + - logger.log: "Tag" + on_tag_removed: + - logger.log: "Tag removed" + on_emulated_tag_scan: + - logger.log: "Tag emulated" diff --git a/tests/components/pn7160_i2c/test.esp32-ard.yaml b/tests/components/pn7160_i2c/test.esp32-ard.yaml index d1a3cf5c77..1643bec317 100644 --- a/tests/components/pn7160_i2c/test.esp32-ard.yaml +++ b/tests/components/pn7160_i2c/test.esp32-ard.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + irq_pin: GPIO14 + ven_pin: GPIO15 -i2c: - - id: i2c_pn7160 - scl: 16 - sda: 17 - -pn7150_i2c: - id: nfcc_pn7160 - irq_pin: 12 - ven_pin: 13 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_i2c/test.esp32-c3-ard.yaml b/tests/components/pn7160_i2c/test.esp32-c3-ard.yaml index d1d7947352..2067143411 100644 --- a/tests/components/pn7160_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/pn7160_i2c/test.esp32-c3-ard.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 + ven_pin: GPIO7 -i2c: - - id: i2c_pn7160 - scl: 5 - sda: 4 - -pn7160_i2c: - id: nfcc_pn7160 - irq_pin: 2 - ven_pin: 3 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_i2c/test.esp32-c3-idf.yaml b/tests/components/pn7160_i2c/test.esp32-c3-idf.yaml index d1d7947352..2067143411 100644 --- a/tests/components/pn7160_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/pn7160_i2c/test.esp32-c3-idf.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 + ven_pin: GPIO7 -i2c: - - id: i2c_pn7160 - scl: 5 - sda: 4 - -pn7160_i2c: - id: nfcc_pn7160 - irq_pin: 2 - ven_pin: 3 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_i2c/test.esp32-idf.yaml b/tests/components/pn7160_i2c/test.esp32-idf.yaml index d1a3cf5c77..1643bec317 100644 --- a/tests/components/pn7160_i2c/test.esp32-idf.yaml +++ b/tests/components/pn7160_i2c/test.esp32-idf.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + irq_pin: GPIO14 + ven_pin: GPIO15 -i2c: - - id: i2c_pn7160 - scl: 16 - sda: 17 - -pn7150_i2c: - id: nfcc_pn7160 - irq_pin: 12 - ven_pin: 13 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_i2c/test.esp8266-ard.yaml b/tests/components/pn7160_i2c/test.esp8266-ard.yaml index 57bd965fc9..7111fc9e00 100644 --- a/tests/components/pn7160_i2c/test.esp8266-ard.yaml +++ b/tests/components/pn7160_i2c/test.esp8266-ard.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO12 + ven_pin: GPIO13 -i2c: - - id: i2c_pn7160 - scl: 5 - sda: 4 - -pn7150_i2c: - id: nfcc_pn7160 - irq_pin: 12 - ven_pin: 13 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_i2c/test.rp2040-ard.yaml b/tests/components/pn7160_i2c/test.rp2040-ard.yaml index 5224b465ed..2067143411 100644 --- a/tests/components/pn7160_i2c/test.rp2040-ard.yaml +++ b/tests/components/pn7160_i2c/test.rp2040-ard.yaml @@ -1,35 +1,7 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + irq_pin: GPIO6 + ven_pin: GPIO7 -i2c: - - id: i2c_pn7160 - scl: 5 - sda: 4 - -pn7150_i2c: - id: nfcc_pn7160 - irq_pin: 2 - ven_pin: 3 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_spi/common.yaml b/tests/components/pn7160_spi/common.yaml new file mode 100644 index 0000000000..9e8d22f835 --- /dev/null +++ b/tests/components/pn7160_spi/common.yaml @@ -0,0 +1,37 @@ +esphome: + on_boot: + then: + - tag.set_clean_mode: nfcc_pn7160 + - tag.set_format_mode: nfcc_pn7160 + - tag.set_read_mode: nfcc_pn7160 + - tag.set_write_message: + message: https://www.home-assistant.io/tag/pulse + include_android_app_record: false + - tag.set_write_mode: nfcc_pn7160 + - tag.set_emulation_message: + message: https://www.home-assistant.io/tag/pulse + include_android_app_record: false + - tag.emulation_off: nfcc_pn7160 + - tag.emulation_on: nfcc_pn7160 + - tag.polling_off: nfcc_pn7160 + - tag.polling_on: nfcc_pn7160 + +spi: + - id: spi_pn7160 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +pn7160_spi: + id: nfcc_pn7160 + cs_pin: ${cs_pin} + irq_pin: ${irq_pin} + ven_pin: ${ven_pin} + emulation_message: https://www.home-assistant.io/tag/pulse_ce + tag_ttl: 1000ms + on_tag: + - logger.log: "Tag" + on_tag_removed: + - logger.log: "Tag removed" + on_emulated_tag_scan: + - logger.log: "Tag emulated" diff --git a/tests/components/pn7160_spi/test.esp32-ard.yaml b/tests/components/pn7160_spi/test.esp32-ard.yaml index 0319648f13..f6073d0416 100644 --- a/tests/components/pn7160_spi/test.esp32-ard.yaml +++ b/tests/components/pn7160_spi/test.esp32-ard.yaml @@ -1,37 +1,9 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO18 + cs_pin: GPIO12 + irq_pin: GPIO13 + ven_pin: GPIO14 -spi: - - id: spi_pn7160 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 - -pn7160_spi: - id: nfcc_pn7160 - cs_pin: 12 - irq_pin: 14 - ven_pin: 13 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_spi/test.esp32-c3-ard.yaml b/tests/components/pn7160_spi/test.esp32-c3-ard.yaml index fd19a53b2b..f8a07fad2f 100644 --- a/tests/components/pn7160_spi/test.esp32-c3-ard.yaml +++ b/tests/components/pn7160_spi/test.esp32-c3-ard.yaml @@ -1,37 +1,9 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + irq_pin: GPIO9 + ven_pin: GPIO10 -spi: - - id: spi_pn7160 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 - -pn7160_spi: - id: nfcc_pn7160 - cs_pin: 4 - irq_pin: 2 - ven_pin: 3 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_spi/test.esp32-c3-idf.yaml b/tests/components/pn7160_spi/test.esp32-c3-idf.yaml index fd19a53b2b..f8a07fad2f 100644 --- a/tests/components/pn7160_spi/test.esp32-c3-idf.yaml +++ b/tests/components/pn7160_spi/test.esp32-c3-idf.yaml @@ -1,37 +1,9 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + irq_pin: GPIO9 + ven_pin: GPIO10 -spi: - - id: spi_pn7160 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 - -pn7160_spi: - id: nfcc_pn7160 - cs_pin: 4 - irq_pin: 2 - ven_pin: 3 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_spi/test.esp32-idf.yaml b/tests/components/pn7160_spi/test.esp32-idf.yaml index 0319648f13..f6073d0416 100644 --- a/tests/components/pn7160_spi/test.esp32-idf.yaml +++ b/tests/components/pn7160_spi/test.esp32-idf.yaml @@ -1,37 +1,9 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO18 + cs_pin: GPIO12 + irq_pin: GPIO13 + ven_pin: GPIO14 -spi: - - id: spi_pn7160 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 - -pn7160_spi: - id: nfcc_pn7160 - cs_pin: 12 - irq_pin: 14 - ven_pin: 13 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_spi/test.esp8266-ard.yaml b/tests/components/pn7160_spi/test.esp8266-ard.yaml index fa356d5610..cbe27533a7 100644 --- a/tests/components/pn7160_spi/test.esp8266-ard.yaml +++ b/tests/components/pn7160_spi/test.esp8266-ard.yaml @@ -1,37 +1,9 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + irq_pin: GPIO15 + ven_pin: GPIO16 -spi: - - id: spi_pn7160 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 - -pn7160_spi: - id: nfcc_pn7160 - cs_pin: 15 - irq_pin: 4 - ven_pin: 5 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pn7160_spi/test.rp2040-ard.yaml b/tests/components/pn7160_spi/test.rp2040-ard.yaml index b36650032f..70cd2425fa 100644 --- a/tests/components/pn7160_spi/test.rp2040-ard.yaml +++ b/tests/components/pn7160_spi/test.rp2040-ard.yaml @@ -1,37 +1,9 @@ -esphome: - on_boot: - then: - - tag.set_clean_mode: nfcc_pn7160 - - tag.set_format_mode: nfcc_pn7160 - - tag.set_read_mode: nfcc_pn7160 - - tag.set_write_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.set_write_mode: nfcc_pn7160 - - tag.set_emulation_message: - message: https://www.home-assistant.io/tag/pulse - include_android_app_record: false - - tag.emulation_off: nfcc_pn7160 - - tag.emulation_on: nfcc_pn7160 - - tag.polling_off: nfcc_pn7160 - - tag.polling_on: nfcc_pn7160 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + irq_pin: GPIO15 + ven_pin: GPIO16 -spi: - - id: spi_pn7160 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 - -pn7160_spi: - id: nfcc_pn7160 - cs_pin: 6 - irq_pin: 7 - ven_pin: 5 - emulation_message: https://www.home-assistant.io/tag/pulse_ce - tag_ttl: 1000ms - on_tag: - - logger.log: "Tag" - on_tag_removed: - - logger.log: "Tag removed" - on_emulated_tag_scan: - - logger.log: "Tag emulated" +<<: !include common.yaml diff --git a/tests/components/pylontech/common.yaml b/tests/components/pylontech/common.yaml new file mode 100644 index 0000000000..6852685be7 --- /dev/null +++ b/tests/components/pylontech/common.yaml @@ -0,0 +1,48 @@ +uart: + - id: uart_pylontech0 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 115200 + +pylontech: + - id: pylontech0 + - id: pylontech1 + +sensor: + - platform: pylontech + pylontech_id: pylontech0 + battery: 1 + voltage: + id: pyl01_voltage + current: + id: pyl01_current + coulomb: + id: pyl01_soc + mos_temperature: + id: pyl01_mos_temperature + - platform: pylontech + pylontech_id: pylontech1 + battery: 1 + voltage: + id: pyl13_voltage + temperature_low: + id: pyl13_temperature_low + temperature_high: + id: pyl13_temperature_high + voltage_low: + id: pyl13_voltage_low + voltage_high: + id: pyl13_voltage_high + +text_sensor: + - platform: pylontech + pylontech_id: pylontech0 + battery: 1 + base_state: + id: pyl0_base_state + voltage_state: + id: pyl0_voltage_state + current_state: + id: pyl0_current_state + temperature_state: + id: pyl0_temperature_state diff --git a/tests/components/pylontech/test.esp32-ard.yaml b/tests/components/pylontech/test.esp32-ard.yaml index a4c168fb47..f486544afa 100644 --- a/tests/components/pylontech/test.esp32-ard.yaml +++ b/tests/components/pylontech/test.esp32-ard.yaml @@ -1,48 +1,5 @@ -uart: - - id: uart_pylontech0 - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -pylontech: - - id: pylontech0 - - id: pylontech1 - -sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - voltage: - id: pyl01_voltage - current: - id: pyl01_current - coulomb: - id: pyl01_soc - mos_temperature: - id: pyl01_mos_temperature - - platform: pylontech - pylontech_id: pylontech1 - battery: 1 - voltage: - id: pyl13_voltage - temperature_low: - id: pyl13_temperature_low - temperature_high: - id: pyl13_temperature_high - voltage_low: - id: pyl13_voltage_low - voltage_high: - id: pyl13_voltage_high - -text_sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - base_state: - id: pyl0_base_state - voltage_state: - id: pyl0_voltage_state - current_state: - id: pyl0_current_state - temperature_state: - id: pyl0_temperature_state +<<: !include common.yaml diff --git a/tests/components/pylontech/test.esp32-c3-ard.yaml b/tests/components/pylontech/test.esp32-c3-ard.yaml index f7ec493422..b516342f3b 100644 --- a/tests/components/pylontech/test.esp32-c3-ard.yaml +++ b/tests/components/pylontech/test.esp32-c3-ard.yaml @@ -1,48 +1,5 @@ -uart: - - id: uart_pylontech0 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -pylontech: - - id: pylontech0 - - id: pylontech1 - -sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - voltage: - id: pyl01_voltage - current: - id: pyl01_current - coulomb: - id: pyl01_soc - mos_temperature: - id: pyl01_mos_temperature - - platform: pylontech - pylontech_id: pylontech1 - battery: 1 - voltage: - id: pyl13_voltage - temperature_low: - id: pyl13_temperature_low - temperature_high: - id: pyl13_temperature_high - voltage_low: - id: pyl13_voltage_low - voltage_high: - id: pyl13_voltage_high - -text_sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - base_state: - id: pyl0_base_state - voltage_state: - id: pyl0_voltage_state - current_state: - id: pyl0_current_state - temperature_state: - id: pyl0_temperature_state +<<: !include common.yaml diff --git a/tests/components/pylontech/test.esp32-c3-idf.yaml b/tests/components/pylontech/test.esp32-c3-idf.yaml index f7ec493422..b516342f3b 100644 --- a/tests/components/pylontech/test.esp32-c3-idf.yaml +++ b/tests/components/pylontech/test.esp32-c3-idf.yaml @@ -1,48 +1,5 @@ -uart: - - id: uart_pylontech0 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -pylontech: - - id: pylontech0 - - id: pylontech1 - -sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - voltage: - id: pyl01_voltage - current: - id: pyl01_current - coulomb: - id: pyl01_soc - mos_temperature: - id: pyl01_mos_temperature - - platform: pylontech - pylontech_id: pylontech1 - battery: 1 - voltage: - id: pyl13_voltage - temperature_low: - id: pyl13_temperature_low - temperature_high: - id: pyl13_temperature_high - voltage_low: - id: pyl13_voltage_low - voltage_high: - id: pyl13_voltage_high - -text_sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - base_state: - id: pyl0_base_state - voltage_state: - id: pyl0_voltage_state - current_state: - id: pyl0_current_state - temperature_state: - id: pyl0_temperature_state +<<: !include common.yaml diff --git a/tests/components/pylontech/test.esp32-idf.yaml b/tests/components/pylontech/test.esp32-idf.yaml index a4c168fb47..f486544afa 100644 --- a/tests/components/pylontech/test.esp32-idf.yaml +++ b/tests/components/pylontech/test.esp32-idf.yaml @@ -1,48 +1,5 @@ -uart: - - id: uart_pylontech0 - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -pylontech: - - id: pylontech0 - - id: pylontech1 - -sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - voltage: - id: pyl01_voltage - current: - id: pyl01_current - coulomb: - id: pyl01_soc - mos_temperature: - id: pyl01_mos_temperature - - platform: pylontech - pylontech_id: pylontech1 - battery: 1 - voltage: - id: pyl13_voltage - temperature_low: - id: pyl13_temperature_low - temperature_high: - id: pyl13_temperature_high - voltage_low: - id: pyl13_voltage_low - voltage_high: - id: pyl13_voltage_high - -text_sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - base_state: - id: pyl0_base_state - voltage_state: - id: pyl0_voltage_state - current_state: - id: pyl0_current_state - temperature_state: - id: pyl0_temperature_state +<<: !include common.yaml diff --git a/tests/components/pylontech/test.esp8266-ard.yaml b/tests/components/pylontech/test.esp8266-ard.yaml index f7ec493422..b516342f3b 100644 --- a/tests/components/pylontech/test.esp8266-ard.yaml +++ b/tests/components/pylontech/test.esp8266-ard.yaml @@ -1,48 +1,5 @@ -uart: - - id: uart_pylontech0 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -pylontech: - - id: pylontech0 - - id: pylontech1 - -sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - voltage: - id: pyl01_voltage - current: - id: pyl01_current - coulomb: - id: pyl01_soc - mos_temperature: - id: pyl01_mos_temperature - - platform: pylontech - pylontech_id: pylontech1 - battery: 1 - voltage: - id: pyl13_voltage - temperature_low: - id: pyl13_temperature_low - temperature_high: - id: pyl13_temperature_high - voltage_low: - id: pyl13_voltage_low - voltage_high: - id: pyl13_voltage_high - -text_sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - base_state: - id: pyl0_base_state - voltage_state: - id: pyl0_voltage_state - current_state: - id: pyl0_current_state - temperature_state: - id: pyl0_temperature_state +<<: !include common.yaml diff --git a/tests/components/pylontech/test.rp2040-ard.yaml b/tests/components/pylontech/test.rp2040-ard.yaml index f7ec493422..b516342f3b 100644 --- a/tests/components/pylontech/test.rp2040-ard.yaml +++ b/tests/components/pylontech/test.rp2040-ard.yaml @@ -1,48 +1,5 @@ -uart: - - id: uart_pylontech0 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -pylontech: - - id: pylontech0 - - id: pylontech1 - -sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - voltage: - id: pyl01_voltage - current: - id: pyl01_current - coulomb: - id: pyl01_soc - mos_temperature: - id: pyl01_mos_temperature - - platform: pylontech - pylontech_id: pylontech1 - battery: 1 - voltage: - id: pyl13_voltage - temperature_low: - id: pyl13_temperature_low - temperature_high: - id: pyl13_temperature_high - voltage_low: - id: pyl13_voltage_low - voltage_high: - id: pyl13_voltage_high - -text_sensor: - - platform: pylontech - pylontech_id: pylontech0 - battery: 1 - base_state: - id: pyl0_base_state - voltage_state: - id: pyl0_voltage_state - current_state: - id: pyl0_current_state - temperature_state: - id: pyl0_temperature_state +<<: !include common.yaml diff --git a/tests/components/pzem004t/common.yaml b/tests/components/pzem004t/common.yaml new file mode 100644 index 0000000000..75f7f30fc9 --- /dev/null +++ b/tests/components/pzem004t/common.yaml @@ -0,0 +1,14 @@ +uart: + - id: uart_pzem004t + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 115200 + +sensor: + - platform: pzem004t + voltage: + name: PZEM004T Voltage + current: + name: PZEM004T Current + power: + name: PZEM004T Power diff --git a/tests/components/pzem004t/test.esp32-ard.yaml b/tests/components/pzem004t/test.esp32-ard.yaml index 23f2bd0eca..f486544afa 100644 --- a/tests/components/pzem004t/test.esp32-ard.yaml +++ b/tests/components/pzem004t/test.esp32-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_pzem004t - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: pzem004t - voltage: - name: PZEM004T Voltage - current: - name: PZEM004T Current - power: - name: PZEM004T Power +<<: !include common.yaml diff --git a/tests/components/pzem004t/test.esp32-c3-ard.yaml b/tests/components/pzem004t/test.esp32-c3-ard.yaml index b9c93f8761..b516342f3b 100644 --- a/tests/components/pzem004t/test.esp32-c3-ard.yaml +++ b/tests/components/pzem004t/test.esp32-c3-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_pzem004t - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pzem004t - voltage: - name: PZEM004T Voltage - current: - name: PZEM004T Current - power: - name: PZEM004T Power +<<: !include common.yaml diff --git a/tests/components/pzem004t/test.esp32-c3-idf.yaml b/tests/components/pzem004t/test.esp32-c3-idf.yaml index b9c93f8761..b516342f3b 100644 --- a/tests/components/pzem004t/test.esp32-c3-idf.yaml +++ b/tests/components/pzem004t/test.esp32-c3-idf.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_pzem004t - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pzem004t - voltage: - name: PZEM004T Voltage - current: - name: PZEM004T Current - power: - name: PZEM004T Power +<<: !include common.yaml diff --git a/tests/components/pzem004t/test.esp32-idf.yaml b/tests/components/pzem004t/test.esp32-idf.yaml index 23f2bd0eca..f486544afa 100644 --- a/tests/components/pzem004t/test.esp32-idf.yaml +++ b/tests/components/pzem004t/test.esp32-idf.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_pzem004t - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: pzem004t - voltage: - name: PZEM004T Voltage - current: - name: PZEM004T Current - power: - name: PZEM004T Power +<<: !include common.yaml diff --git a/tests/components/pzem004t/test.esp8266-ard.yaml b/tests/components/pzem004t/test.esp8266-ard.yaml index b9c93f8761..b516342f3b 100644 --- a/tests/components/pzem004t/test.esp8266-ard.yaml +++ b/tests/components/pzem004t/test.esp8266-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_pzem004t - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pzem004t - voltage: - name: PZEM004T Voltage - current: - name: PZEM004T Current - power: - name: PZEM004T Power +<<: !include common.yaml diff --git a/tests/components/pzem004t/test.rp2040-ard.yaml b/tests/components/pzem004t/test.rp2040-ard.yaml index b9c93f8761..b516342f3b 100644 --- a/tests/components/pzem004t/test.rp2040-ard.yaml +++ b/tests/components/pzem004t/test.rp2040-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_pzem004t - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: pzem004t - voltage: - name: PZEM004T Voltage - current: - name: PZEM004T Current - power: - name: PZEM004T Power +<<: !include common.yaml diff --git a/tests/components/pzemac/common.yaml b/tests/components/pzemac/common.yaml new file mode 100644 index 0000000000..e50f4ad2f2 --- /dev/null +++ b/tests/components/pzemac/common.yaml @@ -0,0 +1,28 @@ +esphome: + on_boot: + then: + - pzemac.reset_energy: pzemac1 + +uart: + - id: uart_pzemac + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +modbus: + +sensor: + - platform: pzemac + id: pzemac1 + voltage: + name: PZEMAC Voltage + current: + name: PZEMAC Current + power: + name: PZEMAC Power + energy: + name: PZEMAC Energy + frequency: + name: PZEMAC Frequency + power_factor: + name: PZEMAC Power Factor diff --git a/tests/components/pzemac/test.esp32-ard.yaml b/tests/components/pzemac/test.esp32-ard.yaml index ce431a6100..f486544afa 100644 --- a/tests/components/pzemac/test.esp32-ard.yaml +++ b/tests/components/pzemac/test.esp32-ard.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - pzemac.reset_energy: pzemac1 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -uart: - - id: uart_pzemac - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -modbus: - -sensor: - - platform: pzemac - id: pzemac1 - voltage: - name: PZEMAC Voltage - current: - name: PZEMAC Current - power: - name: PZEMAC Power - energy: - name: PZEMAC Energy - frequency: - name: PZEMAC Frequency - power_factor: - name: PZEMAC Power Factor +<<: !include common.yaml diff --git a/tests/components/pzemac/test.esp32-c3-ard.yaml b/tests/components/pzemac/test.esp32-c3-ard.yaml index 6d9abbebe9..b516342f3b 100644 --- a/tests/components/pzemac/test.esp32-c3-ard.yaml +++ b/tests/components/pzemac/test.esp32-c3-ard.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - pzemac.reset_energy: pzemac1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pzemac - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -modbus: - -sensor: - - platform: pzemac - id: pzemac1 - voltage: - name: PZEMAC Voltage - current: - name: PZEMAC Current - power: - name: PZEMAC Power - energy: - name: PZEMAC Energy - frequency: - name: PZEMAC Frequency - power_factor: - name: PZEMAC Power Factor +<<: !include common.yaml diff --git a/tests/components/pzemac/test.esp32-c3-idf.yaml b/tests/components/pzemac/test.esp32-c3-idf.yaml index 6d9abbebe9..b516342f3b 100644 --- a/tests/components/pzemac/test.esp32-c3-idf.yaml +++ b/tests/components/pzemac/test.esp32-c3-idf.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - pzemac.reset_energy: pzemac1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pzemac - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -modbus: - -sensor: - - platform: pzemac - id: pzemac1 - voltage: - name: PZEMAC Voltage - current: - name: PZEMAC Current - power: - name: PZEMAC Power - energy: - name: PZEMAC Energy - frequency: - name: PZEMAC Frequency - power_factor: - name: PZEMAC Power Factor +<<: !include common.yaml diff --git a/tests/components/pzemac/test.esp32-idf.yaml b/tests/components/pzemac/test.esp32-idf.yaml index ce431a6100..f486544afa 100644 --- a/tests/components/pzemac/test.esp32-idf.yaml +++ b/tests/components/pzemac/test.esp32-idf.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - pzemac.reset_energy: pzemac1 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -uart: - - id: uart_pzemac - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -modbus: - -sensor: - - platform: pzemac - id: pzemac1 - voltage: - name: PZEMAC Voltage - current: - name: PZEMAC Current - power: - name: PZEMAC Power - energy: - name: PZEMAC Energy - frequency: - name: PZEMAC Frequency - power_factor: - name: PZEMAC Power Factor +<<: !include common.yaml diff --git a/tests/components/pzemac/test.esp8266-ard.yaml b/tests/components/pzemac/test.esp8266-ard.yaml index 6d9abbebe9..b516342f3b 100644 --- a/tests/components/pzemac/test.esp8266-ard.yaml +++ b/tests/components/pzemac/test.esp8266-ard.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - pzemac.reset_energy: pzemac1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pzemac - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -modbus: - -sensor: - - platform: pzemac - id: pzemac1 - voltage: - name: PZEMAC Voltage - current: - name: PZEMAC Current - power: - name: PZEMAC Power - energy: - name: PZEMAC Energy - frequency: - name: PZEMAC Frequency - power_factor: - name: PZEMAC Power Factor +<<: !include common.yaml diff --git a/tests/components/pzemac/test.rp2040-ard.yaml b/tests/components/pzemac/test.rp2040-ard.yaml index 6d9abbebe9..b516342f3b 100644 --- a/tests/components/pzemac/test.rp2040-ard.yaml +++ b/tests/components/pzemac/test.rp2040-ard.yaml @@ -1,28 +1,5 @@ -esphome: - on_boot: - then: - - pzemac.reset_energy: pzemac1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pzemac - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -modbus: - -sensor: - - platform: pzemac - id: pzemac1 - voltage: - name: PZEMAC Voltage - current: - name: PZEMAC Current - power: - name: PZEMAC Power - energy: - name: PZEMAC Energy - frequency: - name: PZEMAC Frequency - power_factor: - name: PZEMAC Power Factor +<<: !include common.yaml diff --git a/tests/components/pzemdc/common.yaml b/tests/components/pzemdc/common.yaml new file mode 100644 index 0000000000..db1868d682 --- /dev/null +++ b/tests/components/pzemdc/common.yaml @@ -0,0 +1,23 @@ +esphome: + on_boot: + then: + - pzemdc.reset_energy: pzemdc1 + +uart: + - id: uart_pzemdc + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + stop_bits: 2 + +sensor: + - platform: pzemdc + id: pzemdc1 + voltage: + name: PZEMDC Voltage + current: + name: PZEMDC Current + power: + name: PZEMDC Power + energy: + name: PZEMDC Energy diff --git a/tests/components/pzemdc/test.esp32-ard.yaml b/tests/components/pzemdc/test.esp32-ard.yaml index 9cc61137de..f486544afa 100644 --- a/tests/components/pzemdc/test.esp32-ard.yaml +++ b/tests/components/pzemdc/test.esp32-ard.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - pzemdc.reset_energy: pzemdc1 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -uart: - - id: uart_pzemdc - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - stop_bits: 2 - -sensor: - - platform: pzemdc - id: pzemdc1 - voltage: - name: PZEMDC Voltage - current: - name: PZEMDC Current - power: - name: PZEMDC Power - energy: - name: PZEMDC Energy +<<: !include common.yaml diff --git a/tests/components/pzemdc/test.esp32-c3-ard.yaml b/tests/components/pzemdc/test.esp32-c3-ard.yaml index 02114b781d..b516342f3b 100644 --- a/tests/components/pzemdc/test.esp32-c3-ard.yaml +++ b/tests/components/pzemdc/test.esp32-c3-ard.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - pzemdc.reset_energy: pzemdc1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pzemdc - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - stop_bits: 2 - -sensor: - - platform: pzemdc - id: pzemdc1 - voltage: - name: PZEMDC Voltage - current: - name: PZEMDC Current - power: - name: PZEMDC Power - energy: - name: PZEMDC Energy +<<: !include common.yaml diff --git a/tests/components/pzemdc/test.esp32-c3-idf.yaml b/tests/components/pzemdc/test.esp32-c3-idf.yaml index 02114b781d..b516342f3b 100644 --- a/tests/components/pzemdc/test.esp32-c3-idf.yaml +++ b/tests/components/pzemdc/test.esp32-c3-idf.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - pzemdc.reset_energy: pzemdc1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pzemdc - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - stop_bits: 2 - -sensor: - - platform: pzemdc - id: pzemdc1 - voltage: - name: PZEMDC Voltage - current: - name: PZEMDC Current - power: - name: PZEMDC Power - energy: - name: PZEMDC Energy +<<: !include common.yaml diff --git a/tests/components/pzemdc/test.esp32-idf.yaml b/tests/components/pzemdc/test.esp32-idf.yaml index 9cc61137de..f486544afa 100644 --- a/tests/components/pzemdc/test.esp32-idf.yaml +++ b/tests/components/pzemdc/test.esp32-idf.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - pzemdc.reset_energy: pzemdc1 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -uart: - - id: uart_pzemdc - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - stop_bits: 2 - -sensor: - - platform: pzemdc - id: pzemdc1 - voltage: - name: PZEMDC Voltage - current: - name: PZEMDC Current - power: - name: PZEMDC Power - energy: - name: PZEMDC Energy +<<: !include common.yaml diff --git a/tests/components/pzemdc/test.esp8266-ard.yaml b/tests/components/pzemdc/test.esp8266-ard.yaml index 02114b781d..b516342f3b 100644 --- a/tests/components/pzemdc/test.esp8266-ard.yaml +++ b/tests/components/pzemdc/test.esp8266-ard.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - pzemdc.reset_energy: pzemdc1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pzemdc - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - stop_bits: 2 - -sensor: - - platform: pzemdc - id: pzemdc1 - voltage: - name: PZEMDC Voltage - current: - name: PZEMDC Current - power: - name: PZEMDC Power - energy: - name: PZEMDC Energy +<<: !include common.yaml diff --git a/tests/components/pzemdc/test.rp2040-ard.yaml b/tests/components/pzemdc/test.rp2040-ard.yaml index 02114b781d..b516342f3b 100644 --- a/tests/components/pzemdc/test.rp2040-ard.yaml +++ b/tests/components/pzemdc/test.rp2040-ard.yaml @@ -1,23 +1,5 @@ -esphome: - on_boot: - then: - - pzemdc.reset_energy: pzemdc1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_pzemdc - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - stop_bits: 2 - -sensor: - - platform: pzemdc - id: pzemdc1 - voltage: - name: PZEMDC Voltage - current: - name: PZEMDC Current - power: - name: PZEMDC Power - energy: - name: PZEMDC Energy +<<: !include common.yaml From bf6874b52eca6033435f743f9a896977b790ea84 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 4 Feb 2025 20:37:22 -0600 Subject: [PATCH 161/194] [CI] Consolidate some tests (Q, R) (#8205) --- tests/components/qmc5883l/common.yaml | 21 ++++++++++ tests/components/qmc5883l/test.esp32-ard.yaml | 24 ++---------- .../qmc5883l/test.esp32-c3-ard.yaml | 24 ++---------- .../qmc5883l/test.esp32-c3-idf.yaml | 24 ++---------- tests/components/qmc5883l/test.esp32-idf.yaml | 24 ++---------- .../components/qmc5883l/test.esp8266-ard.yaml | 24 ++---------- .../components/qmc5883l/test.rp2040-ard.yaml | 24 ++---------- tests/components/qmp6988/common.yaml | 16 ++++++++ tests/components/qmp6988/test.esp32-ard.yaml | 19 ++-------- .../components/qmp6988/test.esp32-c3-ard.yaml | 19 ++-------- .../components/qmp6988/test.esp32-c3-idf.yaml | 19 ++-------- tests/components/qmp6988/test.esp32-idf.yaml | 19 ++-------- .../components/qmp6988/test.esp8266-ard.yaml | 19 ++-------- tests/components/qmp6988/test.rp2040-ard.yaml | 19 ++-------- tests/components/qr_code/common.yaml | 24 ++++++++++++ tests/components/qr_code/test.esp32-ard.yaml | 31 ++++----------- .../components/qr_code/test.esp32-c3-ard.yaml | 32 ++++------------ .../components/qr_code/test.esp32-c3-idf.yaml | 32 ++++------------ tests/components/qr_code/test.esp32-idf.yaml | 31 ++++----------- .../components/qr_code/test.esp8266-ard.yaml | 32 ++++------------ tests/components/qr_code/test.rp2040-ard.yaml | 32 ++++------------ tests/components/qwiic_pir/common.yaml | 8 ++++ .../components/qwiic_pir/test.esp32-ard.yaml | 11 ++---- .../qwiic_pir/test.esp32-c3-ard.yaml | 11 ++---- .../qwiic_pir/test.esp32-c3-idf.yaml | 11 ++---- .../components/qwiic_pir/test.esp32-idf.yaml | 11 ++---- .../qwiic_pir/test.esp8266-ard.yaml | 11 ++---- .../components/qwiic_pir/test.rp2040-ard.yaml | 11 ++---- tests/components/rc522_i2c/common.yaml | 17 +++++++++ .../components/rc522_i2c/test.esp32-ard.yaml | 20 ++-------- .../rc522_i2c/test.esp32-c3-ard.yaml | 20 ++-------- .../rc522_i2c/test.esp32-c3-idf.yaml | 20 ++-------- .../components/rc522_i2c/test.esp32-idf.yaml | 20 ++-------- .../rc522_i2c/test.esp8266-ard.yaml | 20 ++-------- .../components/rc522_i2c/test.rp2040-ard.yaml | 20 ++-------- tests/components/rc522_spi/common.yaml | 15 ++++++++ .../components/rc522_spi/test.esp32-ard.yaml | 20 +++------- .../rc522_spi/test.esp32-c3-ard.yaml | 20 +++------- .../rc522_spi/test.esp32-c3-idf.yaml | 20 +++------- .../components/rc522_spi/test.esp32-idf.yaml | 20 +++------- .../rc522_spi/test.esp8266-ard.yaml | 20 +++------- .../components/rc522_spi/test.rp2040-ard.yaml | 20 +++------- tests/components/rdm6300/common.yaml | 12 ++++++ tests/components/rdm6300/test.esp32-ard.yaml | 15 ++------ .../components/rdm6300/test.esp32-c3-ard.yaml | 15 ++------ .../components/rdm6300/test.esp32-c3-idf.yaml | 15 ++------ tests/components/rdm6300/test.esp32-idf.yaml | 15 ++------ .../components/rdm6300/test.esp8266-ard.yaml | 15 ++------ tests/components/rdm6300/test.rp2040-ard.yaml | 15 ++------ tests/components/resistance/common.yaml | 11 ++++++ .../components/resistance/test.esp32-ard.yaml | 16 ++------ .../resistance/test.esp32-c3-ard.yaml | 16 ++------ .../resistance/test.esp32-c3-idf.yaml | 4 ++ .../components/resistance/test.esp32-idf.yaml | 16 ++------ .../resistance/test.esp32-s2-ard.yaml | 16 ++------ .../resistance/test.esp32-s2-idf.yaml | 4 ++ .../resistance/test.esp32-s3-ard.yaml | 16 ++------ .../resistance/test.esp32-s3-idf.yaml | 4 ++ .../resistance/test.esp8266-ard.yaml | 15 ++------ .../resistance/test.rp2040-ard.yaml | 16 ++------ tests/components/rf_bridge/common.yaml | 35 +++++++++++++++++ .../components/rf_bridge/test.esp32-ard.yaml | 38 ++----------------- .../rf_bridge/test.esp32-c3-ard.yaml | 38 ++----------------- .../rf_bridge/test.esp32-c3-idf.yaml | 38 ++----------------- .../components/rf_bridge/test.esp32-idf.yaml | 38 ++----------------- .../rf_bridge/test.esp8266-ard.yaml | 38 ++----------------- .../components/rf_bridge/test.rp2040-ard.yaml | 38 ++----------------- tests/components/rgb/common.yaml | 18 +++++++++ tests/components/rgb/test.esp32-ard.yaml | 23 +++-------- tests/components/rgb/test.esp32-c3-ard.yaml | 23 +++-------- tests/components/rgb/test.esp32-c3-idf.yaml | 23 +++-------- tests/components/rgb/test.esp32-idf.yaml | 23 +++-------- tests/components/rgb/test.esp8266-ard.yaml | 23 +++-------- tests/components/rgb/test.rp2040-ard.yaml | 23 +++-------- tests/components/rgbct/common.yaml | 28 ++++++++++++++ tests/components/rgbct/test.esp32-ard.yaml | 35 ++++------------- tests/components/rgbct/test.esp32-c3-ard.yaml | 35 ++++------------- tests/components/rgbct/test.esp32-c3-idf.yaml | 35 ++++------------- tests/components/rgbct/test.esp32-idf.yaml | 35 ++++------------- tests/components/rgbct/test.esp8266-ard.yaml | 35 ++++------------- tests/components/rgbct/test.rp2040-ard.yaml | 35 ++++------------- tests/components/rgbw/common.yaml | 22 +++++++++++ tests/components/rgbw/test.esp32-ard.yaml | 28 ++++---------- tests/components/rgbw/test.esp32-c3-ard.yaml | 28 ++++---------- tests/components/rgbw/test.esp32-c3-idf.yaml | 28 ++++---------- tests/components/rgbw/test.esp32-idf.yaml | 28 ++++---------- tests/components/rgbw/test.esp8266-ard.yaml | 28 ++++---------- tests/components/rgbw/test.rp2040-ard.yaml | 28 ++++---------- tests/components/rgbww/common.yaml | 28 ++++++++++++++ tests/components/rgbww/test.esp32-ard.yaml | 35 ++++------------- tests/components/rgbww/test.esp32-c3-ard.yaml | 35 ++++------------- tests/components/rgbww/test.esp32-c3-idf.yaml | 35 ++++------------- tests/components/rgbww/test.esp32-idf.yaml | 35 ++++------------- tests/components/rgbww/test.esp8266-ard.yaml | 35 ++++------------- tests/components/rgbww/test.rp2040-ard.yaml | 35 ++++------------- tests/components/rotary_encoder/common.yaml | 25 ++++++++++++ .../rotary_encoder/test.esp32-ard.yaml | 31 +++------------ .../rotary_encoder/test.esp32-c3-ard.yaml | 31 +++------------ .../rotary_encoder/test.esp32-c3-idf.yaml | 31 +++------------ .../rotary_encoder/test.esp32-idf.yaml | 31 +++------------ .../rotary_encoder/test.esp8266-ard.yaml | 31 +++------------ .../rotary_encoder/test.rp2040-ard.yaml | 31 +++------------ tests/components/rtttl/common.yaml | 15 ++++++++ tests/components/rtttl/test.esp32-ard.yaml | 19 ++-------- tests/components/rtttl/test.esp32-c3-ard.yaml | 19 ++-------- tests/components/rtttl/test.esp32-c3-idf.yaml | 19 ++-------- tests/components/rtttl/test.esp32-idf.yaml | 19 ++-------- tests/components/rtttl/test.esp8266-ard.yaml | 18 ++------- tests/components/rtttl/test.rp2040-ard.yaml | 18 ++------- 109 files changed, 795 insertions(+), 1719 deletions(-) create mode 100644 tests/components/qmc5883l/common.yaml create mode 100644 tests/components/qmp6988/common.yaml create mode 100644 tests/components/qr_code/common.yaml create mode 100644 tests/components/qwiic_pir/common.yaml create mode 100644 tests/components/rc522_i2c/common.yaml create mode 100644 tests/components/rc522_spi/common.yaml create mode 100644 tests/components/rdm6300/common.yaml create mode 100644 tests/components/resistance/common.yaml create mode 100644 tests/components/resistance/test.esp32-c3-idf.yaml create mode 100644 tests/components/resistance/test.esp32-s2-idf.yaml create mode 100644 tests/components/resistance/test.esp32-s3-idf.yaml create mode 100644 tests/components/rf_bridge/common.yaml create mode 100644 tests/components/rgb/common.yaml create mode 100644 tests/components/rgbct/common.yaml create mode 100644 tests/components/rgbw/common.yaml create mode 100644 tests/components/rgbww/common.yaml create mode 100644 tests/components/rotary_encoder/common.yaml create mode 100644 tests/components/rtttl/common.yaml diff --git a/tests/components/qmc5883l/common.yaml b/tests/components/qmc5883l/common.yaml new file mode 100644 index 0000000000..5d8ac73b4f --- /dev/null +++ b/tests/components/qmc5883l/common.yaml @@ -0,0 +1,21 @@ +i2c: + - id: i2c_qmc5883l + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: qmc5883l + address: 0x0D + field_strength_x: + name: QMC5883L Field Strength X + field_strength_y: + name: QMC5883L Field Strength Y + field_strength_z: + name: QMC5883L Field Strength Z + heading: + name: QMC5883L Heading + temperature: + name: QMC5883L Temperature + range: 800uT + oversampling: 256x + update_interval: 15s diff --git a/tests/components/qmc5883l/test.esp32-ard.yaml b/tests/components/qmc5883l/test.esp32-ard.yaml index 9acd391497..63c3bd6afd 100644 --- a/tests/components/qmc5883l/test.esp32-ard.yaml +++ b/tests/components/qmc5883l/test.esp32-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_qmc5883l - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: qmc5883l - address: 0x0D - field_strength_x: - name: QMC5883L Field Strength X - field_strength_y: - name: QMC5883L Field Strength Y - field_strength_z: - name: QMC5883L Field Strength Z - heading: - name: QMC5883L Heading - temperature: - name: QMC5883L Temperature - range: 800uT - oversampling: 256x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/qmc5883l/test.esp32-c3-ard.yaml b/tests/components/qmc5883l/test.esp32-c3-ard.yaml index 841bbd5d1e..ee2c29ca4e 100644 --- a/tests/components/qmc5883l/test.esp32-c3-ard.yaml +++ b/tests/components/qmc5883l/test.esp32-c3-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_qmc5883l - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: qmc5883l - address: 0x0D - field_strength_x: - name: QMC5883L Field Strength X - field_strength_y: - name: QMC5883L Field Strength Y - field_strength_z: - name: QMC5883L Field Strength Z - heading: - name: QMC5883L Heading - temperature: - name: QMC5883L Temperature - range: 800uT - oversampling: 256x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/qmc5883l/test.esp32-c3-idf.yaml b/tests/components/qmc5883l/test.esp32-c3-idf.yaml index 841bbd5d1e..ee2c29ca4e 100644 --- a/tests/components/qmc5883l/test.esp32-c3-idf.yaml +++ b/tests/components/qmc5883l/test.esp32-c3-idf.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_qmc5883l - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: qmc5883l - address: 0x0D - field_strength_x: - name: QMC5883L Field Strength X - field_strength_y: - name: QMC5883L Field Strength Y - field_strength_z: - name: QMC5883L Field Strength Z - heading: - name: QMC5883L Heading - temperature: - name: QMC5883L Temperature - range: 800uT - oversampling: 256x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/qmc5883l/test.esp32-idf.yaml b/tests/components/qmc5883l/test.esp32-idf.yaml index 9acd391497..63c3bd6afd 100644 --- a/tests/components/qmc5883l/test.esp32-idf.yaml +++ b/tests/components/qmc5883l/test.esp32-idf.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_qmc5883l - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: qmc5883l - address: 0x0D - field_strength_x: - name: QMC5883L Field Strength X - field_strength_y: - name: QMC5883L Field Strength Y - field_strength_z: - name: QMC5883L Field Strength Z - heading: - name: QMC5883L Heading - temperature: - name: QMC5883L Temperature - range: 800uT - oversampling: 256x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/qmc5883l/test.esp8266-ard.yaml b/tests/components/qmc5883l/test.esp8266-ard.yaml index 841bbd5d1e..ee2c29ca4e 100644 --- a/tests/components/qmc5883l/test.esp8266-ard.yaml +++ b/tests/components/qmc5883l/test.esp8266-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_qmc5883l - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: qmc5883l - address: 0x0D - field_strength_x: - name: QMC5883L Field Strength X - field_strength_y: - name: QMC5883L Field Strength Y - field_strength_z: - name: QMC5883L Field Strength Z - heading: - name: QMC5883L Heading - temperature: - name: QMC5883L Temperature - range: 800uT - oversampling: 256x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/qmc5883l/test.rp2040-ard.yaml b/tests/components/qmc5883l/test.rp2040-ard.yaml index 841bbd5d1e..ee2c29ca4e 100644 --- a/tests/components/qmc5883l/test.rp2040-ard.yaml +++ b/tests/components/qmc5883l/test.rp2040-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_qmc5883l - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: qmc5883l - address: 0x0D - field_strength_x: - name: QMC5883L Field Strength X - field_strength_y: - name: QMC5883L Field Strength Y - field_strength_z: - name: QMC5883L Field Strength Z - heading: - name: QMC5883L Heading - temperature: - name: QMC5883L Temperature - range: 800uT - oversampling: 256x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/qmp6988/common.yaml b/tests/components/qmp6988/common.yaml new file mode 100644 index 0000000000..cb4b221df0 --- /dev/null +++ b/tests/components/qmp6988/common.yaml @@ -0,0 +1,16 @@ +i2c: + - id: i2c_qmp6988 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: qmp6988 + temperature: + name: QMP6988 Temperature + oversampling: 32x + pressure: + name: QMP6988 Pressure + oversampling: 2x + address: 0x70 + update_interval: 30s + iir_filter: 16x diff --git a/tests/components/qmp6988/test.esp32-ard.yaml b/tests/components/qmp6988/test.esp32-ard.yaml index f3fbf75bbe..63c3bd6afd 100644 --- a/tests/components/qmp6988/test.esp32-ard.yaml +++ b/tests/components/qmp6988/test.esp32-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_qmp6988 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: qmp6988 - temperature: - name: QMP6988 Temperature - oversampling: 32x - pressure: - name: QMP6988 Pressure - oversampling: 2x - address: 0x70 - update_interval: 30s - iir_filter: 16x +<<: !include common.yaml diff --git a/tests/components/qmp6988/test.esp32-c3-ard.yaml b/tests/components/qmp6988/test.esp32-c3-ard.yaml index bcd87ae6b8..ee2c29ca4e 100644 --- a/tests/components/qmp6988/test.esp32-c3-ard.yaml +++ b/tests/components/qmp6988/test.esp32-c3-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_qmp6988 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: qmp6988 - temperature: - name: QMP6988 Temperature - oversampling: 32x - pressure: - name: QMP6988 Pressure - oversampling: 2x - address: 0x70 - update_interval: 30s - iir_filter: 16x +<<: !include common.yaml diff --git a/tests/components/qmp6988/test.esp32-c3-idf.yaml b/tests/components/qmp6988/test.esp32-c3-idf.yaml index bcd87ae6b8..ee2c29ca4e 100644 --- a/tests/components/qmp6988/test.esp32-c3-idf.yaml +++ b/tests/components/qmp6988/test.esp32-c3-idf.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_qmp6988 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: qmp6988 - temperature: - name: QMP6988 Temperature - oversampling: 32x - pressure: - name: QMP6988 Pressure - oversampling: 2x - address: 0x70 - update_interval: 30s - iir_filter: 16x +<<: !include common.yaml diff --git a/tests/components/qmp6988/test.esp32-idf.yaml b/tests/components/qmp6988/test.esp32-idf.yaml index f3fbf75bbe..63c3bd6afd 100644 --- a/tests/components/qmp6988/test.esp32-idf.yaml +++ b/tests/components/qmp6988/test.esp32-idf.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_qmp6988 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: qmp6988 - temperature: - name: QMP6988 Temperature - oversampling: 32x - pressure: - name: QMP6988 Pressure - oversampling: 2x - address: 0x70 - update_interval: 30s - iir_filter: 16x +<<: !include common.yaml diff --git a/tests/components/qmp6988/test.esp8266-ard.yaml b/tests/components/qmp6988/test.esp8266-ard.yaml index bcd87ae6b8..ee2c29ca4e 100644 --- a/tests/components/qmp6988/test.esp8266-ard.yaml +++ b/tests/components/qmp6988/test.esp8266-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_qmp6988 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: qmp6988 - temperature: - name: QMP6988 Temperature - oversampling: 32x - pressure: - name: QMP6988 Pressure - oversampling: 2x - address: 0x70 - update_interval: 30s - iir_filter: 16x +<<: !include common.yaml diff --git a/tests/components/qmp6988/test.rp2040-ard.yaml b/tests/components/qmp6988/test.rp2040-ard.yaml index bcd87ae6b8..ee2c29ca4e 100644 --- a/tests/components/qmp6988/test.rp2040-ard.yaml +++ b/tests/components/qmp6988/test.rp2040-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_qmp6988 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: qmp6988 - temperature: - name: QMP6988 Temperature - oversampling: 32x - pressure: - name: QMP6988 Pressure - oversampling: 2x - address: 0x70 - update_interval: 30s - iir_filter: 16x +<<: !include common.yaml diff --git a/tests/components/qr_code/common.yaml b/tests/components/qr_code/common.yaml new file mode 100644 index 0000000000..85c2ee076b --- /dev/null +++ b/tests/components/qr_code/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_main_lcd + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ili9xxx + id: main_lcd + model: ili9342 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + invert_colors: false + lambda: |- + // Draw a QR code in the center of the screen + auto scale = 2; + auto size = id(homepage_qr).get_size() * scale; + auto x = (it.get_width() / 2) - (size / 2); + auto y = (it.get_height() / 2) - (size / 2); + it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale); + +qr_code: + - id: homepage_qr + value: https://esphome.io/index.html diff --git a/tests/components/qr_code/test.esp32-ard.yaml b/tests/components/qr_code/test.esp32-ard.yaml index 8689d4d73f..bad5241f79 100644 --- a/tests/components/qr_code/test.esp32-ard.yaml +++ b/tests/components/qr_code/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_main_lcd - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ili9xxx - id: main_lcd - model: ili9342 - cs_pin: 12 - dc_pin: 13 - reset_pin: 21 - invert_colors: false - lambda: |- - // Draw a QR code in the center of the screen - auto scale = 2; - auto size = id(homepage_qr).get_size() * scale; - auto x = (it.get_width() / 2) - (size / 2); - auto y = (it.get_height() / 2) - (size / 2); - it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale); - -qr_code: - - id: homepage_qr - value: https://esphome.io/index.html +<<: !include common.yaml diff --git a/tests/components/qr_code/test.esp32-c3-ard.yaml b/tests/components/qr_code/test.esp32-c3-ard.yaml index 3690d2598c..c5c932c92c 100644 --- a/tests/components/qr_code/test.esp32-c3-ard.yaml +++ b/tests/components/qr_code/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_main_lcd - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ili9xxx - id: main_lcd - model: ili9342 - cs_pin: 8 - dc_pin: 9 - reset_pin: 10 - invert_colors: false - lambda: |- - // Draw a QR code in the center of the screen - auto scale = 2; - auto size = id(homepage_qr).get_size() * scale; - auto x = (it.get_width() / 2) - (size / 2); - auto y = (it.get_height() / 2) - (size / 2); - it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale); - -qr_code: - - id: homepage_qr - value: https://esphome.io/index.html +<<: !include common.yaml diff --git a/tests/components/qr_code/test.esp32-c3-idf.yaml b/tests/components/qr_code/test.esp32-c3-idf.yaml index 3690d2598c..c5c932c92c 100644 --- a/tests/components/qr_code/test.esp32-c3-idf.yaml +++ b/tests/components/qr_code/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_main_lcd - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ili9xxx - id: main_lcd - model: ili9342 - cs_pin: 8 - dc_pin: 9 - reset_pin: 10 - invert_colors: false - lambda: |- - // Draw a QR code in the center of the screen - auto scale = 2; - auto size = id(homepage_qr).get_size() * scale; - auto x = (it.get_width() / 2) - (size / 2); - auto y = (it.get_height() / 2) - (size / 2); - it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale); - -qr_code: - - id: homepage_qr - value: https://esphome.io/index.html +<<: !include common.yaml diff --git a/tests/components/qr_code/test.esp32-idf.yaml b/tests/components/qr_code/test.esp32-idf.yaml index 8689d4d73f..bad5241f79 100644 --- a/tests/components/qr_code/test.esp32-idf.yaml +++ b/tests/components/qr_code/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_main_lcd - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ili9xxx - id: main_lcd - model: ili9342 - cs_pin: 12 - dc_pin: 13 - reset_pin: 21 - invert_colors: false - lambda: |- - // Draw a QR code in the center of the screen - auto scale = 2; - auto size = id(homepage_qr).get_size() * scale; - auto x = (it.get_width() / 2) - (size / 2); - auto y = (it.get_height() / 2) - (size / 2); - it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale); - -qr_code: - - id: homepage_qr - value: https://esphome.io/index.html +<<: !include common.yaml diff --git a/tests/components/qr_code/test.esp8266-ard.yaml b/tests/components/qr_code/test.esp8266-ard.yaml index 02dc183440..3f023a60eb 100644 --- a/tests/components/qr_code/test.esp8266-ard.yaml +++ b/tests/components/qr_code/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_main_lcd - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ili9xxx - id: main_lcd - model: ili9342 - cs_pin: 5 - dc_pin: 15 - reset_pin: 16 - invert_colors: false - lambda: |- - // Draw a QR code in the center of the screen - auto scale = 2; - auto size = id(homepage_qr).get_size() * scale; - auto x = (it.get_width() / 2) - (size / 2); - auto y = (it.get_height() / 2) - (size / 2); - it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale); - -qr_code: - - id: homepage_qr - value: https://esphome.io/index.html +<<: !include common.yaml diff --git a/tests/components/qr_code/test.rp2040-ard.yaml b/tests/components/qr_code/test.rp2040-ard.yaml index 0d86f8d213..d7fd6ee294 100644 --- a/tests/components/qr_code/test.rp2040-ard.yaml +++ b/tests/components/qr_code/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_main_lcd - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ili9xxx - id: main_lcd - model: ili9342 - cs_pin: 20 - dc_pin: 21 - reset_pin: 22 - invert_colors: false - lambda: |- - // Draw a QR code in the center of the screen - auto scale = 2; - auto size = id(homepage_qr).get_size() * scale; - auto x = (it.get_width() / 2) - (size / 2); - auto y = (it.get_height() / 2) - (size / 2); - it.qr_code(x, y, id(homepage_qr), Color(255,255,255), scale); - -qr_code: - - id: homepage_qr - value: https://esphome.io/index.html +<<: !include common.yaml diff --git a/tests/components/qwiic_pir/common.yaml b/tests/components/qwiic_pir/common.yaml new file mode 100644 index 0000000000..d4b733405d --- /dev/null +++ b/tests/components/qwiic_pir/common.yaml @@ -0,0 +1,8 @@ +i2c: + - id: i2c_qwiic_pir + scl: ${scl_pin} + sda: ${sda_pin} + +binary_sensor: + - platform: qwiic_pir + name: Qwiic PIR Motion Sensor diff --git a/tests/components/qwiic_pir/test.esp32-ard.yaml b/tests/components/qwiic_pir/test.esp32-ard.yaml index da2e275cf3..63c3bd6afd 100644 --- a/tests/components/qwiic_pir/test.esp32-ard.yaml +++ b/tests/components/qwiic_pir/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_qwiic_pir - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -binary_sensor: - - platform: qwiic_pir - name: Qwiic PIR Motion Sensor +<<: !include common.yaml diff --git a/tests/components/qwiic_pir/test.esp32-c3-ard.yaml b/tests/components/qwiic_pir/test.esp32-c3-ard.yaml index ad52ac91c5..ee2c29ca4e 100644 --- a/tests/components/qwiic_pir/test.esp32-c3-ard.yaml +++ b/tests/components/qwiic_pir/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_qwiic_pir - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -binary_sensor: - - platform: qwiic_pir - name: Qwiic PIR Motion Sensor +<<: !include common.yaml diff --git a/tests/components/qwiic_pir/test.esp32-c3-idf.yaml b/tests/components/qwiic_pir/test.esp32-c3-idf.yaml index ad52ac91c5..ee2c29ca4e 100644 --- a/tests/components/qwiic_pir/test.esp32-c3-idf.yaml +++ b/tests/components/qwiic_pir/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_qwiic_pir - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -binary_sensor: - - platform: qwiic_pir - name: Qwiic PIR Motion Sensor +<<: !include common.yaml diff --git a/tests/components/qwiic_pir/test.esp32-idf.yaml b/tests/components/qwiic_pir/test.esp32-idf.yaml index da2e275cf3..63c3bd6afd 100644 --- a/tests/components/qwiic_pir/test.esp32-idf.yaml +++ b/tests/components/qwiic_pir/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_qwiic_pir - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -binary_sensor: - - platform: qwiic_pir - name: Qwiic PIR Motion Sensor +<<: !include common.yaml diff --git a/tests/components/qwiic_pir/test.esp8266-ard.yaml b/tests/components/qwiic_pir/test.esp8266-ard.yaml index ad52ac91c5..ee2c29ca4e 100644 --- a/tests/components/qwiic_pir/test.esp8266-ard.yaml +++ b/tests/components/qwiic_pir/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_qwiic_pir - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -binary_sensor: - - platform: qwiic_pir - name: Qwiic PIR Motion Sensor +<<: !include common.yaml diff --git a/tests/components/qwiic_pir/test.rp2040-ard.yaml b/tests/components/qwiic_pir/test.rp2040-ard.yaml index ad52ac91c5..ee2c29ca4e 100644 --- a/tests/components/qwiic_pir/test.rp2040-ard.yaml +++ b/tests/components/qwiic_pir/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_qwiic_pir - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -binary_sensor: - - platform: qwiic_pir - name: Qwiic PIR Motion Sensor +<<: !include common.yaml diff --git a/tests/components/rc522_i2c/common.yaml b/tests/components/rc522_i2c/common.yaml new file mode 100644 index 0000000000..b8b7a41bc7 --- /dev/null +++ b/tests/components/rc522_i2c/common.yaml @@ -0,0 +1,17 @@ +i2c: + - id: i2c_rc522 + scl: ${scl_pin} + sda: ${sda_pin} + +rc522_i2c: + - id: rc522_nfcc + update_interval: 1s + on_tag: + - lambda: |- + ESP_LOGD("main", "Found tag %s", x.c_str()); + +binary_sensor: + - platform: rc522 + rc522_id: rc522_nfcc + name: RC522 NFC Tag + uid: 74-10-37-94 diff --git a/tests/components/rc522_i2c/test.esp32-ard.yaml b/tests/components/rc522_i2c/test.esp32-ard.yaml index 69b7d892a4..63c3bd6afd 100644 --- a/tests/components/rc522_i2c/test.esp32-ard.yaml +++ b/tests/components/rc522_i2c/test.esp32-ard.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_rc522 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -rc522_i2c: - - id: rc522_nfcc - update_interval: 1s - on_tag: - - lambda: |- - ESP_LOGD("main", "Found tag %s", x.c_str()); - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: RC522 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_i2c/test.esp32-c3-ard.yaml b/tests/components/rc522_i2c/test.esp32-c3-ard.yaml index 8c8819e257..ee2c29ca4e 100644 --- a/tests/components/rc522_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/rc522_i2c/test.esp32-c3-ard.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_rc522 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -rc522_i2c: - - id: rc522_nfcc - update_interval: 1s - on_tag: - - lambda: |- - ESP_LOGD("main", "Found tag %s", x.c_str()); - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: RC522 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_i2c/test.esp32-c3-idf.yaml b/tests/components/rc522_i2c/test.esp32-c3-idf.yaml index 8c8819e257..ee2c29ca4e 100644 --- a/tests/components/rc522_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/rc522_i2c/test.esp32-c3-idf.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_rc522 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -rc522_i2c: - - id: rc522_nfcc - update_interval: 1s - on_tag: - - lambda: |- - ESP_LOGD("main", "Found tag %s", x.c_str()); - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: RC522 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_i2c/test.esp32-idf.yaml b/tests/components/rc522_i2c/test.esp32-idf.yaml index 69b7d892a4..63c3bd6afd 100644 --- a/tests/components/rc522_i2c/test.esp32-idf.yaml +++ b/tests/components/rc522_i2c/test.esp32-idf.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_rc522 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -rc522_i2c: - - id: rc522_nfcc - update_interval: 1s - on_tag: - - lambda: |- - ESP_LOGD("main", "Found tag %s", x.c_str()); - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: RC522 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_i2c/test.esp8266-ard.yaml b/tests/components/rc522_i2c/test.esp8266-ard.yaml index 8c8819e257..ee2c29ca4e 100644 --- a/tests/components/rc522_i2c/test.esp8266-ard.yaml +++ b/tests/components/rc522_i2c/test.esp8266-ard.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_rc522 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -rc522_i2c: - - id: rc522_nfcc - update_interval: 1s - on_tag: - - lambda: |- - ESP_LOGD("main", "Found tag %s", x.c_str()); - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: RC522 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_i2c/test.rp2040-ard.yaml b/tests/components/rc522_i2c/test.rp2040-ard.yaml index 8c8819e257..ee2c29ca4e 100644 --- a/tests/components/rc522_i2c/test.rp2040-ard.yaml +++ b/tests/components/rc522_i2c/test.rp2040-ard.yaml @@ -1,17 +1,5 @@ -i2c: - - id: i2c_rc522 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -rc522_i2c: - - id: rc522_nfcc - update_interval: 1s - on_tag: - - lambda: |- - ESP_LOGD("main", "Found tag %s", x.c_str()); - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: RC522 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_spi/common.yaml b/tests/components/rc522_spi/common.yaml new file mode 100644 index 0000000000..5c42858993 --- /dev/null +++ b/tests/components/rc522_spi/common.yaml @@ -0,0 +1,15 @@ +spi: + - id: spi_rc522 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +rc522_spi: + id: rc522_nfcc + cs_pin: ${cs_pin} + +binary_sensor: + - platform: rc522 + rc522_id: rc522_nfcc + name: PN532 NFC Tag + uid: 74-10-37-94 diff --git a/tests/components/rc522_spi/test.esp32-ard.yaml b/tests/components/rc522_spi/test.esp32-ard.yaml index 5c0b698a08..54e027a614 100644 --- a/tests/components/rc522_spi/test.esp32-ard.yaml +++ b/tests/components/rc522_spi/test.esp32-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_rc522 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -rc522_spi: - id: rc522_nfcc - cs_pin: 12 - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_spi/test.esp32-c3-ard.yaml b/tests/components/rc522_spi/test.esp32-c3-ard.yaml index 8bcab84700..2415ba5dc6 100644 --- a/tests/components/rc522_spi/test.esp32-c3-ard.yaml +++ b/tests/components/rc522_spi/test.esp32-c3-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_rc522 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -rc522_spi: - id: rc522_nfcc - cs_pin: 4 - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_spi/test.esp32-c3-idf.yaml b/tests/components/rc522_spi/test.esp32-c3-idf.yaml index 8bcab84700..2415ba5dc6 100644 --- a/tests/components/rc522_spi/test.esp32-c3-idf.yaml +++ b/tests/components/rc522_spi/test.esp32-c3-idf.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_rc522 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -rc522_spi: - id: rc522_nfcc - cs_pin: 4 - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_spi/test.esp32-idf.yaml b/tests/components/rc522_spi/test.esp32-idf.yaml index 5c0b698a08..54e027a614 100644 --- a/tests/components/rc522_spi/test.esp32-idf.yaml +++ b/tests/components/rc522_spi/test.esp32-idf.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_rc522 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + cs_pin: GPIO5 -rc522_spi: - id: rc522_nfcc - cs_pin: 12 - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_spi/test.esp8266-ard.yaml b/tests/components/rc522_spi/test.esp8266-ard.yaml index 3c33311266..dbd158d030 100644 --- a/tests/components/rc522_spi/test.esp8266-ard.yaml +++ b/tests/components/rc522_spi/test.esp8266-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_rc522 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO15 -rc522_spi: - id: rc522_nfcc - cs_pin: 15 - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rc522_spi/test.rp2040-ard.yaml b/tests/components/rc522_spi/test.rp2040-ard.yaml index ed2827dbb9..f6c3f1eeca 100644 --- a/tests/components/rc522_spi/test.rp2040-ard.yaml +++ b/tests/components/rc522_spi/test.rp2040-ard.yaml @@ -1,15 +1,7 @@ -spi: - - id: spi_rc522 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -rc522_spi: - id: rc522_nfcc - cs_pin: 6 - -binary_sensor: - - platform: rc522 - rc522_id: rc522_nfcc - name: PN532 NFC Tag - uid: 74-10-37-94 +<<: !include common.yaml diff --git a/tests/components/rdm6300/common.yaml b/tests/components/rdm6300/common.yaml new file mode 100644 index 0000000000..118a295471 --- /dev/null +++ b/tests/components/rdm6300/common.yaml @@ -0,0 +1,12 @@ +uart: + - id: uart_rdm6300 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 115200 + +rdm6300: + +binary_sensor: + - platform: rdm6300 + uid: 7616525 + name: RDM6300 NFC Tag diff --git a/tests/components/rdm6300/test.esp32-ard.yaml b/tests/components/rdm6300/test.esp32-ard.yaml index 4159248124..f486544afa 100644 --- a/tests/components/rdm6300/test.esp32-ard.yaml +++ b/tests/components/rdm6300/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_rdm6300 - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -rdm6300: - -binary_sensor: - - platform: rdm6300 - uid: 7616525 - name: RDM6300 NFC Tag +<<: !include common.yaml diff --git a/tests/components/rdm6300/test.esp32-c3-ard.yaml b/tests/components/rdm6300/test.esp32-c3-ard.yaml index b92fce06e2..b516342f3b 100644 --- a/tests/components/rdm6300/test.esp32-c3-ard.yaml +++ b/tests/components/rdm6300/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_rdm6300 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -rdm6300: - -binary_sensor: - - platform: rdm6300 - uid: 7616525 - name: RDM6300 NFC Tag +<<: !include common.yaml diff --git a/tests/components/rdm6300/test.esp32-c3-idf.yaml b/tests/components/rdm6300/test.esp32-c3-idf.yaml index b92fce06e2..b516342f3b 100644 --- a/tests/components/rdm6300/test.esp32-c3-idf.yaml +++ b/tests/components/rdm6300/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_rdm6300 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -rdm6300: - -binary_sensor: - - platform: rdm6300 - uid: 7616525 - name: RDM6300 NFC Tag +<<: !include common.yaml diff --git a/tests/components/rdm6300/test.esp32-idf.yaml b/tests/components/rdm6300/test.esp32-idf.yaml index 4159248124..f486544afa 100644 --- a/tests/components/rdm6300/test.esp32-idf.yaml +++ b/tests/components/rdm6300/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_rdm6300 - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -rdm6300: - -binary_sensor: - - platform: rdm6300 - uid: 7616525 - name: RDM6300 NFC Tag +<<: !include common.yaml diff --git a/tests/components/rdm6300/test.esp8266-ard.yaml b/tests/components/rdm6300/test.esp8266-ard.yaml index b92fce06e2..b516342f3b 100644 --- a/tests/components/rdm6300/test.esp8266-ard.yaml +++ b/tests/components/rdm6300/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_rdm6300 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -rdm6300: - -binary_sensor: - - platform: rdm6300 - uid: 7616525 - name: RDM6300 NFC Tag +<<: !include common.yaml diff --git a/tests/components/rdm6300/test.rp2040-ard.yaml b/tests/components/rdm6300/test.rp2040-ard.yaml index b92fce06e2..b516342f3b 100644 --- a/tests/components/rdm6300/test.rp2040-ard.yaml +++ b/tests/components/rdm6300/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_rdm6300 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -rdm6300: - -binary_sensor: - - platform: rdm6300 - uid: 7616525 - name: RDM6300 NFC Tag +<<: !include common.yaml diff --git a/tests/components/resistance/common.yaml b/tests/components/resistance/common.yaml new file mode 100644 index 0000000000..b3eec49548 --- /dev/null +++ b/tests/components/resistance/common.yaml @@ -0,0 +1,11 @@ +sensor: + - platform: adc + id: my_sensor + pin: ${pin} + - platform: resistance + sensor: my_sensor + configuration: DOWNSTREAM + resistor: 10kΩ + reference_voltage: 3.3V + name: Resistance + id: resist diff --git a/tests/components/resistance/test.esp32-ard.yaml b/tests/components/resistance/test.esp32-ard.yaml index b1ffc64972..06864605a6 100644 --- a/tests/components/resistance/test.esp32-ard.yaml +++ b/tests/components/resistance/test.esp32-ard.yaml @@ -1,12 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 32 - attenuation: 11db - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist +substitutions: + pin: GPIO32 + +<<: !include common.yaml diff --git a/tests/components/resistance/test.esp32-c3-ard.yaml b/tests/components/resistance/test.esp32-c3-ard.yaml index 84e23d5115..37fb325f4a 100644 --- a/tests/components/resistance/test.esp32-c3-ard.yaml +++ b/tests/components/resistance/test.esp32-c3-ard.yaml @@ -1,12 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 4 - attenuation: 11db - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist +substitutions: + pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/resistance/test.esp32-c3-idf.yaml b/tests/components/resistance/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..37fb325f4a --- /dev/null +++ b/tests/components/resistance/test.esp32-c3-idf.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/resistance/test.esp32-idf.yaml b/tests/components/resistance/test.esp32-idf.yaml index b1ffc64972..06864605a6 100644 --- a/tests/components/resistance/test.esp32-idf.yaml +++ b/tests/components/resistance/test.esp32-idf.yaml @@ -1,12 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 32 - attenuation: 11db - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist +substitutions: + pin: GPIO32 + +<<: !include common.yaml diff --git a/tests/components/resistance/test.esp32-s2-ard.yaml b/tests/components/resistance/test.esp32-s2-ard.yaml index 4ebd6b5c49..1910f325ae 100644 --- a/tests/components/resistance/test.esp32-s2-ard.yaml +++ b/tests/components/resistance/test.esp32-s2-ard.yaml @@ -1,12 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 1 - attenuation: 11db - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist +substitutions: + pin: GPIO1 + +<<: !include common.yaml diff --git a/tests/components/resistance/test.esp32-s2-idf.yaml b/tests/components/resistance/test.esp32-s2-idf.yaml new file mode 100644 index 0000000000..1910f325ae --- /dev/null +++ b/tests/components/resistance/test.esp32-s2-idf.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO1 + +<<: !include common.yaml diff --git a/tests/components/resistance/test.esp32-s3-ard.yaml b/tests/components/resistance/test.esp32-s3-ard.yaml index 4ebd6b5c49..1910f325ae 100644 --- a/tests/components/resistance/test.esp32-s3-ard.yaml +++ b/tests/components/resistance/test.esp32-s3-ard.yaml @@ -1,12 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: 1 - attenuation: 11db - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist +substitutions: + pin: GPIO1 + +<<: !include common.yaml diff --git a/tests/components/resistance/test.esp32-s3-idf.yaml b/tests/components/resistance/test.esp32-s3-idf.yaml new file mode 100644 index 0000000000..1910f325ae --- /dev/null +++ b/tests/components/resistance/test.esp32-s3-idf.yaml @@ -0,0 +1,4 @@ +substitutions: + pin: GPIO1 + +<<: !include common.yaml diff --git a/tests/components/resistance/test.esp8266-ard.yaml b/tests/components/resistance/test.esp8266-ard.yaml index f723f7c7c7..9e34247530 100644 --- a/tests/components/resistance/test.esp8266-ard.yaml +++ b/tests/components/resistance/test.esp8266-ard.yaml @@ -1,11 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - pin: VCC - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist +substitutions: + pin: VCC + +<<: !include common.yaml diff --git a/tests/components/resistance/test.rp2040-ard.yaml b/tests/components/resistance/test.rp2040-ard.yaml index 5cc643926a..9e34247530 100644 --- a/tests/components/resistance/test.rp2040-ard.yaml +++ b/tests/components/resistance/test.rp2040-ard.yaml @@ -1,12 +1,4 @@ -sensor: - - platform: adc - id: my_sensor - name: VSYS - pin: VCC - - platform: resistance - sensor: my_sensor - configuration: DOWNSTREAM - resistor: 10kΩ - reference_voltage: 3.3V - name: Resistance - id: resist +substitutions: + pin: VCC + +<<: !include common.yaml diff --git a/tests/components/rf_bridge/common.yaml b/tests/components/rf_bridge/common.yaml new file mode 100644 index 0000000000..eaadc4bb9c --- /dev/null +++ b/tests/components/rf_bridge/common.yaml @@ -0,0 +1,35 @@ +uart: + - id: uart_rf_bridge + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 115200 + +rf_bridge: + on_code_received: + - lambda: |- + uint32_t test; + test = data.sync; + test = data.low; + test = data.high; + test = data.code; + - rf_bridge.send_code: + sync: 0x1234 + low: 0x1234 + high: 0x1234 + code: 0x123456 + - rf_bridge.learn + on_advanced_code_received: + - lambda: |- + uint32_t test; + std::string test_code; + test = data.length; + test = data.protocol; + test_code = data.code; + - rf_bridge.start_advanced_sniffing: + - rf_bridge.stop_advanced_sniffing: + - rf_bridge.send_advanced_code: + length: 0x04 + protocol: 0x01 + code: "ABC123" + - rf_bridge.send_raw: + raw: "AAA5070008001000ABC12355" diff --git a/tests/components/rf_bridge/test.esp32-ard.yaml b/tests/components/rf_bridge/test.esp32-ard.yaml index 9ade7f0ac0..f486544afa 100644 --- a/tests/components/rf_bridge/test.esp32-ard.yaml +++ b/tests/components/rf_bridge/test.esp32-ard.yaml @@ -1,35 +1,5 @@ -uart: - - id: uart_rf_bridge - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -rf_bridge: - on_code_received: - - lambda: |- - uint32_t test; - test = data.sync; - test = data.low; - test = data.high; - test = data.code; - - rf_bridge.send_code: - sync: 0x1234 - low: 0x1234 - high: 0x1234 - code: 0x123456 - - rf_bridge.learn - on_advanced_code_received: - - lambda: |- - uint32_t test; - std::string test_code; - test = data.length; - test = data.protocol; - test_code = data.code; - - rf_bridge.start_advanced_sniffing: - - rf_bridge.stop_advanced_sniffing: - - rf_bridge.send_advanced_code: - length: 0x04 - protocol: 0x01 - code: "ABC123" - - rf_bridge.send_raw: - raw: "AAA5070008001000ABC12355" +<<: !include common.yaml diff --git a/tests/components/rf_bridge/test.esp32-c3-ard.yaml b/tests/components/rf_bridge/test.esp32-c3-ard.yaml index 95a7aa861a..b516342f3b 100644 --- a/tests/components/rf_bridge/test.esp32-c3-ard.yaml +++ b/tests/components/rf_bridge/test.esp32-c3-ard.yaml @@ -1,35 +1,5 @@ -uart: - - id: uart_rf_bridge - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -rf_bridge: - on_code_received: - - lambda: |- - uint32_t test; - test = data.sync; - test = data.low; - test = data.high; - test = data.code; - - rf_bridge.send_code: - sync: 0x1234 - low: 0x1234 - high: 0x1234 - code: 0x123456 - - rf_bridge.learn - on_advanced_code_received: - - lambda: |- - uint32_t test; - std::string test_code; - test = data.length; - test = data.protocol; - test_code = data.code; - - rf_bridge.start_advanced_sniffing: - - rf_bridge.stop_advanced_sniffing: - - rf_bridge.send_advanced_code: - length: 0x04 - protocol: 0x01 - code: "ABC123" - - rf_bridge.send_raw: - raw: "AAA5070008001000ABC12355" +<<: !include common.yaml diff --git a/tests/components/rf_bridge/test.esp32-c3-idf.yaml b/tests/components/rf_bridge/test.esp32-c3-idf.yaml index 95a7aa861a..b516342f3b 100644 --- a/tests/components/rf_bridge/test.esp32-c3-idf.yaml +++ b/tests/components/rf_bridge/test.esp32-c3-idf.yaml @@ -1,35 +1,5 @@ -uart: - - id: uart_rf_bridge - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -rf_bridge: - on_code_received: - - lambda: |- - uint32_t test; - test = data.sync; - test = data.low; - test = data.high; - test = data.code; - - rf_bridge.send_code: - sync: 0x1234 - low: 0x1234 - high: 0x1234 - code: 0x123456 - - rf_bridge.learn - on_advanced_code_received: - - lambda: |- - uint32_t test; - std::string test_code; - test = data.length; - test = data.protocol; - test_code = data.code; - - rf_bridge.start_advanced_sniffing: - - rf_bridge.stop_advanced_sniffing: - - rf_bridge.send_advanced_code: - length: 0x04 - protocol: 0x01 - code: "ABC123" - - rf_bridge.send_raw: - raw: "AAA5070008001000ABC12355" +<<: !include common.yaml diff --git a/tests/components/rf_bridge/test.esp32-idf.yaml b/tests/components/rf_bridge/test.esp32-idf.yaml index 9ade7f0ac0..f486544afa 100644 --- a/tests/components/rf_bridge/test.esp32-idf.yaml +++ b/tests/components/rf_bridge/test.esp32-idf.yaml @@ -1,35 +1,5 @@ -uart: - - id: uart_rf_bridge - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -rf_bridge: - on_code_received: - - lambda: |- - uint32_t test; - test = data.sync; - test = data.low; - test = data.high; - test = data.code; - - rf_bridge.send_code: - sync: 0x1234 - low: 0x1234 - high: 0x1234 - code: 0x123456 - - rf_bridge.learn - on_advanced_code_received: - - lambda: |- - uint32_t test; - std::string test_code; - test = data.length; - test = data.protocol; - test_code = data.code; - - rf_bridge.start_advanced_sniffing: - - rf_bridge.stop_advanced_sniffing: - - rf_bridge.send_advanced_code: - length: 0x04 - protocol: 0x01 - code: "ABC123" - - rf_bridge.send_raw: - raw: "AAA5070008001000ABC12355" +<<: !include common.yaml diff --git a/tests/components/rf_bridge/test.esp8266-ard.yaml b/tests/components/rf_bridge/test.esp8266-ard.yaml index 95a7aa861a..b516342f3b 100644 --- a/tests/components/rf_bridge/test.esp8266-ard.yaml +++ b/tests/components/rf_bridge/test.esp8266-ard.yaml @@ -1,35 +1,5 @@ -uart: - - id: uart_rf_bridge - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -rf_bridge: - on_code_received: - - lambda: |- - uint32_t test; - test = data.sync; - test = data.low; - test = data.high; - test = data.code; - - rf_bridge.send_code: - sync: 0x1234 - low: 0x1234 - high: 0x1234 - code: 0x123456 - - rf_bridge.learn - on_advanced_code_received: - - lambda: |- - uint32_t test; - std::string test_code; - test = data.length; - test = data.protocol; - test_code = data.code; - - rf_bridge.start_advanced_sniffing: - - rf_bridge.stop_advanced_sniffing: - - rf_bridge.send_advanced_code: - length: 0x04 - protocol: 0x01 - code: "ABC123" - - rf_bridge.send_raw: - raw: "AAA5070008001000ABC12355" +<<: !include common.yaml diff --git a/tests/components/rf_bridge/test.rp2040-ard.yaml b/tests/components/rf_bridge/test.rp2040-ard.yaml index 95a7aa861a..b516342f3b 100644 --- a/tests/components/rf_bridge/test.rp2040-ard.yaml +++ b/tests/components/rf_bridge/test.rp2040-ard.yaml @@ -1,35 +1,5 @@ -uart: - - id: uart_rf_bridge - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -rf_bridge: - on_code_received: - - lambda: |- - uint32_t test; - test = data.sync; - test = data.low; - test = data.high; - test = data.code; - - rf_bridge.send_code: - sync: 0x1234 - low: 0x1234 - high: 0x1234 - code: 0x123456 - - rf_bridge.learn - on_advanced_code_received: - - lambda: |- - uint32_t test; - std::string test_code; - test = data.length; - test = data.protocol; - test_code = data.code; - - rf_bridge.start_advanced_sniffing: - - rf_bridge.stop_advanced_sniffing: - - rf_bridge.send_advanced_code: - length: 0x04 - protocol: 0x01 - code: "ABC123" - - rf_bridge.send_raw: - raw: "AAA5070008001000ABC12355" +<<: !include common.yaml diff --git a/tests/components/rgb/common.yaml b/tests/components/rgb/common.yaml new file mode 100644 index 0000000000..9f25efa431 --- /dev/null +++ b/tests/components/rgb/common.yaml @@ -0,0 +1,18 @@ +output: + - platform: ${light_platform} + id: light_output_1 + pin: ${pin1} + - platform: ${light_platform} + id: light_output_2 + pin: ${pin2} + - platform: ${light_platform} + id: light_output_3 + pin: ${pin3} + +light: + - platform: rgb + name: RGB Light + id: rgb_light + red: light_output_1 + green: light_output_2 + blue: light_output_3 diff --git a/tests/components/rgb/test.esp32-ard.yaml b/tests/components/rgb/test.esp32-ard.yaml index 2173e718be..d78ccec952 100644 --- a/tests/components/rgb/test.esp32-ard.yaml +++ b/tests/components/rgb/test.esp32-ard.yaml @@ -1,18 +1,7 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 - - platform: ledc - id: light_output_3 - pin: 14 +substitutions: + light_platform: ledc + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 -light: - - platform: rgb - name: RGB Light - id: rgb_light - red: light_output_1 - green: light_output_2 - blue: light_output_3 +<<: !include common.yaml diff --git a/tests/components/rgb/test.esp32-c3-ard.yaml b/tests/components/rgb/test.esp32-c3-ard.yaml index 30ff1527b4..1fe4a4bb90 100644 --- a/tests/components/rgb/test.esp32-c3-ard.yaml +++ b/tests/components/rgb/test.esp32-c3-ard.yaml @@ -1,18 +1,7 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 - - platform: ledc - id: light_output_3 - pin: 3 +substitutions: + light_platform: ledc + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 -light: - - platform: rgb - name: RGB Light - id: rgb_light - red: light_output_1 - green: light_output_2 - blue: light_output_3 +<<: !include common.yaml diff --git a/tests/components/rgb/test.esp32-c3-idf.yaml b/tests/components/rgb/test.esp32-c3-idf.yaml index 30ff1527b4..1fe4a4bb90 100644 --- a/tests/components/rgb/test.esp32-c3-idf.yaml +++ b/tests/components/rgb/test.esp32-c3-idf.yaml @@ -1,18 +1,7 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 - - platform: ledc - id: light_output_3 - pin: 3 +substitutions: + light_platform: ledc + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 -light: - - platform: rgb - name: RGB Light - id: rgb_light - red: light_output_1 - green: light_output_2 - blue: light_output_3 +<<: !include common.yaml diff --git a/tests/components/rgb/test.esp32-idf.yaml b/tests/components/rgb/test.esp32-idf.yaml index 2173e718be..d78ccec952 100644 --- a/tests/components/rgb/test.esp32-idf.yaml +++ b/tests/components/rgb/test.esp32-idf.yaml @@ -1,18 +1,7 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 - - platform: ledc - id: light_output_3 - pin: 14 +substitutions: + light_platform: ledc + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 -light: - - platform: rgb - name: RGB Light - id: rgb_light - red: light_output_1 - green: light_output_2 - blue: light_output_3 +<<: !include common.yaml diff --git a/tests/components/rgb/test.esp8266-ard.yaml b/tests/components/rgb/test.esp8266-ard.yaml index 60c5a7e04f..3c9fa80f9e 100644 --- a/tests/components/rgb/test.esp8266-ard.yaml +++ b/tests/components/rgb/test.esp8266-ard.yaml @@ -1,18 +1,7 @@ -output: - - platform: esp8266_pwm - id: light_output_1 - pin: 12 - - platform: esp8266_pwm - id: light_output_2 - pin: 13 - - platform: esp8266_pwm - id: light_output_3 - pin: 14 +substitutions: + light_platform: esp8266_pwm + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 -light: - - platform: rgb - name: RGB Light - id: rgb_light - red: light_output_1 - green: light_output_2 - blue: light_output_3 +<<: !include common.yaml diff --git a/tests/components/rgb/test.rp2040-ard.yaml b/tests/components/rgb/test.rp2040-ard.yaml index fd6519707b..7d8e595f72 100644 --- a/tests/components/rgb/test.rp2040-ard.yaml +++ b/tests/components/rgb/test.rp2040-ard.yaml @@ -1,18 +1,7 @@ -output: - - platform: rp2040_pwm - id: light_output_1 - pin: 12 - - platform: rp2040_pwm - id: light_output_2 - pin: 13 - - platform: rp2040_pwm - id: light_output_3 - pin: 14 +substitutions: + light_platform: rp2040_pwm + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 -light: - - platform: rgb - name: RGB Light - id: rgb_light - red: light_output_1 - green: light_output_2 - blue: light_output_3 +<<: !include common.yaml diff --git a/tests/components/rgbct/common.yaml b/tests/components/rgbct/common.yaml new file mode 100644 index 0000000000..65bb248e95 --- /dev/null +++ b/tests/components/rgbct/common.yaml @@ -0,0 +1,28 @@ +output: + - platform: ${light_platform} + id: light_output_1 + pin: ${pin1} + - platform: ${light_platform} + id: light_output_2 + pin: ${pin2} + - platform: ${light_platform} + id: light_output_3 + pin: ${pin3} + - platform: ${light_platform} + id: light_output_4 + pin: ${pin4} + - platform: ${light_platform} + id: light_output_5 + pin: ${pin5} + +light: + - platform: rgbct + name: RGBCT Light + red: light_output_1 + green: light_output_2 + blue: light_output_3 + color_temperature: light_output_4 + white_brightness: light_output_5 + cold_white_color_temperature: 153 mireds + warm_white_color_temperature: 500 mireds + color_interlock: true diff --git a/tests/components/rgbct/test.esp32-ard.yaml b/tests/components/rgbct/test.esp32-ard.yaml index d9758c9ec7..1ecc626e9c 100644 --- a/tests/components/rgbct/test.esp32-ard.yaml +++ b/tests/components/rgbct/test.esp32-ard.yaml @@ -1,28 +1,9 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 - - platform: ledc - id: light_output_3 - pin: 14 - - platform: ledc - id: light_output_4 - pin: 15 - - platform: ledc - id: light_output_5 - pin: 16 +substitutions: + light_platform: ledc + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 + pin4: GPIO15 + pin5: GPIO16 -light: - - platform: rgbct - name: RGBCT Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - color_temperature: light_output_4 - white_brightness: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbct/test.esp32-c3-ard.yaml b/tests/components/rgbct/test.esp32-c3-ard.yaml index 426c4b8937..27a1fbca4d 100644 --- a/tests/components/rgbct/test.esp32-c3-ard.yaml +++ b/tests/components/rgbct/test.esp32-c3-ard.yaml @@ -1,28 +1,9 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 - - platform: ledc - id: light_output_3 - pin: 3 - - platform: ledc - id: light_output_4 - pin: 4 - - platform: ledc - id: light_output_5 - pin: 5 +substitutions: + light_platform: ledc + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 + pin4: GPIO5 + pin5: GPIO6 -light: - - platform: rgbct - name: RGBCT Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - color_temperature: light_output_4 - white_brightness: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbct/test.esp32-c3-idf.yaml b/tests/components/rgbct/test.esp32-c3-idf.yaml index 426c4b8937..27a1fbca4d 100644 --- a/tests/components/rgbct/test.esp32-c3-idf.yaml +++ b/tests/components/rgbct/test.esp32-c3-idf.yaml @@ -1,28 +1,9 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 - - platform: ledc - id: light_output_3 - pin: 3 - - platform: ledc - id: light_output_4 - pin: 4 - - platform: ledc - id: light_output_5 - pin: 5 +substitutions: + light_platform: ledc + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 + pin4: GPIO5 + pin5: GPIO6 -light: - - platform: rgbct - name: RGBCT Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - color_temperature: light_output_4 - white_brightness: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbct/test.esp32-idf.yaml b/tests/components/rgbct/test.esp32-idf.yaml index d9758c9ec7..1ecc626e9c 100644 --- a/tests/components/rgbct/test.esp32-idf.yaml +++ b/tests/components/rgbct/test.esp32-idf.yaml @@ -1,28 +1,9 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 - - platform: ledc - id: light_output_3 - pin: 14 - - platform: ledc - id: light_output_4 - pin: 15 - - platform: ledc - id: light_output_5 - pin: 16 +substitutions: + light_platform: ledc + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 + pin4: GPIO15 + pin5: GPIO16 -light: - - platform: rgbct - name: RGBCT Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - color_temperature: light_output_4 - white_brightness: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbct/test.esp8266-ard.yaml b/tests/components/rgbct/test.esp8266-ard.yaml index b7008c9ae3..4b66a5927f 100644 --- a/tests/components/rgbct/test.esp8266-ard.yaml +++ b/tests/components/rgbct/test.esp8266-ard.yaml @@ -1,28 +1,9 @@ -output: - - platform: esp8266_pwm - id: light_output_1 - pin: 12 - - platform: esp8266_pwm - id: light_output_2 - pin: 13 - - platform: esp8266_pwm - id: light_output_3 - pin: 14 - - platform: esp8266_pwm - id: light_output_4 - pin: 15 - - platform: esp8266_pwm - id: light_output_5 - pin: 16 +substitutions: + light_platform: esp8266_pwm + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 + pin4: GPIO15 + pin5: GPIO16 -light: - - platform: rgbct - name: RGBCT Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - color_temperature: light_output_4 - white_brightness: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbct/test.rp2040-ard.yaml b/tests/components/rgbct/test.rp2040-ard.yaml index e7e959b2a4..36be8b7711 100644 --- a/tests/components/rgbct/test.rp2040-ard.yaml +++ b/tests/components/rgbct/test.rp2040-ard.yaml @@ -1,28 +1,9 @@ -output: - - platform: rp2040_pwm - id: light_output_1 - pin: 12 - - platform: rp2040_pwm - id: light_output_2 - pin: 13 - - platform: rp2040_pwm - id: light_output_3 - pin: 14 - - platform: rp2040_pwm - id: light_output_4 - pin: 15 - - platform: rp2040_pwm - id: light_output_5 - pin: 16 +substitutions: + light_platform: rp2040_pwm + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 + pin4: GPIO5 + pin5: GPIO6 -light: - - platform: rgbct - name: RGBCT Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - color_temperature: light_output_4 - white_brightness: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbw/common.yaml b/tests/components/rgbw/common.yaml new file mode 100644 index 0000000000..b0f44869d3 --- /dev/null +++ b/tests/components/rgbw/common.yaml @@ -0,0 +1,22 @@ +output: + - platform: ${light_platform} + id: light_output_1 + pin: ${pin1} + - platform: ${light_platform} + id: light_output_2 + pin: ${pin2} + - platform: ${light_platform} + id: light_output_3 + pin: ${pin3} + - platform: ${light_platform} + id: light_output_4 + pin: ${pin4} + +light: + - platform: rgbw + name: RGBW Light + red: light_output_1 + green: light_output_2 + blue: light_output_3 + white: light_output_4 + color_interlock: true diff --git a/tests/components/rgbw/test.esp32-ard.yaml b/tests/components/rgbw/test.esp32-ard.yaml index 6e9e92a03c..ea8efd1a34 100644 --- a/tests/components/rgbw/test.esp32-ard.yaml +++ b/tests/components/rgbw/test.esp32-ard.yaml @@ -1,22 +1,8 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 - - platform: ledc - id: light_output_3 - pin: 14 - - platform: ledc - id: light_output_4 - pin: 15 +substitutions: + light_platform: ledc + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 + pin4: GPIO15 -light: - - platform: rgbw - name: RGBW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - white: light_output_4 - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbw/test.esp32-c3-ard.yaml b/tests/components/rgbw/test.esp32-c3-ard.yaml index c5d4fceb9d..b44734344e 100644 --- a/tests/components/rgbw/test.esp32-c3-ard.yaml +++ b/tests/components/rgbw/test.esp32-c3-ard.yaml @@ -1,22 +1,8 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 - - platform: ledc - id: light_output_3 - pin: 3 - - platform: ledc - id: light_output_4 - pin: 4 +substitutions: + light_platform: ledc + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 + pin4: GPIO5 -light: - - platform: rgbw - name: RGBW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - white: light_output_4 - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbw/test.esp32-c3-idf.yaml b/tests/components/rgbw/test.esp32-c3-idf.yaml index c5d4fceb9d..b44734344e 100644 --- a/tests/components/rgbw/test.esp32-c3-idf.yaml +++ b/tests/components/rgbw/test.esp32-c3-idf.yaml @@ -1,22 +1,8 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 - - platform: ledc - id: light_output_3 - pin: 3 - - platform: ledc - id: light_output_4 - pin: 4 +substitutions: + light_platform: ledc + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 + pin4: GPIO5 -light: - - platform: rgbw - name: RGBW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - white: light_output_4 - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbw/test.esp32-idf.yaml b/tests/components/rgbw/test.esp32-idf.yaml index 6e9e92a03c..ea8efd1a34 100644 --- a/tests/components/rgbw/test.esp32-idf.yaml +++ b/tests/components/rgbw/test.esp32-idf.yaml @@ -1,22 +1,8 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 - - platform: ledc - id: light_output_3 - pin: 14 - - platform: ledc - id: light_output_4 - pin: 15 +substitutions: + light_platform: ledc + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 + pin4: GPIO15 -light: - - platform: rgbw - name: RGBW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - white: light_output_4 - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbw/test.esp8266-ard.yaml b/tests/components/rgbw/test.esp8266-ard.yaml index 54098613e4..31d6805b4e 100644 --- a/tests/components/rgbw/test.esp8266-ard.yaml +++ b/tests/components/rgbw/test.esp8266-ard.yaml @@ -1,22 +1,8 @@ -output: - - platform: esp8266_pwm - id: light_output_1 - pin: 12 - - platform: esp8266_pwm - id: light_output_2 - pin: 13 - - platform: esp8266_pwm - id: light_output_3 - pin: 14 - - platform: esp8266_pwm - id: light_output_4 - pin: 15 +substitutions: + light_platform: esp8266_pwm + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 + pin4: GPIO15 -light: - - platform: rgbw - name: RGBW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - white: light_output_4 - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbw/test.rp2040-ard.yaml b/tests/components/rgbw/test.rp2040-ard.yaml index 6a4437b898..bd22aa46f3 100644 --- a/tests/components/rgbw/test.rp2040-ard.yaml +++ b/tests/components/rgbw/test.rp2040-ard.yaml @@ -1,22 +1,8 @@ -output: - - platform: rp2040_pwm - id: light_output_1 - pin: 12 - - platform: rp2040_pwm - id: light_output_2 - pin: 13 - - platform: rp2040_pwm - id: light_output_3 - pin: 14 - - platform: rp2040_pwm - id: light_output_4 - pin: 15 +substitutions: + light_platform: rp2040_pwm + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 + pin4: GPIO5 -light: - - platform: rgbw - name: RGBW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - white: light_output_4 - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbww/common.yaml b/tests/components/rgbww/common.yaml new file mode 100644 index 0000000000..0013960c10 --- /dev/null +++ b/tests/components/rgbww/common.yaml @@ -0,0 +1,28 @@ +output: + - platform: ${light_platform} + id: light_output_1 + pin: ${pin1} + - platform: ${light_platform} + id: light_output_2 + pin: ${pin2} + - platform: ${light_platform} + id: light_output_3 + pin: ${pin3} + - platform: ${light_platform} + id: light_output_4 + pin: ${pin4} + - platform: ${light_platform} + id: light_output_5 + pin: ${pin5} + +light: + - platform: rgbww + name: RGBWW Light + red: light_output_1 + green: light_output_2 + blue: light_output_3 + cold_white: light_output_4 + warm_white: light_output_5 + cold_white_color_temperature: 153 mireds + warm_white_color_temperature: 500 mireds + color_interlock: true diff --git a/tests/components/rgbww/test.esp32-ard.yaml b/tests/components/rgbww/test.esp32-ard.yaml index c24b6b7746..1ecc626e9c 100644 --- a/tests/components/rgbww/test.esp32-ard.yaml +++ b/tests/components/rgbww/test.esp32-ard.yaml @@ -1,28 +1,9 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 - - platform: ledc - id: light_output_3 - pin: 14 - - platform: ledc - id: light_output_4 - pin: 15 - - platform: ledc - id: light_output_5 - pin: 16 +substitutions: + light_platform: ledc + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 + pin4: GPIO15 + pin5: GPIO16 -light: - - platform: rgbww - name: RGBWW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - cold_white: light_output_4 - warm_white: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbww/test.esp32-c3-ard.yaml b/tests/components/rgbww/test.esp32-c3-ard.yaml index 49e9c7f331..27a1fbca4d 100644 --- a/tests/components/rgbww/test.esp32-c3-ard.yaml +++ b/tests/components/rgbww/test.esp32-c3-ard.yaml @@ -1,28 +1,9 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 - - platform: ledc - id: light_output_3 - pin: 3 - - platform: ledc - id: light_output_4 - pin: 4 - - platform: ledc - id: light_output_5 - pin: 5 +substitutions: + light_platform: ledc + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 + pin4: GPIO5 + pin5: GPIO6 -light: - - platform: rgbww - name: RGBWW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - cold_white: light_output_4 - warm_white: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbww/test.esp32-c3-idf.yaml b/tests/components/rgbww/test.esp32-c3-idf.yaml index 49e9c7f331..27a1fbca4d 100644 --- a/tests/components/rgbww/test.esp32-c3-idf.yaml +++ b/tests/components/rgbww/test.esp32-c3-idf.yaml @@ -1,28 +1,9 @@ -output: - - platform: ledc - id: light_output_1 - pin: 1 - - platform: ledc - id: light_output_2 - pin: 2 - - platform: ledc - id: light_output_3 - pin: 3 - - platform: ledc - id: light_output_4 - pin: 4 - - platform: ledc - id: light_output_5 - pin: 5 +substitutions: + light_platform: ledc + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 + pin4: GPIO5 + pin5: GPIO6 -light: - - platform: rgbww - name: RGBWW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - cold_white: light_output_4 - warm_white: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbww/test.esp32-idf.yaml b/tests/components/rgbww/test.esp32-idf.yaml index c24b6b7746..1ecc626e9c 100644 --- a/tests/components/rgbww/test.esp32-idf.yaml +++ b/tests/components/rgbww/test.esp32-idf.yaml @@ -1,28 +1,9 @@ -output: - - platform: ledc - id: light_output_1 - pin: 12 - - platform: ledc - id: light_output_2 - pin: 13 - - platform: ledc - id: light_output_3 - pin: 14 - - platform: ledc - id: light_output_4 - pin: 15 - - platform: ledc - id: light_output_5 - pin: 16 +substitutions: + light_platform: ledc + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 + pin4: GPIO15 + pin5: GPIO16 -light: - - platform: rgbww - name: RGBWW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - cold_white: light_output_4 - warm_white: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbww/test.esp8266-ard.yaml b/tests/components/rgbww/test.esp8266-ard.yaml index 4ea26e6526..4b66a5927f 100644 --- a/tests/components/rgbww/test.esp8266-ard.yaml +++ b/tests/components/rgbww/test.esp8266-ard.yaml @@ -1,28 +1,9 @@ -output: - - platform: esp8266_pwm - id: light_output_1 - pin: 12 - - platform: esp8266_pwm - id: light_output_2 - pin: 13 - - platform: esp8266_pwm - id: light_output_3 - pin: 14 - - platform: esp8266_pwm - id: light_output_4 - pin: 15 - - platform: esp8266_pwm - id: light_output_5 - pin: 16 +substitutions: + light_platform: esp8266_pwm + pin1: GPIO12 + pin2: GPIO13 + pin3: GPIO14 + pin4: GPIO15 + pin5: GPIO16 -light: - - platform: rgbww - name: RGBWW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - cold_white: light_output_4 - warm_white: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rgbww/test.rp2040-ard.yaml b/tests/components/rgbww/test.rp2040-ard.yaml index 0986f06e78..36be8b7711 100644 --- a/tests/components/rgbww/test.rp2040-ard.yaml +++ b/tests/components/rgbww/test.rp2040-ard.yaml @@ -1,28 +1,9 @@ -output: - - platform: rp2040_pwm - id: light_output_1 - pin: 12 - - platform: rp2040_pwm - id: light_output_2 - pin: 13 - - platform: rp2040_pwm - id: light_output_3 - pin: 14 - - platform: rp2040_pwm - id: light_output_4 - pin: 15 - - platform: rp2040_pwm - id: light_output_5 - pin: 16 +substitutions: + light_platform: rp2040_pwm + pin1: GPIO2 + pin2: GPIO3 + pin3: GPIO4 + pin4: GPIO5 + pin5: GPIO6 -light: - - platform: rgbww - name: RGBWW Light - red: light_output_1 - green: light_output_2 - blue: light_output_3 - cold_white: light_output_4 - warm_white: light_output_5 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - color_interlock: true +<<: !include common.yaml diff --git a/tests/components/rotary_encoder/common.yaml b/tests/components/rotary_encoder/common.yaml new file mode 100644 index 0000000000..57ffdab817 --- /dev/null +++ b/tests/components/rotary_encoder/common.yaml @@ -0,0 +1,25 @@ +sensor: + - platform: rotary_encoder + name: Rotary Encoder + id: rotary_encoder1 + pin_a: ${pin_a} + pin_b: ${pin_b} + pin_reset: ${pin_reset} + filters: + - or: + - debounce: 0.1s + - delta: 10 + resolution: 4 + min_value: -10 + max_value: 30 + on_value: + - sensor.rotary_encoder.set_value: + id: rotary_encoder1 + value: 10 + - sensor.rotary_encoder.set_value: + id: rotary_encoder1 + value: !lambda "return -1;" + on_clockwise: + - logger.log: Clockwise + on_anticlockwise: + - logger.log: Anticlockwise diff --git a/tests/components/rotary_encoder/test.esp32-ard.yaml b/tests/components/rotary_encoder/test.esp32-ard.yaml index da3843f82d..48a624aa37 100644 --- a/tests/components/rotary_encoder/test.esp32-ard.yaml +++ b/tests/components/rotary_encoder/test.esp32-ard.yaml @@ -1,25 +1,6 @@ -sensor: - - platform: rotary_encoder - name: Rotary Encoder - id: rotary_encoder1 - pin_a: 13 - pin_b: 14 - pin_reset: 15 - filters: - - or: - - debounce: 0.1s - - delta: 10 - resolution: 4 - min_value: -10 - max_value: 30 - on_value: - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: 10 - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: !lambda "return -1;" - on_clockwise: - - logger.log: Clockwise - on_anticlockwise: - - logger.log: Anticlockwise +substitutions: + pin_a: GPIO12 + pin_b: GPIO13 + pin_reset: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/rotary_encoder/test.esp32-c3-ard.yaml b/tests/components/rotary_encoder/test.esp32-c3-ard.yaml index 59f8b56abf..b71a454bdd 100644 --- a/tests/components/rotary_encoder/test.esp32-c3-ard.yaml +++ b/tests/components/rotary_encoder/test.esp32-c3-ard.yaml @@ -1,25 +1,6 @@ -sensor: - - platform: rotary_encoder - name: Rotary Encoder - id: rotary_encoder1 - pin_a: 3 - pin_b: 4 - pin_reset: 5 - filters: - - or: - - debounce: 0.1s - - delta: 10 - resolution: 4 - min_value: -10 - max_value: 30 - on_value: - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: 10 - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: !lambda "return -1;" - on_clockwise: - - logger.log: Clockwise - on_anticlockwise: - - logger.log: Anticlockwise +substitutions: + pin_a: GPIO2 + pin_b: GPIO3 + pin_reset: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/rotary_encoder/test.esp32-c3-idf.yaml b/tests/components/rotary_encoder/test.esp32-c3-idf.yaml index 59f8b56abf..b71a454bdd 100644 --- a/tests/components/rotary_encoder/test.esp32-c3-idf.yaml +++ b/tests/components/rotary_encoder/test.esp32-c3-idf.yaml @@ -1,25 +1,6 @@ -sensor: - - platform: rotary_encoder - name: Rotary Encoder - id: rotary_encoder1 - pin_a: 3 - pin_b: 4 - pin_reset: 5 - filters: - - or: - - debounce: 0.1s - - delta: 10 - resolution: 4 - min_value: -10 - max_value: 30 - on_value: - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: 10 - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: !lambda "return -1;" - on_clockwise: - - logger.log: Clockwise - on_anticlockwise: - - logger.log: Anticlockwise +substitutions: + pin_a: GPIO2 + pin_b: GPIO3 + pin_reset: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/rotary_encoder/test.esp32-idf.yaml b/tests/components/rotary_encoder/test.esp32-idf.yaml index da3843f82d..48a624aa37 100644 --- a/tests/components/rotary_encoder/test.esp32-idf.yaml +++ b/tests/components/rotary_encoder/test.esp32-idf.yaml @@ -1,25 +1,6 @@ -sensor: - - platform: rotary_encoder - name: Rotary Encoder - id: rotary_encoder1 - pin_a: 13 - pin_b: 14 - pin_reset: 15 - filters: - - or: - - debounce: 0.1s - - delta: 10 - resolution: 4 - min_value: -10 - max_value: 30 - on_value: - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: 10 - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: !lambda "return -1;" - on_clockwise: - - logger.log: Clockwise - on_anticlockwise: - - logger.log: Anticlockwise +substitutions: + pin_a: GPIO12 + pin_b: GPIO13 + pin_reset: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/rotary_encoder/test.esp8266-ard.yaml b/tests/components/rotary_encoder/test.esp8266-ard.yaml index da3843f82d..48a624aa37 100644 --- a/tests/components/rotary_encoder/test.esp8266-ard.yaml +++ b/tests/components/rotary_encoder/test.esp8266-ard.yaml @@ -1,25 +1,6 @@ -sensor: - - platform: rotary_encoder - name: Rotary Encoder - id: rotary_encoder1 - pin_a: 13 - pin_b: 14 - pin_reset: 15 - filters: - - or: - - debounce: 0.1s - - delta: 10 - resolution: 4 - min_value: -10 - max_value: 30 - on_value: - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: 10 - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: !lambda "return -1;" - on_clockwise: - - logger.log: Clockwise - on_anticlockwise: - - logger.log: Anticlockwise +substitutions: + pin_a: GPIO12 + pin_b: GPIO13 + pin_reset: GPIO14 + +<<: !include common.yaml diff --git a/tests/components/rotary_encoder/test.rp2040-ard.yaml b/tests/components/rotary_encoder/test.rp2040-ard.yaml index da3843f82d..b71a454bdd 100644 --- a/tests/components/rotary_encoder/test.rp2040-ard.yaml +++ b/tests/components/rotary_encoder/test.rp2040-ard.yaml @@ -1,25 +1,6 @@ -sensor: - - platform: rotary_encoder - name: Rotary Encoder - id: rotary_encoder1 - pin_a: 13 - pin_b: 14 - pin_reset: 15 - filters: - - or: - - debounce: 0.1s - - delta: 10 - resolution: 4 - min_value: -10 - max_value: 30 - on_value: - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: 10 - - sensor.rotary_encoder.set_value: - id: rotary_encoder1 - value: !lambda "return -1;" - on_clockwise: - - logger.log: Clockwise - on_anticlockwise: - - logger.log: Anticlockwise +substitutions: + pin_a: GPIO2 + pin_b: GPIO3 + pin_reset: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/rtttl/common.yaml b/tests/components/rtttl/common.yaml new file mode 100644 index 0000000000..86b52ca3de --- /dev/null +++ b/tests/components/rtttl/common.yaml @@ -0,0 +1,15 @@ +esphome: + on_boot: + then: + - rtttl.play: 'siren:d=8,o=5,b=100:d,e,d,e,d,e,d,e' + - rtttl.stop + +output: + - platform: ${output_platform} + id: rtttl_output + pin: ${pin} + frequency: 1500Hz + max_power: 0.5 + +rtttl: + output: rtttl_output diff --git a/tests/components/rtttl/test.esp32-ard.yaml b/tests/components/rtttl/test.esp32-ard.yaml index 367a670741..26da1ce1d6 100644 --- a/tests/components/rtttl/test.esp32-ard.yaml +++ b/tests/components/rtttl/test.esp32-ard.yaml @@ -1,16 +1,5 @@ -esphome: - on_boot: - then: - - rtttl.play: 'siren:d=8,o=5,b=100:d,e,d,e,d,e,d,e' - - rtttl.stop +substitutions: + output_platform: ledc + pin: GPIO14 -output: - - platform: ledc - id: rtttl_output - pin: 13 - frequency: 1500Hz - channel: 14 - max_power: 0.5 - -rtttl: - output: rtttl_output +<<: !include common.yaml diff --git a/tests/components/rtttl/test.esp32-c3-ard.yaml b/tests/components/rtttl/test.esp32-c3-ard.yaml index c525f417de..7476963591 100644 --- a/tests/components/rtttl/test.esp32-c3-ard.yaml +++ b/tests/components/rtttl/test.esp32-c3-ard.yaml @@ -1,16 +1,5 @@ -esphome: - on_boot: - then: - - rtttl.play: 'siren:d=8,o=5,b=100:d,e,d,e,d,e,d,e' - - rtttl.stop +substitutions: + output_platform: ledc + pin: GPIO4 -output: - - platform: ledc - id: rtttl_output - pin: 1 - frequency: 1500Hz - channel: 14 - max_power: 0.5 - -rtttl: - output: rtttl_output +<<: !include common.yaml diff --git a/tests/components/rtttl/test.esp32-c3-idf.yaml b/tests/components/rtttl/test.esp32-c3-idf.yaml index c525f417de..7476963591 100644 --- a/tests/components/rtttl/test.esp32-c3-idf.yaml +++ b/tests/components/rtttl/test.esp32-c3-idf.yaml @@ -1,16 +1,5 @@ -esphome: - on_boot: - then: - - rtttl.play: 'siren:d=8,o=5,b=100:d,e,d,e,d,e,d,e' - - rtttl.stop +substitutions: + output_platform: ledc + pin: GPIO4 -output: - - platform: ledc - id: rtttl_output - pin: 1 - frequency: 1500Hz - channel: 14 - max_power: 0.5 - -rtttl: - output: rtttl_output +<<: !include common.yaml diff --git a/tests/components/rtttl/test.esp32-idf.yaml b/tests/components/rtttl/test.esp32-idf.yaml index 367a670741..26da1ce1d6 100644 --- a/tests/components/rtttl/test.esp32-idf.yaml +++ b/tests/components/rtttl/test.esp32-idf.yaml @@ -1,16 +1,5 @@ -esphome: - on_boot: - then: - - rtttl.play: 'siren:d=8,o=5,b=100:d,e,d,e,d,e,d,e' - - rtttl.stop +substitutions: + output_platform: ledc + pin: GPIO14 -output: - - platform: ledc - id: rtttl_output - pin: 13 - frequency: 1500Hz - channel: 14 - max_power: 0.5 - -rtttl: - output: rtttl_output +<<: !include common.yaml diff --git a/tests/components/rtttl/test.esp8266-ard.yaml b/tests/components/rtttl/test.esp8266-ard.yaml index c3b87c0f72..23a7f43b42 100644 --- a/tests/components/rtttl/test.esp8266-ard.yaml +++ b/tests/components/rtttl/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -esphome: - on_boot: - then: - - rtttl.play: 'siren:d=8,o=5,b=100:d,e,d,e,d,e,d,e' - - rtttl.stop +substitutions: + output_platform: esp8266_pwm + pin: GPIO14 -output: - - platform: esp8266_pwm - id: rtttl_output - pin: 13 - frequency: 1500Hz - max_power: 0.5 - -rtttl: - output: rtttl_output +<<: !include common.yaml diff --git a/tests/components/rtttl/test.rp2040-ard.yaml b/tests/components/rtttl/test.rp2040-ard.yaml index ea240aa34d..d70f7c74ec 100644 --- a/tests/components/rtttl/test.rp2040-ard.yaml +++ b/tests/components/rtttl/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -esphome: - on_boot: - then: - - rtttl.play: 'siren:d=8,o=5,b=100:d,e,d,e,d,e,d,e' - - rtttl.stop +substitutions: + output_platform: rp2040_pwm + pin: GPIO4 -output: - - platform: rp2040_pwm - id: rtttl_output - pin: 3 - frequency: 1500Hz - max_power: 0.5 - -rtttl: - output: rtttl_output +<<: !include common.yaml From 65ca000e6d72819b5bb48aa6fe53a0a210fa90ee Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Tue, 4 Feb 2025 18:43:44 -0800 Subject: [PATCH 162/194] [prometheus] Add update entity to prometheus metrics (#8173) --- .../prometheus/prometheus_handler.cpp | 91 +++++++++++++++++++ .../prometheus/prometheus_handler.h | 27 ++++-- tests/components/prometheus/common.yaml | 23 +++++ 3 files changed, 132 insertions(+), 9 deletions(-) diff --git a/esphome/components/prometheus/prometheus_handler.cpp b/esphome/components/prometheus/prometheus_handler.cpp index 2d39d8ef3f..c31d34f000 100644 --- a/esphome/components/prometheus/prometheus_handler.cpp +++ b/esphome/components/prometheus/prometheus_handler.cpp @@ -77,6 +77,12 @@ void PrometheusHandler::handleRequest(AsyncWebServerRequest *req) { this->media_player_row_(stream, obj, area, node, friendly_name); #endif +#ifdef USE_UPDATE + this->update_entity_type_(stream); + for (auto *obj : App.get_updates()) + this->update_entity_row_(stream, obj, area, node, friendly_name); +#endif + req->send(stream); } @@ -679,6 +685,91 @@ void PrometheusHandler::media_player_row_(AsyncResponseStream *stream, media_pla } #endif +#ifdef USE_UPDATE +void PrometheusHandler::update_entity_type_(AsyncResponseStream *stream) { + stream->print(F("#TYPE esphome_update_entity_state gauge\n")); + stream->print(F("#TYPE esphome_update_entity_info gauge\n")); + stream->print(F("#TYPE esphome_update_entity_failed gauge\n")); +} + +void PrometheusHandler::handle_update_state_(AsyncResponseStream *stream, update::UpdateState state) { + switch (state) { + case update::UpdateState::UPDATE_STATE_UNKNOWN: + stream->print("unknown"); + break; + case update::UpdateState::UPDATE_STATE_NO_UPDATE: + stream->print("none"); + break; + case update::UpdateState::UPDATE_STATE_AVAILABLE: + stream->print("available"); + break; + case update::UpdateState::UPDATE_STATE_INSTALLING: + stream->print("installing"); + break; + default: + stream->print("invalid"); + break; + } +} + +void PrometheusHandler::update_entity_row_(AsyncResponseStream *stream, update::UpdateEntity *obj, std::string &area, + std::string &node, std::string &friendly_name) { + if (obj->is_internal() && !this->include_internal_) + return; + if (obj->has_state()) { + // We have a valid value, output this value + stream->print(F("esphome_update_entity_failed{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} 0\n")); + // First update state + stream->print(F("esphome_update_entity_state{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\",value=\"")); + handle_update_state_(stream, obj->state); + stream->print(F("\"} ")); + stream->print(F("1.0")); + stream->print(F("\n")); + // Next update info + stream->print(F("esphome_update_entity_info{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\",current_version=\"")); + stream->print(obj->update_info.current_version.c_str()); + stream->print(F("\",latest_version=\"")); + stream->print(obj->update_info.latest_version.c_str()); + stream->print(F("\",title=\"")); + stream->print(obj->update_info.title.c_str()); + stream->print(F("\"} ")); + stream->print(F("1.0")); + stream->print(F("\n")); + } else { + // Invalid state + stream->print(F("esphome_update_entity_failed{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} 1\n")); + } +} +#endif + } // namespace prometheus } // namespace esphome #endif diff --git a/esphome/components/prometheus/prometheus_handler.h b/esphome/components/prometheus/prometheus_handler.h index 41a06537ed..08a6e8dc8a 100644 --- a/esphome/components/prometheus/prometheus_handler.h +++ b/esphome/components/prometheus/prometheus_handler.h @@ -75,7 +75,7 @@ class PrometheusHandler : public AsyncWebHandler, public Component { #ifdef USE_BINARY_SENSOR /// Return the type for prometheus void binary_sensor_type_(AsyncResponseStream *stream); - /// Return the sensor state as prometheus data point + /// Return the binary sensor state as prometheus data point void binary_sensor_row_(AsyncResponseStream *stream, binary_sensor::BinarySensor *obj, std::string &area, std::string &node, std::string &friendly_name); #endif @@ -83,7 +83,7 @@ class PrometheusHandler : public AsyncWebHandler, public Component { #ifdef USE_FAN /// Return the type for prometheus void fan_type_(AsyncResponseStream *stream); - /// Return the sensor state as prometheus data point + /// Return the fan state as prometheus data point void fan_row_(AsyncResponseStream *stream, fan::Fan *obj, std::string &area, std::string &node, std::string &friendly_name); #endif @@ -91,7 +91,7 @@ class PrometheusHandler : public AsyncWebHandler, public Component { #ifdef USE_LIGHT /// Return the type for prometheus void light_type_(AsyncResponseStream *stream); - /// Return the Light Values state as prometheus data point + /// Return the light values state as prometheus data point void light_row_(AsyncResponseStream *stream, light::LightState *obj, std::string &area, std::string &node, std::string &friendly_name); #endif @@ -99,7 +99,7 @@ class PrometheusHandler : public AsyncWebHandler, public Component { #ifdef USE_COVER /// Return the type for prometheus void cover_type_(AsyncResponseStream *stream); - /// Return the switch Values state as prometheus data point + /// Return the cover values state as prometheus data point void cover_row_(AsyncResponseStream *stream, cover::Cover *obj, std::string &area, std::string &node, std::string &friendly_name); #endif @@ -107,7 +107,7 @@ class PrometheusHandler : public AsyncWebHandler, public Component { #ifdef USE_SWITCH /// Return the type for prometheus void switch_type_(AsyncResponseStream *stream); - /// Return the switch Values state as prometheus data point + /// Return the switch values state as prometheus data point void switch_row_(AsyncResponseStream *stream, switch_::Switch *obj, std::string &area, std::string &node, std::string &friendly_name); #endif @@ -115,7 +115,7 @@ class PrometheusHandler : public AsyncWebHandler, public Component { #ifdef USE_LOCK /// Return the type for prometheus void lock_type_(AsyncResponseStream *stream); - /// Return the lock Values state as prometheus data point + /// Return the lock values state as prometheus data point void lock_row_(AsyncResponseStream *stream, lock::Lock *obj, std::string &area, std::string &node, std::string &friendly_name); #endif @@ -123,7 +123,7 @@ class PrometheusHandler : public AsyncWebHandler, public Component { #ifdef USE_TEXT_SENSOR /// Return the type for prometheus void text_sensor_type_(AsyncResponseStream *stream); - /// Return the lock Values state as prometheus data point + /// Return the text sensor values state as prometheus data point void text_sensor_row_(AsyncResponseStream *stream, text_sensor::TextSensor *obj, std::string &area, std::string &node, std::string &friendly_name); #endif @@ -131,7 +131,7 @@ class PrometheusHandler : public AsyncWebHandler, public Component { #ifdef USE_NUMBER /// Return the type for prometheus void number_type_(AsyncResponseStream *stream); - /// Return the sensor state as prometheus data point + /// Return the number state as prometheus data point void number_row_(AsyncResponseStream *stream, number::Number *obj, std::string &area, std::string &node, std::string &friendly_name); #endif @@ -147,11 +147,20 @@ class PrometheusHandler : public AsyncWebHandler, public Component { #ifdef USE_MEDIA_PLAYER /// Return the type for prometheus void media_player_type_(AsyncResponseStream *stream); - /// Return the select state as prometheus data point + /// Return the media player state as prometheus data point void media_player_row_(AsyncResponseStream *stream, media_player::MediaPlayer *obj, std::string &area, std::string &node, std::string &friendly_name); #endif +#ifdef USE_UPDATE + /// Return the type for prometheus + void update_entity_type_(AsyncResponseStream *stream); + /// Return the update state and info as prometheus data point + void update_entity_row_(AsyncResponseStream *stream, update::UpdateEntity *obj, std::string &area, std::string &node, + std::string &friendly_name); + void handle_update_state_(AsyncResponseStream *stream, update::UpdateState state); +#endif + web_server_base::WebServerBase *base_; bool include_internal_{false}; std::map relabel_map_id_; diff --git a/tests/components/prometheus/common.yaml b/tests/components/prometheus/common.yaml index 1b87c1d6c1..9205c27f2a 100644 --- a/tests/components/prometheus/common.yaml +++ b/tests/components/prometheus/common.yaml @@ -1,12 +1,35 @@ +substitutions: + verify_ssl: "false" + esphome: name: livingroomdevice friendly_name: Living Room Device area: Living Room + on_boot: + then: + - if: + condition: + update.is_available: + then: + - logger.log: "Update available" + - update.perform: + force_update: true wifi: ssid: MySSID password: password1 +http_request: + verify_ssl: ${verify_ssl} + +ota: + - platform: http_request + +update: + - platform: http_request + name: Firmware Update + source: http://example.com/manifest.json + sensor: - platform: template id: template_sensor1 From 57739b8bb0979eea61822f4e3a6f50fc0837e434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Schr=C3=B6ter?= <5852313+janschroeter@users.noreply.github.com> Date: Wed, 5 Feb 2025 03:53:05 +0100 Subject: [PATCH 163/194] [uponor_smatrix] add target temperature as sensor (#7745) --- .../uponor_smatrix/sensor/__init__.py | 18 ++++++++++++++---- .../sensor/uponor_smatrix_sensor.cpp | 5 +++++ .../sensor/uponor_smatrix_sensor.h | 1 + tests/components/uponor_smatrix/common.yaml | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/esphome/components/uponor_smatrix/sensor/__init__.py b/esphome/components/uponor_smatrix/sensor/__init__.py index 89097aef18..f2b34538ba 100644 --- a/esphome/components/uponor_smatrix/sensor/__init__.py +++ b/esphome/components/uponor_smatrix/sensor/__init__.py @@ -1,11 +1,12 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_EXTERNAL_TEMPERATURE, CONF_HUMIDITY, - CONF_TEMPERATURE, CONF_ID, + CONF_TARGET_TEMPERATURE, + CONF_TEMPERATURE, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, @@ -14,10 +15,10 @@ from esphome.const import ( ) from .. import ( - uponor_smatrix_ns, - UponorSmatrixDevice, UPONOR_SMATRIX_DEVICE_SCHEMA, + UponorSmatrixDevice, register_uponor_smatrix_device, + uponor_smatrix_ns, ) DEPENDENCIES = ["uponor_smatrix"] @@ -50,6 +51,12 @@ CONFIG_SCHEMA = cv.COMPONENT_SCHEMA.extend( device_class=DEVICE_CLASS_HUMIDITY, state_class=STATE_CLASS_MEASUREMENT, ), + cv.Optional(CONF_TARGET_TEMPERATURE): sensor.sensor_schema( + unit_of_measurement=UNIT_CELSIUS, + accuracy_decimals=1, + device_class=DEVICE_CLASS_TEMPERATURE, + state_class=STATE_CLASS_MEASUREMENT, + ), } ).extend(UPONOR_SMATRIX_DEVICE_SCHEMA) @@ -68,3 +75,6 @@ async def to_code(config): if humidity_config := config.get(CONF_HUMIDITY): sens = await sensor.new_sensor(humidity_config) cg.add(var.set_humidity_sensor(sens)) + if target_temperature_config := config.get(CONF_TARGET_TEMPERATURE): + sens = await sensor.new_sensor(target_temperature_config) + cg.add(var.set_target_temperature_sensor(sens)) diff --git a/esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.cpp b/esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.cpp index 2fd2a36efc..47ff3a17f5 100644 --- a/esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.cpp +++ b/esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.cpp @@ -12,6 +12,7 @@ void UponorSmatrixSensor::dump_config() { LOG_SENSOR(" ", "Temperature", this->temperature_sensor_); LOG_SENSOR(" ", "External Temperature", this->external_temperature_sensor_); LOG_SENSOR(" ", "Humidity", this->humidity_sensor_); + LOG_SENSOR(" ", "Target Temperature", this->target_temperature_sensor_); } void UponorSmatrixSensor::on_device_data(const UponorSmatrixData *data, size_t data_len) { @@ -29,6 +30,10 @@ void UponorSmatrixSensor::on_device_data(const UponorSmatrixData *data, size_t d if (this->humidity_sensor_ != nullptr) this->humidity_sensor_->publish_state(data[i].value & 0x00FF); break; + case UPONOR_ID_TARGET_TEMP: + if (this->target_temperature_sensor_ != nullptr) + this->target_temperature_sensor_->publish_state(raw_to_celsius(data[i].value)); + break; } } } diff --git a/esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.h b/esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.h index 5e38117a21..97d0d21838 100644 --- a/esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.h +++ b/esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.h @@ -11,6 +11,7 @@ class UponorSmatrixSensor : public sensor::Sensor, public Component, public Upon SUB_SENSOR(temperature) SUB_SENSOR(external_temperature) SUB_SENSOR(humidity) + SUB_SENSOR(target_temperature) public: void dump_config() override; diff --git a/tests/components/uponor_smatrix/common.yaml b/tests/components/uponor_smatrix/common.yaml index cfdbacaa4c..8ee92bdfc5 100644 --- a/tests/components/uponor_smatrix/common.yaml +++ b/tests/components/uponor_smatrix/common.yaml @@ -36,3 +36,5 @@ sensor: name: Thermostat Temperature Living Room external_temperature: name: Thermostat Floor Temperature Living Room + target_temperature: + name: Thermostat Target Temperature Living Room From e337bd7beb41d28c8d06026cb18f37c725e684dd Mon Sep 17 00:00:00 2001 From: bdm310 Date: Wed, 5 Feb 2025 02:53:23 -0800 Subject: [PATCH 164/194] [sdl] Implement binary sensors from keystrokes (#8207) Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com> --- CODEOWNERS | 2 +- esphome/components/sdl/binary_sensor.py | 270 ++++++++++++++++++++++++ esphome/components/sdl/sdl_esphome.cpp | 16 ++ esphome/components/sdl/sdl_esphome.h | 9 + tests/components/sdl/common.yaml | 11 + 5 files changed, 307 insertions(+), 1 deletion(-) create mode 100644 esphome/components/sdl/binary_sensor.py diff --git a/CODEOWNERS b/CODEOWNERS index 03e26bcb84..eab02efffb 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -357,7 +357,7 @@ esphome/components/rtttl/* @glmnet esphome/components/safe_mode/* @jsuanet @kbx81 @paulmonigatti esphome/components/scd4x/* @martgras @sjtrny esphome/components/script/* @esphome/core -esphome/components/sdl/* @clydebarrow +esphome/components/sdl/* @bdm310 @clydebarrow esphome/components/sdm_meter/* @jesserockz @polyfaces esphome/components/sdp3x/* @Azimath esphome/components/seeed_mr24hpc1/* @limengdu diff --git a/esphome/components/sdl/binary_sensor.py b/esphome/components/sdl/binary_sensor.py new file mode 100644 index 0000000000..3ea6c2d218 --- /dev/null +++ b/esphome/components/sdl/binary_sensor.py @@ -0,0 +1,270 @@ +import esphome.codegen as cg +from esphome.components import binary_sensor +from esphome.components.binary_sensor import BinarySensor +import esphome.config_validation as cv +from esphome.const import CONF_KEY +from esphome.core import Lambda +from esphome.cpp_generator import ExpressionStatement, RawExpression + +from .display import CONF_SDL_ID, Sdl + +CODEOWNERS = ["@bdm310"] + +STATE_ARG = "state" + +SDL_KEYMAP = { + "SDLK_UNKNOWN": 0, + "SDLK_FIRST": 0, + "SDLK_BACKSPACE": 8, + "SDLK_TAB": 9, + "SDLK_CLEAR": 12, + "SDLK_RETURN": 13, + "SDLK_PAUSE": 19, + "SDLK_ESCAPE": 27, + "SDLK_SPACE": 32, + "SDLK_EXCLAIM": 33, + "SDLK_QUOTEDBL": 34, + "SDLK_HASH": 35, + "SDLK_DOLLAR": 36, + "SDLK_AMPERSAND": 38, + "SDLK_QUOTE": 39, + "SDLK_LEFTPAREN": 40, + "SDLK_RIGHTPAREN": 41, + "SDLK_ASTERISK": 42, + "SDLK_PLUS": 43, + "SDLK_COMMA": 44, + "SDLK_MINUS": 45, + "SDLK_PERIOD": 46, + "SDLK_SLASH": 47, + "SDLK_0": 48, + "SDLK_1": 49, + "SDLK_2": 50, + "SDLK_3": 51, + "SDLK_4": 52, + "SDLK_5": 53, + "SDLK_6": 54, + "SDLK_7": 55, + "SDLK_8": 56, + "SDLK_9": 57, + "SDLK_COLON": 58, + "SDLK_SEMICOLON": 59, + "SDLK_LESS": 60, + "SDLK_EQUALS": 61, + "SDLK_GREATER": 62, + "SDLK_QUESTION": 63, + "SDLK_AT": 64, + "SDLK_LEFTBRACKET": 91, + "SDLK_BACKSLASH": 92, + "SDLK_RIGHTBRACKET": 93, + "SDLK_CARET": 94, + "SDLK_UNDERSCORE": 95, + "SDLK_BACKQUOTE": 96, + "SDLK_a": 97, + "SDLK_b": 98, + "SDLK_c": 99, + "SDLK_d": 100, + "SDLK_e": 101, + "SDLK_f": 102, + "SDLK_g": 103, + "SDLK_h": 104, + "SDLK_i": 105, + "SDLK_j": 106, + "SDLK_k": 107, + "SDLK_l": 108, + "SDLK_m": 109, + "SDLK_n": 110, + "SDLK_o": 111, + "SDLK_p": 112, + "SDLK_q": 113, + "SDLK_r": 114, + "SDLK_s": 115, + "SDLK_t": 116, + "SDLK_u": 117, + "SDLK_v": 118, + "SDLK_w": 119, + "SDLK_x": 120, + "SDLK_y": 121, + "SDLK_z": 122, + "SDLK_DELETE": 127, + "SDLK_WORLD_0": 160, + "SDLK_WORLD_1": 161, + "SDLK_WORLD_2": 162, + "SDLK_WORLD_3": 163, + "SDLK_WORLD_4": 164, + "SDLK_WORLD_5": 165, + "SDLK_WORLD_6": 166, + "SDLK_WORLD_7": 167, + "SDLK_WORLD_8": 168, + "SDLK_WORLD_9": 169, + "SDLK_WORLD_10": 170, + "SDLK_WORLD_11": 171, + "SDLK_WORLD_12": 172, + "SDLK_WORLD_13": 173, + "SDLK_WORLD_14": 174, + "SDLK_WORLD_15": 175, + "SDLK_WORLD_16": 176, + "SDLK_WORLD_17": 177, + "SDLK_WORLD_18": 178, + "SDLK_WORLD_19": 179, + "SDLK_WORLD_20": 180, + "SDLK_WORLD_21": 181, + "SDLK_WORLD_22": 182, + "SDLK_WORLD_23": 183, + "SDLK_WORLD_24": 184, + "SDLK_WORLD_25": 185, + "SDLK_WORLD_26": 186, + "SDLK_WORLD_27": 187, + "SDLK_WORLD_28": 188, + "SDLK_WORLD_29": 189, + "SDLK_WORLD_30": 190, + "SDLK_WORLD_31": 191, + "SDLK_WORLD_32": 192, + "SDLK_WORLD_33": 193, + "SDLK_WORLD_34": 194, + "SDLK_WORLD_35": 195, + "SDLK_WORLD_36": 196, + "SDLK_WORLD_37": 197, + "SDLK_WORLD_38": 198, + "SDLK_WORLD_39": 199, + "SDLK_WORLD_40": 200, + "SDLK_WORLD_41": 201, + "SDLK_WORLD_42": 202, + "SDLK_WORLD_43": 203, + "SDLK_WORLD_44": 204, + "SDLK_WORLD_45": 205, + "SDLK_WORLD_46": 206, + "SDLK_WORLD_47": 207, + "SDLK_WORLD_48": 208, + "SDLK_WORLD_49": 209, + "SDLK_WORLD_50": 210, + "SDLK_WORLD_51": 211, + "SDLK_WORLD_52": 212, + "SDLK_WORLD_53": 213, + "SDLK_WORLD_54": 214, + "SDLK_WORLD_55": 215, + "SDLK_WORLD_56": 216, + "SDLK_WORLD_57": 217, + "SDLK_WORLD_58": 218, + "SDLK_WORLD_59": 219, + "SDLK_WORLD_60": 220, + "SDLK_WORLD_61": 221, + "SDLK_WORLD_62": 222, + "SDLK_WORLD_63": 223, + "SDLK_WORLD_64": 224, + "SDLK_WORLD_65": 225, + "SDLK_WORLD_66": 226, + "SDLK_WORLD_67": 227, + "SDLK_WORLD_68": 228, + "SDLK_WORLD_69": 229, + "SDLK_WORLD_70": 230, + "SDLK_WORLD_71": 231, + "SDLK_WORLD_72": 232, + "SDLK_WORLD_73": 233, + "SDLK_WORLD_74": 234, + "SDLK_WORLD_75": 235, + "SDLK_WORLD_76": 236, + "SDLK_WORLD_77": 237, + "SDLK_WORLD_78": 238, + "SDLK_WORLD_79": 239, + "SDLK_WORLD_80": 240, + "SDLK_WORLD_81": 241, + "SDLK_WORLD_82": 242, + "SDLK_WORLD_83": 243, + "SDLK_WORLD_84": 244, + "SDLK_WORLD_85": 245, + "SDLK_WORLD_86": 246, + "SDLK_WORLD_87": 247, + "SDLK_WORLD_88": 248, + "SDLK_WORLD_89": 249, + "SDLK_WORLD_90": 250, + "SDLK_WORLD_91": 251, + "SDLK_WORLD_92": 252, + "SDLK_WORLD_93": 253, + "SDLK_WORLD_94": 254, + "SDLK_WORLD_95": 255, + "SDLK_KP0": 256, + "SDLK_KP1": 257, + "SDLK_KP2": 258, + "SDLK_KP3": 259, + "SDLK_KP4": 260, + "SDLK_KP5": 261, + "SDLK_KP6": 262, + "SDLK_KP7": 263, + "SDLK_KP8": 264, + "SDLK_KP9": 265, + "SDLK_KP_PERIOD": 266, + "SDLK_KP_DIVIDE": 267, + "SDLK_KP_MULTIPLY": 268, + "SDLK_KP_MINUS": 269, + "SDLK_KP_PLUS": 270, + "SDLK_KP_ENTER": 271, + "SDLK_KP_EQUALS": 272, + "SDLK_UP": 273, + "SDLK_DOWN": 274, + "SDLK_RIGHT": 275, + "SDLK_LEFT": 276, + "SDLK_INSERT": 277, + "SDLK_HOME": 278, + "SDLK_END": 279, + "SDLK_PAGEUP": 280, + "SDLK_PAGEDOWN": 281, + "SDLK_F1": 282, + "SDLK_F2": 283, + "SDLK_F3": 284, + "SDLK_F4": 285, + "SDLK_F5": 286, + "SDLK_F6": 287, + "SDLK_F7": 288, + "SDLK_F8": 289, + "SDLK_F9": 290, + "SDLK_F10": 291, + "SDLK_F11": 292, + "SDLK_F12": 293, + "SDLK_F13": 294, + "SDLK_F14": 295, + "SDLK_F15": 296, + "SDLK_NUMLOCK": 300, + "SDLK_CAPSLOCK": 301, + "SDLK_SCROLLOCK": 302, + "SDLK_RSHIFT": 303, + "SDLK_LSHIFT": 304, + "SDLK_RCTRL": 305, + "SDLK_LCTRL": 306, + "SDLK_RALT": 307, + "SDLK_LALT": 308, + "SDLK_RMETA": 309, + "SDLK_LMETA": 310, + "SDLK_LSUPER": 311, + "SDLK_RSUPER": 312, + "SDLK_MODE": 313, + "SDLK_COMPOSE": 314, + "SDLK_HELP": 315, + "SDLK_PRINT": 316, + "SDLK_SYSREQ": 317, + "SDLK_BREAK": 318, + "SDLK_MENU": 319, + "SDLK_POWER": 320, + "SDLK_EURO": 321, + "SDLK_UNDO": 322, +} + +CONFIG_SCHEMA = ( + binary_sensor.binary_sensor_schema(BinarySensor) + .extend( + { + cv.Required(CONF_KEY): cv.enum(SDL_KEYMAP), + cv.GenerateID(CONF_SDL_ID): cv.use_id(Sdl), + } + ) + .extend(cv.COMPONENT_SCHEMA) +) + + +async def to_code(config): + var = await binary_sensor.new_binary_sensor(config) + parent = await cg.get_variable(config[CONF_SDL_ID]) + listener = Lambda( + str(ExpressionStatement(var.publish_state(RawExpression(STATE_ARG)))) + ) + listener = await cg.process_lambda(listener, [(cg.bool_, STATE_ARG)]) + cg.add(parent.add_key_listener(config[CONF_KEY], listener)) diff --git a/esphome/components/sdl/sdl_esphome.cpp b/esphome/components/sdl/sdl_esphome.cpp index 8f0821a2fa..42dfe687e9 100644 --- a/esphome/components/sdl/sdl_esphome.cpp +++ b/esphome/components/sdl/sdl_esphome.cpp @@ -61,6 +61,12 @@ void Sdl::draw_pixel_at(int x, int y, Color color) { this->y_high_ = y; } +void Sdl::process_key(uint32_t keycode, bool down) { + auto callback = this->key_callbacks_.find(keycode); + if (callback != this->key_callbacks_.end()) + callback->second(down); +} + void Sdl::loop() { SDL_Event e; if (SDL_PollEvent(&e)) { @@ -87,6 +93,16 @@ void Sdl::loop() { } break; + case SDL_KEYDOWN: + ESP_LOGD(TAG, "keydown %d", e.key.keysym.sym); + this->process_key(e.key.keysym.sym, true); + break; + + case SDL_KEYUP: + ESP_LOGD(TAG, "keyup %d", e.key.keysym.sym); + this->process_key(e.key.keysym.sym, false); + break; + case SDL_WINDOWEVENT: switch (e.window.event) { case SDL_WINDOWEVENT_SIZE_CHANGED: diff --git a/esphome/components/sdl/sdl_esphome.h b/esphome/components/sdl/sdl_esphome.h index 4b0e59c9fe..39ea3ed417 100644 --- a/esphome/components/sdl/sdl_esphome.h +++ b/esphome/components/sdl/sdl_esphome.h @@ -7,6 +7,7 @@ #include "esphome/components/display/display.h" #define SDL_MAIN_HANDLED #include "SDL.h" +#include namespace esphome { namespace sdl { @@ -22,6 +23,7 @@ class Sdl : public display::Display { void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override; void draw_pixel_at(int x, int y, Color color) override; + void process_key(uint32_t keycode, bool down); void set_dimensions(uint16_t width, uint16_t height) { this->width_ = width; this->height_ = height; @@ -30,6 +32,12 @@ class Sdl : public display::Display { int get_height() override { return this->height_; } float get_setup_priority() const override { return setup_priority::HARDWARE; } void dump_config() override { LOG_DISPLAY("", "SDL", this); } + void add_key_listener(int32_t keycode, std::function &&callback) { + if (!this->key_callbacks_.count(keycode)) { + this->key_callbacks_[keycode] = CallbackManager(); + } + this->key_callbacks_[keycode].add(std::move(callback)); + } int mouse_x{}; int mouse_y{}; @@ -48,6 +56,7 @@ class Sdl : public display::Display { uint16_t y_low_{0}; uint16_t x_high_{0}; uint16_t y_high_{0}; + std::map> key_callbacks_{}; }; } // namespace sdl } // namespace esphome diff --git a/tests/components/sdl/common.yaml b/tests/components/sdl/common.yaml index 0192f054b5..50fa4a5990 100644 --- a/tests/components/sdl/common.yaml +++ b/tests/components/sdl/common.yaml @@ -10,3 +10,14 @@ display: dimensions: width: 450 height: 600 + +binary_sensor: + - platform: sdl + id: key_up + key: SDLK_a + - platform: sdl + id: key_down + key: SDLK_d + - platform: sdl + id: key_enter + key: SDLK_s From 4eb551864df65c95a25f6169b26d18eae975c4a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 20:33:57 +0100 Subject: [PATCH 165/194] Bump the docker-actions group with 2 updates (#8215) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-docker.yml | 4 ++-- .github/workflows/release.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index e156dbf1e2..8de6191205 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -46,9 +46,9 @@ jobs: with: python-version: "3.9" - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.8.0 + uses: docker/setup-buildx-action@v3.9.0 - name: Set up QEMU - uses: docker/setup-qemu-action@v3.3.0 + uses: docker/setup-qemu-action@v3.4.0 - name: Set TAG run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d406ee0069..aa41cf2790 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -89,10 +89,10 @@ jobs: python-version: "3.9" - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.8.0 + uses: docker/setup-buildx-action@v3.9.0 - name: Set up QEMU if: matrix.platform != 'linux/amd64' - uses: docker/setup-qemu-action@v3.3.0 + uses: docker/setup-qemu-action@v3.4.0 - name: Log in to docker hub uses: docker/login-action@v3.3.0 @@ -183,7 +183,7 @@ jobs: merge-multiple: true - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3.8.0 + uses: docker/setup-buildx-action@v3.9.0 - name: Log in to docker hub if: matrix.registry == 'dockerhub' From 7e626b04f2465bc7dd074dd029c2b31ef1694287 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Thu, 6 Feb 2025 23:09:24 -0500 Subject: [PATCH 166/194] [esp32_rmt] Set pull-up and open-drain modes based on pin schema (#8178) Co-authored-by: Keith Burzinski --- .../remote_receiver/remote_receiver_esp32.cpp | 6 ++++++ .../components/remote_transmitter/__init__.py | 17 +++++++++-------- .../remote_transmitter/remote_transmitter.h | 2 -- .../remote_transmitter_esp32.cpp | 14 ++++++++++---- .../remote_transmitter/esp32-common-idf.yaml | 1 - .../remote_transmitter/test.esp32-c3-idf.yaml | 1 - .../remote_transmitter/test.esp32-idf.yaml | 1 - .../remote_transmitter/test.esp32-s3-idf.yaml | 1 - 8 files changed, 25 insertions(+), 18 deletions(-) diff --git a/esphome/components/remote_receiver/remote_receiver_esp32.cpp b/esphome/components/remote_receiver/remote_receiver_esp32.cpp index 8a36971e36..2b6032cdf2 100644 --- a/esphome/components/remote_receiver/remote_receiver_esp32.cpp +++ b/esphome/components/remote_receiver/remote_receiver_esp32.cpp @@ -2,6 +2,7 @@ #include "esphome/core/log.h" #ifdef USE_ESP32 +#include namespace esphome { namespace remote_receiver { @@ -62,6 +63,11 @@ void RemoteReceiverComponent::setup() { this->mark_failed(); return; } + if (this->pin_->get_flags() & gpio::FLAG_PULLUP) { + gpio_pullup_en(gpio_num_t(this->pin_->get_pin())); + } else { + gpio_pullup_dis(gpio_num_t(this->pin_->get_pin())); + } error = rmt_enable(this->channel_); if (error != ESP_OK) { this->error_code_ = error; diff --git a/esphome/components/remote_transmitter/__init__.py b/esphome/components/remote_transmitter/__init__.py index e3462fb246..e7a94c175e 100644 --- a/esphome/components/remote_transmitter/__init__.py +++ b/esphome/components/remote_transmitter/__init__.py @@ -8,6 +8,8 @@ from esphome.const import ( CONF_CLOCK_RESOLUTION, CONF_ID, CONF_INVERTED, + CONF_MODE, + CONF_OPEN_DRAIN, CONF_PIN, CONF_RMT_CHANNEL, CONF_RMT_SYMBOLS, @@ -20,7 +22,6 @@ AUTO_LOAD = ["remote_base"] CONF_EOT_LEVEL = "eot_level" CONF_ON_TRANSMIT = "on_transmit" CONF_ON_COMPLETE = "on_complete" -CONF_ONE_WIRE = "one_wire" remote_transmitter_ns = cg.esphome_ns.namespace("remote_transmitter") RemoteTransmitterComponent = remote_transmitter_ns.class_( @@ -44,7 +45,6 @@ CONFIG_SCHEMA = cv.Schema( cv.only_on_esp32, cv.only_with_arduino, cv.int_range(min=1, max=255) ), cv.Optional(CONF_EOT_LEVEL): cv.All(cv.only_with_esp_idf, cv.boolean), - cv.Optional(CONF_ONE_WIRE): cv.All(cv.only_with_esp_idf, cv.boolean), cv.Optional(CONF_USE_DMA): cv.All(cv.only_with_esp_idf, cv.boolean), cv.SplitDefault( CONF_RMT_SYMBOLS, @@ -74,14 +74,15 @@ async def to_code(config): cg.add(var.set_clock_resolution(config[CONF_CLOCK_RESOLUTION])) if CONF_USE_DMA in config: cg.add(var.set_with_dma(config[CONF_USE_DMA])) - if CONF_ONE_WIRE in config: - cg.add(var.set_one_wire(config[CONF_ONE_WIRE])) if CONF_EOT_LEVEL in config: cg.add(var.set_eot_level(config[CONF_EOT_LEVEL])) - elif CONF_ONE_WIRE in config and config[CONF_ONE_WIRE]: - cg.add(var.set_eot_level(True)) - elif CONF_INVERTED in config[CONF_PIN] and config[CONF_PIN][CONF_INVERTED]: - cg.add(var.set_eot_level(True)) + else: + cg.add( + var.set_eot_level( + config[CONF_PIN][CONF_MODE][CONF_OPEN_DRAIN] + or config[CONF_PIN][CONF_INVERTED] + ) + ) else: if (rmt_channel := config.get(CONF_RMT_CHANNEL, None)) is not None: var = cg.new_Pvariable(config[CONF_ID], pin, rmt_channel) diff --git a/esphome/components/remote_transmitter/remote_transmitter.h b/esphome/components/remote_transmitter/remote_transmitter.h index fd1d182063..0a8f354c72 100644 --- a/esphome/components/remote_transmitter/remote_transmitter.h +++ b/esphome/components/remote_transmitter/remote_transmitter.h @@ -40,7 +40,6 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase, #if defined(USE_ESP32) && ESP_IDF_VERSION_MAJOR >= 5 void set_with_dma(bool with_dma) { this->with_dma_ = with_dma; } - void set_one_wire(bool one_wire) { this->one_wire_ = one_wire; } void set_eot_level(bool eot_level) { this->eot_level_ = eot_level; } void digital_write(bool value); #endif @@ -69,7 +68,6 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase, #if ESP_IDF_VERSION_MAJOR >= 5 std::vector rmt_temp_; bool with_dma_{false}; - bool one_wire_{false}; bool eot_level_{false}; rmt_channel_handle_t channel_{NULL}; rmt_encoder_handle_t encoder_{NULL}; diff --git a/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp b/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp index cd7f366373..01a3980673 100644 --- a/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp +++ b/esphome/components/remote_transmitter/remote_transmitter_esp32.cpp @@ -3,6 +3,7 @@ #include "esphome/core/application.h" #ifdef USE_ESP32 +#include namespace esphome { namespace remote_transmitter { @@ -18,7 +19,6 @@ void RemoteTransmitterComponent::setup() { void RemoteTransmitterComponent::dump_config() { ESP_LOGCONFIG(TAG, "Remote Transmitter:"); #if ESP_IDF_VERSION_MAJOR >= 5 - ESP_LOGCONFIG(TAG, " One wire: %s", this->one_wire_ ? "true" : "false"); ESP_LOGCONFIG(TAG, " Clock resolution: %" PRIu32 " hz", this->clock_resolution_); ESP_LOGCONFIG(TAG, " RMT symbols: %" PRIu32, this->rmt_symbols_); #else @@ -68,6 +68,7 @@ void RemoteTransmitterComponent::configure_rmt_() { esp_err_t error; if (!this->initialized_) { + bool open_drain = (this->pin_->get_flags() & gpio::FLAG_OPEN_DRAIN) != 0; rmt_tx_channel_config_t channel; memset(&channel, 0, sizeof(channel)); channel.clk_src = RMT_CLK_SRC_DEFAULT; @@ -75,8 +76,8 @@ void RemoteTransmitterComponent::configure_rmt_() { channel.gpio_num = gpio_num_t(this->pin_->get_pin()); channel.mem_block_symbols = this->rmt_symbols_; channel.trans_queue_depth = 1; - channel.flags.io_loop_back = this->one_wire_; - channel.flags.io_od_mode = this->one_wire_; + channel.flags.io_loop_back = open_drain; + channel.flags.io_od_mode = open_drain; channel.flags.invert_out = 0; channel.flags.with_dma = this->with_dma_; channel.intr_priority = 0; @@ -91,6 +92,11 @@ void RemoteTransmitterComponent::configure_rmt_() { this->mark_failed(); return; } + if (this->pin_->get_flags() & gpio::FLAG_PULLUP) { + gpio_pullup_en(gpio_num_t(this->pin_->get_pin())); + } else { + gpio_pullup_dis(gpio_num_t(this->pin_->get_pin())); + } rmt_copy_encoder_config_t encoder; memset(&encoder, 0, sizeof(encoder)); @@ -109,7 +115,7 @@ void RemoteTransmitterComponent::configure_rmt_() { this->mark_failed(); return; } - this->digital_write(this->one_wire_ || this->inverted_); + this->digital_write(open_drain || this->inverted_); this->initialized_ = true; } diff --git a/tests/components/remote_transmitter/esp32-common-idf.yaml b/tests/components/remote_transmitter/esp32-common-idf.yaml index 3b8b5e2aef..c5d4ab7b96 100644 --- a/tests/components/remote_transmitter/esp32-common-idf.yaml +++ b/tests/components/remote_transmitter/esp32-common-idf.yaml @@ -3,7 +3,6 @@ remote_transmitter: pin: ${pin} carrier_duty_percent: 50% clock_resolution: ${clock_resolution} - one_wire: ${one_wire} rmt_symbols: ${rmt_symbols} use_dma: ${use_dma} diff --git a/tests/components/remote_transmitter/test.esp32-c3-idf.yaml b/tests/components/remote_transmitter/test.esp32-c3-idf.yaml index 1a27f29dac..be526014bd 100644 --- a/tests/components/remote_transmitter/test.esp32-c3-idf.yaml +++ b/tests/components/remote_transmitter/test.esp32-c3-idf.yaml @@ -1,7 +1,6 @@ substitutions: pin: GPIO2 clock_resolution: "2000000" - one_wire: "true" rmt_symbols: "64" use_dma: "true" diff --git a/tests/components/remote_transmitter/test.esp32-idf.yaml b/tests/components/remote_transmitter/test.esp32-idf.yaml index 1a27f29dac..be526014bd 100644 --- a/tests/components/remote_transmitter/test.esp32-idf.yaml +++ b/tests/components/remote_transmitter/test.esp32-idf.yaml @@ -1,7 +1,6 @@ substitutions: pin: GPIO2 clock_resolution: "2000000" - one_wire: "true" rmt_symbols: "64" use_dma: "true" diff --git a/tests/components/remote_transmitter/test.esp32-s3-idf.yaml b/tests/components/remote_transmitter/test.esp32-s3-idf.yaml index 25bdbd4772..cb86020064 100644 --- a/tests/components/remote_transmitter/test.esp32-s3-idf.yaml +++ b/tests/components/remote_transmitter/test.esp32-s3-idf.yaml @@ -1,7 +1,6 @@ substitutions: pin: GPIO38 clock_resolution: "2000000" - one_wire: "true" rmt_symbols: "64" use_dma: "true" From 9e3359cdf23685b6b6b9c4df4c824c0037847ed7 Mon Sep 17 00:00:00 2001 From: G-Two <7310260+G-Two@users.noreply.github.com> Date: Fri, 7 Feb 2025 00:08:06 -0500 Subject: [PATCH 167/194] Add Toto protocol to remote receiver and transmitter (#8177) --- esphome/components/remote_base/__init__.py | 108 +++++++++++++----- .../components/remote_base/toto_protocol.cpp | 100 ++++++++++++++++ .../components/remote_base/toto_protocol.h | 45 ++++++++ .../remote_receiver/common-actions.yaml | 5 + .../remote_transmitter/common-buttons.yaml | 7 ++ 5 files changed, 237 insertions(+), 28 deletions(-) create mode 100644 esphome/components/remote_base/toto_protocol.cpp create mode 100644 esphome/components/remote_base/toto_protocol.h diff --git a/esphome/components/remote_base/__init__.py b/esphome/components/remote_base/__init__.py index 3d1c10a092..daea4e5c11 100644 --- a/esphome/components/remote_base/__init__.py +++ b/esphome/components/remote_base/__init__.py @@ -1,41 +1,41 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_ADDRESS, + CONF_BUTTON, + CONF_CARRIER_FREQUENCY, + CONF_CHANNEL, + CONF_CHECK, + CONF_CODE, + CONF_COMMAND, CONF_COMMAND_REPEATS, CONF_DATA, - CONF_TRIGGER_ID, - CONF_NBITS, - CONF_ADDRESS, - CONF_COMMAND, - CONF_CODE, - CONF_PULSE_LENGTH, - CONF_SYNC, - CONF_ZERO, - CONF_ONE, - CONF_INVERTED, - CONF_PROTOCOL, - CONF_GROUP, + CONF_DELTA, CONF_DEVICE, - CONF_SECOND, - CONF_STATE, - CONF_CHANNEL, CONF_FAMILY, - CONF_REPEAT, - CONF_WAIT_TIME, - CONF_TIMES, - CONF_TYPE_ID, - CONF_CARRIER_FREQUENCY, + CONF_GROUP, + CONF_ID, + CONF_INVERTED, + CONF_LEVEL, + CONF_MAGNITUDE, + CONF_NBITS, + CONF_ONE, + CONF_PROTOCOL, + CONF_PULSE_LENGTH, CONF_RC_CODE_1, CONF_RC_CODE_2, - CONF_MAGNITUDE, + CONF_REPEAT, + CONF_SECOND, + CONF_STATE, + CONF_SYNC, + CONF_TIMES, + CONF_TRIGGER_ID, + CONF_TYPE_ID, + CONF_WAIT_TIME, CONF_WAND_ID, - CONF_LEVEL, - CONF_DELTA, - CONF_ID, - CONF_BUTTON, - CONF_CHECK, + CONF_ZERO, ) from esphome.core import coroutine from esphome.schema_extractors import SCHEMA_EXTRACT, schema_extractor @@ -1963,3 +1963,55 @@ async def mirage_action(var, config, args): vec_ = cg.std_vector.template(cg.uint8) template_ = await cg.templatable(config[CONF_CODE], args, vec_, vec_) cg.add(var.set_code(template_)) + + +# Toto +( + TotoData, + TotoBinarySensor, + TotoTrigger, + TotoAction, + TotoDumper, +) = declare_protocol("Toto") + +TOTO_SCHEMA = cv.Schema( + { + cv.Optional(CONF_RC_CODE_1, default=0): cv.hex_int_range(0, 0xF), + cv.Optional(CONF_RC_CODE_2, default=0): cv.hex_int_range(0, 0xF), + cv.Required(CONF_COMMAND): cv.hex_uint8_t, + } +) + + +@register_binary_sensor("toto", TotoBinarySensor, TOTO_SCHEMA) +def toto_binary_sensor(var, config): + cg.add( + var.set_data( + cg.StructInitializer( + TotoData, + ("rc_code_1", config[CONF_RC_CODE_1]), + ("rc_code_2", config[CONF_RC_CODE_2]), + ("command", config[CONF_COMMAND]), + ) + ) + ) + + +@register_trigger("toto", TotoTrigger, TotoData) +def toto_trigger(var, config): + pass + + +@register_dumper("toto", TotoDumper) +def toto_dumper(var, config): + pass + + +@register_action("toto", TotoAction, TOTO_SCHEMA) +async def Toto_action(var, config, args): + template_ = await cg.templatable(config[CONF_RC_CODE_1], args, cg.uint8) + cg.add(var.set_rc_code_1(template_)) + template_ = await cg.templatable(config[CONF_RC_CODE_2], args, cg.uint8) + cg.add(var.set_rc_code_2(template_)) + template_ = await cg.templatable(config[CONF_COMMAND], args, cg.uint8) + cg.add(var.set_command(template_)) diff --git a/esphome/components/remote_base/toto_protocol.cpp b/esphome/components/remote_base/toto_protocol.cpp new file mode 100644 index 0000000000..ba21263bc8 --- /dev/null +++ b/esphome/components/remote_base/toto_protocol.cpp @@ -0,0 +1,100 @@ +#include "toto_protocol.h" +#include "esphome/core/log.h" + +namespace esphome { +namespace remote_base { + +static const char *const TAG = "remote.toto"; + +static const uint32_t PREAMBLE_HIGH_US = 6200; +static const uint32_t PREAMBLE_LOW_US = 2800; +static const uint32_t BIT_HIGH_US = 550; +static const uint32_t BIT_ONE_LOW_US = 1700; +static const uint32_t BIT_ZERO_LOW_US = 550; +static const uint32_t TOTO_HEADER = 0x2008; + +void TotoProtocol::encode(RemoteTransmitData *dst, const TotoData &data) { + uint32_t payload = 0; + + payload = data.rc_code_1 << 20; + payload |= data.rc_code_2 << 16; + payload |= data.command << 8; + payload |= ((payload & 0xFF0000) >> 16) ^ ((payload & 0x00FF00) >> 8); + + dst->reserve(80); + dst->set_carrier_frequency(38000); + dst->item(PREAMBLE_HIGH_US, PREAMBLE_LOW_US); + + for (uint32_t mask = 1UL << 14; mask; mask >>= 1) { + if (TOTO_HEADER & mask) { + dst->item(BIT_HIGH_US, BIT_ONE_LOW_US); + } else { + dst->item(BIT_HIGH_US, BIT_ZERO_LOW_US); + } + } + + for (uint32_t mask = 1UL << 23; mask; mask >>= 1) { + if (payload & mask) { + dst->item(BIT_HIGH_US, BIT_ONE_LOW_US); + } else { + dst->item(BIT_HIGH_US, BIT_ZERO_LOW_US); + } + } + + dst->mark(BIT_HIGH_US); +} +optional TotoProtocol::decode(RemoteReceiveData src) { + uint16_t header = 0; + uint32_t payload = 0; + + TotoData data{ + .rc_code_1 = 0, + .rc_code_2 = 0, + .command = 0, + }; + + if (!src.expect_item(PREAMBLE_HIGH_US, PREAMBLE_LOW_US)) { + return {}; + } + + for (uint32_t mask = 1UL << 14; mask; mask >>= 1) { + if (src.expect_item(BIT_HIGH_US, BIT_ONE_LOW_US)) { + header |= mask; + } else if (src.expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) { + header &= ~mask; + } else { + return {}; + } + } + + if (header != TOTO_HEADER) { + return {}; + } + + for (uint32_t mask = 1UL << 23; mask; mask >>= 1) { + if (src.expect_item(BIT_HIGH_US, BIT_ONE_LOW_US)) { + payload |= mask; + } else if (src.expect_item(BIT_HIGH_US, BIT_ZERO_LOW_US)) { + payload &= ~mask; + } else { + return {}; + } + } + + if ((((payload & 0xFF0000) >> 16) ^ ((payload & 0x00FF00) >> 8)) != (payload & 0x0000FF)) { + return {}; + } + + data.rc_code_1 = (payload & 0xF00000) >> 20; + data.rc_code_2 = (payload & 0x0F0000) >> 16; + data.command = (payload & 0x00FF00) >> 8; + + return data; +} +void TotoProtocol::dump(const TotoData &data) { + ESP_LOGI(TAG, "Received Toto data: rc_code_1=0x%01X, rc_code_2=0x%01X, command=0x%02X", data.rc_code_1, + data.rc_code_2, data.command); +} + +} // namespace remote_base +} // namespace esphome diff --git a/esphome/components/remote_base/toto_protocol.h b/esphome/components/remote_base/toto_protocol.h new file mode 100644 index 0000000000..e62714bbbf --- /dev/null +++ b/esphome/components/remote_base/toto_protocol.h @@ -0,0 +1,45 @@ +#pragma once + +#include "remote_base.h" + +namespace esphome { +namespace remote_base { + +struct TotoData { + uint8_t rc_code_1 : 4; + uint8_t rc_code_2 : 4; + uint8_t command; + + bool operator==(const TotoData &rhs) const { + return (rc_code_1 == rhs.rc_code_1) && (rc_code_2 == rhs.rc_code_2) && (command == rhs.command); + } +}; + +class TotoProtocol : public RemoteProtocol { + public: + void encode(RemoteTransmitData *dst, const TotoData &data) override; + optional decode(RemoteReceiveData src) override; + void dump(const TotoData &data) override; +}; + +DECLARE_REMOTE_PROTOCOL(Toto) + +template class TotoAction : public RemoteTransmitterActionBase { + public: + TEMPLATABLE_VALUE(uint8_t, rc_code_1) + TEMPLATABLE_VALUE(uint8_t, rc_code_2) + TEMPLATABLE_VALUE(uint8_t, command) + + void encode(RemoteTransmitData *dst, Ts... x) override { + TotoData data{}; + data.rc_code_1 = this->rc_code_1_.value(x...); + data.rc_code_2 = this->rc_code_2_.value(x...); + data.command = this->command_.value(x...); + this->set_send_times(this->send_times_.value_or(x..., 3)); + this->set_send_wait(this->send_wait_.value_or(x..., 32000)); + TotoProtocol().encode(dst, data); + } +}; + +} // namespace remote_base +} // namespace esphome diff --git a/tests/components/remote_receiver/common-actions.yaml b/tests/components/remote_receiver/common-actions.yaml index 23589aed22..c1f576d20e 100644 --- a/tests/components/remote_receiver/common-actions.yaml +++ b/tests/components/remote_receiver/common-actions.yaml @@ -142,3 +142,8 @@ on_mirage: then: - lambda: |- ESP_LOGD("mirage", "Mirage data: %s", format_hex(x.data).c_str()); +on_toto: + then: + - logger.log: + format: "on_toto: %u %u %u" + args: ["x.rc_code_1", "x.rc_code_2", "x.command"] diff --git a/tests/components/remote_transmitter/common-buttons.yaml b/tests/components/remote_transmitter/common-buttons.yaml index c6a2453b20..b037c50e12 100644 --- a/tests/components/remote_transmitter/common-buttons.yaml +++ b/tests/components/remote_transmitter/common-buttons.yaml @@ -190,3 +190,10 @@ button: channel: 1 button: 1 check: 1 + - platform: template + name: Toto + on_press: + - remote_transmitter.transmit_toto: + command: 0xEC + rc_code_1: 0x0D + rc_code_2: 0x0D From da3d007d7b869fad9ec56aa0d0e3945c9bd32411 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sun, 9 Feb 2025 15:40:19 -0600 Subject: [PATCH 168/194] Markdown tweaks/updates (#8211) --- CONTRIBUTING.md | 20 +++++++++++--------- README.md | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c92d91159..7be7bdac2c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,14 @@ -# Contributing to ESPHome +# Contributing to ESPHome [![Discord Chat](https://img.shields.io/discord/429907082951524364.svg)](https://discord.gg/KhAMKrd) [![GitHub release](https://img.shields.io/github/release/esphome/esphome.svg)](https://GitHub.com/esphome/esphome/releases/) -For a detailed guide, please see https://esphome.io/guides/contributing.html#contributing-to-esphome +We welcome contributions to the ESPHome suite of code and documentation! -Things to note when contributing: +Please read our [contributing guide](https://esphome.io/guides/contributing.html) if you wish to contribute to the +project and be sure to join us on [Discord](https://discord.gg/KhAMKrd). - - Please test your changes :) - - If a new feature is added or an existing user-facing feature is changed, you should also - update the [docs](https://github.com/esphome/esphome-docs). See [contributing to esphome-docs](https://esphome.io/guides/contributing.html#contributing-to-esphomedocs) - for more information. - - Please also update the tests in the `tests/` folder. You can do so by just adding a line in one of the YAML files - which checks if your new feature compiles correctly. +**See also:** + +[Documentation](https://esphome.io) -- [Issues](https://github.com/esphome/issues/issues) -- [Feature requests](https://github.com/esphome/feature-requests/issues) + +--- + +[![ESPHome - A project from the Open Home Foundation](https://www.openhomefoundation.org/badges/esphome.png)](https://www.openhomefoundation.org/) diff --git a/README.md b/README.md index 8e3d8f71aa..4f527870b8 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ -**Documentation:** https://esphome.io/ +--- -For issues, please go to [the issue tracker](https://github.com/esphome/issues/issues). +[Documentation](https://esphome.io) -- [Issues](https://github.com/esphome/issues/issues) -- [Feature requests](https://github.com/esphome/feature-requests/issues) -For feature requests, please see [feature requests](https://github.com/esphome/feature-requests/issues). +--- [![ESPHome - A project from the Open Home Foundation](https://www.openhomefoundation.org/badges/esphome.png)](https://www.openhomefoundation.org/) From 353924257ab1e38ca9d3228e1ac12a0e52055179 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sun, 9 Feb 2025 15:43:10 -0600 Subject: [PATCH 169/194] [CI] Consolidate some tests (S) (#8206) --- tests/components/scd30/common.yaml | 20 +++++++ tests/components/scd30/test.esp32-ard.yaml | 23 ++------ tests/components/scd30/test.esp32-c3-ard.yaml | 23 ++------ tests/components/scd30/test.esp32-c3-idf.yaml | 23 ++------ tests/components/scd30/test.esp32-idf.yaml | 23 ++------ tests/components/scd30/test.esp8266-ard.yaml | 23 ++------ tests/components/scd30/test.rp2040-ard.yaml | 23 ++------ tests/components/scd4x/common.yaml | 20 +++++++ tests/components/scd4x/test.esp32-ard.yaml | 23 ++------ tests/components/scd4x/test.esp32-c3-ard.yaml | 23 ++------ tests/components/scd4x/test.esp32-c3-idf.yaml | 23 ++------ tests/components/scd4x/test.esp32-idf.yaml | 23 ++------ tests/components/scd4x/test.esp8266-ard.yaml | 23 ++------ tests/components/scd4x/test.rp2040-ard.yaml | 23 ++------ tests/components/sdm_meter/common.yaml | 23 ++++++++ .../components/sdm_meter/test.esp32-ard.yaml | 26 ++-------- .../sdm_meter/test.esp32-c3-ard.yaml | 26 ++-------- .../sdm_meter/test.esp32-c3-idf.yaml | 26 ++-------- .../components/sdm_meter/test.esp32-idf.yaml | 26 ++-------- .../sdm_meter/test.esp8266-ard.yaml | 26 ++-------- .../components/sdm_meter/test.rp2040-ard.yaml | 26 ++-------- tests/components/sdp3x/common.yaml | 11 ++++ tests/components/sdp3x/test.esp32-ard.yaml | 14 ++--- tests/components/sdp3x/test.esp32-c3-ard.yaml | 14 ++--- tests/components/sdp3x/test.esp32-c3-idf.yaml | 14 ++--- tests/components/sdp3x/test.esp32-idf.yaml | 14 ++--- tests/components/sdp3x/test.esp8266-ard.yaml | 14 ++--- tests/components/sdp3x/test.rp2040-ard.yaml | 14 ++--- tests/components/sds011/common.yaml | 14 +++++ tests/components/sds011/test.esp32-ard.yaml | 17 ++---- .../components/sds011/test.esp32-c3-ard.yaml | 17 ++---- .../components/sds011/test.esp32-c3-idf.yaml | 17 ++---- tests/components/sds011/test.esp32-idf.yaml | 17 ++---- tests/components/sds011/test.esp8266-ard.yaml | 17 ++---- tests/components/sds011/test.rp2040-ard.yaml | 17 ++---- tests/components/selec_meter/common.yaml | 45 ++++++++++++++++ .../selec_meter/test.esp32-ard.yaml | 48 ++--------------- .../selec_meter/test.esp32-c3-ard.yaml | 48 ++--------------- .../selec_meter/test.esp32-c3-idf.yaml | 48 ++--------------- .../selec_meter/test.esp32-idf.yaml | 48 ++--------------- .../selec_meter/test.esp8266-ard.yaml | 48 ++--------------- .../selec_meter/test.rp2040-ard.yaml | 48 ++--------------- tests/components/sen0321/common.yaml | 10 ++++ tests/components/sen0321/test.esp32-ard.yaml | 13 ++--- .../components/sen0321/test.esp32-c3-ard.yaml | 13 ++--- .../components/sen0321/test.esp32-c3-idf.yaml | 13 ++--- tests/components/sen0321/test.esp32-idf.yaml | 13 ++--- .../components/sen0321/test.esp8266-ard.yaml | 13 ++--- tests/components/sen0321/test.rp2040-ard.yaml | 13 ++--- tests/components/sen21231/common.yaml | 9 ++++ tests/components/sen21231/test.esp32-ard.yaml | 12 ++--- .../sen21231/test.esp32-c3-ard.yaml | 12 ++--- .../sen21231/test.esp32-c3-idf.yaml | 12 ++--- tests/components/sen21231/test.esp32-idf.yaml | 12 ++--- .../components/sen21231/test.esp8266-ard.yaml | 12 ++--- .../components/sen21231/test.rp2040-ard.yaml | 12 ++--- tests/components/sen5x/common.yaml | 49 +++++++++++++++++ tests/components/sen5x/test.esp32-ard.yaml | 52 ++----------------- tests/components/sen5x/test.esp32-c3-ard.yaml | 52 ++----------------- tests/components/sen5x/test.esp32-c3-idf.yaml | 52 ++----------------- tests/components/sen5x/test.esp32-idf.yaml | 52 ++----------------- tests/components/sen5x/test.esp8266-ard.yaml | 52 ++----------------- tests/components/sen5x/test.rp2040-ard.yaml | 52 ++----------------- tests/components/senseair/common.yaml | 19 +++++++ tests/components/senseair/test.esp32-ard.yaml | 22 ++------ .../senseair/test.esp32-c3-ard.yaml | 22 ++------ .../senseair/test.esp32-c3-idf.yaml | 22 ++------ tests/components/senseair/test.esp32-idf.yaml | 22 ++------ .../components/senseair/test.esp8266-ard.yaml | 22 ++------ .../components/senseair/test.rp2040-ard.yaml | 22 ++------ tests/components/servo/common.yaml | 19 +++++++ tests/components/servo/test.esp32-ard.yaml | 22 ++------ tests/components/servo/test.esp32-c3-ard.yaml | 22 ++------ tests/components/servo/test.esp32-c3-idf.yaml | 22 ++------ tests/components/servo/test.esp32-idf.yaml | 22 ++------ tests/components/servo/test.esp8266-ard.yaml | 22 ++------ tests/components/servo/test.rp2040-ard.yaml | 22 ++------ tests/components/sfa30/common.yaml | 15 ++++++ tests/components/sfa30/test.esp32-ard.yaml | 18 ++----- tests/components/sfa30/test.esp32-c3-ard.yaml | 18 ++----- tests/components/sfa30/test.esp32-c3-idf.yaml | 18 ++----- tests/components/sfa30/test.esp32-idf.yaml | 18 ++----- tests/components/sfa30/test.esp8266-ard.yaml | 18 ++----- tests/components/sfa30/test.rp2040-ard.yaml | 18 ++----- tests/components/sgp30/common.yaml | 15 ++++++ tests/components/sgp30/test.esp32-ard.yaml | 18 ++----- tests/components/sgp30/test.esp32-c3-ard.yaml | 18 ++----- tests/components/sgp30/test.esp32-c3-idf.yaml | 18 ++----- tests/components/sgp30/test.esp32-idf.yaml | 18 ++----- tests/components/sgp30/test.esp8266-ard.yaml | 18 ++----- tests/components/sgp30/test.rp2040-ard.yaml | 18 ++----- tests/components/sgp4x/common.yaml | 27 ++++++++++ tests/components/sgp4x/test.esp32-ard.yaml | 30 ++--------- tests/components/sgp4x/test.esp32-c3-ard.yaml | 30 ++--------- tests/components/sgp4x/test.esp32-c3-idf.yaml | 30 ++--------- tests/components/sgp4x/test.esp32-idf.yaml | 30 ++--------- tests/components/sgp4x/test.esp8266-ard.yaml | 30 ++--------- tests/components/sgp4x/test.rp2040-ard.yaml | 30 ++--------- tests/components/sht3xd/common.yaml | 13 +++++ tests/components/sht3xd/test.esp32-ard.yaml | 16 ++---- .../components/sht3xd/test.esp32-c3-ard.yaml | 16 ++---- .../components/sht3xd/test.esp32-c3-idf.yaml | 16 ++---- tests/components/sht3xd/test.esp32-idf.yaml | 16 ++---- tests/components/sht3xd/test.esp8266-ard.yaml | 16 ++---- tests/components/sht3xd/test.rp2040-ard.yaml | 16 ++---- tests/components/sht4x/common.yaml | 13 +++++ tests/components/sht4x/test.esp32-ard.yaml | 16 ++---- tests/components/sht4x/test.esp32-c3-ard.yaml | 16 ++---- tests/components/sht4x/test.esp32-c3-idf.yaml | 16 ++---- tests/components/sht4x/test.esp32-idf.yaml | 16 ++---- tests/components/sht4x/test.esp8266-ard.yaml | 16 ++---- tests/components/sht4x/test.rp2040-ard.yaml | 16 ++---- tests/components/shtcx/common.yaml | 13 +++++ tests/components/shtcx/test.esp32-ard.yaml | 16 ++---- tests/components/shtcx/test.esp32-c3-ard.yaml | 16 ++---- tests/components/shtcx/test.esp32-c3-idf.yaml | 16 ++---- tests/components/shtcx/test.esp32-idf.yaml | 16 ++---- tests/components/shtcx/test.esp8266-ard.yaml | 16 ++---- tests/components/shtcx/test.rp2040-ard.yaml | 16 ++---- tests/components/sim800l/common.yaml | 37 +++++++++++++ tests/components/sim800l/test.esp32-ard.yaml | 40 ++------------ .../components/sim800l/test.esp32-c3-ard.yaml | 40 ++------------ .../components/sim800l/test.esp32-c3-idf.yaml | 40 ++------------ tests/components/sim800l/test.esp32-idf.yaml | 40 ++------------ .../components/sim800l/test.esp8266-ard.yaml | 40 ++------------ tests/components/sim800l/test.rp2040-ard.yaml | 40 ++------------ tests/components/sm16716/common.yaml | 4 +- tests/components/sm16716/test.esp32-ard.yaml | 4 ++ .../components/sm16716/test.esp32-c3-ard.yaml | 4 ++ .../components/sm16716/test.esp32-c3-idf.yaml | 4 ++ tests/components/sm16716/test.esp32-idf.yaml | 4 ++ .../components/sm16716/test.esp8266-ard.yaml | 4 ++ tests/components/sm16716/test.rp2040-ard.yaml | 4 ++ tests/components/sm2135/common.yaml | 4 +- tests/components/sm2135/test.esp32-ard.yaml | 4 ++ .../components/sm2135/test.esp32-c3-ard.yaml | 4 ++ .../components/sm2135/test.esp32-c3-idf.yaml | 4 ++ tests/components/sm2135/test.esp32-idf.yaml | 4 ++ tests/components/sm2135/test.esp8266-ard.yaml | 4 ++ tests/components/sm2135/test.rp2040-ard.yaml | 4 ++ tests/components/sm2235/common.yaml | 4 +- tests/components/sm2235/test.esp32-ard.yaml | 4 ++ .../components/sm2235/test.esp32-c3-ard.yaml | 4 ++ .../components/sm2235/test.esp32-c3-idf.yaml | 4 ++ tests/components/sm2235/test.esp32-idf.yaml | 4 ++ tests/components/sm2235/test.esp8266-ard.yaml | 4 ++ tests/components/sm2235/test.rp2040-ard.yaml | 4 ++ tests/components/sm2335/common.yaml | 4 +- tests/components/sm2335/test.esp32-ard.yaml | 4 ++ .../components/sm2335/test.esp32-c3-ard.yaml | 4 ++ .../components/sm2335/test.esp32-c3-idf.yaml | 4 ++ tests/components/sm2335/test.esp32-idf.yaml | 4 ++ tests/components/sm2335/test.esp8266-ard.yaml | 4 ++ tests/components/sm2335/test.rp2040-ard.yaml | 4 ++ tests/components/sm300d2/common.yaml | 23 ++++++++ tests/components/sm300d2/test.esp32-ard.yaml | 26 ++-------- .../components/sm300d2/test.esp32-c3-ard.yaml | 26 ++-------- .../components/sm300d2/test.esp32-c3-idf.yaml | 26 ++-------- tests/components/sm300d2/test.esp32-idf.yaml | 26 ++-------- .../components/sm300d2/test.esp8266-ard.yaml | 26 ++-------- tests/components/sm300d2/test.rp2040-ard.yaml | 26 ++-------- tests/components/sml/common.yaml | 31 +++++++++++ tests/components/sml/test.esp32-ard.yaml | 34 ++---------- tests/components/sml/test.esp32-c3-ard.yaml | 34 ++---------- tests/components/sml/test.esp32-c3-idf.yaml | 34 ++---------- tests/components/sml/test.esp32-idf.yaml | 34 ++---------- tests/components/sml/test.esp8266-ard.yaml | 34 ++---------- tests/components/sml/test.rp2040-ard.yaml | 34 ++---------- tests/components/smt100/common.yaml | 19 +++++++ tests/components/smt100/test.esp32-ard.yaml | 22 ++------ .../components/smt100/test.esp32-c3-ard.yaml | 22 ++------ .../components/smt100/test.esp32-c3-idf.yaml | 22 ++------ tests/components/smt100/test.esp32-idf.yaml | 22 ++------ tests/components/smt100/test.esp8266-ard.yaml | 22 ++------ tests/components/smt100/test.rp2040-ard.yaml | 22 ++------ tests/components/sn74hc165/common.yaml | 14 +++++ .../components/sn74hc165/test.esp32-ard.yaml | 19 +++---- .../sn74hc165/test.esp32-c3-ard.yaml | 19 +++---- .../sn74hc165/test.esp32-c3-idf.yaml | 19 +++---- .../components/sn74hc165/test.esp32-idf.yaml | 19 +++---- .../sn74hc165/test.esp8266-ard.yaml | 19 +++---- .../components/sn74hc165/test.rp2040-ard.yaml | 19 +++---- tests/components/sn74hc595/common.yaml | 26 ++++++++++ .../components/sn74hc595/test.esp32-ard.yaml | 37 ++++--------- .../sn74hc595/test.esp32-c3-ard.yaml | 37 ++++--------- .../sn74hc595/test.esp32-c3-idf.yaml | 37 ++++--------- .../components/sn74hc595/test.esp32-idf.yaml | 37 ++++--------- .../sn74hc595/test.esp8266-ard.yaml | 37 ++++--------- .../components/sn74hc595/test.rp2040-ard.yaml | 37 ++++--------- tests/components/sonoff_d1/common.yaml | 12 +++++ .../components/sonoff_d1/test.esp32-ard.yaml | 15 ++---- .../sonoff_d1/test.esp32-c3-ard.yaml | 5 ++ .../sonoff_d1/test.esp32-c3-idf.yaml | 5 ++ .../components/sonoff_d1/test.esp32-idf.yaml | 15 ++---- .../sonoff_d1/test.esp8266-ard.yaml | 15 ++---- .../components/sonoff_d1/test.rp2040-ard.yaml | 5 ++ .../speaker/audio_dac.esp32-ard.yaml | 9 ++++ .../speaker/audio_dac.esp32-c3-ard.yaml | 9 ++++ .../speaker/audio_dac.esp32-c3-idf.yaml | 9 ++++ .../speaker/audio_dac.esp32-idf.yaml | 9 ++++ .../components/speaker/common-audio_dac.yaml | 36 +++++++++++++ tests/components/speaker/common.yaml | 26 ++++++++++ tests/components/speaker/test.esp32-ard.yaml | 33 +++--------- .../components/speaker/test.esp32-c3-ard.yaml | 33 +++--------- .../components/speaker/test.esp32-c3-idf.yaml | 33 +++--------- tests/components/speaker/test.esp32-idf.yaml | 42 +++------------ tests/components/speed/common.yaml | 9 ++++ tests/components/speed/test.esp32-ard.yaml | 12 ++--- tests/components/speed/test.esp32-c3-ard.yaml | 12 ++--- tests/components/speed/test.esp32-c3-idf.yaml | 12 ++--- tests/components/speed/test.esp32-idf.yaml | 12 ++--- tests/components/speed/test.esp8266-ard.yaml | 12 ++--- tests/components/speed/test.rp2040-ard.yaml | 12 ++--- tests/components/spi/common.yaml | 5 ++ tests/components/spi/test.esp32-ard.yaml | 11 ++-- tests/components/spi/test.esp32-c3-ard.yaml | 11 ++-- tests/components/spi/test.esp32-c3-idf.yaml | 11 ++-- tests/components/spi/test.esp32-idf.yaml | 11 ++-- tests/components/spi/test.esp32-s3-idf.yaml | 4 +- tests/components/spi/test.esp8266-ard.yaml | 11 ++-- tests/components/spi/test.rp2040-ard.yaml | 11 ++-- tests/components/spi_device/common.yaml | 11 ++++ .../components/spi_device/test.esp32-ard.yaml | 15 ++---- .../spi_device/test.esp32-c3-ard.yaml | 15 ++---- .../spi_device/test.esp32-c3-idf.yaml | 15 ++---- .../components/spi_device/test.esp32-idf.yaml | 15 ++---- .../spi_device/test.esp8266-ard.yaml | 15 ++---- .../spi_device/test.rp2040-ard.yaml | 15 ++---- tests/components/spi_led_strip/common.yaml | 12 +++++ .../spi_led_strip/test.esp32-ard.yaml | 16 ++---- .../spi_led_strip/test.esp32-c3-ard.yaml | 16 ++---- .../spi_led_strip/test.esp32-c3-idf.yaml | 16 ++---- .../spi_led_strip/test.esp32-idf.yaml | 16 ++---- .../spi_led_strip/test.esp8266-ard.yaml | 16 ++---- .../spi_led_strip/test.rp2040-ard.yaml | 16 ++---- tests/components/sps30/common.yaml | 36 +++++++++++++ tests/components/sps30/test.esp32-ard.yaml | 39 ++------------ tests/components/sps30/test.esp32-c3-ard.yaml | 39 ++------------ tests/components/sps30/test.esp32-c3-idf.yaml | 39 ++------------ tests/components/sps30/test.esp32-idf.yaml | 39 ++------------ tests/components/sps30/test.esp8266-ard.yaml | 39 ++------------ tests/components/sps30/test.rp2040-ard.yaml | 39 ++------------ tests/components/ssd1306_i2c/common.yaml | 25 +++++++++ .../ssd1306_i2c/test.esp32-ard.yaml | 29 ++--------- .../ssd1306_i2c/test.esp32-c3-ard.yaml | 29 ++--------- .../ssd1306_i2c/test.esp32-c3-idf.yaml | 29 ++--------- .../ssd1306_i2c/test.esp32-idf.yaml | 29 ++--------- .../ssd1306_i2c/test.esp8266-ard.yaml | 29 ++--------- .../ssd1306_i2c/test.rp2040-ard.yaml | 29 ++--------- tests/components/ssd1306_spi/common.yaml | 24 +++++++++ .../ssd1306_spi/test.esp32-ard.yaml | 31 +++-------- .../ssd1306_spi/test.esp32-c3-ard.yaml | 32 +++--------- .../ssd1306_spi/test.esp32-c3-idf.yaml | 32 +++--------- .../ssd1306_spi/test.esp32-idf.yaml | 31 +++-------- .../ssd1306_spi/test.esp8266-ard.yaml | 32 +++--------- .../ssd1306_spi/test.rp2040-ard.yaml | 32 +++--------- tests/components/ssd1322_spi/common.yaml | 24 +++++++++ .../ssd1322_spi/test.esp32-ard.yaml | 31 +++-------- .../ssd1322_spi/test.esp32-c3-ard.yaml | 32 +++--------- .../ssd1322_spi/test.esp32-c3-idf.yaml | 32 +++--------- .../ssd1322_spi/test.esp32-idf.yaml | 31 +++-------- .../ssd1322_spi/test.esp8266-ard.yaml | 32 +++--------- .../ssd1322_spi/test.rp2040-ard.yaml | 32 +++--------- tests/components/ssd1325_spi/common.yaml | 24 +++++++++ .../ssd1325_spi/test.esp32-ard.yaml | 31 +++-------- .../ssd1325_spi/test.esp32-c3-ard.yaml | 32 +++--------- .../ssd1325_spi/test.esp32-c3-idf.yaml | 32 +++--------- .../ssd1325_spi/test.esp32-idf.yaml | 31 +++-------- .../ssd1325_spi/test.esp8266-ard.yaml | 32 +++--------- .../ssd1325_spi/test.rp2040-ard.yaml | 32 +++--------- tests/components/ssd1327_i2c/common.yaml | 24 +++++++++ .../ssd1327_i2c/test.esp32-ard.yaml | 28 ++-------- .../ssd1327_i2c/test.esp32-c3-ard.yaml | 28 ++-------- .../ssd1327_i2c/test.esp32-c3-idf.yaml | 28 ++-------- .../ssd1327_i2c/test.esp32-idf.yaml | 28 ++-------- .../ssd1327_i2c/test.esp8266-ard.yaml | 28 ++-------- .../ssd1327_i2c/test.rp2040-ard.yaml | 28 ++-------- tests/components/ssd1327_spi/common.yaml | 24 +++++++++ .../ssd1327_spi/test.esp32-ard.yaml | 31 +++-------- .../ssd1327_spi/test.esp32-c3-ard.yaml | 32 +++--------- .../ssd1327_spi/test.esp32-c3-idf.yaml | 32 +++--------- .../ssd1327_spi/test.esp32-idf.yaml | 31 +++-------- .../ssd1327_spi/test.esp8266-ard.yaml | 32 +++--------- .../ssd1327_spi/test.rp2040-ard.yaml | 32 +++--------- tests/components/ssd1331_spi/common.yaml | 23 ++++++++ .../ssd1331_spi/test.esp32-ard.yaml | 30 +++-------- .../ssd1331_spi/test.esp32-c3-ard.yaml | 31 +++-------- .../ssd1331_spi/test.esp32-c3-idf.yaml | 31 +++-------- .../ssd1331_spi/test.esp32-idf.yaml | 30 +++-------- .../ssd1331_spi/test.esp8266-ard.yaml | 31 +++-------- .../ssd1331_spi/test.rp2040-ard.yaml | 31 +++-------- tests/components/ssd1351_spi/common.yaml | 24 +++++++++ .../ssd1351_spi/test.esp32-ard.yaml | 31 +++-------- .../ssd1351_spi/test.esp32-c3-ard.yaml | 32 +++--------- .../ssd1351_spi/test.esp32-c3-idf.yaml | 32 +++--------- .../ssd1351_spi/test.esp32-idf.yaml | 31 +++-------- .../ssd1351_spi/test.esp8266-ard.yaml | 32 +++--------- .../ssd1351_spi/test.rp2040-ard.yaml | 32 +++--------- tests/components/st7567_i2c/common.yaml | 23 ++++++++ .../components/st7567_i2c/test.esp32-ard.yaml | 27 ++-------- .../st7567_i2c/test.esp32-c3-ard.yaml | 27 ++-------- .../st7567_i2c/test.esp32-c3-idf.yaml | 27 ++-------- .../components/st7567_i2c/test.esp32-idf.yaml | 27 ++-------- .../st7567_i2c/test.esp8266-ard.yaml | 27 ++-------- .../st7567_i2c/test.rp2040-ard.yaml | 27 ++-------- tests/components/st7567_spi/common.yaml | 23 ++++++++ .../components/st7567_spi/test.esp32-ard.yaml | 30 +++-------- .../st7567_spi/test.esp32-c3-ard.yaml | 31 +++-------- .../st7567_spi/test.esp32-c3-idf.yaml | 31 +++-------- .../components/st7567_spi/test.esp32-idf.yaml | 30 +++-------- .../st7567_spi/test.esp8266-ard.yaml | 31 +++-------- .../st7567_spi/test.rp2040-ard.yaml | 31 +++-------- tests/components/st7701s/common.yaml | 42 ++++----------- .../components/st7701s/test.esp32-s3-idf.yaml | 10 ++++ tests/components/st7735/common.yaml | 28 ++++++++++ tests/components/st7735/test.esp32-ard.yaml | 35 +++---------- .../components/st7735/test.esp32-c3-ard.yaml | 36 +++---------- .../components/st7735/test.esp32-c3-idf.yaml | 36 +++---------- tests/components/st7735/test.esp32-idf.yaml | 35 +++---------- tests/components/st7735/test.esp8266-ard.yaml | 36 +++---------- tests/components/st7735/test.rp2040-ard.yaml | 36 +++---------- tests/components/st7789v/common.yaml | 24 +++++++++ tests/components/st7789v/test.esp32-ard.yaml | 31 +++-------- .../components/st7789v/test.esp32-c3-ard.yaml | 32 +++--------- .../components/st7789v/test.esp32-c3-idf.yaml | 32 +++--------- tests/components/st7789v/test.esp32-idf.yaml | 31 +++-------- .../components/st7789v/test.esp8266-ard.yaml | 32 +++--------- tests/components/st7789v/test.rp2040-ard.yaml | 32 +++--------- tests/components/st7920/common.yaml | 23 ++++++++ tests/components/st7920/test.esp32-ard.yaml | 28 ++-------- .../components/st7920/test.esp32-c3-ard.yaml | 29 +++-------- .../components/st7920/test.esp32-c3-idf.yaml | 29 +++-------- tests/components/st7920/test.esp32-idf.yaml | 28 ++-------- tests/components/st7920/test.esp8266-ard.yaml | 29 +++-------- tests/components/st7920/test.rp2040-ard.yaml | 29 +++-------- tests/components/sts3x/common.yaml | 10 ++++ tests/components/sts3x/test.esp32-ard.yaml | 13 ++--- tests/components/sts3x/test.esp32-c3-ard.yaml | 13 ++--- tests/components/sts3x/test.esp32-c3-idf.yaml | 13 ++--- tests/components/sts3x/test.esp32-idf.yaml | 13 ++--- tests/components/sts3x/test.esp8266-ard.yaml | 13 ++--- tests/components/sts3x/test.rp2040-ard.yaml | 13 ++--- tests/components/sun_gtil2/common.yaml | 40 ++++++++++++++ .../components/sun_gtil2/test.esp32-ard.yaml | 46 ++-------------- .../sun_gtil2/test.esp32-c3-ard.yaml | 46 ++-------------- .../sun_gtil2/test.esp32-c3-idf.yaml | 46 ++-------------- .../components/sun_gtil2/test.esp32-idf.yaml | 46 ++-------------- .../sun_gtil2/test.esp8266-ard.yaml | 46 ++-------------- .../components/sun_gtil2/test.rp2040-ard.yaml | 46 ++-------------- tests/components/sx1509/common.yaml | 33 ++++++++++++ tests/components/sx1509/test.esp32-ard.yaml | 36 ++----------- .../components/sx1509/test.esp32-c3-ard.yaml | 36 ++----------- .../components/sx1509/test.esp32-c3-idf.yaml | 36 ++----------- tests/components/sx1509/test.esp32-idf.yaml | 36 ++----------- tests/components/sx1509/test.esp8266-ard.yaml | 36 ++----------- tests/components/sx1509/test.rp2040-ard.yaml | 36 ++----------- 356 files changed, 2598 insertions(+), 5745 deletions(-) create mode 100644 tests/components/scd30/common.yaml create mode 100644 tests/components/scd4x/common.yaml create mode 100644 tests/components/sdm_meter/common.yaml create mode 100644 tests/components/sdp3x/common.yaml create mode 100644 tests/components/sds011/common.yaml create mode 100644 tests/components/selec_meter/common.yaml create mode 100644 tests/components/sen0321/common.yaml create mode 100644 tests/components/sen21231/common.yaml create mode 100644 tests/components/sen5x/common.yaml create mode 100644 tests/components/senseair/common.yaml create mode 100644 tests/components/servo/common.yaml create mode 100644 tests/components/sfa30/common.yaml create mode 100644 tests/components/sgp30/common.yaml create mode 100644 tests/components/sgp4x/common.yaml create mode 100644 tests/components/sht3xd/common.yaml create mode 100644 tests/components/sht4x/common.yaml create mode 100644 tests/components/shtcx/common.yaml create mode 100644 tests/components/sim800l/common.yaml create mode 100644 tests/components/sm300d2/common.yaml create mode 100644 tests/components/sml/common.yaml create mode 100644 tests/components/smt100/common.yaml create mode 100644 tests/components/sn74hc165/common.yaml create mode 100644 tests/components/sn74hc595/common.yaml create mode 100644 tests/components/sonoff_d1/common.yaml create mode 100644 tests/components/sonoff_d1/test.esp32-c3-ard.yaml create mode 100644 tests/components/sonoff_d1/test.esp32-c3-idf.yaml create mode 100644 tests/components/sonoff_d1/test.rp2040-ard.yaml create mode 100644 tests/components/speaker/audio_dac.esp32-ard.yaml create mode 100644 tests/components/speaker/audio_dac.esp32-c3-ard.yaml create mode 100644 tests/components/speaker/audio_dac.esp32-c3-idf.yaml create mode 100644 tests/components/speaker/audio_dac.esp32-idf.yaml create mode 100644 tests/components/speaker/common-audio_dac.yaml create mode 100644 tests/components/speaker/common.yaml create mode 100644 tests/components/speed/common.yaml create mode 100644 tests/components/spi/common.yaml create mode 100644 tests/components/spi_device/common.yaml create mode 100644 tests/components/spi_led_strip/common.yaml create mode 100644 tests/components/sps30/common.yaml create mode 100644 tests/components/ssd1306_i2c/common.yaml create mode 100644 tests/components/ssd1306_spi/common.yaml create mode 100644 tests/components/ssd1322_spi/common.yaml create mode 100644 tests/components/ssd1325_spi/common.yaml create mode 100644 tests/components/ssd1327_i2c/common.yaml create mode 100644 tests/components/ssd1327_spi/common.yaml create mode 100644 tests/components/ssd1331_spi/common.yaml create mode 100644 tests/components/ssd1351_spi/common.yaml create mode 100644 tests/components/st7567_i2c/common.yaml create mode 100644 tests/components/st7567_spi/common.yaml create mode 100644 tests/components/st7735/common.yaml create mode 100644 tests/components/st7789v/common.yaml create mode 100644 tests/components/st7920/common.yaml create mode 100644 tests/components/sts3x/common.yaml create mode 100644 tests/components/sun_gtil2/common.yaml create mode 100644 tests/components/sx1509/common.yaml diff --git a/tests/components/scd30/common.yaml b/tests/components/scd30/common.yaml new file mode 100644 index 0000000000..1c45c67af0 --- /dev/null +++ b/tests/components/scd30/common.yaml @@ -0,0 +1,20 @@ +i2c: + - id: i2c_scd30 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: scd30 + co2: + name: SCD30 CO2 + temperature: + id: scd30_temperature + name: SCD30 Temperature + humidity: + name: SCD30 Humidity + address: 0x61 + automatic_self_calibration: true + altitude_compensation: 10m + ambient_pressure_compensation: 961mBar + temperature_offset: 4.2C + update_interval: 15s diff --git a/tests/components/scd30/test.esp32-ard.yaml b/tests/components/scd30/test.esp32-ard.yaml index b48f8054c8..63c3bd6afd 100644 --- a/tests/components/scd30/test.esp32-ard.yaml +++ b/tests/components/scd30/test.esp32-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd30/test.esp32-c3-ard.yaml b/tests/components/scd30/test.esp32-c3-ard.yaml index 80f02a1b87..ee2c29ca4e 100644 --- a/tests/components/scd30/test.esp32-c3-ard.yaml +++ b/tests/components/scd30/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd30/test.esp32-c3-idf.yaml b/tests/components/scd30/test.esp32-c3-idf.yaml index 80f02a1b87..ee2c29ca4e 100644 --- a/tests/components/scd30/test.esp32-c3-idf.yaml +++ b/tests/components/scd30/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd30/test.esp32-idf.yaml b/tests/components/scd30/test.esp32-idf.yaml index b48f8054c8..63c3bd6afd 100644 --- a/tests/components/scd30/test.esp32-idf.yaml +++ b/tests/components/scd30/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd30/test.esp8266-ard.yaml b/tests/components/scd30/test.esp8266-ard.yaml index 80f02a1b87..ee2c29ca4e 100644 --- a/tests/components/scd30/test.esp8266-ard.yaml +++ b/tests/components/scd30/test.esp8266-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd30/test.rp2040-ard.yaml b/tests/components/scd30/test.rp2040-ard.yaml index 80f02a1b87..ee2c29ca4e 100644 --- a/tests/components/scd30/test.rp2040-ard.yaml +++ b/tests/components/scd30/test.rp2040-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/common.yaml b/tests/components/scd4x/common.yaml new file mode 100644 index 0000000000..dfd35e57de --- /dev/null +++ b/tests/components/scd4x/common.yaml @@ -0,0 +1,20 @@ +i2c: + - id: i2c_scd4x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: scd4x + id: scd40 + co2: + name: SCD4X CO2 + temperature: + id: scd4x_temperature + name: SCD4X Temperature + humidity: + name: SCD4X Humidity + automatic_self_calibration: true + altitude_compensation: 10m + ambient_pressure_compensation: 961mBar + temperature_offset: 4.2C + update_interval: 15s diff --git a/tests/components/scd4x/test.esp32-ard.yaml b/tests/components/scd4x/test.esp32-ard.yaml index 02cec921d2..63c3bd6afd 100644 --- a/tests/components/scd4x/test.esp32-ard.yaml +++ b/tests/components/scd4x/test.esp32-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/test.esp32-c3-ard.yaml b/tests/components/scd4x/test.esp32-c3-ard.yaml index 353293be65..ee2c29ca4e 100644 --- a/tests/components/scd4x/test.esp32-c3-ard.yaml +++ b/tests/components/scd4x/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/test.esp32-c3-idf.yaml b/tests/components/scd4x/test.esp32-c3-idf.yaml index 353293be65..ee2c29ca4e 100644 --- a/tests/components/scd4x/test.esp32-c3-idf.yaml +++ b/tests/components/scd4x/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/test.esp32-idf.yaml b/tests/components/scd4x/test.esp32-idf.yaml index 02cec921d2..63c3bd6afd 100644 --- a/tests/components/scd4x/test.esp32-idf.yaml +++ b/tests/components/scd4x/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/test.esp8266-ard.yaml b/tests/components/scd4x/test.esp8266-ard.yaml index 353293be65..ee2c29ca4e 100644 --- a/tests/components/scd4x/test.esp8266-ard.yaml +++ b/tests/components/scd4x/test.esp8266-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/test.rp2040-ard.yaml b/tests/components/scd4x/test.rp2040-ard.yaml index 353293be65..ee2c29ca4e 100644 --- a/tests/components/scd4x/test.rp2040-ard.yaml +++ b/tests/components/scd4x/test.rp2040-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sdm_meter/common.yaml b/tests/components/sdm_meter/common.yaml new file mode 100644 index 0000000000..60c71a796b --- /dev/null +++ b/tests/components/sdm_meter/common.yaml @@ -0,0 +1,23 @@ +uart: + - id: uart_sdm_meter + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: sdm_meter + phase_a: + current: + name: Phase A Current + voltage: + name: Phase A Voltage + active_power: + name: Phase A Power + power_factor: + name: Phase A Power Factor + apparent_power: + name: Phase A Apparent Power + reactive_power: + name: Phase A Reactive Power + phase_angle: + name: Phase A Phase Angle diff --git a/tests/components/sdm_meter/test.esp32-ard.yaml b/tests/components/sdm_meter/test.esp32-ard.yaml index eb3958db19..f486544afa 100644 --- a/tests/components/sdm_meter/test.esp32-ard.yaml +++ b/tests/components/sdm_meter/test.esp32-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdm_meter/test.esp32-c3-ard.yaml b/tests/components/sdm_meter/test.esp32-c3-ard.yaml index 0c2144f983..b516342f3b 100644 --- a/tests/components/sdm_meter/test.esp32-c3-ard.yaml +++ b/tests/components/sdm_meter/test.esp32-c3-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdm_meter/test.esp32-c3-idf.yaml b/tests/components/sdm_meter/test.esp32-c3-idf.yaml index 0c2144f983..b516342f3b 100644 --- a/tests/components/sdm_meter/test.esp32-c3-idf.yaml +++ b/tests/components/sdm_meter/test.esp32-c3-idf.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdm_meter/test.esp32-idf.yaml b/tests/components/sdm_meter/test.esp32-idf.yaml index eb3958db19..f486544afa 100644 --- a/tests/components/sdm_meter/test.esp32-idf.yaml +++ b/tests/components/sdm_meter/test.esp32-idf.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdm_meter/test.esp8266-ard.yaml b/tests/components/sdm_meter/test.esp8266-ard.yaml index 0c2144f983..b516342f3b 100644 --- a/tests/components/sdm_meter/test.esp8266-ard.yaml +++ b/tests/components/sdm_meter/test.esp8266-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdm_meter/test.rp2040-ard.yaml b/tests/components/sdm_meter/test.rp2040-ard.yaml index 0c2144f983..b516342f3b 100644 --- a/tests/components/sdm_meter/test.rp2040-ard.yaml +++ b/tests/components/sdm_meter/test.rp2040-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdp3x/common.yaml b/tests/components/sdp3x/common.yaml new file mode 100644 index 0000000000..d3c5491ca5 --- /dev/null +++ b/tests/components/sdp3x/common.yaml @@ -0,0 +1,11 @@ +i2c: + - id: i2c_sdp3x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sdp3x + id: filter_pressure + name: HVAC Filter Pressure drop + accuracy_decimals: 3 + update_interval: 5s diff --git a/tests/components/sdp3x/test.esp32-ard.yaml b/tests/components/sdp3x/test.esp32-ard.yaml index 00666082eb..63c3bd6afd 100644 --- a/tests/components/sdp3x/test.esp32-ard.yaml +++ b/tests/components/sdp3x/test.esp32-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sdp3x/test.esp32-c3-ard.yaml b/tests/components/sdp3x/test.esp32-c3-ard.yaml index 42b90f1b81..ee2c29ca4e 100644 --- a/tests/components/sdp3x/test.esp32-c3-ard.yaml +++ b/tests/components/sdp3x/test.esp32-c3-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sdp3x/test.esp32-c3-idf.yaml b/tests/components/sdp3x/test.esp32-c3-idf.yaml index 42b90f1b81..ee2c29ca4e 100644 --- a/tests/components/sdp3x/test.esp32-c3-idf.yaml +++ b/tests/components/sdp3x/test.esp32-c3-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sdp3x/test.esp32-idf.yaml b/tests/components/sdp3x/test.esp32-idf.yaml index 00666082eb..63c3bd6afd 100644 --- a/tests/components/sdp3x/test.esp32-idf.yaml +++ b/tests/components/sdp3x/test.esp32-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sdp3x/test.esp8266-ard.yaml b/tests/components/sdp3x/test.esp8266-ard.yaml index 42b90f1b81..ee2c29ca4e 100644 --- a/tests/components/sdp3x/test.esp8266-ard.yaml +++ b/tests/components/sdp3x/test.esp8266-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sdp3x/test.rp2040-ard.yaml b/tests/components/sdp3x/test.rp2040-ard.yaml index 42b90f1b81..ee2c29ca4e 100644 --- a/tests/components/sdp3x/test.rp2040-ard.yaml +++ b/tests/components/sdp3x/test.rp2040-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sds011/common.yaml b/tests/components/sds011/common.yaml new file mode 100644 index 0000000000..c7574e1d7d --- /dev/null +++ b/tests/components/sds011/common.yaml @@ -0,0 +1,14 @@ +uart: + - id: uart_sdm_sds011 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 115200 + +sensor: + - platform: sds011 + pm_2_5: + name: SDS011 PM2.5 + pm_10_0: + name: SDS011 PM10.0 + rx_only: false + update_interval: 5min diff --git a/tests/components/sds011/test.esp32-ard.yaml b/tests/components/sds011/test.esp32-ard.yaml index 275390f14c..f486544afa 100644 --- a/tests/components/sds011/test.esp32-ard.yaml +++ b/tests/components/sds011/test.esp32-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/sds011/test.esp32-c3-ard.yaml b/tests/components/sds011/test.esp32-c3-ard.yaml index e680a62dfe..b516342f3b 100644 --- a/tests/components/sds011/test.esp32-c3-ard.yaml +++ b/tests/components/sds011/test.esp32-c3-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/sds011/test.esp32-c3-idf.yaml b/tests/components/sds011/test.esp32-c3-idf.yaml index e680a62dfe..b516342f3b 100644 --- a/tests/components/sds011/test.esp32-c3-idf.yaml +++ b/tests/components/sds011/test.esp32-c3-idf.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/sds011/test.esp32-idf.yaml b/tests/components/sds011/test.esp32-idf.yaml index 275390f14c..f486544afa 100644 --- a/tests/components/sds011/test.esp32-idf.yaml +++ b/tests/components/sds011/test.esp32-idf.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/sds011/test.esp8266-ard.yaml b/tests/components/sds011/test.esp8266-ard.yaml index e680a62dfe..b516342f3b 100644 --- a/tests/components/sds011/test.esp8266-ard.yaml +++ b/tests/components/sds011/test.esp8266-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/sds011/test.rp2040-ard.yaml b/tests/components/sds011/test.rp2040-ard.yaml index e680a62dfe..b516342f3b 100644 --- a/tests/components/sds011/test.rp2040-ard.yaml +++ b/tests/components/sds011/test.rp2040-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/selec_meter/common.yaml b/tests/components/selec_meter/common.yaml new file mode 100644 index 0000000000..f2714ce828 --- /dev/null +++ b/tests/components/selec_meter/common.yaml @@ -0,0 +1,45 @@ +uart: + - id: uart_selec_meter + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: selec_meter + total_active_energy: + name: SelecEM2M Total Active Energy + import_active_energy: + name: SelecEM2M Import Active Energy + export_active_energy: + name: SelecEM2M Export Active Energy + total_reactive_energy: + name: SelecEM2M Total Reactive Energy + import_reactive_energy: + name: SelecEM2M Import Reactive Energy + export_reactive_energy: + name: SelecEM2M Export Reactive Energy + apparent_energy: + name: SelecEM2M Apparent Energy + active_power: + name: SelecEM2M Active Power + reactive_power: + name: SelecEM2M Reactive Power + apparent_power: + name: SelecEM2M Apparent Power + voltage: + name: SelecEM2M Voltage + current: + name: SelecEM2M Current + power_factor: + name: SelecEM2M Power Factor + frequency: + name: SelecEM2M Frequency + maximum_demand_active_power: + name: SelecEM2M Maximum Demand Active Power + disabled_by_default: true + maximum_demand_reactive_power: + name: SelecEM2M Maximum Demand Reactive Power + disabled_by_default: true + maximum_demand_apparent_power: + name: SelecEM2M Maximum Demand Apparent Power + disabled_by_default: true diff --git a/tests/components/selec_meter/test.esp32-ard.yaml b/tests/components/selec_meter/test.esp32-ard.yaml index 648adc1757..f486544afa 100644 --- a/tests/components/selec_meter/test.esp32-ard.yaml +++ b/tests/components/selec_meter/test.esp32-ard.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/selec_meter/test.esp32-c3-ard.yaml b/tests/components/selec_meter/test.esp32-c3-ard.yaml index 5f6e69f96f..b516342f3b 100644 --- a/tests/components/selec_meter/test.esp32-c3-ard.yaml +++ b/tests/components/selec_meter/test.esp32-c3-ard.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/selec_meter/test.esp32-c3-idf.yaml b/tests/components/selec_meter/test.esp32-c3-idf.yaml index 5f6e69f96f..b516342f3b 100644 --- a/tests/components/selec_meter/test.esp32-c3-idf.yaml +++ b/tests/components/selec_meter/test.esp32-c3-idf.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/selec_meter/test.esp32-idf.yaml b/tests/components/selec_meter/test.esp32-idf.yaml index 648adc1757..f486544afa 100644 --- a/tests/components/selec_meter/test.esp32-idf.yaml +++ b/tests/components/selec_meter/test.esp32-idf.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/selec_meter/test.esp8266-ard.yaml b/tests/components/selec_meter/test.esp8266-ard.yaml index 5f6e69f96f..b516342f3b 100644 --- a/tests/components/selec_meter/test.esp8266-ard.yaml +++ b/tests/components/selec_meter/test.esp8266-ard.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/selec_meter/test.rp2040-ard.yaml b/tests/components/selec_meter/test.rp2040-ard.yaml index 5f6e69f96f..b516342f3b 100644 --- a/tests/components/selec_meter/test.rp2040-ard.yaml +++ b/tests/components/selec_meter/test.rp2040-ard.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/sen0321/common.yaml b/tests/components/sen0321/common.yaml new file mode 100644 index 0000000000..8b9fdff4a1 --- /dev/null +++ b/tests/components/sen0321/common.yaml @@ -0,0 +1,10 @@ +i2c: + - id: i2c_sen0321 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sen0321 + name: Workshop Ozone Sensor + id: sen0321_ozone + update_interval: 10s diff --git a/tests/components/sen0321/test.esp32-ard.yaml b/tests/components/sen0321/test.esp32-ard.yaml index 44f76bf5e6..63c3bd6afd 100644 --- a/tests/components/sen0321/test.esp32-ard.yaml +++ b/tests/components/sen0321/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen0321/test.esp32-c3-ard.yaml b/tests/components/sen0321/test.esp32-c3-ard.yaml index 7fa461a7fa..ee2c29ca4e 100644 --- a/tests/components/sen0321/test.esp32-c3-ard.yaml +++ b/tests/components/sen0321/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen0321/test.esp32-c3-idf.yaml b/tests/components/sen0321/test.esp32-c3-idf.yaml index 7fa461a7fa..ee2c29ca4e 100644 --- a/tests/components/sen0321/test.esp32-c3-idf.yaml +++ b/tests/components/sen0321/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen0321/test.esp32-idf.yaml b/tests/components/sen0321/test.esp32-idf.yaml index 44f76bf5e6..63c3bd6afd 100644 --- a/tests/components/sen0321/test.esp32-idf.yaml +++ b/tests/components/sen0321/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen0321/test.esp8266-ard.yaml b/tests/components/sen0321/test.esp8266-ard.yaml index 7fa461a7fa..ee2c29ca4e 100644 --- a/tests/components/sen0321/test.esp8266-ard.yaml +++ b/tests/components/sen0321/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen0321/test.rp2040-ard.yaml b/tests/components/sen0321/test.rp2040-ard.yaml index 7fa461a7fa..ee2c29ca4e 100644 --- a/tests/components/sen0321/test.rp2040-ard.yaml +++ b/tests/components/sen0321/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen21231/common.yaml b/tests/components/sen21231/common.yaml new file mode 100644 index 0000000000..6fa1d04aa2 --- /dev/null +++ b/tests/components/sen21231/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_sen21231 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sen21231 + id: sen21231_sensor1 + name: Person Sensor diff --git a/tests/components/sen21231/test.esp32-ard.yaml b/tests/components/sen21231/test.esp32-ard.yaml index 3173683f17..63c3bd6afd 100644 --- a/tests/components/sen21231/test.esp32-ard.yaml +++ b/tests/components/sen21231/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen21231/test.esp32-c3-ard.yaml b/tests/components/sen21231/test.esp32-c3-ard.yaml index efd7843f56..ee2c29ca4e 100644 --- a/tests/components/sen21231/test.esp32-c3-ard.yaml +++ b/tests/components/sen21231/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen21231/test.esp32-c3-idf.yaml b/tests/components/sen21231/test.esp32-c3-idf.yaml index efd7843f56..ee2c29ca4e 100644 --- a/tests/components/sen21231/test.esp32-c3-idf.yaml +++ b/tests/components/sen21231/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen21231/test.esp32-idf.yaml b/tests/components/sen21231/test.esp32-idf.yaml index 3173683f17..63c3bd6afd 100644 --- a/tests/components/sen21231/test.esp32-idf.yaml +++ b/tests/components/sen21231/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen21231/test.esp8266-ard.yaml b/tests/components/sen21231/test.esp8266-ard.yaml index efd7843f56..ee2c29ca4e 100644 --- a/tests/components/sen21231/test.esp8266-ard.yaml +++ b/tests/components/sen21231/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen21231/test.rp2040-ard.yaml b/tests/components/sen21231/test.rp2040-ard.yaml index efd7843f56..ee2c29ca4e 100644 --- a/tests/components/sen21231/test.rp2040-ard.yaml +++ b/tests/components/sen21231/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen5x/common.yaml b/tests/components/sen5x/common.yaml new file mode 100644 index 0000000000..9adf268048 --- /dev/null +++ b/tests/components/sen5x/common.yaml @@ -0,0 +1,49 @@ +i2c: + - id: i2c_sen5x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sen5x + id: sen54 + temperature: + name: Temperature + accuracy_decimals: 1 + humidity: + name: Humidity + accuracy_decimals: 0 + pm_1_0: + name: PM <1µm Weight concentration + id: pm_1_0 + accuracy_decimals: 1 + pm_2_5: + name: PM <2.5µm Weight concentration + id: pm_2_5 + accuracy_decimals: 1 + pm_4_0: + name: PM <4µm Weight concentration + id: pm_4_0 + accuracy_decimals: 1 + pm_10_0: + name: PM <10µm Weight concentration + id: pm_10_0 + accuracy_decimals: 1 + nox: + name: NOx + voc: + name: VOC + algorithm_tuning: + index_offset: 100 + learning_time_offset_hours: 12 + learning_time_gain_hours: 12 + gating_max_duration_minutes: 180 + std_initial: 50 + gain_factor: 230 + temperature_compensation: + offset: 0 + normalized_offset_slope: 0 + time_constant: 0 + auto_cleaning_interval: 604800s + acceleration_mode: low + store_baseline: true + address: 0x69 diff --git a/tests/components/sen5x/test.esp32-ard.yaml b/tests/components/sen5x/test.esp32-ard.yaml index b8f89c435f..63c3bd6afd 100644 --- a/tests/components/sen5x/test.esp32-ard.yaml +++ b/tests/components/sen5x/test.esp32-ard.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/sen5x/test.esp32-c3-ard.yaml b/tests/components/sen5x/test.esp32-c3-ard.yaml index 3352a59b17..ee2c29ca4e 100644 --- a/tests/components/sen5x/test.esp32-c3-ard.yaml +++ b/tests/components/sen5x/test.esp32-c3-ard.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/sen5x/test.esp32-c3-idf.yaml b/tests/components/sen5x/test.esp32-c3-idf.yaml index 3352a59b17..ee2c29ca4e 100644 --- a/tests/components/sen5x/test.esp32-c3-idf.yaml +++ b/tests/components/sen5x/test.esp32-c3-idf.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/sen5x/test.esp32-idf.yaml b/tests/components/sen5x/test.esp32-idf.yaml index b8f89c435f..63c3bd6afd 100644 --- a/tests/components/sen5x/test.esp32-idf.yaml +++ b/tests/components/sen5x/test.esp32-idf.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/sen5x/test.esp8266-ard.yaml b/tests/components/sen5x/test.esp8266-ard.yaml index 3352a59b17..ee2c29ca4e 100644 --- a/tests/components/sen5x/test.esp8266-ard.yaml +++ b/tests/components/sen5x/test.esp8266-ard.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/sen5x/test.rp2040-ard.yaml b/tests/components/sen5x/test.rp2040-ard.yaml index 3352a59b17..ee2c29ca4e 100644 --- a/tests/components/sen5x/test.rp2040-ard.yaml +++ b/tests/components/sen5x/test.rp2040-ard.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/senseair/common.yaml b/tests/components/senseair/common.yaml new file mode 100644 index 0000000000..23a933affe --- /dev/null +++ b/tests/components/senseair/common.yaml @@ -0,0 +1,19 @@ +uart: + - id: uart_senseair + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: senseair + id: senseair0 + co2: + name: SenseAir CO2 Value + on_value: + then: + - senseair.background_calibration: senseair0 + - senseair.background_calibration_result: senseair0 + - senseair.abc_get_period: senseair0 + - senseair.abc_enable: senseair0 + - senseair.abc_disable: senseair0 + update_interval: 15s diff --git a/tests/components/senseair/test.esp32-ard.yaml b/tests/components/senseair/test.esp32-ard.yaml index daa4645f59..f486544afa 100644 --- a/tests/components/senseair/test.esp32-ard.yaml +++ b/tests/components/senseair/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/senseair/test.esp32-c3-ard.yaml b/tests/components/senseair/test.esp32-c3-ard.yaml index 41a441f496..b516342f3b 100644 --- a/tests/components/senseair/test.esp32-c3-ard.yaml +++ b/tests/components/senseair/test.esp32-c3-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/senseair/test.esp32-c3-idf.yaml b/tests/components/senseair/test.esp32-c3-idf.yaml index 41a441f496..b516342f3b 100644 --- a/tests/components/senseair/test.esp32-c3-idf.yaml +++ b/tests/components/senseair/test.esp32-c3-idf.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/senseair/test.esp32-idf.yaml b/tests/components/senseair/test.esp32-idf.yaml index daa4645f59..f486544afa 100644 --- a/tests/components/senseair/test.esp32-idf.yaml +++ b/tests/components/senseair/test.esp32-idf.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/senseair/test.esp8266-ard.yaml b/tests/components/senseair/test.esp8266-ard.yaml index 41a441f496..b516342f3b 100644 --- a/tests/components/senseair/test.esp8266-ard.yaml +++ b/tests/components/senseair/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/senseair/test.rp2040-ard.yaml b/tests/components/senseair/test.rp2040-ard.yaml index 41a441f496..b516342f3b 100644 --- a/tests/components/senseair/test.rp2040-ard.yaml +++ b/tests/components/senseair/test.rp2040-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/servo/common.yaml b/tests/components/servo/common.yaml new file mode 100644 index 0000000000..2cfa370c32 --- /dev/null +++ b/tests/components/servo/common.yaml @@ -0,0 +1,19 @@ +esphome: + on_boot: + then: + - servo.write: + id: test_servo + level: -100.0% + - servo.detach: test_servo + +output: + - platform: ${output_platform} + id: servo_output_1 + pin: ${pin} + +servo: + id: test_servo + output: servo_output_1 + restore: true + min_level: 4% + max_level: 8% diff --git a/tests/components/servo/test.esp32-ard.yaml b/tests/components/servo/test.esp32-ard.yaml index e769f055b4..26da1ce1d6 100644 --- a/tests/components/servo/test.esp32-ard.yaml +++ b/tests/components/servo/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: ledc + pin: GPIO14 -output: - - platform: ledc - id: servo_output_1 - pin: 12 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/servo/test.esp32-c3-ard.yaml b/tests/components/servo/test.esp32-c3-ard.yaml index 29ebea3359..7476963591 100644 --- a/tests/components/servo/test.esp32-c3-ard.yaml +++ b/tests/components/servo/test.esp32-c3-ard.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: ledc + pin: GPIO4 -output: - - platform: ledc - id: servo_output_1 - pin: 1 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/servo/test.esp32-c3-idf.yaml b/tests/components/servo/test.esp32-c3-idf.yaml index 29ebea3359..7476963591 100644 --- a/tests/components/servo/test.esp32-c3-idf.yaml +++ b/tests/components/servo/test.esp32-c3-idf.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: ledc + pin: GPIO4 -output: - - platform: ledc - id: servo_output_1 - pin: 1 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/servo/test.esp32-idf.yaml b/tests/components/servo/test.esp32-idf.yaml index e769f055b4..26da1ce1d6 100644 --- a/tests/components/servo/test.esp32-idf.yaml +++ b/tests/components/servo/test.esp32-idf.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: ledc + pin: GPIO14 -output: - - platform: ledc - id: servo_output_1 - pin: 12 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/servo/test.esp8266-ard.yaml b/tests/components/servo/test.esp8266-ard.yaml index 48b4421641..23a7f43b42 100644 --- a/tests/components/servo/test.esp8266-ard.yaml +++ b/tests/components/servo/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: esp8266_pwm + pin: GPIO14 -output: - - platform: esp8266_pwm - id: servo_output_1 - pin: 12 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/servo/test.rp2040-ard.yaml b/tests/components/servo/test.rp2040-ard.yaml index 75efa9407e..d70f7c74ec 100644 --- a/tests/components/servo/test.rp2040-ard.yaml +++ b/tests/components/servo/test.rp2040-ard.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: rp2040_pwm + pin: GPIO4 -output: - - platform: rp2040_pwm - id: servo_output_1 - pin: 12 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/sfa30/common.yaml b/tests/components/sfa30/common.yaml new file mode 100644 index 0000000000..e3b38aa7fb --- /dev/null +++ b/tests/components/sfa30/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_sfa30 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sfa30 + formaldehyde: + name: SFA30 formaldehyde + temperature: + name: SFA30 temperature + humidity: + name: SFA30 humidity + address: 0x5D + update_interval: 30s diff --git a/tests/components/sfa30/test.esp32-ard.yaml b/tests/components/sfa30/test.esp32-ard.yaml index dc7e4988e5..63c3bd6afd 100644 --- a/tests/components/sfa30/test.esp32-ard.yaml +++ b/tests/components/sfa30/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sfa30/test.esp32-c3-ard.yaml b/tests/components/sfa30/test.esp32-c3-ard.yaml index 119059e4e2..ee2c29ca4e 100644 --- a/tests/components/sfa30/test.esp32-c3-ard.yaml +++ b/tests/components/sfa30/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sfa30/test.esp32-c3-idf.yaml b/tests/components/sfa30/test.esp32-c3-idf.yaml index 119059e4e2..ee2c29ca4e 100644 --- a/tests/components/sfa30/test.esp32-c3-idf.yaml +++ b/tests/components/sfa30/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sfa30/test.esp32-idf.yaml b/tests/components/sfa30/test.esp32-idf.yaml index dc7e4988e5..63c3bd6afd 100644 --- a/tests/components/sfa30/test.esp32-idf.yaml +++ b/tests/components/sfa30/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sfa30/test.esp8266-ard.yaml b/tests/components/sfa30/test.esp8266-ard.yaml index 119059e4e2..ee2c29ca4e 100644 --- a/tests/components/sfa30/test.esp8266-ard.yaml +++ b/tests/components/sfa30/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sfa30/test.rp2040-ard.yaml b/tests/components/sfa30/test.rp2040-ard.yaml index 119059e4e2..ee2c29ca4e 100644 --- a/tests/components/sfa30/test.rp2040-ard.yaml +++ b/tests/components/sfa30/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sgp30/common.yaml b/tests/components/sgp30/common.yaml new file mode 100644 index 0000000000..1db5bc67d1 --- /dev/null +++ b/tests/components/sgp30/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_sgp30 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sgp30 + eco2: + name: Workshop eCO2 + accuracy_decimals: 1 + tvoc: + name: Workshop TVOC + accuracy_decimals: 1 + address: 0x58 + update_interval: 5s diff --git a/tests/components/sgp30/test.esp32-ard.yaml b/tests/components/sgp30/test.esp32-ard.yaml index 6ea23c25cd..63c3bd6afd 100644 --- a/tests/components/sgp30/test.esp32-ard.yaml +++ b/tests/components/sgp30/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp30/test.esp32-c3-ard.yaml b/tests/components/sgp30/test.esp32-c3-ard.yaml index 45de67e94b..ee2c29ca4e 100644 --- a/tests/components/sgp30/test.esp32-c3-ard.yaml +++ b/tests/components/sgp30/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp30/test.esp32-c3-idf.yaml b/tests/components/sgp30/test.esp32-c3-idf.yaml index 45de67e94b..ee2c29ca4e 100644 --- a/tests/components/sgp30/test.esp32-c3-idf.yaml +++ b/tests/components/sgp30/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp30/test.esp32-idf.yaml b/tests/components/sgp30/test.esp32-idf.yaml index 6ea23c25cd..63c3bd6afd 100644 --- a/tests/components/sgp30/test.esp32-idf.yaml +++ b/tests/components/sgp30/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp30/test.esp8266-ard.yaml b/tests/components/sgp30/test.esp8266-ard.yaml index 45de67e94b..ee2c29ca4e 100644 --- a/tests/components/sgp30/test.esp8266-ard.yaml +++ b/tests/components/sgp30/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp30/test.rp2040-ard.yaml b/tests/components/sgp30/test.rp2040-ard.yaml index 45de67e94b..ee2c29ca4e 100644 --- a/tests/components/sgp30/test.rp2040-ard.yaml +++ b/tests/components/sgp30/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/common.yaml b/tests/components/sgp4x/common.yaml new file mode 100644 index 0000000000..adb678d542 --- /dev/null +++ b/tests/components/sgp4x/common.yaml @@ -0,0 +1,27 @@ +i2c: + - id: i2c_sgp4x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sgp4x + voc: + name: VOC Index + id: sgp40_voc_index + algorithm_tuning: + index_offset: 100 + learning_time_offset_hours: 12 + learning_time_gain_hours: 12 + gating_max_duration_minutes: 180 + std_initial: 50 + gain_factor: 230 + nox: + name: NOx + algorithm_tuning: + index_offset: 100 + learning_time_offset_hours: 12 + learning_time_gain_hours: 12 + gating_max_duration_minutes: 180 + std_initial: 50 + gain_factor: 230 + update_interval: 5s diff --git a/tests/components/sgp4x/test.esp32-ard.yaml b/tests/components/sgp4x/test.esp32-ard.yaml index c7380b5a10..63c3bd6afd 100644 --- a/tests/components/sgp4x/test.esp32-ard.yaml +++ b/tests/components/sgp4x/test.esp32-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/test.esp32-c3-ard.yaml b/tests/components/sgp4x/test.esp32-c3-ard.yaml index b2876478bd..ee2c29ca4e 100644 --- a/tests/components/sgp4x/test.esp32-c3-ard.yaml +++ b/tests/components/sgp4x/test.esp32-c3-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/test.esp32-c3-idf.yaml b/tests/components/sgp4x/test.esp32-c3-idf.yaml index b2876478bd..ee2c29ca4e 100644 --- a/tests/components/sgp4x/test.esp32-c3-idf.yaml +++ b/tests/components/sgp4x/test.esp32-c3-idf.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/test.esp32-idf.yaml b/tests/components/sgp4x/test.esp32-idf.yaml index c7380b5a10..63c3bd6afd 100644 --- a/tests/components/sgp4x/test.esp32-idf.yaml +++ b/tests/components/sgp4x/test.esp32-idf.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/test.esp8266-ard.yaml b/tests/components/sgp4x/test.esp8266-ard.yaml index b2876478bd..ee2c29ca4e 100644 --- a/tests/components/sgp4x/test.esp8266-ard.yaml +++ b/tests/components/sgp4x/test.esp8266-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/test.rp2040-ard.yaml b/tests/components/sgp4x/test.rp2040-ard.yaml index b2876478bd..ee2c29ca4e 100644 --- a/tests/components/sgp4x/test.rp2040-ard.yaml +++ b/tests/components/sgp4x/test.rp2040-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sht3xd/common.yaml b/tests/components/sht3xd/common.yaml new file mode 100644 index 0000000000..2426ebfbb9 --- /dev/null +++ b/tests/components/sht3xd/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_sht3xd + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sht3xd + temperature: + name: SHT3XD Temperature + humidity: + name: SHT3XD Humidity + address: 0x44 + update_interval: 15s diff --git a/tests/components/sht3xd/test.esp32-ard.yaml b/tests/components/sht3xd/test.esp32-ard.yaml index 2b6ee50760..63c3bd6afd 100644 --- a/tests/components/sht3xd/test.esp32-ard.yaml +++ b/tests/components/sht3xd/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht3xd/test.esp32-c3-ard.yaml b/tests/components/sht3xd/test.esp32-c3-ard.yaml index 0409ff65c6..ee2c29ca4e 100644 --- a/tests/components/sht3xd/test.esp32-c3-ard.yaml +++ b/tests/components/sht3xd/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht3xd/test.esp32-c3-idf.yaml b/tests/components/sht3xd/test.esp32-c3-idf.yaml index 0409ff65c6..ee2c29ca4e 100644 --- a/tests/components/sht3xd/test.esp32-c3-idf.yaml +++ b/tests/components/sht3xd/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht3xd/test.esp32-idf.yaml b/tests/components/sht3xd/test.esp32-idf.yaml index 2b6ee50760..63c3bd6afd 100644 --- a/tests/components/sht3xd/test.esp32-idf.yaml +++ b/tests/components/sht3xd/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht3xd/test.esp8266-ard.yaml b/tests/components/sht3xd/test.esp8266-ard.yaml index 0409ff65c6..ee2c29ca4e 100644 --- a/tests/components/sht3xd/test.esp8266-ard.yaml +++ b/tests/components/sht3xd/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht3xd/test.rp2040-ard.yaml b/tests/components/sht3xd/test.rp2040-ard.yaml index 0409ff65c6..ee2c29ca4e 100644 --- a/tests/components/sht3xd/test.rp2040-ard.yaml +++ b/tests/components/sht3xd/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/common.yaml b/tests/components/sht4x/common.yaml new file mode 100644 index 0000000000..703a8fa32b --- /dev/null +++ b/tests/components/sht4x/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_sht4x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sht4x + temperature: + name: SHT4X Temperature + humidity: + name: SHT4X Humidity + address: 0x44 + update_interval: 15s diff --git a/tests/components/sht4x/test.esp32-ard.yaml b/tests/components/sht4x/test.esp32-ard.yaml index 13ec524d7d..63c3bd6afd 100644 --- a/tests/components/sht4x/test.esp32-ard.yaml +++ b/tests/components/sht4x/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/test.esp32-c3-ard.yaml b/tests/components/sht4x/test.esp32-c3-ard.yaml index 0bcdd864f6..ee2c29ca4e 100644 --- a/tests/components/sht4x/test.esp32-c3-ard.yaml +++ b/tests/components/sht4x/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/test.esp32-c3-idf.yaml b/tests/components/sht4x/test.esp32-c3-idf.yaml index 0bcdd864f6..ee2c29ca4e 100644 --- a/tests/components/sht4x/test.esp32-c3-idf.yaml +++ b/tests/components/sht4x/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/test.esp32-idf.yaml b/tests/components/sht4x/test.esp32-idf.yaml index 13ec524d7d..63c3bd6afd 100644 --- a/tests/components/sht4x/test.esp32-idf.yaml +++ b/tests/components/sht4x/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/test.esp8266-ard.yaml b/tests/components/sht4x/test.esp8266-ard.yaml index 0bcdd864f6..ee2c29ca4e 100644 --- a/tests/components/sht4x/test.esp8266-ard.yaml +++ b/tests/components/sht4x/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/test.rp2040-ard.yaml b/tests/components/sht4x/test.rp2040-ard.yaml index 0bcdd864f6..ee2c29ca4e 100644 --- a/tests/components/sht4x/test.rp2040-ard.yaml +++ b/tests/components/sht4x/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/common.yaml b/tests/components/shtcx/common.yaml new file mode 100644 index 0000000000..0211319124 --- /dev/null +++ b/tests/components/shtcx/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_shtcx + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: shtcx + temperature: + name: SHTCX Temperature + humidity: + name: SHTCX Humidity + address: 0x70 + update_interval: 15s diff --git a/tests/components/shtcx/test.esp32-ard.yaml b/tests/components/shtcx/test.esp32-ard.yaml index 619bac9548..63c3bd6afd 100644 --- a/tests/components/shtcx/test.esp32-ard.yaml +++ b/tests/components/shtcx/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/test.esp32-c3-ard.yaml b/tests/components/shtcx/test.esp32-c3-ard.yaml index c1c7a2a63f..ee2c29ca4e 100644 --- a/tests/components/shtcx/test.esp32-c3-ard.yaml +++ b/tests/components/shtcx/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/test.esp32-c3-idf.yaml b/tests/components/shtcx/test.esp32-c3-idf.yaml index c1c7a2a63f..ee2c29ca4e 100644 --- a/tests/components/shtcx/test.esp32-c3-idf.yaml +++ b/tests/components/shtcx/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/test.esp32-idf.yaml b/tests/components/shtcx/test.esp32-idf.yaml index 619bac9548..63c3bd6afd 100644 --- a/tests/components/shtcx/test.esp32-idf.yaml +++ b/tests/components/shtcx/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/test.esp8266-ard.yaml b/tests/components/shtcx/test.esp8266-ard.yaml index c1c7a2a63f..ee2c29ca4e 100644 --- a/tests/components/shtcx/test.esp8266-ard.yaml +++ b/tests/components/shtcx/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/test.rp2040-ard.yaml b/tests/components/shtcx/test.rp2040-ard.yaml index c1c7a2a63f..ee2c29ca4e 100644 --- a/tests/components/shtcx/test.rp2040-ard.yaml +++ b/tests/components/shtcx/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sim800l/common.yaml b/tests/components/sim800l/common.yaml new file mode 100644 index 0000000000..1b4e2e1af6 --- /dev/null +++ b/tests/components/sim800l/common.yaml @@ -0,0 +1,37 @@ +esphome: + on_boot: + then: + - sim800l.send_sms: + recipient: '+15551234567' + message: Hello there + - sim800l.dial: + recipient: '+15551234567' + - sim800l.connect + - sim800l.disconnect + - sim800l.send_ussd: + ussd: test_ussd + +uart: + - id: uart_sim800l + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sim800l: + on_sms_received: + - lambda: |- + std::string str; + str = sender; + str = message; + - sim800l.send_sms: + message: hello you + recipient: "+1234" + - sim800l.dial: + recipient: "+1234" + on_incoming_call: + - logger.log: + format: "Incoming call from '%s'" + args: ["caller_id.c_str()"] + - sim800l.disconnect + on_ussd_received: + - logger.log: "ussd_received" diff --git a/tests/components/sim800l/test.esp32-ard.yaml b/tests/components/sim800l/test.esp32-ard.yaml index c116548c6f..f486544afa 100644 --- a/tests/components/sim800l/test.esp32-ard.yaml +++ b/tests/components/sim800l/test.esp32-ard.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -uart: - - id: uart_sim800l - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sim800l/test.esp32-c3-ard.yaml b/tests/components/sim800l/test.esp32-c3-ard.yaml index 7ff359d1e7..b516342f3b 100644 --- a/tests/components/sim800l/test.esp32-c3-ard.yaml +++ b/tests/components/sim800l/test.esp32-c3-ard.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_sim800l - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sim800l/test.esp32-c3-idf.yaml b/tests/components/sim800l/test.esp32-c3-idf.yaml index 7ff359d1e7..b516342f3b 100644 --- a/tests/components/sim800l/test.esp32-c3-idf.yaml +++ b/tests/components/sim800l/test.esp32-c3-idf.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_sim800l - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sim800l/test.esp32-idf.yaml b/tests/components/sim800l/test.esp32-idf.yaml index c116548c6f..f486544afa 100644 --- a/tests/components/sim800l/test.esp32-idf.yaml +++ b/tests/components/sim800l/test.esp32-idf.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -uart: - - id: uart_sim800l - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sim800l/test.esp8266-ard.yaml b/tests/components/sim800l/test.esp8266-ard.yaml index 7ff359d1e7..b516342f3b 100644 --- a/tests/components/sim800l/test.esp8266-ard.yaml +++ b/tests/components/sim800l/test.esp8266-ard.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_sim800l - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sim800l/test.rp2040-ard.yaml b/tests/components/sim800l/test.rp2040-ard.yaml index 7ff359d1e7..b516342f3b 100644 --- a/tests/components/sim800l/test.rp2040-ard.yaml +++ b/tests/components/sim800l/test.rp2040-ard.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_sim800l - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sm16716/common.yaml b/tests/components/sm16716/common.yaml index 3bf2712f4e..db61d0b1c2 100644 --- a/tests/components/sm16716/common.yaml +++ b/tests/components/sm16716/common.yaml @@ -1,6 +1,6 @@ sm16716: - clock_pin: 4 - data_pin: 5 + clock_pin: ${clock_pin} + data_pin: ${data_pin} num_channels: 3 num_chips: 1 diff --git a/tests/components/sm16716/test.esp32-ard.yaml b/tests/components/sm16716/test.esp32-ard.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm16716/test.esp32-ard.yaml +++ b/tests/components/sm16716/test.esp32-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm16716/test.esp32-c3-ard.yaml b/tests/components/sm16716/test.esp32-c3-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm16716/test.esp32-c3-ard.yaml +++ b/tests/components/sm16716/test.esp32-c3-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm16716/test.esp32-c3-idf.yaml b/tests/components/sm16716/test.esp32-c3-idf.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm16716/test.esp32-c3-idf.yaml +++ b/tests/components/sm16716/test.esp32-c3-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm16716/test.esp32-idf.yaml b/tests/components/sm16716/test.esp32-idf.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm16716/test.esp32-idf.yaml +++ b/tests/components/sm16716/test.esp32-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm16716/test.esp8266-ard.yaml b/tests/components/sm16716/test.esp8266-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm16716/test.esp8266-ard.yaml +++ b/tests/components/sm16716/test.esp8266-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm16716/test.rp2040-ard.yaml b/tests/components/sm16716/test.rp2040-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm16716/test.rp2040-ard.yaml +++ b/tests/components/sm16716/test.rp2040-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2135/common.yaml b/tests/components/sm2135/common.yaml index 9a0de60839..8f807a9be5 100644 --- a/tests/components/sm2135/common.yaml +++ b/tests/components/sm2135/common.yaml @@ -1,6 +1,6 @@ sm2135: - clock_pin: 4 - data_pin: 5 + clock_pin: ${clock_pin} + data_pin: ${data_pin} rgb_current: 20mA cw_current: 60mA diff --git a/tests/components/sm2135/test.esp32-ard.yaml b/tests/components/sm2135/test.esp32-ard.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2135/test.esp32-ard.yaml +++ b/tests/components/sm2135/test.esp32-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2135/test.esp32-c3-ard.yaml b/tests/components/sm2135/test.esp32-c3-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2135/test.esp32-c3-ard.yaml +++ b/tests/components/sm2135/test.esp32-c3-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2135/test.esp32-c3-idf.yaml b/tests/components/sm2135/test.esp32-c3-idf.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2135/test.esp32-c3-idf.yaml +++ b/tests/components/sm2135/test.esp32-c3-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2135/test.esp32-idf.yaml b/tests/components/sm2135/test.esp32-idf.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2135/test.esp32-idf.yaml +++ b/tests/components/sm2135/test.esp32-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2135/test.esp8266-ard.yaml b/tests/components/sm2135/test.esp8266-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2135/test.esp8266-ard.yaml +++ b/tests/components/sm2135/test.esp8266-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2135/test.rp2040-ard.yaml b/tests/components/sm2135/test.rp2040-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2135/test.rp2040-ard.yaml +++ b/tests/components/sm2135/test.rp2040-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2235/common.yaml b/tests/components/sm2235/common.yaml index 043d43d6f1..d97fa4eb6c 100644 --- a/tests/components/sm2235/common.yaml +++ b/tests/components/sm2235/common.yaml @@ -1,6 +1,6 @@ sm2235: - clock_pin: 4 - data_pin: 5 + clock_pin: ${clock_pin} + data_pin: ${data_pin} max_power_color_channels: 9 max_power_white_channels: 9 diff --git a/tests/components/sm2235/test.esp32-ard.yaml b/tests/components/sm2235/test.esp32-ard.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2235/test.esp32-ard.yaml +++ b/tests/components/sm2235/test.esp32-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2235/test.esp32-c3-ard.yaml b/tests/components/sm2235/test.esp32-c3-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2235/test.esp32-c3-ard.yaml +++ b/tests/components/sm2235/test.esp32-c3-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2235/test.esp32-c3-idf.yaml b/tests/components/sm2235/test.esp32-c3-idf.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2235/test.esp32-c3-idf.yaml +++ b/tests/components/sm2235/test.esp32-c3-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2235/test.esp32-idf.yaml b/tests/components/sm2235/test.esp32-idf.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2235/test.esp32-idf.yaml +++ b/tests/components/sm2235/test.esp32-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2235/test.esp8266-ard.yaml b/tests/components/sm2235/test.esp8266-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2235/test.esp8266-ard.yaml +++ b/tests/components/sm2235/test.esp8266-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2235/test.rp2040-ard.yaml b/tests/components/sm2235/test.rp2040-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2235/test.rp2040-ard.yaml +++ b/tests/components/sm2235/test.rp2040-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2335/common.yaml b/tests/components/sm2335/common.yaml index a5b2aedeb5..51d40aab21 100644 --- a/tests/components/sm2335/common.yaml +++ b/tests/components/sm2335/common.yaml @@ -1,6 +1,6 @@ sm2335: - clock_pin: 4 - data_pin: 5 + clock_pin: ${clock_pin} + data_pin: ${data_pin} max_power_color_channels: 9 max_power_white_channels: 9 diff --git a/tests/components/sm2335/test.esp32-ard.yaml b/tests/components/sm2335/test.esp32-ard.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2335/test.esp32-ard.yaml +++ b/tests/components/sm2335/test.esp32-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2335/test.esp32-c3-ard.yaml b/tests/components/sm2335/test.esp32-c3-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2335/test.esp32-c3-ard.yaml +++ b/tests/components/sm2335/test.esp32-c3-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2335/test.esp32-c3-idf.yaml b/tests/components/sm2335/test.esp32-c3-idf.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2335/test.esp32-c3-idf.yaml +++ b/tests/components/sm2335/test.esp32-c3-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2335/test.esp32-idf.yaml b/tests/components/sm2335/test.esp32-idf.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2335/test.esp32-idf.yaml +++ b/tests/components/sm2335/test.esp32-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2335/test.esp8266-ard.yaml b/tests/components/sm2335/test.esp8266-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2335/test.esp8266-ard.yaml +++ b/tests/components/sm2335/test.esp8266-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2335/test.rp2040-ard.yaml b/tests/components/sm2335/test.rp2040-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2335/test.rp2040-ard.yaml +++ b/tests/components/sm2335/test.rp2040-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm300d2/common.yaml b/tests/components/sm300d2/common.yaml new file mode 100644 index 0000000000..a231b63816 --- /dev/null +++ b/tests/components/sm300d2/common.yaml @@ -0,0 +1,23 @@ +uart: + - id: uart_sm300d2 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: sm300d2 + co2: + name: SM300D2 CO2 Value + formaldehyde: + name: SM300D2 Formaldehyde Value + tvoc: + name: SM300D2 TVOC Value + pm_2_5: + name: SM300D2 PM2.5 Value + pm_10_0: + name: SM300D2 PM10 Value + temperature: + name: SM300D2 Temperature Value + humidity: + name: SM300D2 Humidity Value + update_interval: 60s diff --git a/tests/components/sm300d2/test.esp32-ard.yaml b/tests/components/sm300d2/test.esp32-ard.yaml index 92dba4fb3b..f486544afa 100644 --- a/tests/components/sm300d2/test.esp32-ard.yaml +++ b/tests/components/sm300d2/test.esp32-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sm300d2/test.esp32-c3-ard.yaml b/tests/components/sm300d2/test.esp32-c3-ard.yaml index bcd0a728b2..b516342f3b 100644 --- a/tests/components/sm300d2/test.esp32-c3-ard.yaml +++ b/tests/components/sm300d2/test.esp32-c3-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sm300d2/test.esp32-c3-idf.yaml b/tests/components/sm300d2/test.esp32-c3-idf.yaml index bcd0a728b2..b516342f3b 100644 --- a/tests/components/sm300d2/test.esp32-c3-idf.yaml +++ b/tests/components/sm300d2/test.esp32-c3-idf.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sm300d2/test.esp32-idf.yaml b/tests/components/sm300d2/test.esp32-idf.yaml index 92dba4fb3b..f486544afa 100644 --- a/tests/components/sm300d2/test.esp32-idf.yaml +++ b/tests/components/sm300d2/test.esp32-idf.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sm300d2/test.esp8266-ard.yaml b/tests/components/sm300d2/test.esp8266-ard.yaml index bcd0a728b2..b516342f3b 100644 --- a/tests/components/sm300d2/test.esp8266-ard.yaml +++ b/tests/components/sm300d2/test.esp8266-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sm300d2/test.rp2040-ard.yaml b/tests/components/sm300d2/test.rp2040-ard.yaml index bcd0a728b2..b516342f3b 100644 --- a/tests/components/sm300d2/test.rp2040-ard.yaml +++ b/tests/components/sm300d2/test.rp2040-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sml/common.yaml b/tests/components/sml/common.yaml new file mode 100644 index 0000000000..a50d25eeee --- /dev/null +++ b/tests/components/sml/common.yaml @@ -0,0 +1,31 @@ +uart: + - id: uart_sml + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sml: + id: mysml + on_data: + - logger.log: "SML on_data" + +sensor: + - platform: sml + name: Total energy + sml_id: mysml + server_id: 0123456789abcdef + obis_code: "1-0:1.8.0" + unit_of_measurement: kWh + accuracy_decimals: 1 + device_class: energy + state_class: total_increasing + filters: + - multiply: 0.0001 + +text_sensor: + - platform: sml + name: Manufacturer + sml_id: mysml + server_id: 0123456789abcdef + obis_code: "129-129:199.130.3" + format: text diff --git a/tests/components/sml/test.esp32-ard.yaml b/tests/components/sml/test.esp32-ard.yaml index 7217199380..f486544afa 100644 --- a/tests/components/sml/test.esp32-ard.yaml +++ b/tests/components/sml/test.esp32-ard.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/sml/test.esp32-c3-ard.yaml b/tests/components/sml/test.esp32-c3-ard.yaml index 903f968c26..b516342f3b 100644 --- a/tests/components/sml/test.esp32-c3-ard.yaml +++ b/tests/components/sml/test.esp32-c3-ard.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/sml/test.esp32-c3-idf.yaml b/tests/components/sml/test.esp32-c3-idf.yaml index 903f968c26..b516342f3b 100644 --- a/tests/components/sml/test.esp32-c3-idf.yaml +++ b/tests/components/sml/test.esp32-c3-idf.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/sml/test.esp32-idf.yaml b/tests/components/sml/test.esp32-idf.yaml index 7217199380..f486544afa 100644 --- a/tests/components/sml/test.esp32-idf.yaml +++ b/tests/components/sml/test.esp32-idf.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/sml/test.esp8266-ard.yaml b/tests/components/sml/test.esp8266-ard.yaml index 903f968c26..b516342f3b 100644 --- a/tests/components/sml/test.esp8266-ard.yaml +++ b/tests/components/sml/test.esp8266-ard.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/sml/test.rp2040-ard.yaml b/tests/components/sml/test.rp2040-ard.yaml index 903f968c26..b516342f3b 100644 --- a/tests/components/sml/test.rp2040-ard.yaml +++ b/tests/components/sml/test.rp2040-ard.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/smt100/common.yaml b/tests/components/smt100/common.yaml new file mode 100644 index 0000000000..f86bd762e7 --- /dev/null +++ b/tests/components/smt100/common.yaml @@ -0,0 +1,19 @@ +uart: + - id: uart_smt100 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: smt100 + counts: + name: Counts + dielectric_constant: + name: Dielectric Constant + temperature: + name: Temperature + moisture: + name: Moisture + voltage: + name: Voltage + update_interval: 60s diff --git a/tests/components/smt100/test.esp32-ard.yaml b/tests/components/smt100/test.esp32-ard.yaml index 7c19f4bc45..f486544afa 100644 --- a/tests/components/smt100/test.esp32-ard.yaml +++ b/tests/components/smt100/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/smt100/test.esp32-c3-ard.yaml b/tests/components/smt100/test.esp32-c3-ard.yaml index 4277f2567b..b516342f3b 100644 --- a/tests/components/smt100/test.esp32-c3-ard.yaml +++ b/tests/components/smt100/test.esp32-c3-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/smt100/test.esp32-c3-idf.yaml b/tests/components/smt100/test.esp32-c3-idf.yaml index 4277f2567b..b516342f3b 100644 --- a/tests/components/smt100/test.esp32-c3-idf.yaml +++ b/tests/components/smt100/test.esp32-c3-idf.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/smt100/test.esp32-idf.yaml b/tests/components/smt100/test.esp32-idf.yaml index 7c19f4bc45..f486544afa 100644 --- a/tests/components/smt100/test.esp32-idf.yaml +++ b/tests/components/smt100/test.esp32-idf.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/smt100/test.esp8266-ard.yaml b/tests/components/smt100/test.esp8266-ard.yaml index 4277f2567b..b516342f3b 100644 --- a/tests/components/smt100/test.esp8266-ard.yaml +++ b/tests/components/smt100/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/smt100/test.rp2040-ard.yaml b/tests/components/smt100/test.rp2040-ard.yaml index 4277f2567b..b516342f3b 100644 --- a/tests/components/smt100/test.rp2040-ard.yaml +++ b/tests/components/smt100/test.rp2040-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sn74hc165/common.yaml b/tests/components/sn74hc165/common.yaml new file mode 100644 index 0000000000..f98711048d --- /dev/null +++ b/tests/components/sn74hc165/common.yaml @@ -0,0 +1,14 @@ +sn74hc165: + id: sn74hc165_hub + clock_pin: ${clock_pin} + data_pin: ${data_pin} + load_pin: ${load_pin} + clock_inhibit_pin: ${clock_inhibit_pin} + sr_count: 2 + +binary_sensor: + - platform: gpio + id: sn74hc165_pin_0 + pin: + sn74hc165: sn74hc165_hub + number: 0 diff --git a/tests/components/sn74hc165/test.esp32-ard.yaml b/tests/components/sn74hc165/test.esp32-ard.yaml index 55b06aec9b..27f963312f 100644 --- a/tests/components/sn74hc165/test.esp32-ard.yaml +++ b/tests/components/sn74hc165/test.esp32-ard.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 13 - data_pin: 14 - load_pin: 15 - clock_inhibit_pin: 16 - sr_count: 2 +substitutions: + clock_pin: GPIO13 + data_pin: GPIO14 + load_pin: GPIO15 + clock_inhibit_pin: GPIO16 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc165/test.esp32-c3-ard.yaml b/tests/components/sn74hc165/test.esp32-c3-ard.yaml index f687b23c9d..0a3db917b7 100644 --- a/tests/components/sn74hc165/test.esp32-c3-ard.yaml +++ b/tests/components/sn74hc165/test.esp32-c3-ard.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 3 - data_pin: 4 - load_pin: 5 - clock_inhibit_pin: 6 - sr_count: 2 +substitutions: + clock_pin: GPIO3 + data_pin: GPIO4 + load_pin: GPIO5 + clock_inhibit_pin: GPIO6 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc165/test.esp32-c3-idf.yaml b/tests/components/sn74hc165/test.esp32-c3-idf.yaml index f687b23c9d..0a3db917b7 100644 --- a/tests/components/sn74hc165/test.esp32-c3-idf.yaml +++ b/tests/components/sn74hc165/test.esp32-c3-idf.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 3 - data_pin: 4 - load_pin: 5 - clock_inhibit_pin: 6 - sr_count: 2 +substitutions: + clock_pin: GPIO3 + data_pin: GPIO4 + load_pin: GPIO5 + clock_inhibit_pin: GPIO6 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc165/test.esp32-idf.yaml b/tests/components/sn74hc165/test.esp32-idf.yaml index 55b06aec9b..27f963312f 100644 --- a/tests/components/sn74hc165/test.esp32-idf.yaml +++ b/tests/components/sn74hc165/test.esp32-idf.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 13 - data_pin: 14 - load_pin: 15 - clock_inhibit_pin: 16 - sr_count: 2 +substitutions: + clock_pin: GPIO13 + data_pin: GPIO14 + load_pin: GPIO15 + clock_inhibit_pin: GPIO16 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc165/test.esp8266-ard.yaml b/tests/components/sn74hc165/test.esp8266-ard.yaml index 55b06aec9b..27f963312f 100644 --- a/tests/components/sn74hc165/test.esp8266-ard.yaml +++ b/tests/components/sn74hc165/test.esp8266-ard.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 13 - data_pin: 14 - load_pin: 15 - clock_inhibit_pin: 16 - sr_count: 2 +substitutions: + clock_pin: GPIO13 + data_pin: GPIO14 + load_pin: GPIO15 + clock_inhibit_pin: GPIO16 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc165/test.rp2040-ard.yaml b/tests/components/sn74hc165/test.rp2040-ard.yaml index f687b23c9d..0a3db917b7 100644 --- a/tests/components/sn74hc165/test.rp2040-ard.yaml +++ b/tests/components/sn74hc165/test.rp2040-ard.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 3 - data_pin: 4 - load_pin: 5 - clock_inhibit_pin: 6 - sr_count: 2 +substitutions: + clock_pin: GPIO3 + data_pin: GPIO4 + load_pin: GPIO5 + clock_inhibit_pin: GPIO6 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc595/common.yaml b/tests/components/sn74hc595/common.yaml new file mode 100644 index 0000000000..fc297909f5 --- /dev/null +++ b/tests/components/sn74hc595/common.yaml @@ -0,0 +1,26 @@ +spi: + - id: spi_sn74hc595 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sn74hc595: + - id: sn74hc595_hub + clock_pin: ${clock_pin} + data_pin: ${data_pin} + latch_pin: ${latch_pin1} + oe_pin: ${oe_pin1} + sr_count: 2 + - id: sn74hc595_hub_2 + latch_pin: ${latch_pin2} + oe_pin: ${oe_pin2} + type: spi + sr_count: 2 + +switch: + - platform: gpio + name: SN74HC595 Pin 0 + pin: + sn74hc595: sn74hc595_hub_2 + number: 0 + inverted: false diff --git a/tests/components/sn74hc595/test.esp32-ard.yaml b/tests/components/sn74hc595/test.esp32-ard.yaml index f695395797..a4bab64862 100644 --- a/tests/components/sn74hc595/test.esp32-ard.yaml +++ b/tests/components/sn74hc595/test.esp32-ard.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO18 + clock_pin: GPIO15 + data_pin: GPIO14 + latch_pin1: GPIO21 + oe_pin1: GPIO22 + latch_pin2: GPIO23 + oe_pin2: GPIO25 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 12 - data_pin: 13 - latch_pin: 14 - oe_pin: 18 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 21 - oe_pin: 22 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sn74hc595/test.esp32-c3-ard.yaml b/tests/components/sn74hc595/test.esp32-c3-ard.yaml index 9b093899d3..14c928be88 100644 --- a/tests/components/sn74hc595/test.esp32-c3-ard.yaml +++ b/tests/components/sn74hc595/test.esp32-c3-ard.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO8 + clock_pin: GPIO5 + data_pin: GPIO4 + latch_pin1: GPIO1 + oe_pin1: GPIO2 + latch_pin2: GPIO3 + oe_pin2: GPIO9 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 0 - data_pin: 1 - latch_pin: 2 - oe_pin: 3 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 8 - oe_pin: 9 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sn74hc595/test.esp32-c3-idf.yaml b/tests/components/sn74hc595/test.esp32-c3-idf.yaml index 9b093899d3..14c928be88 100644 --- a/tests/components/sn74hc595/test.esp32-c3-idf.yaml +++ b/tests/components/sn74hc595/test.esp32-c3-idf.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO8 + clock_pin: GPIO5 + data_pin: GPIO4 + latch_pin1: GPIO1 + oe_pin1: GPIO2 + latch_pin2: GPIO3 + oe_pin2: GPIO9 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 0 - data_pin: 1 - latch_pin: 2 - oe_pin: 3 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 8 - oe_pin: 9 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sn74hc595/test.esp32-idf.yaml b/tests/components/sn74hc595/test.esp32-idf.yaml index f695395797..a4bab64862 100644 --- a/tests/components/sn74hc595/test.esp32-idf.yaml +++ b/tests/components/sn74hc595/test.esp32-idf.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO18 + clock_pin: GPIO15 + data_pin: GPIO14 + latch_pin1: GPIO21 + oe_pin1: GPIO22 + latch_pin2: GPIO23 + oe_pin2: GPIO25 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 12 - data_pin: 13 - latch_pin: 14 - oe_pin: 18 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 21 - oe_pin: 22 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sn74hc595/test.esp8266-ard.yaml b/tests/components/sn74hc595/test.esp8266-ard.yaml index 64bf5d1925..cad11feca8 100644 --- a/tests/components/sn74hc595/test.esp8266-ard.yaml +++ b/tests/components/sn74hc595/test.esp8266-ard.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + clock_pin: GPIO5 + data_pin: GPIO4 + latch_pin1: GPIO2 + oe_pin1: GPIO0 + latch_pin2: GPIO3 + oe_pin2: GPIO1 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 0 - data_pin: 2 - latch_pin: 4 - oe_pin: 5 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 15 - oe_pin: 16 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sn74hc595/test.rp2040-ard.yaml b/tests/components/sn74hc595/test.rp2040-ard.yaml index de8e192659..14c928be88 100644 --- a/tests/components/sn74hc595/test.rp2040-ard.yaml +++ b/tests/components/sn74hc595/test.rp2040-ard.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 6 - mosi_pin: 5 - miso_pin: 4 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO8 + clock_pin: GPIO5 + data_pin: GPIO4 + latch_pin1: GPIO1 + oe_pin1: GPIO2 + latch_pin2: GPIO3 + oe_pin2: GPIO9 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 0 - data_pin: 1 - latch_pin: 2 - oe_pin: 3 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 8 - oe_pin: 9 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/common.yaml b/tests/components/sonoff_d1/common.yaml new file mode 100644 index 0000000000..d2d4043b95 --- /dev/null +++ b/tests/components/sonoff_d1/common.yaml @@ -0,0 +1,12 @@ +uart: + - id: uart_sonoff_d1 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +light: + - platform: sonoff_d1 + id: d1_light + name: Sonoff D1 Dimmer + restore_mode: RESTORE_DEFAULT_OFF + use_rm433_remote: false diff --git a/tests/components/sonoff_d1/test.esp32-ard.yaml b/tests/components/sonoff_d1/test.esp32-ard.yaml index dc35e3b6ac..f486544afa 100644 --- a/tests/components/sonoff_d1/test.esp32-ard.yaml +++ b/tests/components/sonoff_d1/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_sonoff_d1 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -light: - - platform: sonoff_d1 - id: d1_light - name: Sonoff D1 Dimmer - restore_mode: RESTORE_DEFAULT_OFF - use_rm433_remote: false +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/test.esp32-c3-ard.yaml b/tests/components/sonoff_d1/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/sonoff_d1/test.esp32-c3-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/test.esp32-c3-idf.yaml b/tests/components/sonoff_d1/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/sonoff_d1/test.esp32-c3-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/test.esp32-idf.yaml b/tests/components/sonoff_d1/test.esp32-idf.yaml index dc35e3b6ac..f486544afa 100644 --- a/tests/components/sonoff_d1/test.esp32-idf.yaml +++ b/tests/components/sonoff_d1/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_sonoff_d1 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -light: - - platform: sonoff_d1 - id: d1_light - name: Sonoff D1 Dimmer - restore_mode: RESTORE_DEFAULT_OFF - use_rm433_remote: false +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/test.esp8266-ard.yaml b/tests/components/sonoff_d1/test.esp8266-ard.yaml index c4a62f4cb3..b516342f3b 100644 --- a/tests/components/sonoff_d1/test.esp8266-ard.yaml +++ b/tests/components/sonoff_d1/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_sonoff_d1 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -light: - - platform: sonoff_d1 - id: d1_light - name: Sonoff D1 Dimmer - restore_mode: RESTORE_DEFAULT_OFF - use_rm433_remote: false +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/test.rp2040-ard.yaml b/tests/components/sonoff_d1/test.rp2040-ard.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/sonoff_d1/test.rp2040-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/speaker/audio_dac.esp32-ard.yaml b/tests/components/speaker/audio_dac.esp32-ard.yaml new file mode 100644 index 0000000000..75d9ddf92b --- /dev/null +++ b/tests/components/speaker/audio_dac.esp32-ard.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + i2s_bclk_pin: GPIO27 + i2s_lrclk_pin: GPIO26 + i2s_mclk_pin: GPIO25 + i2s_dout_pin: GPIO23 + +<<: !include common-audio_dac.yaml diff --git a/tests/components/speaker/audio_dac.esp32-c3-ard.yaml b/tests/components/speaker/audio_dac.esp32-c3-ard.yaml new file mode 100644 index 0000000000..1004d2143e --- /dev/null +++ b/tests/components/speaker/audio_dac.esp32-c3-ard.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + i2s_bclk_pin: GPIO7 + i2s_lrclk_pin: GPIO6 + i2s_mclk_pin: GPIO9 + i2s_dout_pin: GPIO8 + +<<: !include common-audio_dac.yaml diff --git a/tests/components/speaker/audio_dac.esp32-c3-idf.yaml b/tests/components/speaker/audio_dac.esp32-c3-idf.yaml new file mode 100644 index 0000000000..1004d2143e --- /dev/null +++ b/tests/components/speaker/audio_dac.esp32-c3-idf.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + i2s_bclk_pin: GPIO7 + i2s_lrclk_pin: GPIO6 + i2s_mclk_pin: GPIO9 + i2s_dout_pin: GPIO8 + +<<: !include common-audio_dac.yaml diff --git a/tests/components/speaker/audio_dac.esp32-idf.yaml b/tests/components/speaker/audio_dac.esp32-idf.yaml new file mode 100644 index 0000000000..75d9ddf92b --- /dev/null +++ b/tests/components/speaker/audio_dac.esp32-idf.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + i2s_bclk_pin: GPIO27 + i2s_lrclk_pin: GPIO26 + i2s_mclk_pin: GPIO25 + i2s_dout_pin: GPIO23 + +<<: !include common-audio_dac.yaml diff --git a/tests/components/speaker/common-audio_dac.yaml b/tests/components/speaker/common-audio_dac.yaml new file mode 100644 index 0000000000..41b994d4d4 --- /dev/null +++ b/tests/components/speaker/common-audio_dac.yaml @@ -0,0 +1,36 @@ +esphome: + on_boot: + then: + - speaker.mute_on: + - speaker.mute_off: + - if: + condition: speaker.is_stopped + then: + - speaker.play: [0, 1, 2, 3] + - speaker.volume_set: 0.9 + - if: + condition: speaker.is_playing + then: + - speaker.finish: + - speaker.stop: + +i2c: + - id: i2c_audio_dac + scl: ${scl_pin} + sda: ${sda_pin} + +i2s_audio: + i2s_lrclk_pin: ${i2s_bclk_pin} + i2s_bclk_pin: ${i2s_lrclk_pin} + i2s_mclk_pin: ${i2s_mclk_pin} + +audio_dac: + - platform: aic3204 + id: internal_dac + +speaker: + - platform: i2s_audio + id: speaker_with_audio_dac_id + audio_dac: internal_dac + dac_type: external + i2s_dout_pin: ${i2s_dout_pin} diff --git a/tests/components/speaker/common.yaml b/tests/components/speaker/common.yaml new file mode 100644 index 0000000000..c04674ee29 --- /dev/null +++ b/tests/components/speaker/common.yaml @@ -0,0 +1,26 @@ +esphome: + on_boot: + then: + - speaker.mute_on: + - speaker.mute_off: + - if: + condition: speaker.is_stopped + then: + - speaker.play: [0, 1, 2, 3] + - speaker.volume_set: 0.9 + - if: + condition: speaker.is_playing + then: + - speaker.finish: + - speaker.stop: + +i2s_audio: + i2s_lrclk_pin: ${i2s_bclk_pin} + i2s_bclk_pin: ${i2s_lrclk_pin} + i2s_mclk_pin: ${i2s_mclk_pin} + +speaker: + - platform: i2s_audio + id: speaker_id + dac_type: external + i2s_dout_pin: ${i2s_dout_pin} diff --git a/tests/components/speaker/test.esp32-ard.yaml b/tests/components/speaker/test.esp32-ard.yaml index 396b4d95ea..e2439ebdf2 100644 --- a/tests/components/speaker/test.esp32-ard.yaml +++ b/tests/components/speaker/test.esp32-ard.yaml @@ -1,26 +1,9 @@ -esphome: - on_boot: - then: - - speaker.mute_on: - - speaker.mute_off: - - if: - condition: speaker.is_stopped - then: - - speaker.play: [0, 1, 2, 3] - - speaker.volume_set: 0.9 - - if: - condition: speaker.is_playing - then: - - speaker.finish: - - speaker.stop: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + i2s_bclk_pin: GPIO27 + i2s_lrclk_pin: GPIO26 + i2s_mclk_pin: GPIO25 + i2s_dout_pin: GPIO23 -i2s_audio: - i2s_lrclk_pin: 16 - i2s_bclk_pin: 17 - i2s_mclk_pin: 15 - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 13 +<<: !include common.yaml diff --git a/tests/components/speaker/test.esp32-c3-ard.yaml b/tests/components/speaker/test.esp32-c3-ard.yaml index 636aeba766..ddcf051fab 100644 --- a/tests/components/speaker/test.esp32-c3-ard.yaml +++ b/tests/components/speaker/test.esp32-c3-ard.yaml @@ -1,26 +1,9 @@ -esphome: - on_boot: - then: - - speaker.mute_on: - - speaker.mute_off: - - if: - condition: speaker.is_stopped - then: - - speaker.play: [0, 1, 2, 3] - - speaker.volume_set: 0.9 - - if: - condition: speaker.is_playing - then: - - speaker.finish: - - speaker.stop: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + i2s_bclk_pin: GPIO7 + i2s_lrclk_pin: GPIO6 + i2s_mclk_pin: GPIO9 + i2s_dout_pin: GPIO8 -i2s_audio: - i2s_lrclk_pin: 6 - i2s_bclk_pin: 7 - i2s_mclk_pin: 5 - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 3 +<<: !include common.yaml diff --git a/tests/components/speaker/test.esp32-c3-idf.yaml b/tests/components/speaker/test.esp32-c3-idf.yaml index 636aeba766..ddcf051fab 100644 --- a/tests/components/speaker/test.esp32-c3-idf.yaml +++ b/tests/components/speaker/test.esp32-c3-idf.yaml @@ -1,26 +1,9 @@ -esphome: - on_boot: - then: - - speaker.mute_on: - - speaker.mute_off: - - if: - condition: speaker.is_stopped - then: - - speaker.play: [0, 1, 2, 3] - - speaker.volume_set: 0.9 - - if: - condition: speaker.is_playing - then: - - speaker.finish: - - speaker.stop: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + i2s_bclk_pin: GPIO7 + i2s_lrclk_pin: GPIO6 + i2s_mclk_pin: GPIO9 + i2s_dout_pin: GPIO8 -i2s_audio: - i2s_lrclk_pin: 6 - i2s_bclk_pin: 7 - i2s_mclk_pin: 5 - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 3 +<<: !include common.yaml diff --git a/tests/components/speaker/test.esp32-idf.yaml b/tests/components/speaker/test.esp32-idf.yaml index b69440b133..e2439ebdf2 100644 --- a/tests/components/speaker/test.esp32-idf.yaml +++ b/tests/components/speaker/test.esp32-idf.yaml @@ -1,35 +1,9 @@ -esphome: - on_boot: - then: - - speaker.mute_on: - - speaker.mute_off: - - if: - condition: speaker.is_stopped - then: - - speaker.play: [0, 1, 2, 3] - - speaker.volume_set: 0.9 - - if: - condition: speaker.is_playing - then: - - speaker.finish: - - speaker.stop: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + i2s_bclk_pin: GPIO27 + i2s_lrclk_pin: GPIO26 + i2s_mclk_pin: GPIO25 + i2s_dout_pin: GPIO23 -i2s_audio: - i2s_lrclk_pin: 16 - i2s_bclk_pin: 17 - i2s_mclk_pin: 15 - -i2c: - scl: 12 - sda: 10 - -audio_dac: - - platform: aic3204 - id: internal_dac - -speaker: - - platform: i2s_audio - id: speaker_with_audio_dac_id - audio_dac: internal_dac - dac_type: external - i2s_dout_pin: 14 +<<: !include common.yaml diff --git a/tests/components/speed/common.yaml b/tests/components/speed/common.yaml new file mode 100644 index 0000000000..be8172af7e --- /dev/null +++ b/tests/components/speed/common.yaml @@ -0,0 +1,9 @@ +output: + - platform: ${output_platform} + id: fan_output_1 + pin: ${pin} + +fan: + - platform: speed + id: fan_speed + output: fan_output_1 diff --git a/tests/components/speed/test.esp32-ard.yaml b/tests/components/speed/test.esp32-ard.yaml index 29a55e9edd..26da1ce1d6 100644 --- a/tests/components/speed/test.esp32-ard.yaml +++ b/tests/components/speed/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 12 +substitutions: + output_platform: ledc + pin: GPIO14 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/speed/test.esp32-c3-ard.yaml b/tests/components/speed/test.esp32-c3-ard.yaml index fa1920676e..7476963591 100644 --- a/tests/components/speed/test.esp32-c3-ard.yaml +++ b/tests/components/speed/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 2 +substitutions: + output_platform: ledc + pin: GPIO4 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/speed/test.esp32-c3-idf.yaml b/tests/components/speed/test.esp32-c3-idf.yaml index fa1920676e..7476963591 100644 --- a/tests/components/speed/test.esp32-c3-idf.yaml +++ b/tests/components/speed/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 2 +substitutions: + output_platform: ledc + pin: GPIO4 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/speed/test.esp32-idf.yaml b/tests/components/speed/test.esp32-idf.yaml index 29a55e9edd..26da1ce1d6 100644 --- a/tests/components/speed/test.esp32-idf.yaml +++ b/tests/components/speed/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 12 +substitutions: + output_platform: ledc + pin: GPIO14 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/speed/test.esp8266-ard.yaml b/tests/components/speed/test.esp8266-ard.yaml index 6ed9949cf5..23a7f43b42 100644 --- a/tests/components/speed/test.esp8266-ard.yaml +++ b/tests/components/speed/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -output: - - platform: esp8266_pwm - id: fan_output_1 - pin: 12 +substitutions: + output_platform: esp8266_pwm + pin: GPIO14 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/speed/test.rp2040-ard.yaml b/tests/components/speed/test.rp2040-ard.yaml index 02b572db75..d70f7c74ec 100644 --- a/tests/components/speed/test.rp2040-ard.yaml +++ b/tests/components/speed/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -output: - - platform: rp2040_pwm - id: fan_output_1 - pin: 12 +substitutions: + output_platform: rp2040_pwm + pin: GPIO4 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/spi/common.yaml b/tests/components/spi/common.yaml new file mode 100644 index 0000000000..04b4779957 --- /dev/null +++ b/tests/components/spi/common.yaml @@ -0,0 +1,5 @@ +spi: + - id: spi_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} diff --git a/tests/components/spi/test.esp32-ard.yaml b/tests/components/spi/test.esp32-ard.yaml index 1cdcf461dd..448e54fea6 100644 --- a/tests/components/spi/test.esp32-ard.yaml +++ b/tests/components/spi/test.esp32-ard.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + +<<: !include common.yaml diff --git a/tests/components/spi/test.esp32-c3-ard.yaml b/tests/components/spi/test.esp32-c3-ard.yaml index f49470ad07..bfa12b1755 100644 --- a/tests/components/spi/test.esp32-c3-ard.yaml +++ b/tests/components/spi/test.esp32-c3-ard.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/spi/test.esp32-c3-idf.yaml b/tests/components/spi/test.esp32-c3-idf.yaml index f49470ad07..bfa12b1755 100644 --- a/tests/components/spi/test.esp32-c3-idf.yaml +++ b/tests/components/spi/test.esp32-c3-idf.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/spi/test.esp32-idf.yaml b/tests/components/spi/test.esp32-idf.yaml index 1cdcf461dd..448e54fea6 100644 --- a/tests/components/spi/test.esp32-idf.yaml +++ b/tests/components/spi/test.esp32-idf.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + +<<: !include common.yaml diff --git a/tests/components/spi/test.esp32-s3-idf.yaml b/tests/components/spi/test.esp32-s3-idf.yaml index 8db934023a..d394c5d7a4 100644 --- a/tests/components/spi/test.esp32-s3-idf.yaml +++ b/tests/components/spi/test.esp32-s3-idf.yaml @@ -9,8 +9,8 @@ spi: interface: hardware - id: quad_spi type: quad - clk_pin: 47 interface: spi3 + clk_pin: 47 data_pins: - number: 40 allow_other_uses: false @@ -18,7 +18,7 @@ spi: - 42 - 43 - id: spi_id_3 + interface: any clk_pin: 8 mosi_pin: 9 - interface: any diff --git a/tests/components/spi/test.esp8266-ard.yaml b/tests/components/spi/test.esp8266-ard.yaml index 83f110921f..b9545d4f6a 100644 --- a/tests/components/spi/test.esp8266-ard.yaml +++ b/tests/components/spi/test.esp8266-ard.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + +<<: !include common.yaml diff --git a/tests/components/spi/test.rp2040-ard.yaml b/tests/components/spi/test.rp2040-ard.yaml index 1e39d247fe..81a8acafd8 100644 --- a/tests/components/spi/test.rp2040-ard.yaml +++ b/tests/components/spi/test.rp2040-ard.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/spi_device/common.yaml b/tests/components/spi_device/common.yaml new file mode 100644 index 0000000000..636d82202b --- /dev/null +++ b/tests/components/spi_device/common.yaml @@ -0,0 +1,11 @@ +spi: + - id: spi_device1 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +spi_device: + id: spi_device_test + data_rate: 2MHz + spi_mode: 3 + bit_order: lsb_first diff --git a/tests/components/spi_device/test.esp32-ard.yaml b/tests/components/spi_device/test.esp32-ard.yaml index b539cb3ec4..448e54fea6 100644 --- a/tests/components/spi_device/test.esp32-ard.yaml +++ b/tests/components/spi_device/test.esp32-ard.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_device/test.esp32-c3-ard.yaml b/tests/components/spi_device/test.esp32-c3-ard.yaml index 99c0ac1ebb..bfa12b1755 100644 --- a/tests/components/spi_device/test.esp32-c3-ard.yaml +++ b/tests/components/spi_device/test.esp32-c3-ard.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_device/test.esp32-c3-idf.yaml b/tests/components/spi_device/test.esp32-c3-idf.yaml index 99c0ac1ebb..bfa12b1755 100644 --- a/tests/components/spi_device/test.esp32-c3-idf.yaml +++ b/tests/components/spi_device/test.esp32-c3-idf.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_device/test.esp32-idf.yaml b/tests/components/spi_device/test.esp32-idf.yaml index b539cb3ec4..448e54fea6 100644 --- a/tests/components/spi_device/test.esp32-idf.yaml +++ b/tests/components/spi_device/test.esp32-idf.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_device/test.esp8266-ard.yaml b/tests/components/spi_device/test.esp8266-ard.yaml index 988825ce2d..b9545d4f6a 100644 --- a/tests/components/spi_device/test.esp8266-ard.yaml +++ b/tests/components/spi_device/test.esp8266-ard.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_device/test.rp2040-ard.yaml b/tests/components/spi_device/test.rp2040-ard.yaml index 6020643f21..81a8acafd8 100644 --- a/tests/components/spi_device/test.rp2040-ard.yaml +++ b/tests/components/spi_device/test.rp2040-ard.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/common.yaml b/tests/components/spi_led_strip/common.yaml new file mode 100644 index 0000000000..80b98a63a4 --- /dev/null +++ b/tests/components/spi_led_strip/common.yaml @@ -0,0 +1,12 @@ +spi: + - id: spi_spi_led_strip + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +light: + - platform: spi_led_strip + num_leds: 4 + color_correct: [80%, 60%, 100%] + id: rgb_led + name: RGB LED + data_rate: 8MHz diff --git a/tests/components/spi_led_strip/test.esp32-ard.yaml b/tests/components/spi_led_strip/test.esp32-ard.yaml index f4a760bf4c..8906602ef4 100644 --- a/tests/components/spi_led_strip/test.esp32-ard.yaml +++ b/tests/components/spi_led_strip/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/test.esp32-c3-ard.yaml b/tests/components/spi_led_strip/test.esp32-c3-ard.yaml index 983ad2863f..a85b587070 100644 --- a/tests/components/spi_led_strip/test.esp32-c3-ard.yaml +++ b/tests/components/spi_led_strip/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/test.esp32-c3-idf.yaml b/tests/components/spi_led_strip/test.esp32-c3-idf.yaml index 983ad2863f..a85b587070 100644 --- a/tests/components/spi_led_strip/test.esp32-c3-idf.yaml +++ b/tests/components/spi_led_strip/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/test.esp32-idf.yaml b/tests/components/spi_led_strip/test.esp32-idf.yaml index f4a760bf4c..8906602ef4 100644 --- a/tests/components/spi_led_strip/test.esp32-idf.yaml +++ b/tests/components/spi_led_strip/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/test.esp8266-ard.yaml b/tests/components/spi_led_strip/test.esp8266-ard.yaml index 8e76303b6a..7baaa62ed5 100644 --- a/tests/components/spi_led_strip/test.esp8266-ard.yaml +++ b/tests/components/spi_led_strip/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/test.rp2040-ard.yaml b/tests/components/spi_led_strip/test.rp2040-ard.yaml index 9d12f1592b..411cfbe00e 100644 --- a/tests/components/spi_led_strip/test.rp2040-ard.yaml +++ b/tests/components/spi_led_strip/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/sps30/common.yaml b/tests/components/sps30/common.yaml new file mode 100644 index 0000000000..2fbe2c747a --- /dev/null +++ b/tests/components/sps30/common.yaml @@ -0,0 +1,36 @@ +i2c: + - id: i2c_sps30 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sps30 + pm_1_0: + name: Workshop PM <1µm Weight concentration + id: workshop_PM_1_0 + pm_2_5: + name: Workshop PM <2.5µm Weight concentration + id: workshop_PM_2_5 + pm_4_0: + name: Workshop PM <4µm Weight concentration + id: workshop_PM_4_0 + pm_10_0: + name: Workshop PM <10µm Weight concentration + id: workshop_PM_10_0 + pmc_0_5: + name: Workshop PM <0.5µm Number concentration + id: workshop_PMC_0_5 + pmc_1_0: + name: Workshop PM <1µm Number concentration + id: workshop_PMC_1_0 + pmc_2_5: + name: Workshop PM <2.5µm Number concentration + id: workshop_PMC_2_5 + pmc_4_0: + name: Workshop PM <4µm Number concentration + id: workshop_PMC_4_0 + pmc_10_0: + name: Workshop PM <10µm Number concentration + id: workshop_PMC_10_0 + address: 0x69 + update_interval: 10s diff --git a/tests/components/sps30/test.esp32-ard.yaml b/tests/components/sps30/test.esp32-ard.yaml index f9d1ee4e55..63c3bd6afd 100644 --- a/tests/components/sps30/test.esp32-ard.yaml +++ b/tests/components/sps30/test.esp32-ard.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sps30/test.esp32-c3-ard.yaml b/tests/components/sps30/test.esp32-c3-ard.yaml index e071a00936..ee2c29ca4e 100644 --- a/tests/components/sps30/test.esp32-c3-ard.yaml +++ b/tests/components/sps30/test.esp32-c3-ard.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sps30/test.esp32-c3-idf.yaml b/tests/components/sps30/test.esp32-c3-idf.yaml index e071a00936..ee2c29ca4e 100644 --- a/tests/components/sps30/test.esp32-c3-idf.yaml +++ b/tests/components/sps30/test.esp32-c3-idf.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sps30/test.esp32-idf.yaml b/tests/components/sps30/test.esp32-idf.yaml index f9d1ee4e55..63c3bd6afd 100644 --- a/tests/components/sps30/test.esp32-idf.yaml +++ b/tests/components/sps30/test.esp32-idf.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sps30/test.esp8266-ard.yaml b/tests/components/sps30/test.esp8266-ard.yaml index e071a00936..ee2c29ca4e 100644 --- a/tests/components/sps30/test.esp8266-ard.yaml +++ b/tests/components/sps30/test.esp8266-ard.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sps30/test.rp2040-ard.yaml b/tests/components/sps30/test.rp2040-ard.yaml index e071a00936..ee2c29ca4e 100644 --- a/tests/components/sps30/test.rp2040-ard.yaml +++ b/tests/components/sps30/test.rp2040-ard.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/common.yaml b/tests/components/ssd1306_i2c/common.yaml new file mode 100644 index 0000000000..d17f83f03a --- /dev/null +++ b/tests/components/ssd1306_i2c/common.yaml @@ -0,0 +1,25 @@ +i2c: + - id: i2c_ssd1306_i2c + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1306_i2c + model: SSD1306_128X64 + reset_pin: ${reset_pin} + address: 0x3C + id: display1 + contrast: 60% + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, 10, 10); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1306_i2c/test.esp32-ard.yaml b/tests/components/ssd1306_i2c/test.esp32-ard.yaml index dddc67309c..1ca773e06c 100644 --- a/tests/components/ssd1306_i2c/test.esp32-ard.yaml +++ b/tests/components/ssd1306_i2c/test.esp32-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/test.esp32-c3-ard.yaml b/tests/components/ssd1306_i2c/test.esp32-c3-ard.yaml index f4a301db51..4eaff7fa4a 100644 --- a/tests/components/ssd1306_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1306_i2c/test.esp32-c3-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/test.esp32-c3-idf.yaml b/tests/components/ssd1306_i2c/test.esp32-c3-idf.yaml index f4a301db51..4eaff7fa4a 100644 --- a/tests/components/ssd1306_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1306_i2c/test.esp32-c3-idf.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/test.esp32-idf.yaml b/tests/components/ssd1306_i2c/test.esp32-idf.yaml index dddc67309c..1ca773e06c 100644 --- a/tests/components/ssd1306_i2c/test.esp32-idf.yaml +++ b/tests/components/ssd1306_i2c/test.esp32-idf.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/test.esp8266-ard.yaml b/tests/components/ssd1306_i2c/test.esp8266-ard.yaml index f4a301db51..af91c21a0d 100644 --- a/tests/components/ssd1306_i2c/test.esp8266-ard.yaml +++ b/tests/components/ssd1306_i2c/test.esp8266-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO2 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/test.rp2040-ard.yaml b/tests/components/ssd1306_i2c/test.rp2040-ard.yaml index f4a301db51..4eaff7fa4a 100644 --- a/tests/components/ssd1306_i2c/test.rp2040-ard.yaml +++ b/tests/components/ssd1306_i2c/test.rp2040-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/common.yaml b/tests/components/ssd1306_spi/common.yaml new file mode 100644 index 0000000000..71705f32d2 --- /dev/null +++ b/tests/components/ssd1306_spi/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_ssd1306_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1306_spi + model: SSD1306 128x64 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1306_spi/test.esp32-ard.yaml b/tests/components/ssd1306_spi/test.esp32-ard.yaml index b0e5e0f1a2..bad5241f79 100644 --- a/tests/components/ssd1306_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1306_spi/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1306_spi/test.esp32-c3-ard.yaml index 01b2d0e4a8..c5c932c92c 100644 --- a/tests/components/ssd1306_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1306_spi/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1306_spi/test.esp32-c3-idf.yaml index 01b2d0e4a8..c5c932c92c 100644 --- a/tests/components/ssd1306_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1306_spi/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/test.esp32-idf.yaml b/tests/components/ssd1306_spi/test.esp32-idf.yaml index b0e5e0f1a2..bad5241f79 100644 --- a/tests/components/ssd1306_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1306_spi/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/test.esp8266-ard.yaml b/tests/components/ssd1306_spi/test.esp8266-ard.yaml index 135e364bb2..3f023a60eb 100644 --- a/tests/components/ssd1306_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1306_spi/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/test.rp2040-ard.yaml b/tests/components/ssd1306_spi/test.rp2040-ard.yaml index 94c4b85158..d7fd6ee294 100644 --- a/tests/components/ssd1306_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1306_spi/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/common.yaml b/tests/components/ssd1322_spi/common.yaml new file mode 100644 index 0000000000..b67392794c --- /dev/null +++ b/tests/components/ssd1322_spi/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_ssd1322_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1322_spi + model: SSD1322 256x64 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1322_spi/test.esp32-ard.yaml b/tests/components/ssd1322_spi/test.esp32-ard.yaml index aa6d0fbf01..bad5241f79 100644 --- a/tests/components/ssd1322_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1322_spi/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1322_spi/test.esp32-c3-ard.yaml index 4fa9f86594..c5c932c92c 100644 --- a/tests/components/ssd1322_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1322_spi/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1322_spi/test.esp32-c3-idf.yaml index 4fa9f86594..c5c932c92c 100644 --- a/tests/components/ssd1322_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1322_spi/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/test.esp32-idf.yaml b/tests/components/ssd1322_spi/test.esp32-idf.yaml index aa6d0fbf01..bad5241f79 100644 --- a/tests/components/ssd1322_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1322_spi/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/test.esp8266-ard.yaml b/tests/components/ssd1322_spi/test.esp8266-ard.yaml index a5aa565c09..3f023a60eb 100644 --- a/tests/components/ssd1322_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1322_spi/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/test.rp2040-ard.yaml b/tests/components/ssd1322_spi/test.rp2040-ard.yaml index 59544e7878..d7fd6ee294 100644 --- a/tests/components/ssd1322_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1322_spi/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/common.yaml b/tests/components/ssd1325_spi/common.yaml new file mode 100644 index 0000000000..eaa8b619ca --- /dev/null +++ b/tests/components/ssd1325_spi/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_ssd1325_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1325_spi + model: SSD1325 128x64 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1325_spi/test.esp32-ard.yaml b/tests/components/ssd1325_spi/test.esp32-ard.yaml index 84d94eff28..bad5241f79 100644 --- a/tests/components/ssd1325_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1325_spi/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1325_spi/test.esp32-c3-ard.yaml index 0fa8cb6488..c5c932c92c 100644 --- a/tests/components/ssd1325_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1325_spi/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1325_spi/test.esp32-c3-idf.yaml index 0fa8cb6488..c5c932c92c 100644 --- a/tests/components/ssd1325_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1325_spi/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/test.esp32-idf.yaml b/tests/components/ssd1325_spi/test.esp32-idf.yaml index 84d94eff28..bad5241f79 100644 --- a/tests/components/ssd1325_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1325_spi/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/test.esp8266-ard.yaml b/tests/components/ssd1325_spi/test.esp8266-ard.yaml index 9d7e483585..3f023a60eb 100644 --- a/tests/components/ssd1325_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1325_spi/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/test.rp2040-ard.yaml b/tests/components/ssd1325_spi/test.rp2040-ard.yaml index 869663c19d..d7fd6ee294 100644 --- a/tests/components/ssd1325_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1325_spi/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/common.yaml b/tests/components/ssd1327_i2c/common.yaml new file mode 100644 index 0000000000..72a122c3d7 --- /dev/null +++ b/tests/components/ssd1327_i2c/common.yaml @@ -0,0 +1,24 @@ +i2c: + - id: i2c_ssd1327_i2c + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1327_i2c + model: SSD1327_128x128 + reset_pin: ${reset_pin} + address: 0x3C + id: display1 + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, 10, 10); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1327_i2c/test.esp32-ard.yaml b/tests/components/ssd1327_i2c/test.esp32-ard.yaml index e72a9c7b7a..1ca773e06c 100644 --- a/tests/components/ssd1327_i2c/test.esp32-ard.yaml +++ b/tests/components/ssd1327_i2c/test.esp32-ard.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/test.esp32-c3-ard.yaml b/tests/components/ssd1327_i2c/test.esp32-c3-ard.yaml index cd28795ff1..4eaff7fa4a 100644 --- a/tests/components/ssd1327_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1327_i2c/test.esp32-c3-ard.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/test.esp32-c3-idf.yaml b/tests/components/ssd1327_i2c/test.esp32-c3-idf.yaml index cd28795ff1..4eaff7fa4a 100644 --- a/tests/components/ssd1327_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1327_i2c/test.esp32-c3-idf.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/test.esp32-idf.yaml b/tests/components/ssd1327_i2c/test.esp32-idf.yaml index e72a9c7b7a..1ca773e06c 100644 --- a/tests/components/ssd1327_i2c/test.esp32-idf.yaml +++ b/tests/components/ssd1327_i2c/test.esp32-idf.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/test.esp8266-ard.yaml b/tests/components/ssd1327_i2c/test.esp8266-ard.yaml index cd28795ff1..af91c21a0d 100644 --- a/tests/components/ssd1327_i2c/test.esp8266-ard.yaml +++ b/tests/components/ssd1327_i2c/test.esp8266-ard.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO2 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/test.rp2040-ard.yaml b/tests/components/ssd1327_i2c/test.rp2040-ard.yaml index cd28795ff1..4eaff7fa4a 100644 --- a/tests/components/ssd1327_i2c/test.rp2040-ard.yaml +++ b/tests/components/ssd1327_i2c/test.rp2040-ard.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/common.yaml b/tests/components/ssd1327_spi/common.yaml new file mode 100644 index 0000000000..85f4d4736b --- /dev/null +++ b/tests/components/ssd1327_spi/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_ssd1327_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1327_spi + model: SSD1327 128x128 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1327_spi/test.esp32-ard.yaml b/tests/components/ssd1327_spi/test.esp32-ard.yaml index e103ded187..bad5241f79 100644 --- a/tests/components/ssd1327_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1327_spi/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1327_spi/test.esp32-c3-ard.yaml index ec5795d716..c5c932c92c 100644 --- a/tests/components/ssd1327_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1327_spi/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1327_spi/test.esp32-c3-idf.yaml index ec5795d716..c5c932c92c 100644 --- a/tests/components/ssd1327_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1327_spi/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/test.esp32-idf.yaml b/tests/components/ssd1327_spi/test.esp32-idf.yaml index e103ded187..bad5241f79 100644 --- a/tests/components/ssd1327_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1327_spi/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/test.esp8266-ard.yaml b/tests/components/ssd1327_spi/test.esp8266-ard.yaml index 30455d24ee..3f023a60eb 100644 --- a/tests/components/ssd1327_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1327_spi/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/test.rp2040-ard.yaml b/tests/components/ssd1327_spi/test.rp2040-ard.yaml index f819ab2c41..d7fd6ee294 100644 --- a/tests/components/ssd1327_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1327_spi/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/common.yaml b/tests/components/ssd1331_spi/common.yaml new file mode 100644 index 0000000000..40726101e8 --- /dev/null +++ b/tests/components/ssd1331_spi/common.yaml @@ -0,0 +1,23 @@ +spi: + - id: spi_ssd1331_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1331_spi + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1331_spi/test.esp32-ard.yaml b/tests/components/ssd1331_spi/test.esp32-ard.yaml index e9eb8ea9ad..bad5241f79 100644 --- a/tests/components/ssd1331_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1331_spi/test.esp32-ard.yaml @@ -1,24 +1,8 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1331_spi - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1331_spi/test.esp32-c3-ard.yaml index 9a35918faf..c5c932c92c 100644 --- a/tests/components/ssd1331_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1331_spi/test.esp32-c3-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1331_spi - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1331_spi/test.esp32-c3-idf.yaml index 9a35918faf..c5c932c92c 100644 --- a/tests/components/ssd1331_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1331_spi/test.esp32-c3-idf.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1331_spi - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/test.esp32-idf.yaml b/tests/components/ssd1331_spi/test.esp32-idf.yaml index e9eb8ea9ad..bad5241f79 100644 --- a/tests/components/ssd1331_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1331_spi/test.esp32-idf.yaml @@ -1,24 +1,8 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1331_spi - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/test.esp8266-ard.yaml b/tests/components/ssd1331_spi/test.esp8266-ard.yaml index 3b319ef38e..3f023a60eb 100644 --- a/tests/components/ssd1331_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1331_spi/test.esp8266-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1331_spi - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/test.rp2040-ard.yaml b/tests/components/ssd1331_spi/test.rp2040-ard.yaml index 947685b07a..d7fd6ee294 100644 --- a/tests/components/ssd1331_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1331_spi/test.rp2040-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1331_spi - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/common.yaml b/tests/components/ssd1351_spi/common.yaml new file mode 100644 index 0000000000..fa495ff0c3 --- /dev/null +++ b/tests/components/ssd1351_spi/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_ssd1351_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1351_spi + model: "SSD1351 128x128" + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1351_spi/test.esp32-ard.yaml b/tests/components/ssd1351_spi/test.esp32-ard.yaml index 8342cb972b..bad5241f79 100644 --- a/tests/components/ssd1351_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1351_spi/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1351_spi/test.esp32-c3-ard.yaml index 2a7266f502..c5c932c92c 100644 --- a/tests/components/ssd1351_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1351_spi/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1351_spi/test.esp32-c3-idf.yaml index 2a7266f502..c5c932c92c 100644 --- a/tests/components/ssd1351_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1351_spi/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/test.esp32-idf.yaml b/tests/components/ssd1351_spi/test.esp32-idf.yaml index 8342cb972b..bad5241f79 100644 --- a/tests/components/ssd1351_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1351_spi/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/test.esp8266-ard.yaml b/tests/components/ssd1351_spi/test.esp8266-ard.yaml index 7ed9a31dde..3f023a60eb 100644 --- a/tests/components/ssd1351_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1351_spi/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/test.rp2040-ard.yaml b/tests/components/ssd1351_spi/test.rp2040-ard.yaml index 72936d046b..d7fd6ee294 100644 --- a/tests/components/ssd1351_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1351_spi/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/common.yaml b/tests/components/st7567_i2c/common.yaml new file mode 100644 index 0000000000..41c65e5110 --- /dev/null +++ b/tests/components/st7567_i2c/common.yaml @@ -0,0 +1,23 @@ +i2c: + - id: i2c_st7567_i2c + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: st7567_i2c + reset_pin: ${reset_pin} + address: 0x3C + id: display1 + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, 10, 10); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/st7567_i2c/test.esp32-ard.yaml b/tests/components/st7567_i2c/test.esp32-ard.yaml index b7aee61b68..1ca773e06c 100644 --- a/tests/components/st7567_i2c/test.esp32-ard.yaml +++ b/tests/components/st7567_i2c/test.esp32-ard.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/test.esp32-c3-ard.yaml b/tests/components/st7567_i2c/test.esp32-c3-ard.yaml index d779040500..4eaff7fa4a 100644 --- a/tests/components/st7567_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/st7567_i2c/test.esp32-c3-ard.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/test.esp32-c3-idf.yaml b/tests/components/st7567_i2c/test.esp32-c3-idf.yaml index d779040500..4eaff7fa4a 100644 --- a/tests/components/st7567_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/st7567_i2c/test.esp32-c3-idf.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/test.esp32-idf.yaml b/tests/components/st7567_i2c/test.esp32-idf.yaml index b7aee61b68..1ca773e06c 100644 --- a/tests/components/st7567_i2c/test.esp32-idf.yaml +++ b/tests/components/st7567_i2c/test.esp32-idf.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/test.esp8266-ard.yaml b/tests/components/st7567_i2c/test.esp8266-ard.yaml index d779040500..af91c21a0d 100644 --- a/tests/components/st7567_i2c/test.esp8266-ard.yaml +++ b/tests/components/st7567_i2c/test.esp8266-ard.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO2 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/test.rp2040-ard.yaml b/tests/components/st7567_i2c/test.rp2040-ard.yaml index d779040500..4eaff7fa4a 100644 --- a/tests/components/st7567_i2c/test.rp2040-ard.yaml +++ b/tests/components/st7567_i2c/test.rp2040-ard.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/common.yaml b/tests/components/st7567_spi/common.yaml new file mode 100644 index 0000000000..037a700239 --- /dev/null +++ b/tests/components/st7567_spi/common.yaml @@ -0,0 +1,23 @@ +spi: + - id: spi_st7567_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: st7567_spi + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/st7567_spi/test.esp32-ard.yaml b/tests/components/st7567_spi/test.esp32-ard.yaml index bb4530248f..bad5241f79 100644 --- a/tests/components/st7567_spi/test.esp32-ard.yaml +++ b/tests/components/st7567_spi/test.esp32-ard.yaml @@ -1,24 +1,8 @@ -spi: - - id: spi_st7567_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7567_spi - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/test.esp32-c3-ard.yaml b/tests/components/st7567_spi/test.esp32-c3-ard.yaml index b799ce7302..c5c932c92c 100644 --- a/tests/components/st7567_spi/test.esp32-c3-ard.yaml +++ b/tests/components/st7567_spi/test.esp32-c3-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_st7567_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7567_spi - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/test.esp32-c3-idf.yaml b/tests/components/st7567_spi/test.esp32-c3-idf.yaml index b799ce7302..c5c932c92c 100644 --- a/tests/components/st7567_spi/test.esp32-c3-idf.yaml +++ b/tests/components/st7567_spi/test.esp32-c3-idf.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_st7567_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7567_spi - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/test.esp32-idf.yaml b/tests/components/st7567_spi/test.esp32-idf.yaml index bb4530248f..bad5241f79 100644 --- a/tests/components/st7567_spi/test.esp32-idf.yaml +++ b/tests/components/st7567_spi/test.esp32-idf.yaml @@ -1,24 +1,8 @@ -spi: - - id: spi_st7567_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7567_spi - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/test.esp8266-ard.yaml b/tests/components/st7567_spi/test.esp8266-ard.yaml index bbc47e67f6..3f023a60eb 100644 --- a/tests/components/st7567_spi/test.esp8266-ard.yaml +++ b/tests/components/st7567_spi/test.esp8266-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_st7567_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7567_spi - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/test.rp2040-ard.yaml b/tests/components/st7567_spi/test.rp2040-ard.yaml index 1b491101a8..d7fd6ee294 100644 --- a/tests/components/st7567_spi/test.rp2040-ard.yaml +++ b/tests/components/st7567_spi/test.rp2040-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_st7567_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7567_spi - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7701s/common.yaml b/tests/components/st7701s/common.yaml index 6e4fccc9cb..b94fadfe52 100644 --- a/tests/components/st7701s/common.yaml +++ b/tests/components/st7701s/common.yaml @@ -1,21 +1,7 @@ -psram: - mode: octal - speed: 80MHz spi: - - id: lcd_spi - clk_pin: 41 - mosi_pin: 48 - -i2c: - sda: 39 - scl: 40 - scan: false - id: bus_a - -pca9554: - - id: p_c_a - pin_count: 16 - address: 0x20 + - id: spi_st7701s + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} display: - platform: st7701s @@ -28,16 +14,12 @@ display: transform: mirror_x: true mirror_y: true - cs_pin: - pca9554: p_c_a - number: 4 - reset_pin: - pca9554: p_c_a - number: 5 - de_pin: 18 - hsync_pin: 16 - vsync_pin: 17 - pclk_pin: 21 + cs_pin: ${cs_pin} + reset_pin: ${reset_pin} + de_pin: ${de_pin} + hsync_pin: ${hsync_pin} + vsync_pin: ${vsync_pin} + pclk_pin: ${pclk_pin} init_sequence: - 1 - [0x23, 0xA, 0xB] @@ -45,13 +27,11 @@ display: - [0x23, 0xA, 0xB] - delay 0.2s data_pins: - - number: 0 - ignore_strapping_warning: true + - 0 - 1 - 2 - 3 - - number: 4 - ignore_strapping_warning: false + - 4 - 5 - 6 - 7 diff --git a/tests/components/st7701s/test.esp32-s3-idf.yaml b/tests/components/st7701s/test.esp32-s3-idf.yaml index dade44d145..cd09b31f6e 100644 --- a/tests/components/st7701s/test.esp32-s3-idf.yaml +++ b/tests/components/st7701s/test.esp32-s3-idf.yaml @@ -1 +1,11 @@ +substitutions: + clk_pin: GPIO41 + mosi_pin: GPIO48 + cs_pin: GPIO44 + de_pin: GPIO18 + reset_pin: GPIO47 + hsync_pin: GPIO16 + vsync_pin: GPIO17 + pclk_pin: GPIO21 + <<: !include common.yaml diff --git a/tests/components/st7735/common.yaml b/tests/components/st7735/common.yaml new file mode 100644 index 0000000000..c140652eda --- /dev/null +++ b/tests/components/st7735/common.yaml @@ -0,0 +1,28 @@ +spi: + - id: spi_st7735 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: st7735 + model: INITR_18BLACKTAB + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + device_width: 128 + device_height: 160 + col_start: 0 + row_start: 0 + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/st7735/test.esp32-ard.yaml b/tests/components/st7735/test.esp32-ard.yaml index fd3f6cade6..bad5241f79 100644 --- a/tests/components/st7735/test.esp32-ard.yaml +++ b/tests/components/st7735/test.esp32-ard.yaml @@ -1,29 +1,8 @@ -spi: - - id: spi_st7735 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7735/test.esp32-c3-ard.yaml b/tests/components/st7735/test.esp32-c3-ard.yaml index fc6c2421c4..c5c932c92c 100644 --- a/tests/components/st7735/test.esp32-c3-ard.yaml +++ b/tests/components/st7735/test.esp32-c3-ard.yaml @@ -1,29 +1,9 @@ -spi: - - id: spi_st7735 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7735/test.esp32-c3-idf.yaml b/tests/components/st7735/test.esp32-c3-idf.yaml index fc6c2421c4..c5c932c92c 100644 --- a/tests/components/st7735/test.esp32-c3-idf.yaml +++ b/tests/components/st7735/test.esp32-c3-idf.yaml @@ -1,29 +1,9 @@ -spi: - - id: spi_st7735 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7735/test.esp32-idf.yaml b/tests/components/st7735/test.esp32-idf.yaml index fd3f6cade6..bad5241f79 100644 --- a/tests/components/st7735/test.esp32-idf.yaml +++ b/tests/components/st7735/test.esp32-idf.yaml @@ -1,29 +1,8 @@ -spi: - - id: spi_st7735 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7735/test.esp8266-ard.yaml b/tests/components/st7735/test.esp8266-ard.yaml index ea8fa93c36..3f023a60eb 100644 --- a/tests/components/st7735/test.esp8266-ard.yaml +++ b/tests/components/st7735/test.esp8266-ard.yaml @@ -1,29 +1,9 @@ -spi: - - id: spi_st7735 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7735/test.rp2040-ard.yaml b/tests/components/st7735/test.rp2040-ard.yaml index 828f9a3ae1..d7fd6ee294 100644 --- a/tests/components/st7735/test.rp2040-ard.yaml +++ b/tests/components/st7735/test.rp2040-ard.yaml @@ -1,29 +1,9 @@ -spi: - - id: spi_st7735 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/common.yaml b/tests/components/st7789v/common.yaml new file mode 100644 index 0000000000..d5f74809e0 --- /dev/null +++ b/tests/components/st7789v/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_st7789v + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: st7789v + model: TTGO TDisplay 135x240 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/st7789v/test.esp32-ard.yaml b/tests/components/st7789v/test.esp32-ard.yaml index 54a9db6da1..bad5241f79 100644 --- a/tests/components/st7789v/test.esp32-ard.yaml +++ b/tests/components/st7789v/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_st7789v - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/test.esp32-c3-ard.yaml b/tests/components/st7789v/test.esp32-c3-ard.yaml index 1cb8d22fcb..c5c932c92c 100644 --- a/tests/components/st7789v/test.esp32-c3-ard.yaml +++ b/tests/components/st7789v/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_st7789v - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 2 - dc_pin: 3 - reset_pin: 8 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/test.esp32-c3-idf.yaml b/tests/components/st7789v/test.esp32-c3-idf.yaml index 1cb8d22fcb..c5c932c92c 100644 --- a/tests/components/st7789v/test.esp32-c3-idf.yaml +++ b/tests/components/st7789v/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_st7789v - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 2 - dc_pin: 3 - reset_pin: 8 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/test.esp32-idf.yaml b/tests/components/st7789v/test.esp32-idf.yaml index 54a9db6da1..bad5241f79 100644 --- a/tests/components/st7789v/test.esp32-idf.yaml +++ b/tests/components/st7789v/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_st7789v - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/test.esp8266-ard.yaml b/tests/components/st7789v/test.esp8266-ard.yaml index deeceb8c9a..3f023a60eb 100644 --- a/tests/components/st7789v/test.esp8266-ard.yaml +++ b/tests/components/st7789v/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_st7789v - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/test.rp2040-ard.yaml b/tests/components/st7789v/test.rp2040-ard.yaml index 778aa2aa55..d7fd6ee294 100644 --- a/tests/components/st7789v/test.rp2040-ard.yaml +++ b/tests/components/st7789v/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_st7789v - clk_pin: 2 - mosi_pin: 3 - miso_pin: 8 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/common.yaml b/tests/components/st7920/common.yaml new file mode 100644 index 0000000000..9ede271f01 --- /dev/null +++ b/tests/components/st7920/common.yaml @@ -0,0 +1,23 @@ +spi: + - id: spi_st7920 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: st7920 + cs_pin: ${cs_pin} + height: 128 + width: 64 + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/st7920/test.esp32-ard.yaml b/tests/components/st7920/test.esp32-ard.yaml index cdcbc85642..04d2633d2b 100644 --- a/tests/components/st7920/test.esp32-ard.yaml +++ b/tests/components/st7920/test.esp32-ard.yaml @@ -1,24 +1,6 @@ -spi: - - id: spi_st7920 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 -display: - - platform: st7920 - cs_pin: 12 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/test.esp32-c3-ard.yaml b/tests/components/st7920/test.esp32-c3-ard.yaml index 84ae88461f..2415ba5dc6 100644 --- a/tests/components/st7920/test.esp32-c3-ard.yaml +++ b/tests/components/st7920/test.esp32-c3-ard.yaml @@ -1,24 +1,7 @@ -spi: - - id: spi_st7920 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -display: - - platform: st7920 - cs_pin: 2 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/test.esp32-c3-idf.yaml b/tests/components/st7920/test.esp32-c3-idf.yaml index 84ae88461f..2415ba5dc6 100644 --- a/tests/components/st7920/test.esp32-c3-idf.yaml +++ b/tests/components/st7920/test.esp32-c3-idf.yaml @@ -1,24 +1,7 @@ -spi: - - id: spi_st7920 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -display: - - platform: st7920 - cs_pin: 2 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/test.esp32-idf.yaml b/tests/components/st7920/test.esp32-idf.yaml index cdcbc85642..04d2633d2b 100644 --- a/tests/components/st7920/test.esp32-idf.yaml +++ b/tests/components/st7920/test.esp32-idf.yaml @@ -1,24 +1,6 @@ -spi: - - id: spi_st7920 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 -display: - - platform: st7920 - cs_pin: 12 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/test.esp8266-ard.yaml b/tests/components/st7920/test.esp8266-ard.yaml index 0450bf1c5e..bd5c203e35 100644 --- a/tests/components/st7920/test.esp8266-ard.yaml +++ b/tests/components/st7920/test.esp8266-ard.yaml @@ -1,24 +1,7 @@ -spi: - - id: spi_st7920 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 -display: - - platform: st7920 - cs_pin: 15 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/test.rp2040-ard.yaml b/tests/components/st7920/test.rp2040-ard.yaml index f442820e7b..f6c3f1eeca 100644 --- a/tests/components/st7920/test.rp2040-ard.yaml +++ b/tests/components/st7920/test.rp2040-ard.yaml @@ -1,24 +1,7 @@ -spi: - - id: spi_st7920 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -display: - - platform: st7920 - cs_pin: 5 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/sts3x/common.yaml b/tests/components/sts3x/common.yaml new file mode 100644 index 0000000000..1feac4bc3f --- /dev/null +++ b/tests/components/sts3x/common.yaml @@ -0,0 +1,10 @@ +i2c: + - id: i2c_sts3x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sts3x + id: sts3x_sensor + name: STS3X Temperature + address: 0x4A diff --git a/tests/components/sts3x/test.esp32-ard.yaml b/tests/components/sts3x/test.esp32-ard.yaml index a74d61e748..63c3bd6afd 100644 --- a/tests/components/sts3x/test.esp32-ard.yaml +++ b/tests/components/sts3x/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sts3x/test.esp32-c3-ard.yaml b/tests/components/sts3x/test.esp32-c3-ard.yaml index 87980ce3a7..ee2c29ca4e 100644 --- a/tests/components/sts3x/test.esp32-c3-ard.yaml +++ b/tests/components/sts3x/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sts3x/test.esp32-c3-idf.yaml b/tests/components/sts3x/test.esp32-c3-idf.yaml index 87980ce3a7..ee2c29ca4e 100644 --- a/tests/components/sts3x/test.esp32-c3-idf.yaml +++ b/tests/components/sts3x/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sts3x/test.esp32-idf.yaml b/tests/components/sts3x/test.esp32-idf.yaml index a74d61e748..63c3bd6afd 100644 --- a/tests/components/sts3x/test.esp32-idf.yaml +++ b/tests/components/sts3x/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sts3x/test.esp8266-ard.yaml b/tests/components/sts3x/test.esp8266-ard.yaml index 87980ce3a7..ee2c29ca4e 100644 --- a/tests/components/sts3x/test.esp8266-ard.yaml +++ b/tests/components/sts3x/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sts3x/test.rp2040-ard.yaml b/tests/components/sts3x/test.rp2040-ard.yaml index 87980ce3a7..ee2c29ca4e 100644 --- a/tests/components/sts3x/test.rp2040-ard.yaml +++ b/tests/components/sts3x/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/common.yaml b/tests/components/sun_gtil2/common.yaml new file mode 100644 index 0000000000..15cc892d90 --- /dev/null +++ b/tests/components/sun_gtil2/common.yaml @@ -0,0 +1,40 @@ +uart: + - id: uart_sun_gtil2 + rx_pin: ${rx_pin} + baud_rate: 9600 + +sun_gtil2: + +sensor: + - platform: sun_gtil2 + temperature: + id: gtil_temperature + name: Heatsink Temperature + filters: + - throttle_average: 30s + dc_voltage: + id: gtil_dc_voltage + name: DC Voltage + filters: + - throttle_average: 30s + ac_voltage: + id: gtil_ac_voltage + name: AC Voltage + filters: + - throttle_average: 30s + ac_power: + id: gtil_ac_power + name: AC Power + dc_power: + id: gtil_dc_power + name: DC Power + limiter_power: + id: gtil_limiter_power + +text_sensor: + - platform: sun_gtil2 + state: + id: gtil_state + name: State + serial_number: + id: gtil_serial_number diff --git a/tests/components/sun_gtil2/test.esp32-ard.yaml b/tests/components/sun_gtil2/test.esp32-ard.yaml index ed1e68e574..ad420099ff 100644 --- a/tests/components/sun_gtil2/test.esp32-ard.yaml +++ b/tests/components/sun_gtil2/test.esp32-ard.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + rx_pin: GPIO16 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/test.esp32-c3-ard.yaml b/tests/components/sun_gtil2/test.esp32-c3-ard.yaml index 6ec834db98..b8a6b85616 100644 --- a/tests/components/sun_gtil2/test.esp32-c3-ard.yaml +++ b/tests/components/sun_gtil2/test.esp32-c3-ard.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + rx_pin: GPIO5 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/test.esp32-c3-idf.yaml b/tests/components/sun_gtil2/test.esp32-c3-idf.yaml index 6ec834db98..b8a6b85616 100644 --- a/tests/components/sun_gtil2/test.esp32-c3-idf.yaml +++ b/tests/components/sun_gtil2/test.esp32-c3-idf.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + rx_pin: GPIO5 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/test.esp32-idf.yaml b/tests/components/sun_gtil2/test.esp32-idf.yaml index ed1e68e574..ad420099ff 100644 --- a/tests/components/sun_gtil2/test.esp32-idf.yaml +++ b/tests/components/sun_gtil2/test.esp32-idf.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + rx_pin: GPIO16 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/test.esp8266-ard.yaml b/tests/components/sun_gtil2/test.esp8266-ard.yaml index 6ec834db98..b8a6b85616 100644 --- a/tests/components/sun_gtil2/test.esp8266-ard.yaml +++ b/tests/components/sun_gtil2/test.esp8266-ard.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + rx_pin: GPIO5 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/test.rp2040-ard.yaml b/tests/components/sun_gtil2/test.rp2040-ard.yaml index 6ec834db98..b8a6b85616 100644 --- a/tests/components/sun_gtil2/test.rp2040-ard.yaml +++ b/tests/components/sun_gtil2/test.rp2040-ard.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + rx_pin: GPIO5 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sx1509/common.yaml b/tests/components/sx1509/common.yaml new file mode 100644 index 0000000000..a09d850649 --- /dev/null +++ b/tests/components/sx1509/common.yaml @@ -0,0 +1,33 @@ +i2c: + - id: i2c_sx1509 + scl: ${scl_pin} + sda: ${sda_pin} + +sx1509: + - id: sx1509_hub + address: 0x3E + +binary_sensor: + - platform: gpio + name: GPIO SX1509 Test + pin: + sx1509: sx1509_hub + number: 3 + +switch: + - platform: gpio + name: GPIO SX1509 Test Out Open Drain + pin: + sx1509: sx1509_hub + number: 0 + mode: + output: true + open_drain: true + + - platform: gpio + name: GPIO SX1509 Test Out Standard + pin: + sx1509: sx1509_hub + number: 1 + mode: + output: true diff --git a/tests/components/sx1509/test.esp32-ard.yaml b/tests/components/sx1509/test.esp32-ard.yaml index aa1d161a43..63c3bd6afd 100644 --- a/tests/components/sx1509/test.esp32-ard.yaml +++ b/tests/components/sx1509/test.esp32-ard.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml diff --git a/tests/components/sx1509/test.esp32-c3-ard.yaml b/tests/components/sx1509/test.esp32-c3-ard.yaml index 0397812880..ee2c29ca4e 100644 --- a/tests/components/sx1509/test.esp32-c3-ard.yaml +++ b/tests/components/sx1509/test.esp32-c3-ard.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml diff --git a/tests/components/sx1509/test.esp32-c3-idf.yaml b/tests/components/sx1509/test.esp32-c3-idf.yaml index 0397812880..ee2c29ca4e 100644 --- a/tests/components/sx1509/test.esp32-c3-idf.yaml +++ b/tests/components/sx1509/test.esp32-c3-idf.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml diff --git a/tests/components/sx1509/test.esp32-idf.yaml b/tests/components/sx1509/test.esp32-idf.yaml index aa1d161a43..63c3bd6afd 100644 --- a/tests/components/sx1509/test.esp32-idf.yaml +++ b/tests/components/sx1509/test.esp32-idf.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml diff --git a/tests/components/sx1509/test.esp8266-ard.yaml b/tests/components/sx1509/test.esp8266-ard.yaml index 0397812880..ee2c29ca4e 100644 --- a/tests/components/sx1509/test.esp8266-ard.yaml +++ b/tests/components/sx1509/test.esp8266-ard.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml diff --git a/tests/components/sx1509/test.rp2040-ard.yaml b/tests/components/sx1509/test.rp2040-ard.yaml index 0397812880..ee2c29ca4e 100644 --- a/tests/components/sx1509/test.rp2040-ard.yaml +++ b/tests/components/sx1509/test.rp2040-ard.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml From dc8646cda65da5c17acb4c70a3b6ceaa2f54bbe7 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sun, 9 Feb 2025 15:43:17 -0600 Subject: [PATCH 170/194] [CI] Consolidate some tests (U, V, W, X, Y, Z) (#8210) --- tests/components/ufire_ec/common.yaml | 25 ++ tests/components/ufire_ec/test.esp32-ard.yaml | 28 +-- .../ufire_ec/test.esp32-c3-ard.yaml | 28 +-- .../ufire_ec/test.esp32-c3-idf.yaml | 28 +-- tests/components/ufire_ec/test.esp32-idf.yaml | 28 +-- .../components/ufire_ec/test.esp8266-ard.yaml | 28 +-- .../components/ufire_ec/test.rp2040-ard.yaml | 28 +-- tests/components/ufire_ise/common.yaml | 25 ++ .../components/ufire_ise/test.esp32-ard.yaml | 28 +-- .../ufire_ise/test.esp32-c3-ard.yaml | 28 +-- .../ufire_ise/test.esp32-c3-idf.yaml | 28 +-- .../components/ufire_ise/test.esp32-idf.yaml | 28 +-- .../ufire_ise/test.esp8266-ard.yaml | 28 +-- .../components/ufire_ise/test.rp2040-ard.yaml | 28 +-- tests/components/uln2003/common.yaml | 29 +++ tests/components/uln2003/test.esp32-ard.yaml | 34 +-- .../components/uln2003/test.esp32-c3-ard.yaml | 34 +-- .../components/uln2003/test.esp32-c3-idf.yaml | 34 +-- tests/components/uln2003/test.esp32-idf.yaml | 34 +-- .../components/uln2003/test.esp8266-ard.yaml | 34 +-- tests/components/uln2003/test.rp2040-ard.yaml | 34 +-- tests/components/vbus/common.yaml | 42 ++++ tests/components/vbus/test.esp32-ard.yaml | 45 +--- tests/components/vbus/test.esp32-c3-ard.yaml | 45 +--- tests/components/vbus/test.esp32-c3-idf.yaml | 45 +--- tests/components/vbus/test.esp32-idf.yaml | 45 +--- tests/components/vbus/test.esp8266-ard.yaml | 45 +--- tests/components/vbus/test.rp2040-ard.yaml | 45 +--- tests/components/veml3235/common.yaml | 15 ++ tests/components/veml3235/test.esp32-ard.yaml | 18 +- .../veml3235/test.esp32-c3-ard.yaml | 18 +- .../veml3235/test.esp32-c3-idf.yaml | 18 +- tests/components/veml3235/test.esp32-idf.yaml | 18 +- .../components/veml3235/test.esp8266-ard.yaml | 18 +- .../components/veml3235/test.rp2040-ard.yaml | 18 +- tests/components/veml7700/common.yaml | 5 + tests/components/veml7700/test.esp32-ard.yaml | 7 +- .../veml7700/test.esp32-c3-ard.yaml | 7 +- .../veml7700/test.esp32-c3-idf.yaml | 7 +- tests/components/veml7700/test.esp32-idf.yaml | 7 +- .../components/veml7700/test.esp8266-ard.yaml | 7 +- .../components/veml7700/test.rp2040-ard.yaml | 7 +- tests/components/vl53l0x/common.yaml | 12 + tests/components/vl53l0x/test.esp32-ard.yaml | 15 +- .../components/vl53l0x/test.esp32-c3-ard.yaml | 15 +- .../components/vl53l0x/test.esp32-c3-idf.yaml | 15 +- tests/components/vl53l0x/test.esp32-idf.yaml | 15 +- .../components/vl53l0x/test.esp8266-ard.yaml | 15 +- tests/components/vl53l0x/test.rp2040-ard.yaml | 15 +- tests/components/voice_assistant/common.yaml | 57 +++++ .../voice_assistant/test.esp32-ard.yaml | 63 +----- .../voice_assistant/test.esp32-c3-ard.yaml | 62 +---- .../voice_assistant/test.esp32-c3-idf.yaml | 62 +---- .../voice_assistant/test.esp32-idf.yaml | 62 +---- tests/components/waveshare_epaper/common.yaml | 190 ++++++++++++++++ .../waveshare_epaper/test.esp32-ard.yaml | 214 +----------------- .../waveshare_epaper/test.esp32-c3-ard.yaml | 130 +---------- .../waveshare_epaper/test.esp32-c3-idf.yaml | 130 +---------- .../waveshare_epaper/test.esp32-idf.yaml | 130 +---------- .../waveshare_epaper/test.esp8266-ard.yaml | 130 +---------- .../waveshare_epaper/test.rp2040-ard.yaml | 130 +---------- tests/components/whirlpool/common.yaml | 7 + .../components/whirlpool/test.esp32-ard.yaml | 9 +- .../whirlpool/test.esp32-c3-ard.yaml | 9 +- .../whirlpool/test.esp32-c3-idf.yaml | 9 +- .../components/whirlpool/test.esp32-idf.yaml | 9 +- .../whirlpool/test.esp8266-ard.yaml | 9 +- tests/components/whynter/common.yaml | 7 + tests/components/whynter/test.esp32-ard.yaml | 9 +- .../components/whynter/test.esp32-c3-ard.yaml | 9 +- .../components/whynter/test.esp32-c3-idf.yaml | 9 +- tests/components/whynter/test.esp32-idf.yaml | 9 +- .../components/whynter/test.esp8266-ard.yaml | 9 +- tests/components/wl_134/common.yaml | 10 + tests/components/wl_134/test.esp32-ard.yaml | 13 +- .../components/wl_134/test.esp32-c3-ard.yaml | 13 +- .../components/wl_134/test.esp32-c3-idf.yaml | 13 +- tests/components/wl_134/test.esp32-idf.yaml | 13 +- tests/components/wl_134/test.esp8266-ard.yaml | 13 +- tests/components/wl_134/test.rp2040-ard.yaml | 13 +- tests/components/x9c/common.yaml | 8 + tests/components/x9c/test.esp32-ard.yaml | 14 +- tests/components/x9c/test.esp32-c3-ard.yaml | 14 +- tests/components/x9c/test.esp32-c3-idf.yaml | 14 +- tests/components/x9c/test.esp32-idf.yaml | 14 +- tests/components/x9c/test.esp8266-ard.yaml | 14 +- tests/components/x9c/test.rp2040-ard.yaml | 14 +- tests/components/xgzp68xx/common.yaml | 12 + tests/components/xgzp68xx/test.esp32-ard.yaml | 15 +- .../xgzp68xx/test.esp32-c3-ard.yaml | 15 +- .../xgzp68xx/test.esp32-c3-idf.yaml | 15 +- tests/components/xgzp68xx/test.esp32-idf.yaml | 15 +- .../components/xgzp68xx/test.esp8266-ard.yaml | 15 +- .../components/xgzp68xx/test.rp2040-ard.yaml | 15 +- tests/components/xl9535/common.yaml | 26 +++ tests/components/xl9535/test.esp32-ard.yaml | 29 +-- .../components/xl9535/test.esp32-c3-ard.yaml | 29 +-- .../components/xl9535/test.esp32-c3-idf.yaml | 29 +-- tests/components/xl9535/test.esp32-idf.yaml | 29 +-- tests/components/xl9535/test.esp8266-ard.yaml | 29 +-- tests/components/xl9535/test.rp2040-ard.yaml | 29 +-- tests/components/xpt2046/common.yaml | 35 +++ tests/components/xpt2046/test.esp32-ard.yaml | 44 +--- .../components/xpt2046/test.esp32-c3-ard.yaml | 44 +--- .../components/xpt2046/test.esp32-c3-idf.yaml | 44 +--- tests/components/xpt2046/test.esp32-idf.yaml | 44 +--- .../components/xpt2046/test.esp32-s2-ard.yaml | 38 ---- .../components/xpt2046/test.esp8266-ard.yaml | 44 +--- tests/components/xpt2046/test.rp2040-ard.yaml | 44 +--- tests/components/yashima/common.yaml | 7 + tests/components/yashima/test.esp32-ard.yaml | 9 +- .../components/yashima/test.esp32-c3-ard.yaml | 9 +- .../components/yashima/test.esp32-c3-idf.yaml | 9 +- tests/components/yashima/test.esp32-idf.yaml | 9 +- .../components/yashima/test.esp8266-ard.yaml | 9 +- tests/components/zhlt01/common.yaml | 7 + tests/components/zhlt01/test.esp32-ard.yaml | 9 +- .../components/zhlt01/test.esp32-c3-ard.yaml | 9 +- .../components/zhlt01/test.esp32-c3-idf.yaml | 9 +- tests/components/zhlt01/test.esp32-idf.yaml | 9 +- tests/components/zhlt01/test.esp8266-ard.yaml | 9 +- tests/components/zio_ultrasonic/common.yaml | 9 + .../zio_ultrasonic/test.esp32-ard.yaml | 12 +- .../zio_ultrasonic/test.esp32-c3-ard.yaml | 12 +- .../zio_ultrasonic/test.esp32-c3-idf.yaml | 12 +- .../zio_ultrasonic/test.esp32-idf.yaml | 12 +- .../zio_ultrasonic/test.esp8266-ard.yaml | 12 +- .../zio_ultrasonic/test.rp2040-ard.yaml | 12 +- tests/components/zyaura/common.yaml | 10 + tests/components/zyaura/test.esp32-ard.yaml | 15 +- .../components/zyaura/test.esp32-c3-ard.yaml | 15 +- .../components/zyaura/test.esp32-c3-idf.yaml | 15 +- tests/components/zyaura/test.esp32-idf.yaml | 15 +- tests/components/zyaura/test.esp8266-ard.yaml | 15 +- tests/components/zyaura/test.rp2040-ard.yaml | 15 +- 135 files changed, 1070 insertions(+), 2701 deletions(-) create mode 100644 tests/components/ufire_ec/common.yaml create mode 100644 tests/components/ufire_ise/common.yaml create mode 100644 tests/components/uln2003/common.yaml create mode 100644 tests/components/vbus/common.yaml create mode 100644 tests/components/veml3235/common.yaml create mode 100644 tests/components/vl53l0x/common.yaml create mode 100644 tests/components/voice_assistant/common.yaml create mode 100644 tests/components/waveshare_epaper/common.yaml create mode 100644 tests/components/whirlpool/common.yaml create mode 100644 tests/components/whynter/common.yaml create mode 100644 tests/components/wl_134/common.yaml create mode 100644 tests/components/x9c/common.yaml create mode 100644 tests/components/xgzp68xx/common.yaml create mode 100644 tests/components/xl9535/common.yaml create mode 100644 tests/components/xpt2046/common.yaml delete mode 100644 tests/components/xpt2046/test.esp32-s2-ard.yaml create mode 100644 tests/components/yashima/common.yaml create mode 100644 tests/components/zhlt01/common.yaml create mode 100644 tests/components/zio_ultrasonic/common.yaml create mode 100644 tests/components/zyaura/common.yaml diff --git a/tests/components/ufire_ec/common.yaml b/tests/components/ufire_ec/common.yaml new file mode 100644 index 0000000000..dcc957aaee --- /dev/null +++ b/tests/components/ufire_ec/common.yaml @@ -0,0 +1,25 @@ +esphome: + on_boot: + then: + - ufire_ec.calibrate_probe: + id: ufire_ec_board + solution: 0.146 + temperature: !lambda "return id(test_sensor).state;" + - ufire_ec.reset: + +i2c: + - id: i2c_ufire_ec + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: template + id: test_sensor + lambda: "return 21;" + - platform: ufire_ec + id: ufire_ec_board + ec: + name: Ufire EC + temperature_sensor: test_sensor + temperature_compensation: 20.0 + temperature_coefficient: 0.019 diff --git a/tests/components/ufire_ec/test.esp32-ard.yaml b/tests/components/ufire_ec/test.esp32-ard.yaml index 5e6a0daa9e..63c3bd6afd 100644 --- a/tests/components/ufire_ec/test.esp32-ard.yaml +++ b/tests/components/ufire_ec/test.esp32-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_ufire_ec - scl: 16 - sda: 17 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ec/test.esp32-c3-ard.yaml b/tests/components/ufire_ec/test.esp32-c3-ard.yaml index aa72c992b8..ee2c29ca4e 100644 --- a/tests/components/ufire_ec/test.esp32-c3-ard.yaml +++ b/tests/components/ufire_ec/test.esp32-c3-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ec - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ec/test.esp32-c3-idf.yaml b/tests/components/ufire_ec/test.esp32-c3-idf.yaml index aa72c992b8..ee2c29ca4e 100644 --- a/tests/components/ufire_ec/test.esp32-c3-idf.yaml +++ b/tests/components/ufire_ec/test.esp32-c3-idf.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ec - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ec/test.esp32-idf.yaml b/tests/components/ufire_ec/test.esp32-idf.yaml index 5e6a0daa9e..63c3bd6afd 100644 --- a/tests/components/ufire_ec/test.esp32-idf.yaml +++ b/tests/components/ufire_ec/test.esp32-idf.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_ufire_ec - scl: 16 - sda: 17 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ec/test.esp8266-ard.yaml b/tests/components/ufire_ec/test.esp8266-ard.yaml index aa72c992b8..ee2c29ca4e 100644 --- a/tests/components/ufire_ec/test.esp8266-ard.yaml +++ b/tests/components/ufire_ec/test.esp8266-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ec - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ec/test.rp2040-ard.yaml b/tests/components/ufire_ec/test.rp2040-ard.yaml index aa72c992b8..ee2c29ca4e 100644 --- a/tests/components/ufire_ec/test.rp2040-ard.yaml +++ b/tests/components/ufire_ec/test.rp2040-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ec - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ise/common.yaml b/tests/components/ufire_ise/common.yaml new file mode 100644 index 0000000000..d6ead8c479 --- /dev/null +++ b/tests/components/ufire_ise/common.yaml @@ -0,0 +1,25 @@ +esphome: + on_boot: + then: + - ufire_ise.calibrate_probe_high: + id: ufire_ise_sensor + solution: 7.0 + - ufire_ise.calibrate_probe_low: + id: ufire_ise_sensor + solution: 4.0 + - ufire_ise.reset: + +i2c: + - id: i2c_ufire_ise + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: template + id: test_sensor + lambda: "return 21;" + - platform: ufire_ise + id: ufire_ise_sensor + temperature_sensor: test_sensor + ph: + name: Ufire pH diff --git a/tests/components/ufire_ise/test.esp32-ard.yaml b/tests/components/ufire_ise/test.esp32-ard.yaml index 9ed0ac433a..63c3bd6afd 100644 --- a/tests/components/ufire_ise/test.esp32-ard.yaml +++ b/tests/components/ufire_ise/test.esp32-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_ufire_ise - scl: 16 - sda: 17 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/ufire_ise/test.esp32-c3-ard.yaml b/tests/components/ufire_ise/test.esp32-c3-ard.yaml index 36aec73113..ee2c29ca4e 100644 --- a/tests/components/ufire_ise/test.esp32-c3-ard.yaml +++ b/tests/components/ufire_ise/test.esp32-c3-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ise - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/ufire_ise/test.esp32-c3-idf.yaml b/tests/components/ufire_ise/test.esp32-c3-idf.yaml index 36aec73113..ee2c29ca4e 100644 --- a/tests/components/ufire_ise/test.esp32-c3-idf.yaml +++ b/tests/components/ufire_ise/test.esp32-c3-idf.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ise - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/ufire_ise/test.esp32-idf.yaml b/tests/components/ufire_ise/test.esp32-idf.yaml index 9ed0ac433a..63c3bd6afd 100644 --- a/tests/components/ufire_ise/test.esp32-idf.yaml +++ b/tests/components/ufire_ise/test.esp32-idf.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_ufire_ise - scl: 16 - sda: 17 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/ufire_ise/test.esp8266-ard.yaml b/tests/components/ufire_ise/test.esp8266-ard.yaml index 36aec73113..ee2c29ca4e 100644 --- a/tests/components/ufire_ise/test.esp8266-ard.yaml +++ b/tests/components/ufire_ise/test.esp8266-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ise - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/ufire_ise/test.rp2040-ard.yaml b/tests/components/ufire_ise/test.rp2040-ard.yaml index 36aec73113..ee2c29ca4e 100644 --- a/tests/components/ufire_ise/test.rp2040-ard.yaml +++ b/tests/components/ufire_ise/test.rp2040-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ise - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/uln2003/common.yaml b/tests/components/uln2003/common.yaml new file mode 100644 index 0000000000..f848030592 --- /dev/null +++ b/tests/components/uln2003/common.yaml @@ -0,0 +1,29 @@ +esphome: + on_boot: + then: + - stepper.report_position: + id: uln2003_stepper + position: 250 + - stepper.set_target: + id: uln2003_stepper + target: 250 + - stepper.set_acceleration: + id: uln2003_stepper + acceleration: 250 steps/s^2 + - stepper.set_deceleration: + id: uln2003_stepper + deceleration: 250 steps/s^2 + - stepper.set_speed: + id: uln2003_stepper + speed: 250 steps/s + +stepper: + - platform: uln2003 + id: uln2003_stepper + pin_a: ${pin_a} + pin_b: ${pin_b} + pin_c: ${pin_c} + pin_d: ${pin_d} + max_speed: 250 steps/s + acceleration: 100 steps/s^2 + deceleration: 200 steps/s^2 diff --git a/tests/components/uln2003/test.esp32-ard.yaml b/tests/components/uln2003/test.esp32-ard.yaml index 61a6e94396..ee4cff0923 100644 --- a/tests/components/uln2003/test.esp32-ard.yaml +++ b/tests/components/uln2003/test.esp32-ard.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO12 + pin_b: GPIO13 + pin_c: GPIO14 + pin_d: GPIO15 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 12 - pin_b: 13 - pin_c: 14 - pin_d: 15 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/uln2003/test.esp32-c3-ard.yaml b/tests/components/uln2003/test.esp32-c3-ard.yaml index 2d19d4dba3..11d16a4d5d 100644 --- a/tests/components/uln2003/test.esp32-c3-ard.yaml +++ b/tests/components/uln2003/test.esp32-c3-ard.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO0 + pin_b: GPIO1 + pin_c: GPIO2 + pin_d: GPIO3 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 0 - pin_b: 1 - pin_c: 2 - pin_d: 3 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/uln2003/test.esp32-c3-idf.yaml b/tests/components/uln2003/test.esp32-c3-idf.yaml index 2d19d4dba3..11d16a4d5d 100644 --- a/tests/components/uln2003/test.esp32-c3-idf.yaml +++ b/tests/components/uln2003/test.esp32-c3-idf.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO0 + pin_b: GPIO1 + pin_c: GPIO2 + pin_d: GPIO3 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 0 - pin_b: 1 - pin_c: 2 - pin_d: 3 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/uln2003/test.esp32-idf.yaml b/tests/components/uln2003/test.esp32-idf.yaml index 61a6e94396..ee4cff0923 100644 --- a/tests/components/uln2003/test.esp32-idf.yaml +++ b/tests/components/uln2003/test.esp32-idf.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO12 + pin_b: GPIO13 + pin_c: GPIO14 + pin_d: GPIO15 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 12 - pin_b: 13 - pin_c: 14 - pin_d: 15 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/uln2003/test.esp8266-ard.yaml b/tests/components/uln2003/test.esp8266-ard.yaml index 61a6e94396..ee4cff0923 100644 --- a/tests/components/uln2003/test.esp8266-ard.yaml +++ b/tests/components/uln2003/test.esp8266-ard.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO12 + pin_b: GPIO13 + pin_c: GPIO14 + pin_d: GPIO15 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 12 - pin_b: 13 - pin_c: 14 - pin_d: 15 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/uln2003/test.rp2040-ard.yaml b/tests/components/uln2003/test.rp2040-ard.yaml index 2d19d4dba3..11d16a4d5d 100644 --- a/tests/components/uln2003/test.rp2040-ard.yaml +++ b/tests/components/uln2003/test.rp2040-ard.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO0 + pin_b: GPIO1 + pin_c: GPIO2 + pin_d: GPIO3 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 0 - pin_b: 1 - pin_c: 2 - pin_d: 3 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/vbus/common.yaml b/tests/components/vbus/common.yaml new file mode 100644 index 0000000000..a1f94cd839 --- /dev/null +++ b/tests/components/vbus/common.yaml @@ -0,0 +1,42 @@ +uart: + - id: uart_vbus + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +vbus: + +binary_sensor: + - platform: vbus + model: deltasol_bs_plus + relay1: + name: Relay 1 On + relay2: + name: Relay 2 On + sensor1_error: + name: Sensor 1 Error + - platform: vbus + model: custom + command: 0x100 + source: 0x1234 + dest: 0x10 + binary_sensors: + - id: vcustom_b + name: VBus Custom Binary Sensor + lambda: return x[0] & 1; + +sensor: + - platform: vbus + model: deltasol c + temperature_1: + name: Temperature 1 + temperature_2: + name: Temperature 2 + temperature_3: + name: Temperature 3 + operating_hours_1: + name: Operating Hours 1 + heat_quantity: + name: Heat Quantity + time: + name: System Time diff --git a/tests/components/vbus/test.esp32-ard.yaml b/tests/components/vbus/test.esp32-ard.yaml index a0e5ca42cc..f486544afa 100644 --- a/tests/components/vbus/test.esp32-ard.yaml +++ b/tests/components/vbus/test.esp32-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/vbus/test.esp32-c3-ard.yaml b/tests/components/vbus/test.esp32-c3-ard.yaml index 67ee542031..b516342f3b 100644 --- a/tests/components/vbus/test.esp32-c3-ard.yaml +++ b/tests/components/vbus/test.esp32-c3-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/vbus/test.esp32-c3-idf.yaml b/tests/components/vbus/test.esp32-c3-idf.yaml index 67ee542031..b516342f3b 100644 --- a/tests/components/vbus/test.esp32-c3-idf.yaml +++ b/tests/components/vbus/test.esp32-c3-idf.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/vbus/test.esp32-idf.yaml b/tests/components/vbus/test.esp32-idf.yaml index a0e5ca42cc..f486544afa 100644 --- a/tests/components/vbus/test.esp32-idf.yaml +++ b/tests/components/vbus/test.esp32-idf.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/vbus/test.esp8266-ard.yaml b/tests/components/vbus/test.esp8266-ard.yaml index 67ee542031..b516342f3b 100644 --- a/tests/components/vbus/test.esp8266-ard.yaml +++ b/tests/components/vbus/test.esp8266-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/vbus/test.rp2040-ard.yaml b/tests/components/vbus/test.rp2040-ard.yaml index 67ee542031..b516342f3b 100644 --- a/tests/components/vbus/test.rp2040-ard.yaml +++ b/tests/components/vbus/test.rp2040-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/veml3235/common.yaml b/tests/components/veml3235/common.yaml new file mode 100644 index 0000000000..b89a9e12c7 --- /dev/null +++ b/tests/components/veml3235/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_veml3235 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: veml3235 + id: veml3235_sensor + name: VEML3235 Light Sensor + auto_gain: true + auto_gain_threshold_high: 90% + auto_gain_threshold_low: 15% + digital_gain: 1X + gain: 1X + integration_time: 50ms diff --git a/tests/components/veml3235/test.esp32-ard.yaml b/tests/components/veml3235/test.esp32-ard.yaml index 3442fa4317..63c3bd6afd 100644 --- a/tests/components/veml3235/test.esp32-ard.yaml +++ b/tests/components/veml3235/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml3235/test.esp32-c3-ard.yaml b/tests/components/veml3235/test.esp32-c3-ard.yaml index 1f79c5f50c..ee2c29ca4e 100644 --- a/tests/components/veml3235/test.esp32-c3-ard.yaml +++ b/tests/components/veml3235/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml3235/test.esp32-c3-idf.yaml b/tests/components/veml3235/test.esp32-c3-idf.yaml index 1f79c5f50c..ee2c29ca4e 100644 --- a/tests/components/veml3235/test.esp32-c3-idf.yaml +++ b/tests/components/veml3235/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml3235/test.esp32-idf.yaml b/tests/components/veml3235/test.esp32-idf.yaml index 3442fa4317..63c3bd6afd 100644 --- a/tests/components/veml3235/test.esp32-idf.yaml +++ b/tests/components/veml3235/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml3235/test.esp8266-ard.yaml b/tests/components/veml3235/test.esp8266-ard.yaml index 1f79c5f50c..ee2c29ca4e 100644 --- a/tests/components/veml3235/test.esp8266-ard.yaml +++ b/tests/components/veml3235/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml3235/test.rp2040-ard.yaml b/tests/components/veml3235/test.rp2040-ard.yaml index 1f79c5f50c..ee2c29ca4e 100644 --- a/tests/components/veml3235/test.rp2040-ard.yaml +++ b/tests/components/veml3235/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml7700/common.yaml b/tests/components/veml7700/common.yaml index 6620c8d7e1..af4ebee6e7 100644 --- a/tests/components/veml7700/common.yaml +++ b/tests/components/veml7700/common.yaml @@ -1,3 +1,8 @@ +i2c: + - id: i2c_veml7700 + scl: ${scl_pin} + sda: ${sda_pin} + sensor: - platform: veml7700 address: 0x10 diff --git a/tests/components/veml7700/test.esp32-ard.yaml b/tests/components/veml7700/test.esp32-ard.yaml index 4b812a1392..63c3bd6afd 100644 --- a/tests/components/veml7700/test.esp32-ard.yaml +++ b/tests/components/veml7700/test.esp32-ard.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 <<: !include common.yaml diff --git a/tests/components/veml7700/test.esp32-c3-ard.yaml b/tests/components/veml7700/test.esp32-c3-ard.yaml index ce0fa0125b..ee2c29ca4e 100644 --- a/tests/components/veml7700/test.esp32-c3-ard.yaml +++ b/tests/components/veml7700/test.esp32-c3-ard.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/veml7700/test.esp32-c3-idf.yaml b/tests/components/veml7700/test.esp32-c3-idf.yaml index ce0fa0125b..ee2c29ca4e 100644 --- a/tests/components/veml7700/test.esp32-c3-idf.yaml +++ b/tests/components/veml7700/test.esp32-c3-idf.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/veml7700/test.esp32-idf.yaml b/tests/components/veml7700/test.esp32-idf.yaml index 4b812a1392..63c3bd6afd 100644 --- a/tests/components/veml7700/test.esp32-idf.yaml +++ b/tests/components/veml7700/test.esp32-idf.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 <<: !include common.yaml diff --git a/tests/components/veml7700/test.esp8266-ard.yaml b/tests/components/veml7700/test.esp8266-ard.yaml index ce0fa0125b..ee2c29ca4e 100644 --- a/tests/components/veml7700/test.esp8266-ard.yaml +++ b/tests/components/veml7700/test.esp8266-ard.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/veml7700/test.rp2040-ard.yaml b/tests/components/veml7700/test.rp2040-ard.yaml index ce0fa0125b..ee2c29ca4e 100644 --- a/tests/components/veml7700/test.rp2040-ard.yaml +++ b/tests/components/veml7700/test.rp2040-ard.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/vl53l0x/common.yaml b/tests/components/vl53l0x/common.yaml new file mode 100644 index 0000000000..973e481b1a --- /dev/null +++ b/tests/components/vl53l0x/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_vl53l0x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: vl53l0x + name: VL53L0x Distance + address: 0x29 + enable_pin: 3 + timeout: 200us + update_interval: 60s diff --git a/tests/components/vl53l0x/test.esp32-ard.yaml b/tests/components/vl53l0x/test.esp32-ard.yaml index 8f35de0e72..63c3bd6afd 100644 --- a/tests/components/vl53l0x/test.esp32-ard.yaml +++ b/tests/components/vl53l0x/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/vl53l0x/test.esp32-c3-ard.yaml b/tests/components/vl53l0x/test.esp32-c3-ard.yaml index 832f7dcfbc..ee2c29ca4e 100644 --- a/tests/components/vl53l0x/test.esp32-c3-ard.yaml +++ b/tests/components/vl53l0x/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/vl53l0x/test.esp32-c3-idf.yaml b/tests/components/vl53l0x/test.esp32-c3-idf.yaml index 832f7dcfbc..ee2c29ca4e 100644 --- a/tests/components/vl53l0x/test.esp32-c3-idf.yaml +++ b/tests/components/vl53l0x/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/vl53l0x/test.esp32-idf.yaml b/tests/components/vl53l0x/test.esp32-idf.yaml index 8f35de0e72..63c3bd6afd 100644 --- a/tests/components/vl53l0x/test.esp32-idf.yaml +++ b/tests/components/vl53l0x/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/vl53l0x/test.esp8266-ard.yaml b/tests/components/vl53l0x/test.esp8266-ard.yaml index 832f7dcfbc..ee2c29ca4e 100644 --- a/tests/components/vl53l0x/test.esp8266-ard.yaml +++ b/tests/components/vl53l0x/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/vl53l0x/test.rp2040-ard.yaml b/tests/components/vl53l0x/test.rp2040-ard.yaml index 832f7dcfbc..ee2c29ca4e 100644 --- a/tests/components/vl53l0x/test.rp2040-ard.yaml +++ b/tests/components/vl53l0x/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/voice_assistant/common.yaml b/tests/components/voice_assistant/common.yaml new file mode 100644 index 0000000000..e7374941f7 --- /dev/null +++ b/tests/components/voice_assistant/common.yaml @@ -0,0 +1,57 @@ +esphome: + on_boot: + then: + - voice_assistant.start + - voice_assistant.start_continuous + - voice_assistant.stop + +wifi: + ssid: MySSID + password: password1 + +api: + +i2s_audio: + i2s_lrclk_pin: ${i2s_lrclk_pin} + i2s_bclk_pin: ${i2s_bclk_pin} + i2s_mclk_pin: ${i2s_mclk_pin} + +microphone: + - platform: i2s_audio + id: mic_id_external + i2s_din_pin: ${i2s_din_pin} + adc_type: external + pdm: false + +speaker: + - platform: i2s_audio + id: speaker_id + dac_type: external + i2s_dout_pin: ${i2s_dout_pin} + +voice_assistant: + microphone: mic_id_external + speaker: speaker_id + conversation_timeout: 60s + on_listening: + - logger.log: "Voice assistant microphone listening" + on_start: + - logger.log: "Voice assistant started" + on_stt_end: + - logger.log: + format: "Voice assistant STT ended with result %s" + args: [x.c_str()] + on_tts_start: + - logger.log: + format: "Voice assistant TTS started with text %s" + args: [x.c_str()] + on_tts_end: + - logger.log: + format: "Voice assistant TTS ended with url %s" + args: [x.c_str()] + on_end: + - logger.log: "Voice assistant ended" + on_error: + - logger.log: + format: "Voice assistant error - code %s, message: %s" + args: [code.c_str(), message.c_str()] diff --git a/tests/components/voice_assistant/test.esp32-ard.yaml b/tests/components/voice_assistant/test.esp32-ard.yaml index cbf9460087..f6e553f9dc 100644 --- a/tests/components/voice_assistant/test.esp32-ard.yaml +++ b/tests/components/voice_assistant/test.esp32-ard.yaml @@ -1,57 +1,8 @@ -esphome: - on_boot: - then: - - voice_assistant.start - - voice_assistant.start_continuous - - voice_assistant.stop +substitutions: + i2s_lrclk_pin: GPIO16 + i2s_bclk_pin: GPIO17 + i2s_mclk_pin: GPIO15 + i2s_din_pin: GPIO13 + i2s_dout_pin: GPIO12 -wifi: - ssid: MySSID - password: password1 - -api: - -i2s_audio: - i2s_lrclk_pin: 16 - i2s_bclk_pin: 17 - i2s_mclk_pin: 15 - -microphone: - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 13 - adc_type: external - pdm: false - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 12 - -voice_assistant: - microphone: mic_id_external - speaker: speaker_id - conversation_timeout: 60s - on_listening: - - logger.log: "Voice assistant microphone listening" - on_start: - - logger.log: "Voice assistant started" - on_stt_end: - - logger.log: - format: "Voice assistant STT ended with result %s" - args: [x.c_str()] - on_tts_start: - - logger.log: - format: "Voice assistant TTS started with text %s" - args: [x.c_str()] - on_tts_end: - - logger.log: - format: "Voice assistant TTS ended with url %s" - args: [x.c_str()] - on_end: - - logger.log: "Voice assistant ended" - on_error: - - logger.log: - format: "Voice assistant error - code %s, message: %s" - args: [code.c_str(), message.c_str()] +<<: !include common.yaml diff --git a/tests/components/voice_assistant/test.esp32-c3-ard.yaml b/tests/components/voice_assistant/test.esp32-c3-ard.yaml index 86357fad36..f596d927cb 100644 --- a/tests/components/voice_assistant/test.esp32-c3-ard.yaml +++ b/tests/components/voice_assistant/test.esp32-c3-ard.yaml @@ -1,56 +1,8 @@ -esphome: - on_boot: - then: - - voice_assistant.start - - voice_assistant.start_continuous - - voice_assistant.stop +substitutions: + i2s_lrclk_pin: GPIO6 + i2s_bclk_pin: GPIO7 + i2s_mclk_pin: GPIO5 + i2s_din_pin: GPIO3 + i2s_dout_pin: GPIO2 -wifi: - ssid: MySSID - password: password1 - -api: - -i2s_audio: - i2s_lrclk_pin: 6 - i2s_bclk_pin: 7 - i2s_mclk_pin: 5 - -microphone: - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 3 - adc_type: external - pdm: false - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 2 - -voice_assistant: - microphone: mic_id_external - speaker: speaker_id - on_listening: - - logger.log: "Voice assistant microphone listening" - on_start: - - logger.log: "Voice assistant started" - on_stt_end: - - logger.log: - format: "Voice assistant STT ended with result %s" - args: [x.c_str()] - on_tts_start: - - logger.log: - format: "Voice assistant TTS started with text %s" - args: [x.c_str()] - on_tts_end: - - logger.log: - format: "Voice assistant TTS ended with url %s" - args: [x.c_str()] - on_end: - - logger.log: "Voice assistant ended" - on_error: - - logger.log: - format: "Voice assistant error - code %s, message: %s" - args: [code.c_str(), message.c_str()] +<<: !include common.yaml diff --git a/tests/components/voice_assistant/test.esp32-c3-idf.yaml b/tests/components/voice_assistant/test.esp32-c3-idf.yaml index 86357fad36..f596d927cb 100644 --- a/tests/components/voice_assistant/test.esp32-c3-idf.yaml +++ b/tests/components/voice_assistant/test.esp32-c3-idf.yaml @@ -1,56 +1,8 @@ -esphome: - on_boot: - then: - - voice_assistant.start - - voice_assistant.start_continuous - - voice_assistant.stop +substitutions: + i2s_lrclk_pin: GPIO6 + i2s_bclk_pin: GPIO7 + i2s_mclk_pin: GPIO5 + i2s_din_pin: GPIO3 + i2s_dout_pin: GPIO2 -wifi: - ssid: MySSID - password: password1 - -api: - -i2s_audio: - i2s_lrclk_pin: 6 - i2s_bclk_pin: 7 - i2s_mclk_pin: 5 - -microphone: - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 3 - adc_type: external - pdm: false - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 2 - -voice_assistant: - microphone: mic_id_external - speaker: speaker_id - on_listening: - - logger.log: "Voice assistant microphone listening" - on_start: - - logger.log: "Voice assistant started" - on_stt_end: - - logger.log: - format: "Voice assistant STT ended with result %s" - args: [x.c_str()] - on_tts_start: - - logger.log: - format: "Voice assistant TTS started with text %s" - args: [x.c_str()] - on_tts_end: - - logger.log: - format: "Voice assistant TTS ended with url %s" - args: [x.c_str()] - on_end: - - logger.log: "Voice assistant ended" - on_error: - - logger.log: - format: "Voice assistant error - code %s, message: %s" - args: [code.c_str(), message.c_str()] +<<: !include common.yaml diff --git a/tests/components/voice_assistant/test.esp32-idf.yaml b/tests/components/voice_assistant/test.esp32-idf.yaml index da9b50721f..f6e553f9dc 100644 --- a/tests/components/voice_assistant/test.esp32-idf.yaml +++ b/tests/components/voice_assistant/test.esp32-idf.yaml @@ -1,56 +1,8 @@ -esphome: - on_boot: - then: - - voice_assistant.start - - voice_assistant.start_continuous - - voice_assistant.stop +substitutions: + i2s_lrclk_pin: GPIO16 + i2s_bclk_pin: GPIO17 + i2s_mclk_pin: GPIO15 + i2s_din_pin: GPIO13 + i2s_dout_pin: GPIO12 -wifi: - ssid: MySSID - password: password1 - -api: - -i2s_audio: - i2s_lrclk_pin: 16 - i2s_bclk_pin: 17 - i2s_mclk_pin: 15 - -microphone: - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 13 - adc_type: external - pdm: false - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 12 - -voice_assistant: - microphone: mic_id_external - speaker: speaker_id - on_listening: - - logger.log: "Voice assistant microphone listening" - on_start: - - logger.log: "Voice assistant started" - on_stt_end: - - logger.log: - format: "Voice assistant STT ended with result %s" - args: [x.c_str()] - on_tts_start: - - logger.log: - format: "Voice assistant TTS started with text %s" - args: [x.c_str()] - on_tts_end: - - logger.log: - format: "Voice assistant TTS ended with url %s" - args: [x.c_str()] - on_end: - - logger.log: "Voice assistant ended" - on_error: - - logger.log: - format: "Voice assistant error - code %s, message: %s" - args: [code.c_str(), message.c_str()] +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml new file mode 100644 index 0000000000..92c443908e --- /dev/null +++ b/tests/components/waveshare_epaper/common.yaml @@ -0,0 +1,190 @@ +spi: + - id: spi_waveshare_epaper + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: waveshare_epaper + model: 2.13in-ttgo-b1 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.13in-ttgo-b74 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.90in + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + reset_duration: 200ms + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.90inv2 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.90in-dke + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.70in-b + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.70in-bv2 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 1.54in-m5coreink-m09 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.13inv3 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.13inv2 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 7.50in-bv3-bwr + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); diff --git a/tests/components/waveshare_epaper/test.esp32-ard.yaml b/tests/components/waveshare_epaper/test.esp32-ard.yaml index 944f98a1e9..c658ea91ee 100644 --- a/tests/components/waveshare_epaper/test.esp32-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp32-ard.yaml @@ -1,207 +1,9 @@ ---- -spi: - - id: spi_id_1 - clk_pin: - number: GPIO18 - mosi_pin: - number: GPIO23 - miso_pin: - number: GPIO19 - interface: hardware +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO18 + dc_pin: GPIO19 + busy_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: waveshare_epaper - model: 2.13in-ttgo-b1 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.13in-ttgo-b74 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.90in - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.90inv2 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.90in-dke - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.70in-b - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.70in-bv2 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 1.54in-m5coreink-m09 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.13inv3 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.13inv2 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 7.50in-bv3-bwr - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml b/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml index 5d651bd180..e2873f0fe9 100644 --- a/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml @@ -1,123 +1,9 @@ -spi: - - id: spi_waveshare_epaper - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + cs_pin: GPIO0 + dc_pin: GPIO5 + busy_pin: GPIO3 + reset_pin: GPIO4 -display: - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.13in-ttgo-b1 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90in - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90inv2 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-b - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-bv2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 1.54in-m5coreink-m09 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 7.50in-bv3-bwr - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml b/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml index 5d651bd180..e2873f0fe9 100644 --- a/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml +++ b/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml @@ -1,123 +1,9 @@ -spi: - - id: spi_waveshare_epaper - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + cs_pin: GPIO0 + dc_pin: GPIO5 + busy_pin: GPIO3 + reset_pin: GPIO4 -display: - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.13in-ttgo-b1 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90in - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90inv2 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-b - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-bv2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 1.54in-m5coreink-m09 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 7.50in-bv3-bwr - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-idf.yaml b/tests/components/waveshare_epaper/test.esp32-idf.yaml index 47f894d967..c658ea91ee 100644 --- a/tests/components/waveshare_epaper/test.esp32-idf.yaml +++ b/tests/components/waveshare_epaper/test.esp32-idf.yaml @@ -1,123 +1,9 @@ -spi: - - id: spi_bme280 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO18 + dc_pin: GPIO19 + busy_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.13in-ttgo-b1 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90in - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90inv2 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-b - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-bv2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 1.54in-m5coreink-m09 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 7.50in-bv3-bwr - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp8266-ard.yaml b/tests/components/waveshare_epaper/test.esp8266-ard.yaml index ceda328598..bc178b7009 100644 --- a/tests/components/waveshare_epaper/test.esp8266-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp8266-ard.yaml @@ -1,123 +1,9 @@ -spi: - - id: spi_bme280 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + cs_pin: GPIO15 + dc_pin: GPIO12 + busy_pin: GPIO5 + reset_pin: GPIO4 -display: - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.13in-ttgo-b1 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90in - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90inv2 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-b - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-bv2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 1.54in-m5coreink-m09 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 7.50in-bv3-bwr - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.rp2040-ard.yaml b/tests/components/waveshare_epaper/test.rp2040-ard.yaml index be7e780033..801b0b51c5 100644 --- a/tests/components/waveshare_epaper/test.rp2040-ard.yaml +++ b/tests/components/waveshare_epaper/test.rp2040-ard.yaml @@ -1,123 +1,9 @@ -spi: - - id: spi_bme280 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + cs_pin: GPIO5 + dc_pin: GPIO4 + busy_pin: GPIO0 + reset_pin: GPIO1 -display: - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 2.13in-ttgo-b1 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 2.90in - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 2.90inv2 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 2.70in-b - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 2.70in-bv2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 1.54in-m5coreink-m09 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 7.50in-bv3-bwr - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/whirlpool/common.yaml b/tests/components/whirlpool/common.yaml new file mode 100644 index 0000000000..804c1aac26 --- /dev/null +++ b/tests/components/whirlpool/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: whirlpool + name: Whirlpool Climate diff --git a/tests/components/whirlpool/test.esp32-ard.yaml b/tests/components/whirlpool/test.esp32-ard.yaml index 4d0afc39a4..7b012aa64c 100644 --- a/tests/components/whirlpool/test.esp32-ard.yaml +++ b/tests/components/whirlpool/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whirlpool - name: Whirlpool Climate +<<: !include common.yaml diff --git a/tests/components/whirlpool/test.esp32-c3-ard.yaml b/tests/components/whirlpool/test.esp32-c3-ard.yaml index 4d0afc39a4..7b012aa64c 100644 --- a/tests/components/whirlpool/test.esp32-c3-ard.yaml +++ b/tests/components/whirlpool/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whirlpool - name: Whirlpool Climate +<<: !include common.yaml diff --git a/tests/components/whirlpool/test.esp32-c3-idf.yaml b/tests/components/whirlpool/test.esp32-c3-idf.yaml index 4d0afc39a4..7b012aa64c 100644 --- a/tests/components/whirlpool/test.esp32-c3-idf.yaml +++ b/tests/components/whirlpool/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whirlpool - name: Whirlpool Climate +<<: !include common.yaml diff --git a/tests/components/whirlpool/test.esp32-idf.yaml b/tests/components/whirlpool/test.esp32-idf.yaml index 4d0afc39a4..7b012aa64c 100644 --- a/tests/components/whirlpool/test.esp32-idf.yaml +++ b/tests/components/whirlpool/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whirlpool - name: Whirlpool Climate +<<: !include common.yaml diff --git a/tests/components/whirlpool/test.esp8266-ard.yaml b/tests/components/whirlpool/test.esp8266-ard.yaml index efd530c160..f5097fcf5f 100644 --- a/tests/components/whirlpool/test.esp8266-ard.yaml +++ b/tests/components/whirlpool/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: whirlpool - name: Whirlpool Climate +<<: !include common.yaml diff --git a/tests/components/whynter/common.yaml b/tests/components/whynter/common.yaml new file mode 100644 index 0000000000..04ad6bed54 --- /dev/null +++ b/tests/components/whynter/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: whynter + name: Whynter Climate diff --git a/tests/components/whynter/test.esp32-ard.yaml b/tests/components/whynter/test.esp32-ard.yaml index dc8fb9584d..7b012aa64c 100644 --- a/tests/components/whynter/test.esp32-ard.yaml +++ b/tests/components/whynter/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whynter - name: Whynter Climate +<<: !include common.yaml diff --git a/tests/components/whynter/test.esp32-c3-ard.yaml b/tests/components/whynter/test.esp32-c3-ard.yaml index dc8fb9584d..7b012aa64c 100644 --- a/tests/components/whynter/test.esp32-c3-ard.yaml +++ b/tests/components/whynter/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whynter - name: Whynter Climate +<<: !include common.yaml diff --git a/tests/components/whynter/test.esp32-c3-idf.yaml b/tests/components/whynter/test.esp32-c3-idf.yaml index dc8fb9584d..7b012aa64c 100644 --- a/tests/components/whynter/test.esp32-c3-idf.yaml +++ b/tests/components/whynter/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whynter - name: Whynter Climate +<<: !include common.yaml diff --git a/tests/components/whynter/test.esp32-idf.yaml b/tests/components/whynter/test.esp32-idf.yaml index dc8fb9584d..7b012aa64c 100644 --- a/tests/components/whynter/test.esp32-idf.yaml +++ b/tests/components/whynter/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whynter - name: Whynter Climate +<<: !include common.yaml diff --git a/tests/components/whynter/test.esp8266-ard.yaml b/tests/components/whynter/test.esp8266-ard.yaml index a656a7427d..f5097fcf5f 100644 --- a/tests/components/whynter/test.esp8266-ard.yaml +++ b/tests/components/whynter/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: whynter - name: Whynter Climate +<<: !include common.yaml diff --git a/tests/components/wl_134/common.yaml b/tests/components/wl_134/common.yaml new file mode 100644 index 0000000000..71c50be79b --- /dev/null +++ b/tests/components/wl_134/common.yaml @@ -0,0 +1,10 @@ +uart: + - id: uart_wl_134 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +text_sensor: + - platform: wl_134 + name: Transponder Code + reset: true diff --git a/tests/components/wl_134/test.esp32-ard.yaml b/tests/components/wl_134/test.esp32-ard.yaml index d517889d28..f486544afa 100644 --- a/tests/components/wl_134/test.esp32-ard.yaml +++ b/tests/components/wl_134/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/wl_134/test.esp32-c3-ard.yaml b/tests/components/wl_134/test.esp32-c3-ard.yaml index 7cda1ba060..b516342f3b 100644 --- a/tests/components/wl_134/test.esp32-c3-ard.yaml +++ b/tests/components/wl_134/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/wl_134/test.esp32-c3-idf.yaml b/tests/components/wl_134/test.esp32-c3-idf.yaml index 7cda1ba060..b516342f3b 100644 --- a/tests/components/wl_134/test.esp32-c3-idf.yaml +++ b/tests/components/wl_134/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/wl_134/test.esp32-idf.yaml b/tests/components/wl_134/test.esp32-idf.yaml index d517889d28..f486544afa 100644 --- a/tests/components/wl_134/test.esp32-idf.yaml +++ b/tests/components/wl_134/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/wl_134/test.esp8266-ard.yaml b/tests/components/wl_134/test.esp8266-ard.yaml index 7cda1ba060..b516342f3b 100644 --- a/tests/components/wl_134/test.esp8266-ard.yaml +++ b/tests/components/wl_134/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/wl_134/test.rp2040-ard.yaml b/tests/components/wl_134/test.rp2040-ard.yaml index 7cda1ba060..b516342f3b 100644 --- a/tests/components/wl_134/test.rp2040-ard.yaml +++ b/tests/components/wl_134/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/x9c/common.yaml b/tests/components/x9c/common.yaml new file mode 100644 index 0000000000..07713c66c3 --- /dev/null +++ b/tests/components/x9c/common.yaml @@ -0,0 +1,8 @@ +output: + - platform: x9c + id: test_x9c + cs_pin: ${cs_pin} + inc_pin: ${inc_pin} + ud_pin: ${ud_pin} + initial_value: 0.5 + step_delay: 50us diff --git a/tests/components/x9c/test.esp32-ard.yaml b/tests/components/x9c/test.esp32-ard.yaml index f587b69b4f..6dfe3a67eb 100644 --- a/tests/components/x9c/test.esp32-ard.yaml +++ b/tests/components/x9c/test.esp32-ard.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 13 - inc_pin: 14 - ud_pin: 15 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO13 + inc_pin: GPIO14 + ud_pin: GPIO15 + +<<: !include common.yaml diff --git a/tests/components/x9c/test.esp32-c3-ard.yaml b/tests/components/x9c/test.esp32-c3-ard.yaml index 972c743fcd..b06e15a98c 100644 --- a/tests/components/x9c/test.esp32-c3-ard.yaml +++ b/tests/components/x9c/test.esp32-c3-ard.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 3 - inc_pin: 4 - ud_pin: 5 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO3 + inc_pin: GPIO4 + ud_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/x9c/test.esp32-c3-idf.yaml b/tests/components/x9c/test.esp32-c3-idf.yaml index 972c743fcd..b06e15a98c 100644 --- a/tests/components/x9c/test.esp32-c3-idf.yaml +++ b/tests/components/x9c/test.esp32-c3-idf.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 3 - inc_pin: 4 - ud_pin: 5 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO3 + inc_pin: GPIO4 + ud_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/x9c/test.esp32-idf.yaml b/tests/components/x9c/test.esp32-idf.yaml index f587b69b4f..6dfe3a67eb 100644 --- a/tests/components/x9c/test.esp32-idf.yaml +++ b/tests/components/x9c/test.esp32-idf.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 13 - inc_pin: 14 - ud_pin: 15 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO13 + inc_pin: GPIO14 + ud_pin: GPIO15 + +<<: !include common.yaml diff --git a/tests/components/x9c/test.esp8266-ard.yaml b/tests/components/x9c/test.esp8266-ard.yaml index f587b69b4f..6dfe3a67eb 100644 --- a/tests/components/x9c/test.esp8266-ard.yaml +++ b/tests/components/x9c/test.esp8266-ard.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 13 - inc_pin: 14 - ud_pin: 15 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO13 + inc_pin: GPIO14 + ud_pin: GPIO15 + +<<: !include common.yaml diff --git a/tests/components/x9c/test.rp2040-ard.yaml b/tests/components/x9c/test.rp2040-ard.yaml index 972c743fcd..b06e15a98c 100644 --- a/tests/components/x9c/test.rp2040-ard.yaml +++ b/tests/components/x9c/test.rp2040-ard.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 3 - inc_pin: 4 - ud_pin: 5 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO3 + inc_pin: GPIO4 + ud_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/common.yaml b/tests/components/xgzp68xx/common.yaml new file mode 100644 index 0000000000..224dd9ed14 --- /dev/null +++ b/tests/components/xgzp68xx/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_xgzp68xx + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: xgzp68xx + k_value: 4096 + temperature: + name: Pressure Temperature + pressure: + name: Differential pressure diff --git a/tests/components/xgzp68xx/test.esp32-ard.yaml b/tests/components/xgzp68xx/test.esp32-ard.yaml index fb55421123..63c3bd6afd 100644 --- a/tests/components/xgzp68xx/test.esp32-ard.yaml +++ b/tests/components/xgzp68xx/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/test.esp32-c3-ard.yaml b/tests/components/xgzp68xx/test.esp32-c3-ard.yaml index 25df8cc225..ee2c29ca4e 100644 --- a/tests/components/xgzp68xx/test.esp32-c3-ard.yaml +++ b/tests/components/xgzp68xx/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/test.esp32-c3-idf.yaml b/tests/components/xgzp68xx/test.esp32-c3-idf.yaml index 25df8cc225..ee2c29ca4e 100644 --- a/tests/components/xgzp68xx/test.esp32-c3-idf.yaml +++ b/tests/components/xgzp68xx/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/test.esp32-idf.yaml b/tests/components/xgzp68xx/test.esp32-idf.yaml index fb55421123..63c3bd6afd 100644 --- a/tests/components/xgzp68xx/test.esp32-idf.yaml +++ b/tests/components/xgzp68xx/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/test.esp8266-ard.yaml b/tests/components/xgzp68xx/test.esp8266-ard.yaml index 25df8cc225..ee2c29ca4e 100644 --- a/tests/components/xgzp68xx/test.esp8266-ard.yaml +++ b/tests/components/xgzp68xx/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/test.rp2040-ard.yaml b/tests/components/xgzp68xx/test.rp2040-ard.yaml index 25df8cc225..ee2c29ca4e 100644 --- a/tests/components/xgzp68xx/test.rp2040-ard.yaml +++ b/tests/components/xgzp68xx/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xl9535/common.yaml b/tests/components/xl9535/common.yaml new file mode 100644 index 0000000000..e01163cf12 --- /dev/null +++ b/tests/components/xl9535/common.yaml @@ -0,0 +1,26 @@ +i2c: + - id: i2c_xl9535 + scl: ${scl_pin} + sda: ${sda_pin} + +xl9535: + - id: xl9535_hub + address: 0x20 + +binary_sensor: + - platform: gpio + name: XL9535 Pin 0 + pin: + xl9535: xl9535_hub + number: 0 + mode: + input: true + inverted: false + - platform: gpio + name: XL9535 Pin 17 + pin: + xl9535: xl9535_hub + number: 17 + mode: + input: true + inverted: false diff --git a/tests/components/xl9535/test.esp32-ard.yaml b/tests/components/xl9535/test.esp32-ard.yaml index a65aae890e..63c3bd6afd 100644 --- a/tests/components/xl9535/test.esp32-ard.yaml +++ b/tests/components/xl9535/test.esp32-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xl9535/test.esp32-c3-ard.yaml b/tests/components/xl9535/test.esp32-c3-ard.yaml index 178adf870e..ee2c29ca4e 100644 --- a/tests/components/xl9535/test.esp32-c3-ard.yaml +++ b/tests/components/xl9535/test.esp32-c3-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xl9535/test.esp32-c3-idf.yaml b/tests/components/xl9535/test.esp32-c3-idf.yaml index 178adf870e..ee2c29ca4e 100644 --- a/tests/components/xl9535/test.esp32-c3-idf.yaml +++ b/tests/components/xl9535/test.esp32-c3-idf.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xl9535/test.esp32-idf.yaml b/tests/components/xl9535/test.esp32-idf.yaml index a65aae890e..63c3bd6afd 100644 --- a/tests/components/xl9535/test.esp32-idf.yaml +++ b/tests/components/xl9535/test.esp32-idf.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xl9535/test.esp8266-ard.yaml b/tests/components/xl9535/test.esp8266-ard.yaml index 178adf870e..ee2c29ca4e 100644 --- a/tests/components/xl9535/test.esp8266-ard.yaml +++ b/tests/components/xl9535/test.esp8266-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xl9535/test.rp2040-ard.yaml b/tests/components/xl9535/test.rp2040-ard.yaml index 178adf870e..ee2c29ca4e 100644 --- a/tests/components/xl9535/test.rp2040-ard.yaml +++ b/tests/components/xl9535/test.rp2040-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xpt2046/common.yaml b/tests/components/xpt2046/common.yaml new file mode 100644 index 0000000000..9ef680cff4 --- /dev/null +++ b/tests/components/xpt2046/common.yaml @@ -0,0 +1,35 @@ +spi: + - id: spi_xpt2046 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +display: + - platform: ili9xxx + id: xpt_display + dimensions: 320x240 + model: TFT 2.4 + cs_pin: ${disp_cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + invert_colors: false + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + +touchscreen: + - platform: xpt2046 + id: xpt_touchscreen + cs_pin: ${cs_pin} + interrupt_pin: ${interrupt_pin} + display: xpt_display + update_interval: 50ms + threshold: 400 + calibration: + x_min: 280 + x_max: 3860 + y_min: 340 + y_max: 3860 + on_touch: + - logger.log: + format: Touch at (%d, %d) + args: [touch.x, touch.y] diff --git a/tests/components/xpt2046/test.esp32-ard.yaml b/tests/components/xpt2046/test.esp32-ard.yaml index 9e305791e0..b39174947b 100644 --- a/tests/components/xpt2046/test.esp32-ard.yaml +++ b/tests/components/xpt2046/test.esp32-ard.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO17 + mosi_pin: GPIO18 + miso_pin: GPIO19 + dc_pin: GPIO13 + cs_pin: GPIO14 + disp_cs_pin: GPIO4 + interrupt_pin: GPIO21 + reset_pin: GPIO22 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 13 - dc_pin: 14 - reset_pin: 21 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 18 - interrupt_pin: 19 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 280 - x_max: 3860 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/xpt2046/test.esp32-c3-ard.yaml b/tests/components/xpt2046/test.esp32-c3-ard.yaml index c03fd6b345..79b84902ac 100644 --- a/tests/components/xpt2046/test.esp32-c3-ard.yaml +++ b/tests/components/xpt2046/test.esp32-c3-ard.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO4 + mosi_pin: GPIO5 + miso_pin: GPIO6 + dc_pin: GPIO7 + cs_pin: GPIO0 + disp_cs_pin: GPIO1 + interrupt_pin: GPIO3 + reset_pin: GPIO10 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 8 - dc_pin: 9 - reset_pin: 10 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 4 - interrupt_pin: 3 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 28 - x_max: 280 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/xpt2046/test.esp32-c3-idf.yaml b/tests/components/xpt2046/test.esp32-c3-idf.yaml index 787ca9b1ed..79b84902ac 100644 --- a/tests/components/xpt2046/test.esp32-c3-idf.yaml +++ b/tests/components/xpt2046/test.esp32-c3-idf.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO4 + mosi_pin: GPIO5 + miso_pin: GPIO6 + dc_pin: GPIO7 + cs_pin: GPIO0 + disp_cs_pin: GPIO1 + interrupt_pin: GPIO3 + reset_pin: GPIO10 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 8 - dc_pin: 9 - reset_pin: 10 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 4 - interrupt_pin: 3 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 50 - x_max: 280 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/xpt2046/test.esp32-idf.yaml b/tests/components/xpt2046/test.esp32-idf.yaml index e79997146b..b39174947b 100644 --- a/tests/components/xpt2046/test.esp32-idf.yaml +++ b/tests/components/xpt2046/test.esp32-idf.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO17 + mosi_pin: GPIO18 + miso_pin: GPIO19 + dc_pin: GPIO13 + cs_pin: GPIO14 + disp_cs_pin: GPIO4 + interrupt_pin: GPIO21 + reset_pin: GPIO22 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 13 - dc_pin: 14 - reset_pin: 21 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 18 - interrupt_pin: 19 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 50 - x_max: 280 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/xpt2046/test.esp32-s2-ard.yaml b/tests/components/xpt2046/test.esp32-s2-ard.yaml deleted file mode 100644 index df2a99b4f5..0000000000 --- a/tests/components/xpt2046/test.esp32-s2-ard.yaml +++ /dev/null @@ -1,38 +0,0 @@ -spi: - clk_pin: 7 - mosi_pin: 11 - miso_pin: 9 - -display: - - platform: ili9xxx - id: my_display - model: ili9341 - cs_pin: 5 - dc_pin: 12 - reset_pin: 33 - auto_clear_enabled: false - data_rate: 40MHz - dimensions: 320x240 - update_interval: never - invert_colors: false - transform: - mirror_y: false - mirror_x: false - swap_xy: true - -touchscreen: - - platform: xpt2046 - display: my_display - id: my_toucher - update_interval: 50ms - cs_pin: 18 - threshold: 300 - calibration: - x_min: 210 - x_max: 3890 - y_min: 170 - y_max: 3730 - transform: - mirror_x: false - mirror_y: true - swap_xy: true diff --git a/tests/components/xpt2046/test.esp8266-ard.yaml b/tests/components/xpt2046/test.esp8266-ard.yaml index ab71f7b8bc..246c5c8953 100644 --- a/tests/components/xpt2046/test.esp8266-ard.yaml +++ b/tests/components/xpt2046/test.esp8266-ard.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + dc_pin: GPIO15 + cs_pin: GPIO16 + disp_cs_pin: GPIO4 + interrupt_pin: GPIO5 + reset_pin: GPIO2 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 15 - dc_pin: 4 - reset_pin: 5 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 0 - interrupt_pin: 16 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 50 - x_max: 280 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/xpt2046/test.rp2040-ard.yaml b/tests/components/xpt2046/test.rp2040-ard.yaml index 622e69ac98..e693b363d9 100644 --- a/tests/components/xpt2046/test.rp2040-ard.yaml +++ b/tests/components/xpt2046/test.rp2040-ard.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO8 + dc_pin: GPIO9 + cs_pin: GPIO0 + disp_cs_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 8 - dc_pin: 9 - reset_pin: 10 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 5 - interrupt_pin: 6 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 280 - x_max: 3860 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/yashima/common.yaml b/tests/components/yashima/common.yaml new file mode 100644 index 0000000000..bfe181f1a6 --- /dev/null +++ b/tests/components/yashima/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: yashima + name: Yashima Climate diff --git a/tests/components/yashima/test.esp32-ard.yaml b/tests/components/yashima/test.esp32-ard.yaml index 4b6d6daee4..7b012aa64c 100644 --- a/tests/components/yashima/test.esp32-ard.yaml +++ b/tests/components/yashima/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: yashima - name: Yashima Climate +<<: !include common.yaml diff --git a/tests/components/yashima/test.esp32-c3-ard.yaml b/tests/components/yashima/test.esp32-c3-ard.yaml index 4b6d6daee4..7b012aa64c 100644 --- a/tests/components/yashima/test.esp32-c3-ard.yaml +++ b/tests/components/yashima/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: yashima - name: Yashima Climate +<<: !include common.yaml diff --git a/tests/components/yashima/test.esp32-c3-idf.yaml b/tests/components/yashima/test.esp32-c3-idf.yaml index 4b6d6daee4..7b012aa64c 100644 --- a/tests/components/yashima/test.esp32-c3-idf.yaml +++ b/tests/components/yashima/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: yashima - name: Yashima Climate +<<: !include common.yaml diff --git a/tests/components/yashima/test.esp32-idf.yaml b/tests/components/yashima/test.esp32-idf.yaml index 4b6d6daee4..7b012aa64c 100644 --- a/tests/components/yashima/test.esp32-idf.yaml +++ b/tests/components/yashima/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: yashima - name: Yashima Climate +<<: !include common.yaml diff --git a/tests/components/yashima/test.esp8266-ard.yaml b/tests/components/yashima/test.esp8266-ard.yaml index 296a7ede25..f5097fcf5f 100644 --- a/tests/components/yashima/test.esp8266-ard.yaml +++ b/tests/components/yashima/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: yashima - name: Yashima Climate +<<: !include common.yaml diff --git a/tests/components/zhlt01/common.yaml b/tests/components/zhlt01/common.yaml new file mode 100644 index 0000000000..0adbe77325 --- /dev/null +++ b/tests/components/zhlt01/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: zhlt01 + name: ZH/LT-01 Climate diff --git a/tests/components/zhlt01/test.esp32-ard.yaml b/tests/components/zhlt01/test.esp32-ard.yaml index d1dc3b4926..7b012aa64c 100644 --- a/tests/components/zhlt01/test.esp32-ard.yaml +++ b/tests/components/zhlt01/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: zhlt01 - name: ZH/LT-01 Climate +<<: !include common.yaml diff --git a/tests/components/zhlt01/test.esp32-c3-ard.yaml b/tests/components/zhlt01/test.esp32-c3-ard.yaml index d1dc3b4926..7b012aa64c 100644 --- a/tests/components/zhlt01/test.esp32-c3-ard.yaml +++ b/tests/components/zhlt01/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: zhlt01 - name: ZH/LT-01 Climate +<<: !include common.yaml diff --git a/tests/components/zhlt01/test.esp32-c3-idf.yaml b/tests/components/zhlt01/test.esp32-c3-idf.yaml index d1dc3b4926..7b012aa64c 100644 --- a/tests/components/zhlt01/test.esp32-c3-idf.yaml +++ b/tests/components/zhlt01/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: zhlt01 - name: ZH/LT-01 Climate +<<: !include common.yaml diff --git a/tests/components/zhlt01/test.esp32-idf.yaml b/tests/components/zhlt01/test.esp32-idf.yaml index d1dc3b4926..7b012aa64c 100644 --- a/tests/components/zhlt01/test.esp32-idf.yaml +++ b/tests/components/zhlt01/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: zhlt01 - name: ZH/LT-01 Climate +<<: !include common.yaml diff --git a/tests/components/zhlt01/test.esp8266-ard.yaml b/tests/components/zhlt01/test.esp8266-ard.yaml index 40a00bc458..f5097fcf5f 100644 --- a/tests/components/zhlt01/test.esp8266-ard.yaml +++ b/tests/components/zhlt01/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: zhlt01 - name: ZH/LT-01 Climate +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/common.yaml b/tests/components/zio_ultrasonic/common.yaml new file mode 100644 index 0000000000..e13853d8f1 --- /dev/null +++ b/tests/components/zio_ultrasonic/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_zio_ultrasonic + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: zio_ultrasonic + name: "Distance" + update_interval: 60s diff --git a/tests/components/zio_ultrasonic/test.esp32-ard.yaml b/tests/components/zio_ultrasonic/test.esp32-ard.yaml index ad4050307e..63c3bd6afd 100644 --- a/tests/components/zio_ultrasonic/test.esp32-ard.yaml +++ b/tests/components/zio_ultrasonic/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/test.esp32-c3-ard.yaml b/tests/components/zio_ultrasonic/test.esp32-c3-ard.yaml index 36e1697a38..ee2c29ca4e 100644 --- a/tests/components/zio_ultrasonic/test.esp32-c3-ard.yaml +++ b/tests/components/zio_ultrasonic/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/test.esp32-c3-idf.yaml b/tests/components/zio_ultrasonic/test.esp32-c3-idf.yaml index 36e1697a38..ee2c29ca4e 100644 --- a/tests/components/zio_ultrasonic/test.esp32-c3-idf.yaml +++ b/tests/components/zio_ultrasonic/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/test.esp32-idf.yaml b/tests/components/zio_ultrasonic/test.esp32-idf.yaml index ad4050307e..63c3bd6afd 100644 --- a/tests/components/zio_ultrasonic/test.esp32-idf.yaml +++ b/tests/components/zio_ultrasonic/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/test.esp8266-ard.yaml b/tests/components/zio_ultrasonic/test.esp8266-ard.yaml index 36e1697a38..ee2c29ca4e 100644 --- a/tests/components/zio_ultrasonic/test.esp8266-ard.yaml +++ b/tests/components/zio_ultrasonic/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/test.rp2040-ard.yaml b/tests/components/zio_ultrasonic/test.rp2040-ard.yaml index 36e1697a38..ee2c29ca4e 100644 --- a/tests/components/zio_ultrasonic/test.rp2040-ard.yaml +++ b/tests/components/zio_ultrasonic/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zyaura/common.yaml b/tests/components/zyaura/common.yaml new file mode 100644 index 0000000000..e2a994a317 --- /dev/null +++ b/tests/components/zyaura/common.yaml @@ -0,0 +1,10 @@ +sensor: + - platform: zyaura + clock_pin: ${clock_pin} + data_pin: ${data_pin} + co2: + name: ZyAura CO2 + temperature: + name: ZyAura Temperature + humidity: + name: ZyAura Humidity diff --git a/tests/components/zyaura/test.esp32-ard.yaml b/tests/components/zyaura/test.esp32-ard.yaml index 29116a978b..d295973e3f 100644 --- a/tests/components/zyaura/test.esp32-ard.yaml +++ b/tests/components/zyaura/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 16 - data_pin: 17 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/zyaura/test.esp32-c3-ard.yaml b/tests/components/zyaura/test.esp32-c3-ard.yaml index 90205c468c..7808481215 100644 --- a/tests/components/zyaura/test.esp32-c3-ard.yaml +++ b/tests/components/zyaura/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 5 - data_pin: 4 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/zyaura/test.esp32-c3-idf.yaml b/tests/components/zyaura/test.esp32-c3-idf.yaml index 90205c468c..7808481215 100644 --- a/tests/components/zyaura/test.esp32-c3-idf.yaml +++ b/tests/components/zyaura/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 5 - data_pin: 4 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/zyaura/test.esp32-idf.yaml b/tests/components/zyaura/test.esp32-idf.yaml index 29116a978b..d295973e3f 100644 --- a/tests/components/zyaura/test.esp32-idf.yaml +++ b/tests/components/zyaura/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 16 - data_pin: 17 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/zyaura/test.esp8266-ard.yaml b/tests/components/zyaura/test.esp8266-ard.yaml index 90205c468c..7808481215 100644 --- a/tests/components/zyaura/test.esp8266-ard.yaml +++ b/tests/components/zyaura/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 5 - data_pin: 4 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/zyaura/test.rp2040-ard.yaml b/tests/components/zyaura/test.rp2040-ard.yaml index 90205c468c..7808481215 100644 --- a/tests/components/zyaura/test.rp2040-ard.yaml +++ b/tests/components/zyaura/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 5 - data_pin: 4 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + +<<: !include common.yaml From 8897a9866d4c80df8e528aacd73d05c604ba83a7 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sun, 9 Feb 2025 15:43:21 -0600 Subject: [PATCH 171/194] [CI] Consolidate some tests (T) (#8208) --- tests/components/t6615/common.yaml | 10 +++ tests/components/t6615/test.esp32-ard.yaml | 13 +-- tests/components/t6615/test.esp32-c3-ard.yaml | 13 +-- tests/components/t6615/test.esp32-c3-idf.yaml | 13 +-- tests/components/t6615/test.esp32-idf.yaml | 13 +-- tests/components/t6615/test.esp8266-ard.yaml | 13 +-- tests/components/t6615/test.rp2040-ard.yaml | 13 +-- tests/components/tc74/common.yaml | 8 ++ tests/components/tc74/test.esp32-ard.yaml | 11 +-- tests/components/tc74/test.esp32-c3-ard.yaml | 11 +-- tests/components/tc74/test.esp32-c3-idf.yaml | 11 +-- tests/components/tc74/test.esp32-idf.yaml | 11 +-- tests/components/tc74/test.esp8266-ard.yaml | 11 +-- tests/components/tc74/test.rp2040-ard.yaml | 11 +-- tests/components/tca9548a/common.yaml | 15 ++++ tests/components/tca9548a/test.esp32-ard.yaml | 18 +--- .../tca9548a/test.esp32-c3-ard.yaml | 18 +--- .../tca9548a/test.esp32-c3-idf.yaml | 18 +--- tests/components/tca9548a/test.esp32-idf.yaml | 18 +--- .../components/tca9548a/test.esp8266-ard.yaml | 18 +--- .../components/tca9548a/test.rp2040-ard.yaml | 18 +--- tests/components/tca9555/common.yaml | 27 ++++++ tests/components/tca9555/test.esp32-ard.yaml | 30 +------ .../components/tca9555/test.esp32-c3-ard.yaml | 30 +------ .../components/tca9555/test.esp32-c3-idf.yaml | 30 +------ tests/components/tca9555/test.esp32-idf.yaml | 30 +------ .../components/tca9555/test.esp8266-ard.yaml | 30 +------ tests/components/tca9555/test.rp2040-ard.yaml | 30 +------ tests/components/tcl112/common.yaml | 15 ++++ tests/components/tcl112/test.esp32-ard.yaml | 17 +--- .../components/tcl112/test.esp32-c3-ard.yaml | 17 +--- .../components/tcl112/test.esp32-c3-idf.yaml | 17 +--- tests/components/tcl112/test.esp32-idf.yaml | 17 +--- tests/components/tcl112/test.esp8266-ard.yaml | 17 +--- tests/components/tcs34725/common.yaml | 21 +++++ tests/components/tcs34725/test.esp32-ard.yaml | 24 +----- .../tcs34725/test.esp32-c3-ard.yaml | 24 +----- .../tcs34725/test.esp32-c3-idf.yaml | 24 +----- tests/components/tcs34725/test.esp32-idf.yaml | 24 +----- .../components/tcs34725/test.esp8266-ard.yaml | 24 +----- .../components/tcs34725/test.rp2040-ard.yaml | 24 +----- tests/components/tee501/common.yaml | 9 ++ tests/components/tee501/test.esp32-ard.yaml | 12 +-- .../components/tee501/test.esp32-c3-ard.yaml | 12 +-- .../components/tee501/test.esp32-c3-idf.yaml | 12 +-- tests/components/tee501/test.esp32-idf.yaml | 12 +-- tests/components/tee501/test.esp8266-ard.yaml | 12 +-- tests/components/tee501/test.rp2040-ard.yaml | 12 +-- tests/components/teleinfo/common.yaml | 42 ++++++++++ tests/components/teleinfo/test.esp32-ard.yaml | 45 +--------- .../teleinfo/test.esp32-c3-ard.yaml | 45 +--------- .../teleinfo/test.esp32-c3-idf.yaml | 45 +--------- tests/components/teleinfo/test.esp32-idf.yaml | 45 +--------- .../components/teleinfo/test.esp8266-ard.yaml | 45 +--------- .../components/teleinfo/test.rp2040-ard.yaml | 45 +--------- tests/components/tlc59208f/common.yaml | 50 +++++++++++ .../components/tlc59208f/test.esp32-ard.yaml | 53 +----------- .../tlc59208f/test.esp32-c3-ard.yaml | 53 +----------- .../tlc59208f/test.esp32-c3-idf.yaml | 53 +----------- .../components/tlc59208f/test.esp32-idf.yaml | 53 +----------- .../tlc59208f/test.esp8266-ard.yaml | 53 +----------- .../components/tlc59208f/test.rp2040-ard.yaml | 53 +----------- tests/components/tm1621/common.yaml | 12 +++ tests/components/tm1621/test.esp32-ard.yaml | 19 ++--- .../components/tm1621/test.esp32-c3-ard.yaml | 19 ++--- .../components/tm1621/test.esp32-c3-idf.yaml | 19 ++--- tests/components/tm1621/test.esp32-idf.yaml | 19 ++--- tests/components/tm1621/test.esp8266-ard.yaml | 19 ++--- tests/components/tm1621/test.rp2040-ard.yaml | 19 ++--- tests/components/tm1637/common.yaml | 7 ++ tests/components/tm1637/test.esp32-ard.yaml | 12 ++- .../components/tm1637/test.esp32-c3-ard.yaml | 12 ++- .../components/tm1637/test.esp32-c3-idf.yaml | 12 ++- tests/components/tm1637/test.esp32-idf.yaml | 12 ++- tests/components/tm1637/test.esp8266-ard.yaml | 12 ++- tests/components/tm1637/test.rp2040-ard.yaml | 12 ++- tests/components/tmp102/common.yaml | 8 ++ tests/components/tmp102/test.esp32-ard.yaml | 11 +-- .../components/tmp102/test.esp32-c3-ard.yaml | 11 +-- .../components/tmp102/test.esp32-c3-idf.yaml | 11 +-- tests/components/tmp102/test.esp32-idf.yaml | 11 +-- tests/components/tmp102/test.esp8266-ard.yaml | 11 +-- tests/components/tmp102/test.rp2040-ard.yaml | 11 +-- tests/components/tmp1075/common.yaml | 16 ++++ tests/components/tmp1075/test.esp32-ard.yaml | 19 +---- .../components/tmp1075/test.esp32-c3-ard.yaml | 19 +---- .../components/tmp1075/test.esp32-c3-idf.yaml | 19 +---- tests/components/tmp1075/test.esp32-idf.yaml | 19 +---- .../components/tmp1075/test.esp8266-ard.yaml | 19 +---- tests/components/tmp1075/test.rp2040-ard.yaml | 19 +---- tests/components/tmp117/common.yaml | 9 ++ tests/components/tmp117/test.esp32-ard.yaml | 12 +-- .../components/tmp117/test.esp32-c3-ard.yaml | 12 +-- .../components/tmp117/test.esp32-c3-idf.yaml | 12 +-- tests/components/tmp117/test.esp32-idf.yaml | 12 +-- tests/components/tmp117/test.esp8266-ard.yaml | 12 +-- tests/components/tmp117/test.rp2040-ard.yaml | 12 +-- tests/components/tof10120/common.yaml | 9 ++ tests/components/tof10120/test.esp32-ard.yaml | 12 +-- .../tof10120/test.esp32-c3-ard.yaml | 12 +-- .../tof10120/test.esp32-c3-idf.yaml | 12 +-- tests/components/tof10120/test.esp32-idf.yaml | 12 +-- .../components/tof10120/test.esp8266-ard.yaml | 12 +-- .../components/tof10120/test.rp2040-ard.yaml | 12 +-- tests/components/toshiba/common.yaml | 7 ++ tests/components/toshiba/test.esp32-ard.yaml | 9 +- .../components/toshiba/test.esp32-c3-ard.yaml | 9 +- .../components/toshiba/test.esp32-c3-idf.yaml | 9 +- tests/components/toshiba/test.esp32-idf.yaml | 9 +- .../components/toshiba/test.esp8266-ard.yaml | 9 +- .../components/total_daily_energy/common.yaml | 32 ++++++++ .../total_daily_energy/test.esp32-ard.yaml | 36 ++------ .../total_daily_energy/test.esp32-c3-ard.yaml | 36 ++------ .../total_daily_energy/test.esp32-c3-idf.yaml | 36 ++------ .../total_daily_energy/test.esp32-idf.yaml | 36 ++------ .../total_daily_energy/test.esp8266-ard.yaml | 36 ++------ .../total_daily_energy/test.rp2040-ard.yaml | 36 ++------ tests/components/tsl2561/common.yaml | 13 +++ tests/components/tsl2561/test.esp32-ard.yaml | 16 +--- .../components/tsl2561/test.esp32-c3-ard.yaml | 16 +--- .../components/tsl2561/test.esp32-c3-idf.yaml | 16 +--- tests/components/tsl2561/test.esp32-idf.yaml | 16 +--- .../components/tsl2561/test.esp8266-ard.yaml | 16 +--- tests/components/tsl2561/test.rp2040-ard.yaml | 16 +--- tests/components/tsl2591/common.yaml | 25 ++++++ tests/components/tsl2591/test.esp32-ard.yaml | 28 +------ .../components/tsl2591/test.esp32-c3-ard.yaml | 28 +------ .../components/tsl2591/test.esp32-c3-idf.yaml | 28 +------ tests/components/tsl2591/test.esp32-idf.yaml | 28 +------ .../components/tsl2591/test.esp8266-ard.yaml | 28 +------ tests/components/tsl2591/test.rp2040-ard.yaml | 28 +------ tests/components/tt21100/common.yaml | 25 ++++++ tests/components/tt21100/test.esp32-ard.yaml | 31 ++----- .../components/tt21100/test.esp32-c3-ard.yaml | 31 ++----- .../components/tt21100/test.esp32-c3-idf.yaml | 31 ++----- tests/components/tt21100/test.esp32-idf.yaml | 31 ++----- .../components/tt21100/test.esp32-s2-ard.yaml | 44 ---------- .../components/tt21100/test.esp8266-ard.yaml | 31 ++----- tests/components/tt21100/test.rp2040-ard.yaml | 31 ++----- tests/components/ttp229_bsf/common.yaml | 8 ++ .../components/ttp229_bsf/test.esp32-ard.yaml | 11 +-- .../ttp229_bsf/test.esp32-c3-ard.yaml | 11 +-- .../ttp229_bsf/test.esp32-c3-idf.yaml | 11 +-- .../components/ttp229_bsf/test.esp32-idf.yaml | 11 +-- .../ttp229_bsf/test.esp8266-ard.yaml | 11 +-- .../ttp229_bsf/test.rp2040-ard.yaml | 11 +-- tests/components/ttp229_lsf/common.yaml | 11 +++ .../components/ttp229_lsf/test.esp32-ard.yaml | 14 +--- .../ttp229_lsf/test.esp32-c3-ard.yaml | 14 +--- .../ttp229_lsf/test.esp32-c3-idf.yaml | 14 +--- .../components/ttp229_lsf/test.esp32-idf.yaml | 14 +--- .../ttp229_lsf/test.esp8266-ard.yaml | 14 +--- .../ttp229_lsf/test.rp2040-ard.yaml | 14 +--- tests/components/tuya/common.yaml | 78 ++++++++++++++++++ tests/components/tuya/test.esp32-ard.yaml | 82 ++----------------- tests/components/tuya/test.esp32-c3-ard.yaml | 82 ++----------------- tests/components/tuya/test.esp32-c3-idf.yaml | 82 ++----------------- tests/components/tuya/test.esp32-idf.yaml | 82 ++----------------- tests/components/tuya/test.esp8266-ard.yaml | 82 ++----------------- tests/components/tuya/test.rp2040-ard.yaml | 82 ++----------------- 160 files changed, 1045 insertions(+), 2640 deletions(-) create mode 100644 tests/components/t6615/common.yaml create mode 100644 tests/components/tc74/common.yaml create mode 100644 tests/components/tca9548a/common.yaml create mode 100644 tests/components/tca9555/common.yaml create mode 100644 tests/components/tcl112/common.yaml create mode 100644 tests/components/tcs34725/common.yaml create mode 100644 tests/components/tee501/common.yaml create mode 100644 tests/components/teleinfo/common.yaml create mode 100644 tests/components/tlc59208f/common.yaml create mode 100644 tests/components/tm1621/common.yaml create mode 100644 tests/components/tm1637/common.yaml create mode 100644 tests/components/tmp102/common.yaml create mode 100644 tests/components/tmp1075/common.yaml create mode 100644 tests/components/tmp117/common.yaml create mode 100644 tests/components/tof10120/common.yaml create mode 100644 tests/components/toshiba/common.yaml create mode 100644 tests/components/total_daily_energy/common.yaml create mode 100644 tests/components/tsl2561/common.yaml create mode 100644 tests/components/tsl2591/common.yaml create mode 100644 tests/components/tt21100/common.yaml delete mode 100644 tests/components/tt21100/test.esp32-s2-ard.yaml create mode 100644 tests/components/ttp229_bsf/common.yaml create mode 100644 tests/components/ttp229_lsf/common.yaml create mode 100644 tests/components/tuya/common.yaml diff --git a/tests/components/t6615/common.yaml b/tests/components/t6615/common.yaml new file mode 100644 index 0000000000..3ad715ae2b --- /dev/null +++ b/tests/components/t6615/common.yaml @@ -0,0 +1,10 @@ +uart: + - id: uart_t6615 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 19200 + +sensor: + - platform: t6615 + co2: + name: CO2 Sensor diff --git a/tests/components/t6615/test.esp32-ard.yaml b/tests/components/t6615/test.esp32-ard.yaml index 2cfaa0ae5b..f486544afa 100644 --- a/tests/components/t6615/test.esp32-ard.yaml +++ b/tests/components/t6615/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 17 - rx_pin: 16 - baud_rate: 19200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/t6615/test.esp32-c3-ard.yaml b/tests/components/t6615/test.esp32-c3-ard.yaml index e8690c770f..b516342f3b 100644 --- a/tests/components/t6615/test.esp32-c3-ard.yaml +++ b/tests/components/t6615/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 4 - rx_pin: 5 - baud_rate: 19200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/t6615/test.esp32-c3-idf.yaml b/tests/components/t6615/test.esp32-c3-idf.yaml index e8690c770f..b516342f3b 100644 --- a/tests/components/t6615/test.esp32-c3-idf.yaml +++ b/tests/components/t6615/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 4 - rx_pin: 5 - baud_rate: 19200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/t6615/test.esp32-idf.yaml b/tests/components/t6615/test.esp32-idf.yaml index 2cfaa0ae5b..f486544afa 100644 --- a/tests/components/t6615/test.esp32-idf.yaml +++ b/tests/components/t6615/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 17 - rx_pin: 16 - baud_rate: 19200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/t6615/test.esp8266-ard.yaml b/tests/components/t6615/test.esp8266-ard.yaml index e8690c770f..b516342f3b 100644 --- a/tests/components/t6615/test.esp8266-ard.yaml +++ b/tests/components/t6615/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 4 - rx_pin: 5 - baud_rate: 19200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/t6615/test.rp2040-ard.yaml b/tests/components/t6615/test.rp2040-ard.yaml index e8690c770f..b516342f3b 100644 --- a/tests/components/t6615/test.rp2040-ard.yaml +++ b/tests/components/t6615/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 4 - rx_pin: 5 - baud_rate: 19200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/tc74/common.yaml b/tests/components/tc74/common.yaml new file mode 100644 index 0000000000..88f5c91e12 --- /dev/null +++ b/tests/components/tc74/common.yaml @@ -0,0 +1,8 @@ +i2c: + - id: i2c_tc74 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tc74 + name: TC74 Temperature diff --git a/tests/components/tc74/test.esp32-ard.yaml b/tests/components/tc74/test.esp32-ard.yaml index ef9b40e184..63c3bd6afd 100644 --- a/tests/components/tc74/test.esp32-ard.yaml +++ b/tests/components/tc74/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tc74/test.esp32-c3-ard.yaml b/tests/components/tc74/test.esp32-c3-ard.yaml index e1a373fbf4..ee2c29ca4e 100644 --- a/tests/components/tc74/test.esp32-c3-ard.yaml +++ b/tests/components/tc74/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tc74/test.esp32-c3-idf.yaml b/tests/components/tc74/test.esp32-c3-idf.yaml index e1a373fbf4..ee2c29ca4e 100644 --- a/tests/components/tc74/test.esp32-c3-idf.yaml +++ b/tests/components/tc74/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tc74/test.esp32-idf.yaml b/tests/components/tc74/test.esp32-idf.yaml index ef9b40e184..63c3bd6afd 100644 --- a/tests/components/tc74/test.esp32-idf.yaml +++ b/tests/components/tc74/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tc74/test.esp8266-ard.yaml b/tests/components/tc74/test.esp8266-ard.yaml index e1a373fbf4..ee2c29ca4e 100644 --- a/tests/components/tc74/test.esp8266-ard.yaml +++ b/tests/components/tc74/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tc74/test.rp2040-ard.yaml b/tests/components/tc74/test.rp2040-ard.yaml index e1a373fbf4..ee2c29ca4e 100644 --- a/tests/components/tc74/test.rp2040-ard.yaml +++ b/tests/components/tc74/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tca9548a/common.yaml b/tests/components/tca9548a/common.yaml new file mode 100644 index 0000000000..67e812e08b --- /dev/null +++ b/tests/components/tca9548a/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_tca9548a + scl: ${scl_pin} + sda: ${sda_pin} + +tca9548a: + - id: multiplex0 + address: 0x70 + channels: + - bus_id: multiplex0_chan0 + channel: 0 + i2c_id: i2c_tca9548a + - id: multiplex1 + address: 0x71 + i2c_id: multiplex0_chan0 diff --git a/tests/components/tca9548a/test.esp32-ard.yaml b/tests/components/tca9548a/test.esp32-ard.yaml index 7edb83c821..63c3bd6afd 100644 --- a/tests/components/tca9548a/test.esp32-ard.yaml +++ b/tests/components/tca9548a/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9548a/test.esp32-c3-ard.yaml b/tests/components/tca9548a/test.esp32-c3-ard.yaml index 2294530d14..ee2c29ca4e 100644 --- a/tests/components/tca9548a/test.esp32-c3-ard.yaml +++ b/tests/components/tca9548a/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9548a/test.esp32-c3-idf.yaml b/tests/components/tca9548a/test.esp32-c3-idf.yaml index 2294530d14..ee2c29ca4e 100644 --- a/tests/components/tca9548a/test.esp32-c3-idf.yaml +++ b/tests/components/tca9548a/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9548a/test.esp32-idf.yaml b/tests/components/tca9548a/test.esp32-idf.yaml index 7edb83c821..63c3bd6afd 100644 --- a/tests/components/tca9548a/test.esp32-idf.yaml +++ b/tests/components/tca9548a/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9548a/test.esp8266-ard.yaml b/tests/components/tca9548a/test.esp8266-ard.yaml index 2294530d14..ee2c29ca4e 100644 --- a/tests/components/tca9548a/test.esp8266-ard.yaml +++ b/tests/components/tca9548a/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9548a/test.rp2040-ard.yaml b/tests/components/tca9548a/test.rp2040-ard.yaml index 2294530d14..ee2c29ca4e 100644 --- a/tests/components/tca9548a/test.rp2040-ard.yaml +++ b/tests/components/tca9548a/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9555/common.yaml b/tests/components/tca9555/common.yaml new file mode 100644 index 0000000000..0fc3086786 --- /dev/null +++ b/tests/components/tca9555/common.yaml @@ -0,0 +1,27 @@ +i2c: + - id: i2c_tca9555 + scl: ${scl_pin} + sda: ${sda_pin} + +tca9555: + - id: tca9555_hub + address: 0x21 + +binary_sensor: + - platform: gpio + id: tca9555_binary_sensor + name: TCA9555 Binary Sensor + pin: + tca9555: tca9555_hub + number: 1 + mode: INPUT + inverted: true + +output: + - platform: gpio + id: tca9555_output + pin: + tca9555: tca9555_hub + number: 0 + mode: OUTPUT + inverted: false diff --git a/tests/components/tca9555/test.esp32-ard.yaml b/tests/components/tca9555/test.esp32-ard.yaml index e0c046b443..63c3bd6afd 100644 --- a/tests/components/tca9555/test.esp32-ard.yaml +++ b/tests/components/tca9555/test.esp32-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tca9555/test.esp32-c3-ard.yaml b/tests/components/tca9555/test.esp32-c3-ard.yaml index 5c49b27640..ee2c29ca4e 100644 --- a/tests/components/tca9555/test.esp32-c3-ard.yaml +++ b/tests/components/tca9555/test.esp32-c3-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tca9555/test.esp32-c3-idf.yaml b/tests/components/tca9555/test.esp32-c3-idf.yaml index 5c49b27640..ee2c29ca4e 100644 --- a/tests/components/tca9555/test.esp32-c3-idf.yaml +++ b/tests/components/tca9555/test.esp32-c3-idf.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tca9555/test.esp32-idf.yaml b/tests/components/tca9555/test.esp32-idf.yaml index e0c046b443..63c3bd6afd 100644 --- a/tests/components/tca9555/test.esp32-idf.yaml +++ b/tests/components/tca9555/test.esp32-idf.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tca9555/test.esp8266-ard.yaml b/tests/components/tca9555/test.esp8266-ard.yaml index 5c49b27640..ee2c29ca4e 100644 --- a/tests/components/tca9555/test.esp8266-ard.yaml +++ b/tests/components/tca9555/test.esp8266-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tca9555/test.rp2040-ard.yaml b/tests/components/tca9555/test.rp2040-ard.yaml index 5c49b27640..ee2c29ca4e 100644 --- a/tests/components/tca9555/test.rp2040-ard.yaml +++ b/tests/components/tca9555/test.rp2040-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tcl112/common.yaml b/tests/components/tcl112/common.yaml new file mode 100644 index 0000000000..0e43de4a4a --- /dev/null +++ b/tests/components/tcl112/common.yaml @@ -0,0 +1,15 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +sensor: + - platform: template + id: tcl112_sensor + lambda: "return 21;" + +climate: + - platform: tcl112 + name: TCL112 Climate with Sensor + supports_heat: true + supports_cool: true + sensor: tcl112_sensor diff --git a/tests/components/tcl112/test.esp32-ard.yaml b/tests/components/tcl112/test.esp32-ard.yaml index 03c0e84fe5..7b012aa64c 100644 --- a/tests/components/tcl112/test.esp32-ard.yaml +++ b/tests/components/tcl112/test.esp32-ard.yaml @@ -1,15 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -sensor: - - platform: template - id: tcl112_sensor - lambda: "return 21;" - -climate: - - platform: tcl112 - name: TCL112 Climate with Sensor - supports_heat: true - supports_cool: true - sensor: tcl112_sensor +<<: !include common.yaml diff --git a/tests/components/tcl112/test.esp32-c3-ard.yaml b/tests/components/tcl112/test.esp32-c3-ard.yaml index 03c0e84fe5..7b012aa64c 100644 --- a/tests/components/tcl112/test.esp32-c3-ard.yaml +++ b/tests/components/tcl112/test.esp32-c3-ard.yaml @@ -1,15 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -sensor: - - platform: template - id: tcl112_sensor - lambda: "return 21;" - -climate: - - platform: tcl112 - name: TCL112 Climate with Sensor - supports_heat: true - supports_cool: true - sensor: tcl112_sensor +<<: !include common.yaml diff --git a/tests/components/tcl112/test.esp32-c3-idf.yaml b/tests/components/tcl112/test.esp32-c3-idf.yaml index 03c0e84fe5..7b012aa64c 100644 --- a/tests/components/tcl112/test.esp32-c3-idf.yaml +++ b/tests/components/tcl112/test.esp32-c3-idf.yaml @@ -1,15 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -sensor: - - platform: template - id: tcl112_sensor - lambda: "return 21;" - -climate: - - platform: tcl112 - name: TCL112 Climate with Sensor - supports_heat: true - supports_cool: true - sensor: tcl112_sensor +<<: !include common.yaml diff --git a/tests/components/tcl112/test.esp32-idf.yaml b/tests/components/tcl112/test.esp32-idf.yaml index 03c0e84fe5..7b012aa64c 100644 --- a/tests/components/tcl112/test.esp32-idf.yaml +++ b/tests/components/tcl112/test.esp32-idf.yaml @@ -1,15 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -sensor: - - platform: template - id: tcl112_sensor - lambda: "return 21;" - -climate: - - platform: tcl112 - name: TCL112 Climate with Sensor - supports_heat: true - supports_cool: true - sensor: tcl112_sensor +<<: !include common.yaml diff --git a/tests/components/tcl112/test.esp8266-ard.yaml b/tests/components/tcl112/test.esp8266-ard.yaml index 0a85536928..f5097fcf5f 100644 --- a/tests/components/tcl112/test.esp8266-ard.yaml +++ b/tests/components/tcl112/test.esp8266-ard.yaml @@ -1,15 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -sensor: - - platform: template - id: tcl112_sensor - lambda: "return 21;" - -climate: - - platform: tcl112 - name: TCL112 Climate with Sensor - supports_heat: true - supports_cool: true - sensor: tcl112_sensor +<<: !include common.yaml diff --git a/tests/components/tcs34725/common.yaml b/tests/components/tcs34725/common.yaml new file mode 100644 index 0000000000..5296988fa5 --- /dev/null +++ b/tests/components/tcs34725/common.yaml @@ -0,0 +1,21 @@ +i2c: + - id: i2c_tcs34725 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tcs34725 + red_channel: + name: Red Channel + green_channel: + name: Green Channel + blue_channel: + name: Blue Channel + clear_channel: + name: Clear Channel + illuminance: + name: Illuminance + color_temperature: + name: Color Temperature + integration_time: 614ms + gain: 60x diff --git a/tests/components/tcs34725/test.esp32-ard.yaml b/tests/components/tcs34725/test.esp32-ard.yaml index 86ef82962e..63c3bd6afd 100644 --- a/tests/components/tcs34725/test.esp32-ard.yaml +++ b/tests/components/tcs34725/test.esp32-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tcs34725/test.esp32-c3-ard.yaml b/tests/components/tcs34725/test.esp32-c3-ard.yaml index 9b459c9104..ee2c29ca4e 100644 --- a/tests/components/tcs34725/test.esp32-c3-ard.yaml +++ b/tests/components/tcs34725/test.esp32-c3-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tcs34725/test.esp32-c3-idf.yaml b/tests/components/tcs34725/test.esp32-c3-idf.yaml index 9b459c9104..ee2c29ca4e 100644 --- a/tests/components/tcs34725/test.esp32-c3-idf.yaml +++ b/tests/components/tcs34725/test.esp32-c3-idf.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tcs34725/test.esp32-idf.yaml b/tests/components/tcs34725/test.esp32-idf.yaml index 86ef82962e..63c3bd6afd 100644 --- a/tests/components/tcs34725/test.esp32-idf.yaml +++ b/tests/components/tcs34725/test.esp32-idf.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tcs34725/test.esp8266-ard.yaml b/tests/components/tcs34725/test.esp8266-ard.yaml index 9b459c9104..ee2c29ca4e 100644 --- a/tests/components/tcs34725/test.esp8266-ard.yaml +++ b/tests/components/tcs34725/test.esp8266-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tcs34725/test.rp2040-ard.yaml b/tests/components/tcs34725/test.rp2040-ard.yaml index 9b459c9104..ee2c29ca4e 100644 --- a/tests/components/tcs34725/test.rp2040-ard.yaml +++ b/tests/components/tcs34725/test.rp2040-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tee501/common.yaml b/tests/components/tee501/common.yaml new file mode 100644 index 0000000000..c01ab7e37a --- /dev/null +++ b/tests/components/tee501/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_tee501 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tee501 + name: TEE501 Temperature + address: 0x48 diff --git a/tests/components/tee501/test.esp32-ard.yaml b/tests/components/tee501/test.esp32-ard.yaml index acf6fed4bf..63c3bd6afd 100644 --- a/tests/components/tee501/test.esp32-ard.yaml +++ b/tests/components/tee501/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/tee501/test.esp32-c3-ard.yaml b/tests/components/tee501/test.esp32-c3-ard.yaml index 11991a6153..ee2c29ca4e 100644 --- a/tests/components/tee501/test.esp32-c3-ard.yaml +++ b/tests/components/tee501/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/tee501/test.esp32-c3-idf.yaml b/tests/components/tee501/test.esp32-c3-idf.yaml index 11991a6153..ee2c29ca4e 100644 --- a/tests/components/tee501/test.esp32-c3-idf.yaml +++ b/tests/components/tee501/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/tee501/test.esp32-idf.yaml b/tests/components/tee501/test.esp32-idf.yaml index acf6fed4bf..63c3bd6afd 100644 --- a/tests/components/tee501/test.esp32-idf.yaml +++ b/tests/components/tee501/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/tee501/test.esp8266-ard.yaml b/tests/components/tee501/test.esp8266-ard.yaml index 11991a6153..ee2c29ca4e 100644 --- a/tests/components/tee501/test.esp8266-ard.yaml +++ b/tests/components/tee501/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/tee501/test.rp2040-ard.yaml b/tests/components/tee501/test.rp2040-ard.yaml index 11991a6153..ee2c29ca4e 100644 --- a/tests/components/tee501/test.rp2040-ard.yaml +++ b/tests/components/tee501/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/teleinfo/common.yaml b/tests/components/teleinfo/common.yaml new file mode 100644 index 0000000000..90b684e977 --- /dev/null +++ b/tests/components/teleinfo/common.yaml @@ -0,0 +1,42 @@ +uart: + - id: uart_teleinfo + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 1200 + parity: EVEN + +button: + - platform: template + name: Poller component suspend test + on_press: + - component.suspend: test_teleinfo + - delay: 20s + - component.update: test_teleinfo + - delay: 20s + - component.resume: test_teleinfo + - delay: 20s + - component.resume: + id: test_teleinfo + update_interval: 2s + - delay: 20s + - component.resume: + id: test_teleinfo + update_interval: !lambda return 2500; + +teleinfo: + id: test_teleinfo + historical_mode: true + update_interval: 60s + +sensor: + - platform: teleinfo + name: hchc + tag_name: HCHC + teleinfo_id: test_teleinfo + unit_of_measurement: Wh + +text_sensor: + - platform: teleinfo + name: optarif + tag_name: OPTARIF + teleinfo_id: test_teleinfo diff --git a/tests/components/teleinfo/test.esp32-ard.yaml b/tests/components/teleinfo/test.esp32-ard.yaml index a5bd176143..f486544afa 100644 --- a/tests/components/teleinfo/test.esp32-ard.yaml +++ b/tests/components/teleinfo/test.esp32-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 17 - rx_pin: 16 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/teleinfo/test.esp32-c3-ard.yaml b/tests/components/teleinfo/test.esp32-c3-ard.yaml index 55641e1e01..b516342f3b 100644 --- a/tests/components/teleinfo/test.esp32-c3-ard.yaml +++ b/tests/components/teleinfo/test.esp32-c3-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/teleinfo/test.esp32-c3-idf.yaml b/tests/components/teleinfo/test.esp32-c3-idf.yaml index 55641e1e01..b516342f3b 100644 --- a/tests/components/teleinfo/test.esp32-c3-idf.yaml +++ b/tests/components/teleinfo/test.esp32-c3-idf.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/teleinfo/test.esp32-idf.yaml b/tests/components/teleinfo/test.esp32-idf.yaml index a5bd176143..f486544afa 100644 --- a/tests/components/teleinfo/test.esp32-idf.yaml +++ b/tests/components/teleinfo/test.esp32-idf.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 17 - rx_pin: 16 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/teleinfo/test.esp8266-ard.yaml b/tests/components/teleinfo/test.esp8266-ard.yaml index 55641e1e01..b516342f3b 100644 --- a/tests/components/teleinfo/test.esp8266-ard.yaml +++ b/tests/components/teleinfo/test.esp8266-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/teleinfo/test.rp2040-ard.yaml b/tests/components/teleinfo/test.rp2040-ard.yaml index 55641e1e01..b516342f3b 100644 --- a/tests/components/teleinfo/test.rp2040-ard.yaml +++ b/tests/components/teleinfo/test.rp2040-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/tlc59208f/common.yaml b/tests/components/tlc59208f/common.yaml new file mode 100644 index 0000000000..49460dcefc --- /dev/null +++ b/tests/components/tlc59208f/common.yaml @@ -0,0 +1,50 @@ +i2c: + - id: i2c_tlc59208f + scl: ${scl_pin} + sda: ${sda_pin} + +tlc59208f: + - address: 0x20 + id: tlc59208f_1 + - address: 0x22 + id: tlc59208f_2 + - address: 0x24 + id: tlc59208f_3 + +output: + - platform: tlc59208f + id: tlc_0 + channel: 0 + tlc59208f_id: tlc59208f_1 + - platform: tlc59208f + id: tlc_1 + channel: 1 + tlc59208f_id: tlc59208f_1 + - platform: tlc59208f + id: tlc_2 + channel: 2 + tlc59208f_id: tlc59208f_1 + - platform: tlc59208f + id: tlc_3 + channel: 0 + tlc59208f_id: tlc59208f_2 + - platform: tlc59208f + id: tlc_4 + channel: 1 + tlc59208f_id: tlc59208f_2 + - platform: tlc59208f + id: tlc_5 + channel: 2 + tlc59208f_id: tlc59208f_2 + - platform: tlc59208f + id: tlc_6 + channel: 0 + tlc59208f_id: tlc59208f_3 + - platform: tlc59208f + id: tlc_7 + channel: 1 + tlc59208f_id: tlc59208f_3 + - platform: tlc59208f + id: tlc_8 + channel: 2 + tlc59208f_id: tlc59208f_3 diff --git a/tests/components/tlc59208f/test.esp32-ard.yaml b/tests/components/tlc59208f/test.esp32-ard.yaml index 2639de3b3d..63c3bd6afd 100644 --- a/tests/components/tlc59208f/test.esp32-ard.yaml +++ b/tests/components/tlc59208f/test.esp32-ard.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tlc59208f/test.esp32-c3-ard.yaml b/tests/components/tlc59208f/test.esp32-c3-ard.yaml index 923ea4b4a4..ee2c29ca4e 100644 --- a/tests/components/tlc59208f/test.esp32-c3-ard.yaml +++ b/tests/components/tlc59208f/test.esp32-c3-ard.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tlc59208f/test.esp32-c3-idf.yaml b/tests/components/tlc59208f/test.esp32-c3-idf.yaml index 923ea4b4a4..ee2c29ca4e 100644 --- a/tests/components/tlc59208f/test.esp32-c3-idf.yaml +++ b/tests/components/tlc59208f/test.esp32-c3-idf.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tlc59208f/test.esp32-idf.yaml b/tests/components/tlc59208f/test.esp32-idf.yaml index 2639de3b3d..63c3bd6afd 100644 --- a/tests/components/tlc59208f/test.esp32-idf.yaml +++ b/tests/components/tlc59208f/test.esp32-idf.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tlc59208f/test.esp8266-ard.yaml b/tests/components/tlc59208f/test.esp8266-ard.yaml index 923ea4b4a4..ee2c29ca4e 100644 --- a/tests/components/tlc59208f/test.esp8266-ard.yaml +++ b/tests/components/tlc59208f/test.esp8266-ard.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tlc59208f/test.rp2040-ard.yaml b/tests/components/tlc59208f/test.rp2040-ard.yaml index 923ea4b4a4..ee2c29ca4e 100644 --- a/tests/components/tlc59208f/test.rp2040-ard.yaml +++ b/tests/components/tlc59208f/test.rp2040-ard.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tm1621/common.yaml b/tests/components/tm1621/common.yaml new file mode 100644 index 0000000000..77f7ae74fe --- /dev/null +++ b/tests/components/tm1621/common.yaml @@ -0,0 +1,12 @@ +display: + - platform: tm1621 + id: tm1621_display + cs_pin: ${cs_pin} + data_pin: ${data_pin} + read_pin: ${read_pin} + write_pin: ${write_pin} + lambda: |- + it.printf(0, "%.1f", 20.0); + it.display_celsius(true); + it.printf(1, "%.1f", 20.0); + it.display_humidity(true); diff --git a/tests/components/tm1621/test.esp32-ard.yaml b/tests/components/tm1621/test.esp32-ard.yaml index 8eab46f000..0441e4bffe 100644 --- a/tests/components/tm1621/test.esp32-ard.yaml +++ b/tests/components/tm1621/test.esp32-ard.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 15 - data_pin: 14 - read_pin: 12 - write_pin: 13 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO16 + data_pin: GPIO17 + read_pin: GPIO12 + write_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1621/test.esp32-c3-ard.yaml b/tests/components/tm1621/test.esp32-c3-ard.yaml index cddd64f31f..562ced7485 100644 --- a/tests/components/tm1621/test.esp32-c3-ard.yaml +++ b/tests/components/tm1621/test.esp32-c3-ard.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 7 - data_pin: 4 - read_pin: 5 - write_pin: 6 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO6 + data_pin: GPIO7 + read_pin: GPIO2 + write_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tm1621/test.esp32-c3-idf.yaml b/tests/components/tm1621/test.esp32-c3-idf.yaml index cddd64f31f..562ced7485 100644 --- a/tests/components/tm1621/test.esp32-c3-idf.yaml +++ b/tests/components/tm1621/test.esp32-c3-idf.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 7 - data_pin: 4 - read_pin: 5 - write_pin: 6 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO6 + data_pin: GPIO7 + read_pin: GPIO2 + write_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tm1621/test.esp32-idf.yaml b/tests/components/tm1621/test.esp32-idf.yaml index 8eab46f000..0441e4bffe 100644 --- a/tests/components/tm1621/test.esp32-idf.yaml +++ b/tests/components/tm1621/test.esp32-idf.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 15 - data_pin: 14 - read_pin: 12 - write_pin: 13 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO16 + data_pin: GPIO17 + read_pin: GPIO12 + write_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1621/test.esp8266-ard.yaml b/tests/components/tm1621/test.esp8266-ard.yaml index 8eab46f000..ee7b62ce35 100644 --- a/tests/components/tm1621/test.esp8266-ard.yaml +++ b/tests/components/tm1621/test.esp8266-ard.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 15 - data_pin: 14 - read_pin: 12 - write_pin: 13 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO15 + data_pin: GPIO14 + read_pin: GPIO12 + write_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1621/test.rp2040-ard.yaml b/tests/components/tm1621/test.rp2040-ard.yaml index cddd64f31f..562ced7485 100644 --- a/tests/components/tm1621/test.rp2040-ard.yaml +++ b/tests/components/tm1621/test.rp2040-ard.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 7 - data_pin: 4 - read_pin: 5 - write_pin: 6 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO6 + data_pin: GPIO7 + read_pin: GPIO2 + write_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tm1637/common.yaml b/tests/components/tm1637/common.yaml new file mode 100644 index 0000000000..8d01e29877 --- /dev/null +++ b/tests/components/tm1637/common.yaml @@ -0,0 +1,7 @@ +display: + - platform: tm1637 + clk_pin: ${clk_pin} + dio_pin: ${dio_pin} + intensity: 3 + lambda: |- + it.print("1234"); diff --git a/tests/components/tm1637/test.esp32-ard.yaml b/tests/components/tm1637/test.esp32-ard.yaml index bf5f331cca..2c5786c47c 100644 --- a/tests/components/tm1637/test.esp32-ard.yaml +++ b/tests/components/tm1637/test.esp32-ard.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 15 - dio_pin: 14 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO14 + dio_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1637/test.esp32-c3-ard.yaml b/tests/components/tm1637/test.esp32-c3-ard.yaml index fa4c95b443..96f6708a3b 100644 --- a/tests/components/tm1637/test.esp32-c3-ard.yaml +++ b/tests/components/tm1637/test.esp32-c3-ard.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 5 - dio_pin: 4 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO4 + dio_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tm1637/test.esp32-c3-idf.yaml b/tests/components/tm1637/test.esp32-c3-idf.yaml index fa4c95b443..96f6708a3b 100644 --- a/tests/components/tm1637/test.esp32-c3-idf.yaml +++ b/tests/components/tm1637/test.esp32-c3-idf.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 5 - dio_pin: 4 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO4 + dio_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tm1637/test.esp32-idf.yaml b/tests/components/tm1637/test.esp32-idf.yaml index bf5f331cca..2c5786c47c 100644 --- a/tests/components/tm1637/test.esp32-idf.yaml +++ b/tests/components/tm1637/test.esp32-idf.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 15 - dio_pin: 14 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO14 + dio_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1637/test.esp8266-ard.yaml b/tests/components/tm1637/test.esp8266-ard.yaml index fa4c95b443..2c5786c47c 100644 --- a/tests/components/tm1637/test.esp8266-ard.yaml +++ b/tests/components/tm1637/test.esp8266-ard.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 5 - dio_pin: 4 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO14 + dio_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1637/test.rp2040-ard.yaml b/tests/components/tm1637/test.rp2040-ard.yaml index fa4c95b443..96f6708a3b 100644 --- a/tests/components/tm1637/test.rp2040-ard.yaml +++ b/tests/components/tm1637/test.rp2040-ard.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 5 - dio_pin: 4 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO4 + dio_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tmp102/common.yaml b/tests/components/tmp102/common.yaml new file mode 100644 index 0000000000..afc4a27fad --- /dev/null +++ b/tests/components/tmp102/common.yaml @@ -0,0 +1,8 @@ +i2c: + - id: i2c_tmp102 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tmp102 + name: TMP102 Temperature diff --git a/tests/components/tmp102/test.esp32-ard.yaml b/tests/components/tmp102/test.esp32-ard.yaml index 840bf7edb3..63c3bd6afd 100644 --- a/tests/components/tmp102/test.esp32-ard.yaml +++ b/tests/components/tmp102/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp102/test.esp32-c3-ard.yaml b/tests/components/tmp102/test.esp32-c3-ard.yaml index c1d35fca3f..ee2c29ca4e 100644 --- a/tests/components/tmp102/test.esp32-c3-ard.yaml +++ b/tests/components/tmp102/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp102/test.esp32-c3-idf.yaml b/tests/components/tmp102/test.esp32-c3-idf.yaml index c1d35fca3f..ee2c29ca4e 100644 --- a/tests/components/tmp102/test.esp32-c3-idf.yaml +++ b/tests/components/tmp102/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp102/test.esp32-idf.yaml b/tests/components/tmp102/test.esp32-idf.yaml index 840bf7edb3..63c3bd6afd 100644 --- a/tests/components/tmp102/test.esp32-idf.yaml +++ b/tests/components/tmp102/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp102/test.esp8266-ard.yaml b/tests/components/tmp102/test.esp8266-ard.yaml index c1d35fca3f..ee2c29ca4e 100644 --- a/tests/components/tmp102/test.esp8266-ard.yaml +++ b/tests/components/tmp102/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp102/test.rp2040-ard.yaml b/tests/components/tmp102/test.rp2040-ard.yaml index c1d35fca3f..ee2c29ca4e 100644 --- a/tests/components/tmp102/test.rp2040-ard.yaml +++ b/tests/components/tmp102/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp1075/common.yaml b/tests/components/tmp1075/common.yaml new file mode 100644 index 0000000000..4c4c6c6f35 --- /dev/null +++ b/tests/components/tmp1075/common.yaml @@ -0,0 +1,16 @@ +i2c: + - id: i2c_tmp1075 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tmp1075 + name: Temperature TMP1075 + conversion_rate: 27.5ms + alert: + limit_low: 50 + limit_high: 75 + fault_count: 1 + polarity: active_high + function: comparator + update_interval: 10s diff --git a/tests/components/tmp1075/test.esp32-ard.yaml b/tests/components/tmp1075/test.esp32-ard.yaml index 6c50d0da77..63c3bd6afd 100644 --- a/tests/components/tmp1075/test.esp32-ard.yaml +++ b/tests/components/tmp1075/test.esp32-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp1075/test.esp32-c3-ard.yaml b/tests/components/tmp1075/test.esp32-c3-ard.yaml index 99433aa655..ee2c29ca4e 100644 --- a/tests/components/tmp1075/test.esp32-c3-ard.yaml +++ b/tests/components/tmp1075/test.esp32-c3-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp1075/test.esp32-c3-idf.yaml b/tests/components/tmp1075/test.esp32-c3-idf.yaml index 99433aa655..ee2c29ca4e 100644 --- a/tests/components/tmp1075/test.esp32-c3-idf.yaml +++ b/tests/components/tmp1075/test.esp32-c3-idf.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp1075/test.esp32-idf.yaml b/tests/components/tmp1075/test.esp32-idf.yaml index 6c50d0da77..63c3bd6afd 100644 --- a/tests/components/tmp1075/test.esp32-idf.yaml +++ b/tests/components/tmp1075/test.esp32-idf.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp1075/test.esp8266-ard.yaml b/tests/components/tmp1075/test.esp8266-ard.yaml index 99433aa655..ee2c29ca4e 100644 --- a/tests/components/tmp1075/test.esp8266-ard.yaml +++ b/tests/components/tmp1075/test.esp8266-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp1075/test.rp2040-ard.yaml b/tests/components/tmp1075/test.rp2040-ard.yaml index 99433aa655..ee2c29ca4e 100644 --- a/tests/components/tmp1075/test.rp2040-ard.yaml +++ b/tests/components/tmp1075/test.rp2040-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp117/common.yaml b/tests/components/tmp117/common.yaml new file mode 100644 index 0000000000..f4a5688933 --- /dev/null +++ b/tests/components/tmp117/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_tmp117 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tmp117 + name: TMP117 Temperature + update_interval: 5s diff --git a/tests/components/tmp117/test.esp32-ard.yaml b/tests/components/tmp117/test.esp32-ard.yaml index 03e0dd4e8e..63c3bd6afd 100644 --- a/tests/components/tmp117/test.esp32-ard.yaml +++ b/tests/components/tmp117/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tmp117/test.esp32-c3-ard.yaml b/tests/components/tmp117/test.esp32-c3-ard.yaml index 61fc2cc03d..ee2c29ca4e 100644 --- a/tests/components/tmp117/test.esp32-c3-ard.yaml +++ b/tests/components/tmp117/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tmp117/test.esp32-c3-idf.yaml b/tests/components/tmp117/test.esp32-c3-idf.yaml index 61fc2cc03d..ee2c29ca4e 100644 --- a/tests/components/tmp117/test.esp32-c3-idf.yaml +++ b/tests/components/tmp117/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tmp117/test.esp32-idf.yaml b/tests/components/tmp117/test.esp32-idf.yaml index 03e0dd4e8e..63c3bd6afd 100644 --- a/tests/components/tmp117/test.esp32-idf.yaml +++ b/tests/components/tmp117/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tmp117/test.esp8266-ard.yaml b/tests/components/tmp117/test.esp8266-ard.yaml index 61fc2cc03d..ee2c29ca4e 100644 --- a/tests/components/tmp117/test.esp8266-ard.yaml +++ b/tests/components/tmp117/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tmp117/test.rp2040-ard.yaml b/tests/components/tmp117/test.rp2040-ard.yaml index 61fc2cc03d..ee2c29ca4e 100644 --- a/tests/components/tmp117/test.rp2040-ard.yaml +++ b/tests/components/tmp117/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/common.yaml b/tests/components/tof10120/common.yaml new file mode 100644 index 0000000000..67643323d9 --- /dev/null +++ b/tests/components/tof10120/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_tof10120 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tof10120 + name: Distance sensor + update_interval: 5s diff --git a/tests/components/tof10120/test.esp32-ard.yaml b/tests/components/tof10120/test.esp32-ard.yaml index 74541ecde8..63c3bd6afd 100644 --- a/tests/components/tof10120/test.esp32-ard.yaml +++ b/tests/components/tof10120/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/test.esp32-c3-ard.yaml b/tests/components/tof10120/test.esp32-c3-ard.yaml index 01cde0df6a..ee2c29ca4e 100644 --- a/tests/components/tof10120/test.esp32-c3-ard.yaml +++ b/tests/components/tof10120/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/test.esp32-c3-idf.yaml b/tests/components/tof10120/test.esp32-c3-idf.yaml index 01cde0df6a..ee2c29ca4e 100644 --- a/tests/components/tof10120/test.esp32-c3-idf.yaml +++ b/tests/components/tof10120/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/test.esp32-idf.yaml b/tests/components/tof10120/test.esp32-idf.yaml index 74541ecde8..63c3bd6afd 100644 --- a/tests/components/tof10120/test.esp32-idf.yaml +++ b/tests/components/tof10120/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/test.esp8266-ard.yaml b/tests/components/tof10120/test.esp8266-ard.yaml index 01cde0df6a..ee2c29ca4e 100644 --- a/tests/components/tof10120/test.esp8266-ard.yaml +++ b/tests/components/tof10120/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/test.rp2040-ard.yaml b/tests/components/tof10120/test.rp2040-ard.yaml index 01cde0df6a..ee2c29ca4e 100644 --- a/tests/components/tof10120/test.rp2040-ard.yaml +++ b/tests/components/tof10120/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/toshiba/common.yaml b/tests/components/toshiba/common.yaml new file mode 100644 index 0000000000..79a833980e --- /dev/null +++ b/tests/components/toshiba/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: toshiba + name: Toshiba Climate diff --git a/tests/components/toshiba/test.esp32-ard.yaml b/tests/components/toshiba/test.esp32-ard.yaml index c134c7f5bd..7b012aa64c 100644 --- a/tests/components/toshiba/test.esp32-ard.yaml +++ b/tests/components/toshiba/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: toshiba - name: Toshiba Climate +<<: !include common.yaml diff --git a/tests/components/toshiba/test.esp32-c3-ard.yaml b/tests/components/toshiba/test.esp32-c3-ard.yaml index c134c7f5bd..7b012aa64c 100644 --- a/tests/components/toshiba/test.esp32-c3-ard.yaml +++ b/tests/components/toshiba/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: toshiba - name: Toshiba Climate +<<: !include common.yaml diff --git a/tests/components/toshiba/test.esp32-c3-idf.yaml b/tests/components/toshiba/test.esp32-c3-idf.yaml index c134c7f5bd..7b012aa64c 100644 --- a/tests/components/toshiba/test.esp32-c3-idf.yaml +++ b/tests/components/toshiba/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: toshiba - name: Toshiba Climate +<<: !include common.yaml diff --git a/tests/components/toshiba/test.esp32-idf.yaml b/tests/components/toshiba/test.esp32-idf.yaml index c134c7f5bd..7b012aa64c 100644 --- a/tests/components/toshiba/test.esp32-idf.yaml +++ b/tests/components/toshiba/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: toshiba - name: Toshiba Climate +<<: !include common.yaml diff --git a/tests/components/toshiba/test.esp8266-ard.yaml b/tests/components/toshiba/test.esp8266-ard.yaml index 8730a5d4ab..f5097fcf5f 100644 --- a/tests/components/toshiba/test.esp8266-ard.yaml +++ b/tests/components/toshiba/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: toshiba - name: Toshiba Climate +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/common.yaml b/tests/components/total_daily_energy/common.yaml new file mode 100644 index 0000000000..ae4d30408b --- /dev/null +++ b/tests/components/total_daily_energy/common.yaml @@ -0,0 +1,32 @@ +wifi: + ssid: MySSID + password: password1 + +time: + - platform: sntp + id: sntp_time + +sensor: + - platform: hlw8012 + sel_pin: ${sel_pin} + cf_pin: ${cf_pin} + cf1_pin: ${cf1_pin} + current: + name: HLW8012 Current + voltage: + name: HLW8012 Voltage + power: + name: HLW8012 Power + id: hlw8012_power + energy: + name: HLW8012 Energy + id: hlw8012_energy + update_interval: 15s + current_resistor: 0.001 ohm + voltage_divider: 2351 + change_mode_every: "never" + initial_mode: VOLTAGE + model: hlw8012 + - platform: total_daily_energy + name: HLW8012 Total Daily Energy + power_id: hlw8012_power diff --git a/tests/components/total_daily_energy/test.esp32-ard.yaml b/tests/components/total_daily_energy/test.esp32-ard.yaml index 34d452aae5..8b42b21b54 100644 --- a/tests/components/total_daily_energy/test.esp32-ard.yaml +++ b/tests/components/total_daily_energy/test.esp32-ard.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO12 + cf_pin: GPIO13 + cf1_pin: GPIO14 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 15 - cf_pin: 14 - cf1_pin: 13 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/test.esp32-c3-ard.yaml b/tests/components/total_daily_energy/test.esp32-c3-ard.yaml index 71afa45ed5..8b0d069ce2 100644 --- a/tests/components/total_daily_energy/test.esp32-c3-ard.yaml +++ b/tests/components/total_daily_energy/test.esp32-c3-ard.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO2 + cf_pin: GPIO3 + cf1_pin: GPIO4 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 5 - cf_pin: 4 - cf1_pin: 3 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/test.esp32-c3-idf.yaml b/tests/components/total_daily_energy/test.esp32-c3-idf.yaml index 71afa45ed5..8b0d069ce2 100644 --- a/tests/components/total_daily_energy/test.esp32-c3-idf.yaml +++ b/tests/components/total_daily_energy/test.esp32-c3-idf.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO2 + cf_pin: GPIO3 + cf1_pin: GPIO4 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 5 - cf_pin: 4 - cf1_pin: 3 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/test.esp32-idf.yaml b/tests/components/total_daily_energy/test.esp32-idf.yaml index 34d452aae5..8b42b21b54 100644 --- a/tests/components/total_daily_energy/test.esp32-idf.yaml +++ b/tests/components/total_daily_energy/test.esp32-idf.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO12 + cf_pin: GPIO13 + cf1_pin: GPIO14 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 15 - cf_pin: 14 - cf1_pin: 13 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/test.esp8266-ard.yaml b/tests/components/total_daily_energy/test.esp8266-ard.yaml index 34d452aae5..8b42b21b54 100644 --- a/tests/components/total_daily_energy/test.esp8266-ard.yaml +++ b/tests/components/total_daily_energy/test.esp8266-ard.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO12 + cf_pin: GPIO13 + cf1_pin: GPIO14 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 15 - cf_pin: 14 - cf1_pin: 13 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/test.rp2040-ard.yaml b/tests/components/total_daily_energy/test.rp2040-ard.yaml index 71afa45ed5..8b0d069ce2 100644 --- a/tests/components/total_daily_energy/test.rp2040-ard.yaml +++ b/tests/components/total_daily_energy/test.rp2040-ard.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO2 + cf_pin: GPIO3 + cf1_pin: GPIO4 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 5 - cf_pin: 4 - cf1_pin: 3 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/tsl2561/common.yaml b/tests/components/tsl2561/common.yaml new file mode 100644 index 0000000000..d2b4f75df3 --- /dev/null +++ b/tests/components/tsl2561/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_tsl2561 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tsl2561 + name: TSL2561 Ambient Light + address: 0x39 + is_cs_package: true + integration_time: 402ms + gain: 16x + update_interval: 15s diff --git a/tests/components/tsl2561/test.esp32-ard.yaml b/tests/components/tsl2561/test.esp32-ard.yaml index 8d43c62414..63c3bd6afd 100644 --- a/tests/components/tsl2561/test.esp32-ard.yaml +++ b/tests/components/tsl2561/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2561/test.esp32-c3-ard.yaml b/tests/components/tsl2561/test.esp32-c3-ard.yaml index 1ea768c5d9..ee2c29ca4e 100644 --- a/tests/components/tsl2561/test.esp32-c3-ard.yaml +++ b/tests/components/tsl2561/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2561/test.esp32-c3-idf.yaml b/tests/components/tsl2561/test.esp32-c3-idf.yaml index 1ea768c5d9..ee2c29ca4e 100644 --- a/tests/components/tsl2561/test.esp32-c3-idf.yaml +++ b/tests/components/tsl2561/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2561/test.esp32-idf.yaml b/tests/components/tsl2561/test.esp32-idf.yaml index 8d43c62414..63c3bd6afd 100644 --- a/tests/components/tsl2561/test.esp32-idf.yaml +++ b/tests/components/tsl2561/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2561/test.esp8266-ard.yaml b/tests/components/tsl2561/test.esp8266-ard.yaml index 1ea768c5d9..ee2c29ca4e 100644 --- a/tests/components/tsl2561/test.esp8266-ard.yaml +++ b/tests/components/tsl2561/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2561/test.rp2040-ard.yaml b/tests/components/tsl2561/test.rp2040-ard.yaml index 1ea768c5d9..ee2c29ca4e 100644 --- a/tests/components/tsl2561/test.rp2040-ard.yaml +++ b/tests/components/tsl2561/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/common.yaml b/tests/components/tsl2591/common.yaml new file mode 100644 index 0000000000..d58c46fb48 --- /dev/null +++ b/tests/components/tsl2591/common.yaml @@ -0,0 +1,25 @@ +i2c: + - id: i2c_tsl2591 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tsl2591 + id: test_tsl2591 + address: 0x29 + integration_time: 600ms + gain: high + visible: + name: tsl2591 visible + id: tsl2591_vis + unit_of_measurement: pH + infrared: + name: tsl2591 infrared + id: tsl2591_ir + full_spectrum: + name: tsl2591 full_spectrum + id: tsl2591_fs + calculated_lux: + name: tsl2591 calculated_lux + id: tsl2591_cl + update_interval: 15s diff --git a/tests/components/tsl2591/test.esp32-ard.yaml b/tests/components/tsl2591/test.esp32-ard.yaml index 14f9311ae6..63c3bd6afd 100644 --- a/tests/components/tsl2591/test.esp32-ard.yaml +++ b/tests/components/tsl2591/test.esp32-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/test.esp32-c3-ard.yaml b/tests/components/tsl2591/test.esp32-c3-ard.yaml index de57ef548a..ee2c29ca4e 100644 --- a/tests/components/tsl2591/test.esp32-c3-ard.yaml +++ b/tests/components/tsl2591/test.esp32-c3-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/test.esp32-c3-idf.yaml b/tests/components/tsl2591/test.esp32-c3-idf.yaml index de57ef548a..ee2c29ca4e 100644 --- a/tests/components/tsl2591/test.esp32-c3-idf.yaml +++ b/tests/components/tsl2591/test.esp32-c3-idf.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/test.esp32-idf.yaml b/tests/components/tsl2591/test.esp32-idf.yaml index 14f9311ae6..63c3bd6afd 100644 --- a/tests/components/tsl2591/test.esp32-idf.yaml +++ b/tests/components/tsl2591/test.esp32-idf.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/test.esp8266-ard.yaml b/tests/components/tsl2591/test.esp8266-ard.yaml index de57ef548a..ee2c29ca4e 100644 --- a/tests/components/tsl2591/test.esp8266-ard.yaml +++ b/tests/components/tsl2591/test.esp8266-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/test.rp2040-ard.yaml b/tests/components/tsl2591/test.rp2040-ard.yaml index de57ef548a..ee2c29ca4e 100644 --- a/tests/components/tsl2591/test.rp2040-ard.yaml +++ b/tests/components/tsl2591/test.rp2040-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tt21100/common.yaml b/tests/components/tt21100/common.yaml new file mode 100644 index 0000000000..a5d7970429 --- /dev/null +++ b/tests/components/tt21100/common.yaml @@ -0,0 +1,25 @@ +i2c: + - id: i2c_tt21100 + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1306_i2c + id: ssd1306_display + model: SSD1306_128X64 + reset_pin: ${disp_reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + +touchscreen: + - platform: tt21100 + display: ssd1306_display + interrupt_pin: ${interrupt_pin} + reset_pin: ${reset_pin} + +binary_sensor: + - platform: tt21100 + name: Home Button + index: 1 diff --git a/tests/components/tt21100/test.esp32-ard.yaml b/tests/components/tt21100/test.esp32-ard.yaml index 2419b0ad6a..05598719f9 100644 --- a/tests/components/tt21100/test.esp32-ard.yaml +++ b/tests/components/tt21100/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 16 - sda: 17 +substitutions: + disp_reset_pin: GPIO12 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 14 - reset_pin: 15 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/tt21100/test.esp32-c3-ard.yaml b/tests/components/tt21100/test.esp32-c3-ard.yaml index 17b8c8065a..36a8ce2778 100644 --- a/tests/components/tt21100/test.esp32-c3-ard.yaml +++ b/tests/components/tt21100/test.esp32-c3-ard.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 5 - sda: 4 +substitutions: + disp_reset_pin: GPIO10 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 6 - reset_pin: 7 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/tt21100/test.esp32-c3-idf.yaml b/tests/components/tt21100/test.esp32-c3-idf.yaml index 17b8c8065a..36a8ce2778 100644 --- a/tests/components/tt21100/test.esp32-c3-idf.yaml +++ b/tests/components/tt21100/test.esp32-c3-idf.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 5 - sda: 4 +substitutions: + disp_reset_pin: GPIO10 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 6 - reset_pin: 7 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/tt21100/test.esp32-idf.yaml b/tests/components/tt21100/test.esp32-idf.yaml index 2419b0ad6a..05598719f9 100644 --- a/tests/components/tt21100/test.esp32-idf.yaml +++ b/tests/components/tt21100/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 16 - sda: 17 +substitutions: + disp_reset_pin: GPIO12 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 14 - reset_pin: 15 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/tt21100/test.esp32-s2-ard.yaml b/tests/components/tt21100/test.esp32-s2-ard.yaml deleted file mode 100644 index 86b9e7530d..0000000000 --- a/tests/components/tt21100/test.esp32-s2-ard.yaml +++ /dev/null @@ -1,44 +0,0 @@ -i2c: - sda: GPIO8 - scl: GPIO18 - -spi: - clk_pin: 7 - mosi_pin: 11 - miso_pin: 9 - -display: - - platform: ili9xxx - id: my_display - model: ili9341 - cs_pin: 5 - dc_pin: 12 - reset_pin: 33 - auto_clear_enabled: false - data_rate: 40MHz - dimensions: 320x240 - update_interval: never - invert_colors: false - transform: - mirror_y: false - mirror_x: false - swap_xy: true - -touchscreen: - - platform: tt21100 - address: 0x24 - interrupt_pin: GPIO3 - on_touch: - - logger.log: "Touchscreen:: Touched" - -binary_sensor: - - platform: tt21100 - index: 0 - name: "Home" - - - platform: touchscreen - name: FanLo - x_min: 0 - x_max: 105 - y_min: 0 - y_max: 80 diff --git a/tests/components/tt21100/test.esp8266-ard.yaml b/tests/components/tt21100/test.esp8266-ard.yaml index 1393019417..05598719f9 100644 --- a/tests/components/tt21100/test.esp8266-ard.yaml +++ b/tests/components/tt21100/test.esp8266-ard.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 5 - sda: 4 +substitutions: + disp_reset_pin: GPIO12 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 14 - reset_pin: 15 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/tt21100/test.rp2040-ard.yaml b/tests/components/tt21100/test.rp2040-ard.yaml index 17b8c8065a..36a8ce2778 100644 --- a/tests/components/tt21100/test.rp2040-ard.yaml +++ b/tests/components/tt21100/test.rp2040-ard.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 5 - sda: 4 +substitutions: + disp_reset_pin: GPIO10 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 6 - reset_pin: 7 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/common.yaml b/tests/components/ttp229_bsf/common.yaml new file mode 100644 index 0000000000..42c26a5d51 --- /dev/null +++ b/tests/components/ttp229_bsf/common.yaml @@ -0,0 +1,8 @@ +ttp229_bsf: + scl_pin: ${scl_pin} + sdo_pin: ${sdo_pin} + +binary_sensor: + - platform: ttp229_bsf + name: TTP229 Channel 0 + channel: 0 diff --git a/tests/components/ttp229_bsf/test.esp32-ard.yaml b/tests/components/ttp229_bsf/test.esp32-ard.yaml index edee6d164e..80ed75293f 100644 --- a/tests/components/ttp229_bsf/test.esp32-ard.yaml +++ b/tests/components/ttp229_bsf/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 16 - sdo_pin: 17 +substitutions: + scl_pin: GPIO16 + sdo_pin: GPIO17 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/test.esp32-c3-ard.yaml b/tests/components/ttp229_bsf/test.esp32-c3-ard.yaml index 2006061c6e..135b213edc 100644 --- a/tests/components/ttp229_bsf/test.esp32-c3-ard.yaml +++ b/tests/components/ttp229_bsf/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 5 - sdo_pin: 4 +substitutions: + scl_pin: GPIO5 + sdo_pin: GPIO4 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/test.esp32-c3-idf.yaml b/tests/components/ttp229_bsf/test.esp32-c3-idf.yaml index 2006061c6e..135b213edc 100644 --- a/tests/components/ttp229_bsf/test.esp32-c3-idf.yaml +++ b/tests/components/ttp229_bsf/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 5 - sdo_pin: 4 +substitutions: + scl_pin: GPIO5 + sdo_pin: GPIO4 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/test.esp32-idf.yaml b/tests/components/ttp229_bsf/test.esp32-idf.yaml index edee6d164e..80ed75293f 100644 --- a/tests/components/ttp229_bsf/test.esp32-idf.yaml +++ b/tests/components/ttp229_bsf/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 16 - sdo_pin: 17 +substitutions: + scl_pin: GPIO16 + sdo_pin: GPIO17 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/test.esp8266-ard.yaml b/tests/components/ttp229_bsf/test.esp8266-ard.yaml index 2006061c6e..135b213edc 100644 --- a/tests/components/ttp229_bsf/test.esp8266-ard.yaml +++ b/tests/components/ttp229_bsf/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 5 - sdo_pin: 4 +substitutions: + scl_pin: GPIO5 + sdo_pin: GPIO4 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/test.rp2040-ard.yaml b/tests/components/ttp229_bsf/test.rp2040-ard.yaml index 2006061c6e..135b213edc 100644 --- a/tests/components/ttp229_bsf/test.rp2040-ard.yaml +++ b/tests/components/ttp229_bsf/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 5 - sdo_pin: 4 +substitutions: + scl_pin: GPIO5 + sdo_pin: GPIO4 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/common.yaml b/tests/components/ttp229_lsf/common.yaml new file mode 100644 index 0000000000..5c0dbf9517 --- /dev/null +++ b/tests/components/ttp229_lsf/common.yaml @@ -0,0 +1,11 @@ +i2c: + - id: i2c_ttp229_lsf + scl: ${scl_pin} + sda: ${sda_pin} + +ttp229_lsf: + +binary_sensor: + - platform: ttp229_lsf + name: TTP229 Channel 0 + channel: 0 diff --git a/tests/components/ttp229_lsf/test.esp32-ard.yaml b/tests/components/ttp229_lsf/test.esp32-ard.yaml index 81fb965883..63c3bd6afd 100644 --- a/tests/components/ttp229_lsf/test.esp32-ard.yaml +++ b/tests/components/ttp229_lsf/test.esp32-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/test.esp32-c3-ard.yaml b/tests/components/ttp229_lsf/test.esp32-c3-ard.yaml index 3927aff40e..ee2c29ca4e 100644 --- a/tests/components/ttp229_lsf/test.esp32-c3-ard.yaml +++ b/tests/components/ttp229_lsf/test.esp32-c3-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/test.esp32-c3-idf.yaml b/tests/components/ttp229_lsf/test.esp32-c3-idf.yaml index 3927aff40e..ee2c29ca4e 100644 --- a/tests/components/ttp229_lsf/test.esp32-c3-idf.yaml +++ b/tests/components/ttp229_lsf/test.esp32-c3-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/test.esp32-idf.yaml b/tests/components/ttp229_lsf/test.esp32-idf.yaml index 81fb965883..63c3bd6afd 100644 --- a/tests/components/ttp229_lsf/test.esp32-idf.yaml +++ b/tests/components/ttp229_lsf/test.esp32-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/test.esp8266-ard.yaml b/tests/components/ttp229_lsf/test.esp8266-ard.yaml index 3927aff40e..ee2c29ca4e 100644 --- a/tests/components/ttp229_lsf/test.esp8266-ard.yaml +++ b/tests/components/ttp229_lsf/test.esp8266-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/test.rp2040-ard.yaml b/tests/components/ttp229_lsf/test.rp2040-ard.yaml index 3927aff40e..ee2c29ca4e 100644 --- a/tests/components/ttp229_lsf/test.rp2040-ard.yaml +++ b/tests/components/ttp229_lsf/test.rp2040-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/tuya/common.yaml b/tests/components/tuya/common.yaml new file mode 100644 index 0000000000..fcf8a2d96b --- /dev/null +++ b/tests/components/tuya/common.yaml @@ -0,0 +1,78 @@ +wifi: + ssid: MySSID + password: password1 + +uart: + - id: uart_tuya + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +tuya: + status_pin: + number: ${status_pin} + inverted: true + on_datapoint_update: + - sensor_datapoint: 6 + datapoint_type: raw + then: + - logger.log: Datapoint 6 updated + +binary_sensor: + - platform: tuya + id: tuya_binary_sensor + sensor_datapoint: 1 + +climate: + - platform: tuya + id: tuya_climate + switch_datapoint: 1 + target_temperature_datapoint: 3 + current_temperature_multiplier: 0.5 + target_temperature_multiplier: 0.5 + reports_fahrenheit: true + +cover: + - platform: tuya + id: tuya_cover + position_datapoint: 2 + +light: + - platform: tuya + id: tuya_light + switch_datapoint: 1 + dimmer_datapoint: 2 + min_value_datapoint: 3 + color_temperature_datapoint: 4 + min_value: 1 + max_value: 100 + cold_white_color_temperature: 153 mireds + warm_white_color_temperature: 500 mireds + gamma_correct: 1 + +number: + - platform: tuya + id: tuya_number + number_datapoint: 102 + min_value: 0 + max_value: 17 + step: 1 + +select: + - platform: tuya + id: tuya_select + enum_datapoint: 42 + options: + 0: Internal + 1: Floor + 2: Both + +sensor: + - platform: tuya + id: tuya_sensor + sensor_datapoint: 1 + +switch: + - platform: tuya + id: tuya_switch + switch_datapoint: 1 diff --git a/tests/components/tuya/test.esp32-ard.yaml b/tests/components/tuya/test.esp32-ard.yaml index 9105522dcd..926a46cf73 100644 --- a/tests/components/tuya/test.esp32-ard.yaml +++ b/tests/components/tuya/test.esp32-ard.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 + status_pin: GPIO12 -uart: - - id: uart_tuya - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -tuya: - status_pin: - number: 15 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml diff --git a/tests/components/tuya/test.esp32-c3-ard.yaml b/tests/components/tuya/test.esp32-c3-ard.yaml index 4892e807b1..c62a0b10f6 100644 --- a/tests/components/tuya/test.esp32-c3-ard.yaml +++ b/tests/components/tuya/test.esp32-c3-ard.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + status_pin: GPIO2 -uart: - - id: uart_tuya - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -tuya: - status_pin: - number: 6 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml diff --git a/tests/components/tuya/test.esp32-c3-idf.yaml b/tests/components/tuya/test.esp32-c3-idf.yaml index 4892e807b1..c62a0b10f6 100644 --- a/tests/components/tuya/test.esp32-c3-idf.yaml +++ b/tests/components/tuya/test.esp32-c3-idf.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + status_pin: GPIO2 -uart: - - id: uart_tuya - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -tuya: - status_pin: - number: 6 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml diff --git a/tests/components/tuya/test.esp32-idf.yaml b/tests/components/tuya/test.esp32-idf.yaml index 9105522dcd..926a46cf73 100644 --- a/tests/components/tuya/test.esp32-idf.yaml +++ b/tests/components/tuya/test.esp32-idf.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 + status_pin: GPIO12 -uart: - - id: uart_tuya - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -tuya: - status_pin: - number: 15 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml diff --git a/tests/components/tuya/test.esp8266-ard.yaml b/tests/components/tuya/test.esp8266-ard.yaml index 56177fb982..11d46ed50e 100644 --- a/tests/components/tuya/test.esp8266-ard.yaml +++ b/tests/components/tuya/test.esp8266-ard.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + status_pin: GPIO12 -uart: - - id: uart_tuya - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -tuya: - status_pin: - number: 16 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml diff --git a/tests/components/tuya/test.rp2040-ard.yaml b/tests/components/tuya/test.rp2040-ard.yaml index 4892e807b1..11d46ed50e 100644 --- a/tests/components/tuya/test.rp2040-ard.yaml +++ b/tests/components/tuya/test.rp2040-ard.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + status_pin: GPIO12 -uart: - - id: uart_tuya - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -tuya: - status_pin: - number: 6 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml From 0cd3af2fcd475d4e724669de10b2ec0710ca60ab Mon Sep 17 00:00:00 2001 From: guillempages Date: Mon, 10 Feb 2025 01:17:29 +0100 Subject: [PATCH 172/194] [online_image]Pin specific version of JPEG library (#8217) --- esphome/components/online_image/__init__.py | 2 +- platformio.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/online_image/__init__.py b/esphome/components/online_image/__init__.py index c476270571..6b69bc240b 100644 --- a/esphome/components/online_image/__init__.py +++ b/esphome/components/online_image/__init__.py @@ -66,7 +66,7 @@ class JPEGFormat(Format): def actions(self): cg.add_define("USE_ONLINE_IMAGE_JPEG_SUPPORT") - cg.add_library("JPEGDEC", "1.6.2", "https://github.com/bitbank2/JPEGDEC") + cg.add_library("JPEGDEC", None, "https://github.com/bitbank2/JPEGDEC#ca1e0f2") class PNGFormat(Format): diff --git a/platformio.ini b/platformio.ini index cf11139b73..4153310480 100644 --- a/platformio.ini +++ b/platformio.ini @@ -42,7 +42,7 @@ lib_deps = pavlodn/HaierProtocol@0.9.31 ; haier kikuchan98/pngle@1.0.2 ; online_image ; Using the repository directly, otherwise ESP-IDF can't use the library - https://github.com/bitbank2/JPEGDEC.git#1.6.2 ; online_image + https://github.com/bitbank2/JPEGDEC.git#ca1e0f2 ; online_image ; This is using the repository until a new release is published to PlatformIO https://github.com/Sensirion/arduino-gas-index-algorithm.git#3.2.1 ; Sensirion Gas Index Algorithm Arduino Library lvgl/lvgl@8.4.0 ; lvgl From ff7d232ee6ed86b69e7abfa139a8d83af07c620b Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 10 Feb 2025 13:53:26 +1100 Subject: [PATCH 173/194] [logger] Add runtime level select (#8222) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- CODEOWNERS | 1 + esphome/components/logger/__init__.py | 48 ++++++++++++++++--- esphome/components/logger/logger.cpp | 27 ++++++----- esphome/components/logger/logger.h | 18 ++++--- esphome/components/logger/select/__init__.py | 29 +++++++++++ .../logger/select/logger_level_select.cpp | 27 +++++++++++ .../logger/select/logger_level_select.h | 15 ++++++ esphome/core/defines.h | 3 ++ .../logger/common-default_uart.yaml | 12 ++++- 9 files changed, 154 insertions(+), 26 deletions(-) create mode 100644 esphome/components/logger/select/__init__.py create mode 100644 esphome/components/logger/select/logger_level_select.cpp create mode 100644 esphome/components/logger/select/logger_level_select.h diff --git a/CODEOWNERS b/CODEOWNERS index eab02efffb..d4b3d7eff9 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -242,6 +242,7 @@ esphome/components/lightwaverf/* @max246 esphome/components/lilygo_t5_47/touchscreen/* @jesserockz esphome/components/lock/* @esphome/core esphome/components/logger/* @esphome/core +esphome/components/logger/select/* @clydebarrow esphome/components/ltr390/* @latonita @sjtrny esphome/components/ltr501/* @latonita esphome/components/ltr_als_ps/* @latonita diff --git a/esphome/components/logger/__init__.py b/esphome/components/logger/__init__.py index 6e92777058..a89bf95c77 100644 --- a/esphome/components/logger/__init__.py +++ b/esphome/components/logger/__init__.py @@ -35,7 +35,7 @@ from esphome.const import ( PLATFORM_RP2040, PLATFORM_RTL87XX, ) -from esphome.core import CORE, EsphomeError, Lambda, coroutine_with_priority +from esphome.core import CORE, Lambda, coroutine_with_priority CODEOWNERS = ["@esphome/core"] logger_ns = cg.esphome_ns.namespace("logger") @@ -77,6 +77,9 @@ USB_SERIAL_JTAG = "USB_SERIAL_JTAG" USB_CDC = "USB_CDC" DEFAULT = "DEFAULT" +CONF_INITIAL_LEVEL = "initial_level" +CONF_LOGGER_ID = "logger_id" + UART_SELECTION_ESP32 = { VARIANT_ESP32: [UART0, UART1, UART2], VARIANT_ESP32S2: [UART0, UART1, USB_CDC], @@ -154,11 +157,11 @@ def uart_selection(value): def validate_local_no_higher_than_global(value): - global_level = value.get(CONF_LEVEL, "DEBUG") + global_level = LOG_LEVEL_SEVERITY.index(value[CONF_LEVEL]) for tag, level in value.get(CONF_LOGS, {}).items(): - if LOG_LEVEL_SEVERITY.index(level) > LOG_LEVEL_SEVERITY.index(global_level): - raise EsphomeError( - f"The local log level {level} for {tag} must be less severe than the global log level {global_level}." + if LOG_LEVEL_SEVERITY.index(level) > global_level: + raise cv.Invalid( + f"The configured log level for {tag} ({level}) must be no more severe than the global log level {value[CONF_LEVEL]}." ) return value @@ -209,6 +212,7 @@ CONFIG_SCHEMA = cv.All( cv.string: is_log_level, } ), + cv.Optional(CONF_INITIAL_LEVEL): is_log_level, cv.Optional(CONF_ON_MESSAGE): automation.validate_automation( { cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(LoggerMessageTrigger), @@ -227,7 +231,14 @@ CONFIG_SCHEMA = cv.All( @coroutine_with_priority(90.0) async def to_code(config): baud_rate = config[CONF_BAUD_RATE] - log = cg.new_Pvariable(config[CONF_ID], baud_rate, config[CONF_TX_BUFFER_SIZE]) + level = config[CONF_LEVEL] + initial_level = LOG_LEVELS[config.get(CONF_INITIAL_LEVEL, level)] + log = cg.new_Pvariable( + config[CONF_ID], + baud_rate, + config[CONF_TX_BUFFER_SIZE], + ) + cg.add(log.set_log_level(initial_level)) if CONF_HARDWARE_UART in config: cg.add( log.set_uart_selection( @@ -239,7 +250,6 @@ async def to_code(config): for tag, level in config[CONF_LOGS].items(): cg.add(log.set_log_level(tag, LOG_LEVELS[level])) - level = config[CONF_LEVEL] cg.add_define("USE_LOGGER") this_severity = LOG_LEVEL_SEVERITY.index(level) cg.add_build_flag(f"-DESPHOME_LOG_LEVEL={LOG_LEVELS[level]}") @@ -367,3 +377,27 @@ async def logger_log_action_to_code(config, action_id, template_arg, args): lambda_ = await cg.process_lambda(Lambda(text), args, return_type=cg.void) return cg.new_Pvariable(action_id, template_arg, lambda_) + + +@automation.register_action( + "logger.set_level", + LambdaAction, + cv.maybe_simple_value( + { + cv.GenerateID(CONF_LOGGER_ID): cv.use_id(Logger), + cv.Required(CONF_LEVEL): is_log_level, + cv.Optional(CONF_TAG): cv.string, + }, + key=CONF_LEVEL, + ), +) +async def logger_set_level_to_code(config, action_id, template_arg, args): + level = LOG_LEVELS[config[CONF_LEVEL]] + logger = await cg.get_variable(config[CONF_LOGGER_ID]) + if tag := config.get(CONF_TAG): + text = str(cg.statement(logger.set_log_level(tag, level))) + else: + text = str(cg.statement(logger.set_log_level(level))) + + lambda_ = await cg.process_lambda(Lambda(text), args, return_type=cg.void) + return cg.new_Pvariable(action_id, template_arg, lambda_) diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index 36934c7459..79fc4cf499 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -105,12 +105,9 @@ int HOT Logger::level_for(const char *tag) { // Uses std::vector<> for low memory footprint, though the vector // could be sorted to minimize lookup times. This feature isn't used that // much anyway so it doesn't matter too much. - for (auto &it : this->log_levels_) { - if (it.tag == tag) { - return it.level; - } - } - return ESPHOME_LOG_LEVEL; + if (this->log_levels_.count(tag) != 0) + return this->log_levels_[tag]; + return this->current_level_; } void HOT Logger::log_message_(int level, const char *tag, int offset) { @@ -167,9 +164,7 @@ void Logger::loop() { #endif void Logger::set_baud_rate(uint32_t baud_rate) { this->baud_rate_ = baud_rate; } -void Logger::set_log_level(const std::string &tag, int log_level) { - this->log_levels_.push_back(LogLevelOverride{tag, log_level}); -} +void Logger::set_log_level(const std::string &tag, int log_level) { this->log_levels_[tag] = log_level; } #if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) UARTSelection Logger::get_uart() const { return this->uart_; } @@ -183,18 +178,28 @@ const char *const LOG_LEVELS[] = {"NONE", "ERROR", "WARN", "INFO", "CONFIG", "DE void Logger::dump_config() { ESP_LOGCONFIG(TAG, "Logger:"); - ESP_LOGCONFIG(TAG, " Level: %s", LOG_LEVELS[ESPHOME_LOG_LEVEL]); + ESP_LOGCONFIG(TAG, " Max Level: %s", LOG_LEVELS[ESPHOME_LOG_LEVEL]); + ESP_LOGCONFIG(TAG, " Initial Level: %s", LOG_LEVELS[this->current_level_]); #ifndef USE_HOST ESP_LOGCONFIG(TAG, " Log Baud Rate: %" PRIu32, this->baud_rate_); ESP_LOGCONFIG(TAG, " Hardware UART: %s", get_uart_selection_()); #endif for (auto &it : this->log_levels_) { - ESP_LOGCONFIG(TAG, " Level for '%s': %s", it.tag.c_str(), LOG_LEVELS[it.level]); + ESP_LOGCONFIG(TAG, " Level for '%s': %s", it.first.c_str(), LOG_LEVELS[it.second]); } } void Logger::write_footer_() { this->write_to_buffer_(ESPHOME_LOG_RESET_COLOR, strlen(ESPHOME_LOG_RESET_COLOR)); } +void Logger::set_log_level(int level) { + if (level > ESPHOME_LOG_LEVEL) { + level = ESPHOME_LOG_LEVEL; + ESP_LOGW(TAG, "Cannot set log level higher than pre-compiled %s", LOG_LEVELS[ESPHOME_LOG_LEVEL]); + } + this->current_level_ = level; + this->level_callback_.call(level); +} + Logger *global_logger = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) } // namespace logger diff --git a/esphome/components/logger/logger.h b/esphome/components/logger/logger.h index b55cfb0771..c4c873e020 100644 --- a/esphome/components/logger/logger.h +++ b/esphome/components/logger/logger.h @@ -1,11 +1,12 @@ #pragma once #include -#include +#include #include "esphome/core/automation.h" #include "esphome/core/component.h" #include "esphome/core/defines.h" #include "esphome/core/helpers.h" +#include "esphome/core/log.h" #ifdef USE_ARDUINO #if defined(USE_ESP8266) || defined(USE_ESP32) @@ -74,8 +75,11 @@ class Logger : public Component { UARTSelection get_uart() const; #endif + /// Set the default log level for this logger. + void set_log_level(int level); /// Set the log level of the specified tag. void set_log_level(const std::string &tag, int log_level); + int get_log_level() { return this->current_level_; } // ========== INTERNAL METHODS ========== // (In most use cases you won't need these) @@ -88,6 +92,9 @@ class Logger : public Component { /// Register a callback that will be called for every log message sent void add_on_log_callback(std::function &&callback); + // add a listener for log level changes + void add_listener(std::function &&callback) { this->level_callback_.add(std::move(callback)); } + float get_setup_priority() const override; void log_vprintf_(int level, const char *tag, int line, const char *format, va_list args); // NOLINT @@ -159,17 +166,14 @@ class Logger : public Component { #ifdef USE_ESP_IDF uart_port_t uart_num_; #endif - struct LogLevelOverride { - std::string tag; - int level; - }; - std::vector log_levels_; + std::map log_levels_{}; CallbackManager log_callback_{}; + int current_level_{ESPHOME_LOG_LEVEL_VERY_VERBOSE}; /// Prevents recursive log calls, if true a log message is already being processed. bool recursion_guard_ = false; void *main_task_ = nullptr; + CallbackManager level_callback_{}; }; - extern Logger *global_logger; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) class LoggerMessageTrigger : public Trigger { diff --git a/esphome/components/logger/select/__init__.py b/esphome/components/logger/select/__init__.py new file mode 100644 index 0000000000..b1fc881537 --- /dev/null +++ b/esphome/components/logger/select/__init__.py @@ -0,0 +1,29 @@ +import esphome.codegen as cg +from esphome.components import select +import esphome.config_validation as cv +from esphome.const import CONF_LEVEL, CONF_LOGGER, ENTITY_CATEGORY_CONFIG, ICON_BUG +from esphome.core import CORE +from esphome.cpp_helpers import register_component, register_parented + +from .. import CONF_LOGGER_ID, LOG_LEVEL_SEVERITY, Logger, logger_ns + +CODEOWNERS = ["@clydebarrow"] + +LoggerLevelSelect = logger_ns.class_("LoggerLevelSelect", select.Select, cg.Component) + +CONFIG_SCHEMA = select.select_schema( + LoggerLevelSelect, icon=ICON_BUG, entity_category=ENTITY_CATEGORY_CONFIG +).extend( + { + cv.GenerateID(CONF_LOGGER_ID): cv.use_id(Logger), + } +) + + +async def to_code(config): + levels = LOG_LEVEL_SEVERITY + index = levels.index(CORE.config[CONF_LOGGER][CONF_LEVEL]) + levels = levels[: index + 1] + var = await select.new_select(config, options=levels) + await register_parented(var, config[CONF_LOGGER_ID]) + await register_component(var, config) diff --git a/esphome/components/logger/select/logger_level_select.cpp b/esphome/components/logger/select/logger_level_select.cpp new file mode 100644 index 0000000000..b71a6e02a2 --- /dev/null +++ b/esphome/components/logger/select/logger_level_select.cpp @@ -0,0 +1,27 @@ +#include "logger_level_select.h" + +namespace esphome { +namespace logger { + +void LoggerLevelSelect::publish_state(int level) { + auto value = this->at(level); + if (!value) { + return; + } + Select::publish_state(value.value()); +} + +void LoggerLevelSelect::setup() { + this->parent_->add_listener([this](int level) { this->publish_state(level); }); + this->publish_state(this->parent_->get_log_level()); +} + +void LoggerLevelSelect::control(const std::string &value) { + auto level = this->index_of(value); + if (!level) + return; + this->parent_->set_log_level(level.value()); +} + +} // namespace logger +} // namespace esphome diff --git a/esphome/components/logger/select/logger_level_select.h b/esphome/components/logger/select/logger_level_select.h new file mode 100644 index 0000000000..2c92c84d13 --- /dev/null +++ b/esphome/components/logger/select/logger_level_select.h @@ -0,0 +1,15 @@ +#pragma once + +#include "esphome/components/select/select.h" +#include "esphome/core/component.h" +#include "esphome/components/logger/logger.h" +namespace esphome { +namespace logger { +class LoggerLevelSelect : public Component, public select::Select, public Parented { + public: + void publish_state(int level); + void setup() override; + void control(const std::string &value) override; +}; +} // namespace logger +} // namespace esphome diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 8407391bce..dc0ac3c1e8 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -14,6 +14,9 @@ #define ESPHOME_PROJECT_VERSION_30 "v2" #define ESPHOME_VARIANT "ESP32" +// logger +#define ESPHOME_LOG_LEVEL ESPHOME_LOG_LEVEL_VERY_VERBOSE + // Feature flags #define USE_ALARM_CONTROL_PANEL #define USE_AUDIO_FLAC_SUPPORT diff --git a/tests/components/logger/common-default_uart.yaml b/tests/components/logger/common-default_uart.yaml index 70b485daac..e8b56043eb 100644 --- a/tests/components/logger/common-default_uart.yaml +++ b/tests/components/logger/common-default_uart.yaml @@ -1,7 +1,17 @@ esphome: on_boot: then: - - logger.log: Hello world + - logger.log: + level: warn + format: "Warning: Logger level is %d" + args: [id(logger_id).get_log_level()] + - logger.set_level: WARN logger: + id: logger_id level: DEBUG + initial_level: INFO + +select: + - platform: logger + name: Logger Level From 45b8810ab8a888a1cf43aae308770d159a87e25f Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sun, 9 Feb 2025 21:55:16 -0500 Subject: [PATCH 174/194] [online_image] Set Accept header (#8216) --- .../components/online_image/online_image.cpp | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index b08c14b721..da0e88a904 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -100,7 +100,35 @@ void OnlineImage::update() { } ESP_LOGI(TAG, "Updating image %s", this->url_.c_str()); - this->downloader_ = this->parent_->get(this->url_); + std::list headers = {}; + + http_request::Header accept_header; + accept_header.name = "Accept"; + std::string accept_mime_type; + switch (this->format_) { +#ifdef USE_ONLINE_IMAGE_BMP_SUPPORT + case ImageFormat::BMP: + accept_mime_type = "image/bmp"; + break; +#endif // ONLINE_IMAGE_BMP_SUPPORT +#ifdef USE_ONLINE_IMAGE_JPEG_SUPPORT + case ImageFormat::JPEG: + accept_mime_type = "image/jpeg"; + break; +#endif // USE_ONLINE_IMAGE_JPEG_SUPPORT +#ifdef USE_ONLINE_IMAGE_PNG_SUPPORT + case ImageFormat::PNG: + accept_mime_type = "image/png"; + break; +#endif // ONLINE_IMAGE_PNG_SUPPORT + default: + accept_mime_type = "image/*"; + } + accept_header.value = (accept_mime_type + ",*/*;q=0.8").c_str(); + + headers.push_back(accept_header); + + this->downloader_ = this->parent_->get(this->url_, headers); if (this->downloader_ == nullptr) { ESP_LOGE(TAG, "Download failed."); From 66c35a943244c3b279dc79741cb4e47422f39f84 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 10 Feb 2025 14:46:05 +1100 Subject: [PATCH 175/194] [waveshare_epaper] Rationalise and complete tests (#8221) --- .../components/waveshare_epaper/display.py | 4 +- tests/components/waveshare_epaper/common.yaml | 765 ++++++++++++++++-- .../waveshare_epaper/test.esp32-ard.yaml | 12 +- .../waveshare_epaper/test.esp32-c3-ard.yaml | 8 +- .../waveshare_epaper/test.esp32-c3-idf.yaml | 8 +- .../waveshare_epaper/test.esp32-idf.yaml | 8 +- .../waveshare_epaper/test.esp8266-ard.yaml | 8 +- .../waveshare_epaper/test.rp2040-ard.yaml | 6 +- 8 files changed, 709 insertions(+), 110 deletions(-) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index d5240b2674..3a5151682f 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -120,7 +120,7 @@ MODELS = { "2.13in-ttgo-b74": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B74), "2.90in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN), "2.90inv2": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN_V2), - "gdew029t5": ("c", GDEW029T5), + "gdew029t5": ("b", GDEW029T5), "2.70in": ("b", WaveshareEPaper2P7In), "2.70in-b": ("b", WaveshareEPaper2P7InB), "2.70in-bv2": ("b", WaveshareEPaper2P7InBV2), @@ -143,7 +143,7 @@ MODELS = { "7.50in-hd-b": ("b", WaveshareEPaper7P5InHDB), "2.13in-ttgo-dke": ("c", WaveshareEPaper2P13InDKE), "2.13inv3": ("c", WaveshareEPaper2P13InV3), - "1.54in-m5coreink-m09": ("c", GDEW0154M09), + "1.54in-m5coreink-m09": ("b", GDEW0154M09), "13.3in-k": ("b", WaveshareEPaper13P3InK), } diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index 92c443908e..ff9ddb955f 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -4,8 +4,150 @@ spi: mosi_pin: ${mosi_pin} display: + # 1.54 inch displays - platform: waveshare_epaper + id: epd_1_54 + model: 1.54in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_1_54v2 + model: 1.54inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_1_54v2b + model: 1.54inv2-b + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_1_54m09 + model: 1.54in-m5coreink-m09 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 2.13 inch displays + - platform: waveshare_epaper + id: epd_2_13 + model: 2.13in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_13v2 + model: 2.13inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_13ttgo + model: 2.13in-ttgo + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_13ttgo_b1 model: 2.13in-ttgo-b1 + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} @@ -21,8 +163,31 @@ display: full_update_every: 30 lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + id: epd_2_13ttgo_b73 + model: 2.13in-ttgo-b73 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_13ttgo_b74 model: 2.13in-ttgo-b74 + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} @@ -38,8 +203,129 @@ display: full_update_every: 30 lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + id: epd_2_13dke + model: 2.13in-ttgo-dke + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_13v3 + model: 2.13inv3 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 2.7 inch displays + - platform: waveshare_epaper + id: epd_2_70 + model: 2.70in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_70b + model: 2.70in-b + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_70bv2 + model: 2.70in-bv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_70v2 + model: 2.70inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 2.9 inch displays + - platform: waveshare_epaper + id: epd_2_90 model: 2.90in + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} @@ -56,8 +342,400 @@ display: reset_duration: 200ms lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_90v2 + model: 2.90inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + reset_duration: 200ms + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_90b + model: 2.90in-b + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_90bv3 + model: 2.90in-bv3 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_90v2r2 + model: 2.90inv2-r2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_90dke + model: 2.90in-dke + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + reset_duration: 200ms + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_gdew029t5 + model: gdew029t5 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 4.2 inch displays + - platform: waveshare_epaper + id: epd_4_20 + model: 4.20in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_4_20bv2 + model: 4.20in-bv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 5.83 inch displays + - platform: waveshare_epaper + id: epd_5_83 + model: 5.83in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_5_83v2 + model: 5.83inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 7.5 inch displays + - platform: waveshare_epaper + id: epd_7_50 + model: 7.50in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50bv2 + model: 7.50in-bv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50bv3 + model: 7.50in-bv3 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50bv3_bwr + model: 7.50in-bv3-bwr + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50bc + model: 7.50in-bc + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50v2 + model: 7.50inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50v2alt + model: 7.50inv2alt + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50hdb + model: 7.50in-hd-b + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 13.3 inch displays + - platform: waveshare_epaper + id: epd_13_3k + model: 13.3in-k + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + model: 2.90in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + reset_duration: 200ms + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper model: 2.90inv2 + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} @@ -73,25 +751,10 @@ display: full_update_every: 30 lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.90in-dke - cs_pin: - allow_other_uses: true - number: ${cs_pin} - dc_pin: - allow_other_uses: true - number: ${dc_pin} - busy_pin: - allow_other_uses: true - number: ${busy_pin} - reset_pin: - allow_other_uses: true - number: ${reset_pin} - full_update_every: 1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper model: 2.70in-b + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} @@ -106,74 +769,10 @@ display: number: ${reset_pin} lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper model: 2.70in-bv2 - cs_pin: - allow_other_uses: true - number: ${cs_pin} - dc_pin: - allow_other_uses: true - number: ${dc_pin} - busy_pin: - allow_other_uses: true - number: ${busy_pin} - reset_pin: - allow_other_uses: true - number: ${reset_pin} - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 1.54in-m5coreink-m09 - cs_pin: - allow_other_uses: true - number: ${cs_pin} - dc_pin: - allow_other_uses: true - number: ${dc_pin} - busy_pin: - allow_other_uses: true - number: ${busy_pin} - reset_pin: - allow_other_uses: true - number: ${reset_pin} - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.13inv3 - cs_pin: - allow_other_uses: true - number: ${cs_pin} - dc_pin: - allow_other_uses: true - number: ${dc_pin} - busy_pin: - allow_other_uses: true - number: ${busy_pin} - reset_pin: - allow_other_uses: true - number: ${reset_pin} - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.13inv2 - cs_pin: - allow_other_uses: true - number: ${cs_pin} - dc_pin: - allow_other_uses: true - number: ${dc_pin} - busy_pin: - allow_other_uses: true - number: ${busy_pin} - reset_pin: - allow_other_uses: true - number: ${reset_pin} - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 7.50in-bv3-bwr + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} diff --git a/tests/components/waveshare_epaper/test.esp32-ard.yaml b/tests/components/waveshare_epaper/test.esp32-ard.yaml index c658ea91ee..c36345b984 100644 --- a/tests/components/waveshare_epaper/test.esp32-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp32-ard.yaml @@ -1,9 +1,9 @@ substitutions: - clk_pin: GPIO16 - mosi_pin: GPIO17 - cs_pin: GPIO18 - dc_pin: GPIO19 - busy_pin: GPIO13 - reset_pin: GPIO14 + clk_pin: GPIO18 + mosi_pin: GPIO23 + cs_pin: GPIO25 + dc_pin: GPIO26 + busy_pin: GPIO27 + reset_pin: GPIO32 <<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml b/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml index e2873f0fe9..4cb230f6f2 100644 --- a/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml @@ -1,9 +1,9 @@ substitutions: clk_pin: GPIO6 mosi_pin: GPIO7 - cs_pin: GPIO0 - dc_pin: GPIO5 - busy_pin: GPIO3 - reset_pin: GPIO4 + cs_pin: GPIO4 + dc_pin: GPIO1 + busy_pin: GPIO2 + reset_pin: GPIO3 <<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml b/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml index e2873f0fe9..4cb230f6f2 100644 --- a/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml +++ b/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml @@ -1,9 +1,9 @@ substitutions: clk_pin: GPIO6 mosi_pin: GPIO7 - cs_pin: GPIO0 - dc_pin: GPIO5 - busy_pin: GPIO3 - reset_pin: GPIO4 + cs_pin: GPIO4 + dc_pin: GPIO1 + busy_pin: GPIO2 + reset_pin: GPIO3 <<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-idf.yaml b/tests/components/waveshare_epaper/test.esp32-idf.yaml index c658ea91ee..9e8b2fdec8 100644 --- a/tests/components/waveshare_epaper/test.esp32-idf.yaml +++ b/tests/components/waveshare_epaper/test.esp32-idf.yaml @@ -1,9 +1,9 @@ substitutions: clk_pin: GPIO16 mosi_pin: GPIO17 - cs_pin: GPIO18 - dc_pin: GPIO19 - busy_pin: GPIO13 - reset_pin: GPIO14 + cs_pin: GPIO4 + dc_pin: GPIO5 + busy_pin: GPIO18 + reset_pin: GPIO19 <<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp8266-ard.yaml b/tests/components/waveshare_epaper/test.esp8266-ard.yaml index bc178b7009..ee8199bcc0 100644 --- a/tests/components/waveshare_epaper/test.esp8266-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp8266-ard.yaml @@ -1,9 +1,9 @@ substitutions: clk_pin: GPIO14 mosi_pin: GPIO13 - cs_pin: GPIO15 - dc_pin: GPIO12 - busy_pin: GPIO5 - reset_pin: GPIO4 + cs_pin: GPIO4 + dc_pin: GPIO5 + busy_pin: GPIO15 + reset_pin: GPIO16 <<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.rp2040-ard.yaml b/tests/components/waveshare_epaper/test.rp2040-ard.yaml index 801b0b51c5..e92f6d421d 100644 --- a/tests/components/waveshare_epaper/test.rp2040-ard.yaml +++ b/tests/components/waveshare_epaper/test.rp2040-ard.yaml @@ -2,8 +2,8 @@ substitutions: clk_pin: GPIO2 mosi_pin: GPIO3 cs_pin: GPIO5 - dc_pin: GPIO4 - busy_pin: GPIO0 - reset_pin: GPIO1 + dc_pin: GPIO6 + busy_pin: GPIO7 + reset_pin: GPIO8 <<: !include common.yaml From fd24b1423c5957ee4c648904aa2d1a87467c1b27 Mon Sep 17 00:00:00 2001 From: Awesome Walrus <74941879+QRPp@users.noreply.github.com> Date: Mon, 10 Feb 2025 03:54:37 +0000 Subject: [PATCH 176/194] Fix pref conflict of WiFi creds and fast_connect (#8219) --- esphome/components/wifi/wifi_component.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index eef962b8c4..4a50553305 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -66,7 +66,7 @@ void WiFiComponent::start() { this->pref_ = global_preferences->make_preference(hash, true); if (this->fast_connect_) { - this->fast_connect_pref_ = global_preferences->make_preference(hash, false); + this->fast_connect_pref_ = global_preferences->make_preference(hash + 1, false); } SavedWifiSettings save{}; From 0d13e2040dbf0e488544fd357e38f88129155b67 Mon Sep 17 00:00:00 2001 From: Stefan Rado <628587+kroimon@users.noreply.github.com> Date: Mon, 10 Feb 2025 05:12:46 +0100 Subject: [PATCH 177/194] Don't activate venv in devcontainer (#8128) --- .pre-commit-config.yaml | 2 +- script/{run-in-env => run-in-env.py} | 36 +++++++++++++++++----------- 2 files changed, 23 insertions(+), 15 deletions(-) rename script/{run-in-env => run-in-env.py} (63%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index adf0ac6fc2..212d822ff8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,6 +45,6 @@ repos: hooks: - id: pylint name: pylint - entry: python script/run-in-env pylint + entry: python3 script/run-in-env.py pylint language: system types: [python] diff --git a/script/run-in-env b/script/run-in-env.py similarity index 63% rename from script/run-in-env rename to script/run-in-env.py index 57bfddccf7..57121266be 100644 --- a/script/run-in-env +++ b/script/run-in-env.py @@ -7,6 +7,13 @@ import sys def find_and_activate_virtualenv(): + if ( + ("VIRTUAL_ENV" in os.environ) + or os.environ.get("DEVCONTAINER", False) + or os.environ.get("ESPHOME_NO_VENV", False) + ): + return + try: # Get the top-level directory of the git repository my_path = subprocess.check_output( @@ -17,7 +24,7 @@ def find_and_activate_virtualenv(): "Error: Not a git repository or unable to determine the top-level directory.", file=sys.stderr, ) - sys.exit(1) + return # Check for virtual environments for venv in ["venv", ".venv", "."]: @@ -29,25 +36,26 @@ def find_and_activate_virtualenv(): ) if activate_path.exists(): # Activate the virtual environment by updating PATH - env = os.environ.copy() venv_bin_dir = activate_path.parent - env["PATH"] = f"{venv_bin_dir}{os.pathsep}{env['PATH']}" - env["VIRTUAL_ENV"] = str(venv_bin_dir.parent) + os.environ["PATH"] = f"{venv_bin_dir}{os.pathsep}{os.environ['PATH']}" + os.environ["VIRTUAL_ENV"] = str(venv_bin_dir.parent) print(f"Activated virtual environment: {venv_bin_dir.parent}") - - # Execute the remaining arguments in the new environment - if len(sys.argv) > 1: - subprocess.run(sys.argv[1:], env=env, check=False) - else: - print( - "No command provided to run in the virtual environment.", - file=sys.stderr, - ) return print("No virtual environment found.", file=sys.stderr) - sys.exit(1) + + +def run_command(): + # Execute the remaining arguments in the new environment + if len(sys.argv) > 1: + subprocess.run(sys.argv[1:], check=False) + else: + print( + "No command provided to run in the virtual environment.", + file=sys.stderr, + ) if __name__ == "__main__": find_and_activate_virtualenv() + run_command() From 1ab1768b6a21b0dd270706288a418f68df1fdb8c Mon Sep 17 00:00:00 2001 From: Igor Novgorodov Date: Mon, 10 Feb 2025 05:32:54 +0100 Subject: [PATCH 178/194] Add ADC sampling method option (#8131) Co-authored-by: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> --- esphome/components/adc/__init__.py | 8 +++ esphome/components/adc/adc_sensor.h | 17 ++++++ esphome/components/adc/adc_sensor_common.cpp | 55 +++++++++++++++++++ esphome/components/adc/adc_sensor_esp32.cpp | 13 +++-- esphome/components/adc/adc_sensor_esp8266.cpp | 16 ++++-- .../components/adc/adc_sensor_libretiny.cpp | 17 ++++-- esphome/components/adc/adc_sensor_rp2040.cpp | 23 ++++---- esphome/components/adc/sensor.py | 12 +++- tests/component_tests/sensor/test_sensor.yaml | 1 + 9 files changed, 132 insertions(+), 30 deletions(-) diff --git a/esphome/components/adc/__init__.py b/esphome/components/adc/__init__.py index d8d21523b9..be420475fb 100644 --- a/esphome/components/adc/__init__.py +++ b/esphome/components/adc/__init__.py @@ -36,6 +36,14 @@ ATTENUATION_MODES = { "auto": "auto", } +sampling_mode = adc_ns.enum("SamplingMode", is_class=True) + +SAMPLING_MODES = { + "avg": sampling_mode.AVG, + "min": sampling_mode.MIN, + "max": sampling_mode.MAX, +} + adc1_channel_t = cg.global_ns.enum("adc1_channel_t") adc2_channel_t = cg.global_ns.enum("adc2_channel_t") diff --git a/esphome/components/adc/adc_sensor.h b/esphome/components/adc/adc_sensor.h index 7a3e1c8da7..62f2461245 100644 --- a/esphome/components/adc/adc_sensor.h +++ b/esphome/components/adc/adc_sensor.h @@ -28,6 +28,21 @@ static const adc_atten_t ADC_ATTEN_DB_12_COMPAT = ADC_ATTEN_DB_11; #endif #endif // USE_ESP32 +enum class SamplingMode : uint8_t { AVG = 0, MIN = 1, MAX = 2 }; +const LogString *sampling_mode_to_str(SamplingMode mode); + +class Aggregator { + public: + void add_sample(uint32_t value); + uint32_t aggregate(); + Aggregator(SamplingMode mode); + + protected: + SamplingMode mode_{SamplingMode::AVG}; + uint32_t aggr_{0}; + uint32_t samples_{0}; +}; + class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage_sampler::VoltageSampler { public: #ifdef USE_ESP32 @@ -54,6 +69,7 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage void set_pin(InternalGPIOPin *pin) { this->pin_ = pin; } void set_output_raw(bool output_raw) { this->output_raw_ = output_raw; } void set_sample_count(uint8_t sample_count); + void set_sampling_mode(SamplingMode sampling_mode); float sample() override; #ifdef USE_ESP8266 @@ -68,6 +84,7 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage InternalGPIOPin *pin_; bool output_raw_{false}; uint8_t sample_count_{1}; + SamplingMode sampling_mode_{SamplingMode::AVG}; #ifdef USE_RP2040 bool is_temperature_{false}; diff --git a/esphome/components/adc/adc_sensor_common.cpp b/esphome/components/adc/adc_sensor_common.cpp index 2dccd55fcd..c7509c7c7a 100644 --- a/esphome/components/adc/adc_sensor_common.cpp +++ b/esphome/components/adc/adc_sensor_common.cpp @@ -6,6 +6,59 @@ namespace adc { static const char *const TAG = "adc.common"; +const LogString *sampling_mode_to_str(SamplingMode mode) { + switch (mode) { + case SamplingMode::AVG: + return LOG_STR("average"); + case SamplingMode::MIN: + return LOG_STR("minimum"); + case SamplingMode::MAX: + return LOG_STR("maximum"); + } + return LOG_STR("unknown"); +} + +Aggregator::Aggregator(SamplingMode mode) { + this->mode_ = mode; + // set to max uint if mode is "min" + if (mode == SamplingMode::MIN) { + this->aggr_ = UINT32_MAX; + } +} + +void Aggregator::add_sample(uint32_t value) { + this->samples_ += 1; + + switch (this->mode_) { + case SamplingMode::AVG: + this->aggr_ += value; + break; + + case SamplingMode::MIN: + if (value < this->aggr_) { + this->aggr_ = value; + } + break; + + case SamplingMode::MAX: + if (value > this->aggr_) { + this->aggr_ = value; + } + } +} + +uint32_t Aggregator::aggregate() { + if (this->mode_ == SamplingMode::AVG) { + if (this->samples_ == 0) { + return this->aggr_; + } + + return (this->aggr_ + (this->samples_ >> 1)) / this->samples_; // NOLINT(clang-analyzer-core.DivideZero) + } + + return this->aggr_; +} + void ADCSensor::update() { float value_v = this->sample(); ESP_LOGV(TAG, "'%s': Got voltage=%.4fV", this->get_name().c_str(), value_v); @@ -18,6 +71,8 @@ void ADCSensor::set_sample_count(uint8_t sample_count) { } } +void ADCSensor::set_sampling_mode(SamplingMode sampling_mode) { this->sampling_mode_ = sampling_mode; } + float ADCSensor::get_setup_priority() const { return setup_priority::DATA; } } // namespace adc diff --git a/esphome/components/adc/adc_sensor_esp32.cpp b/esphome/components/adc/adc_sensor_esp32.cpp index 24e3750091..0f1d802937 100644 --- a/esphome/components/adc/adc_sensor_esp32.cpp +++ b/esphome/components/adc/adc_sensor_esp32.cpp @@ -78,12 +78,14 @@ void ADCSensor::dump_config() { } } ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_); + ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_))); LOG_UPDATE_INTERVAL(this); } float ADCSensor::sample() { if (!this->autorange_) { - uint32_t sum = 0; + auto aggr = Aggregator(this->sampling_mode_); + for (uint8_t sample = 0; sample < this->sample_count_; sample++) { int raw = -1; if (this->channel1_ != ADC1_CHANNEL_MAX) { @@ -94,13 +96,14 @@ float ADCSensor::sample() { if (raw == -1) { return NAN; } - sum += raw; + + aggr.add_sample(raw); } - sum = (sum + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) if (this->output_raw_) { - return sum; + return aggr.aggregate(); } - uint32_t mv = esp_adc_cal_raw_to_voltage(sum, &this->cal_characteristics_[(int32_t) this->attenuation_]); + uint32_t mv = + esp_adc_cal_raw_to_voltage(aggr.aggregate(), &this->cal_characteristics_[(int32_t) this->attenuation_]); return mv / 1000.0f; } diff --git a/esphome/components/adc/adc_sensor_esp8266.cpp b/esphome/components/adc/adc_sensor_esp8266.cpp index c9b6f8b652..9a12009abc 100644 --- a/esphome/components/adc/adc_sensor_esp8266.cpp +++ b/esphome/components/adc/adc_sensor_esp8266.cpp @@ -31,23 +31,27 @@ void ADCSensor::dump_config() { LOG_PIN(" Pin: ", this->pin_); #endif // USE_ADC_SENSOR_VCC ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_); + ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_))); LOG_UPDATE_INTERVAL(this); } float ADCSensor::sample() { - uint32_t raw = 0; + auto aggr = Aggregator(this->sampling_mode_); + for (uint8_t sample = 0; sample < this->sample_count_; sample++) { + uint32_t raw = 0; #ifdef USE_ADC_SENSOR_VCC - raw += ESP.getVcc(); // NOLINT(readability-static-accessed-through-instance) + raw = ESP.getVcc(); // NOLINT(readability-static-accessed-through-instance) #else - raw += analogRead(this->pin_->get_pin()); // NOLINT + raw = analogRead(this->pin_->get_pin()); // NOLINT #endif // USE_ADC_SENSOR_VCC + aggr.add_sample(raw); } - raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) + if (this->output_raw_) { - return raw; + return aggr.aggregate(); } - return raw / 1024.0f; + return aggr.aggregate() / 1024.0f; } std::string ADCSensor::unique_id() { return get_mac_address() + "-adc"; } diff --git a/esphome/components/adc/adc_sensor_libretiny.cpp b/esphome/components/adc/adc_sensor_libretiny.cpp index cd04477b3f..9e75ed414c 100644 --- a/esphome/components/adc/adc_sensor_libretiny.cpp +++ b/esphome/components/adc/adc_sensor_libretiny.cpp @@ -23,23 +23,28 @@ void ADCSensor::dump_config() { LOG_PIN(" Pin: ", this->pin_); #endif // USE_ADC_SENSOR_VCC ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_); + ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_))); LOG_UPDATE_INTERVAL(this); } float ADCSensor::sample() { uint32_t raw = 0; + auto aggr = Aggregator(this->sampling_mode_); + if (this->output_raw_) { for (uint8_t sample = 0; sample < this->sample_count_; sample++) { - raw += analogRead(this->pin_->get_pin()); // NOLINT + raw = analogRead(this->pin_->get_pin()); // NOLINT + aggr.add_sample(raw); } - raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) - return raw; + return aggr.aggregate(); } + for (uint8_t sample = 0; sample < this->sample_count_; sample++) { - raw += analogReadVoltage(this->pin_->get_pin()); // NOLINT + raw = analogReadVoltage(this->pin_->get_pin()); // NOLINT + aggr.add_sample(raw); } - raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) - return raw / 1000.0f; + + return aggr.aggregate() / 1000.0f; } } // namespace adc diff --git a/esphome/components/adc/adc_sensor_rp2040.cpp b/esphome/components/adc/adc_sensor_rp2040.cpp index 520ff3bacc..f6cf1bac7a 100644 --- a/esphome/components/adc/adc_sensor_rp2040.cpp +++ b/esphome/components/adc/adc_sensor_rp2040.cpp @@ -34,24 +34,28 @@ void ADCSensor::dump_config() { #endif // USE_ADC_SENSOR_VCC } ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_); + ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_))); LOG_UPDATE_INTERVAL(this); } float ADCSensor::sample() { + uint32_t raw = 0; + auto aggr = Aggregator(this->sampling_mode_); + if (this->is_temperature_) { adc_set_temp_sensor_enabled(true); delay(1); adc_select_input(4); - uint32_t raw = 0; + for (uint8_t sample = 0; sample < this->sample_count_; sample++) { - raw += adc_read(); + raw = adc_read(); + aggr.add_sample(raw); } - raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) adc_set_temp_sensor_enabled(false); if (this->output_raw_) { - return raw; + return aggr.aggregate(); } - return raw * 3.3f / 4096.0f; + return aggr.aggregate() * 3.3f / 4096.0f; } uint8_t pin = this->pin_->get_pin(); @@ -68,11 +72,10 @@ float ADCSensor::sample() { adc_gpio_init(pin); adc_select_input(pin - 26); - uint32_t raw = 0; for (uint8_t sample = 0; sample < this->sample_count_; sample++) { - raw += adc_read(); + raw = adc_read(); + aggr.add_sample(raw); } - raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) #ifdef CYW43_USES_VSYS_PIN if (pin == PICO_VSYS_PIN) { @@ -81,10 +84,10 @@ float ADCSensor::sample() { #endif // CYW43_USES_VSYS_PIN if (this->output_raw_) { - return raw; + return aggr.aggregate(); } float coeff = pin == PICO_VSYS_PIN ? 3.0f : 1.0f; - return raw * 3.3f / 4096.0f * coeff; + return aggr.aggregate() * 3.3f / 4096.0f * coeff; } } // namespace adc diff --git a/esphome/components/adc/sensor.py b/esphome/components/adc/sensor.py index 59ea9e184c..3309bd04c5 100644 --- a/esphome/components/adc/sensor.py +++ b/esphome/components/adc/sensor.py @@ -1,11 +1,9 @@ import logging import esphome.codegen as cg -import esphome.config_validation as cv -import esphome.final_validate as fv -from esphome.core import CORE from esphome.components import sensor, voltage_sampler from esphome.components.esp32 import get_esp32_variant +import esphome.config_validation as cv from esphome.const import ( CONF_ATTENUATION, CONF_ID, @@ -17,10 +15,14 @@ from esphome.const import ( STATE_CLASS_MEASUREMENT, UNIT_VOLT, ) +from esphome.core import CORE +import esphome.final_validate as fv + from . import ( ATTENUATION_MODES, ESP32_VARIANT_ADC1_PIN_TO_CHANNEL, ESP32_VARIANT_ADC2_PIN_TO_CHANNEL, + SAMPLING_MODES, adc_ns, validate_adc_pin, ) @@ -30,9 +32,11 @@ _LOGGER = logging.getLogger(__name__) AUTO_LOAD = ["voltage_sampler"] CONF_SAMPLES = "samples" +CONF_SAMPLING_MODE = "sampling_mode" _attenuation = cv.enum(ATTENUATION_MODES, lower=True) +_sampling_mode = cv.enum(SAMPLING_MODES, lower=True) def validate_config(config): @@ -88,6 +92,7 @@ CONFIG_SCHEMA = cv.All( cv.only_on_esp32, _attenuation ), cv.Optional(CONF_SAMPLES, default=1): cv.int_range(min=1, max=255), + cv.Optional(CONF_SAMPLING_MODE, default="avg"): _sampling_mode, } ) .extend(cv.polling_component_schema("60s")), @@ -112,6 +117,7 @@ async def to_code(config): cg.add(var.set_output_raw(config[CONF_RAW])) cg.add(var.set_sample_count(config[CONF_SAMPLES])) + cg.add(var.set_sampling_mode(config[CONF_SAMPLING_MODE])) if attenuation := config.get(CONF_ATTENUATION): if attenuation == "auto": diff --git a/tests/component_tests/sensor/test_sensor.yaml b/tests/component_tests/sensor/test_sensor.yaml index 612b8e5e56..0f0ad5e94e 100644 --- a/tests/component_tests/sensor/test_sensor.yaml +++ b/tests/component_tests/sensor/test_sensor.yaml @@ -10,5 +10,6 @@ sensor: pin: A0 id: s_1 name: test s1 + sampling_mode: min update_interval: 60s device_class: voltage From 8be9f02693fdd383b4bfcde3fb3216068472cc3e Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Sun, 9 Feb 2025 23:42:40 -0500 Subject: [PATCH 179/194] [ota] Increase socket timeout earlier in OTA script (#8129) --- esphome/espota2.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/esphome/espota2.py b/esphome/espota2.py index 94b845b246..4f2a08fb4a 100644 --- a/esphome/espota2.py +++ b/esphome/espota2.py @@ -249,6 +249,9 @@ def perform_ota( send_check(sock, result, "auth result") receive_exactly(sock, 1, "auth result", RESPONSE_AUTH_OK) + # Set higher timeout during upload + sock.settimeout(30.0) + upload_size = len(upload_contents) upload_size_encoded = [ (upload_size >> 24) & 0xFF, @@ -271,8 +274,6 @@ def perform_ota( # show the actual progress sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, UPLOAD_BUFFER_SIZE) - # Set higher timeout during upload - sock.settimeout(30.0) start_time = time.perf_counter() offset = 0 From 84836f15db00e8eecc73fa06b169fa7265ed653b Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Mon, 10 Feb 2025 13:00:23 -0600 Subject: [PATCH 180/194] [speaker] Media Player Components PR9 (#8171) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- CODEOWNERS | 1 + esphome/components/media_player/__init__.py | 59 +- esphome/components/media_player/automation.h | 13 +- .../components/media_player/media_player.cpp | 8 + .../components/media_player/media_player.h | 12 +- .../speaker/media_player/__init__.py | 458 ++++++++++++++ .../speaker/media_player/audio_pipeline.cpp | 560 +++++++++++++++++ .../speaker/media_player/audio_pipeline.h | 158 +++++ .../speaker/media_player/automation.h | 26 + .../media_player/speaker_media_player.cpp | 577 ++++++++++++++++++ .../media_player/speaker_media_player.h | 160 +++++ tests/components/media_player/common.yaml | 2 + .../speaker/common-media_player.yaml | 12 + .../speaker/media_player.esp32-idf.yaml | 9 + .../speaker/media_player.esp32-s3-idf.yaml | 9 + 15 files changed, 2043 insertions(+), 21 deletions(-) create mode 100644 esphome/components/speaker/media_player/__init__.py create mode 100644 esphome/components/speaker/media_player/audio_pipeline.cpp create mode 100644 esphome/components/speaker/media_player/audio_pipeline.h create mode 100644 esphome/components/speaker/media_player/automation.h create mode 100644 esphome/components/speaker/media_player/speaker_media_player.cpp create mode 100644 esphome/components/speaker/media_player/speaker_media_player.h create mode 100644 tests/components/speaker/common-media_player.yaml create mode 100644 tests/components/speaker/media_player.esp32-idf.yaml create mode 100644 tests/components/speaker/media_player.esp32-s3-idf.yaml diff --git a/CODEOWNERS b/CODEOWNERS index d4b3d7eff9..26e36befe5 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -390,6 +390,7 @@ esphome/components/sn74hc165/* @jesserockz esphome/components/socket/* @esphome/core esphome/components/sonoff_d1/* @anatoly-savchenkov esphome/components/speaker/* @jesserockz @kahrendt +esphome/components/speaker/media_player/* @kahrendt @synesthesiam esphome/components/spi/* @clydebarrow @esphome/core esphome/components/spi_device/* @clydebarrow esphome/components/spi_led_strip/* @clydebarrow diff --git a/esphome/components/media_player/__init__.py b/esphome/components/media_player/__init__.py index a46b30db29..b2543ac05f 100644 --- a/esphome/components/media_player/__init__.py +++ b/esphome/components/media_player/__init__.py @@ -1,5 +1,4 @@ from esphome import automation -from esphome.automation import maybe_simple_id import esphome.codegen as cg import esphome.config_validation as cv from esphome.const import ( @@ -21,6 +20,16 @@ media_player_ns = cg.esphome_ns.namespace("media_player") MediaPlayer = media_player_ns.class_("MediaPlayer") +MediaPlayerSupportedFormat = media_player_ns.struct("MediaPlayerSupportedFormat") + +MediaPlayerFormatPurpose = media_player_ns.enum( + "MediaPlayerFormatPurpose", is_class=True +) +MEDIA_PLAYER_FORMAT_PURPOSE_ENUM = { + "default": MediaPlayerFormatPurpose.PURPOSE_DEFAULT, + "announcement": MediaPlayerFormatPurpose.PURPOSE_ANNOUNCEMENT, +} + PlayAction = media_player_ns.class_( "PlayAction", automation.Action, cg.Parented.template(MediaPlayer) @@ -47,7 +56,7 @@ VolumeSetAction = media_player_ns.class_( "VolumeSetAction", automation.Action, cg.Parented.template(MediaPlayer) ) - +CONF_ANNOUNCEMENT = "announcement" CONF_ON_PLAY = "on_play" CONF_ON_PAUSE = "on_pause" CONF_ON_ANNOUNCEMENT = "on_announcement" @@ -125,7 +134,16 @@ MEDIA_PLAYER_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend( ) -MEDIA_PLAYER_ACTION_SCHEMA = maybe_simple_id({cv.GenerateID(): cv.use_id(MediaPlayer)}) +MEDIA_PLAYER_ACTION_SCHEMA = cv.Schema( + { + cv.GenerateID(): cv.use_id(MediaPlayer), + cv.Optional(CONF_ANNOUNCEMENT, default=False): cv.templatable(cv.boolean), + } +) + +MEDIA_PLAYER_CONDITION_SCHEMA = automation.maybe_simple_id( + {cv.GenerateID(): cv.use_id(MediaPlayer)} +) @automation.register_action( @@ -135,6 +153,7 @@ MEDIA_PLAYER_ACTION_SCHEMA = maybe_simple_id({cv.GenerateID(): cv.use_id(MediaPl { cv.GenerateID(): cv.use_id(MediaPlayer), cv.Required(CONF_MEDIA_URL): cv.templatable(cv.url), + cv.Optional(CONF_ANNOUNCEMENT, default=False): cv.templatable(cv.boolean), }, key=CONF_MEDIA_URL, ), @@ -143,7 +162,9 @@ async def media_player_play_media_action(config, action_id, template_arg, args): var = cg.new_Pvariable(action_id, template_arg) await cg.register_parented(var, config[CONF_ID]) media_url = await cg.templatable(config[CONF_MEDIA_URL], args, cg.std_string) + announcement = await cg.templatable(config[CONF_ANNOUNCEMENT], args, cg.bool_) cg.add(var.set_media_url(media_url)) + cg.add(var.set_announcement(announcement)) return var @@ -161,19 +182,27 @@ async def media_player_play_media_action(config, action_id, template_arg, args): @automation.register_action( "media_player.volume_down", VolumeDownAction, MEDIA_PLAYER_ACTION_SCHEMA ) -@automation.register_condition( - "media_player.is_idle", IsIdleCondition, MEDIA_PLAYER_ACTION_SCHEMA -) -@automation.register_condition( - "media_player.is_paused", IsPausedCondition, MEDIA_PLAYER_ACTION_SCHEMA -) -@automation.register_condition( - "media_player.is_playing", IsPlayingCondition, MEDIA_PLAYER_ACTION_SCHEMA -) -@automation.register_condition( - "media_player.is_announcing", IsAnnouncingCondition, MEDIA_PLAYER_ACTION_SCHEMA -) async def media_player_action(config, action_id, template_arg, args): + var = cg.new_Pvariable(action_id, template_arg) + await cg.register_parented(var, config[CONF_ID]) + announcement = await cg.templatable(config[CONF_ANNOUNCEMENT], args, cg.bool_) + cg.add(var.set_announcement(announcement)) + return var + + +@automation.register_condition( + "media_player.is_idle", IsIdleCondition, MEDIA_PLAYER_CONDITION_SCHEMA +) +@automation.register_condition( + "media_player.is_paused", IsPausedCondition, MEDIA_PLAYER_CONDITION_SCHEMA +) +@automation.register_condition( + "media_player.is_playing", IsPlayingCondition, MEDIA_PLAYER_CONDITION_SCHEMA +) +@automation.register_condition( + "media_player.is_announcing", IsAnnouncingCondition, MEDIA_PLAYER_CONDITION_SCHEMA +) +async def media_player_condition(config, action_id, template_arg, args): var = cg.new_Pvariable(action_id, template_arg) await cg.register_parented(var, config[CONF_ID]) return var diff --git a/esphome/components/media_player/automation.h b/esphome/components/media_player/automation.h index 7b9220c4a5..422c224a85 100644 --- a/esphome/components/media_player/automation.h +++ b/esphome/components/media_player/automation.h @@ -10,7 +10,10 @@ namespace media_player { template class MediaPlayerCommandAction : public Action, public Parented { public: - void play(Ts... x) override { this->parent_->make_call().set_command(Command).perform(); } + TEMPLATABLE_VALUE(bool, announcement); + void play(Ts... x) override { + this->parent_->make_call().set_command(Command).set_announcement(this->announcement_.value(x...)).perform(); + } }; template @@ -28,7 +31,13 @@ using VolumeDownAction = MediaPlayerCommandAction class PlayMediaAction : public Action, public Parented { TEMPLATABLE_VALUE(std::string, media_url) - void play(Ts... x) override { this->parent_->make_call().set_media_url(this->media_url_.value(x...)).perform(); } + TEMPLATABLE_VALUE(bool, announcement) + void play(Ts... x) override { + this->parent_->make_call() + .set_media_url(this->media_url_.value(x...)) + .set_announcement(this->announcement_.value(x...)) + .perform(); + } }; template class VolumeSetAction : public Action, public Parented { diff --git a/esphome/components/media_player/media_player.cpp b/esphome/components/media_player/media_player.cpp index b5190d8573..01304d9135 100644 --- a/esphome/components/media_player/media_player.cpp +++ b/esphome/components/media_player/media_player.cpp @@ -41,6 +41,14 @@ const char *media_player_command_to_string(MediaPlayerCommand command) { return "VOLUME_UP"; case MEDIA_PLAYER_COMMAND_VOLUME_DOWN: return "VOLUME_DOWN"; + case MEDIA_PLAYER_COMMAND_ENQUEUE: + return "ENQUEUE"; + case MEDIA_PLAYER_COMMAND_REPEAT_ONE: + return "REPEAT_ONE"; + case MEDIA_PLAYER_COMMAND_REPEAT_OFF: + return "REPEAT_OFF"; + case MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST: + return "CLEAR_PLAYLIST"; default: return "UNKNOWN"; } diff --git a/esphome/components/media_player/media_player.h b/esphome/components/media_player/media_player.h index 78b3ed6216..ee5889901c 100644 --- a/esphome/components/media_player/media_player.h +++ b/esphome/components/media_player/media_player.h @@ -24,6 +24,10 @@ enum MediaPlayerCommand : uint8_t { MEDIA_PLAYER_COMMAND_TOGGLE = 5, MEDIA_PLAYER_COMMAND_VOLUME_UP = 6, MEDIA_PLAYER_COMMAND_VOLUME_DOWN = 7, + MEDIA_PLAYER_COMMAND_ENQUEUE = 8, + MEDIA_PLAYER_COMMAND_REPEAT_ONE = 9, + MEDIA_PLAYER_COMMAND_REPEAT_OFF = 10, + MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST = 11, }; const char *media_player_command_to_string(MediaPlayerCommand command); @@ -72,10 +76,10 @@ class MediaPlayerCall { void perform(); - const optional &get_command() const { return command_; } - const optional &get_media_url() const { return media_url_; } - const optional &get_volume() const { return volume_; } - const optional &get_announcement() const { return announcement_; } + const optional &get_command() const { return this->command_; } + const optional &get_media_url() const { return this->media_url_; } + const optional &get_volume() const { return this->volume_; } + const optional &get_announcement() const { return this->announcement_; } protected: void validate_(); diff --git a/esphome/components/speaker/media_player/__init__.py b/esphome/components/speaker/media_player/__init__.py new file mode 100644 index 0000000000..14b72cacc0 --- /dev/null +++ b/esphome/components/speaker/media_player/__init__.py @@ -0,0 +1,458 @@ +"""Speaker Media Player Setup.""" + +import hashlib +import logging +from pathlib import Path + +from esphome import automation, external_files +import esphome.codegen as cg +from esphome.components import audio, esp32, media_player, speaker +import esphome.config_validation as cv +from esphome.const import ( + CONF_BUFFER_SIZE, + CONF_FILE, + CONF_FILES, + CONF_FORMAT, + CONF_ID, + CONF_NUM_CHANNELS, + CONF_PATH, + CONF_RAW_DATA_ID, + CONF_SAMPLE_RATE, + CONF_SPEAKER, + CONF_TASK_STACK_IN_PSRAM, + CONF_TYPE, + CONF_URL, +) +from esphome.core import CORE, HexInt +from esphome.core.entity_helpers import inherit_property_from +from esphome.external_files import download_content + +_LOGGER = logging.getLogger(__name__) + +AUTO_LOAD = ["audio", "psram"] + +CODEOWNERS = ["@kahrendt", "@synesthesiam"] +DOMAIN = "media_player" + +TYPE_LOCAL = "local" +TYPE_WEB = "web" + +CONF_ANNOUNCEMENT = "announcement" +CONF_ANNOUNCEMENT_PIPELINE = "announcement_pipeline" +CONF_CODEC_SUPPORT_ENABLED = "codec_support_enabled" +CONF_ENQUEUE = "enqueue" +CONF_MEDIA_FILE = "media_file" +CONF_MEDIA_PIPELINE = "media_pipeline" +CONF_ON_MUTE = "on_mute" +CONF_ON_UNMUTE = "on_unmute" +CONF_ON_VOLUME = "on_volume" +CONF_STREAM = "stream" +CONF_VOLUME_INCREMENT = "volume_increment" +CONF_VOLUME_MIN = "volume_min" +CONF_VOLUME_MAX = "volume_max" + + +speaker_ns = cg.esphome_ns.namespace("speaker") +SpeakerMediaPlayer = speaker_ns.class_( + "SpeakerMediaPlayer", + media_player.MediaPlayer, + cg.Component, +) + +AudioPipeline = speaker_ns.class_("AudioPipeline") +AudioPipelineType = speaker_ns.enum("AudioPipelineType", is_class=True) +AUDIO_PIPELINE_TYPE_ENUM = { + "MEDIA": AudioPipelineType.MEDIA, + "ANNOUNCEMENT": AudioPipelineType.ANNOUNCEMENT, +} + +PlayOnDeviceMediaAction = speaker_ns.class_( + "PlayOnDeviceMediaAction", + automation.Action, + cg.Parented.template(SpeakerMediaPlayer), +) +StopStreamAction = speaker_ns.class_( + "StopStreamAction", automation.Action, cg.Parented.template(SpeakerMediaPlayer) +) + + +def _compute_local_file_path(value: dict) -> Path: + url = value[CONF_URL] + h = hashlib.new("sha256") + h.update(url.encode()) + key = h.hexdigest()[:8] + base_dir = external_files.compute_local_file_dir(DOMAIN) + _LOGGER.debug("_compute_local_file_path: base_dir=%s", base_dir / key) + return base_dir / key + + +def _download_web_file(value): + url = value[CONF_URL] + path = _compute_local_file_path(value) + + download_content(url, path) + _LOGGER.debug("download_web_file: path=%s", path) + return value + + +# Returns a media_player.MediaPlayerSupportedFormat struct with the configured +# format, sample rate, number of channels, purpose, and bytes per sample +def _get_supported_format_struct(pipeline, type): + args = [ + media_player.MediaPlayerSupportedFormat, + ] + + if pipeline[CONF_FORMAT] == "FLAC": + args.append(("format", "flac")) + elif pipeline[CONF_FORMAT] == "MP3": + args.append(("format", "mp3")) + elif pipeline[CONF_FORMAT] == "WAV": + args.append(("format", "wav")) + + args.append(("sample_rate", pipeline[CONF_SAMPLE_RATE])) + args.append(("num_channels", pipeline[CONF_NUM_CHANNELS])) + + if type == "MEDIA": + args.append( + ( + "purpose", + media_player.MEDIA_PLAYER_FORMAT_PURPOSE_ENUM["default"], + ) + ) + elif type == "ANNOUNCEMENT": + args.append( + ( + "purpose", + media_player.MEDIA_PLAYER_FORMAT_PURPOSE_ENUM["announcement"], + ) + ) + if pipeline[CONF_FORMAT] != "MP3": + args.append(("sample_bytes", 2)) + + return cg.StructInitializer(*args) + + +def _file_schema(value): + if isinstance(value, str): + return _validate_file_shorthand(value) + return TYPED_FILE_SCHEMA(value) + + +def _read_audio_file_and_type(file_config): + conf_file = file_config[CONF_FILE] + file_source = conf_file[CONF_TYPE] + if file_source == TYPE_LOCAL: + path = CORE.relative_config_path(conf_file[CONF_PATH]) + elif file_source == TYPE_WEB: + path = _compute_local_file_path(conf_file) + else: + raise cv.Invalid("Unsupported file source.") + + with open(path, "rb") as f: + data = f.read() + + import puremagic + + file_type: str = puremagic.from_string(data) + if file_type.startswith("."): + file_type = file_type[1:] + + media_file_type = audio.AUDIO_FILE_TYPE_ENUM["NONE"] + if file_type in ("wav"): + media_file_type = audio.AUDIO_FILE_TYPE_ENUM["WAV"] + elif file_type in ("mp3", "mpeg", "mpga"): + media_file_type = audio.AUDIO_FILE_TYPE_ENUM["MP3"] + elif file_type in ("flac"): + media_file_type = audio.AUDIO_FILE_TYPE_ENUM["FLAC"] + + return data, media_file_type + + +def _validate_file_shorthand(value): + value = cv.string_strict(value) + if value.startswith("http://") or value.startswith("https://"): + return _file_schema( + { + CONF_TYPE: TYPE_WEB, + CONF_URL: value, + } + ) + return _file_schema( + { + CONF_TYPE: TYPE_LOCAL, + CONF_PATH: value, + } + ) + + +def _validate_pipeline(config): + # Inherit transcoder settings from speaker if not manually set + inherit_property_from(CONF_NUM_CHANNELS, CONF_SPEAKER)(config) + inherit_property_from(CONF_SAMPLE_RATE, CONF_SPEAKER)(config) + + # Validate the transcoder settings is compatible with the speaker + audio.final_validate_audio_schema( + "speaker media_player", + audio_device=CONF_SPEAKER, + bits_per_sample=16, + channels=config.get(CONF_NUM_CHANNELS), + sample_rate=config.get(CONF_SAMPLE_RATE), + )(config) + + return config + + +def _validate_repeated_speaker(config): + if (announcement_config := config.get(CONF_ANNOUNCEMENT_PIPELINE)) and ( + media_config := config.get(CONF_MEDIA_PIPELINE) + ): + if announcement_config[CONF_SPEAKER] == media_config[CONF_SPEAKER]: + raise cv.Invalid( + "The announcement and media pipelines cannot use the same speaker. Use the `mixer` speaker component to create two source speakers." + ) + + return config + + +def _validate_supported_local_file(config): + for file_config in config.get(CONF_FILES, []): + _, media_file_type = _read_audio_file_and_type(file_config) + if str(media_file_type) == str(audio.AUDIO_FILE_TYPE_ENUM["NONE"]): + raise cv.Invalid("Unsupported local media file.") + if not config[CONF_CODEC_SUPPORT_ENABLED] and str(media_file_type) != str( + audio.AUDIO_FILE_TYPE_ENUM["WAV"] + ): + # Only wav files are supported + raise cv.Invalid( + f"Unsupported local media file type, set {CONF_CODEC_SUPPORT_ENABLED} to true or convert the media file to wav" + ) + + return config + + +LOCAL_SCHEMA = cv.Schema( + { + cv.Required(CONF_PATH): cv.file_, + } +) + +WEB_SCHEMA = cv.All( + { + cv.Required(CONF_URL): cv.url, + }, + _download_web_file, +) + + +TYPED_FILE_SCHEMA = cv.typed_schema( + { + TYPE_LOCAL: LOCAL_SCHEMA, + TYPE_WEB: WEB_SCHEMA, + }, +) + + +MEDIA_FILE_TYPE_SCHEMA = cv.Schema( + { + cv.Required(CONF_ID): cv.declare_id(audio.AudioFile), + cv.Required(CONF_FILE): _file_schema, + cv.GenerateID(CONF_RAW_DATA_ID): cv.declare_id(cg.uint8), + } +) + +PIPELINE_SCHEMA = cv.Schema( + { + cv.GenerateID(): cv.declare_id(AudioPipeline), + cv.Required(CONF_SPEAKER): cv.use_id(speaker.Speaker), + cv.Optional(CONF_FORMAT, default="FLAC"): cv.enum(audio.AUDIO_FILE_TYPE_ENUM), + cv.Optional(CONF_SAMPLE_RATE): cv.int_range(min=1), + cv.Optional(CONF_NUM_CHANNELS): cv.int_range(1, 2), + } +) + +CONFIG_SCHEMA = cv.All( + media_player.MEDIA_PLAYER_SCHEMA.extend( + { + cv.GenerateID(): cv.declare_id(SpeakerMediaPlayer), + cv.Required(CONF_ANNOUNCEMENT_PIPELINE): PIPELINE_SCHEMA, + cv.Optional(CONF_MEDIA_PIPELINE): PIPELINE_SCHEMA, + cv.Optional(CONF_BUFFER_SIZE, default=1000000): cv.int_range( + min=4000, max=4000000 + ), + cv.Optional(CONF_CODEC_SUPPORT_ENABLED, default=True): cv.boolean, + cv.Optional(CONF_FILES): cv.ensure_list(MEDIA_FILE_TYPE_SCHEMA), + cv.Optional(CONF_TASK_STACK_IN_PSRAM, default=False): cv.boolean, + cv.Optional(CONF_VOLUME_INCREMENT, default=0.05): cv.percentage, + cv.Optional(CONF_VOLUME_MAX, default=1.0): cv.percentage, + cv.Optional(CONF_VOLUME_MIN, default=0.0): cv.percentage, + cv.Optional(CONF_ON_MUTE): automation.validate_automation(single=True), + cv.Optional(CONF_ON_UNMUTE): automation.validate_automation(single=True), + cv.Optional(CONF_ON_VOLUME): automation.validate_automation(single=True), + } + ), + cv.only_with_esp_idf, + _validate_repeated_speaker, +) + + +FINAL_VALIDATE_SCHEMA = cv.All( + cv.Schema( + { + cv.Optional(CONF_ANNOUNCEMENT_PIPELINE): _validate_pipeline, + cv.Optional(CONF_MEDIA_PIPELINE): _validate_pipeline, + }, + extra=cv.ALLOW_EXTRA, + ), + _validate_supported_local_file, +) + + +async def to_code(config): + if config[CONF_CODEC_SUPPORT_ENABLED]: + # Compile all supported audio codecs and optimize the wifi settings + + cg.add_define("USE_AUDIO_FLAC_SUPPORT", True) + cg.add_define("USE_AUDIO_MP3_SUPPORT", True) + + # Wifi settings based on https://github.com/espressif/esp-adf/issues/297#issuecomment-783811702 + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM", 16) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM", 512) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_STATIC_TX_BUFFER", True) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_TX_BUFFER_TYPE", 0) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM", 8) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM", 32) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED", True) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_TX_BA_WIN", 16) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED", True) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_RX_BA_WIN", 32) + esp32.add_idf_sdkconfig_option("CONFIG_LWIP_MAX_ACTIVE_TCP", 16) + esp32.add_idf_sdkconfig_option("CONFIG_LWIP_MAX_LISTENING_TCP", 16) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_MAXRTX", 12) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_SYNMAXRTX", 6) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_MSS", 1436) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_MSL", 60000) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_SND_BUF_DEFAULT", 65535) + esp32.add_idf_sdkconfig_option( + "CONFIG_TCP_WND_DEFAULT", 65535 + ) # Adjusted from referenced settings to avoid compilation error + esp32.add_idf_sdkconfig_option("CONFIG_TCP_RECVMBOX_SIZE", 512) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_QUEUE_OOSEQ", True) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_OVERSIZE_MSS", True) + esp32.add_idf_sdkconfig_option("CONFIG_LWIP_WND_SCALE", True) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_RCV_SCALE", 3) + esp32.add_idf_sdkconfig_option("CONFIG_LWIP_TCPIP_RECVMBOX_SIZE", 512) + + # Allocate wifi buffers in PSRAM + esp32.add_idf_sdkconfig_option("CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP", True) + + var = cg.new_Pvariable(config[CONF_ID]) + await cg.register_component(var, config) + await media_player.register_media_player(var, config) + + cg.add_define("USE_OTA_STATE_CALLBACK") + + cg.add(var.set_buffer_size(config[CONF_BUFFER_SIZE])) + + cg.add(var.set_task_stack_in_psram(config[CONF_TASK_STACK_IN_PSRAM])) + if config[CONF_TASK_STACK_IN_PSRAM]: + esp32.add_idf_sdkconfig_option( + "CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY", True + ) + + cg.add(var.set_volume_increment(config[CONF_VOLUME_INCREMENT])) + cg.add(var.set_volume_max(config[CONF_VOLUME_MAX])) + cg.add(var.set_volume_min(config[CONF_VOLUME_MIN])) + + announcement_pipeline_config = config[CONF_ANNOUNCEMENT_PIPELINE] + spkr = await cg.get_variable(announcement_pipeline_config[CONF_SPEAKER]) + cg.add(var.set_announcement_speaker(spkr)) + if announcement_pipeline_config[CONF_FORMAT] != "NONE": + cg.add( + var.set_announcement_format( + _get_supported_format_struct( + announcement_pipeline_config, "ANNOUNCEMENT" + ) + ) + ) + + if media_pipeline_config := config.get(CONF_MEDIA_PIPELINE): + spkr = await cg.get_variable(media_pipeline_config[CONF_SPEAKER]) + cg.add(var.set_media_speaker(spkr)) + if media_pipeline_config[CONF_FORMAT] != "NONE": + cg.add( + var.set_media_format( + _get_supported_format_struct(media_pipeline_config, "MEDIA") + ) + ) + + if on_mute := config.get(CONF_ON_MUTE): + await automation.build_automation( + var.get_mute_trigger(), + [], + on_mute, + ) + if on_unmute := config.get(CONF_ON_UNMUTE): + await automation.build_automation( + var.get_unmute_trigger(), + [], + on_unmute, + ) + if on_volume := config.get(CONF_ON_VOLUME): + await automation.build_automation( + var.get_volume_trigger(), + [(cg.float_, "x")], + on_volume, + ) + + for file_config in config.get(CONF_FILES, []): + data, media_file_type = _read_audio_file_and_type(file_config) + + rhs = [HexInt(x) for x in data] + prog_arr = cg.progmem_array(file_config[CONF_RAW_DATA_ID], rhs) + + media_files_struct = cg.StructInitializer( + audio.AudioFile, + ( + "data", + prog_arr, + ), + ( + "length", + len(rhs), + ), + ( + "file_type", + media_file_type, + ), + ) + + cg.new_Pvariable( + file_config[CONF_ID], + media_files_struct, + ) + + +@automation.register_action( + "media_player.speaker.play_on_device_media_file", + PlayOnDeviceMediaAction, + cv.maybe_simple_value( + { + cv.GenerateID(): cv.use_id(SpeakerMediaPlayer), + cv.Required(CONF_MEDIA_FILE): cv.use_id(audio.AudioFile), + cv.Optional(CONF_ANNOUNCEMENT, default=False): cv.templatable(cv.boolean), + cv.Optional(CONF_ENQUEUE, default=False): cv.templatable(cv.boolean), + }, + key=CONF_MEDIA_FILE, + ), +) +async def play_on_device_media_media_action(config, action_id, template_arg, args): + var = cg.new_Pvariable(action_id, template_arg) + await cg.register_parented(var, config[CONF_ID]) + media_file = await cg.get_variable(config[CONF_MEDIA_FILE]) + announcement = await cg.templatable(config[CONF_ANNOUNCEMENT], args, cg.bool_) + enqueue = await cg.templatable(config[CONF_ENQUEUE], args, cg.bool_) + + cg.add(var.set_audio_file(media_file)) + cg.add(var.set_announcement(announcement)) + cg.add(var.set_enqueue(enqueue)) + return var diff --git a/esphome/components/speaker/media_player/audio_pipeline.cpp b/esphome/components/speaker/media_player/audio_pipeline.cpp new file mode 100644 index 0000000000..73ec5a3334 --- /dev/null +++ b/esphome/components/speaker/media_player/audio_pipeline.cpp @@ -0,0 +1,560 @@ +#include "audio_pipeline.h" + +#ifdef USE_ESP_IDF + +#include "esphome/core/defines.h" +#include "esphome/core/hal.h" +#include "esphome/core/helpers.h" +#include "esphome/core/log.h" + +namespace esphome { +namespace speaker { + +static const uint32_t INITIAL_BUFFER_MS = 1000; // Start playback after buffering this duration of the file + +static const uint32_t READ_TASK_STACK_SIZE = 5 * 1024; +static const uint32_t DECODE_TASK_STACK_SIZE = 3 * 1024; + +static const uint32_t INFO_ERROR_QUEUE_COUNT = 5; + +static const char *const TAG = "speaker_media_player.pipeline"; + +enum EventGroupBits : uint32_t { + // MESSAGE_* bits are only set by their respective tasks + + // Stops all activity in the pipeline elements; cleared by process_state() and set by stop() or by each task + PIPELINE_COMMAND_STOP = (1 << 0), + + // Read audio from an HTTP source; cleared by reader task and set by start_url + READER_COMMAND_INIT_HTTP = (1 << 4), + // Read audio from an audio file from the flash; cleared by reader task and set by start_file + READER_COMMAND_INIT_FILE = (1 << 5), + + // Audio file type is read after checking it is supported; cleared by decoder task + READER_MESSAGE_LOADED_MEDIA_TYPE = (1 << 6), + // Reader is done (either through a failure or just end of the stream); cleared by reader task + READER_MESSAGE_FINISHED = (1 << 7), + // Error reading the file; cleared by process_state() + READER_MESSAGE_ERROR = (1 << 8), + + // Decoder is done (either through a faiilure or the end of the stream); cleared by decoder task + DECODER_MESSAGE_FINISHED = (1 << 12), + // Error decoding the file; cleared by process_state() by decoder task + DECODER_MESSAGE_ERROR = (1 << 13), +}; + +AudioPipeline::AudioPipeline(speaker::Speaker *speaker, size_t buffer_size, bool task_stack_in_psram, + std::string base_name, UBaseType_t priority) + : base_name_(std::move(base_name)), + priority_(priority), + task_stack_in_psram_(task_stack_in_psram), + speaker_(speaker), + buffer_size_(buffer_size) { + this->allocate_communications_(); + this->transfer_buffer_size_ = std::min(buffer_size_ / 4, DEFAULT_TRANSFER_BUFFER_SIZE); +} + +void AudioPipeline::start_url(const std::string &uri) { + if (this->is_playing_) { + xEventGroupSetBits(this->event_group_, PIPELINE_COMMAND_STOP); + } + this->current_uri_ = uri; + this->pending_url_ = true; +} + +void AudioPipeline::start_file(audio::AudioFile *audio_file) { + if (this->is_playing_) { + xEventGroupSetBits(this->event_group_, PIPELINE_COMMAND_STOP); + } + this->current_audio_file_ = audio_file; + this->pending_file_ = true; +} + +esp_err_t AudioPipeline::stop() { + xEventGroupSetBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP); + + return ESP_OK; +} +void AudioPipeline::set_pause_state(bool pause_state) { + this->speaker_->set_pause_state(pause_state); + + this->pause_state_ = pause_state; +} + +void AudioPipeline::suspend_tasks() { + if (this->read_task_handle_ != nullptr) { + vTaskSuspend(this->read_task_handle_); + } + if (this->decode_task_handle_ != nullptr) { + vTaskSuspend(this->decode_task_handle_); + } +} + +void AudioPipeline::resume_tasks() { + if (this->read_task_handle_ != nullptr) { + vTaskResume(this->read_task_handle_); + } + if (this->decode_task_handle_ != nullptr) { + vTaskResume(this->decode_task_handle_); + } +} + +AudioPipelineState AudioPipeline::process_state() { + /* + * Log items from info error queue + */ + InfoErrorEvent event; + if (this->info_error_queue_ != nullptr) { + while (xQueueReceive(this->info_error_queue_, &event, 0)) { + switch (event.source) { + case InfoErrorSource::READER: + if (event.err.has_value()) { + ESP_LOGE(TAG, "Media reader encountered an error: %s", esp_err_to_name(event.err.value())); + } else if (event.file_type.has_value()) { + ESP_LOGD(TAG, "Reading %s file type", audio_file_type_to_string(event.file_type.value())); + } + + break; + case InfoErrorSource::DECODER: + if (event.err.has_value()) { + ESP_LOGE(TAG, "Decoder encountered an error: %s", esp_err_to_name(event.err.value())); + } + + if (event.audio_stream_info.has_value()) { + ESP_LOGD(TAG, "Decoded audio has %d channels, %" PRId32 " Hz sample rate, and %d bits per sample", + event.audio_stream_info.value().get_channels(), event.audio_stream_info.value().get_sample_rate(), + event.audio_stream_info.value().get_bits_per_sample()); + } + + if (event.decoding_err.has_value()) { + switch (event.decoding_err.value()) { + case DecodingError::FAILED_HEADER: + ESP_LOGE(TAG, "Failed to parse the file's header."); + break; + case DecodingError::INCOMPATIBLE_BITS_PER_SAMPLE: + ESP_LOGE(TAG, "Incompatible bits per sample. Only 16 bits per sample is supported"); + break; + case DecodingError::INCOMPATIBLE_CHANNELS: + ESP_LOGE(TAG, "Incompatible number of channels. Only 1 or 2 channel audio is supported."); + break; + } + } + break; + } + } + } + + /* + * Determine the current state based on the event group bits and tasks' status + */ + + EventBits_t event_bits = xEventGroupGetBits(this->event_group_); + + if (this->pending_url_ || this->pending_file_) { + // Init command pending + if (!(event_bits & EventGroupBits::PIPELINE_COMMAND_STOP)) { + // Only start if there is no pending stop command + if ((this->read_task_handle_ == nullptr) || (this->decode_task_handle_ == nullptr)) { + // At least one task isn't running + this->start_tasks_(); + } + + if (this->pending_url_) { + xEventGroupSetBits(this->event_group_, EventGroupBits::READER_COMMAND_INIT_HTTP); + this->playback_ms_ = 0; + this->pending_url_ = false; + } else if (this->pending_file_) { + xEventGroupSetBits(this->event_group_, EventGroupBits::READER_COMMAND_INIT_FILE); + this->playback_ms_ = 0; + this->pending_file_ = false; + } + + this->is_playing_ = true; + return AudioPipelineState::PLAYING; + } + } + + if ((event_bits & EventGroupBits::READER_MESSAGE_FINISHED) && + (!(event_bits & EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE) && + (event_bits & EventGroupBits::DECODER_MESSAGE_FINISHED))) { + // Tasks are finished and there's no media in between the reader and decoder + + if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) { + // Stop command is fully processed, so clear the command bit + xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP); + } + + if (!this->is_playing_) { + // The tasks have been stopped for two ``process_state`` calls in a row, so delete the tasks + if ((this->read_task_handle_ != nullptr) || (this->decode_task_handle_ != nullptr)) { + this->delete_tasks_(); + this->speaker_->stop(); + } + } + this->is_playing_ = false; + return AudioPipelineState::STOPPED; + } + + if ((event_bits & EventGroupBits::READER_MESSAGE_ERROR)) { + xEventGroupClearBits(this->event_group_, EventGroupBits::READER_MESSAGE_ERROR); + return AudioPipelineState::ERROR_READING; + } + + if ((event_bits & EventGroupBits::DECODER_MESSAGE_ERROR)) { + xEventGroupClearBits(this->event_group_, EventGroupBits::DECODER_MESSAGE_ERROR); + return AudioPipelineState::ERROR_DECODING; + } + + if (this->pause_state_) { + return AudioPipelineState::PAUSED; + } + + if ((this->read_task_handle_ == nullptr) && (this->decode_task_handle_ == nullptr)) { + // No tasks are running, so the pipeline is stopped. + xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP); + return AudioPipelineState::STOPPED; + } + + this->is_playing_ = true; + return AudioPipelineState::PLAYING; +} + +esp_err_t AudioPipeline::allocate_communications_() { + if (this->event_group_ == nullptr) + this->event_group_ = xEventGroupCreate(); + + if (this->event_group_ == nullptr) { + return ESP_ERR_NO_MEM; + } + + if (this->info_error_queue_ == nullptr) + this->info_error_queue_ = xQueueCreate(INFO_ERROR_QUEUE_COUNT, sizeof(InfoErrorEvent)); + + if (this->info_error_queue_ == nullptr) + return ESP_ERR_NO_MEM; + + return ESP_OK; +} + +esp_err_t AudioPipeline::start_tasks_() { + if (this->read_task_handle_ == nullptr) { + if (this->read_task_stack_buffer_ == nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + this->read_task_stack_buffer_ = stack_allocator.allocate(READ_TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + this->read_task_stack_buffer_ = stack_allocator.allocate(READ_TASK_STACK_SIZE); + } + } + + if (this->read_task_stack_buffer_ == nullptr) { + return ESP_ERR_NO_MEM; + } + + if (this->read_task_handle_ == nullptr) { + this->read_task_handle_ = + xTaskCreateStatic(read_task, (this->base_name_ + "_read").c_str(), READ_TASK_STACK_SIZE, (void *) this, + this->priority_, this->read_task_stack_buffer_, &this->read_task_stack_); + } + + if (this->read_task_handle_ == nullptr) { + return ESP_ERR_INVALID_STATE; + } + } + + if (this->decode_task_handle_ == nullptr) { + if (this->decode_task_stack_buffer_ == nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + this->decode_task_stack_buffer_ = stack_allocator.allocate(DECODE_TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + this->decode_task_stack_buffer_ = stack_allocator.allocate(DECODE_TASK_STACK_SIZE); + } + } + + if (this->decode_task_stack_buffer_ == nullptr) { + return ESP_ERR_NO_MEM; + } + + if (this->decode_task_handle_ == nullptr) { + this->decode_task_handle_ = + xTaskCreateStatic(decode_task, (this->base_name_ + "_decode").c_str(), DECODE_TASK_STACK_SIZE, (void *) this, + this->priority_, this->decode_task_stack_buffer_, &this->decode_task_stack_); + } + + if (this->decode_task_handle_ == nullptr) { + return ESP_ERR_INVALID_STATE; + } + } + + return ESP_OK; +} + +void AudioPipeline::delete_tasks_() { + if (this->read_task_handle_ != nullptr) { + vTaskDelete(this->read_task_handle_); + + if (this->read_task_stack_buffer_ != nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + stack_allocator.deallocate(this->read_task_stack_buffer_, READ_TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + stack_allocator.deallocate(this->read_task_stack_buffer_, READ_TASK_STACK_SIZE); + } + + this->read_task_stack_buffer_ = nullptr; + this->read_task_handle_ = nullptr; + } + } + + if (this->decode_task_handle_ != nullptr) { + vTaskDelete(this->decode_task_handle_); + + if (this->decode_task_stack_buffer_ != nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + stack_allocator.deallocate(this->decode_task_stack_buffer_, DECODE_TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + stack_allocator.deallocate(this->decode_task_stack_buffer_, DECODE_TASK_STACK_SIZE); + } + + this->decode_task_stack_buffer_ = nullptr; + this->decode_task_handle_ = nullptr; + } + } +} + +void AudioPipeline::read_task(void *params) { + AudioPipeline *this_pipeline = (AudioPipeline *) params; + + while (true) { + xEventGroupSetBits(this_pipeline->event_group_, EventGroupBits::READER_MESSAGE_FINISHED); + + // Wait until the pipeline notifies us the source of the media file + EventBits_t event_bits = + xEventGroupWaitBits(this_pipeline->event_group_, + EventGroupBits::READER_COMMAND_INIT_FILE | EventGroupBits::READER_COMMAND_INIT_HTTP | + EventGroupBits::PIPELINE_COMMAND_STOP, // Bit message to read + pdFALSE, // Clear the bit on exit + pdFALSE, // Wait for all the bits, + portMAX_DELAY); // Block indefinitely until bit is set + + if (!(event_bits & EventGroupBits::PIPELINE_COMMAND_STOP)) { + xEventGroupClearBits(this_pipeline->event_group_, EventGroupBits::READER_MESSAGE_FINISHED | + EventGroupBits::READER_COMMAND_INIT_FILE | + EventGroupBits::READER_COMMAND_INIT_HTTP); + InfoErrorEvent event; + event.source = InfoErrorSource::READER; + esp_err_t err = ESP_OK; + + std::unique_ptr reader = + make_unique(this_pipeline->transfer_buffer_size_); + + if (event_bits & EventGroupBits::READER_COMMAND_INIT_FILE) { + err = reader->start(this_pipeline->current_audio_file_, this_pipeline->current_audio_file_type_); + } else { + err = reader->start(this_pipeline->current_uri_, this_pipeline->current_audio_file_type_); + } + + if (err == ESP_OK) { + size_t file_ring_buffer_size = this_pipeline->buffer_size_; + + std::shared_ptr temp_ring_buffer; + + if (!this_pipeline->raw_file_ring_buffer_.use_count()) { + temp_ring_buffer = RingBuffer::create(file_ring_buffer_size); + this_pipeline->raw_file_ring_buffer_ = temp_ring_buffer; + } + + if (!this_pipeline->raw_file_ring_buffer_.use_count()) { + err = ESP_ERR_NO_MEM; + } else { + reader->add_sink(this_pipeline->raw_file_ring_buffer_); + } + } + + if (err != ESP_OK) { + // Send specific error message + event.err = err; + xQueueSend(this_pipeline->info_error_queue_, &event, portMAX_DELAY); + + // Setting up the reader failed, stop the pipeline + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::READER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + } else { + // Send the file type to the pipeline + event.file_type = this_pipeline->current_audio_file_type_; + xQueueSend(this_pipeline->info_error_queue_, &event, portMAX_DELAY); + xEventGroupSetBits(this_pipeline->event_group_, EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE); + } + + while (true) { + event_bits = xEventGroupGetBits(this_pipeline->event_group_); + + if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) { + break; + } + + audio::AudioReaderState reader_state = reader->read(); + + if (reader_state == audio::AudioReaderState::FINISHED) { + break; + } else if (reader_state == audio::AudioReaderState::FAILED) { + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::READER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + break; + } + } + event_bits = xEventGroupGetBits(this_pipeline->event_group_); + if ((event_bits & EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE) || + (this_pipeline->raw_file_ring_buffer_.use_count() == 1)) { + // Decoder task hasn't started yet, so delay a bit before releasing ownership of the ring buffer + delay(10); + } + } + } +} + +void AudioPipeline::decode_task(void *params) { + AudioPipeline *this_pipeline = (AudioPipeline *) params; + + while (true) { + xEventGroupSetBits(this_pipeline->event_group_, EventGroupBits::DECODER_MESSAGE_FINISHED); + + // Wait until the reader notifies us that the media type is available + EventBits_t event_bits = xEventGroupWaitBits(this_pipeline->event_group_, + EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE | + EventGroupBits::PIPELINE_COMMAND_STOP, // Bit message to read + pdFALSE, // Clear the bit on exit + pdFALSE, // Wait for all the bits, + portMAX_DELAY); // Block indefinitely until bit is set + + if (!(event_bits & EventGroupBits::PIPELINE_COMMAND_STOP)) { + xEventGroupClearBits(this_pipeline->event_group_, + EventGroupBits::DECODER_MESSAGE_FINISHED | EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE); + InfoErrorEvent event; + event.source = InfoErrorSource::DECODER; + + std::unique_ptr decoder = + make_unique(this_pipeline->transfer_buffer_size_, this_pipeline->transfer_buffer_size_); + + esp_err_t err = decoder->start(this_pipeline->current_audio_file_type_); + decoder->add_source(this_pipeline->raw_file_ring_buffer_); + + if (err != ESP_OK) { + // Send specific error message + event.err = err; + xQueueSend(this_pipeline->info_error_queue_, &event, portMAX_DELAY); + + // Setting up the decoder failed, stop the pipeline + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::DECODER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + } + + bool has_stream_info = false; + bool started_playback = false; + + size_t initial_bytes_to_buffer = 0; + + while (true) { + event_bits = xEventGroupGetBits(this_pipeline->event_group_); + + if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) { + break; + } + + // Update pause state + if (!started_playback) { + if (!(event_bits & EventGroupBits::READER_MESSAGE_FINISHED)) { + decoder->set_pause_output_state(true); + } else { + started_playback = true; + } + } else { + decoder->set_pause_output_state(this_pipeline->pause_state_); + } + + // Stop gracefully if the reader has finished + audio::AudioDecoderState decoder_state = decoder->decode(event_bits & EventGroupBits::READER_MESSAGE_FINISHED); + + if ((decoder_state == audio::AudioDecoderState::DECODING) || + (decoder_state == audio::AudioDecoderState::FINISHED)) { + this_pipeline->playback_ms_ = decoder->get_playback_ms(); + } + + if (decoder_state == audio::AudioDecoderState::FINISHED) { + break; + } else if (decoder_state == audio::AudioDecoderState::FAILED) { + if (!has_stream_info) { + event.decoding_err = DecodingError::FAILED_HEADER; + xQueueSend(this_pipeline->info_error_queue_, &event, portMAX_DELAY); + } + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::DECODER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + break; + } + + if (!has_stream_info && decoder->get_audio_stream_info().has_value()) { + has_stream_info = true; + + this_pipeline->current_audio_stream_info_ = decoder->get_audio_stream_info().value(); + + // Send the stream information to the pipeline + event.audio_stream_info = this_pipeline->current_audio_stream_info_; + + if (this_pipeline->current_audio_stream_info_.get_bits_per_sample() != 16) { + // Error state, incompatible bits per sample + event.decoding_err = DecodingError::INCOMPATIBLE_BITS_PER_SAMPLE; + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::DECODER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + } else if ((this_pipeline->current_audio_stream_info_.get_channels() > 2)) { + // Error state, incompatible number of channels + event.decoding_err = DecodingError::INCOMPATIBLE_CHANNELS; + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::DECODER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + } else { + // Send audio directly to the speaker + this_pipeline->speaker_->set_audio_stream_info(this_pipeline->current_audio_stream_info_); + decoder->add_sink(this_pipeline->speaker_); + } + + initial_bytes_to_buffer = std::min(this_pipeline->current_audio_stream_info_.ms_to_bytes(INITIAL_BUFFER_MS), + this_pipeline->buffer_size_ * 3 / 4); + + switch (this_pipeline->current_audio_file_type_) { +#ifdef USE_AUDIO_MP3_SUPPORT + case audio::AudioFileType::MP3: + initial_bytes_to_buffer /= 8; // Estimate the MP3 compression factor is 8 + break; +#endif +#ifdef USE_AUDIO_FLAC_SUPPORT + case audio::AudioFileType::FLAC: + initial_bytes_to_buffer /= 2; // Estimate the FLAC compression factor is 2 + break; +#endif + default: + break; + } + xQueueSend(this_pipeline->info_error_queue_, &event, portMAX_DELAY); + } + + if (!started_playback && has_stream_info) { + // Verify enough data is available before starting playback + std::shared_ptr temp_ring_buffer = this_pipeline->raw_file_ring_buffer_.lock(); + if (temp_ring_buffer->available() >= initial_bytes_to_buffer) { + started_playback = true; + } + } + } + } + } +} + +} // namespace speaker +} // namespace esphome + +#endif diff --git a/esphome/components/speaker/media_player/audio_pipeline.h b/esphome/components/speaker/media_player/audio_pipeline.h new file mode 100644 index 0000000000..c382e1eebe --- /dev/null +++ b/esphome/components/speaker/media_player/audio_pipeline.h @@ -0,0 +1,158 @@ +#pragma once + +#ifdef USE_ESP_IDF + +#include "esphome/components/audio/audio.h" +#include "esphome/components/audio/audio_reader.h" +#include "esphome/components/audio/audio_decoder.h" +#include "esphome/components/speaker/speaker.h" + +#include "esphome/core/ring_buffer.h" + +#include "esp_err.h" + +#include +#include +#include + +namespace esphome { +namespace speaker { + +// Internal sink/source buffers for reader and decoder +static const size_t DEFAULT_TRANSFER_BUFFER_SIZE = 24 * 1024; + +enum class AudioPipelineType : uint8_t { + MEDIA, + ANNOUNCEMENT, +}; + +enum class AudioPipelineState : uint8_t { + STARTING_FILE, + STARTING_URL, + PLAYING, + STOPPING, + STOPPED, + PAUSED, + ERROR_READING, + ERROR_DECODING, +}; + +enum class InfoErrorSource : uint8_t { + READER = 0, + DECODER, +}; + +enum class DecodingError : uint8_t { + FAILED_HEADER = 0, + INCOMPATIBLE_BITS_PER_SAMPLE, + INCOMPATIBLE_CHANNELS, +}; + +// Used to pass information from each task. +struct InfoErrorEvent { + InfoErrorSource source; + optional err; + optional file_type; + optional audio_stream_info; + optional decoding_err; +}; + +class AudioPipeline { + public: + /// @param speaker ESPHome speaker component for pipeline's audio output + /// @param buffer_size Size of the buffer in bytes between the reader and decoder + /// @param task_stack_in_psram True if the task stack should be allocated in PSRAM, false otherwise + /// @param task_name FreeRTOS task base name + /// @param priority FreeRTOS task priority + AudioPipeline(speaker::Speaker *speaker, size_t buffer_size, bool task_stack_in_psram, std::string base_name, + UBaseType_t priority); + + /// @brief Starts an audio pipeline given a media url + /// @param uri media file url + /// @return ESP_OK if successful or an appropriate error if not + void start_url(const std::string &uri); + + /// @brief Starts an audio pipeline given a AudioFile pointer + /// @param audio_file pointer to an AudioFile object + /// @return ESP_OK if successful or an appropriate error if not + void start_file(audio::AudioFile *audio_file); + + /// @brief Stops the pipeline. Sends a stop signal to each task (if running) and clears the ring buffers. + /// @return ESP_OK if successful or ESP_ERR_TIMEOUT if the tasks did not indicate they stopped + esp_err_t stop(); + + /// @brief Processes the state of the audio pipeline based on the info_error_queue_ and event_group_. Handles creating + /// and stopping the pipeline tasks. Needs to be regularly called to update the internal pipeline state. + /// @return AudioPipelineState + AudioPipelineState process_state(); + + /// @brief Suspends any running tasks + void suspend_tasks(); + /// @brief Resumes any running tasks + void resume_tasks(); + + uint32_t get_playback_ms() { return this->playback_ms_; } + + void set_pause_state(bool pause_state); + + protected: + /// @brief Allocates the event group and info error queue. + /// @return ESP_OK if successful or ESP_ERR_NO_MEM if it is unable to allocate all parts + esp_err_t allocate_communications_(); + + /// @brief Common start code for the pipeline, regardless if the source is a file or url. + /// @return ESP_OK if successful or an appropriate error if not + esp_err_t start_tasks_(); + + /// @brief Resets the task related pointers and deallocates their stacks. + void delete_tasks_(); + + std::string base_name_; + UBaseType_t priority_; + + uint32_t playback_ms_{0}; + + bool is_playing_{false}; + bool pause_state_{false}; + bool task_stack_in_psram_; + + // Pending file start state used to ensure the pipeline fully stops before attempting to start the next file + bool pending_url_{false}; + bool pending_file_{false}; + + speaker::Speaker *speaker_{nullptr}; + + std::string current_uri_{}; + audio::AudioFile *current_audio_file_{nullptr}; + + audio::AudioFileType current_audio_file_type_; + audio::AudioStreamInfo current_audio_stream_info_; + + size_t buffer_size_; // Ring buffer between reader and decoder + size_t transfer_buffer_size_; // Internal source/sink buffers for the audio reader and decoder + + std::weak_ptr raw_file_ring_buffer_; + + // Handles basic control/state of the three tasks + EventGroupHandle_t event_group_{nullptr}; + + // Receives detailed info (file type, stream info, resampling info) or specific errors from the three tasks + QueueHandle_t info_error_queue_{nullptr}; + + // Handles reading the media file from flash or a url + static void read_task(void *params); + TaskHandle_t read_task_handle_{nullptr}; + StaticTask_t read_task_stack_; + StackType_t *read_task_stack_buffer_{nullptr}; + + // Decodes the media file into PCM audio + static void decode_task(void *params); + TaskHandle_t decode_task_handle_{nullptr}; + StaticTask_t decode_task_stack_; + StackType_t *decode_task_stack_buffer_{nullptr}; +}; + +} // namespace speaker +} // namespace esphome + +#endif diff --git a/esphome/components/speaker/media_player/automation.h b/esphome/components/speaker/media_player/automation.h new file mode 100644 index 0000000000..d1a01aabc4 --- /dev/null +++ b/esphome/components/speaker/media_player/automation.h @@ -0,0 +1,26 @@ +#pragma once + +#include "speaker_media_player.h" + +#ifdef USE_ESP_IDF + +#include "esphome/components/audio/audio.h" +#include "esphome/core/automation.h" + +namespace esphome { +namespace speaker { + +template class PlayOnDeviceMediaAction : public Action, public Parented { + TEMPLATABLE_VALUE(audio::AudioFile *, audio_file) + TEMPLATABLE_VALUE(bool, announcement) + TEMPLATABLE_VALUE(bool, enqueue) + void play(Ts... x) override { + this->parent_->play_file(this->audio_file_.value(x...), this->announcement_.value(x...), + this->enqueue_.value(x...)); + } +}; + +} // namespace speaker +} // namespace esphome + +#endif diff --git a/esphome/components/speaker/media_player/speaker_media_player.cpp b/esphome/components/speaker/media_player/speaker_media_player.cpp new file mode 100644 index 0000000000..0a2585ce60 --- /dev/null +++ b/esphome/components/speaker/media_player/speaker_media_player.cpp @@ -0,0 +1,577 @@ +#include "speaker_media_player.h" + +#ifdef USE_ESP_IDF + +#include "esphome/core/log.h" + +#include "esphome/components/audio/audio.h" +#ifdef USE_OTA +#include "esphome/components/ota/ota_backend.h" +#endif + +namespace esphome { +namespace speaker { + +// Framework: +// - Media player that can handle two streams: one for media and one for announcements +// - Each stream has an individual speaker component for output +// - Each stream is handled by an ``AudioPipeline`` object with two parts/tasks +// - ``AudioReader`` handles reading from an HTTP source or from a PROGMEM flash set at compile time +// - ``AudioDecoder`` handles decoding the audio file. All formats are limited to two channels and 16 bits per sample +// - FLAC +// - MP3 (based on the libhelix decoder) +// - WAV +// - Each task runs until it is done processing the file or it receives a stop command +// - Inter-task communication uses a FreeRTOS Event Group +// - The ``AudioPipeline`` sets up a ring buffer between the reader and decoder tasks. The decoder task outputs audio +// directly to a speaker component. +// - The pipelines internal state needs to be processed by regularly calling ``process_state``. +// - Generic media player commands are received by the ``control`` function. The commands are added to the +// ``media_control_command_queue_`` to be processed in the component's loop +// - Local file play back is initiatied with ``play_file`` and adds it to the ``media_control_command_queue_`` +// - Starting a stream intializes the appropriate pipeline or stops it if it is already running +// - Volume and mute commands are achieved by the ``mute``, ``unmute``, ``set_volume`` functions. +// - Volume commands are ignored if the media control queue is full to avoid crashing with rapid volume +// increases/decreases. +// - These functions all send the appropriate information to the speakers to implement. +// - Pausing is implemented in the decoder task and is also sent directly to the media speaker component to decrease +// latency. +// - The components main loop performs housekeeping: +// - It reads the media control queue and processes it directly +// - It determines the overall state of the media player by considering the state of each pipeline +// - announcement playback takes highest priority +// - Handles playlists and repeating by starting the appropriate file when a previous file is finished +// - Logging only happens in the main loop task to reduce task stack memory usage. + +static const uint32_t MEDIA_CONTROLS_QUEUE_LENGTH = 20; + +static const UBaseType_t MEDIA_PIPELINE_TASK_PRIORITY = 1; +static const UBaseType_t ANNOUNCEMENT_PIPELINE_TASK_PRIORITY = 1; + +static const float FIRST_BOOT_DEFAULT_VOLUME = 0.5f; + +static const char *const TAG = "speaker_media_player"; + +void SpeakerMediaPlayer::setup() { + state = media_player::MEDIA_PLAYER_STATE_IDLE; + + this->media_control_command_queue_ = xQueueCreate(MEDIA_CONTROLS_QUEUE_LENGTH, sizeof(MediaCallCommand)); + + this->pref_ = global_preferences->make_preference(this->get_object_id_hash()); + + VolumeRestoreState volume_restore_state; + if (this->pref_.load(&volume_restore_state)) { + this->set_volume_(volume_restore_state.volume); + this->set_mute_state_(volume_restore_state.is_muted); + } else { + this->set_volume_(FIRST_BOOT_DEFAULT_VOLUME); + this->set_mute_state_(false); + } + +#ifdef USE_OTA + ota::get_global_ota_callback()->add_on_state_callback( + [this](ota::OTAState state, float progress, uint8_t error, ota::OTAComponent *comp) { + if (state == ota::OTA_STARTED) { + if (this->media_pipeline_ != nullptr) { + this->media_pipeline_->suspend_tasks(); + } + if (this->announcement_pipeline_ != nullptr) { + this->announcement_pipeline_->suspend_tasks(); + } + } else if (state == ota::OTA_ERROR) { + if (this->media_pipeline_ != nullptr) { + this->media_pipeline_->resume_tasks(); + } + if (this->announcement_pipeline_ != nullptr) { + this->announcement_pipeline_->resume_tasks(); + } + } + }); +#endif + + this->announcement_pipeline_ = + make_unique(this->announcement_speaker_, this->buffer_size_, this->task_stack_in_psram_, "ann", + ANNOUNCEMENT_PIPELINE_TASK_PRIORITY); + + if (this->announcement_pipeline_ == nullptr) { + ESP_LOGE(TAG, "Failed to create announcement pipeline"); + this->mark_failed(); + } + + if (!this->single_pipeline_()) { + this->media_pipeline_ = make_unique(this->media_speaker_, this->buffer_size_, + this->task_stack_in_psram_, "ann", MEDIA_PIPELINE_TASK_PRIORITY); + + if (this->media_pipeline_ == nullptr) { + ESP_LOGE(TAG, "Failed to create media pipeline"); + this->mark_failed(); + } + + // Setup callback to track the duration of audio played by the media pipeline + this->media_speaker_->add_audio_output_callback( + [this](uint32_t new_playback_ms, uint32_t remainder_us, uint32_t pending_ms, uint32_t write_timestamp) { + this->playback_ms_ += new_playback_ms; + this->remainder_us_ = remainder_us; + this->pending_ms_ = pending_ms; + this->last_audio_write_timestamp_ = write_timestamp; + this->playback_us_ = this->playback_ms_ * 1000 + this->remainder_us_; + }); + } + + ESP_LOGI(TAG, "Set up speaker media player"); +} + +void SpeakerMediaPlayer::set_playlist_delay_ms(AudioPipelineType pipeline_type, uint32_t delay_ms) { + switch (pipeline_type) { + case AudioPipelineType::ANNOUNCEMENT: + this->announcement_playlist_delay_ms_ = delay_ms; + break; + case AudioPipelineType::MEDIA: + this->media_playlist_delay_ms_ = delay_ms; + break; + } +} + +void SpeakerMediaPlayer::watch_media_commands_() { + if (!this->is_ready()) { + return; + } + + MediaCallCommand media_command; + esp_err_t err = ESP_OK; + + if (xQueueReceive(this->media_control_command_queue_, &media_command, 0) == pdTRUE) { + bool new_url = media_command.new_url.has_value() && media_command.new_url.value(); + bool new_file = media_command.new_file.has_value() && media_command.new_file.value(); + + if (new_url || new_file) { + bool enqueue = media_command.enqueue.has_value() && media_command.enqueue.value(); + + if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { + // Announcement playlist/pipeline + + if (!enqueue) { + // Clear the queue and ensure the loaded next item doesn't start playing + this->cancel_timeout("next_ann"); + this->announcement_playlist_.clear(); + } + + PlaylistItem playlist_item; + if (new_url) { + playlist_item.url = this->announcement_url_; + if (!enqueue) { + // Not adding to the queue, so directly start playback and internally unpause the pipeline + this->announcement_pipeline_->start_url(playlist_item.url.value()); + this->announcement_pipeline_->set_pause_state(false); + } + } else { + playlist_item.file = this->announcement_file_; + if (!enqueue) { + // Not adding to the queue, so directly start playback and internally unpause the pipeline + this->announcement_pipeline_->start_file(playlist_item.file.value()); + this->announcement_pipeline_->set_pause_state(false); + } + } + this->announcement_playlist_.push_back(playlist_item); + } else { + // Media playlist/pipeline + + if (!enqueue) { + // Clear the queue and ensure the loaded next item doesn't start playing + this->cancel_timeout("next_media"); + this->media_playlist_.clear(); + } + + this->is_paused_ = false; + PlaylistItem playlist_item; + if (new_url) { + playlist_item.url = this->media_url_; + if (!enqueue) { + // Not adding to the queue, so directly start playback and internally unpause the pipeline + this->media_pipeline_->start_url(playlist_item.url.value()); + this->media_pipeline_->set_pause_state(false); + } + } else { + playlist_item.file = this->media_file_; + if (!enqueue) { + // Not adding to the queue, so directly start playback and internally unpause the pipeline + this->media_pipeline_->start_file(playlist_item.file.value()); + this->media_pipeline_->set_pause_state(false); + } + } + this->media_playlist_.push_back(playlist_item); + } + + if (err != ESP_OK) { + ESP_LOGE(TAG, "Error starting the audio pipeline: %s", esp_err_to_name(err)); + this->status_set_error(); + } else { + this->status_clear_error(); + } + + return; // Don't process the new file play command further + } + + if (media_command.volume.has_value()) { + this->set_volume_(media_command.volume.value()); + this->publish_state(); + } + + if (media_command.command.has_value()) { + switch (media_command.command.value()) { + case media_player::MEDIA_PLAYER_COMMAND_PLAY: + if ((this->media_pipeline_ != nullptr) && (this->is_paused_)) { + this->media_pipeline_->set_pause_state(false); + } + this->is_paused_ = false; + break; + case media_player::MEDIA_PLAYER_COMMAND_PAUSE: + if ((this->media_pipeline_ != nullptr) && (!this->is_paused_)) { + this->media_pipeline_->set_pause_state(true); + } + this->is_paused_ = true; + break; + case media_player::MEDIA_PLAYER_COMMAND_STOP: + if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { + if (this->announcement_pipeline_ != nullptr) { + this->cancel_timeout("next_ann"); + this->announcement_playlist_.clear(); + this->announcement_pipeline_->stop(); + } + } else { + if (this->media_pipeline_ != nullptr) { + this->cancel_timeout("next_media"); + this->media_playlist_.clear(); + this->media_pipeline_->stop(); + } + } + break; + case media_player::MEDIA_PLAYER_COMMAND_TOGGLE: + if (this->media_pipeline_ != nullptr) { + if (this->is_paused_) { + this->media_pipeline_->set_pause_state(false); + this->is_paused_ = false; + } else { + this->media_pipeline_->set_pause_state(true); + this->is_paused_ = true; + } + } + break; + case media_player::MEDIA_PLAYER_COMMAND_MUTE: { + this->set_mute_state_(true); + + this->publish_state(); + break; + } + case media_player::MEDIA_PLAYER_COMMAND_UNMUTE: + this->set_mute_state_(false); + this->publish_state(); + break; + case media_player::MEDIA_PLAYER_COMMAND_VOLUME_UP: + this->set_volume_(std::min(1.0f, this->volume + this->volume_increment_)); + this->publish_state(); + break; + case media_player::MEDIA_PLAYER_COMMAND_VOLUME_DOWN: + this->set_volume_(std::max(0.0f, this->volume - this->volume_increment_)); + this->publish_state(); + break; + case media_player::MEDIA_PLAYER_COMMAND_REPEAT_ONE: + if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { + this->announcement_repeat_one_ = true; + } else { + this->media_repeat_one_ = true; + } + break; + case media_player::MEDIA_PLAYER_COMMAND_REPEAT_OFF: + if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { + this->announcement_repeat_one_ = false; + } else { + this->media_repeat_one_ = false; + } + break; + case media_player::MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST: + if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { + if (this->announcement_playlist_.empty()) { + this->announcement_playlist_.resize(1); + } + } else { + if (this->media_playlist_.empty()) { + this->media_playlist_.resize(1); + } + } + break; + default: + break; + } + } + } +} + +void SpeakerMediaPlayer::loop() { + this->watch_media_commands_(); + + // Determine state of the media player + media_player::MediaPlayerState old_state = this->state; + + AudioPipelineState old_media_pipeline_state = this->media_pipeline_state_; + if (this->media_pipeline_ != nullptr) { + this->media_pipeline_state_ = this->media_pipeline_->process_state(); + this->decoded_playback_ms_ = this->media_pipeline_->get_playback_ms(); + } + + if (this->media_pipeline_state_ == AudioPipelineState::ERROR_READING) { + ESP_LOGE(TAG, "The media pipeline's file reader encountered an error."); + } else if (this->media_pipeline_state_ == AudioPipelineState::ERROR_DECODING) { + ESP_LOGE(TAG, "The media pipeline's audio decoder encountered an error."); + } + + AudioPipelineState old_announcement_pipeline_state = this->announcement_pipeline_state_; + if (this->announcement_pipeline_ != nullptr) { + this->announcement_pipeline_state_ = this->announcement_pipeline_->process_state(); + } + + if (this->announcement_pipeline_state_ == AudioPipelineState::ERROR_READING) { + ESP_LOGE(TAG, "The announcement pipeline's file reader encountered an error."); + } else if (this->announcement_pipeline_state_ == AudioPipelineState::ERROR_DECODING) { + ESP_LOGE(TAG, "The announcement pipeline's audio decoder encountered an error."); + } + + if (this->announcement_pipeline_state_ != AudioPipelineState::STOPPED) { + this->state = media_player::MEDIA_PLAYER_STATE_ANNOUNCING; + } else { + if (!this->announcement_playlist_.empty()) { + uint32_t timeout_ms = 0; + if (old_announcement_pipeline_state == AudioPipelineState::PLAYING) { + // Finished the current announcement file + if (!this->announcement_repeat_one_) { + // Pop item off the playlist if repeat is disabled + this->announcement_playlist_.pop_front(); + } + // Only delay starting playback if moving on the next playlist item or repeating the current item + timeout_ms = this->announcement_playlist_delay_ms_; + } + + if (!this->announcement_playlist_.empty()) { + // Start the next announcement file + PlaylistItem playlist_item = this->announcement_playlist_.front(); + if (playlist_item.url.has_value()) { + this->announcement_pipeline_->start_url(playlist_item.url.value()); + } else if (playlist_item.file.has_value()) { + this->announcement_pipeline_->start_file(playlist_item.file.value()); + } + + if (timeout_ms > 0) { + // Pause pipeline internally to facilitiate delay between items + this->announcement_pipeline_->set_pause_state(true); + // Internally unpause the pipeline after the delay between playlist items + this->set_timeout("next_ann", timeout_ms, + [this]() { this->announcement_pipeline_->set_pause_state(this->is_paused_); }); + } + } + } else { + if (this->is_paused_) { + this->state = media_player::MEDIA_PLAYER_STATE_PAUSED; + } else if (this->media_pipeline_state_ == AudioPipelineState::PLAYING) { + this->state = media_player::MEDIA_PLAYER_STATE_PLAYING; + } else if (this->media_pipeline_state_ == AudioPipelineState::STOPPED) { + // Reset playback durations + this->decoded_playback_ms_ = 0; + this->playback_us_ = 0; + this->playback_ms_ = 0; + this->remainder_us_ = 0; + this->pending_ms_ = 0; + + if (!media_playlist_.empty()) { + uint32_t timeout_ms = 0; + if (old_media_pipeline_state == AudioPipelineState::PLAYING) { + // Finished the current media file + if (!this->media_repeat_one_) { + // Pop item off the playlist if repeat is disabled + this->media_playlist_.pop_front(); + } + // Only delay starting playback if moving on the next playlist item or repeating the current item + timeout_ms = this->announcement_playlist_delay_ms_; + } + if (!this->media_playlist_.empty()) { + PlaylistItem playlist_item = this->media_playlist_.front(); + if (playlist_item.url.has_value()) { + this->media_pipeline_->start_url(playlist_item.url.value()); + } else if (playlist_item.file.has_value()) { + this->media_pipeline_->start_file(playlist_item.file.value()); + } + + if (timeout_ms > 0) { + // Pause pipeline internally to facilitiate delay between items + this->media_pipeline_->set_pause_state(true); + // Internally unpause the pipeline after the delay between playlist items + this->set_timeout("next_media", timeout_ms, + [this]() { this->media_pipeline_->set_pause_state(this->is_paused_); }); + } + } + } else { + this->state = media_player::MEDIA_PLAYER_STATE_IDLE; + } + } + } + } + + if (this->state != old_state) { + this->publish_state(); + ESP_LOGD(TAG, "State changed to %s", media_player::media_player_state_to_string(this->state)); + } +} + +void SpeakerMediaPlayer::play_file(audio::AudioFile *media_file, bool announcement, bool enqueue) { + if (!this->is_ready()) { + // Ignore any commands sent before the media player is setup + return; + } + + MediaCallCommand media_command; + + media_command.new_file = true; + if (this->single_pipeline_() || announcement) { + this->announcement_file_ = media_file; + media_command.announce = true; + } else { + this->media_file_ = media_file; + media_command.announce = false; + } + media_command.enqueue = enqueue; + xQueueSend(this->media_control_command_queue_, &media_command, portMAX_DELAY); +} + +void SpeakerMediaPlayer::control(const media_player::MediaPlayerCall &call) { + if (!this->is_ready()) { + // Ignore any commands sent before the media player is setup + return; + } + + MediaCallCommand media_command; + + if (this->single_pipeline_() || (call.get_announcement().has_value() && call.get_announcement().value())) { + media_command.announce = true; + } else { + media_command.announce = false; + } + + if (call.get_media_url().has_value()) { + std::string new_uri = call.get_media_url().value(); + + media_command.new_url = true; + if (this->single_pipeline_() || (call.get_announcement().has_value() && call.get_announcement().value())) { + this->announcement_url_ = new_uri; + } else { + this->media_url_ = new_uri; + } + + if (call.get_command().has_value()) { + if (call.get_command().value() == media_player::MEDIA_PLAYER_COMMAND_ENQUEUE) { + media_command.enqueue = true; + } + } + + xQueueSend(this->media_control_command_queue_, &media_command, portMAX_DELAY); + return; + } + + if (call.get_volume().has_value()) { + media_command.volume = call.get_volume().value(); + // Wait 0 ticks for queue to be free, volume sets aren't that important! + xQueueSend(this->media_control_command_queue_, &media_command, 0); + return; + } + + if (call.get_command().has_value()) { + media_command.command = call.get_command().value(); + TickType_t ticks_to_wait = portMAX_DELAY; + if ((call.get_command().value() == media_player::MEDIA_PLAYER_COMMAND_VOLUME_UP) || + (call.get_command().value() == media_player::MEDIA_PLAYER_COMMAND_VOLUME_DOWN)) { + ticks_to_wait = 0; // Wait 0 ticks for queue to be free, volume sets aren't that important! + } + xQueueSend(this->media_control_command_queue_, &media_command, ticks_to_wait); + return; + } +} + +media_player::MediaPlayerTraits SpeakerMediaPlayer::get_traits() { + auto traits = media_player::MediaPlayerTraits(); + if (!this->single_pipeline_()) { + traits.set_supports_pause(true); + } + + if (this->announcement_format_.has_value()) { + traits.get_supported_formats().push_back(this->announcement_format_.value()); + } + if (this->media_format_.has_value()) { + traits.get_supported_formats().push_back(this->media_format_.value()); + } else if (this->single_pipeline_() && this->announcement_format_.has_value()) { + // Only one pipeline is defined, so use the announcement format (if configured) for the default purpose + media_player::MediaPlayerSupportedFormat media_format = this->announcement_format_.value(); + media_format.purpose = media_player::MediaPlayerFormatPurpose::PURPOSE_DEFAULT; + traits.get_supported_formats().push_back(media_format); + } + + return traits; +}; + +void SpeakerMediaPlayer::save_volume_restore_state_() { + VolumeRestoreState volume_restore_state; + volume_restore_state.volume = this->volume; + volume_restore_state.is_muted = this->is_muted_; + this->pref_.save(&volume_restore_state); +} + +void SpeakerMediaPlayer::set_mute_state_(bool mute_state) { + if (this->media_speaker_ != nullptr) { + this->media_speaker_->set_mute_state(mute_state); + } + if (this->announcement_speaker_ != nullptr) { + this->announcement_speaker_->set_mute_state(mute_state); + } + + bool old_mute_state = this->is_muted_; + this->is_muted_ = mute_state; + + this->save_volume_restore_state_(); + + if (old_mute_state != mute_state) { + if (mute_state) { + this->defer([this]() { this->mute_trigger_->trigger(); }); + } else { + this->defer([this]() { this->unmute_trigger_->trigger(); }); + } + } +} + +void SpeakerMediaPlayer::set_volume_(float volume, bool publish) { + // Remap the volume to fit with in the configured limits + float bounded_volume = remap(volume, 0.0f, 1.0f, this->volume_min_, this->volume_max_); + + if (this->media_speaker_ != nullptr) { + this->media_speaker_->set_volume(bounded_volume); + } + + if (this->announcement_speaker_ != nullptr) { + this->announcement_speaker_->set_volume(bounded_volume); + } + + if (publish) { + this->volume = volume; + this->save_volume_restore_state_(); + } + + // Turn on the mute state if the volume is effectively zero, off otherwise + if (volume < 0.001) { + this->set_mute_state_(true); + } else { + this->set_mute_state_(false); + } + + this->defer([this, volume]() { this->volume_trigger_->trigger(volume); }); +} + +} // namespace speaker +} // namespace esphome + +#endif diff --git a/esphome/components/speaker/media_player/speaker_media_player.h b/esphome/components/speaker/media_player/speaker_media_player.h new file mode 100644 index 0000000000..6cbce91866 --- /dev/null +++ b/esphome/components/speaker/media_player/speaker_media_player.h @@ -0,0 +1,160 @@ +#pragma once + +#ifdef USE_ESP_IDF + +#include "audio_pipeline.h" + +#include "esphome/components/audio/audio.h" + +#include "esphome/components/media_player/media_player.h" +#include "esphome/components/speaker/speaker.h" + +#include "esphome/core/automation.h" +#include "esphome/core/component.h" +#include "esphome/core/preferences.h" + +#include +#include +#include + +namespace esphome { +namespace speaker { + +struct MediaCallCommand { + optional command; + optional volume; + optional announce; + optional new_url; + optional new_file; + optional enqueue; +}; + +struct PlaylistItem { + optional url; + optional file; +}; + +struct VolumeRestoreState { + float volume; + bool is_muted; +}; + +class SpeakerMediaPlayer : public Component, public media_player::MediaPlayer { + public: + float get_setup_priority() const override { return esphome::setup_priority::PROCESSOR; } + void setup() override; + void loop() override; + + // MediaPlayer implementations + media_player::MediaPlayerTraits get_traits() override; + bool is_muted() const override { return this->is_muted_; } + + void set_buffer_size(size_t buffer_size) { this->buffer_size_ = buffer_size; } + void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; } + + // Percentage to increase or decrease the volume for volume up or volume down commands + void set_volume_increment(float volume_increment) { this->volume_increment_ = volume_increment; } + + void set_volume_max(float volume_max) { this->volume_max_ = volume_max; } + void set_volume_min(float volume_min) { this->volume_min_ = volume_min; } + + void set_announcement_speaker(Speaker *announcement_speaker) { this->announcement_speaker_ = announcement_speaker; } + void set_announcement_format(const media_player::MediaPlayerSupportedFormat &announcement_format) { + this->announcement_format_ = announcement_format; + } + void set_media_speaker(Speaker *media_speaker) { this->media_speaker_ = media_speaker; } + void set_media_format(const media_player::MediaPlayerSupportedFormat &media_format) { + this->media_format_ = media_format; + } + + Trigger<> *get_mute_trigger() const { return this->mute_trigger_; } + Trigger<> *get_unmute_trigger() const { return this->unmute_trigger_; } + Trigger *get_volume_trigger() const { return this->volume_trigger_; } + + void play_file(audio::AudioFile *media_file, bool announcement, bool enqueue); + + uint32_t get_playback_ms() const { return this->playback_ms_; } + uint32_t get_playback_us() const { return this->playback_us_; } + uint32_t get_decoded_playback_ms() const { return this->decoded_playback_ms_; } + + void set_playlist_delay_ms(AudioPipelineType pipeline_type, uint32_t delay_ms); + + protected: + // Receives commands from HA or from the voice assistant component + // Sends commands to the media_control_commanda_queue_ + void control(const media_player::MediaPlayerCall &call) override; + + /// @brief Updates this->volume and saves volume/mute state to flash for restortation if publish is true. + void set_volume_(float volume, bool publish = true); + + /// @brief Sets the mute state. Restores previous volume if unmuting. Always saves volume/mute state to flash for + /// restoration. + /// @param mute_state If true, audio will be muted. If false, audio will be unmuted + void set_mute_state_(bool mute_state); + + /// @brief Saves the current volume and mute state to the flash for restoration. + void save_volume_restore_state_(); + + /// Returns true if the media player has only the announcement pipeline defined, false if both the announcement and + /// media pipelines are defined. + inline bool single_pipeline_() { return (this->media_speaker_ == nullptr); } + + // Processes commands from media_control_command_queue_. + void watch_media_commands_(); + + std::unique_ptr announcement_pipeline_; + std::unique_ptr media_pipeline_; + Speaker *media_speaker_{nullptr}; + Speaker *announcement_speaker_{nullptr}; + + optional media_format_; + AudioPipelineState media_pipeline_state_{AudioPipelineState::STOPPED}; + std::string media_url_{}; // only modified by control function + audio::AudioFile *media_file_{}; // only modified by play_file function + bool media_repeat_one_{false}; + uint32_t media_playlist_delay_ms_{0}; + + optional announcement_format_; + AudioPipelineState announcement_pipeline_state_{AudioPipelineState::STOPPED}; + std::string announcement_url_{}; // only modified by control function + audio::AudioFile *announcement_file_{}; // only modified by play_file function + bool announcement_repeat_one_{false}; + uint32_t announcement_playlist_delay_ms_{0}; + + QueueHandle_t media_control_command_queue_; + + std::deque announcement_playlist_; + std::deque media_playlist_; + + size_t buffer_size_; + + bool task_stack_in_psram_; + + bool is_paused_{false}; + bool is_muted_{false}; + + // The amount to change the volume on volume up/down commands + float volume_increment_; + + float volume_max_; + float volume_min_; + + // Used to save volume/mute state for restoration on reboot + ESPPreferenceObject pref_; + + Trigger<> *mute_trigger_ = new Trigger<>(); + Trigger<> *unmute_trigger_ = new Trigger<>(); + Trigger *volume_trigger_ = new Trigger(); + + uint32_t decoded_playback_ms_{0}; + uint32_t playback_us_{0}; + uint32_t playback_ms_{0}; + uint32_t remainder_us_{0}; + uint32_t pending_ms_{0}; + uint32_t last_audio_write_timestamp_{0}; +}; + +} // namespace speaker +} // namespace esphome + +#endif diff --git a/tests/components/media_player/common.yaml b/tests/components/media_player/common.yaml index af0d5c7765..763bc231c0 100644 --- a/tests/components/media_player/common.yaml +++ b/tests/components/media_player/common.yaml @@ -21,6 +21,8 @@ media_player: - media_player.pause: on_play: - media_player.stop: + - media_player.stop: + announcement: true on_pause: - media_player.toggle: - wait_until: diff --git a/tests/components/speaker/common-media_player.yaml b/tests/components/speaker/common-media_player.yaml new file mode 100644 index 0000000000..edc9f670fc --- /dev/null +++ b/tests/components/speaker/common-media_player.yaml @@ -0,0 +1,12 @@ +<<: !include common.yaml + +media_player: + - platform: speaker + id: speaker_media_player_id + announcement_pipeline: + speaker: speaker_id + buffer_size: 1000000 + volume_increment: 0.02 + volume_max: 0.95 + volume_min: 0.0 + task_stack_in_psram: true diff --git a/tests/components/speaker/media_player.esp32-idf.yaml b/tests/components/speaker/media_player.esp32-idf.yaml new file mode 100644 index 0000000000..4712e4bae8 --- /dev/null +++ b/tests/components/speaker/media_player.esp32-idf.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + i2s_bclk_pin: GPIO27 + i2s_lrclk_pin: GPIO26 + i2s_mclk_pin: GPIO25 + i2s_dout_pin: GPIO23 + +<<: !include common-media_player.yaml diff --git a/tests/components/speaker/media_player.esp32-s3-idf.yaml b/tests/components/speaker/media_player.esp32-s3-idf.yaml new file mode 100644 index 0000000000..b3eec04d23 --- /dev/null +++ b/tests/components/speaker/media_player.esp32-s3-idf.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO2 + sda_pin: GPIO3 + i2s_bclk_pin: GPIO4 + i2s_lrclk_pin: GPIO5 + i2s_mclk_pin: GPIO6 + i2s_dout_pin: GPIO7 + +<<: !include common-media_player.yaml From abdf215d3a54eff4b33b5d76207372245b5d1031 Mon Sep 17 00:00:00 2001 From: mystster Date: Tue, 11 Feb 2025 05:29:27 +0900 Subject: [PATCH 181/194] Add partial update of GDEW029T5 e-paper display (#8162) Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 2 +- .../waveshare_epaper/waveshare_epaper.cpp | 242 ++++++++++++++++-- .../waveshare_epaper/waveshare_epaper.h | 21 +- tests/components/waveshare_epaper/common.yaml | 1 + 4 files changed, 236 insertions(+), 30 deletions(-) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 3a5151682f..81afc159a5 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -120,7 +120,7 @@ MODELS = { "2.13in-ttgo-b74": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B74), "2.90in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN), "2.90inv2": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN_V2), - "gdew029t5": ("b", GDEW029T5), + "gdew029t5": ("c", GDEW029T5), "2.70in": ("b", WaveshareEPaper2P7In), "2.70in-b": ("b", WaveshareEPaper2P7InB), "2.70in-bv2": ("b", WaveshareEPaper2P7InBV2), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index fb9e8ff6e5..2ff271f999 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -1596,15 +1596,108 @@ void WaveshareEPaper2P9InV2R2::set_full_update_every(uint32_t full_update_every) // Datasheet: // - https://v4.cecdn.yun300.cn/100001_1909185148/SSD1680.pdf // - https://github.com/adafruit/Adafruit_EPD/blob/master/src/panels/ThinkInk_290_Grayscale4_T5.h +// - https://github.com/ZinggJM/GxEPD2/blob/master/src/epd/GxEPD2_290_T5.cpp +// - http://www.e-paper-display.com/GDEW029T5%20V3.1%20Specification5c22.pdf? // ======================================================== -void GDEW029T5::initialize() { - // from https://www.waveshare.com/w/upload/b/bb/2.9inch-e-paper-b-specification.pdf, page 37 - // EPD hardware init start - this->reset_(); +// full screen update LUT +static const uint8_t LUT_20_VCOMDC_29_5[] = { + 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, 0x00, 0x14, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_21_WW_29_5[] = { + 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x40, 0x14, + 0x00, 0x00, 0x00, 0x01, 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_22_BW_29_5[] = { + 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x40, 0x14, + 0x00, 0x00, 0x00, 0x01, 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_23_WB_29_5[] = { + 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14, + 0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_24_BB_29_5[] = { + 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14, + 0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +// partial screen update LUT +static const uint8_t LUT_20_VCOMDC_PARTIAL_29_5[] = { + 0x00, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_21_WW_PARTIAL_29_5[] = { + 0x00, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_22_BW_PARTIAL_29_5[] = { + 0x80, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_23_WB_PARTIAL_29_5[] = { + 0x40, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_24_BB_PARTIAL_29_5[] = { + 0x00, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +void GDEW029T5::power_on_() { + if (!this->power_is_on_) { + this->command(0x04); + this->wait_until_idle_(); + } + this->power_is_on_ = true; +} + +void GDEW029T5::power_off_() { + this->command(0x02); + this->wait_until_idle_(); + this->power_is_on_ = false; +} + +void GDEW029T5::deep_sleep() { + this->power_off_(); + if (this->deep_sleep_between_updates_) { + this->command(0x07); // deep sleep + this->data(0xA5); // check code + ESP_LOGD(TAG, "go to deep sleep"); + this->is_deep_sleep_ = true; + } +} + +void GDEW029T5::init_display_() { + // from https://github.com/ZinggJM/GxEPD2/blob/master/src/epd/GxEPD2_290_T5.cpp + + // Hardware Initialization + if (this->deep_sleep_between_updates_ && this->is_deep_sleep_) { + ESP_LOGI(TAG, "wake up from deep sleep"); + this->reset_(); + this->is_deep_sleep_ = false; + } // COMMAND POWER SETTINGS - this->command(0x00); + this->command(0x01); this->data(0x03); this->data(0x00); this->data(0x2b); @@ -1617,40 +1710,122 @@ void GDEW029T5::initialize() { this->data(0x17); this->data(0x17); - // COMMAND POWER ON - this->command(0x04); - this->wait_until_idle_(); - - // Not sure what this does but it's in the Adafruit EPD library - this->command(0xFF); - this->wait_until_idle_(); + this->power_on_(); // COMMAND PANEL SETTING this->command(0x00); // 128x296 resolution: 10 - // LUT from OTP: 0 + // LUT from register: 1 // B/W mode (doesn't work): 1 // scan-up: 1 // shift-right: 1 // booster ON: 1 // no soft reset: 1 - this->data(0b10011111); + this->data(0b10111111); + this->data(0x0d); // VCOM to 0V fast + this->command(0x30); // PLL setting + this->data(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ + this->command(0x61); // resolution setting + this->data(this->get_width_internal()); + this->data(this->get_height_internal() >> 8); + this->data(this->get_height_internal() & 0xFF); - // COMMAND RESOLUTION SETTING - // set to 128x296 by COMMAND PANEL SETTING - - // COMMAND VCOM AND DATA INTERVAL SETTING - // use defaults for white border and ESPHome image polarity - - // EPD hardware init end + ESP_LOGD(TAG, "panel setting done"); } + +void GDEW029T5::initialize() { + // from https://www.waveshare.com/w/upload/b/bb/2.9inch-e-paper-b-specification.pdf, page 37 + if (this->reset_pin_ != nullptr) + this->deep_sleep_between_updates_ = true; + + // old buffer for partial update + ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + this->old_buffer_ = allocator.allocate(this->get_buffer_length_()); + if (this->old_buffer_ == nullptr) { + ESP_LOGE(TAG, "Could not allocate old buffer for display!"); + return; + } + for (size_t i = 0; i < this->get_buffer_length_(); i++) { + this->old_buffer_[i] = 0xFF; + } +} + +// initialize for full(normal) update +void GDEW029T5::init_full_() { + this->init_display_(); + this->command(0x82); // vcom_DC setting + this->data(0x08); + this->command(0X50); // VCOM AND DATA INTERVAL SETTING + this->data(0x97); // WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7 + this->command(0x20); + this->write_lut_(LUT_20_VCOMDC_29_5, sizeof(LUT_20_VCOMDC_29_5)); + this->command(0x21); + this->write_lut_(LUT_21_WW_29_5, sizeof(LUT_21_WW_29_5)); + this->command(0x22); + this->write_lut_(LUT_22_BW_29_5, sizeof(LUT_22_BW_29_5)); + this->command(0x23); + this->write_lut_(LUT_23_WB_29_5, sizeof(LUT_23_WB_29_5)); + this->command(0x24); + this->write_lut_(LUT_24_BB_29_5, sizeof(LUT_24_BB_29_5)); + ESP_LOGD(TAG, "initialized full update"); +} + +// initialzie for partial update +void GDEW029T5::init_partial_() { + this->init_display_(); + this->command(0x82); // vcom_DC setting + this->data(0x08); + this->command(0X50); // VCOM AND DATA INTERVAL SETTING + this->data(0x17); // WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7 + this->command(0x20); + this->write_lut_(LUT_20_VCOMDC_PARTIAL_29_5, sizeof(LUT_20_VCOMDC_PARTIAL_29_5)); + this->command(0x21); + this->write_lut_(LUT_21_WW_PARTIAL_29_5, sizeof(LUT_21_WW_PARTIAL_29_5)); + this->command(0x22); + this->write_lut_(LUT_22_BW_PARTIAL_29_5, sizeof(LUT_22_BW_PARTIAL_29_5)); + this->command(0x23); + this->write_lut_(LUT_23_WB_PARTIAL_29_5, sizeof(LUT_23_WB_PARTIAL_29_5)); + this->command(0x24); + this->write_lut_(LUT_24_BB_PARTIAL_29_5, sizeof(LUT_24_BB_PARTIAL_29_5)); + ESP_LOGD(TAG, "initialized partial update"); +} + void HOT GDEW029T5::display() { + bool full_update = this->at_update_ == 0; + if (full_update) { + this->init_full_(); + } else { + this->init_partial_(); + this->command(0x91); // partial in + // set partial window + this->command(0x90); + // this->data(0); + this->data(0); + // this->data(0); + this->data((this->get_width_internal() - 1) % 256); + this->data(0); + this->data(0); + this->data(((this->get_height_internal() - 1)) / 256); + this->data(((this->get_height_internal() - 1)) % 256); + this->data(0x01); + } + // input old buffer data + this->command(0x10); + delay(2); + this->start_data_(); + for (size_t i = 0; i < this->get_buffer_length_(); i++) { + this->write_byte(this->old_buffer_[i]); + } + this->end_data_(); + delay(2); + // COMMAND DATA START TRANSMISSION 2 (B/W only) this->command(0x13); delay(2); this->start_data_(); for (size_t i = 0; i < this->get_buffer_length_(); i++) { this->write_byte(this->buffer_[i]); + this->old_buffer_[i] = this->buffer_[i]; } this->end_data_(); delay(2); @@ -1660,10 +1835,28 @@ void HOT GDEW029T5::display() { delay(2); this->wait_until_idle_(); - // COMMAND POWER OFF - // NOTE: power off < deep sleep - this->command(0x02); + if (full_update) { + ESP_LOGD(TAG, "full update done"); + } else { + this->command(0x92); // partial out + ESP_LOGD(TAG, "partial update done"); + } + + this->at_update_ = (this->at_update_ + 1) % this->full_update_every_; + // COMMAND deep sleep + this->deep_sleep(); } + +void GDEW029T5::write_lut_(const uint8_t *lut, const uint8_t size) { + // COMMAND WRITE LUT REGISTER + this->start_data_(); + for (uint8_t i = 0; i < size; i++) + this->write_byte(lut[i]); + this->end_data_(); +} + +void GDEW029T5::set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; } + int GDEW029T5::get_width_internal() { return 128; } int GDEW029T5::get_height_internal() { return 296; } void GDEW029T5::dump_config() { @@ -1672,6 +1865,7 @@ void GDEW029T5::dump_config() { LOG_PIN(" Reset Pin: ", this->reset_pin_); LOG_PIN(" DC Pin: ", this->dc_pin_); LOG_PIN(" Busy Pin: ", this->busy_pin_); + ESP_LOGCONFIG(TAG, " Full Update Every: %" PRIu32, this->full_update_every_); LOG_UPDATE_INTERVAL(this); } diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 0fc1051268..e0c8001a50 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -254,16 +254,27 @@ class GDEW029T5 : public WaveshareEPaper { void dump_config() override; - void deep_sleep() override { - // COMMAND DEEP SLEEP - this->command(0x07); - this->data(0xA5); // check byte - } + void deep_sleep() override; + void set_full_update_every(uint32_t full_update_every); protected: + void init_display_(); + void init_full_(); + void init_partial_(); + void write_lut_(const uint8_t *lut, uint8_t size); + void power_off_(); + void power_on_(); int get_width_internal() override; int get_height_internal() override; + + private: + uint32_t full_update_every_{30}; + uint32_t at_update_{0}; + bool deep_sleep_between_updates_{false}; + bool power_is_on_{false}; + bool is_deep_sleep_{false}; + uint8_t *old_buffer_{nullptr}; }; class WaveshareEPaper2P7InV2 : public WaveshareEPaper { diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index ff9ddb955f..1d77e0cf38 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -459,6 +459,7 @@ display: reset_pin: allow_other_uses: true number: ${reset_pin} + full_update_every: 30 lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); From b667ceacedbbc5f248801460aef6432b62c6097c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=A1ta=20GEEK?= <63705187+TataGEEK@users.noreply.github.com> Date: Tue, 11 Feb 2025 01:35:56 +0100 Subject: [PATCH 182/194] Add waveshare 2.9inch e-Paper HAT (D) (#7906) Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 4 + .../waveshare_epaper/waveshare_epaper.cpp | 87 +++++++++++++++++++ .../waveshare_epaper/waveshare_epaper.h | 20 +++++ tests/components/waveshare_epaper/common.yaml | 19 ++++ 4 files changed, 130 insertions(+) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 81afc159a5..f0064c6a4d 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -55,6 +55,9 @@ GDEW029T5 = waveshare_epaper_ns.class_("GDEW029T5", WaveshareEPaper) WaveshareEPaper2P9InDKE = waveshare_epaper_ns.class_( "WaveshareEPaper2P9InDKE", WaveshareEPaper ) +WaveshareEPaper2P9InD = waveshare_epaper_ns.class_( + "WaveshareEPaper2P9InD", WaveshareEPaper +) WaveshareEPaper4P2In = waveshare_epaper_ns.class_( "WaveshareEPaper4P2In", WaveshareEPaper ) @@ -128,6 +131,7 @@ MODELS = { "2.90in-b": ("b", WaveshareEPaper2P9InB), "2.90in-bv3": ("b", WaveshareEPaper2P9InBV3), "2.90inv2-r2": ("c", WaveshareEPaper2P9InV2R2), + "2.90in-d": ("b", WaveshareEPaper2P9InD), "2.90in-dke": ("c", WaveshareEPaper2P9InDKE), "4.20in": ("b", WaveshareEPaper4P2In), "4.20in-bv2": ("b", WaveshareEPaper4P2InBV2), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 2ff271f999..f240c98096 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -1211,6 +1211,93 @@ void WaveshareEPaper2P9InB::dump_config() { LOG_UPDATE_INTERVAL(this); } +// ======================================================== +// Waveshare 2.9-inch E-Paper (Type D) +// Waveshare WIKI: https://www.waveshare.com/wiki/Pico-ePaper-2.9-D +// Datasheet: https://www.waveshare.com/w/upload/b/b5/2.9inch_e-Paper_(D)_Specification.pdf +// ======================================================== + +void WaveshareEPaper2P9InD::initialize() { + // EPD hardware init start + this->reset_(); + + // Booster Soft Start + this->command(0x06); // Command: BTST + this->data(0x17); // Soft start configuration Phase A + this->data(0x17); // Soft start configuration Phase B + this->data(0x17); // Soft start configuration Phase C + + // Power Setting + this->command(0x01); // Command: PWR + this->data(0x03); // Intern DC/DC for VDH/VDL and VGH/VGL + this->data(0x00); // Default configuration VCOM_HV and VGHL_LV + this->data(0x2b); // VDH = 10.8 V + this->data(0x2b); // VDL = -10.8 V + + // Power ON + this->command(0x04); // Command: PON + this->wait_until_idle_(); + + // Panel settings + this->command(0x00); // Command: PSR + this->data(0x1F); // LUT from OTP, black and white mode, default scan + + // PLL Control + this->command(0x30); // Command: PLL + this->data(0x3A); // Default PLL frequency + + // Resolution settings + this->command(0x61); // Command: TRES + this->data(0x80); // Width: 128 + this->data(0x01); // Height MSB: 296 + this->data(0x28); // Height LSB: 296 + + // VCOM and data interval settings + this->command(0x50); // Command: CDI + this->data(0x77); + + // VCOM_DC settings + this->command(0x82); // Command: VDCS + this->data(0x12); // Dafault VCOM_DC +} + +void WaveshareEPaper2P9InD::display() { + // Start transmitting old data (clearing buffer) + this->command(0x10); // Command: DTM1 (OLD frame data) + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + // Start transmitting new data (updated content) + this->command(0x13); // Command: DTM2 (NEW frame data) + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + // Refresh Display + this->command(0x12); // Command: DRF + this->wait_until_idle_(); + + // Enter Power Off + this->command(0x02); // Command: POF + this->wait_until_idle_(); + + // Enter Deep Sleep + this->command(0x07); // Command: DSLP + this->data(0xA5); +} + +int WaveshareEPaper2P9InD::get_width_internal() { return 128; } +int WaveshareEPaper2P9InD::get_height_internal() { return 296; } +void WaveshareEPaper2P9InD::dump_config() { + LOG_DISPLAY("", "Waveshare E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 2.9in (D)"); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} + // DKE 2.9 // https://www.badge.team/docs/badges/sha2017/hardware/#e-ink-display-the-dke-group-depg0290b1 // https://www.badge.team/docs/badges/sha2017/hardware/DEPG0290B01V3.0.pdf diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index e0c8001a50..c2277f2962 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -427,6 +427,26 @@ class WaveshareEPaper2P9InDKE : public WaveshareEPaper { int get_height_internal() override; }; +class WaveshareEPaper2P9InD : public WaveshareEPaper { + public: + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + // COMMAND DEEP SLEEP + this->command(0x07); + this->data(0xA5); + } + + protected: + int get_width_internal() override; + + int get_height_internal() override; +}; + class WaveshareEPaper4P2In : public WaveshareEPaper { public: void initialize() override; diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index 1d77e0cf38..4a67ccd67d 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -714,6 +714,25 @@ display: lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.90in-d + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + reset_duration: 200ms + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper model: 2.90in spi_id: spi_waveshare_epaper From 8b7aa4c1102f2102d38a2d189e678b6761ee7d51 Mon Sep 17 00:00:00 2001 From: guillempages Date: Tue, 11 Feb 2025 01:39:03 +0100 Subject: [PATCH 183/194] [http_request]Use std::string for headers (#8225) --- esphome/components/http_request/http_request.h | 4 ++-- esphome/components/http_request/http_request_arduino.cpp | 2 +- esphome/components/http_request/http_request_idf.cpp | 2 +- esphome/components/online_image/online_image.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/esphome/components/http_request/http_request.h b/esphome/components/http_request/http_request.h index b2ce718ec4..e98fd1a475 100644 --- a/esphome/components/http_request/http_request.h +++ b/esphome/components/http_request/http_request.h @@ -18,8 +18,8 @@ namespace esphome { namespace http_request { struct Header { - const char *name; - const char *value; + std::string name; + std::string value; }; // Some common HTTP status codes diff --git a/esphome/components/http_request/http_request_arduino.cpp b/esphome/components/http_request/http_request_arduino.cpp index 85a1312aaa..b0067e7839 100644 --- a/esphome/components/http_request/http_request_arduino.cpp +++ b/esphome/components/http_request/http_request_arduino.cpp @@ -96,7 +96,7 @@ std::shared_ptr HttpRequestArduino::start(std::string url, std::s container->client_.setUserAgent(this->useragent_); } for (const auto &header : headers) { - container->client_.addHeader(header.name, header.value, false, true); + container->client_.addHeader(header.name.c_str(), header.value.c_str(), false, true); } // returned needed headers must be collected before the requests diff --git a/esphome/components/http_request/http_request_idf.cpp b/esphome/components/http_request/http_request_idf.cpp index 66f064c2ce..78c37403f5 100644 --- a/esphome/components/http_request/http_request_idf.cpp +++ b/esphome/components/http_request/http_request_idf.cpp @@ -84,7 +84,7 @@ std::shared_ptr HttpRequestIDF::start(std::string url, std::strin container->set_secure(secure); for (const auto &header : headers) { - esp_http_client_set_header(client, header.name, header.value); + esp_http_client_set_header(client, header.name.c_str(), header.value.c_str()); } const int body_len = body.length(); diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index da0e88a904..a1c530c2ab 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -124,7 +124,7 @@ void OnlineImage::update() { default: accept_mime_type = "image/*"; } - accept_header.value = (accept_mime_type + ",*/*;q=0.8").c_str(); + accept_header.value = accept_mime_type + ",*/*;q=0.8"; headers.push_back(accept_header); From c9e7562aff0b3a94c47baf3dc946646564432a3e Mon Sep 17 00:00:00 2001 From: guillempages Date: Tue, 11 Feb 2025 12:12:13 +0100 Subject: [PATCH 184/194] [online_image] Improve error handling (#8212) --- esphome/components/online_image/image_decoder.cpp | 12 +++++++++++- esphome/components/online_image/image_decoder.h | 11 ++++++----- esphome/components/online_image/jpeg_image.cpp | 7 ++++--- esphome/components/online_image/jpeg_image.h | 2 +- esphome/components/online_image/online_image.cpp | 7 ++++++- esphome/components/online_image/png_image.cpp | 7 ++++++- esphome/components/online_image/png_image.h | 2 +- 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/esphome/components/online_image/image_decoder.cpp b/esphome/components/online_image/image_decoder.cpp index 2958d8671d..d8c0cc33c4 100644 --- a/esphome/components/online_image/image_decoder.cpp +++ b/esphome/components/online_image/image_decoder.cpp @@ -25,6 +25,15 @@ void ImageDecoder::draw(int x, int y, int w, int h, const Color &color) { } } +DownloadBuffer::DownloadBuffer(size_t size) : size_(size) { + this->buffer_ = this->allocator_.allocate(size); + this->reset(); + if (!this->buffer_) { + ESP_LOGE(TAG, "Initial allocation of download buffer failed!"); + this->size_ = 0; + } +} + uint8_t *DownloadBuffer::data(size_t offset) { if (offset > this->size_) { ESP_LOGE(TAG, "Tried to access beyond download buffer bounds!!!"); @@ -46,12 +55,13 @@ size_t DownloadBuffer::resize(size_t size) { return size; } this->allocator_.deallocate(this->buffer_, this->size_); - this->size_ = size; this->buffer_ = this->allocator_.allocate(size); this->reset(); if (this->buffer_) { + this->size_ = size; return size; } else { + this->size_ = 0; return 0; } } diff --git a/esphome/components/online_image/image_decoder.h b/esphome/components/online_image/image_decoder.h index 957af49ac9..d11b8b46d3 100644 --- a/esphome/components/online_image/image_decoder.h +++ b/esphome/components/online_image/image_decoder.h @@ -29,8 +29,12 @@ class ImageDecoder { * @brief Initialize the decoder. * * @param download_size The total number of bytes that need to be downloaded for the image. + * @return int Returns 0 on success, a {@see DecodeError} value in case of an error. */ - virtual void prepare(size_t download_size) { this->download_size_ = download_size; } + virtual int prepare(size_t download_size) { + this->download_size_ = download_size; + return 0; + } /** * @brief Decode a part of the image. It will try reading from the buffer. @@ -83,10 +87,7 @@ class ImageDecoder { class DownloadBuffer { public: - DownloadBuffer(size_t size) : size_(size) { - this->buffer_ = this->allocator_.allocate(size); - this->reset(); - } + DownloadBuffer(size_t size); virtual ~DownloadBuffer() { this->allocator_.deallocate(this->buffer_, this->size_); } diff --git a/esphome/components/online_image/jpeg_image.cpp b/esphome/components/online_image/jpeg_image.cpp index 773b85a2c4..0aff576da8 100644 --- a/esphome/components/online_image/jpeg_image.cpp +++ b/esphome/components/online_image/jpeg_image.cpp @@ -41,13 +41,14 @@ static int draw_callback(JPEGDRAW *jpeg) { return 1; } -void JpegDecoder::prepare(size_t download_size) { +int JpegDecoder::prepare(size_t download_size) { ImageDecoder::prepare(download_size); auto size = this->image_->resize_download_buffer(download_size); if (size < download_size) { - ESP_LOGE(TAG, "Resize failed!"); - // TODO: return an error code; + ESP_LOGE(TAG, "Download buffer resize failed!"); + return DECODE_ERROR_OUT_OF_MEMORY; } + return 0; } int HOT JpegDecoder::decode(uint8_t *buffer, size_t size) { diff --git a/esphome/components/online_image/jpeg_image.h b/esphome/components/online_image/jpeg_image.h index f04a35655a..fd488d6138 100644 --- a/esphome/components/online_image/jpeg_image.h +++ b/esphome/components/online_image/jpeg_image.h @@ -21,7 +21,7 @@ class JpegDecoder : public ImageDecoder { JpegDecoder(OnlineImage *image) : ImageDecoder(image) {} ~JpegDecoder() override {} - void prepare(size_t download_size) override; + int prepare(size_t download_size) override; int HOT decode(uint8_t *buffer, size_t size) override; protected: diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index a1c530c2ab..3b3d00a044 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -178,7 +178,12 @@ void OnlineImage::update() { this->download_error_callback_.call(); return; } - this->decoder_->prepare(total_size); + auto prepare_result = this->decoder_->prepare(total_size); + if (prepare_result < 0) { + this->end_connection_(); + this->download_error_callback_.call(); + return; + } ESP_LOGI(TAG, "Downloading image (Size: %d)", total_size); this->start_time_ = ::time(nullptr); } diff --git a/esphome/components/online_image/png_image.cpp b/esphome/components/online_image/png_image.cpp index 6bc968c7ba..fc5fb554bf 100644 --- a/esphome/components/online_image/png_image.cpp +++ b/esphome/components/online_image/png_image.cpp @@ -40,11 +40,16 @@ static void draw_callback(pngle_t *pngle, uint32_t x, uint32_t y, uint32_t w, ui decoder->draw(x, y, w, h, color); } -void PngDecoder::prepare(size_t download_size) { +int PngDecoder::prepare(size_t download_size) { ImageDecoder::prepare(download_size); + if (!this->pngle_) { + ESP_LOGE(TAG, "PNG decoder engine not initialized!"); + return DECODE_ERROR_OUT_OF_MEMORY; + } pngle_set_user_data(this->pngle_, this); pngle_set_init_callback(this->pngle_, init_callback); pngle_set_draw_callback(this->pngle_, draw_callback); + return 0; } int HOT PngDecoder::decode(uint8_t *buffer, size_t size) { diff --git a/esphome/components/online_image/png_image.h b/esphome/components/online_image/png_image.h index c137227907..39f445c588 100644 --- a/esphome/components/online_image/png_image.h +++ b/esphome/components/online_image/png_image.h @@ -21,7 +21,7 @@ class PngDecoder : public ImageDecoder { PngDecoder(OnlineImage *image) : ImageDecoder(image), pngle_(pngle_new()) {} ~PngDecoder() override { pngle_destroy(this->pngle_); } - void prepare(size_t download_size) override; + int prepare(size_t download_size) override; int HOT decode(uint8_t *buffer, size_t size) override; protected: From 46d19d82c2df3885690ed3f67a78e95728bafb77 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Tue, 11 Feb 2025 12:14:59 -0600 Subject: [PATCH 185/194] [speaker] Bugfix: Ensure all audio is played after completely decoding a file (#8231) --- .../components/speaker/media_player/audio_pipeline.cpp | 10 +++++++++- .../components/speaker/media_player/audio_pipeline.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/esphome/components/speaker/media_player/audio_pipeline.cpp b/esphome/components/speaker/media_player/audio_pipeline.cpp index 73ec5a3334..b49cf3ddda 100644 --- a/esphome/components/speaker/media_player/audio_pipeline.cpp +++ b/esphome/components/speaker/media_player/audio_pipeline.cpp @@ -182,13 +182,21 @@ AudioPipelineState AudioPipeline::process_state() { if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) { // Stop command is fully processed, so clear the command bit xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP); + this->hard_stop_ = true; } if (!this->is_playing_) { // The tasks have been stopped for two ``process_state`` calls in a row, so delete the tasks if ((this->read_task_handle_ != nullptr) || (this->decode_task_handle_ != nullptr)) { this->delete_tasks_(); - this->speaker_->stop(); + if (this->hard_stop_) { + // Stop command was sent, so immediately end of the playback + this->speaker_->stop(); + this->hard_stop_ = false; + } else { + // Decoded all the audio, so let the speaker finish playing before stopping + this->speaker_->finish(); + } } } this->is_playing_ = false; diff --git a/esphome/components/speaker/media_player/audio_pipeline.h b/esphome/components/speaker/media_player/audio_pipeline.h index c382e1eebe..722d9cbb2a 100644 --- a/esphome/components/speaker/media_player/audio_pipeline.h +++ b/esphome/components/speaker/media_player/audio_pipeline.h @@ -112,6 +112,7 @@ class AudioPipeline { uint32_t playback_ms_{0}; + bool hard_stop_{false}; bool is_playing_{false}; bool pause_state_{false}; bool task_stack_in_psram_; From 33f9d66e8188ce68c7083aac909857cdd5281069 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Tue, 11 Feb 2025 12:20:39 -0600 Subject: [PATCH 186/194] [voice_assistant] Add announce support (#8232) --- .../voice_assistant/voice_assistant.cpp | 38 ++++++++++++------- .../voice_assistant/voice_assistant.h | 8 ++++ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/esphome/components/voice_assistant/voice_assistant.cpp b/esphome/components/voice_assistant/voice_assistant.cpp index 6f164f69d3..4b02867967 100644 --- a/esphome/components/voice_assistant/voice_assistant.cpp +++ b/esphome/components/voice_assistant/voice_assistant.cpp @@ -1,4 +1,5 @@ #include "voice_assistant.h" +#include "esphome/core/defines.h" #ifdef USE_VOICE_ASSISTANT @@ -127,7 +128,7 @@ void VoiceAssistant::clear_buffers_() { } #ifdef USE_SPEAKER - if (this->speaker_buffer_ != nullptr) { + if ((this->speaker_ != nullptr) && (this->speaker_buffer_ != nullptr)) { memset(this->speaker_buffer_, 0, SPEAKER_BUFFER_SIZE); this->speaker_buffer_size_ = 0; @@ -159,7 +160,7 @@ void VoiceAssistant::deallocate_buffers_() { this->input_buffer_ = nullptr; #ifdef USE_SPEAKER - if (this->speaker_buffer_ != nullptr) { + if ((this->speaker_ != nullptr) && (this->speaker_buffer_ != nullptr)) { ExternalRAMAllocator speaker_deallocator(ExternalRAMAllocator::ALLOW_FAILURE); speaker_deallocator.deallocate(this->speaker_buffer_, SPEAKER_BUFFER_SIZE); this->speaker_buffer_ = nullptr; @@ -389,14 +390,7 @@ void VoiceAssistant::loop() { } #endif if (playing) { - this->set_timeout("playing", 2000, [this]() { - this->cancel_timeout("speaker-timeout"); - this->set_state_(State::IDLE, State::IDLE); - - api::VoiceAssistantAnnounceFinished msg; - msg.success = true; - this->api_client_->send_voice_assistant_announce_finished(msg); - }); + this->start_playback_timeout_(); } break; } @@ -614,6 +608,8 @@ void VoiceAssistant::request_stop() { this->desired_state_ = State::IDLE; break; case State::AWAITING_RESPONSE: + this->signal_stop_(); + break; case State::STREAMING_RESPONSE: case State::RESPONSE_FINISHED: break; // Let the incoming audio stream finish then it will go to idle. @@ -631,6 +627,17 @@ void VoiceAssistant::signal_stop_() { this->api_client_->send_voice_assistant_request(msg); } +void VoiceAssistant::start_playback_timeout_() { + this->set_timeout("playing", 100, [this]() { + this->cancel_timeout("speaker-timeout"); + this->set_state_(State::IDLE, State::IDLE); + + api::VoiceAssistantAnnounceFinished msg; + msg.success = true; + this->api_client_->send_voice_assistant_announce_finished(msg); + }); +} + void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) { ESP_LOGD(TAG, "Event Type: %" PRId32, msg.event_type); switch (msg.event_type) { @@ -715,6 +722,8 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) { #ifdef USE_MEDIA_PLAYER if (this->media_player_ != nullptr) { this->media_player_->make_call().set_media_url(url).set_announcement(true).perform(); + // Start the playback timeout, as the media player state isn't immediately updated + this->start_playback_timeout_(); } #endif this->tts_end_trigger_->trigger(url); @@ -725,7 +734,11 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) { } case api::enums::VOICE_ASSISTANT_RUN_END: { ESP_LOGD(TAG, "Assist Pipeline ended"); - if (this->state_ == State::STREAMING_MICROPHONE) { + if ((this->state_ == State::STARTING_PIPELINE) || (this->state_ == State::AWAITING_RESPONSE)) { + // Pipeline ended before starting microphone + // Or there wasn't a TTS start event ("nevermind") + this->set_state_(State::IDLE, State::IDLE); + } else if (this->state_ == State::STREAMING_MICROPHONE) { this->ring_buffer_->reset(); #ifdef USE_ESP_ADF if (this->use_wake_word_) { @@ -736,9 +749,6 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) { { this->set_state_(State::IDLE, State::IDLE); } - } else if (this->state_ == State::AWAITING_RESPONSE) { - // No TTS start event ("nevermind") - this->set_state_(State::IDLE, State::IDLE); } this->defer([this]() { this->end_trigger_->trigger(); }); break; diff --git a/esphome/components/voice_assistant/voice_assistant.h b/esphome/components/voice_assistant/voice_assistant.h index 0016d3157c..12124c1486 100644 --- a/esphome/components/voice_assistant/voice_assistant.h +++ b/esphome/components/voice_assistant/voice_assistant.h @@ -40,6 +40,7 @@ enum VoiceAssistantFeature : uint32_t { FEATURE_SPEAKER = 1 << 1, FEATURE_API_AUDIO = 1 << 2, FEATURE_TIMERS = 1 << 3, + FEATURE_ANNOUNCE = 1 << 4, }; enum class State { @@ -136,6 +137,12 @@ class VoiceAssistant : public Component { flags |= VoiceAssistantFeature::FEATURE_TIMERS; } +#ifdef USE_MEDIA_PLAYER + if (this->media_player_ != nullptr) { + flags |= VoiceAssistantFeature::FEATURE_ANNOUNCE; + } +#endif + return flags; } @@ -209,6 +216,7 @@ class VoiceAssistant : public Component { void set_state_(State state); void set_state_(State state, State desired_state); void signal_stop_(); + void start_playback_timeout_(); std::unique_ptr socket_ = nullptr; struct sockaddr_storage dest_addr_; From 6b3f3e1da6ed7725eaa5bacc65b069190f2787e3 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Tue, 11 Feb 2025 11:51:55 -0800 Subject: [PATCH 187/194] [prometheus] Adding valve entity metrics (#8223) --- .../prometheus/prometheus_handler.cpp | 54 +++++++++++++++++++ .../prometheus/prometheus_handler.h | 8 +++ tests/components/prometheus/common.yaml | 8 +++ 3 files changed, 70 insertions(+) diff --git a/esphome/components/prometheus/prometheus_handler.cpp b/esphome/components/prometheus/prometheus_handler.cpp index c31d34f000..794df299a1 100644 --- a/esphome/components/prometheus/prometheus_handler.cpp +++ b/esphome/components/prometheus/prometheus_handler.cpp @@ -83,6 +83,12 @@ void PrometheusHandler::handleRequest(AsyncWebServerRequest *req) { this->update_entity_row_(stream, obj, area, node, friendly_name); #endif +#ifdef USE_VALVE + this->valve_type_(stream); + for (auto *obj : App.get_valves()) + this->valve_row_(stream, obj, area, node, friendly_name); +#endif + req->send(stream); } @@ -770,6 +776,54 @@ void PrometheusHandler::update_entity_row_(AsyncResponseStream *stream, update:: } #endif +#ifdef USE_VALVE +void PrometheusHandler::valve_type_(AsyncResponseStream *stream) { + stream->print(F("#TYPE esphome_valve_operation gauge\n")); + stream->print(F("#TYPE esphome_valve_failed gauge\n")); + stream->print(F("#TYPE esphome_valve_position gauge\n")); +} + +void PrometheusHandler::valve_row_(AsyncResponseStream *stream, valve::Valve *obj, std::string &area, std::string &node, + std::string &friendly_name) { + if (obj->is_internal() && !this->include_internal_) + return; + stream->print(F("esphome_valve_failed{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} 0\n")); + // Data itself + stream->print(F("esphome_valve_operation{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\",operation=\"")); + stream->print(valve::valve_operation_to_str(obj->current_operation)); + stream->print(F("\"} ")); + stream->print(F("1.0")); + stream->print(F("\n")); + // Now see if position is supported + if (obj->get_traits().get_supports_position()) { + stream->print(F("esphome_valve_position{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} ")); + stream->print(obj->position); + stream->print(F("\n")); + } +} +#endif + } // namespace prometheus } // namespace esphome #endif diff --git a/esphome/components/prometheus/prometheus_handler.h b/esphome/components/prometheus/prometheus_handler.h index 08a6e8dc8a..b77dbc462b 100644 --- a/esphome/components/prometheus/prometheus_handler.h +++ b/esphome/components/prometheus/prometheus_handler.h @@ -161,6 +161,14 @@ class PrometheusHandler : public AsyncWebHandler, public Component { void handle_update_state_(AsyncResponseStream *stream, update::UpdateState state); #endif +#ifdef USE_VALVE + /// Return the type for prometheus + void valve_type_(AsyncResponseStream *stream); + /// Return the valve state as prometheus data point + void valve_row_(AsyncResponseStream *stream, valve::Valve *obj, std::string &area, std::string &node, + std::string &friendly_name); +#endif + web_server_base::WebServerBase *base_; bool include_internal_{false}; std::map relabel_map_id_; diff --git a/tests/components/prometheus/common.yaml b/tests/components/prometheus/common.yaml index 9205c27f2a..7c226b6782 100644 --- a/tests/components/prometheus/common.yaml +++ b/tests/components/prometheus/common.yaml @@ -121,6 +121,14 @@ number: max_value: 100 step: 1 +valve: + - platform: template + name: "Template Valve" + lambda: |- + return VALVE_OPEN; + optimistic: true + has_position: true + prometheus: include_internal: true relabel: From 14d7931bd6b12d4b91846af1a83196a9b06651e2 Mon Sep 17 00:00:00 2001 From: tmpeh <41875356+tmpeh@users.noreply.github.com> Date: Tue, 11 Feb 2025 21:41:52 +0100 Subject: [PATCH 188/194] Added Waveshare e-paper display model "7.50inv2p" to the waveshare_epaper component. (#7751) Co-authored-by: Tim Pehla Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 4 + .../waveshare_epaper/waveshare_epaper.cpp | 203 ++++++++++++++++++ .../waveshare_epaper/waveshare_epaper.h | 37 ++++ tests/components/waveshare_epaper/common.yaml | 20 ++ 4 files changed, 264 insertions(+) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index f0064c6a4d..2d8619bc5c 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -91,6 +91,9 @@ WaveshareEPaper7P5InV2 = waveshare_epaper_ns.class_( WaveshareEPaper7P5InV2alt = waveshare_epaper_ns.class_( "WaveshareEPaper7P5InV2alt", WaveshareEPaper ) +WaveshareEPaper7P5InV2P = waveshare_epaper_ns.class_( + "WaveshareEPaper7P5InV2P", WaveshareEPaper +) WaveshareEPaper7P5InHDB = waveshare_epaper_ns.class_( "WaveshareEPaper7P5InHDB", WaveshareEPaper ) @@ -144,6 +147,7 @@ MODELS = { "7.50in-bc": ("b", WaveshareEPaper7P5InBC), "7.50inv2": ("b", WaveshareEPaper7P5InV2), "7.50inv2alt": ("b", WaveshareEPaper7P5InV2alt), + "7.50inv2p": ("c", WaveshareEPaper7P5InV2P), "7.50in-hd-b": ("b", WaveshareEPaper7P5InHDB), "2.13in-ttgo-dke": ("c", WaveshareEPaper2P13InDKE), "2.13inv3": ("c", WaveshareEPaper2P13InV3), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index f240c98096..9f8c32721d 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -3100,6 +3100,209 @@ void WaveshareEPaper7P5InV2alt::dump_config() { LOG_UPDATE_INTERVAL(this); } +/* 7.50inV2 with partial and fast refresh */ +bool WaveshareEPaper7P5InV2P::wait_until_idle_() { + if (this->busy_pin_ == nullptr) { + return true; + } + + const uint32_t start = millis(); + while (this->busy_pin_->digital_read()) { + this->command(0x71); + if (millis() - start > this->idle_timeout_()) { + ESP_LOGE(TAG, "Timeout while displaying image!"); + return false; + } + App.feed_wdt(); + delay(10); + } + return true; +} + +void WaveshareEPaper7P5InV2P::reset_() { + if (this->reset_pin_ != nullptr) { + this->reset_pin_->digital_write(true); + delay(20); + this->reset_pin_->digital_write(false); + delay(2); + this->reset_pin_->digital_write(true); + delay(20); + } +} + +void WaveshareEPaper7P5InV2P::turn_on_display_() { + this->command(0x12); + delay(100); // NOLINT + this->wait_until_idle_(); +} + +void WaveshareEPaper7P5InV2P::initialize() { + this->reset_(); + + // COMMAND POWER SETTING + this->command(0x01); + this->data(0x07); + this->data(0x07); + this->data(0x3f); + this->data(0x3f); + + // COMMAND BOOSTER SOFT START + this->command(0x06); + this->data(0x17); + this->data(0x17); + this->data(0x28); + this->data(0x17); + + // COMMAND POWER DRIVER HAT UP + this->command(0x04); + delay(100); // NOLINT + this->wait_until_idle_(); + + // COMMAND PANEL SETTING + this->command(0x00); + this->data(0x1F); + + // COMMAND RESOLUTION SETTING + this->command(0x61); + this->data(0x03); + this->data(0x20); + this->data(0x01); + this->data(0xE0); + + // COMMAND DUAL SPI MM_EN, DUSPI_EN + this->command(0x15); + this->data(0x00); + + // COMMAND VCOM AND DATA INTERVAL SETTING + this->command(0x50); + this->data(0x10); + this->data(0x07); + + // COMMAND TCON SETTING + this->command(0x60); + this->data(0x22); + + // COMMAND ENABLE FAST UPDATE + this->command(0xE0); + this->data(0x02); + this->command(0xE5); + this->data(0x5A); + + // COMMAND POWER DRIVER HAT DOWN + this->command(0x02); +} + +void HOT WaveshareEPaper7P5InV2P::display() { + uint32_t buf_len = this->get_buffer_length_(); + + // COMMAND POWER ON + ESP_LOGI(TAG, "Power on the display and hat"); + + this->command(0x04); + delay(200); // NOLINT + this->wait_until_idle_(); + + if (this->full_update_every_ == 1) { + this->command(0x13); + for (uint32_t i = 0; i < buf_len; i++) { + this->data(~(this->buffer_[i])); + } + + this->turn_on_display_(); + + this->command(0x02); + this->wait_until_idle_(); + return; + } + + this->command(0x50); + this->data(0xA9); + this->data(0x07); + + if (this->at_update_ == 0) { + // Enable fast refresh + this->command(0xE5); + this->data(0x5A); + + this->command(0x92); + + this->command(0x10); + delay(2); + for (uint32_t i = 0; i < buf_len; i++) { + this->data(~(this->buffer_[i])); + } + + delay(100); // NOLINT + this->wait_until_idle_(); + + this->command(0x13); + delay(2); + for (uint32_t i = 0; i < buf_len; i++) { + this->data(this->buffer_[i]); + } + + delay(100); // NOLINT + this->wait_until_idle_(); + + this->turn_on_display_(); + + } else { + // Enable partial refresh + this->command(0xE5); + this->data(0x6E); + + // Activate partial refresh and set window bounds + this->command(0x91); + this->command(0x90); + + this->data(0x00); + this->data(0x00); + this->data((get_width_internal() - 1) >> 8 & 0xFF); + this->data((get_width_internal() - 1) & 0xFF); + + this->data(0x00); + this->data(0x00); + this->data((get_height_internal() - 1) >> 8 & 0xFF); + this->data((get_height_internal() - 1) & 0xFF); + + this->data(0x01); + + this->command(0x13); + delay(2); + for (uint32_t i = 0; i < buf_len; i++) { + this->data(this->buffer_[i]); + } + + delay(100); // NOLINT + this->wait_until_idle_(); + + this->turn_on_display_(); + } + + ESP_LOGV(TAG, "Before command(0x02) (>> power off)"); + this->command(0x02); + this->wait_until_idle_(); + ESP_LOGV(TAG, "After command(0x02) (>> power off)"); + + this->at_update_ = (this->at_update_ + 1) % this->full_update_every_; +} + +int WaveshareEPaper7P5InV2P::get_width_internal() { return 800; } +int WaveshareEPaper7P5InV2P::get_height_internal() { return 480; } +uint32_t WaveshareEPaper7P5InV2P::idle_timeout_() { return 10000; } +void WaveshareEPaper7P5InV2P::dump_config() { + LOG_DISPLAY("", "Waveshare E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 7.50inv2p"); + ESP_LOGCONFIG(TAG, " Full Update Every: %" PRIu32, this->full_update_every_); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} +void WaveshareEPaper7P5InV2P::set_full_update_every(uint32_t full_update_every) { + this->full_update_every_ = full_update_every; +} + /* 7.50in-bc */ void WaveshareEPaper7P5InBC::initialize() { /* The command sequence is similar to the 7P5In display but differs in subtle ways diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index c2277f2962..73090fa009 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -775,6 +775,43 @@ class WaveshareEPaper7P5InV2alt : public WaveshareEPaper7P5InV2 { }; }; +class WaveshareEPaper7P5InV2P : public WaveshareEPaper { + public: + bool wait_until_idle_(); + + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + // COMMAND POWER OFF + this->command(0x02); + this->wait_until_idle_(); + // COMMAND DEEP SLEEP + this->command(0x07); + this->data(0xA5); // check byte + } + + void set_full_update_every(uint32_t full_update_every); + + protected: + int get_width_internal() override; + + int get_height_internal() override; + + uint32_t idle_timeout_() override; + + uint32_t full_update_every_{30}; + uint32_t at_update_{0}; + + private: + void reset_(); + + void turn_on_display_(); +}; + class WaveshareEPaper7P5InHDB : public WaveshareEPaper { public: void initialize() override; diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index 4a67ccd67d..667bbb1bb0 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -675,6 +675,26 @@ display: lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + id: epd_7_50inv2p + model: 7.50inv2p + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper id: epd_7_50hdb model: 7.50in-hd-b From 0401ee94282c3b8e436c3983e23233171fad0c77 Mon Sep 17 00:00:00 2001 From: Rachasak Ragkamnerd Date: Wed, 12 Feb 2025 04:35:07 +0700 Subject: [PATCH 189/194] added Waveshare BWR Mode for the 4.2in Display (#7995) Co-authored-by: rrachasak Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 4 ++ .../waveshare_epaper/waveshare_epaper.cpp | 58 +++++++++++++++++++ .../waveshare_epaper/waveshare_epaper.h | 28 +++++++++ tests/components/waveshare_epaper/common.yaml | 19 ++++++ 4 files changed, 109 insertions(+) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 2d8619bc5c..f6e56c543d 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -64,6 +64,9 @@ WaveshareEPaper4P2In = waveshare_epaper_ns.class_( WaveshareEPaper4P2InBV2 = waveshare_epaper_ns.class_( "WaveshareEPaper4P2InBV2", WaveshareEPaper ) +WaveshareEPaper4P2InBV2BWR = waveshare_epaper_ns.class_( + "WaveshareEPaper4P2InBV2BWR", WaveshareEPaperBWR +) WaveshareEPaper5P8In = waveshare_epaper_ns.class_( "WaveshareEPaper5P8In", WaveshareEPaper ) @@ -138,6 +141,7 @@ MODELS = { "2.90in-dke": ("c", WaveshareEPaper2P9InDKE), "4.20in": ("b", WaveshareEPaper4P2In), "4.20in-bv2": ("b", WaveshareEPaper4P2InBV2), + "4.20in-bv2-bwr": ("b", WaveshareEPaper4P2InBV2BWR), "5.83in": ("b", WaveshareEPaper5P8In), "5.83inv2": ("b", WaveshareEPaper5P8InV2), "7.50in": ("b", WaveshareEPaper7P5In), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 9f8c32721d..a4439e2d7d 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -2274,6 +2274,64 @@ void WaveshareEPaper4P2InBV2::dump_config() { LOG_UPDATE_INTERVAL(this); } +// ======================================================== +// 4.20in Type B With Red colour support (LUT from OTP) +// Datasheet: +// - https://www.waveshare.com/w/upload/2/20/4.2inch-e-paper-module-user-manual-en.pdf +// - https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/c/lib/e-Paper/EPD_4in2b_V2.c +// The implementation is an adaptation of WaveshareEPaper4P2InBV2 class +// ======================================================== +void WaveshareEPaper4P2InBV2BWR::initialize() { + // these exact timings are required for a proper reset/init + this->reset_pin_->digital_write(false); + delay(2); + this->reset_pin_->digital_write(true); + delay(200); // NOLINT + + // COMMAND POWER ON + this->command(0x04); + this->wait_until_idle_(); + + // COMMAND PANEL SETTING + this->command(0x00); + this->data(0x0f); // LUT from OTP +} + +void HOT WaveshareEPaper4P2InBV2BWR::display() { + const uint32_t buf_len = this->get_buffer_length_() / 2u; + + this->command(0x10); // Send BW data Transmission + delay(2); // Delay to prevent Watchdog error + for (uint32_t i = 0; i < buf_len; ++i) { + this->data(this->buffer_[i]); + } + + this->command(0x13); // Send red data Transmission + delay(2); // Delay to prevent Watchdog error + for (uint32_t i = 0; i < buf_len; ++i) { + // Red color need to flip bit from the buffer. Otherwise, red will conqure the screen! + this->data(~this->buffer_[buf_len + i]); + } + + // COMMAND DISPLAY REFRESH + this->command(0x12); + this->wait_until_idle_(); + + // COMMAND POWER OFF + // NOTE: power off < deep sleep + this->command(0x02); +} +int WaveshareEPaper4P2InBV2BWR::get_width_internal() { return 400; } +int WaveshareEPaper4P2InBV2BWR::get_height_internal() { return 300; } +void WaveshareEPaper4P2InBV2BWR::dump_config() { + LOG_DISPLAY("", "Waveshare E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 4.2in (B V2) BWR-Mode"); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} + void WaveshareEPaper5P8In::initialize() { // COMMAND POWER SETTING this->command(0x01); diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 73090fa009..4d811228f1 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -518,6 +518,34 @@ class WaveshareEPaper4P2InBV2 : public WaveshareEPaper { int get_height_internal() override; }; +class WaveshareEPaper4P2InBV2BWR : public WaveshareEPaperBWR { + public: + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + // COMMAND VCOM AND DATA INTERVAL SETTING + this->command(0x50); + this->data(0xF7); // border floating + + // COMMAND POWER OFF + this->command(0x02); + this->wait_until_idle_(); + + // COMMAND DEEP SLEEP + this->command(0x07); + this->data(0xA5); // check code + } + + protected: + int get_width_internal() override; + + int get_height_internal() override; +}; + class WaveshareEPaper5P8In : public WaveshareEPaper { public: void initialize() override; diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index 667bbb1bb0..5889b4659e 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -502,6 +502,25 @@ display: lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + id: epd_4_20in_bv2_bwr + model: 4.20in-bv2-bwr + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + # 5.83 inch displays - platform: waveshare_epaper id: epd_5_83 From a2f1b902388f6d8c89b2f332199273e479beed65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Koek?= Date: Tue, 11 Feb 2025 23:16:33 +0000 Subject: [PATCH 190/194] Add GDEY029T94 support (#7931) Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 2 + .../waveshare_epaper/waveshare_epaper.cpp | 75 ++++++++++++++++++- .../waveshare_epaper/waveshare_epaper.h | 19 +++++ 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index f6e56c543d..7b51eb338c 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -52,6 +52,7 @@ WaveshareEPaper2P9InV2R2 = waveshare_epaper_ns.class_( "WaveshareEPaper2P9InV2R2", WaveshareEPaper ) GDEW029T5 = waveshare_epaper_ns.class_("GDEW029T5", WaveshareEPaper) +GDEY029T94 = waveshare_epaper_ns.class_("GDEY029T94", WaveshareEPaper) WaveshareEPaper2P9InDKE = waveshare_epaper_ns.class_( "WaveshareEPaper2P9InDKE", WaveshareEPaper ) @@ -136,6 +137,7 @@ MODELS = { "2.70inv2": ("b", WaveshareEPaper2P7InV2), "2.90in-b": ("b", WaveshareEPaper2P9InB), "2.90in-bv3": ("b", WaveshareEPaper2P9InBV3), + "gdey029t94": ("c", GDEY029T94), "2.90inv2-r2": ("c", WaveshareEPaper2P9InV2R2), "2.90in-d": ("b", WaveshareEPaper2P9InD), "2.90in-dke": ("c", WaveshareEPaper2P9InDKE), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index a4439e2d7d..1e8671bfa6 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -1677,9 +1677,82 @@ int WaveshareEPaper2P9InV2R2::get_width_controller() { return this->get_width_in void WaveshareEPaper2P9InV2R2::set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; } +// ======================================================== +// Good Display 2.9in black/white +// Datasheet: +// - https://files.seeedstudio.com/wiki/Other_Display/29-epaper/GDEY029T94.pdf +// - +// https://github.com/Allen-Kuang/e-ink_Demo/blob/main/2.9%20inch%20E-paper%20-%20monocolor%20128x296/example/Display_EPD_W21.cpp +// ======================================================== + +void GDEY029T94::initialize() { + // EPD hardware init start + this->reset_(); + + this->wait_until_idle_(); + this->command(0x12); // SWRESET + this->wait_until_idle_(); + + this->command(0x01); // Driver output control + this->data((this->get_height_internal() - 1) % 256); + this->data((this->get_height_internal() - 1) / 256); + this->data(0x00); + + this->command(0x11); // data entry mode + this->data(0x03); + + this->command(0x44); // set Ram-X address start/end position + this->data(0x00); + this->data(this->get_width_internal() / 8 - 1); + + this->command(0x45); // set Ram-Y address start/end position + this->data(0x00); + this->data(0x00); + this->data((this->get_height_internal() - 1) % 256); + this->data((this->get_height_internal() - 1) / 256); + + this->command(0x3C); // BorderWavefrom + this->data(0x05); + + this->command(0x21); // Display update control + this->data(0x00); + this->data(0x80); + + this->command(0x18); // Read built-in temperature sensor + this->data(0x80); + + this->command(0x4E); // set RAM x address count to 0; + this->data(0x00); + this->command(0x4F); // set RAM y address count to 0X199; + this->command(0x00); + this->command(0x00); + this->wait_until_idle_(); +} +void HOT GDEY029T94::display() { + this->command(0x24); // write RAM for black(0)/white (1) + this->start_data_(); + for (uint32_t i = 0; i < this->get_buffer_length_(); i++) { + this->write_byte(this->buffer_[i]); + } + this->end_data_(); + this->command(0x22); // Display Update Control + this->data(0xF7); + this->command(0x20); // Activate Display Update Sequence + this->wait_until_idle_(); +} +int GDEY029T94::get_width_internal() { return 128; } +int GDEY029T94::get_height_internal() { return 296; } +void GDEY029T94::dump_config() { + LOG_DISPLAY("", "E-Paper (Good Display)", this); + ESP_LOGCONFIG(TAG, " Model: 2.9in GDEY029T94"); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} // ======================================================== -// Good Display 2.9in black/white/grey +// Good Display 2.9in black/white // Datasheet: // - https://v4.cecdn.yun300.cn/100001_1909185148/SSD1680.pdf // - https://github.com/adafruit/Adafruit_EPD/blob/master/src/panels/ThinkInk_290_Grayscale4_T5.h diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 4d811228f1..54e7619ebc 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -277,6 +277,25 @@ class GDEW029T5 : public WaveshareEPaper { uint8_t *old_buffer_{nullptr}; }; +class GDEY029T94 : public WaveshareEPaper { + public: + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + this->command(0x10); // Enter deep sleep + this->data(0x01); + } + + protected: + int get_width_internal() override; + + int get_height_internal() override; +}; + class WaveshareEPaper2P7InV2 : public WaveshareEPaper { public: void initialize() override; From 88cfdc33d458475c4dc3fa67653f7abf355dd7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gr=C3=BCner?= Date: Wed, 12 Feb 2025 00:17:34 +0100 Subject: [PATCH 191/194] GDEY042T81 e-paper displays support (#8061) Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 2 + .../waveshare_epaper/waveshare_epaper.cpp | 200 ++++++++++++++++++ .../waveshare_epaper/waveshare_epaper.h | 37 ++++ tests/components/waveshare_epaper/common.yaml | 20 ++ 4 files changed, 259 insertions(+) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 7b51eb338c..72823e4e36 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -56,6 +56,7 @@ GDEY029T94 = waveshare_epaper_ns.class_("GDEY029T94", WaveshareEPaper) WaveshareEPaper2P9InDKE = waveshare_epaper_ns.class_( "WaveshareEPaper2P9InDKE", WaveshareEPaper ) +GDEY042T81 = waveshare_epaper_ns.class_("GDEY042T81", WaveshareEPaper) WaveshareEPaper2P9InD = waveshare_epaper_ns.class_( "WaveshareEPaper2P9InD", WaveshareEPaper ) @@ -141,6 +142,7 @@ MODELS = { "2.90inv2-r2": ("c", WaveshareEPaper2P9InV2R2), "2.90in-d": ("b", WaveshareEPaper2P9InD), "2.90in-dke": ("c", WaveshareEPaper2P9InDKE), + "gdey042t81": ("c", GDEY042T81), "4.20in": ("b", WaveshareEPaper4P2In), "4.20in-bv2": ("b", WaveshareEPaper4P2InBV2), "4.20in-bv2-bwr": ("b", WaveshareEPaper4P2InBV2BWR), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 1e8671bfa6..2a540a1b75 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -2169,6 +2169,206 @@ void GDEW0154M09::dump_config() { LOG_UPDATE_INTERVAL(this); } +// ======================================================== +// Good Display 4.2in black/white GDEY042T81 (SSD1683) +// Product page: +// - https://www.good-display.com/product/386.html +// Datasheet: +// - https://v4.cecdn.yun300.cn/100001_1909185148/GDEY042T81.pdf +// - https://v4.cecdn.yun300.cn/100001_1909185148/SSD1683.PDF +// Reference code from GoodDisplay: +// - https://www.good-display.com/companyfile/1572.html (2024-08-01 15:40:41) +// Other reference code: +// - https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp +// ======================================================== + +void GDEY042T81::initialize() { + this->init_display_(); + ESP_LOGD(TAG, "Initialization complete, set the display to deep sleep"); + this->deep_sleep(); +} + +// conflicting documentation / examples regarding reset timings +// https://v4.cecdn.yun300.cn/100001_1909185148/SSD1683.PDF -> 10ms +// GD sample code (Display_EPD_W21.cpp, see above) -> 10 ms +// https://v4.cecdn.yun300.cn/100001_1909185148/GDEY042T81.pdf (section 14.2) -> 0.2ms (200us) +// https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L351 +// -> 10ms +// 10 ms seems to work, so we use this +GDEY042T81::GDEY042T81() { this->reset_duration_ = 10; } + +void GDEY042T81::reset_() { + if (this->reset_pin_ != nullptr) { + this->reset_pin_->digital_write(false); + delay(reset_duration_); // NOLINT + this->reset_pin_->digital_write(true); + delay(reset_duration_); // NOLINT + } +} + +void GDEY042T81::init_display_() { + this->reset_(); + + this->wait_until_idle_(); + this->command(0x12); // SWRESET + this->wait_until_idle_(); + + // Specify number of lines for the driver: 300 (MUX 300) + // https://v4.cecdn.yun300.cn/100001_1909185148/SSD1683.PDF (section 8.1) + // https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L354 + this->command(0x01); // driver output control + this->data(0x2B); // (height - 1) % 256 + this->data(0x01); // (height - 1) / 256 + this->data(0x00); + + // https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L360 + this->command(0x3C); // BorderWaveform + this->data(0x01); + this->command(0x18); // Read built-in temperature sensor + this->data(0x80); + + // GD sample code (Display_EPD_W21.cpp@90ff) + this->command(0x11); // data entry mode + this->data(0x03); + // set windows (0,0,400,300) + this->command(0x44); // set Ram-X address start/end position + this->data(0); + this->data(0x31); // (width / 8 -1) + + this->command(0x45); // set Ram-y address start/end position + this->data(0); + this->data(0); + this->data(0x2B); // (height - 1) % 256 + this->data(0x01); // (height - 1) / 256 + + // set cursor (0,0) + this->command(0x4E); // set RAM x address count to 0; + this->data(0); + this->command(0x4F); // set RAM y address count to 0; + this->data(0); + this->data(0); + + this->wait_until_idle_(); +} + +// https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L366 +void GDEY042T81::update_full_() { + this->command(0x21); // display update control + this->data(0x40); // bypass RED as 0 + this->data(0x00); // single chip application + + // only ever do a fast update because slow updates are only relevant + // for lower operating temperatures + // see + // https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_290_GDEY029T94.h#L30 + // + // Should slow/fast updates be made configurable similar to how GxEPD2 does it? No idea if anyone would need it... + this->command(0x1A); // Write to temperature register + this->data(0x6E); + this->command(0x22); + this->data(0xd7); + + this->command(0x20); + this->wait_until_idle_(); +} + +// https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L389 +void GDEY042T81::update_part_() { + this->command(0x21); // display update control + this->data(0x00); // RED normal + this->data(0x00); // single chip application + + this->command(0x22); + this->data(0xfc); + + this->command(0x20); + this->wait_until_idle_(); +} + +void HOT GDEY042T81::display() { + ESP_LOGD(TAG, "Wake up the display"); + this->init_display_(); + + if (!this->wait_until_idle_()) { + this->status_set_warning(); + ESP_LOGE(TAG, "Failed to perform update, display is busy"); + return; + } + + // basic code structure copied from WaveshareEPaper2P9InV2R2 + if (this->full_update_every_ == 1) { + ESP_LOGD(TAG, "Full update"); + // do single full update + this->command(0x24); + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + // TurnOnDisplay + this->update_full_(); + return; + } + + // if (this->full_update_every_ == 1 || + if (this->at_update_ == 0) { + ESP_LOGD(TAG, "Update"); + // do base update + this->command(0x24); + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + this->command(0x26); + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + // TurnOnDisplay; + this->update_full_(); + } else { + // do partial update (full screen) + // no need to load a LUT for GoodDisplays as they seem to have the LUT onboard + // GD example code (Display_EPD_W21.cpp@283ff) + // + // not setting the BorderWaveform here again (contrary to the GD example) because according to + // https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L358 + // it seems to be enough to set it during display initialization + ESP_LOGD(TAG, "Partial update"); + this->reset_(); + if (!this->wait_until_idle_()) { + this->status_set_warning(); + ESP_LOGE(TAG, "Failed to perform partial update, display is busy"); + return; + } + + this->command(0x24); + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + // TurnOnDisplay + this->update_part_(); + } + + this->at_update_ = (this->at_update_ + 1) % this->full_update_every_; + this->wait_until_idle_(); + ESP_LOGD(TAG, "Set the display back to deep sleep"); + this->deep_sleep(); +} +void GDEY042T81::set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; } +int GDEY042T81::get_width_internal() { return 400; } +int GDEY042T81::get_height_internal() { return 300; } +uint32_t GDEY042T81::idle_timeout_() { return 5000; } +void GDEY042T81::dump_config() { + LOG_DISPLAY("", "GoodDisplay E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 4.2in B/W GDEY042T81"); + ESP_LOGCONFIG(TAG, " Full Update Every: %" PRIu32, this->full_update_every_); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} + static const uint8_t LUT_VCOM_DC_4_2[] = { 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00, 0x02, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 54e7619ebc..1e7cb6c6c7 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -466,6 +466,43 @@ class WaveshareEPaper2P9InD : public WaveshareEPaper { int get_height_internal() override; }; +class GDEY042T81 : public WaveshareEPaper { + public: + GDEY042T81(); + + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + // COMMAND POWER OFF + this->command(0x22); + this->data(0x83); + this->command(0x20); + // COMMAND DEEP SLEEP + this->command(0x10); + this->data(0x01); + } + + void set_full_update_every(uint32_t full_update_every); + + protected: + uint32_t full_update_every_{30}; + uint32_t at_update_{0}; + + int get_width_internal() override; + int get_height_internal() override; + uint32_t idle_timeout_() override; + + private: + void reset_(); + void update_full_(); + void update_part_(); + void init_display_(); +}; + class WaveshareEPaper4P2In : public WaveshareEPaper { public: void initialize() override; diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index 5889b4659e..09ba1af778 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -463,6 +463,26 @@ display: lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + id: epd_gdew042t81 + model: gdey042t81 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + # 4.2 inch displays - platform: waveshare_epaper id: epd_4_20 From 7bb2c3c4968185d6cc4848986b0f3cdc71e7da5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Neil=20S=C3=A9gard?= <55683504+NeilSCGH@users.noreply.github.com> Date: Wed, 12 Feb 2025 00:31:56 +0100 Subject: [PATCH 192/194] Add support for Waveshare 7.3" ACeP 7-Color display (#6380) --- .../components/waveshare_epaper/display.py | 5 + .../waveshare_epaper/waveshare_213v3.cpp | 6 +- .../waveshare_epaper/waveshare_epaper.cpp | 311 +++++++++++++++++- .../waveshare_epaper/waveshare_epaper.h | 56 +++- 4 files changed, 369 insertions(+), 9 deletions(-) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 72823e4e36..8acb6ac68f 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -24,6 +24,7 @@ WaveshareEPaper = waveshare_epaper_ns.class_("WaveshareEPaper", WaveshareEPaperB WaveshareEPaperBWR = waveshare_epaper_ns.class_( "WaveshareEPaperBWR", WaveshareEPaperBase ) +WaveshareEPaper7C = waveshare_epaper_ns.class_("WaveshareEPaper7C", WaveshareEPaperBase) WaveshareEPaperTypeA = waveshare_epaper_ns.class_( "WaveshareEPaperTypeA", WaveshareEPaper ) @@ -75,6 +76,9 @@ WaveshareEPaper5P8In = waveshare_epaper_ns.class_( WaveshareEPaper5P8InV2 = waveshare_epaper_ns.class_( "WaveshareEPaper5P8InV2", WaveshareEPaper ) +WaveshareEPaper7P3InF = waveshare_epaper_ns.class_( + "WaveshareEPaper7P3InF", WaveshareEPaper7C +) WaveshareEPaper7P5In = waveshare_epaper_ns.class_( "WaveshareEPaper7P5In", WaveshareEPaper ) @@ -148,6 +152,7 @@ MODELS = { "4.20in-bv2-bwr": ("b", WaveshareEPaper4P2InBV2BWR), "5.83in": ("b", WaveshareEPaper5P8In), "5.83inv2": ("b", WaveshareEPaper5P8InV2), + "7.30in-f": ("b", WaveshareEPaper7P3InF), "7.50in": ("b", WaveshareEPaper7P5In), "7.50in-bv2": ("b", WaveshareEPaper7P5InBV2), "7.50in-bv3": ("b", WaveshareEPaper7P5InBV3), diff --git a/esphome/components/waveshare_epaper/waveshare_213v3.cpp b/esphome/components/waveshare_epaper/waveshare_213v3.cpp index 85d7033d4b..316cd80ccd 100644 --- a/esphome/components/waveshare_epaper/waveshare_213v3.cpp +++ b/esphome/components/waveshare_epaper/waveshare_213v3.cpp @@ -87,7 +87,11 @@ void WaveshareEPaper2P13InV3::send_reset_() { } void WaveshareEPaper2P13InV3::setup() { - setup_pins_(); + this->init_internal_(this->get_buffer_length_()); + this->setup_pins_(); + this->spi_setup(); + this->reset_(); + delay(20); this->send_reset_(); // as a one-off delay this is not worth working around. diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 2a540a1b75..96fc82fcdd 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -3,6 +3,7 @@ #include "esphome/core/application.h" #include "esphome/core/helpers.h" #include +#include namespace esphome { namespace waveshare_epaper { @@ -110,8 +111,14 @@ static const uint8_t PARTIAL_UPD_2IN9_LUT[PARTIAL_UPD_2IN9_LUT_SIZE] = }; // clang-format on -void WaveshareEPaperBase::setup_pins_() { +void WaveshareEPaperBase::setup() { this->init_internal_(this->get_buffer_length_()); + this->setup_pins_(); + this->spi_setup(); + this->reset_(); + this->initialize(); +} +void WaveshareEPaperBase::setup_pins_() { this->dc_pin_->setup(); // OUTPUT this->dc_pin_->digital_write(false); if (this->reset_pin_ != nullptr) { @@ -121,9 +128,6 @@ void WaveshareEPaperBase::setup_pins_() { if (this->busy_pin_ != nullptr) { this->busy_pin_->setup(); // INPUT } - this->spi_setup(); - - this->reset_(); } float WaveshareEPaperBase::get_setup_priority() const { return setup_priority::PROCESSOR; } void WaveshareEPaperBase::command(uint8_t value) { @@ -173,6 +177,87 @@ void WaveshareEPaper::fill(Color color) { for (uint32_t i = 0; i < this->get_buffer_length_(); i++) this->buffer_[i] = fill; } +void WaveshareEPaper7C::setup() { + this->init_internal_7c_(this->get_buffer_length_()); + this->setup_pins_(); + this->spi_setup(); + this->reset_(); + this->initialize(); +} +void WaveshareEPaper7C::init_internal_7c_(uint32_t buffer_length) { + ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + uint32_t small_buffer_length = buffer_length / NUM_BUFFERS; + + for (int i = 0; i < NUM_BUFFERS; i++) { + this->buffers_[i] = allocator.allocate(small_buffer_length); + if (this->buffers_[i] == nullptr) { + ESP_LOGE(TAG, "Could not allocate buffer %d for display!", i); + for (auto &buffer : this->buffers_) { + allocator.deallocate(buffer, small_buffer_length); + buffer = nullptr; + } + return; + } + } + this->clear(); +} +uint8_t WaveshareEPaper7C::color_to_hex(Color color) { + uint8_t hex_code; + if (color.red > 127) { + if (color.green > 170) { + if (color.blue > 127) { + hex_code = 0x1; // White + } else { + hex_code = 0x5; // Yellow + } + } else if (color.green > 85) { + hex_code = 0x6; // Orange + } else { + hex_code = 0x4; // Red (or Magenta) + } + } else { + if (color.green > 127) { + if (color.blue > 127) { + hex_code = 0x3; // Cyan -> Blue + } else { + hex_code = 0x2; // Green + } + } else { + if (color.blue > 127) { + hex_code = 0x3; // Blue + } else { + hex_code = 0x0; // Black + } + } + } + + return hex_code; +} +void WaveshareEPaper7C::fill(Color color) { + uint8_t pixel_color; + if (color.is_on()) { + pixel_color = this->color_to_hex(color); + } else { + pixel_color = 0x1; + } + + if (this->buffers_[0] == nullptr) { + ESP_LOGE(TAG, "Buffer unavailable!"); + } else { + uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS; + for (auto &buffer : this->buffers_) { + for (uint32_t buffer_pos = 0; buffer_pos < small_buffer_length; buffer_pos += 3) { + // We store 8 bitset<3> in 3 bytes + // | byte 1 | byte 2 | byte 3 | + // |aaabbbaa|abbbaaab|bbaaabbb| + buffer[buffer_pos + 0] = pixel_color << 5 | pixel_color << 2 | pixel_color >> 1; + buffer[buffer_pos + 1] = pixel_color << 7 | pixel_color << 4 | pixel_color << 1 | pixel_color >> 2; + buffer[buffer_pos + 2] = pixel_color << 6 | pixel_color << 3 | pixel_color << 0; + } + App.feed_wdt(); + } + } +} void HOT WaveshareEPaper::draw_absolute_pixel_internal(int x, int y, Color color) { if (x >= this->get_width_internal() || y >= this->get_height_internal() || x < 0 || y < 0) return; @@ -193,6 +278,9 @@ uint32_t WaveshareEPaper::get_buffer_length_() { uint32_t WaveshareEPaperBWR::get_buffer_length_() { return this->get_width_controller() * this->get_height_internal() / 4u; } // black and red buffer +uint32_t WaveshareEPaper7C::get_buffer_length_() { + return this->get_width_controller() * this->get_height_internal() / 8u * 3u; +} // 7 colors buffer, 1 pixel = 3 bits, we will store 8 pixels in 24 bits = 3 bytes void WaveshareEPaperBWR::fill(Color color) { this->filled_rectangle(0, 0, this->get_width(), this->get_height(), color); @@ -219,7 +307,33 @@ void HOT WaveshareEPaperBWR::draw_absolute_pixel_internal(int x, int y, Color co this->buffer_[pos + buf_half_len] &= ~(0x80 >> subpos); } } +void HOT WaveshareEPaper7C::draw_absolute_pixel_internal(int x, int y, Color color) { + if (x >= this->get_width_internal() || y >= this->get_height_internal() || x < 0 || y < 0) + return; + uint8_t pixel_bits = this->color_to_hex(color); + uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS; + uint32_t pixel_position = x + y * this->get_width_controller(); + uint32_t first_bit_position = pixel_position * 3; + uint32_t byte_position = first_bit_position / 8u; + uint32_t byte_subposition = first_bit_position % 8u; + uint32_t buffer_position = byte_position / small_buffer_length; + uint32_t buffer_subposition = byte_position % small_buffer_length; + + if (byte_subposition <= 5) { + this->buffers_[buffer_position][buffer_subposition] = + (this->buffers_[buffer_position][buffer_subposition] & (0xFF ^ (0b111 << (5 - byte_subposition)))) | + (pixel_bits << (5 - byte_subposition)); + } else { + this->buffers_[buffer_position][buffer_subposition + 0] = + (this->buffers_[buffer_position][buffer_subposition + 0] & (0xFF ^ (0b111 >> (byte_subposition - 5)))) | + (pixel_bits >> (byte_subposition - 5)); + + this->buffers_[buffer_position][buffer_subposition + 1] = (this->buffers_[buffer_position][buffer_subposition + 1] & + (0xFF ^ (0xFF & (0b111 << (13 - byte_subposition))))) | + (pixel_bits << (13 - byte_subposition)); + } +} void WaveshareEPaperBase::start_command_() { this->dc_pin_->digital_write(false); this->enable(); @@ -3193,6 +3307,195 @@ void WaveshareEPaper7P5In::dump_config() { LOG_PIN(" Busy Pin: ", this->busy_pin_); LOG_UPDATE_INTERVAL(this); } +void WaveshareEPaper7P3InF::initialize() { + if (this->buffers_[0] == nullptr) { + ESP_LOGE(TAG, "Buffer unavailable!"); + return; + } + + this->reset_(); + delay(20); + this->wait_until_idle_(); + + // COMMAND CMDH + this->command(0xAA); + this->data(0x49); + this->data(0x55); + this->data(0x20); + this->data(0x08); + this->data(0x09); + this->data(0x18); + + this->command(0x01); + this->data(0x3F); + this->data(0x00); + this->data(0x32); + this->data(0x2A); + this->data(0x0E); + this->data(0x2A); + + this->command(0x00); + this->data(0x5F); + this->data(0x69); + + this->command(0x03); + this->data(0x00); + this->data(0x54); + this->data(0x00); + this->data(0x44); + + this->command(0x05); + this->data(0x40); + this->data(0x1F); + this->data(0x1F); + this->data(0x2C); + + this->command(0x06); + this->data(0x6F); + this->data(0x1F); + this->data(0x1F); + this->data(0x22); + + this->command(0x08); + this->data(0x6F); + this->data(0x1F); + this->data(0x1F); + this->data(0x22); + + // COMMAND IPC + this->command(0x13); + this->data(0x00); + this->data(0x04); + + this->command(0x30); + this->data(0x3C); + + // COMMAND TSE + this->command(0x41); + this->data(0x00); + + this->command(0x50); + this->data(0x3F); + + this->command(0x60); + this->data(0x02); + this->data(0x00); + + this->command(0x61); + this->data(0x03); + this->data(0x20); + this->data(0x01); + this->data(0xE0); + + this->command(0x82); + this->data(0x1E); + + this->command(0x84); + this->data(0x00); + + // COMMAND AGID + this->command(0x86); + this->data(0x00); + + this->command(0xE3); + this->data(0x2F); + + // COMMAND CCSET + this->command(0xE0); + this->data(0x00); + + // COMMAND TSSET + this->command(0xE6); + this->data(0x00); + + ESP_LOGI(TAG, "Display initialized successfully"); +} +void HOT WaveshareEPaper7P3InF::display() { + if (this->buffers_[0] == nullptr) { + ESP_LOGE(TAG, "Buffer unavailable!"); + return; + } + + // INITIALIZATION + ESP_LOGI(TAG, "Initialise the display"); + this->initialize(); + + // COMMAND DATA START TRANSMISSION + ESP_LOGI(TAG, "Sending data to the display"); + this->command(0x10); + uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS; + uint8_t byte_to_send; + for (auto &buffer : this->buffers_) { + for (uint32_t buffer_pos = 0; buffer_pos < small_buffer_length; buffer_pos += 3) { + std::bitset<24> triplet = + buffer[buffer_pos + 0] << 16 | buffer[buffer_pos + 1] << 8 | buffer[buffer_pos + 2] << 0; + // 8 bitset<3> are stored in 3 bytes + // |aaabbbaa|abbbaaab|bbaaabbb| + // | byte 1 | byte 2 | byte 3 | + byte_to_send = ((triplet >> 17).to_ulong() & 0b01110000) | ((triplet >> 18).to_ulong() & 0b00000111); + this->data(byte_to_send); + + byte_to_send = ((triplet >> 11).to_ulong() & 0b01110000) | ((triplet >> 12).to_ulong() & 0b00000111); + this->data(byte_to_send); + + byte_to_send = ((triplet >> 5).to_ulong() & 0b01110000) | ((triplet >> 6).to_ulong() & 0b00000111); + this->data(byte_to_send); + + byte_to_send = ((triplet << 1).to_ulong() & 0b01110000) | ((triplet << 0).to_ulong() & 0b00000111); + this->data(byte_to_send); + } + App.feed_wdt(); + } + + // COMMAND POWER ON + ESP_LOGI(TAG, "Power on the display"); + this->command(0x04); + this->wait_until_idle_(); + + // COMMAND REFRESH SCREEN + ESP_LOGI(TAG, "Refresh the display"); + this->command(0x12); + this->data(0x00); + this->wait_until_idle_(); + + // COMMAND POWER OFF + ESP_LOGI(TAG, "Power off the display"); + this->command(0x02); + this->data(0x00); + this->wait_until_idle_(); + + ESP_LOGI(TAG, "Set the display to deep sleep"); + this->command(0x07); + this->data(0xA5); +} +int WaveshareEPaper7P3InF::get_width_internal() { return 800; } +int WaveshareEPaper7P3InF::get_height_internal() { return 480; } +uint32_t WaveshareEPaper7P3InF::idle_timeout_() { return 35000; } +void WaveshareEPaper7P3InF::dump_config() { + LOG_DISPLAY("", "Waveshare E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 7.3in-F"); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} + +bool WaveshareEPaper7P3InF::wait_until_idle_() { + if (this->busy_pin_ == nullptr) { + return true; + } + const uint32_t start = millis(); + while (this->busy_pin_->digital_read()) { + if (millis() - start > this->idle_timeout_()) { + ESP_LOGE(TAG, "Timeout while displaying image!"); + return false; + } + App.feed_wdt(); + delay(10); + } + delay(200); // NOLINT + return true; +} bool WaveshareEPaper7P5InV2::wait_until_idle_() { if (this->busy_pin_ == nullptr) { return true; diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 1e7cb6c6c7..d6387cd643 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -27,10 +27,7 @@ class WaveshareEPaperBase : public display::DisplayBuffer, void update() override; - void setup() override { - this->setup_pins_(); - this->initialize(); - } + void setup() override; void on_safe_shutdown() override; @@ -86,6 +83,23 @@ class WaveshareEPaperBWR : public WaveshareEPaperBase { uint32_t get_buffer_length_() override; }; +class WaveshareEPaper7C : public WaveshareEPaperBase { + public: + uint8_t color_to_hex(Color color); + void fill(Color color) override; + + display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; } + + protected: + void draw_absolute_pixel_internal(int x, int y, Color color) override; + uint32_t get_buffer_length_() override; + void setup() override; + void init_internal_7c_(uint32_t buffer_length); + + static const int NUM_BUFFERS = 10; + uint8_t *buffers_[NUM_BUFFERS]; +}; + enum WaveshareEPaperTypeAModel { WAVESHARE_EPAPER_1_54_IN = 0, WAVESHARE_EPAPER_1_54_IN_V2, @@ -160,6 +174,7 @@ enum WaveshareEPaperTypeBModel { WAVESHARE_EPAPER_2_7_IN_B_V2, WAVESHARE_EPAPER_4_2_IN, WAVESHARE_EPAPER_4_2_IN_B_V2, + WAVESHARE_EPAPER_7_3_IN_F, WAVESHARE_EPAPER_7_5_IN, WAVESHARE_EPAPER_7_5_INV2, WAVESHARE_EPAPER_7_5_IN_B_V2, @@ -668,6 +683,39 @@ class WaveshareEPaper5P8InV2 : public WaveshareEPaper { int get_height_internal() override; }; +class WaveshareEPaper7P3InF : public WaveshareEPaper7C { + public: + void initialize() override; + + void display() override; + + void dump_config() override; + + protected: + int get_width_internal() override; + + int get_height_internal() override; + + uint32_t idle_timeout_() override; + + void deep_sleep() override { ; } + + bool wait_until_idle_(); + + bool deep_sleep_between_updates_{true}; + + void reset_() { + if (this->reset_pin_ != nullptr) { + this->reset_pin_->digital_write(true); + delay(20); + this->reset_pin_->digital_write(false); + delay(1); + this->reset_pin_->digital_write(true); + delay(20); + } + }; +}; + class WaveshareEPaper7P5In : public WaveshareEPaper { public: void initialize() override; From 0b6c416680b24efb217d39a88d1bac5e6daed665 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:16:17 +1300 Subject: [PATCH 193/194] Bump esphome-dashboard to 20250212.0 (#8235) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0d93c3cc2d..bbf0ae7f3d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ pyserial==3.5 platformio==6.1.16 # When updating platformio, also update Dockerfile esptool==4.7.0 click==8.1.7 -esphome-dashboard==20241217.1 +esphome-dashboard==20250212.0 aioesphomeapi==24.6.2 zeroconf==0.143.0 puremagic==1.27 From 2b75e34719acfea017f436c63036050f1c9f3651 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:53:43 +1300 Subject: [PATCH 194/194] Bump version to 2025.2.0b1 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 16bfda9478..696cc599fc 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.0-dev" +__version__ = "2025.2.0b1" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = (