diff --git a/.github/actions/build-image/action.yaml b/.github/actions/build-image/action.yaml index e6b6da4177..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.11.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.11.0 + uses: docker/build-push-action@v6.13.0 env: DOCKER_BUILD_SUMMARY: false DOCKER_BUILD_RECORD_UPLOAD: false diff --git a/.github/actions/restore-python/action.yml b/.github/actions/restore-python/action.yml index 6b87cf0170..c53e64a7b9 100644 --- a/.github/actions/restore-python/action.yml +++ b/.github/actions/restore-python/action.yml @@ -17,12 +17,12 @@ 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 id: cache-venv - uses: actions/cache/restore@v4.2.0 + uses: actions/cache/restore@v4.2.1 with: path: venv # yamllint disable-line rule:line-length 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..303a6a777f 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -33,22 +33,20 @@ concurrency: jobs: check-docker: name: Build docker containers - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - arch: [amd64, armv7, aarch64] + os: ["ubuntu-latest", "ubuntu-24.04-arm"] build_type: ["ha-addon", "docker", "lint"] 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 - uses: docker/setup-buildx-action@v3.8.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3.3.0 + uses: docker/setup-buildx-action@v3.9.0 - name: Set TAG run: | @@ -58,6 +56,6 @@ jobs: run: | docker/build.py \ --tag "${TAG}" \ - --arch "${{ matrix.arch }}" \ + --arch "${{ matrix.os == 'ubuntu-24.04-arm' && 'aarch64' || 'amd64' }}" \ --build-type "${{ matrix.build_type }}" \ build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a344b177ae..59dc31e9f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,12 +42,12 @@ 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 id: cache-venv - uses: actions/cache@v4.2.0 + uses: actions/cache@v4.2.1 with: path: venv # yamllint disable-line rule:line-length @@ -61,8 +61,8 @@ jobs: pip install -r requirements.txt -r requirements_optional.txt -r requirements_test.txt pip install -e . - black: - name: Check black + ruff: + name: Check ruff runs-on: ubuntu-24.04 needs: - common @@ -74,10 +74,10 @@ jobs: with: python-version: ${{ env.DEFAULT_PYTHON }} cache-key: ${{ needs.common.outputs.cache-key }} - - name: Run black + - name: Run Ruff run: | . venv/bin/activate - black --verbose esphome tests + ruff format esphome tests - name: Suggested changes run: script/ci-suggest-changes if: always() @@ -255,7 +255,7 @@ jobs: runs-on: ubuntu-24.04 needs: - common - - black + - ruff - ci-custom - clang-format - flake8 @@ -303,14 +303,14 @@ jobs: - name: Cache platformio if: github.ref == 'refs/heads/dev' - uses: actions/cache@v4.2.0 + uses: actions/cache@v4.2.1 with: path: ~/.platformio key: platformio-${{ matrix.pio_cache_key }} - name: Cache platformio if: github.ref != 'refs/heads/dev' - uses: actions/cache/restore@v4.2.0 + uses: actions/cache/restore@v4.2.1 with: path: ~/.platformio key: platformio-${{ matrix.pio_cache_key }} @@ -482,7 +482,7 @@ jobs: runs-on: ubuntu-24.04 needs: - common - - black + - ruff - ci-custom - clang-format - flake8 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 962bc66e94..aa41cf2790 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 @@ -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 }} @@ -80,20 +80,19 @@ jobs: matrix: platform: - linux/amd64 - - linux/arm/v7 - linux/arm64 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 - 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 @@ -184,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' 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 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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aeb434167a..667a8f2e8b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,21 +4,13 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.5.4 + rev: v0.9.2 hooks: # Run the linter. - id: ruff 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: @@ -53,6 +45,6 @@ repos: hooks: - id: pylint name: pylint - entry: script/run-in-env.sh pylint - language: script + entry: python3 script/run-in-env.py pylint + language: system types: [python] diff --git a/CODEOWNERS b/CODEOWNERS index ba7106e6a3..c725c2e736 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 @@ -132,6 +133,8 @@ 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 esphome/components/esp32_ble/* @Rapsssito @jesserockz @@ -145,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 @@ -230,6 +234,7 @@ esphome/components/kuntze/* @ssieb esphome/components/lcd_menu/* @numo68 esphome/components/ld2410/* @regevbr @sebcaps esphome/components/ld2420/* @descipher +esphome/components/ld2450/* @hareeshmu esphome/components/ledc/* @OttoWinter esphome/components/libretiny/* @kuba2k2 esphome/components/libretiny_pwm/* @kuba2k2 @@ -238,6 +243,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 @@ -273,6 +279,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 @@ -339,7 +346,7 @@ 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/resampler/speaker/* @kahrendt esphome/components/restart/* @esphome/core esphome/components/rf_bridge/* @jesserockz esphome/components/rgbct/* @jesserockz @@ -352,7 +359,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 @@ -384,6 +391,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 @@ -494,5 +502,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/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/) diff --git a/docker/Dockerfile b/docker/Dockerfile index 429f5c4a1f..6da5c52d64 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -35,7 +35,7 @@ RUN \ iputils-ping=3:20221126-1+deb12u1 \ git=1:2.39.5-0+deb12u1 \ curl=7.88.1-10+deb12u8 \ - openssh-client=1:9.2p1-2+deb12u3 \ + openssh-client=1:9.2p1-2+deb12u4 \ python3-cffi=1.15.1-5 \ libcairo2=1.16.0-7 \ libmagic1=1:5.44-3 \ @@ -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 <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/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/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/api/client.py b/esphome/components/api/client.py index dd013c8c34..c61b8d5ea3 100644 --- a/esphome/components/api/client.py +++ b/esphome/components/api/client.py @@ -1,12 +1,11 @@ from __future__ import annotations import asyncio -import logging from datetime import datetime -from typing import Any +import logging +from typing import TYPE_CHECKING, Any from aioesphomeapi import APIClient -from aioesphomeapi.api_pb2 import SubscribeLogsResponse from aioesphomeapi.log_runner import async_run from esphome.const import CONF_KEY, CONF_PASSWORD, CONF_PORT, __version__ @@ -14,6 +13,12 @@ from esphome.core import CORE from . import CONF_ENCRYPTION +if TYPE_CHECKING: + from aioesphomeapi.api_pb2 import ( + SubscribeLogsResponse, # pylint: disable=no-name-in-module + ) + + _LOGGER = logging.getLogger(__name__) 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/audio/audio_decoder.cpp b/esphome/components/audio/audio_decoder.cpp new file mode 100644 index 0000000000..ab358ad805 --- /dev/null +++ b/esphome/components/audio/audio_decoder.cpp @@ -0,0 +1,361 @@ +#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: + // Intentional fallthrough + 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 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 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..7f4e987b4c --- /dev/null +++ b/esphome/components/audio/audio_resampler.h @@ -0,0 +1,101 @@ +#pragma once + +#ifdef USE_ESP32 + +#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 "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 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 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/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/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/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); } 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/climate/__init__.py b/esphome/components/climate/__init__.py index ec68940726..445507c620 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)?" ) @@ -128,7 +128,6 @@ VISUAL_TEMPERATURE_STEP_SCHEMA = cv.Schema( def visual_temperature_step(value): - # Allow defining target/current temperature steps separately if isinstance(value, dict): return VISUAL_TEMPERATURE_STEP_SCHEMA(value) diff --git a/esphome/components/cse7766/cse7766.cpp b/esphome/components/cse7766/cse7766.cpp index 3907c195d0..88a91e374a 100644 --- a/esphome/components/cse7766/cse7766.cpp +++ b/esphome/components/cse7766/cse7766.cpp @@ -1,8 +1,5 @@ #include "cse7766.h" #include "esphome/core/log.h" -#include -#include -#include namespace esphome { namespace cse7766 { @@ -72,12 +69,8 @@ bool CSE7766Component::check_byte_() { void CSE7766Component::parse_data_() { #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE { - std::stringstream ss; - ss << "Raw data:" << std::hex << std::uppercase << std::setfill('0'); - for (uint8_t i = 0; i < 23; i++) { - ss << ' ' << std::setw(2) << static_cast(this->raw_data_[i]); - } - ESP_LOGVV(TAG, "%s", ss.str().c_str()); + std::string s = format_hex_pretty(this->raw_data_, sizeof(this->raw_data_)); + ESP_LOGVV(TAG, "Raw data: %s", s.c_str()); } #endif @@ -211,21 +204,20 @@ void CSE7766Component::parse_data_() { #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE { - std::stringstream ss; - ss << "Parsed:"; + std::string buf = "Parsed:"; if (have_voltage) { - ss << " V=" << voltage << "V"; + buf += str_sprintf(" V=%fV", voltage); } if (have_current) { - ss << " I=" << current * 1000.0f << "mA (~" << calculated_current * 1000.0f << "mA)"; + buf += str_sprintf(" I=%fmA (~%fmA)", current * 1000.0f, calculated_current * 1000.0f); } if (have_power) { - ss << " P=" << power << "W"; + buf += str_sprintf(" P=%fW", power); } if (energy != 0.0f) { - ss << " E=" << energy << "kWh (" << cf_pulses << ")"; + buf += str_sprintf(" E=%fkWh (%u)", energy, cf_pulses); } - ESP_LOGVV(TAG, "%s", ss.str().c_str()); + ESP_LOGVV(TAG, "%s", buf.c_str()); } #endif } 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 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) ) 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); diff --git a/esphome/components/dht/dht.cpp b/esphome/components/dht/dht.cpp index 5a18f6f36e..f2a33a26ac 100644 --- a/esphome/components/dht/dht.cpp +++ b/esphome/components/dht/dht.cpp @@ -23,6 +23,7 @@ void DHT::dump_config() { } else { ESP_LOGCONFIG(TAG, " Model: DHT22 (or equivalent)"); } + ESP_LOGCONFIG(TAG, " Internal Pull-up: %s", ONOFF(this->pin_->get_flags() & gpio::FLAG_PULLUP)); LOG_UPDATE_INTERVAL(this); @@ -101,7 +102,7 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r } else { delayMicroseconds(800); } - this->pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP); + this->pin_->pin_mode(this->pin_->get_flags()); { InterruptLock lock; diff --git a/esphome/components/dht/sensor.py b/esphome/components/dht/sensor.py index da92a97e1f..be53df2625 100644 --- a/esphome/components/dht/sensor.py +++ b/esphome/components/dht/sensor.py @@ -34,7 +34,7 @@ DHT = dht_ns.class_("DHT", cg.PollingComponent) CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(): cv.declare_id(DHT), - cv.Required(CONF_PIN): pins.internal_gpio_input_pin_schema, + cv.Required(CONF_PIN): pins.internal_gpio_input_pullup_pin_schema, cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema( unit_of_measurement=UNIT_CELSIUS, accuracy_decimals=1, 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: diff --git a/esphome/components/display/display.cpp b/esphome/components/display/display.cpp index 202c64ef14..b12a81e050 100644 --- a/esphome/components/display/display.cpp +++ b/esphome/components/display/display.cpp @@ -815,8 +815,20 @@ void Display::test_card() { DisplayPage::DisplayPage(display_writer_t writer) : writer_(std::move(writer)) {} void DisplayPage::show() { this->parent_->show_page(this); } -void DisplayPage::show_next() { this->next_->show(); } -void DisplayPage::show_prev() { this->prev_->show(); } +void DisplayPage::show_next() { + if (this->next_ == nullptr) { + ESP_LOGE(TAG, "no next page"); + return; + } + this->next_->show(); +} +void DisplayPage::show_prev() { + if (this->prev_ == nullptr) { + ESP_LOGE(TAG, "no previous page"); + return; + } + this->prev_->show(); +} void DisplayPage::set_parent(Display *parent) { this->parent_ = parent; } void DisplayPage::set_prev(DisplayPage *prev) { this->prev_ = prev; } void DisplayPage::set_next(DisplayPage *next) { this->next_ = next; } 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/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/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/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/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/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_beacon/__init__.py b/esphome/components/esp32_ble_beacon/__init__.py index f97f289a0a..6e0d103aa0 100644 --- a/esphome/components/esp32_ble_beacon/__init__.py +++ b/esphome/components/esp32_ble_beacon/__init__.py @@ -66,7 +66,9 @@ FINAL_VALIDATE_SCHEMA = esp32_ble.validate_variant async def to_code(config): uuid = config[CONF_UUID].hex - uuid_arr = [cg.RawExpression(f"0x{uuid[i:i + 2]}") for i in range(0, len(uuid), 2)] + uuid_arr = [ + cg.RawExpression(f"0x{uuid[i : i + 2]}") for i in range(0, len(uuid), 2) + ] var = cg.new_Pvariable(config[CONF_ID], uuid_arr) parent = await cg.get_variable(config[esp32_ble.CONF_BLE_ID]) 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_dac/esp32_dac.cpp b/esphome/components/esp32_dac/esp32_dac.cpp index 7f37e2ce47..6f1577b8b1 100644 --- a/esphome/components/esp32_dac/esp32_dac.cpp +++ b/esphome/components/esp32_dac/esp32_dac.cpp @@ -7,13 +7,16 @@ #ifdef USE_ARDUINO #include #endif -#ifdef USE_ESP_IDF -#include -#endif namespace esphome { namespace esp32_dac { +#ifdef USE_ESP32_VARIANT_ESP32S2 +static constexpr uint8_t DAC0_PIN = 17; +#else +static constexpr uint8_t DAC0_PIN = 25; +#endif + static const char *const TAG = "esp32_dac"; void ESP32DAC::setup() { @@ -22,8 +25,15 @@ void ESP32DAC::setup() { this->turn_off(); #ifdef USE_ESP_IDF - auto channel = pin_->get_pin() == 25 ? DAC_CHANNEL_1 : DAC_CHANNEL_2; - dac_output_enable(channel); + const dac_channel_t channel = this->pin_->get_pin() == DAC0_PIN ? DAC_CHAN_0 : DAC_CHAN_1; + const dac_oneshot_config_t oneshot_cfg{channel}; + dac_oneshot_new_channel(&oneshot_cfg, &this->dac_handle_); +#endif +} + +void ESP32DAC::on_safe_shutdown() { +#ifdef USE_ESP_IDF + dac_oneshot_del_channel(this->dac_handle_); #endif } @@ -40,8 +50,7 @@ void ESP32DAC::write_state(float state) { state = state * 255; #ifdef USE_ESP_IDF - auto channel = pin_->get_pin() == 25 ? DAC_CHANNEL_1 : DAC_CHANNEL_2; - dac_output_voltage(channel, (uint8_t) state); + dac_oneshot_output_voltage(this->dac_handle_, state); #endif #ifdef USE_ARDUINO dacWrite(this->pin_->get_pin(), state); diff --git a/esphome/components/esp32_dac/esp32_dac.h b/esphome/components/esp32_dac/esp32_dac.h index 0fb1ddebf0..63d0c914a1 100644 --- a/esphome/components/esp32_dac/esp32_dac.h +++ b/esphome/components/esp32_dac/esp32_dac.h @@ -7,6 +7,10 @@ #ifdef USE_ESP32 +#ifdef USE_ESP_IDF +#include +#endif + namespace esphome { namespace esp32_dac { @@ -16,6 +20,7 @@ class ESP32DAC : public output::FloatOutput, public Component { /// Initialize pin void setup() override; + void on_safe_shutdown() override; void dump_config() override; /// HARDWARE setup_priority float get_setup_priority() const override { return setup_priority::HARDWARE; } @@ -24,6 +29,9 @@ class ESP32DAC : public output::FloatOutput, public Component { void write_state(float state) override; InternalGPIOPin *pin_; +#ifdef USE_ESP_IDF + dac_oneshot_handle_t dac_handle_; +#endif }; } // namespace esp32_dac diff --git a/esphome/components/esp32_dac/output.py b/esphome/components/esp32_dac/output.py index f119198618..c80780986f 100644 --- a/esphome/components/esp32_dac/output.py +++ b/esphome/components/esp32_dac/output.py @@ -1,15 +1,27 @@ +import esphome.codegen as cg +import esphome.config_validation as cv from esphome import pins from esphome.components import output -import esphome.config_validation as cv -import esphome.codegen as cg +from esphome.components.esp32 import get_esp32_variant +from esphome.components.esp32.const import VARIANT_ESP32, VARIANT_ESP32S2 from esphome.const import CONF_ID, CONF_NUMBER, CONF_PIN DEPENDENCIES = ["esp32"] +DAC_PINS = { + VARIANT_ESP32: (25, 26), + VARIANT_ESP32S2: (17, 18), +} + def valid_dac_pin(value): - num = value[CONF_NUMBER] - cv.one_of(25, 26)(num) + variant = get_esp32_variant() + try: + valid_pins = DAC_PINS[variant] + except KeyError as ex: + raise cv.Invalid(f"DAC is not supported on {variant}") from ex + given_pin = value[CONF_NUMBER] + cv.one_of(*valid_pins)(given_pin) return value 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/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/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_) { 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/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/esp8266/gpio.py b/esphome/components/esp8266/gpio.py index 53016d2130..050efaacae 100644 --- a/esphome/components/esp8266/gpio.py +++ b/esphome/components/esp8266/gpio.py @@ -112,8 +112,7 @@ def validate_supports(value): ) if is_pullup and num == 16: raise cv.Invalid( - "GPIO Pin 16 does not support pullup pin mode. " - "Please choose another pin.", + "GPIO Pin 16 does not support pullup pin mode. Please choose another pin.", [CONF_MODE, CONF_PULLUP], ) if is_pulldown and num != 16: 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/components/font/__init__.py b/esphome/components/font/__init__.py index e2051298fe..4f569379be 100644 --- a/esphome/components/font/__init__.py +++ b/esphome/components/font/__init__.py @@ -5,8 +5,8 @@ import os from pathlib import Path import re +import esphome_glyphsets as glyphsets import freetype -import glyphsets import requests from esphome import core, external_files diff --git a/esphome/components/graph/graph.cpp b/esphome/components/graph/graph.cpp index 09f7557714..cbe059b255 100644 --- a/esphome/components/graph/graph.cpp +++ b/esphome/components/graph/graph.cpp @@ -4,9 +4,6 @@ #include "esphome/core/log.h" #include "esphome/core/hal.h" #include -#include -#include // std::cout, std::fixed -#include namespace esphome { namespace graph { @@ -231,9 +228,8 @@ void GraphLegend::init(Graph *g) { ESP_LOGI(TAGL, " %s %d %d", txtstr.c_str(), fw, fh); if (this->values_ != VALUE_POSITION_TYPE_NONE) { - std::stringstream ss; - ss << std::fixed << std::setprecision(trace->sensor_->get_accuracy_decimals()) << trace->sensor_->get_state(); - std::string valstr = ss.str(); + std::string valstr = + value_accuracy_to_string(trace->sensor_->get_state(), trace->sensor_->get_accuracy_decimals()); if (this->units_) { valstr += trace->sensor_->get_unit_of_measurement(); } @@ -368,9 +364,8 @@ void Graph::draw_legend(display::Display *buff, uint16_t x_offset, uint16_t y_of if (legend_->values_ != VALUE_POSITION_TYPE_NONE) { int xv = x + legend_->xv_; int yv = y + legend_->yv_; - std::stringstream ss; - ss << std::fixed << std::setprecision(trace->sensor_->get_accuracy_decimals()) << trace->sensor_->get_state(); - std::string valstr = ss.str(); + std::string valstr = + value_accuracy_to_string(trace->sensor_->get_state(), trace->sensor_->get_accuracy_decimals()); if (legend_->units_) { valstr += trace->sensor_->get_unit_of_measurement(); } diff --git a/esphome/components/haier/climate.py b/esphome/components/haier/climate.py index f2dc7174cb..f77d624649 100644 --- a/esphome/components/haier/climate.py +++ b/esphome/components/haier/climate.py @@ -1,9 +1,15 @@ -import logging -import esphome.codegen as cg -import esphome.config_validation as cv -import esphome.final_validate as fv -from esphome.components import uart, climate, logger +import logging + from esphome import automation +import esphome.codegen as cg +from esphome.components import climate, logger, uart +from esphome.components.climate import ( + CONF_CURRENT_TEMPERATURE, + ClimateMode, + ClimatePreset, + ClimateSwingMode, +) +import esphome.config_validation as cv from esphome.const import ( CONF_BEEPER, CONF_DISPLAY, @@ -24,12 +30,7 @@ from esphome.const import ( CONF_VISUAL, CONF_WIFI, ) -from esphome.components.climate import ( - ClimateMode, - ClimatePreset, - ClimateSwingMode, - CONF_CURRENT_TEMPERATURE, -) +import esphome.final_validate as fv _LOGGER = logging.getLogger(__name__) 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/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/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 b449f046ee..78c37403f5 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 { @@ -82,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(); @@ -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 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)); diff --git a/esphome/components/i2s_audio/speaker/__init__.py b/esphome/components/i2s_audio/speaker/__init__.py index 0355c16321..aa3b50d336 100644 --- a/esphome/components/i2s_audio/speaker/__init__.py +++ b/esphome/components/i2s_audio/speaker/__init__.py @@ -1,13 +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_CHANNEL, CONF_ID, CONF_MODE, CONF_TIMEOUT +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, @@ -24,10 +36,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 = { @@ -53,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() @@ -85,6 +129,7 @@ BASE_SCHEMA = ( .extend(cv.COMPONENT_SCHEMA) ) + CONFIG_SCHEMA = cv.All( cv.typed_schema( { @@ -106,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/image/__init__.py b/esphome/components/image/__init__.py index a503e8f471..20b041a321 100644 --- a/esphome/components/image/__init__.py +++ b/esphome/components/image/__init__.py @@ -273,16 +273,14 @@ 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") -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 +415,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 +456,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 +472,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 +490,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 +552,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/ld2450/__init__.py b/esphome/components/ld2450/__init__.py new file mode 100644 index 0000000000..37f68a8f3e --- /dev/null +++ b/esphome/components/ld2450/__init__.py @@ -0,0 +1,51 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import uart +from esphome.const import ( + CONF_ID, + CONF_THROTTLE, +) + +DEPENDENCIES = ["uart"] +CODEOWNERS = ["@hareeshmu"] +MULTI_CONF = True + +ld2450_ns = cg.esphome_ns.namespace("ld2450") +LD2450Component = ld2450_ns.class_("LD2450Component", cg.Component, uart.UARTDevice) + +CONF_LD2450_ID = "ld2450_id" + +CONFIG_SCHEMA = cv.All( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(LD2450Component), + cv.Optional(CONF_THROTTLE, default="1000ms"): cv.All( + cv.positive_time_period_milliseconds, + cv.Range(min=cv.TimePeriod(milliseconds=1)), + ), + } + ) + .extend(uart.UART_DEVICE_SCHEMA) + .extend(cv.COMPONENT_SCHEMA) +) + +LD2450BaseSchema = cv.Schema( + { + cv.GenerateID(CONF_LD2450_ID): cv.use_id(LD2450Component), + }, +) + +FINAL_VALIDATE_SCHEMA = uart.final_validate_device_schema( + "ld2450", + require_tx=True, + require_rx=True, + parity="NONE", + stop_bits=1, +) + + +async def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + await cg.register_component(var, config) + await uart.register_uart_device(var, config) + cg.add(var.set_throttle(config[CONF_THROTTLE])) diff --git a/esphome/components/ld2450/binary_sensor.py b/esphome/components/ld2450/binary_sensor.py new file mode 100644 index 0000000000..d0082ac21a --- /dev/null +++ b/esphome/components/ld2450/binary_sensor.py @@ -0,0 +1,47 @@ +import esphome.codegen as cg +from esphome.components import binary_sensor +import esphome.config_validation as cv +from esphome.const import ( + CONF_HAS_MOVING_TARGET, + CONF_HAS_STILL_TARGET, + CONF_HAS_TARGET, + DEVICE_CLASS_MOTION, + DEVICE_CLASS_OCCUPANCY, +) + +from . import CONF_LD2450_ID, LD2450Component + +DEPENDENCIES = ["ld2450"] + +ICON_MEDITATION = "mdi:meditation" +ICON_SHIELD_ACCOUNT = "mdi:shield-account" +ICON_TARGET_ACCOUNT = "mdi:target-account" + +CONFIG_SCHEMA = { + cv.GenerateID(CONF_LD2450_ID): cv.use_id(LD2450Component), + cv.Optional(CONF_HAS_TARGET): binary_sensor.binary_sensor_schema( + device_class=DEVICE_CLASS_OCCUPANCY, + icon=ICON_SHIELD_ACCOUNT, + ), + cv.Optional(CONF_HAS_MOVING_TARGET): binary_sensor.binary_sensor_schema( + device_class=DEVICE_CLASS_MOTION, + icon=ICON_TARGET_ACCOUNT, + ), + cv.Optional(CONF_HAS_STILL_TARGET): binary_sensor.binary_sensor_schema( + device_class=DEVICE_CLASS_OCCUPANCY, + icon=ICON_MEDITATION, + ), +} + + +async def to_code(config): + ld2450_component = await cg.get_variable(config[CONF_LD2450_ID]) + if has_target_config := config.get(CONF_HAS_TARGET): + sens = await binary_sensor.new_binary_sensor(has_target_config) + cg.add(ld2450_component.set_target_binary_sensor(sens)) + if has_moving_target_config := config.get(CONF_HAS_MOVING_TARGET): + sens = await binary_sensor.new_binary_sensor(has_moving_target_config) + cg.add(ld2450_component.set_moving_target_binary_sensor(sens)) + if has_still_target_config := config.get(CONF_HAS_STILL_TARGET): + sens = await binary_sensor.new_binary_sensor(has_still_target_config) + cg.add(ld2450_component.set_still_target_binary_sensor(sens)) diff --git a/esphome/components/ld2450/button/__init__.py b/esphome/components/ld2450/button/__init__.py new file mode 100644 index 0000000000..39671d3a3b --- /dev/null +++ b/esphome/components/ld2450/button/__init__.py @@ -0,0 +1,45 @@ +import esphome.codegen as cg +from esphome.components import button +import esphome.config_validation as cv +from esphome.const import ( + CONF_FACTORY_RESET, + CONF_RESTART, + DEVICE_CLASS_RESTART, + ENTITY_CATEGORY_CONFIG, + ENTITY_CATEGORY_DIAGNOSTIC, + ICON_RESTART, + ICON_RESTART_ALERT, +) + +from .. import CONF_LD2450_ID, LD2450Component, ld2450_ns + +ResetButton = ld2450_ns.class_("ResetButton", button.Button) +RestartButton = ld2450_ns.class_("RestartButton", button.Button) + +CONFIG_SCHEMA = { + cv.GenerateID(CONF_LD2450_ID): cv.use_id(LD2450Component), + cv.Optional(CONF_FACTORY_RESET): button.button_schema( + ResetButton, + device_class=DEVICE_CLASS_RESTART, + entity_category=ENTITY_CATEGORY_CONFIG, + icon=ICON_RESTART_ALERT, + ), + cv.Optional(CONF_RESTART): button.button_schema( + RestartButton, + device_class=DEVICE_CLASS_RESTART, + entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + icon=ICON_RESTART, + ), +} + + +async def to_code(config): + ld2450_component = await cg.get_variable(config[CONF_LD2450_ID]) + if factory_reset_config := config.get(CONF_FACTORY_RESET): + b = await button.new_button(factory_reset_config) + await cg.register_parented(b, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_reset_button(b)) + if restart_config := config.get(CONF_RESTART): + b = await button.new_button(restart_config) + await cg.register_parented(b, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_restart_button(b)) diff --git a/esphome/components/ld2450/button/reset_button.cpp b/esphome/components/ld2450/button/reset_button.cpp new file mode 100644 index 0000000000..e96ec99cc5 --- /dev/null +++ b/esphome/components/ld2450/button/reset_button.cpp @@ -0,0 +1,9 @@ +#include "reset_button.h" + +namespace esphome { +namespace ld2450 { + +void ResetButton::press_action() { this->parent_->factory_reset(); } + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/button/reset_button.h b/esphome/components/ld2450/button/reset_button.h new file mode 100644 index 0000000000..73804fa6d6 --- /dev/null +++ b/esphome/components/ld2450/button/reset_button.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/components/button/button.h" +#include "../ld2450.h" + +namespace esphome { +namespace ld2450 { + +class ResetButton : public button::Button, public Parented { + public: + ResetButton() = default; + + protected: + void press_action() override; +}; + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/button/restart_button.cpp b/esphome/components/ld2450/button/restart_button.cpp new file mode 100644 index 0000000000..ee2f5ac12f --- /dev/null +++ b/esphome/components/ld2450/button/restart_button.cpp @@ -0,0 +1,9 @@ +#include "restart_button.h" + +namespace esphome { +namespace ld2450 { + +void RestartButton::press_action() { this->parent_->restart_and_read_all_info(); } + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/button/restart_button.h b/esphome/components/ld2450/button/restart_button.h new file mode 100644 index 0000000000..a44ae5a4d2 --- /dev/null +++ b/esphome/components/ld2450/button/restart_button.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/components/button/button.h" +#include "../ld2450.h" + +namespace esphome { +namespace ld2450 { + +class RestartButton : public button::Button, public Parented { + public: + RestartButton() = default; + + protected: + void press_action() override; +}; + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/ld2450.cpp b/esphome/components/ld2450/ld2450.cpp new file mode 100644 index 0000000000..044ee5ef8b --- /dev/null +++ b/esphome/components/ld2450/ld2450.cpp @@ -0,0 +1,867 @@ +#include "ld2450.h" +#include +#ifdef USE_NUMBER +#include "esphome/components/number/number.h" +#endif +#ifdef USE_SENSOR +#include "esphome/components/sensor/sensor.h" +#endif +#include "esphome/core/component.h" + +#define highbyte(val) (uint8_t)((val) >> 8) +#define lowbyte(val) (uint8_t)((val) &0xff) + +namespace esphome { +namespace ld2450 { + +static const char *const TAG = "ld2450"; +static const char *const UNKNOWN_MAC("unknown"); + +// LD2450 UART Serial Commands +static const uint8_t CMD_ENABLE_CONF = 0x00FF; +static const uint8_t CMD_DISABLE_CONF = 0x00FE; +static const uint8_t CMD_VERSION = 0x00A0; +static const uint8_t CMD_MAC = 0x00A5; +static const uint8_t CMD_RESET = 0x00A2; +static const uint8_t CMD_RESTART = 0x00A3; +static const uint8_t CMD_BLUETOOTH = 0x00A4; +static const uint8_t CMD_SINGLE_TARGET_MODE = 0x0080; +static const uint8_t CMD_MULTI_TARGET_MODE = 0x0090; +static const uint8_t CMD_QUERY_TARGET_MODE = 0x0091; +static const uint8_t CMD_SET_BAUD_RATE = 0x00A1; +static const uint8_t CMD_QUERY_ZONE = 0x00C1; +static const uint8_t CMD_SET_ZONE = 0x00C2; + +static inline uint16_t convert_seconds_to_ms(uint16_t value) { return value * 1000; }; + +static inline std::string convert_signed_int_to_hex(int value) { + auto value_as_str = str_snprintf("%04x", 4, value & 0xFFFF); + return value_as_str; +} + +static inline void convert_int_values_to_hex(const int *values, uint8_t *bytes) { + for (int i = 0; i < 4; i++) { + std::string temp_hex = convert_signed_int_to_hex(values[i]); + bytes[i * 2] = std::stoi(temp_hex.substr(2, 2), nullptr, 16); // Store high byte + bytes[i * 2 + 1] = std::stoi(temp_hex.substr(0, 2), nullptr, 16); // Store low byte + } +} + +static inline int16_t decode_coordinate(uint8_t low_byte, uint8_t high_byte) { + int16_t coordinate = (high_byte & 0x7F) << 8 | low_byte; + if ((high_byte & 0x80) == 0) { + coordinate = -coordinate; + } + return coordinate; // mm +} + +static inline int16_t decode_speed(uint8_t low_byte, uint8_t high_byte) { + int16_t speed = (high_byte & 0x7F) << 8 | low_byte; + if ((high_byte & 0x80) == 0) { + speed = -speed; + } + return speed * 10; // mm/s +} + +static inline int16_t hex_to_signed_int(const uint8_t *buffer, uint8_t offset) { + uint16_t hex_val = (buffer[offset + 1] << 8) | buffer[offset]; + int16_t dec_val = static_cast(hex_val); + if (dec_val & 0x8000) { + dec_val -= 65536; + } + return dec_val; +} + +static inline float calculate_angle(float base, float hypotenuse) { + if (base < 0.0 || hypotenuse <= 0.0) { + return 0.0; + } + float angle_radians = std::acos(base / hypotenuse); + float angle_degrees = angle_radians * (180.0 / M_PI); + return angle_degrees; +} + +static inline std::string get_direction(int16_t speed) { + static const char *const APPROACHING = "Approaching"; + static const char *const MOVING_AWAY = "Moving away"; + static const char *const STATIONARY = "Stationary"; + + if (speed > 0) { + return MOVING_AWAY; + } + if (speed < 0) { + return APPROACHING; + } + return STATIONARY; +} + +static inline std::string format_mac(uint8_t *buffer) { + return str_snprintf("%02X:%02X:%02X:%02X:%02X:%02X", 17, buffer[10], buffer[11], buffer[12], buffer[13], buffer[14], + buffer[15]); +} + +static inline std::string format_version(uint8_t *buffer) { + return str_sprintf("%u.%02X.%02X%02X%02X%02X", buffer[13], buffer[12], buffer[17], buffer[16], buffer[15], + buffer[14]); +} + +LD2450Component::LD2450Component() {} + +void LD2450Component::setup() { + ESP_LOGCONFIG(TAG, "Setting up HLK-LD2450..."); +#ifdef USE_NUMBER + this->pref_ = global_preferences->make_preference(this->presence_timeout_number_->get_object_id_hash()); + this->set_presence_timeout(); +#endif + this->read_all_info(); +} + +void LD2450Component::dump_config() { + ESP_LOGCONFIG(TAG, "HLK-LD2450 Human motion tracking radar module:"); +#ifdef USE_BINARY_SENSOR + LOG_BINARY_SENSOR(" ", "TargetBinarySensor", this->target_binary_sensor_); + LOG_BINARY_SENSOR(" ", "MovingTargetBinarySensor", this->moving_target_binary_sensor_); + LOG_BINARY_SENSOR(" ", "StillTargetBinarySensor", this->still_target_binary_sensor_); +#endif +#ifdef USE_SWITCH + LOG_SWITCH(" ", "BluetoothSwitch", this->bluetooth_switch_); + LOG_SWITCH(" ", "MultiTargetSwitch", this->multi_target_switch_); +#endif +#ifdef USE_BUTTON + LOG_BUTTON(" ", "ResetButton", this->reset_button_); + LOG_BUTTON(" ", "RestartButton", this->restart_button_); +#endif +#ifdef USE_SENSOR + LOG_SENSOR(" ", "TargetCountSensor", this->target_count_sensor_); + LOG_SENSOR(" ", "StillTargetCountSensor", this->still_target_count_sensor_); + LOG_SENSOR(" ", "MovingTargetCountSensor", this->moving_target_count_sensor_); + for (sensor::Sensor *s : this->move_x_sensors_) { + LOG_SENSOR(" ", "NthTargetXSensor", s); + } + for (sensor::Sensor *s : this->move_y_sensors_) { + LOG_SENSOR(" ", "NthTargetYSensor", s); + } + for (sensor::Sensor *s : this->move_speed_sensors_) { + LOG_SENSOR(" ", "NthTargetSpeedSensor", s); + } + for (sensor::Sensor *s : this->move_angle_sensors_) { + LOG_SENSOR(" ", "NthTargetAngleSensor", s); + } + for (sensor::Sensor *s : this->move_distance_sensors_) { + LOG_SENSOR(" ", "NthTargetDistanceSensor", s); + } + for (sensor::Sensor *s : this->move_resolution_sensors_) { + LOG_SENSOR(" ", "NthTargetResolutionSensor", s); + } + for (sensor::Sensor *s : this->zone_target_count_sensors_) { + LOG_SENSOR(" ", "NthZoneTargetCountSensor", s); + } + for (sensor::Sensor *s : this->zone_still_target_count_sensors_) { + LOG_SENSOR(" ", "NthZoneStillTargetCountSensor", s); + } + for (sensor::Sensor *s : this->zone_moving_target_count_sensors_) { + LOG_SENSOR(" ", "NthZoneMovingTargetCountSensor", s); + } +#endif +#ifdef USE_TEXT_SENSOR + LOG_TEXT_SENSOR(" ", "VersionTextSensor", this->version_text_sensor_); + LOG_TEXT_SENSOR(" ", "MacTextSensor", this->mac_text_sensor_); + for (text_sensor::TextSensor *s : this->direction_text_sensors_) { + LOG_TEXT_SENSOR(" ", "NthDirectionTextSensor", s); + } +#endif +#ifdef USE_NUMBER + for (number::Number *n : this->zone_x1_numbers_) { + LOG_NUMBER(" ", "ZoneX1Number", n); + } + for (number::Number *n : this->zone_y1_numbers_) { + LOG_NUMBER(" ", "ZoneY1Number", n); + } + for (number::Number *n : this->zone_x2_numbers_) { + LOG_NUMBER(" ", "ZoneX2Number", n); + } + for (number::Number *n : this->zone_y2_numbers_) { + LOG_NUMBER(" ", "ZoneY2Number", n); + } +#endif +#ifdef USE_SELECT + LOG_SELECT(" ", "BaudRateSelect", this->baud_rate_select_); + LOG_SELECT(" ", "ZoneTypeSelect", this->zone_type_select_); +#endif +#ifdef USE_NUMBER + LOG_NUMBER(" ", "PresenceTimeoutNumber", this->presence_timeout_number_); +#endif + ESP_LOGCONFIG(TAG, " Throttle : %ums", this->throttle_); + ESP_LOGCONFIG(TAG, " MAC Address : %s", const_cast(this->mac_.c_str())); + ESP_LOGCONFIG(TAG, " Firmware version : %s", const_cast(this->version_.c_str())); +} + +void LD2450Component::loop() { + while (this->available()) { + this->readline_(read(), this->buffer_data_, MAX_LINE_LENGTH); + } +} + +// Count targets in zone +uint8_t LD2450Component::count_targets_in_zone_(const Zone &zone, bool is_moving) { + uint8_t count = 0; + for (auto &index : this->target_info_) { + if (index.x > zone.x1 && index.x < zone.x2 && index.y > zone.y1 && index.y < zone.y2 && + index.is_moving == is_moving) { + count++; + } + } + return count; +} + +// Service reset_radar_zone +void LD2450Component::reset_radar_zone() { + this->zone_type_ = 0; + for (auto &i : this->zone_config_) { + i.x1 = 0; + i.y1 = 0; + i.x2 = 0; + i.y2 = 0; + } + this->send_set_zone_command_(); +} + +void LD2450Component::set_radar_zone(int32_t zone_type, int32_t zone1_x1, int32_t zone1_y1, int32_t zone1_x2, + int32_t zone1_y2, int32_t zone2_x1, int32_t zone2_y1, int32_t zone2_x2, + int32_t zone2_y2, int32_t zone3_x1, int32_t zone3_y1, int32_t zone3_x2, + int32_t zone3_y2) { + this->zone_type_ = zone_type; + int zone_parameters[12] = {zone1_x1, zone1_y1, zone1_x2, zone1_y2, zone2_x1, zone2_y1, + zone2_x2, zone2_y2, zone3_x1, zone3_y1, zone3_x2, zone3_y2}; + for (int i = 0; i < MAX_ZONES; i++) { + this->zone_config_[i].x1 = zone_parameters[i * 4]; + this->zone_config_[i].y1 = zone_parameters[i * 4 + 1]; + this->zone_config_[i].x2 = zone_parameters[i * 4 + 2]; + this->zone_config_[i].y2 = zone_parameters[i * 4 + 3]; + } + this->send_set_zone_command_(); +} + +// Set Zone on LD2450 Sensor +void LD2450Component::send_set_zone_command_() { + uint8_t cmd_value[26] = {}; + uint8_t zone_type_bytes[2] = {static_cast(this->zone_type_), 0x00}; + uint8_t area_config[24] = {}; + for (int i = 0; i < MAX_ZONES; i++) { + int values[4] = {this->zone_config_[i].x1, this->zone_config_[i].y1, this->zone_config_[i].x2, + this->zone_config_[i].y2}; + ld2450::convert_int_values_to_hex(values, area_config + (i * 8)); + } + std::memcpy(cmd_value, zone_type_bytes, 2); + std::memcpy(cmd_value + 2, area_config, 24); + this->set_config_mode_(true); + this->send_command_(CMD_SET_ZONE, cmd_value, 26); + this->set_config_mode_(false); +} + +// Check presense timeout to reset presence status +bool LD2450Component::get_timeout_status_(uint32_t check_millis) { + if (check_millis == 0) { + return true; + } + if (this->timeout_ == 0) { + this->timeout_ = ld2450::convert_seconds_to_ms(DEFAULT_PRESENCE_TIMEOUT); + } + auto current_millis = millis(); + return current_millis - check_millis >= this->timeout_; +} + +// Extract, store and publish zone details LD2450 buffer +void LD2450Component::process_zone_(uint8_t *buffer) { + uint8_t index, start; + for (index = 0; index < MAX_ZONES; index++) { + start = 12 + index * 8; + this->zone_config_[index].x1 = ld2450::hex_to_signed_int(buffer, start); + this->zone_config_[index].y1 = ld2450::hex_to_signed_int(buffer, start + 2); + this->zone_config_[index].x2 = ld2450::hex_to_signed_int(buffer, start + 4); + this->zone_config_[index].y2 = ld2450::hex_to_signed_int(buffer, start + 6); +#ifdef USE_NUMBER + this->zone_x1_numbers_[index]->publish_state(this->zone_config_[index].x1); + this->zone_y1_numbers_[index]->publish_state(this->zone_config_[index].y1); + this->zone_x2_numbers_[index]->publish_state(this->zone_config_[index].x2); + this->zone_y2_numbers_[index]->publish_state(this->zone_config_[index].y2); +#endif + } +} + +// Read all info from LD2450 buffer +void LD2450Component::read_all_info() { + this->set_config_mode_(true); + this->get_version_(); + this->get_mac_(); + this->query_target_tracking_mode_(); + this->query_zone_(); + this->set_config_mode_(false); +#ifdef USE_SELECT + const auto baud_rate = std::to_string(this->parent_->get_baud_rate()); + if (this->baud_rate_select_ != nullptr && this->baud_rate_select_->state != baud_rate) { + this->baud_rate_select_->publish_state(baud_rate); + } + this->publish_zone_type(); +#endif +} + +// Read zone info from LD2450 buffer +void LD2450Component::query_zone_info() { + this->set_config_mode_(true); + this->query_zone_(); + this->set_config_mode_(false); +} + +// Restart LD2450 and read all info from buffer +void LD2450Component::restart_and_read_all_info() { + this->set_config_mode_(true); + this->restart_(); + this->set_timeout(1000, [this]() { this->read_all_info(); }); +} + +// Send command with values to LD2450 +void LD2450Component::send_command_(uint8_t command, const uint8_t *command_value, uint8_t command_value_len) { + ESP_LOGV(TAG, "Sending command %02X", command); + // frame header + this->write_array(CMD_FRAME_HEADER, 4); + // length bytes + int len = 2; + if (command_value != nullptr) { + len += command_value_len; + } + this->write_byte(lowbyte(len)); + this->write_byte(highbyte(len)); + // command + this->write_byte(lowbyte(command)); + this->write_byte(highbyte(command)); + // command value bytes + if (command_value != nullptr) { + for (int i = 0; i < command_value_len; i++) { + this->write_byte(command_value[i]); + } + } + // footer + this->write_array(CMD_FRAME_END, 4); + // FIXME to remove + delay(50); // NOLINT +} + +// LD2450 Radar data message: +// [AA FF 03 00] [0E 03 B1 86 10 00 40 01] [00 00 00 00 00 00 00 00] [00 00 00 00 00 00 00 00] [55 CC] +// Header Target 1 Target 2 Target 3 End +void LD2450Component::handle_periodic_data_(uint8_t *buffer, uint8_t len) { + if (len < 29) { // header (4 bytes) + 8 x 3 target data + footer (2 bytes) + ESP_LOGE(TAG, "Periodic data: invalid message length"); + return; + } + if (buffer[0] != 0xAA || buffer[1] != 0xFF || buffer[2] != 0x03 || buffer[3] != 0x00) { // header + ESP_LOGE(TAG, "Periodic data: invalid message header"); + return; + } + if (buffer[len - 2] != 0x55 || buffer[len - 1] != 0xCC) { // footer + ESP_LOGE(TAG, "Periodic data: invalid message footer"); + return; + } + + auto current_millis = millis(); + if (current_millis - this->last_periodic_millis_ < this->throttle_) { + ESP_LOGV(TAG, "Throttling: %d", this->throttle_); + return; + } + + this->last_periodic_millis_ = current_millis; + + int16_t target_count = 0; + int16_t still_target_count = 0; + int16_t moving_target_count = 0; + int16_t start = 0; + int16_t val = 0; + uint8_t index = 0; + int16_t tx = 0; + int16_t ty = 0; + int16_t td = 0; + int16_t ts = 0; + int16_t angle = 0; + std::string direction{}; + bool is_moving = false; + +#ifdef USE_SENSOR + // Loop thru targets + // X + for (index = 0; index < MAX_TARGETS; index++) { + start = TARGET_X + index * 8; + is_moving = false; + sensor::Sensor *sx = this->move_x_sensors_[index]; + if (sx != nullptr) { + val = ld2450::decode_coordinate(buffer[start], buffer[start + 1]); + tx = val; + sx->publish_state(val); + } + // Y + start = TARGET_Y + index * 8; + sensor::Sensor *sy = this->move_y_sensors_[index]; + if (sy != nullptr) { + val = ld2450::decode_coordinate(buffer[start], buffer[start + 1]); + ty = val; + sy->publish_state(val); + } + // SPEED + start = TARGET_SPEED + index * 8; + sensor::Sensor *ss = this->move_speed_sensors_[index]; + if (ss != nullptr) { + val = ld2450::decode_speed(buffer[start], buffer[start + 1]); + ts = val; + if (val) { + is_moving = true; + moving_target_count++; + } + ss->publish_state(val); + } + // RESOLUTION + start = TARGET_RESOLUTION + index * 8; + sensor::Sensor *sr = this->move_resolution_sensors_[index]; + if (sr != nullptr) { + val = (buffer[start + 1] << 8) | buffer[start]; + sr->publish_state(val); + } + // DISTANCE + sensor::Sensor *sd = this->move_distance_sensors_[index]; + if (sd != nullptr) { + val = (uint16_t) sqrt( + pow(ld2450::decode_coordinate(buffer[TARGET_X + index * 8], buffer[(TARGET_X + index * 8) + 1]), 2) + + pow(ld2450::decode_coordinate(buffer[TARGET_Y + index * 8], buffer[(TARGET_Y + index * 8) + 1]), 2)); + td = val; + if (val > 0) { + target_count++; + } + + sd->publish_state(val); + } + // ANGLE + angle = calculate_angle(static_cast(ty), static_cast(td)); + if (tx > 0) { + angle = angle * -1; + } + sensor::Sensor *sa = this->move_angle_sensors_[index]; + if (sa != nullptr) { + sa->publish_state(angle); + } +#endif + // DIRECTION +#ifdef USE_TEXT_SENSOR + direction = get_direction(ts); + if (td == 0) { + direction = "NA"; + } + text_sensor::TextSensor *tsd = this->direction_text_sensors_[index]; + if (tsd != nullptr) { + tsd->publish_state(direction); + } +#endif + + // Store target info for zone target count + this->target_info_[index].x = tx; + this->target_info_[index].y = ty; + this->target_info_[index].is_moving = is_moving; + + } // End loop thru targets + +#ifdef USE_SENSOR + // Loop thru zones + uint8_t zone_still_targets = 0; + uint8_t zone_moving_targets = 0; + uint8_t zone_all_targets = 0; + for (index = 0; index < MAX_ZONES; index++) { + // Publish Still Target Count in Zones + sensor::Sensor *szstc = this->zone_still_target_count_sensors_[index]; + if (szstc != nullptr) { + zone_still_targets = this->count_targets_in_zone_(this->zone_config_[index], false); + szstc->publish_state(zone_still_targets); + } + // Publish Moving Target Count in Zones + sensor::Sensor *szmtc = this->zone_moving_target_count_sensors_[index]; + if (szmtc != nullptr) { + zone_moving_targets = this->count_targets_in_zone_(this->zone_config_[index], true); + szmtc->publish_state(zone_moving_targets); + } + + zone_all_targets = zone_still_targets + zone_moving_targets; + + // Publish All Target Count in Zones + sensor::Sensor *sztc = this->zone_target_count_sensors_[index]; + if (sztc != nullptr) { + sztc->publish_state(zone_all_targets); + } + + } // End loop thru zones + + still_target_count = target_count - moving_target_count; + // Target Count + if (this->target_count_sensor_ != nullptr) { + this->target_count_sensor_->publish_state(target_count); + } + // Still Target Count + if (this->still_target_count_sensor_ != nullptr) { + this->still_target_count_sensor_->publish_state(still_target_count); + } + // Moving Target Count + if (this->moving_target_count_sensor_ != nullptr) { + this->moving_target_count_sensor_->publish_state(moving_target_count); + } +#endif + +#ifdef USE_BINARY_SENSOR + // Target Presence + if (this->target_binary_sensor_ != nullptr) { + if (target_count > 0) { + this->target_binary_sensor_->publish_state(true); + } else { + if (this->get_timeout_status_(this->presence_millis_)) { + this->target_binary_sensor_->publish_state(false); + } else { + ESP_LOGV(TAG, "Clear presence waiting timeout: %d", this->timeout_); + } + } + } + // Moving Target Presence + if (this->moving_target_binary_sensor_ != nullptr) { + if (moving_target_count > 0) { + this->moving_target_binary_sensor_->publish_state(true); + } else { + if (this->get_timeout_status_(this->moving_presence_millis_)) { + this->moving_target_binary_sensor_->publish_state(false); + } + } + } + // Still Target Presence + if (this->still_target_binary_sensor_ != nullptr) { + if (still_target_count > 0) { + this->still_target_binary_sensor_->publish_state(true); + } else { + if (this->get_timeout_status_(this->still_presence_millis_)) { + this->still_target_binary_sensor_->publish_state(false); + } + } + } +#endif +#ifdef USE_SENSOR + // For presence timeout check + if (target_count > 0) { + this->presence_millis_ = millis(); + } + if (moving_target_count > 0) { + this->moving_presence_millis_ = millis(); + } + if (still_target_count > 0) { + this->still_presence_millis_ = millis(); + } +#endif +} + +bool LD2450Component::handle_ack_data_(uint8_t *buffer, uint8_t len) { + ESP_LOGV(TAG, "Handling ack data for command %02X", buffer[COMMAND]); + if (len < 10) { + ESP_LOGE(TAG, "Ack data: invalid length"); + return true; + } + if (buffer[0] != 0xFD || buffer[1] != 0xFC || buffer[2] != 0xFB || buffer[3] != 0xFA) { // frame header + ESP_LOGE(TAG, "Ack data: invalid header (command %02X)", buffer[COMMAND]); + return true; + } + if (buffer[COMMAND_STATUS] != 0x01) { + ESP_LOGE(TAG, "Ack data: invalid status"); + return true; + } + if (buffer[8] || buffer[9]) { + ESP_LOGE(TAG, "Ack data: last buffer was %u, %u", buffer[8], buffer[9]); + return true; + } + + switch (buffer[COMMAND]) { + case lowbyte(CMD_ENABLE_CONF): + ESP_LOGV(TAG, "Got enable conf command"); + break; + case lowbyte(CMD_DISABLE_CONF): + ESP_LOGV(TAG, "Got disable conf command"); + break; + case lowbyte(CMD_SET_BAUD_RATE): + ESP_LOGV(TAG, "Got baud rate change command"); +#ifdef USE_SELECT + if (this->baud_rate_select_ != nullptr) { + ESP_LOGV(TAG, "Change baud rate to %s", this->baud_rate_select_->state.c_str()); + } +#endif + break; + case lowbyte(CMD_VERSION): + this->version_ = ld2450::format_version(buffer); + ESP_LOGV(TAG, "Firmware version: %s", this->version_.c_str()); +#ifdef USE_TEXT_SENSOR + if (this->version_text_sensor_ != nullptr) { + this->version_text_sensor_->publish_state(this->version_); + } +#endif + break; + case lowbyte(CMD_MAC): + if (len < 20) { + return false; + } + this->mac_ = ld2450::format_mac(buffer); + ESP_LOGV(TAG, "MAC address: %s", this->mac_.c_str()); +#ifdef USE_TEXT_SENSOR + if (this->mac_text_sensor_ != nullptr) { + this->mac_text_sensor_->publish_state(this->mac_); + } +#endif +#ifdef USE_SWITCH + if (this->bluetooth_switch_ != nullptr) { + this->bluetooth_switch_->publish_state(this->mac_ != UNKNOWN_MAC); + } +#endif + break; + case lowbyte(CMD_BLUETOOTH): + ESP_LOGV(TAG, "Got Bluetooth command"); + break; + case lowbyte(CMD_SINGLE_TARGET_MODE): + ESP_LOGV(TAG, "Got single target conf command"); +#ifdef USE_SWITCH + if (this->multi_target_switch_ != nullptr) { + this->multi_target_switch_->publish_state(false); + } +#endif + break; + case lowbyte(CMD_MULTI_TARGET_MODE): + ESP_LOGV(TAG, "Got multi target conf command"); +#ifdef USE_SWITCH + if (this->multi_target_switch_ != nullptr) { + this->multi_target_switch_->publish_state(true); + } +#endif + break; + case lowbyte(CMD_QUERY_TARGET_MODE): + ESP_LOGV(TAG, "Got query target tracking mode command"); +#ifdef USE_SWITCH + if (this->multi_target_switch_ != nullptr) { + this->multi_target_switch_->publish_state(buffer[10] == 0x02); + } +#endif + break; + case lowbyte(CMD_QUERY_ZONE): + ESP_LOGV(TAG, "Got query zone conf command"); + this->zone_type_ = std::stoi(std::to_string(buffer[10]), nullptr, 16); + this->publish_zone_type(); +#ifdef USE_SELECT + if (this->zone_type_select_ != nullptr) { + ESP_LOGV(TAG, "Change zone type to: %s", this->zone_type_select_->state.c_str()); + } +#endif + if (buffer[10] == 0x00) { + ESP_LOGV(TAG, "Zone: Disabled"); + } + if (buffer[10] == 0x01) { + ESP_LOGV(TAG, "Zone: Area detection"); + } + if (buffer[10] == 0x02) { + ESP_LOGV(TAG, "Zone: Area filter"); + } + this->process_zone_(buffer); + break; + case lowbyte(CMD_SET_ZONE): + ESP_LOGV(TAG, "Got set zone conf command"); + this->query_zone_info(); + break; + default: + break; + } + return true; +} + +// Read LD2450 buffer data +void LD2450Component::readline_(int readch, uint8_t *buffer, uint8_t len) { + if (readch < 0) { + return; + } + if (this->buffer_pos_ < len - 1) { + buffer[this->buffer_pos_++] = readch; + buffer[this->buffer_pos_] = 0; + } else { + this->buffer_pos_ = 0; + } + if (this->buffer_pos_ < 4) { + return; + } + if (buffer[this->buffer_pos_ - 2] == 0x55 && buffer[this->buffer_pos_ - 1] == 0xCC) { + ESP_LOGV(TAG, "Handle periodic radar data"); + this->handle_periodic_data_(buffer, this->buffer_pos_); + this->buffer_pos_ = 0; // Reset position index for next frame + } else if (buffer[this->buffer_pos_ - 4] == 0x04 && buffer[this->buffer_pos_ - 3] == 0x03 && + buffer[this->buffer_pos_ - 2] == 0x02 && buffer[this->buffer_pos_ - 1] == 0x01) { + ESP_LOGV(TAG, "Handle command ack data"); + if (this->handle_ack_data_(buffer, this->buffer_pos_)) { + this->buffer_pos_ = 0; // Reset position index for next frame + } else { + ESP_LOGV(TAG, "Command ack data invalid"); + } + } +} + +// Set Config Mode - Pre-requisite sending commands +void LD2450Component::set_config_mode_(bool enable) { + uint8_t cmd = enable ? CMD_ENABLE_CONF : CMD_DISABLE_CONF; + uint8_t cmd_value[2] = {0x01, 0x00}; + this->send_command_(cmd, enable ? cmd_value : nullptr, 2); +} + +// Set Bluetooth Enable/Disable +void LD2450Component::set_bluetooth(bool enable) { + this->set_config_mode_(true); + uint8_t enable_cmd_value[2] = {0x01, 0x00}; + uint8_t disable_cmd_value[2] = {0x00, 0x00}; + this->send_command_(CMD_BLUETOOTH, enable ? enable_cmd_value : disable_cmd_value, 2); + this->set_timeout(200, [this]() { this->restart_and_read_all_info(); }); +} + +// Set Baud rate +void LD2450Component::set_baud_rate(const std::string &state) { + this->set_config_mode_(true); + uint8_t cmd_value[2] = {BAUD_RATE_ENUM_TO_INT.at(state), 0x00}; + this->send_command_(CMD_SET_BAUD_RATE, cmd_value, 2); + this->set_timeout(200, [this]() { this->restart_(); }); +} + +// Set Zone Type - one of: Disabled, Detection, Filter +void LD2450Component::set_zone_type(const std::string &state) { + ESP_LOGV(TAG, "Set zone type: %s", state.c_str()); + uint8_t zone_type = ZONE_TYPE_ENUM_TO_INT.at(state); + this->zone_type_ = zone_type; + this->send_set_zone_command_(); +} + +// Publish Zone Type to Select component +void LD2450Component::publish_zone_type() { +#ifdef USE_SELECT + std::string zone_type = ZONE_TYPE_INT_TO_ENUM.at(static_cast(this->zone_type_)); + if (this->zone_type_select_ != nullptr) { + this->zone_type_select_->publish_state(zone_type); + } +#endif +} + +// Set Single/Multiplayer target detection +void LD2450Component::set_multi_target(bool enable) { + this->set_config_mode_(true); + uint8_t cmd = enable ? CMD_MULTI_TARGET_MODE : CMD_SINGLE_TARGET_MODE; + this->send_command_(cmd, nullptr, 0); + this->set_config_mode_(false); +} + +// LD2450 factory reset +void LD2450Component::factory_reset() { + this->set_config_mode_(true); + this->send_command_(CMD_RESET, nullptr, 0); + this->set_timeout(200, [this]() { this->restart_and_read_all_info(); }); +} + +// Restart LD2450 module +void LD2450Component::restart_() { this->send_command_(CMD_RESTART, nullptr, 0); } + +// Get LD2450 firmware version +void LD2450Component::get_version_() { this->send_command_(CMD_VERSION, nullptr, 0); } + +// Get LD2450 mac address +void LD2450Component::get_mac_() { + uint8_t cmd_value[2] = {0x01, 0x00}; + this->send_command_(CMD_MAC, cmd_value, 2); +} + +// Query for target tracking mode +void LD2450Component::query_target_tracking_mode_() { this->send_command_(CMD_QUERY_TARGET_MODE, nullptr, 0); } + +// Query for zone info +void LD2450Component::query_zone_() { this->send_command_(CMD_QUERY_ZONE, nullptr, 0); } + +#ifdef USE_SENSOR +void LD2450Component::set_move_x_sensor(uint8_t target, sensor::Sensor *s) { this->move_x_sensors_[target] = s; } +void LD2450Component::set_move_y_sensor(uint8_t target, sensor::Sensor *s) { this->move_y_sensors_[target] = s; } +void LD2450Component::set_move_speed_sensor(uint8_t target, sensor::Sensor *s) { + this->move_speed_sensors_[target] = s; +} +void LD2450Component::set_move_angle_sensor(uint8_t target, sensor::Sensor *s) { + this->move_angle_sensors_[target] = s; +} +void LD2450Component::set_move_distance_sensor(uint8_t target, sensor::Sensor *s) { + this->move_distance_sensors_[target] = s; +} +void LD2450Component::set_move_resolution_sensor(uint8_t target, sensor::Sensor *s) { + this->move_resolution_sensors_[target] = s; +} +void LD2450Component::set_zone_target_count_sensor(uint8_t zone, sensor::Sensor *s) { + this->zone_target_count_sensors_[zone] = s; +} +void LD2450Component::set_zone_still_target_count_sensor(uint8_t zone, sensor::Sensor *s) { + this->zone_still_target_count_sensors_[zone] = s; +} +void LD2450Component::set_zone_moving_target_count_sensor(uint8_t zone, sensor::Sensor *s) { + this->zone_moving_target_count_sensors_[zone] = s; +} +#endif +#ifdef USE_TEXT_SENSOR +void LD2450Component::set_direction_text_sensor(uint8_t target, text_sensor::TextSensor *s) { + this->direction_text_sensors_[target] = s; +} +#endif + +// Send Zone coordinates data to LD2450 +#ifdef USE_NUMBER +void LD2450Component::set_zone_coordinate(uint8_t zone) { + number::Number *x1sens = this->zone_x1_numbers_[zone]; + number::Number *y1sens = this->zone_y1_numbers_[zone]; + number::Number *x2sens = this->zone_x2_numbers_[zone]; + number::Number *y2sens = this->zone_y2_numbers_[zone]; + if (!x1sens->has_state() || !y1sens->has_state() || !x2sens->has_state() || !y2sens->has_state()) { + return; + } + this->zone_config_[zone].x1 = static_cast(x1sens->state); + this->zone_config_[zone].y1 = static_cast(y1sens->state); + this->zone_config_[zone].x2 = static_cast(x2sens->state); + this->zone_config_[zone].y2 = static_cast(y2sens->state); + this->send_set_zone_command_(); +} + +void LD2450Component::set_zone_x1_number(uint8_t zone, number::Number *n) { this->zone_x1_numbers_[zone] = n; } +void LD2450Component::set_zone_y1_number(uint8_t zone, number::Number *n) { this->zone_y1_numbers_[zone] = n; } +void LD2450Component::set_zone_x2_number(uint8_t zone, number::Number *n) { this->zone_x2_numbers_[zone] = n; } +void LD2450Component::set_zone_y2_number(uint8_t zone, number::Number *n) { this->zone_y2_numbers_[zone] = n; } +#endif + +// Set Presence Timeout load and save from flash +#ifdef USE_NUMBER +void LD2450Component::set_presence_timeout() { + if (this->presence_timeout_number_ != nullptr) { + if (this->presence_timeout_number_->state == 0) { + float timeout = this->restore_from_flash_(); + this->presence_timeout_number_->publish_state(timeout); + this->timeout_ = ld2450::convert_seconds_to_ms(timeout); + } + if (this->presence_timeout_number_->has_state()) { + this->save_to_flash_(this->presence_timeout_number_->state); + this->timeout_ = ld2450::convert_seconds_to_ms(this->presence_timeout_number_->state); + } + } +} + +// Save Presence Timeout to flash +void LD2450Component::save_to_flash_(float value) { this->pref_.save(&value); } + +// Load Presence Timeout from flash +float LD2450Component::restore_from_flash_() { + float value; + if (!this->pref_.load(&value)) { + value = DEFAULT_PRESENCE_TIMEOUT; + } + return value; +} +#endif + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/ld2450.h b/esphome/components/ld2450/ld2450.h new file mode 100644 index 0000000000..2fed7dc0c9 --- /dev/null +++ b/esphome/components/ld2450/ld2450.h @@ -0,0 +1,231 @@ +#pragma once + +#include +#include +#include "esphome/components/uart/uart.h" +#include "esphome/core/component.h" +#include "esphome/core/defines.h" +#include "esphome/core/helpers.h" +#include "esphome/core/preferences.h" +#ifdef USE_SENSOR +#include "esphome/components/sensor/sensor.h" +#endif +#ifdef USE_NUMBER +#include "esphome/components/number/number.h" +#endif +#ifdef USE_SWITCH +#include "esphome/components/switch/switch.h" +#endif +#ifdef USE_BUTTON +#include "esphome/components/button/button.h" +#endif +#ifdef USE_SELECT +#include "esphome/components/select/select.h" +#endif +#ifdef USE_TEXT_SENSOR +#include "esphome/components/text_sensor/text_sensor.h" +#endif +#ifdef USE_BINARY_SENSOR +#include "esphome/components/binary_sensor/binary_sensor.h" +#endif + +#ifndef M_PI +#define M_PI 3.14 +#endif + +namespace esphome { +namespace ld2450 { + +// Constants +static const uint8_t DEFAULT_PRESENCE_TIMEOUT = 5; // Timeout to reset presense status 5 sec. +static const uint8_t MAX_LINE_LENGTH = 60; // Max characters for serial buffer +static const uint8_t MAX_TARGETS = 3; // Max 3 Targets in LD2450 +static const uint8_t MAX_ZONES = 3; // Max 3 Zones in LD2450 + +// Target coordinate struct +struct Target { + int16_t x; + int16_t y; + bool is_moving; +}; + +// Zone coordinate struct +struct Zone { + int16_t x1 = 0; + int16_t y1 = 0; + int16_t x2 = 0; + int16_t y2 = 0; +}; + +enum BaudRateStructure : uint8_t { + BAUD_RATE_9600 = 1, + BAUD_RATE_19200 = 2, + BAUD_RATE_38400 = 3, + BAUD_RATE_57600 = 4, + BAUD_RATE_115200 = 5, + BAUD_RATE_230400 = 6, + BAUD_RATE_256000 = 7, + BAUD_RATE_460800 = 8 +}; + +// Convert baud rate enum to int +static const std::map BAUD_RATE_ENUM_TO_INT{ + {"9600", BAUD_RATE_9600}, {"19200", BAUD_RATE_19200}, {"38400", BAUD_RATE_38400}, + {"57600", BAUD_RATE_57600}, {"115200", BAUD_RATE_115200}, {"230400", BAUD_RATE_230400}, + {"256000", BAUD_RATE_256000}, {"460800", BAUD_RATE_460800}}; + +// Zone type struct +enum ZoneTypeStructure : uint8_t { ZONE_DISABLED = 0, ZONE_DETECTION = 1, ZONE_FILTER = 2 }; + +// Convert zone type int to enum +static const std::map ZONE_TYPE_INT_TO_ENUM{ + {ZONE_DISABLED, "Disabled"}, {ZONE_DETECTION, "Detection"}, {ZONE_FILTER, "Filter"}}; + +// Convert zone type enum to int +static const std::map ZONE_TYPE_ENUM_TO_INT{ + {"Disabled", ZONE_DISABLED}, {"Detection", ZONE_DETECTION}, {"Filter", ZONE_FILTER}}; + +// LD2450 serial command header & footer +static const uint8_t CMD_FRAME_HEADER[4] = {0xFD, 0xFC, 0xFB, 0xFA}; +static const uint8_t CMD_FRAME_END[4] = {0x04, 0x03, 0x02, 0x01}; + +enum PeriodicDataStructure : uint8_t { + TARGET_X = 4, + TARGET_Y = 6, + TARGET_SPEED = 8, + TARGET_RESOLUTION = 10, +}; + +enum PeriodicDataValue : uint8_t { HEAD = 0XAA, END = 0x55, CHECK = 0x00 }; + +enum AckDataStructure : uint8_t { COMMAND = 6, COMMAND_STATUS = 7 }; + +class LD2450Component : public Component, public uart::UARTDevice { +#ifdef USE_SENSOR + SUB_SENSOR(target_count) + SUB_SENSOR(still_target_count) + SUB_SENSOR(moving_target_count) +#endif +#ifdef USE_BINARY_SENSOR + SUB_BINARY_SENSOR(target) + SUB_BINARY_SENSOR(moving_target) + SUB_BINARY_SENSOR(still_target) +#endif +#ifdef USE_TEXT_SENSOR + SUB_TEXT_SENSOR(version) + SUB_TEXT_SENSOR(mac) +#endif +#ifdef USE_SELECT + SUB_SELECT(baud_rate) + SUB_SELECT(zone_type) +#endif +#ifdef USE_SWITCH + SUB_SWITCH(bluetooth) + SUB_SWITCH(multi_target) +#endif +#ifdef USE_BUTTON + SUB_BUTTON(reset) + SUB_BUTTON(restart) +#endif +#ifdef USE_NUMBER + SUB_NUMBER(presence_timeout) +#endif + + public: + LD2450Component(); + void setup() override; + void dump_config() override; + void loop() override; + void set_presence_timeout(); + void set_throttle(uint16_t value) { this->throttle_ = value; }; + void read_all_info(); + void query_zone_info(); + void restart_and_read_all_info(); + void set_bluetooth(bool enable); + void set_multi_target(bool enable); + void set_baud_rate(const std::string &state); + void set_zone_type(const std::string &state); + void publish_zone_type(); + void factory_reset(); +#ifdef USE_TEXT_SENSOR + void set_direction_text_sensor(uint8_t target, text_sensor::TextSensor *s); +#endif +#ifdef USE_NUMBER + void set_zone_coordinate(uint8_t zone); + void set_zone_x1_number(uint8_t zone, number::Number *n); + void set_zone_y1_number(uint8_t zone, number::Number *n); + void set_zone_x2_number(uint8_t zone, number::Number *n); + void set_zone_y2_number(uint8_t zone, number::Number *n); +#endif +#ifdef USE_SENSOR + void set_move_x_sensor(uint8_t target, sensor::Sensor *s); + void set_move_y_sensor(uint8_t target, sensor::Sensor *s); + void set_move_speed_sensor(uint8_t target, sensor::Sensor *s); + void set_move_angle_sensor(uint8_t target, sensor::Sensor *s); + void set_move_distance_sensor(uint8_t target, sensor::Sensor *s); + void set_move_resolution_sensor(uint8_t target, sensor::Sensor *s); + void set_zone_target_count_sensor(uint8_t zone, sensor::Sensor *s); + void set_zone_still_target_count_sensor(uint8_t zone, sensor::Sensor *s); + void set_zone_moving_target_count_sensor(uint8_t zone, sensor::Sensor *s); +#endif + void reset_radar_zone(); + void set_radar_zone(int32_t zone_type, int32_t zone1_x1, int32_t zone1_y1, int32_t zone1_x2, int32_t zone1_y2, + int32_t zone2_x1, int32_t zone2_y1, int32_t zone2_x2, int32_t zone2_y2, int32_t zone3_x1, + int32_t zone3_y1, int32_t zone3_x2, int32_t zone3_y2); + + protected: + void send_command_(uint8_t command_str, const uint8_t *command_value, uint8_t command_value_len); + void set_config_mode_(bool enable); + void handle_periodic_data_(uint8_t *buffer, uint8_t len); + bool handle_ack_data_(uint8_t *buffer, uint8_t len); + void process_zone_(uint8_t *buffer); + void readline_(int readch, uint8_t *buffer, uint8_t len); + void get_version_(); + void get_mac_(); + void query_target_tracking_mode_(); + void query_zone_(); + void restart_(); + void send_set_zone_command_(); + void save_to_flash_(float value); + float restore_from_flash_(); + bool get_timeout_status_(uint32_t check_millis); + uint8_t count_targets_in_zone_(const Zone &zone, bool is_moving); + + Target target_info_[MAX_TARGETS]; + Zone zone_config_[MAX_ZONES]; + uint8_t buffer_pos_ = 0; // where to resume processing/populating buffer + uint8_t buffer_data_[MAX_LINE_LENGTH]; + uint32_t last_periodic_millis_ = 0; + uint32_t presence_millis_ = 0; + uint32_t still_presence_millis_ = 0; + uint32_t moving_presence_millis_ = 0; + uint16_t throttle_ = 0; + uint16_t timeout_ = 5; + uint8_t zone_type_ = 0; + std::string version_{}; + std::string mac_{}; +#ifdef USE_NUMBER + ESPPreferenceObject pref_; // only used when numbers are in use + std::vector zone_x1_numbers_ = std::vector(MAX_ZONES); + std::vector zone_y1_numbers_ = std::vector(MAX_ZONES); + std::vector zone_x2_numbers_ = std::vector(MAX_ZONES); + std::vector zone_y2_numbers_ = std::vector(MAX_ZONES); +#endif +#ifdef USE_SENSOR + std::vector move_x_sensors_ = std::vector(MAX_TARGETS); + std::vector move_y_sensors_ = std::vector(MAX_TARGETS); + std::vector move_speed_sensors_ = std::vector(MAX_TARGETS); + std::vector move_angle_sensors_ = std::vector(MAX_TARGETS); + std::vector move_distance_sensors_ = std::vector(MAX_TARGETS); + std::vector move_resolution_sensors_ = std::vector(MAX_TARGETS); + std::vector zone_target_count_sensors_ = std::vector(MAX_ZONES); + std::vector zone_still_target_count_sensors_ = std::vector(MAX_ZONES); + std::vector zone_moving_target_count_sensors_ = std::vector(MAX_ZONES); +#endif +#ifdef USE_TEXT_SENSOR + std::vector direction_text_sensors_ = std::vector(3); +#endif +}; + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/number/__init__.py b/esphome/components/ld2450/number/__init__.py new file mode 100644 index 0000000000..8e83de56a0 --- /dev/null +++ b/esphome/components/ld2450/number/__init__.py @@ -0,0 +1,120 @@ +import esphome.codegen as cg +from esphome.components import number +import esphome.config_validation as cv +from esphome.const import ( + CONF_ID, + DEVICE_CLASS_DISTANCE, + ENTITY_CATEGORY_CONFIG, + ICON_TIMELAPSE, + UNIT_MILLIMETER, + UNIT_SECOND, +) + +from .. import CONF_LD2450_ID, LD2450Component, ld2450_ns + +CONF_PRESENCE_TIMEOUT = "presence_timeout" +CONF_X1 = "x1" +CONF_X2 = "x2" +CONF_Y1 = "y1" +CONF_Y2 = "y2" +ICON_ARROW_BOTTOM_RIGHT = "mdi:arrow-bottom-right" +ICON_ARROW_BOTTOM_RIGHT_BOLD_BOX_OUTLINE = "mdi:arrow-bottom-right-bold-box-outline" +ICON_ARROW_TOP_LEFT = "mdi:arrow-top-left" +ICON_ARROW_TOP_LEFT_BOLD_BOX_OUTLINE = "mdi:arrow-top-left-bold-box-outline" +MAX_ZONES = 3 + +PresenceTimeoutNumber = ld2450_ns.class_("PresenceTimeoutNumber", number.Number) +ZoneCoordinateNumber = ld2450_ns.class_("ZoneCoordinateNumber", number.Number) + +CONFIG_SCHEMA = cv.Schema( + { + cv.GenerateID(CONF_LD2450_ID): cv.use_id(LD2450Component), + cv.Required(CONF_PRESENCE_TIMEOUT): number.number_schema( + PresenceTimeoutNumber, + unit_of_measurement=UNIT_SECOND, + entity_category=ENTITY_CATEGORY_CONFIG, + icon=ICON_TIMELAPSE, + ), + } +) + +CONFIG_SCHEMA = CONFIG_SCHEMA.extend( + { + cv.Optional(f"zone_{n + 1}"): cv.Schema( + { + cv.Required(CONF_X1): number.number_schema( + ZoneCoordinateNumber, + device_class=DEVICE_CLASS_DISTANCE, + unit_of_measurement=UNIT_MILLIMETER, + entity_category=ENTITY_CATEGORY_CONFIG, + icon=ICON_ARROW_TOP_LEFT_BOLD_BOX_OUTLINE, + ), + cv.Required(CONF_Y1): number.number_schema( + ZoneCoordinateNumber, + device_class=DEVICE_CLASS_DISTANCE, + unit_of_measurement=UNIT_MILLIMETER, + entity_category=ENTITY_CATEGORY_CONFIG, + icon=ICON_ARROW_TOP_LEFT, + ), + cv.Required(CONF_X2): number.number_schema( + ZoneCoordinateNumber, + device_class=DEVICE_CLASS_DISTANCE, + unit_of_measurement=UNIT_MILLIMETER, + entity_category=ENTITY_CATEGORY_CONFIG, + icon=ICON_ARROW_BOTTOM_RIGHT_BOLD_BOX_OUTLINE, + ), + cv.Required(CONF_Y2): number.number_schema( + ZoneCoordinateNumber, + device_class=DEVICE_CLASS_DISTANCE, + unit_of_measurement=UNIT_MILLIMETER, + entity_category=ENTITY_CATEGORY_CONFIG, + icon=ICON_ARROW_BOTTOM_RIGHT, + ), + } + ) + for n in range(MAX_ZONES) + } +) + + +async def to_code(config): + ld2450_component = await cg.get_variable(config[CONF_LD2450_ID]) + if presence_timeout_config := config.get(CONF_PRESENCE_TIMEOUT): + n = await number.new_number( + presence_timeout_config, + min_value=0, + max_value=3600, + step=1, + ) + await cg.register_parented(n, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_presence_timeout_number(n)) + for x in range(MAX_ZONES): + if zone_conf := config.get(f"zone_{x + 1}"): + if zone_x1_config := zone_conf.get(CONF_X1): + n = cg.new_Pvariable(zone_x1_config[CONF_ID], x) + await number.register_number( + n, zone_x1_config, min_value=-4860, max_value=4860, step=1 + ) + await cg.register_parented(n, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_zone_x1_number(x, n)) + if zone_y1_config := zone_conf.get(CONF_Y1): + n = cg.new_Pvariable(zone_y1_config[CONF_ID], x) + await number.register_number( + n, zone_y1_config, min_value=0, max_value=7560, step=1 + ) + await cg.register_parented(n, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_zone_y1_number(x, n)) + if zone_x2_config := zone_conf.get(CONF_X2): + n = cg.new_Pvariable(zone_x2_config[CONF_ID], x) + await number.register_number( + n, zone_x2_config, min_value=-4860, max_value=4860, step=1 + ) + await cg.register_parented(n, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_zone_x2_number(x, n)) + if zone_y2_config := zone_conf.get(CONF_Y2): + n = cg.new_Pvariable(zone_y2_config[CONF_ID], x) + await number.register_number( + n, zone_y2_config, min_value=0, max_value=7560, step=1 + ) + await cg.register_parented(n, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_zone_y2_number(x, n)) diff --git a/esphome/components/ld2450/number/presence_timeout_number.cpp b/esphome/components/ld2450/number/presence_timeout_number.cpp new file mode 100644 index 0000000000..ecfe71f484 --- /dev/null +++ b/esphome/components/ld2450/number/presence_timeout_number.cpp @@ -0,0 +1,12 @@ +#include "presence_timeout_number.h" + +namespace esphome { +namespace ld2450 { + +void PresenceTimeoutNumber::control(float value) { + this->publish_state(value); + this->parent_->set_presence_timeout(); +} + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/number/presence_timeout_number.h b/esphome/components/ld2450/number/presence_timeout_number.h new file mode 100644 index 0000000000..b18699792f --- /dev/null +++ b/esphome/components/ld2450/number/presence_timeout_number.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/components/number/number.h" +#include "../ld2450.h" + +namespace esphome { +namespace ld2450 { + +class PresenceTimeoutNumber : public number::Number, public Parented { + public: + PresenceTimeoutNumber() = default; + + protected: + void control(float value) override; +}; + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/number/zone_coordinate_number.cpp b/esphome/components/ld2450/number/zone_coordinate_number.cpp new file mode 100644 index 0000000000..5338d7e5ee --- /dev/null +++ b/esphome/components/ld2450/number/zone_coordinate_number.cpp @@ -0,0 +1,14 @@ +#include "zone_coordinate_number.h" + +namespace esphome { +namespace ld2450 { + +ZoneCoordinateNumber::ZoneCoordinateNumber(uint8_t zone) : zone_(zone) {} + +void ZoneCoordinateNumber::control(float value) { + this->publish_state(value); + this->parent_->set_zone_coordinate(this->zone_); +} + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/number/zone_coordinate_number.h b/esphome/components/ld2450/number/zone_coordinate_number.h new file mode 100644 index 0000000000..72b83889c4 --- /dev/null +++ b/esphome/components/ld2450/number/zone_coordinate_number.h @@ -0,0 +1,19 @@ +#pragma once + +#include "esphome/components/number/number.h" +#include "../ld2450.h" + +namespace esphome { +namespace ld2450 { + +class ZoneCoordinateNumber : public number::Number, public Parented { + public: + ZoneCoordinateNumber(uint8_t zone); + + protected: + uint8_t zone_; + void control(float value) override; +}; + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/select/__init__.py b/esphome/components/ld2450/select/__init__.py new file mode 100644 index 0000000000..25dd819637 --- /dev/null +++ b/esphome/components/ld2450/select/__init__.py @@ -0,0 +1,56 @@ +import esphome.codegen as cg +from esphome.components import select +import esphome.config_validation as cv +from esphome.const import CONF_BAUD_RATE, ENTITY_CATEGORY_CONFIG, ICON_THERMOMETER + +from .. import CONF_LD2450_ID, LD2450Component, ld2450_ns + +CONF_ZONE_TYPE = "zone_type" + +BaudRateSelect = ld2450_ns.class_("BaudRateSelect", select.Select) +ZoneTypeSelect = ld2450_ns.class_("ZoneTypeSelect", select.Select) + +CONFIG_SCHEMA = { + cv.GenerateID(CONF_LD2450_ID): cv.use_id(LD2450Component), + cv.Optional(CONF_BAUD_RATE): select.select_schema( + BaudRateSelect, + entity_category=ENTITY_CATEGORY_CONFIG, + icon=ICON_THERMOMETER, + ), + cv.Optional(CONF_ZONE_TYPE): select.select_schema( + ZoneTypeSelect, + entity_category=ENTITY_CATEGORY_CONFIG, + icon=ICON_THERMOMETER, + ), +} + + +async def to_code(config): + ld2450_component = await cg.get_variable(config[CONF_LD2450_ID]) + if baud_rate_config := config.get(CONF_BAUD_RATE): + s = await select.new_select( + baud_rate_config, + options=[ + "9600", + "19200", + "38400", + "57600", + "115200", + "230400", + "256000", + "460800", + ], + ) + await cg.register_parented(s, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_baud_rate_select(s)) + if zone_type_config := config.get(CONF_ZONE_TYPE): + s = await select.new_select( + zone_type_config, + options=[ + "Disabled", + "Detection", + "Filter", + ], + ) + await cg.register_parented(s, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_zone_type_select(s)) diff --git a/esphome/components/ld2450/select/baud_rate_select.cpp b/esphome/components/ld2450/select/baud_rate_select.cpp new file mode 100644 index 0000000000..06439aaa75 --- /dev/null +++ b/esphome/components/ld2450/select/baud_rate_select.cpp @@ -0,0 +1,12 @@ +#include "baud_rate_select.h" + +namespace esphome { +namespace ld2450 { + +void BaudRateSelect::control(const std::string &value) { + this->publish_state(value); + this->parent_->set_baud_rate(state); +} + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/select/baud_rate_select.h b/esphome/components/ld2450/select/baud_rate_select.h new file mode 100644 index 0000000000..04fe65b4fd --- /dev/null +++ b/esphome/components/ld2450/select/baud_rate_select.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/components/select/select.h" +#include "../ld2450.h" + +namespace esphome { +namespace ld2450 { + +class BaudRateSelect : public select::Select, public Parented { + public: + BaudRateSelect() = default; + + protected: + void control(const std::string &value) override; +}; + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/select/zone_type_select.cpp b/esphome/components/ld2450/select/zone_type_select.cpp new file mode 100644 index 0000000000..a9f6155142 --- /dev/null +++ b/esphome/components/ld2450/select/zone_type_select.cpp @@ -0,0 +1,12 @@ +#include "zone_type_select.h" + +namespace esphome { +namespace ld2450 { + +void ZoneTypeSelect::control(const std::string &value) { + this->publish_state(value); + this->parent_->set_zone_type(state); +} + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/select/zone_type_select.h b/esphome/components/ld2450/select/zone_type_select.h new file mode 100644 index 0000000000..8aafeb6beb --- /dev/null +++ b/esphome/components/ld2450/select/zone_type_select.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/components/select/select.h" +#include "../ld2450.h" + +namespace esphome { +namespace ld2450 { + +class ZoneTypeSelect : public select::Select, public Parented { + public: + ZoneTypeSelect() = default; + + protected: + void control(const std::string &value) override; +}; + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/sensor.py b/esphome/components/ld2450/sensor.py new file mode 100644 index 0000000000..21580c5801 --- /dev/null +++ b/esphome/components/ld2450/sensor.py @@ -0,0 +1,156 @@ +import esphome.codegen as cg +from esphome.components import sensor +import esphome.config_validation as cv +from esphome.const import ( + CONF_ANGLE, + CONF_DISTANCE, + CONF_RESOLUTION, + CONF_SPEED, + DEVICE_CLASS_DISTANCE, + DEVICE_CLASS_SPEED, + UNIT_DEGREES, + UNIT_MILLIMETER, +) + +from . import CONF_LD2450_ID, LD2450Component + +DEPENDENCIES = ["ld2450"] + +CONF_MOVING_TARGET_COUNT = "moving_target_count" +CONF_STILL_TARGET_COUNT = "still_target_count" +CONF_TARGET_COUNT = "target_count" +CONF_X = "x" +CONF_Y = "y" + +ICON_ACCOUNT_GROUP = "mdi:account-group" +ICON_ACCOUNT_SWITCH = "mdi:account-switch" +ICON_ALPHA_X_BOX_OUTLINE = "mdi:alpha-x-box-outline" +ICON_ALPHA_Y_BOX_OUTLINE = "mdi:alpha-y-box-outline" +ICON_FORMAT_TEXT_ROTATION_ANGLE_UP = "mdi:format-text-rotation-angle-up" +ICON_HUMAN_GREETING_PROXIMITY = "mdi:human-greeting-proximity" +ICON_MAP_MARKER_ACCOUNT = "mdi:map-marker-account" +ICON_MAP_MARKER_DISTANCE = "mdi:map-marker-distance" +ICON_RELATION_ZERO_OR_ONE_TO_ZERO_OR_ONE = "mdi:relation-zero-or-one-to-zero-or-one" +ICON_SPEEDOMETER_SLOW = "mdi:speedometer-slow" + +MAX_TARGETS = 3 +MAX_ZONES = 3 + +UNIT_MILLIMETER_PER_SECOND = "mm/s" + +CONFIG_SCHEMA = cv.Schema( + { + cv.GenerateID(CONF_LD2450_ID): cv.use_id(LD2450Component), + cv.Optional(CONF_TARGET_COUNT): sensor.sensor_schema( + icon=ICON_ACCOUNT_GROUP, + ), + cv.Optional(CONF_STILL_TARGET_COUNT): sensor.sensor_schema( + icon=ICON_HUMAN_GREETING_PROXIMITY, + ), + cv.Optional(CONF_MOVING_TARGET_COUNT): sensor.sensor_schema( + icon=ICON_ACCOUNT_SWITCH, + ), + } +) + +CONFIG_SCHEMA = CONFIG_SCHEMA.extend( + { + cv.Optional(f"target_{n + 1}"): cv.Schema( + { + cv.Optional(CONF_X): sensor.sensor_schema( + device_class=DEVICE_CLASS_DISTANCE, + unit_of_measurement=UNIT_MILLIMETER, + icon=ICON_ALPHA_X_BOX_OUTLINE, + ), + cv.Optional(CONF_Y): sensor.sensor_schema( + device_class=DEVICE_CLASS_DISTANCE, + unit_of_measurement=UNIT_MILLIMETER, + icon=ICON_ALPHA_Y_BOX_OUTLINE, + ), + cv.Optional(CONF_SPEED): sensor.sensor_schema( + device_class=DEVICE_CLASS_SPEED, + unit_of_measurement=UNIT_MILLIMETER_PER_SECOND, + icon=ICON_SPEEDOMETER_SLOW, + ), + cv.Optional(CONF_ANGLE): sensor.sensor_schema( + unit_of_measurement=UNIT_DEGREES, + icon=ICON_FORMAT_TEXT_ROTATION_ANGLE_UP, + ), + cv.Optional(CONF_DISTANCE): sensor.sensor_schema( + device_class=DEVICE_CLASS_DISTANCE, + unit_of_measurement=UNIT_MILLIMETER, + icon=ICON_MAP_MARKER_DISTANCE, + ), + cv.Optional(CONF_RESOLUTION): sensor.sensor_schema( + device_class=DEVICE_CLASS_DISTANCE, + unit_of_measurement=UNIT_MILLIMETER, + icon=ICON_RELATION_ZERO_OR_ONE_TO_ZERO_OR_ONE, + ), + } + ) + for n in range(MAX_TARGETS) + }, + { + cv.Optional(f"zone_{n + 1}"): cv.Schema( + { + cv.Optional(CONF_TARGET_COUNT): sensor.sensor_schema( + icon=ICON_MAP_MARKER_ACCOUNT, + ), + cv.Optional(CONF_STILL_TARGET_COUNT): sensor.sensor_schema( + icon=ICON_MAP_MARKER_ACCOUNT, + ), + cv.Optional(CONF_MOVING_TARGET_COUNT): sensor.sensor_schema( + icon=ICON_MAP_MARKER_ACCOUNT, + ), + } + ) + for n in range(MAX_ZONES) + }, +) + + +async def to_code(config): + ld2450_component = await cg.get_variable(config[CONF_LD2450_ID]) + + if target_count_config := config.get(CONF_TARGET_COUNT): + sens = await sensor.new_sensor(target_count_config) + cg.add(ld2450_component.set_target_count_sensor(sens)) + + if still_target_count_config := config.get(CONF_STILL_TARGET_COUNT): + sens = await sensor.new_sensor(still_target_count_config) + cg.add(ld2450_component.set_still_target_count_sensor(sens)) + + if moving_target_count_config := config.get(CONF_MOVING_TARGET_COUNT): + sens = await sensor.new_sensor(moving_target_count_config) + cg.add(ld2450_component.set_moving_target_count_sensor(sens)) + for n in range(MAX_TARGETS): + if target_conf := config.get(f"target_{n + 1}"): + if x_config := target_conf.get(CONF_X): + sens = await sensor.new_sensor(x_config) + cg.add(ld2450_component.set_move_x_sensor(n, sens)) + if y_config := target_conf.get(CONF_Y): + sens = await sensor.new_sensor(y_config) + cg.add(ld2450_component.set_move_y_sensor(n, sens)) + if speed_config := target_conf.get(CONF_SPEED): + sens = await sensor.new_sensor(speed_config) + cg.add(ld2450_component.set_move_speed_sensor(n, sens)) + if angle_config := target_conf.get(CONF_ANGLE): + sens = await sensor.new_sensor(angle_config) + cg.add(ld2450_component.set_move_angle_sensor(n, sens)) + if distance_config := target_conf.get(CONF_DISTANCE): + sens = await sensor.new_sensor(distance_config) + cg.add(ld2450_component.set_move_distance_sensor(n, sens)) + if resolution_config := target_conf.get(CONF_RESOLUTION): + sens = await sensor.new_sensor(resolution_config) + cg.add(ld2450_component.set_move_resolution_sensor(n, sens)) + for n in range(MAX_ZONES): + if zone_config := config.get(f"zone_{n + 1}"): + if target_count_config := zone_config.get(CONF_TARGET_COUNT): + sens = await sensor.new_sensor(target_count_config) + cg.add(ld2450_component.set_zone_target_count_sensor(n, sens)) + if still_target_count_config := zone_config.get(CONF_STILL_TARGET_COUNT): + sens = await sensor.new_sensor(still_target_count_config) + cg.add(ld2450_component.set_zone_still_target_count_sensor(n, sens)) + if moving_target_count_config := zone_config.get(CONF_MOVING_TARGET_COUNT): + sens = await sensor.new_sensor(moving_target_count_config) + cg.add(ld2450_component.set_zone_moving_target_count_sensor(n, sens)) diff --git a/esphome/components/ld2450/switch/__init__.py b/esphome/components/ld2450/switch/__init__.py new file mode 100644 index 0000000000..fb3969cf50 --- /dev/null +++ b/esphome/components/ld2450/switch/__init__.py @@ -0,0 +1,45 @@ +import esphome.codegen as cg +from esphome.components import switch +import esphome.config_validation as cv +from esphome.const import ( + DEVICE_CLASS_SWITCH, + ENTITY_CATEGORY_CONFIG, + ICON_BLUETOOTH, + ICON_PULSE, +) + +from .. import CONF_LD2450_ID, LD2450Component, ld2450_ns + +BluetoothSwitch = ld2450_ns.class_("BluetoothSwitch", switch.Switch) +MultiTargetSwitch = ld2450_ns.class_("MultiTargetSwitch", switch.Switch) + +CONF_BLUETOOTH = "bluetooth" +CONF_MULTI_TARGET = "multi_target" + +CONFIG_SCHEMA = { + cv.GenerateID(CONF_LD2450_ID): cv.use_id(LD2450Component), + cv.Optional(CONF_BLUETOOTH): switch.switch_schema( + BluetoothSwitch, + device_class=DEVICE_CLASS_SWITCH, + entity_category=ENTITY_CATEGORY_CONFIG, + icon=ICON_BLUETOOTH, + ), + cv.Optional(CONF_MULTI_TARGET): switch.switch_schema( + MultiTargetSwitch, + device_class=DEVICE_CLASS_SWITCH, + entity_category=ENTITY_CATEGORY_CONFIG, + icon=ICON_PULSE, + ), +} + + +async def to_code(config): + ld2450_component = await cg.get_variable(config[CONF_LD2450_ID]) + if bluetooth_config := config.get(CONF_BLUETOOTH): + s = await switch.new_switch(bluetooth_config) + await cg.register_parented(s, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_bluetooth_switch(s)) + if multi_target_config := config.get(CONF_MULTI_TARGET): + s = await switch.new_switch(multi_target_config) + await cg.register_parented(s, config[CONF_LD2450_ID]) + cg.add(ld2450_component.set_multi_target_switch(s)) diff --git a/esphome/components/ld2450/switch/bluetooth_switch.cpp b/esphome/components/ld2450/switch/bluetooth_switch.cpp new file mode 100644 index 0000000000..fa0d4fb06a --- /dev/null +++ b/esphome/components/ld2450/switch/bluetooth_switch.cpp @@ -0,0 +1,12 @@ +#include "bluetooth_switch.h" + +namespace esphome { +namespace ld2450 { + +void BluetoothSwitch::write_state(bool state) { + this->publish_state(state); + this->parent_->set_bluetooth(state); +} + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/switch/bluetooth_switch.h b/esphome/components/ld2450/switch/bluetooth_switch.h new file mode 100644 index 0000000000..3c1c4f755c --- /dev/null +++ b/esphome/components/ld2450/switch/bluetooth_switch.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/components/switch/switch.h" +#include "../ld2450.h" + +namespace esphome { +namespace ld2450 { + +class BluetoothSwitch : public switch_::Switch, public Parented { + public: + BluetoothSwitch() = default; + + protected: + void write_state(bool state) override; +}; + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/switch/multi_target_switch.cpp b/esphome/components/ld2450/switch/multi_target_switch.cpp new file mode 100644 index 0000000000..a163e29fc5 --- /dev/null +++ b/esphome/components/ld2450/switch/multi_target_switch.cpp @@ -0,0 +1,12 @@ +#include "multi_target_switch.h" + +namespace esphome { +namespace ld2450 { + +void MultiTargetSwitch::write_state(bool state) { + this->publish_state(state); + this->parent_->set_multi_target(state); +} + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/switch/multi_target_switch.h b/esphome/components/ld2450/switch/multi_target_switch.h new file mode 100644 index 0000000000..ca6253588d --- /dev/null +++ b/esphome/components/ld2450/switch/multi_target_switch.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/components/switch/switch.h" +#include "../ld2450.h" + +namespace esphome { +namespace ld2450 { + +class MultiTargetSwitch : public switch_::Switch, public Parented { + public: + MultiTargetSwitch() = default; + + protected: + void write_state(bool state) override; +}; + +} // namespace ld2450 +} // namespace esphome diff --git a/esphome/components/ld2450/text_sensor.py b/esphome/components/ld2450/text_sensor.py new file mode 100644 index 0000000000..6c11024b89 --- /dev/null +++ b/esphome/components/ld2450/text_sensor.py @@ -0,0 +1,62 @@ +import esphome.codegen as cg +from esphome.components import text_sensor +import esphome.config_validation as cv +from esphome.const import ( + CONF_DIRECTION, + CONF_MAC_ADDRESS, + CONF_VERSION, + ENTITY_CATEGORY_DIAGNOSTIC, + ENTITY_CATEGORY_NONE, + ICON_BLUETOOTH, + ICON_CHIP, + ICON_SIGN_DIRECTION, +) + +from . import CONF_LD2450_ID, LD2450Component + +DEPENDENCIES = ["ld2450"] + +MAX_TARGETS = 3 + +CONFIG_SCHEMA = cv.Schema( + { + cv.GenerateID(CONF_LD2450_ID): cv.use_id(LD2450Component), + cv.Optional(CONF_VERSION): text_sensor.text_sensor_schema( + entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + icon=ICON_CHIP, + ), + cv.Optional(CONF_MAC_ADDRESS): text_sensor.text_sensor_schema( + entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + icon=ICON_BLUETOOTH, + ), + } +) + +CONFIG_SCHEMA = CONFIG_SCHEMA.extend( + { + cv.Optional(f"target_{n + 1}"): cv.Schema( + { + cv.Optional(CONF_DIRECTION): text_sensor.text_sensor_schema( + entity_category=ENTITY_CATEGORY_NONE, + icon=ICON_SIGN_DIRECTION, + ), + } + ) + for n in range(MAX_TARGETS) + } +) + + +async def to_code(config): + ld2450_component = await cg.get_variable(config[CONF_LD2450_ID]) + if version_config := config.get(CONF_VERSION): + sens = await text_sensor.new_text_sensor(version_config) + cg.add(ld2450_component.set_version_text_sensor(sens)) + if mac_address_config := config.get(CONF_MAC_ADDRESS): + sens = await text_sensor.new_text_sensor(mac_address_config) + cg.add(ld2450_component.set_mac_text_sensor(sens)) + for n in range(MAX_TARGETS): + if direction_conf := config.get(f"target_{n + 1}"): + if direction_config := direction_conf.get(CONF_DIRECTION): + sens = await text_sensor.new_text_sensor(direction_config) + cg.add(ld2450_component.set_direction_text_sensor(n, sens)) 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/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/logger/__init__.py b/esphome/components/logger/__init__.py index f30bc23e38..113f306327 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 @@ -186,6 +189,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, @@ -207,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), @@ -225,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( @@ -234,10 +247,9 @@ async def to_code(config): ) cg.add(log.pre_setup()) - for tag, level in config[CONF_LOGS].items(): - cg.add(log.set_log_level(tag, LOG_LEVELS[level])) + for tag, log_level in config[CONF_LOGS].items(): + cg.add(log.set_log_level(tag, LOG_LEVELS[log_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]}") @@ -365,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..57f0ba9f9a 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -102,15 +102,9 @@ void Logger::log_vprintf_(int level, const char *tag, int line, const __FlashStr #endif 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 +161,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 +175,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/components/lvgl/__init__.py b/esphome/components/lvgl/__init__.py index c64ffcb5f2..22571c2550 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(): @@ -389,75 +396,87 @@ def add_hello_world(config): FINAL_VALIDATE_SCHEMA = final_validation -LVGL_SCHEMA = ( - cv.polling_component_schema("1s") - .extend(obj_schema(obj_spec)) - .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, ) 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/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/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/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/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/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp index acdcacc083..89e86741b0 100644 --- a/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp +++ b/esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp @@ -1,8 +1,6 @@ #include "modbus_textsensor.h" #include "esphome/core/log.h" -#include -#include namespace esphome { namespace modbus_controller { @@ -12,20 +10,17 @@ static const char *const TAG = "modbus_controller.text_sensor"; void ModbusTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Modbus Controller Text Sensor", this); } void ModbusTextSensor::parse_and_publish(const std::vector &data) { - std::ostringstream output; + std::string output_str{}; uint8_t items_left = this->response_bytes; uint8_t index = this->offset; - char buffer[5]; while ((items_left > 0) && index < data.size()) { uint8_t b = data[index]; switch (this->encode_) { case RawEncoding::HEXBYTES: - sprintf(buffer, "%02x", b); - output << buffer; + output_str += str_snprintf("%02x", 2, b); break; case RawEncoding::COMMA: - sprintf(buffer, index != this->offset ? ",%d" : "%d", b); - output << buffer; + output_str += str_sprintf(index != this->offset ? ",%d" : "%d", b); break; case RawEncoding::ANSI: if (b < 0x20) @@ -33,25 +28,24 @@ void ModbusTextSensor::parse_and_publish(const std::vector &data) { // FALLTHROUGH // Anything else no encoding default: - output << (char) b; + output_str += (char) b; break; } items_left--; index++; } - auto result = output.str(); // Is there a lambda registered // call it with the pre converted value and the raw data array if (this->transform_func_.has_value()) { // the lambda can parse the response itself - auto val = (*this->transform_func_)(this, result, data); + auto val = (*this->transform_func_)(this, output_str, data); if (val.has_value()) { ESP_LOGV(TAG, "Value overwritten by lambda"); - result = val.value(); + output_str = val.value(); } } - this->publish_state(result); + this->publish_state(output_str); } } // namespace modbus_controller 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/mqtt/__init__.py b/esphome/components/mqtt/__init__.py index e1002478a1..99f8ad76d8 100644 --- a/esphome/components/mqtt/__init__.py +++ b/esphome/components/mqtt/__init__.py @@ -36,6 +36,7 @@ from esphome.const import ( CONF_PAYLOAD_AVAILABLE, CONF_PAYLOAD_NOT_AVAILABLE, CONF_PORT, + CONF_PUBLISH_NAN_AS_NONE, CONF_QOS, CONF_REBOOT_TIMEOUT, CONF_RETAIN, @@ -49,7 +50,6 @@ from esphome.const import ( CONF_USE_ABBREVIATIONS, CONF_USERNAME, CONF_WILL_MESSAGE, - CONF_PUBLISH_NAN_AS_NONE, PLATFORM_BK72XX, PLATFORM_ESP32, PLATFORM_ESP8266, @@ -406,7 +406,7 @@ async def to_code(config): if CONF_SSL_FINGERPRINTS in config: for fingerprint in config[CONF_SSL_FINGERPRINTS]: arr = [ - cg.RawExpression(f"0x{fingerprint[i:i + 2]}") for i in range(0, 40, 2) + cg.RawExpression(f"0x{fingerprint[i : i + 2]}") for i in range(0, 40, 2) ] cg.add(var.add_ssl_fingerprint(arr)) cg.add_build_flag("-DASYNC_TCP_SSL_ENABLED=1") 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"; 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/nfc/binary_sensor/__init__.py b/esphome/components/nfc/binary_sensor/__init__.py index 21c8298ea8..47cf014550 100644 --- a/esphome/components/nfc/binary_sensor/__init__.py +++ b/esphome/components/nfc/binary_sensor/__init__.py @@ -1,9 +1,10 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_UID from esphome.core import HexInt -from .. import nfc_ns, Nfcc, NfcTagListener + +from .. import Nfcc, NfcTagListener, nfc_ns DEPENDENCIES = ["nfc"] @@ -25,8 +26,7 @@ def validate_uid(value): for x in value.split("-"): if len(x) != 2: raise cv.Invalid( - "Each part (separated by '-') of the UID must be two characters " - "long." + "Each part (separated by '-') of the UID must be two characters long." ) try: x = int(x, 16) 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/online_image/__init__.py b/esphome/components/online_image/__init__.py index d1915c7364..6b69bc240b 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, @@ -52,6 +52,23 @@ class Format: pass +class BMPFormat(Format): + def __init__(self): + super().__init__("BMP") + + def actions(self): + 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", None, "https://github.com/bitbank2/JPEGDEC#ca1e0f2") + + class PNGFormat(Format): def __init__(self): super().__init__("PNG") @@ -61,8 +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 (PNGFormat(),)} +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_) @@ -102,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( @@ -168,7 +192,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/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..0ab7dadde3 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 success = this->image_->resize_(width, height) > 0; this->x_scale_ = static_cast(this->image_->buffer_width_) / width; this->y_scale_ = static_cast(this->image_->buffer_height_) / height; + return success; } void ImageDecoder::draw(int x, int y, int w, int h, const Color &color) { @@ -24,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!!!"); @@ -40,5 +50,24 @@ size_t DownloadBuffer::read(size_t len) { return this->unread_; } +size_t DownloadBuffer::resize(size_t size) { + if (this->size_ >= size) { + // Avoid useless reallocations; if the buffer is big enough, don't reallocate. + return this->size_; + } + this->allocator_.deallocate(this->buffer_, this->size_); + this->buffer_ = this->allocator_.allocate(size); + this->reset(); + if (this->buffer_) { + this->size_ = size; + return size; + } else { + ESP_LOGE(TAG, "allocation of %zu bytes failed. Biggest block in heap: %zu Bytes", size, + this->allocator_.get_max_free_block_size()); + this->size_ = 0; + 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 cde7f572e3..d11b8b46d3 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; /** @@ -23,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(uint32_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. @@ -45,8 +55,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. @@ -68,18 +79,15 @@ 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; }; 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_); } @@ -99,8 +107,10 @@ class DownloadBuffer { void reset() { this->unread_ = 0; } + size_t resize(size_t size); + 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/jpeg_image.cpp b/esphome/components/online_image/jpeg_image.cpp new file mode 100644 index 0000000000..e5ee3dd8bf --- /dev/null +++ b/esphome/components/online_image/jpeg_image.cpp @@ -0,0 +1,92 @@ +#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; +} + +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, "Download buffer resize failed!"); + return DECODE_ERROR_OUT_OF_MEMORY; + } + return 0; +} + +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: %d", this->jpeg_.getLastError()); + 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); + if (!this->set_size(this->jpeg_.getWidth(), this->jpeg_.getHeight())) { + return DECODE_ERROR_OUT_OF_MEMORY; + } + 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..fd488d6138 --- /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 {} + + int 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 93d070c6a9..3411018901 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -6,6 +6,12 @@ static const char *const TAG = "online_image"; #include "image_decoder.h" +#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 @@ -29,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) { @@ -57,33 +64,34 @@ void OnlineImage::release() { } } -bool OnlineImage::resize_(int width_in, int height_in) { +size_t OnlineImage::resize_(int width_in, int height_in) { int width = this->fixed_width_; int height = this->fixed_height_; - if (this->auto_resize_()) { + if (this->is_auto_resize_()) { width = width_in; height = height_in; if (this->width_ != width && this->height_ != height) { this->release(); } } - if (this->buffer_) { - return false; - } size_t new_size = this->get_buffer_size_(width, height); + if (this->buffer_) { + // Buffer already allocated => no need to resize + return new_size; + } ESP_LOGD(TAG, "Allocating new buffer of %zu bytes", new_size); this->buffer_ = this->allocator_.allocate(new_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; + return 0; } this->buffer_width_ = width; this->buffer_height_ = height; this->width_ = width; ESP_LOGV(TAG, "New size: (%d, %d)", width, height); - return true; + return new_size; } void OnlineImage::update() { @@ -93,7 +101,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"; + + headers.push_back(accept_header); + + this->downloader_ = this->parent_->get(this->url_, headers); if (this->downloader_ == nullptr) { ESP_LOGE(TAG, "Download failed."); @@ -118,20 +154,39 @@ void OnlineImage::update() { ESP_LOGD(TAG, "Starting download"); size_t total_size = this->downloader_->content_length; +#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) { - this->decoder_ = esphome::make_unique(this); + 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"); + 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); } void OnlineImage::loop() { @@ -145,6 +200,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; @@ -155,6 +211,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 e044b4f390..2d10e528b1 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" @@ -23,10 +23,12 @@ 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, + /** BMP format. */ + BMP, }; /** @@ -77,23 +79,42 @@ 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); 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; } int get_position_(int x, int y) const { return (x + y * this->buffer_width_) * this->get_bpp() / 8; } - ESPHOME_ALWAYS_INLINE bool auto_resize_() const { return this->fixed_width_ == 0 || this->fixed_height_ == 0; } + ESPHOME_ALWAYS_INLINE bool is_auto_resize_() const { return this->fixed_width_ == 0 || this->fixed_height_ == 0; } - bool resize_(int width, int height); + /** + * @brief Resize the image buffer to the requested dimensions. + * + * The buffer will be allocated if not existing. + * If the dimensions have been fixed in the yaml config, the buffer will be created + * with those dimensions and not resized, even on request. + * Otherwise, the old buffer will be deallocated and a new buffer with the requested + * allocated + * + * @param width + * @param height + * @return 0 if no memory could be allocated, the size of the new buffer otherwise. + */ + size_t resize_(int width, int height); /** * @brief Draw a pixel into the buffer. @@ -118,6 +139,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}; @@ -147,7 +174,9 @@ class OnlineImage : public PollingComponent, */ int buffer_height_; - friend void ImageDecoder::set_size(int width, int 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 4c4c22f9b7..fc5fb554bf 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" @@ -41,17 +40,22 @@ 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) { +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) { 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..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(uint32_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/opentherm/binary_sensor/__init__.py b/esphome/components/opentherm/binary_sensor/__init__.py index 643734f90c..d4c7861a1d 100644 --- a/esphome/components/opentherm/binary_sensor/__init__.py +++ b/esphome/components/opentherm/binary_sensor/__init__.py @@ -1,8 +1,9 @@ from typing import Any -import esphome.config_validation as cv from esphome.components import binary_sensor -from .. import const, schema, validate, generate +import esphome.config_validation as cv + +from .. import const, generate, schema, validate DEPENDENCIES = [const.OPENTHERM] COMPONENT_TYPE = const.BINARY_SENSOR @@ -11,8 +12,7 @@ COMPONENT_TYPE = const.BINARY_SENSOR def get_entity_validation_schema(entity: schema.BinarySensorSchema) -> cv.Schema: return binary_sensor.binary_sensor_schema( device_class=( - entity.device_class - or binary_sensor._UNDEF # pylint: disable=protected-access + entity.device_class or binary_sensor._UNDEF # pylint: disable=protected-access ), icon=(entity.icon or binary_sensor._UNDEF), # pylint: disable=protected-access ) diff --git a/esphome/components/opentherm/generate.py b/esphome/components/opentherm/generate.py index 6b6a0255a8..a97754d52c 100644 --- a/esphome/components/opentherm/generate.py +++ b/esphome/components/opentherm/generate.py @@ -3,8 +3,9 @@ from typing import Any, Callable, Optional import esphome.codegen as cg from esphome.const import CONF_ID + from . import const -from .schema import TSchema, SettingSchema +from .schema import SettingSchema, TSchema opentherm_ns = cg.esphome_ns.namespace("opentherm") OpenthermHub = opentherm_ns.class_("OpenthermHub", cg.Component) @@ -112,11 +113,10 @@ def add_messages(hub: cg.MockObj, keys: list[str], schemas: dict[str, TSchema]): msg_expr = cg.RawExpression(f"esphome::opentherm::MessageId::{msg}") if keep_updated: cg.add(hub.add_repeating_message(msg_expr)) + elif order is not None: + cg.add(hub.add_initial_message(msg_expr, order)) else: - if order is not None: - cg.add(hub.add_initial_message(msg_expr, order)) - else: - cg.add(hub.add_initial_message(msg_expr)) + cg.add(hub.add_initial_message(msg_expr)) def add_property_set(var: cg.MockObj, config_key: str, config: dict[str, Any]) -> None: @@ -128,7 +128,7 @@ Create = Callable[[dict[str, Any], str, cg.MockObj], Awaitable[cg.Pvariable]] def create_only_conf( - create: Callable[[dict[str, Any]], Awaitable[cg.Pvariable]] + create: Callable[[dict[str, Any]], Awaitable[cg.Pvariable]], ) -> Create: return lambda conf, _key, _hub: create(conf) diff --git a/esphome/components/opentherm/sensor/__init__.py b/esphome/components/opentherm/sensor/__init__.py index 546a79054b..86c842b299 100644 --- a/esphome/components/opentherm/sensor/__init__.py +++ b/esphome/components/opentherm/sensor/__init__.py @@ -1,8 +1,9 @@ from typing import Any -import esphome.config_validation as cv from esphome.components import sensor -from .. import const, schema, validate, generate +import esphome.config_validation as cv + +from .. import const, generate, schema, validate DEPENDENCIES = [const.OPENTHERM] COMPONENT_TYPE = const.SENSOR @@ -22,11 +23,9 @@ MSG_DATA_TYPES = { def get_entity_validation_schema(entity: schema.SensorSchema) -> cv.Schema: return sensor.sensor_schema( - unit_of_measurement=entity.unit_of_measurement - or sensor._UNDEF, # pylint: disable=protected-access + unit_of_measurement=entity.unit_of_measurement or sensor._UNDEF, # pylint: disable=protected-access accuracy_decimals=entity.accuracy_decimals, - device_class=entity.device_class - or sensor._UNDEF, # pylint: disable=protected-access + device_class=entity.device_class or sensor._UNDEF, # pylint: disable=protected-access icon=entity.icon or sensor._UNDEF, # pylint: disable=protected-access state_class=entity.state_class, ).extend( 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/pn532/binary_sensor.py b/esphome/components/pn532/binary_sensor.py index 9bcae30750..b9c3103c65 100644 --- a/esphome/components/pn532/binary_sensor.py +++ b/esphome/components/pn532/binary_sensor.py @@ -1,9 +1,10 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_UID from esphome.core import HexInt -from . import pn532_ns, PN532, CONF_PN532_ID + +from . import CONF_PN532_ID, PN532, pn532_ns DEPENDENCIES = ["pn532"] @@ -13,8 +14,7 @@ def validate_uid(value): for x in value.split("-"): if len(x) != 2: raise cv.Invalid( - "Each part (separated by '-') of the UID must be two characters " - "long." + "Each part (separated by '-') of the UID must be two characters long." ) try: x = int(x, 16) 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/esphome/components/prometheus/prometheus_handler.cpp b/esphome/components/prometheus/prometheus_handler.cpp index 2d39d8ef3f..794df299a1 100644 --- a/esphome/components/prometheus/prometheus_handler.cpp +++ b/esphome/components/prometheus/prometheus_handler.cpp @@ -77,6 +77,18 @@ 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 + +#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); } @@ -679,6 +691,139 @@ 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 + +#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 41a06537ed..b77dbc462b 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,28 @@ 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 + +#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/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; } diff --git a/esphome/components/rc522/binary_sensor.py b/esphome/components/rc522/binary_sensor.py index 716c0eca76..87f81c2223 100644 --- a/esphome/components/rc522/binary_sensor.py +++ b/esphome/components/rc522/binary_sensor.py @@ -1,9 +1,10 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_UID from esphome.core import HexInt -from . import rc522_ns, RC522, CONF_RC522_ID + +from . import CONF_RC522_ID, RC522, rc522_ns DEPENDENCIES = ["rc522"] @@ -13,8 +14,7 @@ def validate_uid(value): for x in value.split("-"): if len(x) != 2: raise cv.Invalid( - "Each part (separated by '-') of the UID must be two characters " - "long." + "Each part (separated by '-') of the UID must be two characters long." ) try: x = int(x, 16) 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/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; 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..6a635b0f7c --- /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..., 36000)); + TotoProtocol().encode(dst, data); + } +}; + +} // namespace remote_base +} // namespace esphome 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( 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/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); 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/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 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/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/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/components/scd30/sensor.py b/esphome/components/scd30/sensor.py index a900c51a58..cee8cc7b71 100644 --- a/esphome/components/scd30/sensor.py +++ b/esphome/components/scd30/sensor.py @@ -75,7 +75,7 @@ CONFIG_SCHEMA = ( cv.Optional(CONF_UPDATE_INTERVAL, default="60s"): cv.All( cv.positive_time_period_seconds, cv.Range( - min=core.TimePeriod(seconds=1), max=core.TimePeriod(seconds=1800) + min=core.TimePeriod(seconds=2), max=core.TimePeriod(seconds=1800) ), ), } 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/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/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/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/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..b49cf3ddda --- /dev/null +++ b/esphome/components/speaker/media_player/audio_pipeline.cpp @@ -0,0 +1,568 @@ +#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); + 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_(); + 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; + 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..722d9cbb2a --- /dev/null +++ b/esphome/components/speaker/media_player/audio_pipeline.h @@ -0,0 +1,159 @@ +#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 hard_stop_{false}; + 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/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/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; 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/thermostat/climate.py b/esphome/components/thermostat/climate.py index a529bbd474..638aad7c06 100644 --- a/esphome/components/thermostat/climate.py +++ b/esphome/components/thermostat/climate.py @@ -137,7 +137,7 @@ def validate_temperature_preset(preset, root_config, name, requirements): def generate_comparable_preset(config, name): - comparable_preset = f"{CONF_PRESET}:\n" f" - {CONF_NAME}: {name}\n" + comparable_preset = f"{CONF_PRESET}:\n - {CONF_NAME}: {name}\n" if CONF_DEFAULT_TARGET_TEMPERATURE_LOW in config: comparable_preset += f" {CONF_DEFAULT_TARGET_TEMPERATURE_LOW}: {config[CONF_DEFAULT_TARGET_TEMPERATURE_LOW]}\n" diff --git a/esphome/components/udp/__init__.py b/esphome/components/udp/__init__.py index e189975ade..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") @@ -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..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; @@ -249,6 +204,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); @@ -297,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); @@ -488,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) { @@ -565,6 +535,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/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/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 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_; diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index d5240b2674..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 ) @@ -52,21 +53,32 @@ 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 ) +GDEY042T81 = waveshare_epaper_ns.class_("GDEY042T81", WaveshareEPaper) +WaveshareEPaper2P9InD = waveshare_epaper_ns.class_( + "WaveshareEPaper2P9InD", WaveshareEPaper +) WaveshareEPaper4P2In = waveshare_epaper_ns.class_( "WaveshareEPaper4P2In", WaveshareEPaper ) WaveshareEPaper4P2InBV2 = waveshare_epaper_ns.class_( "WaveshareEPaper4P2InBV2", WaveshareEPaper ) +WaveshareEPaper4P2InBV2BWR = waveshare_epaper_ns.class_( + "WaveshareEPaper4P2InBV2BWR", WaveshareEPaperBWR +) WaveshareEPaper5P8In = waveshare_epaper_ns.class_( "WaveshareEPaper5P8In", WaveshareEPaper ) WaveshareEPaper5P8InV2 = waveshare_epaper_ns.class_( "WaveshareEPaper5P8InV2", WaveshareEPaper ) +WaveshareEPaper7P3InF = waveshare_epaper_ns.class_( + "WaveshareEPaper7P3InF", WaveshareEPaper7C +) WaveshareEPaper7P5In = waveshare_epaper_ns.class_( "WaveshareEPaper7P5In", WaveshareEPaper ) @@ -88,6 +100,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 ) @@ -127,12 +142,17 @@ 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), + "gdey042t81": ("c", GDEY042T81), "4.20in": ("b", WaveshareEPaper4P2In), "4.20in-bv2": ("b", WaveshareEPaper4P2InBV2), + "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), @@ -140,10 +160,11 @@ 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), - "1.54in-m5coreink-m09": ("c", GDEW0154M09), + "1.54in-m5coreink-m09": ("b", GDEW0154M09), "13.3in-k": ("b", WaveshareEPaper13P3InK), } diff --git a/esphome/components/waveshare_epaper/waveshare_213v3.cpp b/esphome/components/waveshare_epaper/waveshare_213v3.cpp index 196aeed3f7..316cd80ccd 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_(); } @@ -86,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. @@ -162,7 +167,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.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index fb9e8ff6e5..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(); @@ -1211,6 +1325,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 @@ -1590,21 +1791,187 @@ 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/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 +// - 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 GDEW029T5::initialize() { - // from https://www.waveshare.com/w/upload/b/bb/2.9inch-e-paper-b-specification.pdf, page 37 +void GDEY029T94::initialize() { // EPD hardware init start this->reset_(); - // COMMAND POWER SETTINGS + 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 +// 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? +// ======================================================== + +// 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(0x01); this->data(0x03); this->data(0x00); this->data(0x2b); @@ -1617,40 +1984,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 +2109,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 +2139,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); } @@ -1815,6 +2283,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, @@ -1993,6 +2661,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); @@ -2581,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; @@ -2819,6 +3734,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 4544f7df59..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, @@ -247,6 +262,37 @@ class WaveshareEPaper2P7InBV2 : public WaveshareEPaperBWR { }; class GDEW029T5 : public WaveshareEPaper { + public: + void initialize() override; + + void display() override; + + void dump_config() override; + + 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 GDEY029T94 : public WaveshareEPaper { public: void initialize() override; @@ -255,9 +301,8 @@ class GDEW029T5 : public WaveshareEPaper { void dump_config() override; void deep_sleep() override { - // COMMAND DEEP SLEEP - this->command(0x07); - this->data(0xA5); // check byte + this->command(0x10); // Enter deep sleep + this->data(0x01); } protected: @@ -416,6 +461,63 @@ 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 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; @@ -487,6 +589,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; @@ -553,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; @@ -744,6 +907,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; @@ -811,6 +1011,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; 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/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{}; 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/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 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/config_validation.py b/esphome/config_validation.py index 20a0774ccb..9f7ce4d2e3 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) @@ -1214,8 +1223,7 @@ def subscribe_topic(value): if index != len(value) - 1: # If there are multiple wildcards, this will also trigger raise Invalid( - "Multi-level wildcard must be the last " - "character in the topic filter." + "Multi-level wildcard must be the last character in the topic filter." ) if len(value) > 1 and value[index - 1] != "/": raise Invalid("Multi-level wildcard must be after a topic level separator.") diff --git a/esphome/const.py b/esphome/const.py index 284f8d5f78..f74ea64148 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.0-dev" +__version__ = "2025.3.0-dev" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( @@ -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"} @@ -103,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" @@ -536,9 +528,11 @@ 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" +CONF_NOTIFY = "notify" CONF_NUM_ATTEMPTS = "num_attempts" CONF_NUM_CHANNELS = "num_channels" CONF_NUM_CHIPS = "num_chips" @@ -623,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" @@ -867,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" diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index f26c3da483..2a7b8b9d91 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.abspath(os.path.dirname(self.config_path)) @property def data_dir(self): @@ -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 eee8b73934..359b78acf1 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -1,21 +1,16 @@ import logging -import multiprocessing import os -import re +from pathlib import Path 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,13 +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, ) from esphome.core import CORE, coroutine_with_priority @@ -44,7 +35,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 +48,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"} @@ -83,6 +71,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: @@ -102,16 +93,24 @@ def valid_project_name(value: str): return value +def get_usable_cpu_count() -> int: + """Return the number of CPUs that can be used for processes. + On Python 3.13+ this is the number of CPUs that can be used for processes. + On older Python versions this is the number of CPUs. + """ + return ( + os.process_cpu_count() if hasattr(os, "process_cpu_count") else os.cpu_count() + ) + + if "ESPHOME_DEFAULT_COMPILE_PROCESS_LIMIT" in os.environ: _compile_process_limit_default = min( - int(os.environ["ESPHOME_DEFAULT_COMPILE_PROCESS_LIMIT"]), - multiprocessing.cpu_count(), + int(os.environ["ESPHOME_DEFAULT_COMPILE_PROCESS_LIMIT"]), get_usable_cpu_count() ) else: _compile_process_limit_default = cv.UNDEFINED -CONF_ESP8266_RESTORE_FROM_FLASH = "esp8266_restore_from_flash" CONFIG_SCHEMA = cv.All( cv.Schema( { @@ -165,7 +164,7 @@ CONFIG_SCHEMA = cv.All( ), cv.Optional( CONF_COMPILE_PROCESS_LIMIT, default=_compile_process_limit_default - ): cv.int_range(min=1, max=multiprocessing.cpu_count()), + ): cv.int_range(min=1, max=get_usable_cpu_count()), } ), validate_hostname, @@ -175,14 +174,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 ), @@ -191,7 +185,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]) @@ -204,63 +222,28 @@ 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 = [] - if not has_oldstyle and not newstyle_found: + for domain, _ in config.items(): + if domain.startswith("."): + continue + 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 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 + return target_platforms[0] def include_file(path, basename): @@ -390,7 +373,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/core/defines.h b/esphome/core/defines.h index c38a26c6a8..dc0ac3c1e8 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -14,8 +14,13 @@ #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 +#define USE_AUDIO_MP3_SUPPORT #define USE_API #define USE_API_NOISE #define USE_API_PLAINTEXT @@ -60,7 +65,9 @@ #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_ONLINE_IMAGE_JPEG_SUPPORT #define USE_OTA #define USE_OTA_PASSWORD #define USE_OTA_STATE_CALLBACK @@ -120,7 +127,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) diff --git a/esphome/core/gpio.h b/esphome/core/gpio.h index 1b6f2ba1e6..dd6f14fef9 100644 --- a/esphome/core/gpio.h +++ b/esphome/core/gpio.h @@ -53,6 +53,13 @@ class GPIOPin { virtual void pin_mode(gpio::Flags flags) = 0; + /** + * @brief Retrieve GPIO pin flags. + * + * @return The GPIO flags describing the pin mode and properties. + */ + virtual gpio::Flags get_flags() const = 0; + virtual bool digital_read() = 0; virtual void digital_write(bool value) = 0; 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 diff --git a/esphome/cpp_generator.py b/esphome/cpp_generator.py index 7a82d5cba1..eb0bd25d1d 100644 --- a/esphome/cpp_generator.py +++ b/esphome/cpp_generator.py @@ -506,9 +506,9 @@ def with_local_variable(id_: ID, rhs: SafeExpType, callback: Callable, *args) -> """ # throw if the callback is async: - assert not inspect.iscoroutinefunction( - callback - ), "with_local_variable() callback cannot be async!" + assert not inspect.iscoroutinefunction(callback), ( + "with_local_variable() callback cannot be async!" + ) CORE.add(RawStatement("{")) # output opening curly brace obj = variable(id_, rhs, None, True) @@ -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): diff --git a/esphome/dashboard/web_server.py b/esphome/dashboard/web_server.py index 67712da9b6..b8562aaccb 100644 --- a/esphome/dashboard/web_server.py +++ b/esphome/dashboard/web_server.py @@ -853,7 +853,7 @@ class InfoRequestHandler(BaseHandler): dashboard = DASHBOARD entry = dashboard.entries.get(yaml_path) - if not entry: + if not entry or entry.storage is None: self.set_status(404) return 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 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" 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 = {} diff --git a/esphome/wizard.py b/esphome/wizard.py index eecbbdb172..7fdf245c76 100644 --- a/esphome/wizard.py +++ b/esphome/wizard.py @@ -144,17 +144,17 @@ def wizard_file(**kwargs): # Configure API if "password" in kwargs: - config += f" password: \"{kwargs['password']}\"\n" + config += f' password: "{kwargs["password"]}"\n' if "api_encryption_key" in kwargs: - config += f" encryption:\n key: \"{kwargs['api_encryption_key']}\"\n" + config += f' encryption:\n key: "{kwargs["api_encryption_key"]}"\n' # Configure OTA config += "\nota:\n" config += " - platform: esphome\n" if "ota_password" in kwargs: - config += f" password: \"{kwargs['ota_password']}\"" + config += f' password: "{kwargs["ota_password"]}"' elif "password" in kwargs: - config += f" password: \"{kwargs['password']}\"" + config += f' password: "{kwargs["password"]}"' # Configuring wifi config += "\n\nwifi:\n" @@ -181,18 +181,14 @@ def wizard_file(**kwargs): password: "{fallback_psk}" captive_portal: - """.format( - **kwargs - ) + """.format(**kwargs) else: config += """ # Enable fallback hotspot in case wifi connection fails ap: ssid: "{fallback_name}" password: "{fallback_psk}" - """.format( - **kwargs - ) + """.format(**kwargs) return config @@ -388,19 +384,19 @@ def wizard(path): safe_print() # Don't sleep because user needs to copy link if platform == "ESP32": - safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'nodemcu-32s')}\".") + safe_print(f'For example "{color(Fore.BOLD_WHITE, "nodemcu-32s")}".') boards_list = esp32_boards.BOARDS.items() elif platform == "ESP8266": - safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'nodemcuv2')}\".") + safe_print(f'For example "{color(Fore.BOLD_WHITE, "nodemcuv2")}".') boards_list = esp8266_boards.BOARDS.items() elif platform == "BK72XX": - safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'cb2s')}\".") + safe_print(f'For example "{color(Fore.BOLD_WHITE, "cb2s")}".') boards_list = bk72xx_boards.BOARDS.items() elif platform == "RTL87XX": - safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'wr3')}\".") + safe_print(f'For example "{color(Fore.BOLD_WHITE, "wr3")}".') boards_list = rtl87xx_boards.BOARDS.items() elif platform == "RP2040": - safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'rpipicow')}\".") + safe_print(f'For example "{color(Fore.BOLD_WHITE, "rpipicow")}".') boards_list = rp2040_boards.BOARDS.items() else: @@ -439,7 +435,7 @@ def wizard(path): f"First, what's the {color(Fore.GREEN, 'SSID')} (the name) of the WiFi network {name} should connect to?" ) sleep(1.5) - safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'Abraham Linksys')}\".") + safe_print(f'For example "{color(Fore.BOLD_WHITE, "Abraham Linksys")}".') while True: ssid = safe_input(color(Fore.BOLD_WHITE, "(ssid): ")) try: @@ -465,7 +461,7 @@ def wizard(path): f"Now please state the {color(Fore.GREEN, 'password')} of the WiFi network so that I can connect to it (Leave empty for no password)" ) safe_print() - safe_print(f"For example \"{color(Fore.BOLD_WHITE, 'PASSWORD42')}\"") + safe_print(f'For example "{color(Fore.BOLD_WHITE, "PASSWORD42")}"') sleep(0.5) psk = safe_input(color(Fore.BOLD_WHITE, "(PSK): ")) safe_print( diff --git a/esphome/writer.py b/esphome/writer.py index 90446ae4b1..39423db64c 100644 --- a/esphome/writer.py +++ b/esphome/writer.py @@ -212,9 +212,7 @@ def write_platformio_project(): write_platformio_ini(content) -DEFINES_H_FORMAT = ( - ESPHOME_H_FORMAT -) = """\ +DEFINES_H_FORMAT = ESPHOME_H_FORMAT = """\ #pragma once #include "esphome/core/macros.h" {} diff --git a/platformio.ini b/platformio.ini index 7234333a8c..69a0b7ce2a 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#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 @@ -125,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} @@ -146,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 diff --git a/requirements.txt b/requirements.txt index d96004c8ef..1de6e3dd06 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,12 +12,12 @@ 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 -aioesphomeapi==24.6.2 -zeroconf==0.132.2 +esphome-dashboard==20250212.0 +aioesphomeapi==29.1.0 +zeroconf==0.145.1 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import -glyphsets==1.0.0 +esphome-glyphsets==0.1.0 pillow==10.4.0 freetype-py==2.5.1 diff --git a/requirements_test.txt b/requirements_test.txt index 5d94f7f640..d836efc148 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,6 +1,6 @@ pylint==3.2.7 flake8==7.0.0 # also change in .pre-commit-config.yaml when updating -black==24.4.2 # also change in .pre-commit-config.yaml when updating +ruff==0.9.2 # also change in .pre-commit-config.yaml when updating pyupgrade==3.15.2 # also change in .pre-commit-config.yaml when updating pre-commit diff --git a/script/clang-format b/script/clang-format index d922c5b6f1..b1e84a56b7 100755 --- a/script/clang-format +++ b/script/clang-format @@ -1,7 +1,6 @@ #!/usr/bin/env python3 import argparse -import multiprocessing import os import queue import re @@ -11,7 +10,13 @@ import threading import click import colorama -from helpers import filter_changed, get_binary, git_ls_files, print_error_for_file +from helpers import ( + filter_changed, + get_binary, + get_usable_cpu_count, + git_ls_files, + print_error_for_file, +) def run_format(executable, args, queue, lock, failed_files): @@ -25,7 +30,9 @@ def run_format(executable, args, queue, lock, failed_files): invocation.extend(["--dry-run", "-Werror"]) invocation.append(path) - proc = subprocess.run(invocation, capture_output=True, encoding="utf-8") + proc = subprocess.run( + invocation, capture_output=True, encoding="utf-8", check=False + ) if proc.returncode != 0: with lock: print_error_for_file(path, proc.stderr) @@ -45,7 +52,7 @@ def main(): "-j", "--jobs", type=int, - default=multiprocessing.cpu_count(), + default=get_usable_cpu_count(), help="number of format instances to be run in parallel.", ) parser.add_argument( @@ -80,7 +87,8 @@ def main(): lock = threading.Lock() for _ in range(args.jobs): t = threading.Thread( - target=run_format, args=(executable, args, task_queue, lock, failed_files) + target=run_format, + args=(executable, args, task_queue, lock, failed_files), ) t.daemon = True t.start() @@ -95,7 +103,7 @@ def main(): # Wait for all threads to be done. task_queue.join() - except FileNotFoundError as ex: + except FileNotFoundError: return 1 except KeyboardInterrupt: print() @@ -103,7 +111,7 @@ def main(): # Kill subprocesses (and ourselves!) # No simple, clean alternative appears to be available. os.kill(0, 9) - return 2 # Will not execute. + return 2 # Will not execute. return len(failed_files) diff --git a/script/clang-tidy b/script/clang-tidy index 5c19f81043..51705f955b 100755 --- a/script/clang-tidy +++ b/script/clang-tidy @@ -1,7 +1,6 @@ #!/usr/bin/env python3 import argparse -import multiprocessing import os import queue import re @@ -19,6 +18,7 @@ from helpers import ( filter_changed, filter_grep, get_binary, + get_usable_cpu_count, git_ls_files, load_idedata, print_error_for_file, @@ -170,7 +170,7 @@ def main(): "-j", "--jobs", type=int, - default=multiprocessing.cpu_count(), + default=get_usable_cpu_count(), help="number of tidy instances to be run in parallel.", ) parser.add_argument( diff --git a/script/helpers.py b/script/helpers.py index 6f36faaeb1..6148371e32 100644 --- a/script/helpers.py +++ b/script/helpers.py @@ -188,3 +188,14 @@ def get_binary(name: str, version: str) -> str: """ ) raise + + +def get_usable_cpu_count() -> int: + """Return the number of CPUs that can be used for processes. + + On Python 3.13+ this is the number of CPUs that can be used for processes. + On older Python versions this is the number of CPUs. + """ + return ( + os.process_cpu_count() if hasattr(os, "process_cpu_count") else os.cpu_count() + ) diff --git a/script/run-in-env.py b/script/run-in-env.py new file mode 100644 index 0000000000..57121266be --- /dev/null +++ b/script/run-in-env.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 + +import os +from pathlib import Path +import subprocess +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( + ["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, + ) + return + + # 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 + venv_bin_dir = activate_path.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}") + return + + print("No virtual environment found.", file=sys.stderr) + + +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() 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 "$@" 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..0f0ad5e94e 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: @@ -9,5 +10,6 @@ sensor: pin: A0 id: s_1 name: test s1 + sampling_mode: min update_interval: 60s device_class: voltage 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/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 a869f2379b..63c3bd6afd 100644 --- a/tests/components/ads1115/test.esp32-ard.yaml +++ b/tests/components/ads1115/test.esp32-ard.yaml @@ -1,13 +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 - 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 7ac5a09f3f..ee2c29ca4e 100644 --- a/tests/components/ads1115/test.esp32-c3-ard.yaml +++ b/tests/components/ads1115/test.esp32-c3-ard.yaml @@ -1,13 +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 - 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 7ac5a09f3f..ee2c29ca4e 100644 --- a/tests/components/ads1115/test.esp32-c3-idf.yaml +++ b/tests/components/ads1115/test.esp32-c3-idf.yaml @@ -1,13 +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 - 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 a869f2379b..63c3bd6afd 100644 --- a/tests/components/ads1115/test.esp32-idf.yaml +++ b/tests/components/ads1115/test.esp32-idf.yaml @@ -1,13 +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 - 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 7ac5a09f3f..ee2c29ca4e 100644 --- a/tests/components/ads1115/test.esp8266-ard.yaml +++ b/tests/components/ads1115/test.esp8266-ard.yaml @@ -1,13 +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 - 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 7ac5a09f3f..ee2c29ca4e 100644 --- a/tests/components/ads1115/test.rp2040-ard.yaml +++ b/tests/components/ads1115/test.rp2040-ard.yaml @@ -1,13 +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 - 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/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/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 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 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 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 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/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 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 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 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(); 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 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 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 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 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/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/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 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/ld2450/common.yaml b/tests/components/ld2450/common.yaml new file mode 100644 index 0000000000..2e62efb0f5 --- /dev/null +++ b/tests/components/ld2450/common.yaml @@ -0,0 +1,168 @@ +uart: + - id: ld2450_uart + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 256000 + parity: NONE + stop_bits: 1 + +ld2450: + - id: ld2450_radar + uart_id: ld2450_uart + throttle: 1000ms + +button: + - platform: ld2450 + ld2450_id: ld2450_radar + factory_reset: + name: LD2450 Factory Reset + entity_category: config + restart: + name: LD2450 Restart + entity_category: config + +sensor: + - platform: ld2450 + ld2450_id: ld2450_radar + target_count: + name: Presence Target Count + still_target_count: + name: Still Target Count + moving_target_count: + name: Moving Target Count + target_1: + x: + name: Target-1 X + y: + name: Target-1 Y + speed: + name: Target-1 Speed + angle: + name: Target-1 Angle + distance: + name: Target-1 Distance + resolution: + name: Target-1 Resolution + target_2: + x: + name: Target-2 X + y: + name: Target-2 Y + speed: + name: Target-2 Speed + angle: + name: Target-2 Angle + distance: + name: Target-2 Distance + resolution: + name: Target-2 Resolution + target_3: + x: + name: Target-3 X + y: + name: Target-3 Y + speed: + name: Target-3 Speed + angle: + name: Target-3 Angle + distance: + name: Target-3 Distance + resolution: + name: Target-3 Resolution + zone_1: + target_count: + name: Zone-1 All Target Count + still_target_count: + name: Zone-1 Still Target Count + moving_target_count: + name: Zone-1 Moving Target Count + zone_2: + target_count: + name: Zone-2 All Target Count + still_target_count: + name: Zone-2 Still Target Count + moving_target_count: + name: Zone-2 Moving Target Count + zone_3: + target_count: + name: Zone-3 All Target Count + still_target_count: + name: Zone-3 Still Target Count + moving_target_count: + name: Zone-3 Moving Target Count + +binary_sensor: + - platform: ld2450 + ld2450_id: ld2450_radar + has_target: + name: Presence + has_moving_target: + name: Moving Target + has_still_target: + name: Still Target + +switch: + - platform: ld2450 + ld2450_id: ld2450_radar + bluetooth: + name: Bluetooth + multi_target: + name: Multi Target Tracking + +text_sensor: + - platform: ld2450 + ld2450_id: ld2450_radar + version: + name: LD2450 Firmware + mac_address: + name: LD2450 BT MAC + target_1: + direction: + name: Target-1 Direction + target_2: + direction: + name: Target-2 Direction + target_3: + direction: + name: Target-3 Direction + +number: + - platform: ld2450 + ld2450_id: ld2450_radar + presence_timeout: + name: Timeout + zone_1: + x1: + name: Zone-1 X1 + y1: + name: Zone-1 Y1 + x2: + name: Zone-1 X2 + y2: + name: Zone-1 Y2 + zone_2: + x1: + name: Zone-2 X1 + y1: + name: Zone-2 Y1 + x2: + name: Zone-2 X2 + y2: + name: Zone-2 Y2 + zone_3: + x1: + name: Zone-3 X1 + y1: + name: Zone-3 Y1 + x2: + name: Zone-3 X2 + y2: + name: Zone-3 Y2 + +select: + - platform: ld2450 + ld2450_id: ld2450_radar + baud_rate: + name: Baud Rate + zone_type: + name: Zone Type diff --git a/tests/components/ld2450/test.esp32-ard.yaml b/tests/components/ld2450/test.esp32-ard.yaml new file mode 100644 index 0000000000..f486544afa --- /dev/null +++ b/tests/components/ld2450/test.esp32-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 + +<<: !include common.yaml diff --git a/tests/components/ld2450/test.esp32-c3-ard.yaml b/tests/components/ld2450/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/ld2450/test.esp32-c3-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/ld2450/test.esp32-c3-idf.yaml b/tests/components/ld2450/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/ld2450/test.esp32-c3-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/ld2450/test.esp32-idf.yaml b/tests/components/ld2450/test.esp32-idf.yaml new file mode 100644 index 0000000000..f486544afa --- /dev/null +++ b/tests/components/ld2450/test.esp32-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 + +<<: !include common.yaml diff --git a/tests/components/ld2450/test.esp8266-ard.yaml b/tests/components/ld2450/test.esp8266-ard.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/ld2450/test.esp8266-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/ld2450/test.rp2040-ard.yaml b/tests/components/ld2450/test.rp2040-ard.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/ld2450/test.rp2040-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !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/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 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 diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index b3227bb96e..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 @@ -834,12 +846,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 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/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/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/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 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..7fa9f8dae3 --- /dev/null +++ b/tests/components/modbus_controller/common.yaml @@ -0,0 +1,105 @@ +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 + +binary_sensor: + - platform: modbus_controller + modbus_controller_id: modbus_controller1 + id: modbus_binary_sensor1 + name: Test Binary Sensor + register_type: read + address: 0x3200 + bitmask: 0x80 + +number: + - platform: modbus_controller + modbus_controller_id: modbus_controller1 + id: modbus_number1 + name: Test Number + address: 0x9001 + value_type: U_WORD + multiply: 1.0 + +output: + - platform: modbus_controller + modbus_controller_id: modbus_controller1 + id: modbus_output1 + address: 2048 + register_type: holding + value_type: U_WORD + multiply: 1000 + +select: + - platform: modbus_controller + modbus_controller_id: modbus_controller1 + id: modbus_select1 + name: Test Select + address: 1000 + value_type: U_WORD + optionsmap: + "Zero": 0 + "One": 1 + "Two": 2 + "Three": 3 + +sensor: + - platform: modbus_controller + modbus_controller_id: modbus_controller1 + id: modbus_sensor1 + name: Test Sensor + register_type: holding + address: 0x9001 + unit_of_measurement: "AH" + value_type: U_WORD + +switch: + - platform: modbus_controller + modbus_controller_id: modbus_controller1 + id: modbus_switch1 + name: Test Switch + register_type: coil + address: 0x15 + bitmask: 1 + +text_sensor: + - platform: modbus_controller + modbus_controller_id: modbus_controller1 + id: modbus_text_sensor1 + name: Test Text Sensor + register_type: holding + address: 0x9013 + register_count: 3 + raw_encode: HEXBYTES + response_size: 6 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 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/online_image/common.yaml b/tests/components/online_image/common.yaml index 81f43e9fdc..69daa915c5 100644 --- a/tests/components/online_image/common.yaml +++ b/tests/components/online_image/common.yaml @@ -14,18 +14,30 @@ 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 + - id: online_binary_bmp + 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: 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/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 diff --git a/tests/components/prometheus/common.yaml b/tests/components/prometheus/common.yaml index 1b87c1d6c1..7c226b6782 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 @@ -98,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: 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 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/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 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" 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 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 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/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 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/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" 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-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/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/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 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 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 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 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/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 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..09ba1af778 --- /dev/null +++ b/tests/components/waveshare_epaper/common.yaml @@ -0,0 +1,868 @@ +spi: + - id: spi_waveshare_epaper + clk_pin: ${clk_pin} + 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} + 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_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} + 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_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} + 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_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} + full_update_every: 30 + 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 + 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()); + + - 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 + 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_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 + 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-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 + 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} + 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.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 + 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()); diff --git a/tests/components/waveshare_epaper/test.esp32-ard.yaml b/tests/components/waveshare_epaper/test.esp32-ard.yaml index 944f98a1e9..c36345b984 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: GPIO18 + mosi_pin: GPIO23 + cs_pin: GPIO25 + dc_pin: GPIO26 + busy_pin: GPIO27 + reset_pin: GPIO32 -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..4cb230f6f2 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: GPIO4 + dc_pin: GPIO1 + busy_pin: GPIO2 + reset_pin: GPIO3 -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..4cb230f6f2 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: GPIO4 + dc_pin: GPIO1 + busy_pin: GPIO2 + reset_pin: GPIO3 -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..9e8b2fdec8 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: GPIO4 + dc_pin: GPIO5 + busy_pin: GPIO18 + reset_pin: GPIO19 -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..ee8199bcc0 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: GPIO4 + dc_pin: GPIO5 + busy_pin: GPIO15 + reset_pin: GPIO16 -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..e92f6d421d 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: GPIO6 + busy_pin: GPIO7 + reset_pin: GPIO8 -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 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_cpp_generator.py b/tests/unit_tests/test_cpp_generator.py index 6f4b5a40bc..95633ca0c6 100644 --- a/tests/unit_tests/test_cpp_generator.py +++ b/tests/unit_tests/test_cpp_generator.py @@ -1,11 +1,9 @@ from collections.abc import Iterator - import math import pytest -from esphome import cpp_generator as cg -from esphome import cpp_types as ct +from esphome import cpp_generator as cg, cpp_types as ct class TestExpressions: @@ -156,10 +154,7 @@ class TestLambdaExpression: actual = str(target) assert actual == ( - "[=](int32_t foo, float bar) {\n" - " if ((foo == 5) && (bar < 10))) {\n" - " }\n" - "}" + "[=](int32_t foo, float bar) {\n if ((foo == 5) && (bar < 10))) {\n }\n}" ) def test_str__with_return(self): 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"