From da3d007d7b869fad9ec56aa0d0e3945c9bd32411 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sun, 9 Feb 2025 15:40:19 -0600 Subject: [PATCH 01/79] Markdown tweaks/updates (#8211) --- CONTRIBUTING.md | 20 +++++++++++--------- README.md | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c92d91159..7be7bdac2c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,14 @@ -# Contributing to ESPHome +# Contributing to ESPHome [![Discord Chat](https://img.shields.io/discord/429907082951524364.svg)](https://discord.gg/KhAMKrd) [![GitHub release](https://img.shields.io/github/release/esphome/esphome.svg)](https://GitHub.com/esphome/esphome/releases/) -For a detailed guide, please see https://esphome.io/guides/contributing.html#contributing-to-esphome +We welcome contributions to the ESPHome suite of code and documentation! -Things to note when contributing: +Please read our [contributing guide](https://esphome.io/guides/contributing.html) if you wish to contribute to the +project and be sure to join us on [Discord](https://discord.gg/KhAMKrd). - - Please test your changes :) - - If a new feature is added or an existing user-facing feature is changed, you should also - update the [docs](https://github.com/esphome/esphome-docs). See [contributing to esphome-docs](https://esphome.io/guides/contributing.html#contributing-to-esphomedocs) - for more information. - - Please also update the tests in the `tests/` folder. You can do so by just adding a line in one of the YAML files - which checks if your new feature compiles correctly. +**See also:** + +[Documentation](https://esphome.io) -- [Issues](https://github.com/esphome/issues/issues) -- [Feature requests](https://github.com/esphome/feature-requests/issues) + +--- + +[![ESPHome - A project from the Open Home Foundation](https://www.openhomefoundation.org/badges/esphome.png)](https://www.openhomefoundation.org/) diff --git a/README.md b/README.md index 8e3d8f71aa..4f527870b8 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ -**Documentation:** https://esphome.io/ +--- -For issues, please go to [the issue tracker](https://github.com/esphome/issues/issues). +[Documentation](https://esphome.io) -- [Issues](https://github.com/esphome/issues/issues) -- [Feature requests](https://github.com/esphome/feature-requests/issues) -For feature requests, please see [feature requests](https://github.com/esphome/feature-requests/issues). +--- [![ESPHome - A project from the Open Home Foundation](https://www.openhomefoundation.org/badges/esphome.png)](https://www.openhomefoundation.org/) From 353924257ab1e38ca9d3228e1ac12a0e52055179 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sun, 9 Feb 2025 15:43:10 -0600 Subject: [PATCH 02/79] [CI] Consolidate some tests (S) (#8206) --- tests/components/scd30/common.yaml | 20 +++++++ tests/components/scd30/test.esp32-ard.yaml | 23 ++------ tests/components/scd30/test.esp32-c3-ard.yaml | 23 ++------ tests/components/scd30/test.esp32-c3-idf.yaml | 23 ++------ tests/components/scd30/test.esp32-idf.yaml | 23 ++------ tests/components/scd30/test.esp8266-ard.yaml | 23 ++------ tests/components/scd30/test.rp2040-ard.yaml | 23 ++------ tests/components/scd4x/common.yaml | 20 +++++++ tests/components/scd4x/test.esp32-ard.yaml | 23 ++------ tests/components/scd4x/test.esp32-c3-ard.yaml | 23 ++------ tests/components/scd4x/test.esp32-c3-idf.yaml | 23 ++------ tests/components/scd4x/test.esp32-idf.yaml | 23 ++------ tests/components/scd4x/test.esp8266-ard.yaml | 23 ++------ tests/components/scd4x/test.rp2040-ard.yaml | 23 ++------ tests/components/sdm_meter/common.yaml | 23 ++++++++ .../components/sdm_meter/test.esp32-ard.yaml | 26 ++-------- .../sdm_meter/test.esp32-c3-ard.yaml | 26 ++-------- .../sdm_meter/test.esp32-c3-idf.yaml | 26 ++-------- .../components/sdm_meter/test.esp32-idf.yaml | 26 ++-------- .../sdm_meter/test.esp8266-ard.yaml | 26 ++-------- .../components/sdm_meter/test.rp2040-ard.yaml | 26 ++-------- tests/components/sdp3x/common.yaml | 11 ++++ tests/components/sdp3x/test.esp32-ard.yaml | 14 ++--- tests/components/sdp3x/test.esp32-c3-ard.yaml | 14 ++--- tests/components/sdp3x/test.esp32-c3-idf.yaml | 14 ++--- tests/components/sdp3x/test.esp32-idf.yaml | 14 ++--- tests/components/sdp3x/test.esp8266-ard.yaml | 14 ++--- tests/components/sdp3x/test.rp2040-ard.yaml | 14 ++--- tests/components/sds011/common.yaml | 14 +++++ tests/components/sds011/test.esp32-ard.yaml | 17 ++---- .../components/sds011/test.esp32-c3-ard.yaml | 17 ++---- .../components/sds011/test.esp32-c3-idf.yaml | 17 ++---- tests/components/sds011/test.esp32-idf.yaml | 17 ++---- tests/components/sds011/test.esp8266-ard.yaml | 17 ++---- tests/components/sds011/test.rp2040-ard.yaml | 17 ++---- tests/components/selec_meter/common.yaml | 45 ++++++++++++++++ .../selec_meter/test.esp32-ard.yaml | 48 ++--------------- .../selec_meter/test.esp32-c3-ard.yaml | 48 ++--------------- .../selec_meter/test.esp32-c3-idf.yaml | 48 ++--------------- .../selec_meter/test.esp32-idf.yaml | 48 ++--------------- .../selec_meter/test.esp8266-ard.yaml | 48 ++--------------- .../selec_meter/test.rp2040-ard.yaml | 48 ++--------------- tests/components/sen0321/common.yaml | 10 ++++ tests/components/sen0321/test.esp32-ard.yaml | 13 ++--- .../components/sen0321/test.esp32-c3-ard.yaml | 13 ++--- .../components/sen0321/test.esp32-c3-idf.yaml | 13 ++--- tests/components/sen0321/test.esp32-idf.yaml | 13 ++--- .../components/sen0321/test.esp8266-ard.yaml | 13 ++--- tests/components/sen0321/test.rp2040-ard.yaml | 13 ++--- tests/components/sen21231/common.yaml | 9 ++++ tests/components/sen21231/test.esp32-ard.yaml | 12 ++--- .../sen21231/test.esp32-c3-ard.yaml | 12 ++--- .../sen21231/test.esp32-c3-idf.yaml | 12 ++--- tests/components/sen21231/test.esp32-idf.yaml | 12 ++--- .../components/sen21231/test.esp8266-ard.yaml | 12 ++--- .../components/sen21231/test.rp2040-ard.yaml | 12 ++--- tests/components/sen5x/common.yaml | 49 +++++++++++++++++ tests/components/sen5x/test.esp32-ard.yaml | 52 ++----------------- tests/components/sen5x/test.esp32-c3-ard.yaml | 52 ++----------------- tests/components/sen5x/test.esp32-c3-idf.yaml | 52 ++----------------- tests/components/sen5x/test.esp32-idf.yaml | 52 ++----------------- tests/components/sen5x/test.esp8266-ard.yaml | 52 ++----------------- tests/components/sen5x/test.rp2040-ard.yaml | 52 ++----------------- tests/components/senseair/common.yaml | 19 +++++++ tests/components/senseair/test.esp32-ard.yaml | 22 ++------ .../senseair/test.esp32-c3-ard.yaml | 22 ++------ .../senseair/test.esp32-c3-idf.yaml | 22 ++------ tests/components/senseair/test.esp32-idf.yaml | 22 ++------ .../components/senseair/test.esp8266-ard.yaml | 22 ++------ .../components/senseair/test.rp2040-ard.yaml | 22 ++------ tests/components/servo/common.yaml | 19 +++++++ tests/components/servo/test.esp32-ard.yaml | 22 ++------ tests/components/servo/test.esp32-c3-ard.yaml | 22 ++------ tests/components/servo/test.esp32-c3-idf.yaml | 22 ++------ tests/components/servo/test.esp32-idf.yaml | 22 ++------ tests/components/servo/test.esp8266-ard.yaml | 22 ++------ tests/components/servo/test.rp2040-ard.yaml | 22 ++------ tests/components/sfa30/common.yaml | 15 ++++++ tests/components/sfa30/test.esp32-ard.yaml | 18 ++----- tests/components/sfa30/test.esp32-c3-ard.yaml | 18 ++----- tests/components/sfa30/test.esp32-c3-idf.yaml | 18 ++----- tests/components/sfa30/test.esp32-idf.yaml | 18 ++----- tests/components/sfa30/test.esp8266-ard.yaml | 18 ++----- tests/components/sfa30/test.rp2040-ard.yaml | 18 ++----- tests/components/sgp30/common.yaml | 15 ++++++ tests/components/sgp30/test.esp32-ard.yaml | 18 ++----- tests/components/sgp30/test.esp32-c3-ard.yaml | 18 ++----- tests/components/sgp30/test.esp32-c3-idf.yaml | 18 ++----- tests/components/sgp30/test.esp32-idf.yaml | 18 ++----- tests/components/sgp30/test.esp8266-ard.yaml | 18 ++----- tests/components/sgp30/test.rp2040-ard.yaml | 18 ++----- tests/components/sgp4x/common.yaml | 27 ++++++++++ tests/components/sgp4x/test.esp32-ard.yaml | 30 ++--------- tests/components/sgp4x/test.esp32-c3-ard.yaml | 30 ++--------- tests/components/sgp4x/test.esp32-c3-idf.yaml | 30 ++--------- tests/components/sgp4x/test.esp32-idf.yaml | 30 ++--------- tests/components/sgp4x/test.esp8266-ard.yaml | 30 ++--------- tests/components/sgp4x/test.rp2040-ard.yaml | 30 ++--------- tests/components/sht3xd/common.yaml | 13 +++++ tests/components/sht3xd/test.esp32-ard.yaml | 16 ++---- .../components/sht3xd/test.esp32-c3-ard.yaml | 16 ++---- .../components/sht3xd/test.esp32-c3-idf.yaml | 16 ++---- tests/components/sht3xd/test.esp32-idf.yaml | 16 ++---- tests/components/sht3xd/test.esp8266-ard.yaml | 16 ++---- tests/components/sht3xd/test.rp2040-ard.yaml | 16 ++---- tests/components/sht4x/common.yaml | 13 +++++ tests/components/sht4x/test.esp32-ard.yaml | 16 ++---- tests/components/sht4x/test.esp32-c3-ard.yaml | 16 ++---- tests/components/sht4x/test.esp32-c3-idf.yaml | 16 ++---- tests/components/sht4x/test.esp32-idf.yaml | 16 ++---- tests/components/sht4x/test.esp8266-ard.yaml | 16 ++---- tests/components/sht4x/test.rp2040-ard.yaml | 16 ++---- tests/components/shtcx/common.yaml | 13 +++++ tests/components/shtcx/test.esp32-ard.yaml | 16 ++---- tests/components/shtcx/test.esp32-c3-ard.yaml | 16 ++---- tests/components/shtcx/test.esp32-c3-idf.yaml | 16 ++---- tests/components/shtcx/test.esp32-idf.yaml | 16 ++---- tests/components/shtcx/test.esp8266-ard.yaml | 16 ++---- tests/components/shtcx/test.rp2040-ard.yaml | 16 ++---- tests/components/sim800l/common.yaml | 37 +++++++++++++ tests/components/sim800l/test.esp32-ard.yaml | 40 ++------------ .../components/sim800l/test.esp32-c3-ard.yaml | 40 ++------------ .../components/sim800l/test.esp32-c3-idf.yaml | 40 ++------------ tests/components/sim800l/test.esp32-idf.yaml | 40 ++------------ .../components/sim800l/test.esp8266-ard.yaml | 40 ++------------ tests/components/sim800l/test.rp2040-ard.yaml | 40 ++------------ tests/components/sm16716/common.yaml | 4 +- tests/components/sm16716/test.esp32-ard.yaml | 4 ++ .../components/sm16716/test.esp32-c3-ard.yaml | 4 ++ .../components/sm16716/test.esp32-c3-idf.yaml | 4 ++ tests/components/sm16716/test.esp32-idf.yaml | 4 ++ .../components/sm16716/test.esp8266-ard.yaml | 4 ++ tests/components/sm16716/test.rp2040-ard.yaml | 4 ++ tests/components/sm2135/common.yaml | 4 +- tests/components/sm2135/test.esp32-ard.yaml | 4 ++ .../components/sm2135/test.esp32-c3-ard.yaml | 4 ++ .../components/sm2135/test.esp32-c3-idf.yaml | 4 ++ tests/components/sm2135/test.esp32-idf.yaml | 4 ++ tests/components/sm2135/test.esp8266-ard.yaml | 4 ++ tests/components/sm2135/test.rp2040-ard.yaml | 4 ++ tests/components/sm2235/common.yaml | 4 +- tests/components/sm2235/test.esp32-ard.yaml | 4 ++ .../components/sm2235/test.esp32-c3-ard.yaml | 4 ++ .../components/sm2235/test.esp32-c3-idf.yaml | 4 ++ tests/components/sm2235/test.esp32-idf.yaml | 4 ++ tests/components/sm2235/test.esp8266-ard.yaml | 4 ++ tests/components/sm2235/test.rp2040-ard.yaml | 4 ++ tests/components/sm2335/common.yaml | 4 +- tests/components/sm2335/test.esp32-ard.yaml | 4 ++ .../components/sm2335/test.esp32-c3-ard.yaml | 4 ++ .../components/sm2335/test.esp32-c3-idf.yaml | 4 ++ tests/components/sm2335/test.esp32-idf.yaml | 4 ++ tests/components/sm2335/test.esp8266-ard.yaml | 4 ++ tests/components/sm2335/test.rp2040-ard.yaml | 4 ++ tests/components/sm300d2/common.yaml | 23 ++++++++ tests/components/sm300d2/test.esp32-ard.yaml | 26 ++-------- .../components/sm300d2/test.esp32-c3-ard.yaml | 26 ++-------- .../components/sm300d2/test.esp32-c3-idf.yaml | 26 ++-------- tests/components/sm300d2/test.esp32-idf.yaml | 26 ++-------- .../components/sm300d2/test.esp8266-ard.yaml | 26 ++-------- tests/components/sm300d2/test.rp2040-ard.yaml | 26 ++-------- tests/components/sml/common.yaml | 31 +++++++++++ tests/components/sml/test.esp32-ard.yaml | 34 ++---------- tests/components/sml/test.esp32-c3-ard.yaml | 34 ++---------- tests/components/sml/test.esp32-c3-idf.yaml | 34 ++---------- tests/components/sml/test.esp32-idf.yaml | 34 ++---------- tests/components/sml/test.esp8266-ard.yaml | 34 ++---------- tests/components/sml/test.rp2040-ard.yaml | 34 ++---------- tests/components/smt100/common.yaml | 19 +++++++ tests/components/smt100/test.esp32-ard.yaml | 22 ++------ .../components/smt100/test.esp32-c3-ard.yaml | 22 ++------ .../components/smt100/test.esp32-c3-idf.yaml | 22 ++------ tests/components/smt100/test.esp32-idf.yaml | 22 ++------ tests/components/smt100/test.esp8266-ard.yaml | 22 ++------ tests/components/smt100/test.rp2040-ard.yaml | 22 ++------ tests/components/sn74hc165/common.yaml | 14 +++++ .../components/sn74hc165/test.esp32-ard.yaml | 19 +++---- .../sn74hc165/test.esp32-c3-ard.yaml | 19 +++---- .../sn74hc165/test.esp32-c3-idf.yaml | 19 +++---- .../components/sn74hc165/test.esp32-idf.yaml | 19 +++---- .../sn74hc165/test.esp8266-ard.yaml | 19 +++---- .../components/sn74hc165/test.rp2040-ard.yaml | 19 +++---- tests/components/sn74hc595/common.yaml | 26 ++++++++++ .../components/sn74hc595/test.esp32-ard.yaml | 37 ++++--------- .../sn74hc595/test.esp32-c3-ard.yaml | 37 ++++--------- .../sn74hc595/test.esp32-c3-idf.yaml | 37 ++++--------- .../components/sn74hc595/test.esp32-idf.yaml | 37 ++++--------- .../sn74hc595/test.esp8266-ard.yaml | 37 ++++--------- .../components/sn74hc595/test.rp2040-ard.yaml | 37 ++++--------- tests/components/sonoff_d1/common.yaml | 12 +++++ .../components/sonoff_d1/test.esp32-ard.yaml | 15 ++---- .../sonoff_d1/test.esp32-c3-ard.yaml | 5 ++ .../sonoff_d1/test.esp32-c3-idf.yaml | 5 ++ .../components/sonoff_d1/test.esp32-idf.yaml | 15 ++---- .../sonoff_d1/test.esp8266-ard.yaml | 15 ++---- .../components/sonoff_d1/test.rp2040-ard.yaml | 5 ++ .../speaker/audio_dac.esp32-ard.yaml | 9 ++++ .../speaker/audio_dac.esp32-c3-ard.yaml | 9 ++++ .../speaker/audio_dac.esp32-c3-idf.yaml | 9 ++++ .../speaker/audio_dac.esp32-idf.yaml | 9 ++++ .../components/speaker/common-audio_dac.yaml | 36 +++++++++++++ tests/components/speaker/common.yaml | 26 ++++++++++ tests/components/speaker/test.esp32-ard.yaml | 33 +++--------- .../components/speaker/test.esp32-c3-ard.yaml | 33 +++--------- .../components/speaker/test.esp32-c3-idf.yaml | 33 +++--------- tests/components/speaker/test.esp32-idf.yaml | 42 +++------------ tests/components/speed/common.yaml | 9 ++++ tests/components/speed/test.esp32-ard.yaml | 12 ++--- tests/components/speed/test.esp32-c3-ard.yaml | 12 ++--- tests/components/speed/test.esp32-c3-idf.yaml | 12 ++--- tests/components/speed/test.esp32-idf.yaml | 12 ++--- tests/components/speed/test.esp8266-ard.yaml | 12 ++--- tests/components/speed/test.rp2040-ard.yaml | 12 ++--- tests/components/spi/common.yaml | 5 ++ tests/components/spi/test.esp32-ard.yaml | 11 ++-- tests/components/spi/test.esp32-c3-ard.yaml | 11 ++-- tests/components/spi/test.esp32-c3-idf.yaml | 11 ++-- tests/components/spi/test.esp32-idf.yaml | 11 ++-- tests/components/spi/test.esp32-s3-idf.yaml | 4 +- tests/components/spi/test.esp8266-ard.yaml | 11 ++-- tests/components/spi/test.rp2040-ard.yaml | 11 ++-- tests/components/spi_device/common.yaml | 11 ++++ .../components/spi_device/test.esp32-ard.yaml | 15 ++---- .../spi_device/test.esp32-c3-ard.yaml | 15 ++---- .../spi_device/test.esp32-c3-idf.yaml | 15 ++---- .../components/spi_device/test.esp32-idf.yaml | 15 ++---- .../spi_device/test.esp8266-ard.yaml | 15 ++---- .../spi_device/test.rp2040-ard.yaml | 15 ++---- tests/components/spi_led_strip/common.yaml | 12 +++++ .../spi_led_strip/test.esp32-ard.yaml | 16 ++---- .../spi_led_strip/test.esp32-c3-ard.yaml | 16 ++---- .../spi_led_strip/test.esp32-c3-idf.yaml | 16 ++---- .../spi_led_strip/test.esp32-idf.yaml | 16 ++---- .../spi_led_strip/test.esp8266-ard.yaml | 16 ++---- .../spi_led_strip/test.rp2040-ard.yaml | 16 ++---- tests/components/sps30/common.yaml | 36 +++++++++++++ tests/components/sps30/test.esp32-ard.yaml | 39 ++------------ tests/components/sps30/test.esp32-c3-ard.yaml | 39 ++------------ tests/components/sps30/test.esp32-c3-idf.yaml | 39 ++------------ tests/components/sps30/test.esp32-idf.yaml | 39 ++------------ tests/components/sps30/test.esp8266-ard.yaml | 39 ++------------ tests/components/sps30/test.rp2040-ard.yaml | 39 ++------------ tests/components/ssd1306_i2c/common.yaml | 25 +++++++++ .../ssd1306_i2c/test.esp32-ard.yaml | 29 ++--------- .../ssd1306_i2c/test.esp32-c3-ard.yaml | 29 ++--------- .../ssd1306_i2c/test.esp32-c3-idf.yaml | 29 ++--------- .../ssd1306_i2c/test.esp32-idf.yaml | 29 ++--------- .../ssd1306_i2c/test.esp8266-ard.yaml | 29 ++--------- .../ssd1306_i2c/test.rp2040-ard.yaml | 29 ++--------- tests/components/ssd1306_spi/common.yaml | 24 +++++++++ .../ssd1306_spi/test.esp32-ard.yaml | 31 +++-------- .../ssd1306_spi/test.esp32-c3-ard.yaml | 32 +++--------- .../ssd1306_spi/test.esp32-c3-idf.yaml | 32 +++--------- .../ssd1306_spi/test.esp32-idf.yaml | 31 +++-------- .../ssd1306_spi/test.esp8266-ard.yaml | 32 +++--------- .../ssd1306_spi/test.rp2040-ard.yaml | 32 +++--------- tests/components/ssd1322_spi/common.yaml | 24 +++++++++ .../ssd1322_spi/test.esp32-ard.yaml | 31 +++-------- .../ssd1322_spi/test.esp32-c3-ard.yaml | 32 +++--------- .../ssd1322_spi/test.esp32-c3-idf.yaml | 32 +++--------- .../ssd1322_spi/test.esp32-idf.yaml | 31 +++-------- .../ssd1322_spi/test.esp8266-ard.yaml | 32 +++--------- .../ssd1322_spi/test.rp2040-ard.yaml | 32 +++--------- tests/components/ssd1325_spi/common.yaml | 24 +++++++++ .../ssd1325_spi/test.esp32-ard.yaml | 31 +++-------- .../ssd1325_spi/test.esp32-c3-ard.yaml | 32 +++--------- .../ssd1325_spi/test.esp32-c3-idf.yaml | 32 +++--------- .../ssd1325_spi/test.esp32-idf.yaml | 31 +++-------- .../ssd1325_spi/test.esp8266-ard.yaml | 32 +++--------- .../ssd1325_spi/test.rp2040-ard.yaml | 32 +++--------- tests/components/ssd1327_i2c/common.yaml | 24 +++++++++ .../ssd1327_i2c/test.esp32-ard.yaml | 28 ++-------- .../ssd1327_i2c/test.esp32-c3-ard.yaml | 28 ++-------- .../ssd1327_i2c/test.esp32-c3-idf.yaml | 28 ++-------- .../ssd1327_i2c/test.esp32-idf.yaml | 28 ++-------- .../ssd1327_i2c/test.esp8266-ard.yaml | 28 ++-------- .../ssd1327_i2c/test.rp2040-ard.yaml | 28 ++-------- tests/components/ssd1327_spi/common.yaml | 24 +++++++++ .../ssd1327_spi/test.esp32-ard.yaml | 31 +++-------- .../ssd1327_spi/test.esp32-c3-ard.yaml | 32 +++--------- .../ssd1327_spi/test.esp32-c3-idf.yaml | 32 +++--------- .../ssd1327_spi/test.esp32-idf.yaml | 31 +++-------- .../ssd1327_spi/test.esp8266-ard.yaml | 32 +++--------- .../ssd1327_spi/test.rp2040-ard.yaml | 32 +++--------- tests/components/ssd1331_spi/common.yaml | 23 ++++++++ .../ssd1331_spi/test.esp32-ard.yaml | 30 +++-------- .../ssd1331_spi/test.esp32-c3-ard.yaml | 31 +++-------- .../ssd1331_spi/test.esp32-c3-idf.yaml | 31 +++-------- .../ssd1331_spi/test.esp32-idf.yaml | 30 +++-------- .../ssd1331_spi/test.esp8266-ard.yaml | 31 +++-------- .../ssd1331_spi/test.rp2040-ard.yaml | 31 +++-------- tests/components/ssd1351_spi/common.yaml | 24 +++++++++ .../ssd1351_spi/test.esp32-ard.yaml | 31 +++-------- .../ssd1351_spi/test.esp32-c3-ard.yaml | 32 +++--------- .../ssd1351_spi/test.esp32-c3-idf.yaml | 32 +++--------- .../ssd1351_spi/test.esp32-idf.yaml | 31 +++-------- .../ssd1351_spi/test.esp8266-ard.yaml | 32 +++--------- .../ssd1351_spi/test.rp2040-ard.yaml | 32 +++--------- tests/components/st7567_i2c/common.yaml | 23 ++++++++ .../components/st7567_i2c/test.esp32-ard.yaml | 27 ++-------- .../st7567_i2c/test.esp32-c3-ard.yaml | 27 ++-------- .../st7567_i2c/test.esp32-c3-idf.yaml | 27 ++-------- .../components/st7567_i2c/test.esp32-idf.yaml | 27 ++-------- .../st7567_i2c/test.esp8266-ard.yaml | 27 ++-------- .../st7567_i2c/test.rp2040-ard.yaml | 27 ++-------- tests/components/st7567_spi/common.yaml | 23 ++++++++ .../components/st7567_spi/test.esp32-ard.yaml | 30 +++-------- .../st7567_spi/test.esp32-c3-ard.yaml | 31 +++-------- .../st7567_spi/test.esp32-c3-idf.yaml | 31 +++-------- .../components/st7567_spi/test.esp32-idf.yaml | 30 +++-------- .../st7567_spi/test.esp8266-ard.yaml | 31 +++-------- .../st7567_spi/test.rp2040-ard.yaml | 31 +++-------- tests/components/st7701s/common.yaml | 42 ++++----------- .../components/st7701s/test.esp32-s3-idf.yaml | 10 ++++ tests/components/st7735/common.yaml | 28 ++++++++++ tests/components/st7735/test.esp32-ard.yaml | 35 +++---------- .../components/st7735/test.esp32-c3-ard.yaml | 36 +++---------- .../components/st7735/test.esp32-c3-idf.yaml | 36 +++---------- tests/components/st7735/test.esp32-idf.yaml | 35 +++---------- tests/components/st7735/test.esp8266-ard.yaml | 36 +++---------- tests/components/st7735/test.rp2040-ard.yaml | 36 +++---------- tests/components/st7789v/common.yaml | 24 +++++++++ tests/components/st7789v/test.esp32-ard.yaml | 31 +++-------- .../components/st7789v/test.esp32-c3-ard.yaml | 32 +++--------- .../components/st7789v/test.esp32-c3-idf.yaml | 32 +++--------- tests/components/st7789v/test.esp32-idf.yaml | 31 +++-------- .../components/st7789v/test.esp8266-ard.yaml | 32 +++--------- tests/components/st7789v/test.rp2040-ard.yaml | 32 +++--------- tests/components/st7920/common.yaml | 23 ++++++++ tests/components/st7920/test.esp32-ard.yaml | 28 ++-------- .../components/st7920/test.esp32-c3-ard.yaml | 29 +++-------- .../components/st7920/test.esp32-c3-idf.yaml | 29 +++-------- tests/components/st7920/test.esp32-idf.yaml | 28 ++-------- tests/components/st7920/test.esp8266-ard.yaml | 29 +++-------- tests/components/st7920/test.rp2040-ard.yaml | 29 +++-------- tests/components/sts3x/common.yaml | 10 ++++ tests/components/sts3x/test.esp32-ard.yaml | 13 ++--- tests/components/sts3x/test.esp32-c3-ard.yaml | 13 ++--- tests/components/sts3x/test.esp32-c3-idf.yaml | 13 ++--- tests/components/sts3x/test.esp32-idf.yaml | 13 ++--- tests/components/sts3x/test.esp8266-ard.yaml | 13 ++--- tests/components/sts3x/test.rp2040-ard.yaml | 13 ++--- tests/components/sun_gtil2/common.yaml | 40 ++++++++++++++ .../components/sun_gtil2/test.esp32-ard.yaml | 46 ++-------------- .../sun_gtil2/test.esp32-c3-ard.yaml | 46 ++-------------- .../sun_gtil2/test.esp32-c3-idf.yaml | 46 ++-------------- .../components/sun_gtil2/test.esp32-idf.yaml | 46 ++-------------- .../sun_gtil2/test.esp8266-ard.yaml | 46 ++-------------- .../components/sun_gtil2/test.rp2040-ard.yaml | 46 ++-------------- tests/components/sx1509/common.yaml | 33 ++++++++++++ tests/components/sx1509/test.esp32-ard.yaml | 36 ++----------- .../components/sx1509/test.esp32-c3-ard.yaml | 36 ++----------- .../components/sx1509/test.esp32-c3-idf.yaml | 36 ++----------- tests/components/sx1509/test.esp32-idf.yaml | 36 ++----------- tests/components/sx1509/test.esp8266-ard.yaml | 36 ++----------- tests/components/sx1509/test.rp2040-ard.yaml | 36 ++----------- 356 files changed, 2598 insertions(+), 5745 deletions(-) create mode 100644 tests/components/scd30/common.yaml create mode 100644 tests/components/scd4x/common.yaml create mode 100644 tests/components/sdm_meter/common.yaml create mode 100644 tests/components/sdp3x/common.yaml create mode 100644 tests/components/sds011/common.yaml create mode 100644 tests/components/selec_meter/common.yaml create mode 100644 tests/components/sen0321/common.yaml create mode 100644 tests/components/sen21231/common.yaml create mode 100644 tests/components/sen5x/common.yaml create mode 100644 tests/components/senseair/common.yaml create mode 100644 tests/components/servo/common.yaml create mode 100644 tests/components/sfa30/common.yaml create mode 100644 tests/components/sgp30/common.yaml create mode 100644 tests/components/sgp4x/common.yaml create mode 100644 tests/components/sht3xd/common.yaml create mode 100644 tests/components/sht4x/common.yaml create mode 100644 tests/components/shtcx/common.yaml create mode 100644 tests/components/sim800l/common.yaml create mode 100644 tests/components/sm300d2/common.yaml create mode 100644 tests/components/sml/common.yaml create mode 100644 tests/components/smt100/common.yaml create mode 100644 tests/components/sn74hc165/common.yaml create mode 100644 tests/components/sn74hc595/common.yaml create mode 100644 tests/components/sonoff_d1/common.yaml create mode 100644 tests/components/sonoff_d1/test.esp32-c3-ard.yaml create mode 100644 tests/components/sonoff_d1/test.esp32-c3-idf.yaml create mode 100644 tests/components/sonoff_d1/test.rp2040-ard.yaml create mode 100644 tests/components/speaker/audio_dac.esp32-ard.yaml create mode 100644 tests/components/speaker/audio_dac.esp32-c3-ard.yaml create mode 100644 tests/components/speaker/audio_dac.esp32-c3-idf.yaml create mode 100644 tests/components/speaker/audio_dac.esp32-idf.yaml create mode 100644 tests/components/speaker/common-audio_dac.yaml create mode 100644 tests/components/speaker/common.yaml create mode 100644 tests/components/speed/common.yaml create mode 100644 tests/components/spi/common.yaml create mode 100644 tests/components/spi_device/common.yaml create mode 100644 tests/components/spi_led_strip/common.yaml create mode 100644 tests/components/sps30/common.yaml create mode 100644 tests/components/ssd1306_i2c/common.yaml create mode 100644 tests/components/ssd1306_spi/common.yaml create mode 100644 tests/components/ssd1322_spi/common.yaml create mode 100644 tests/components/ssd1325_spi/common.yaml create mode 100644 tests/components/ssd1327_i2c/common.yaml create mode 100644 tests/components/ssd1327_spi/common.yaml create mode 100644 tests/components/ssd1331_spi/common.yaml create mode 100644 tests/components/ssd1351_spi/common.yaml create mode 100644 tests/components/st7567_i2c/common.yaml create mode 100644 tests/components/st7567_spi/common.yaml create mode 100644 tests/components/st7735/common.yaml create mode 100644 tests/components/st7789v/common.yaml create mode 100644 tests/components/st7920/common.yaml create mode 100644 tests/components/sts3x/common.yaml create mode 100644 tests/components/sun_gtil2/common.yaml create mode 100644 tests/components/sx1509/common.yaml diff --git a/tests/components/scd30/common.yaml b/tests/components/scd30/common.yaml new file mode 100644 index 0000000000..1c45c67af0 --- /dev/null +++ b/tests/components/scd30/common.yaml @@ -0,0 +1,20 @@ +i2c: + - id: i2c_scd30 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: scd30 + co2: + name: SCD30 CO2 + temperature: + id: scd30_temperature + name: SCD30 Temperature + humidity: + name: SCD30 Humidity + address: 0x61 + automatic_self_calibration: true + altitude_compensation: 10m + ambient_pressure_compensation: 961mBar + temperature_offset: 4.2C + update_interval: 15s diff --git a/tests/components/scd30/test.esp32-ard.yaml b/tests/components/scd30/test.esp32-ard.yaml index b48f8054c8..63c3bd6afd 100644 --- a/tests/components/scd30/test.esp32-ard.yaml +++ b/tests/components/scd30/test.esp32-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd30/test.esp32-c3-ard.yaml b/tests/components/scd30/test.esp32-c3-ard.yaml index 80f02a1b87..ee2c29ca4e 100644 --- a/tests/components/scd30/test.esp32-c3-ard.yaml +++ b/tests/components/scd30/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd30/test.esp32-c3-idf.yaml b/tests/components/scd30/test.esp32-c3-idf.yaml index 80f02a1b87..ee2c29ca4e 100644 --- a/tests/components/scd30/test.esp32-c3-idf.yaml +++ b/tests/components/scd30/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd30/test.esp32-idf.yaml b/tests/components/scd30/test.esp32-idf.yaml index b48f8054c8..63c3bd6afd 100644 --- a/tests/components/scd30/test.esp32-idf.yaml +++ b/tests/components/scd30/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd30/test.esp8266-ard.yaml b/tests/components/scd30/test.esp8266-ard.yaml index 80f02a1b87..ee2c29ca4e 100644 --- a/tests/components/scd30/test.esp8266-ard.yaml +++ b/tests/components/scd30/test.esp8266-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd30/test.rp2040-ard.yaml b/tests/components/scd30/test.rp2040-ard.yaml index 80f02a1b87..ee2c29ca4e 100644 --- a/tests/components/scd30/test.rp2040-ard.yaml +++ b/tests/components/scd30/test.rp2040-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd30 - co2: - name: SCD30 CO2 - temperature: - id: scd30_temperature - name: SCD30 Temperature - humidity: - name: SCD30 Humidity - address: 0x61 - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/common.yaml b/tests/components/scd4x/common.yaml new file mode 100644 index 0000000000..dfd35e57de --- /dev/null +++ b/tests/components/scd4x/common.yaml @@ -0,0 +1,20 @@ +i2c: + - id: i2c_scd4x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: scd4x + id: scd40 + co2: + name: SCD4X CO2 + temperature: + id: scd4x_temperature + name: SCD4X Temperature + humidity: + name: SCD4X Humidity + automatic_self_calibration: true + altitude_compensation: 10m + ambient_pressure_compensation: 961mBar + temperature_offset: 4.2C + update_interval: 15s diff --git a/tests/components/scd4x/test.esp32-ard.yaml b/tests/components/scd4x/test.esp32-ard.yaml index 02cec921d2..63c3bd6afd 100644 --- a/tests/components/scd4x/test.esp32-ard.yaml +++ b/tests/components/scd4x/test.esp32-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/test.esp32-c3-ard.yaml b/tests/components/scd4x/test.esp32-c3-ard.yaml index 353293be65..ee2c29ca4e 100644 --- a/tests/components/scd4x/test.esp32-c3-ard.yaml +++ b/tests/components/scd4x/test.esp32-c3-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/test.esp32-c3-idf.yaml b/tests/components/scd4x/test.esp32-c3-idf.yaml index 353293be65..ee2c29ca4e 100644 --- a/tests/components/scd4x/test.esp32-c3-idf.yaml +++ b/tests/components/scd4x/test.esp32-c3-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/test.esp32-idf.yaml b/tests/components/scd4x/test.esp32-idf.yaml index 02cec921d2..63c3bd6afd 100644 --- a/tests/components/scd4x/test.esp32-idf.yaml +++ b/tests/components/scd4x/test.esp32-idf.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/test.esp8266-ard.yaml b/tests/components/scd4x/test.esp8266-ard.yaml index 353293be65..ee2c29ca4e 100644 --- a/tests/components/scd4x/test.esp8266-ard.yaml +++ b/tests/components/scd4x/test.esp8266-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/scd4x/test.rp2040-ard.yaml b/tests/components/scd4x/test.rp2040-ard.yaml index 353293be65..ee2c29ca4e 100644 --- a/tests/components/scd4x/test.rp2040-ard.yaml +++ b/tests/components/scd4x/test.rp2040-ard.yaml @@ -1,20 +1,5 @@ -i2c: - - id: i2c_scd4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: scd4x - id: scd40 - co2: - name: SCD4X CO2 - temperature: - id: scd4x_temperature - name: SCD4X Temperature - humidity: - name: SCD4X Humidity - automatic_self_calibration: true - altitude_compensation: 10m - ambient_pressure_compensation: 961mBar - temperature_offset: 4.2C - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sdm_meter/common.yaml b/tests/components/sdm_meter/common.yaml new file mode 100644 index 0000000000..60c71a796b --- /dev/null +++ b/tests/components/sdm_meter/common.yaml @@ -0,0 +1,23 @@ +uart: + - id: uart_sdm_meter + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: sdm_meter + phase_a: + current: + name: Phase A Current + voltage: + name: Phase A Voltage + active_power: + name: Phase A Power + power_factor: + name: Phase A Power Factor + apparent_power: + name: Phase A Apparent Power + reactive_power: + name: Phase A Reactive Power + phase_angle: + name: Phase A Phase Angle diff --git a/tests/components/sdm_meter/test.esp32-ard.yaml b/tests/components/sdm_meter/test.esp32-ard.yaml index eb3958db19..f486544afa 100644 --- a/tests/components/sdm_meter/test.esp32-ard.yaml +++ b/tests/components/sdm_meter/test.esp32-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdm_meter/test.esp32-c3-ard.yaml b/tests/components/sdm_meter/test.esp32-c3-ard.yaml index 0c2144f983..b516342f3b 100644 --- a/tests/components/sdm_meter/test.esp32-c3-ard.yaml +++ b/tests/components/sdm_meter/test.esp32-c3-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdm_meter/test.esp32-c3-idf.yaml b/tests/components/sdm_meter/test.esp32-c3-idf.yaml index 0c2144f983..b516342f3b 100644 --- a/tests/components/sdm_meter/test.esp32-c3-idf.yaml +++ b/tests/components/sdm_meter/test.esp32-c3-idf.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdm_meter/test.esp32-idf.yaml b/tests/components/sdm_meter/test.esp32-idf.yaml index eb3958db19..f486544afa 100644 --- a/tests/components/sdm_meter/test.esp32-idf.yaml +++ b/tests/components/sdm_meter/test.esp32-idf.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdm_meter/test.esp8266-ard.yaml b/tests/components/sdm_meter/test.esp8266-ard.yaml index 0c2144f983..b516342f3b 100644 --- a/tests/components/sdm_meter/test.esp8266-ard.yaml +++ b/tests/components/sdm_meter/test.esp8266-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdm_meter/test.rp2040-ard.yaml b/tests/components/sdm_meter/test.rp2040-ard.yaml index 0c2144f983..b516342f3b 100644 --- a/tests/components/sdm_meter/test.rp2040-ard.yaml +++ b/tests/components/sdm_meter/test.rp2040-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sdm_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sdm_meter - phase_a: - current: - name: Phase A Current - voltage: - name: Phase A Voltage - active_power: - name: Phase A Power - power_factor: - name: Phase A Power Factor - apparent_power: - name: Phase A Apparent Power - reactive_power: - name: Phase A Reactive Power - phase_angle: - name: Phase A Phase Angle +<<: !include common.yaml diff --git a/tests/components/sdp3x/common.yaml b/tests/components/sdp3x/common.yaml new file mode 100644 index 0000000000..d3c5491ca5 --- /dev/null +++ b/tests/components/sdp3x/common.yaml @@ -0,0 +1,11 @@ +i2c: + - id: i2c_sdp3x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sdp3x + id: filter_pressure + name: HVAC Filter Pressure drop + accuracy_decimals: 3 + update_interval: 5s diff --git a/tests/components/sdp3x/test.esp32-ard.yaml b/tests/components/sdp3x/test.esp32-ard.yaml index 00666082eb..63c3bd6afd 100644 --- a/tests/components/sdp3x/test.esp32-ard.yaml +++ b/tests/components/sdp3x/test.esp32-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sdp3x/test.esp32-c3-ard.yaml b/tests/components/sdp3x/test.esp32-c3-ard.yaml index 42b90f1b81..ee2c29ca4e 100644 --- a/tests/components/sdp3x/test.esp32-c3-ard.yaml +++ b/tests/components/sdp3x/test.esp32-c3-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sdp3x/test.esp32-c3-idf.yaml b/tests/components/sdp3x/test.esp32-c3-idf.yaml index 42b90f1b81..ee2c29ca4e 100644 --- a/tests/components/sdp3x/test.esp32-c3-idf.yaml +++ b/tests/components/sdp3x/test.esp32-c3-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sdp3x/test.esp32-idf.yaml b/tests/components/sdp3x/test.esp32-idf.yaml index 00666082eb..63c3bd6afd 100644 --- a/tests/components/sdp3x/test.esp32-idf.yaml +++ b/tests/components/sdp3x/test.esp32-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sdp3x/test.esp8266-ard.yaml b/tests/components/sdp3x/test.esp8266-ard.yaml index 42b90f1b81..ee2c29ca4e 100644 --- a/tests/components/sdp3x/test.esp8266-ard.yaml +++ b/tests/components/sdp3x/test.esp8266-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sdp3x/test.rp2040-ard.yaml b/tests/components/sdp3x/test.rp2040-ard.yaml index 42b90f1b81..ee2c29ca4e 100644 --- a/tests/components/sdp3x/test.rp2040-ard.yaml +++ b/tests/components/sdp3x/test.rp2040-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_sdp3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sdp3x - id: filter_pressure - name: HVAC Filter Pressure drop - accuracy_decimals: 3 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sds011/common.yaml b/tests/components/sds011/common.yaml new file mode 100644 index 0000000000..c7574e1d7d --- /dev/null +++ b/tests/components/sds011/common.yaml @@ -0,0 +1,14 @@ +uart: + - id: uart_sdm_sds011 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 115200 + +sensor: + - platform: sds011 + pm_2_5: + name: SDS011 PM2.5 + pm_10_0: + name: SDS011 PM10.0 + rx_only: false + update_interval: 5min diff --git a/tests/components/sds011/test.esp32-ard.yaml b/tests/components/sds011/test.esp32-ard.yaml index 275390f14c..f486544afa 100644 --- a/tests/components/sds011/test.esp32-ard.yaml +++ b/tests/components/sds011/test.esp32-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/sds011/test.esp32-c3-ard.yaml b/tests/components/sds011/test.esp32-c3-ard.yaml index e680a62dfe..b516342f3b 100644 --- a/tests/components/sds011/test.esp32-c3-ard.yaml +++ b/tests/components/sds011/test.esp32-c3-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/sds011/test.esp32-c3-idf.yaml b/tests/components/sds011/test.esp32-c3-idf.yaml index e680a62dfe..b516342f3b 100644 --- a/tests/components/sds011/test.esp32-c3-idf.yaml +++ b/tests/components/sds011/test.esp32-c3-idf.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/sds011/test.esp32-idf.yaml b/tests/components/sds011/test.esp32-idf.yaml index 275390f14c..f486544afa 100644 --- a/tests/components/sds011/test.esp32-idf.yaml +++ b/tests/components/sds011/test.esp32-idf.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 17 - rx_pin: 16 - baud_rate: 115200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/sds011/test.esp8266-ard.yaml b/tests/components/sds011/test.esp8266-ard.yaml index e680a62dfe..b516342f3b 100644 --- a/tests/components/sds011/test.esp8266-ard.yaml +++ b/tests/components/sds011/test.esp8266-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/sds011/test.rp2040-ard.yaml b/tests/components/sds011/test.rp2040-ard.yaml index e680a62dfe..b516342f3b 100644 --- a/tests/components/sds011/test.rp2040-ard.yaml +++ b/tests/components/sds011/test.rp2040-ard.yaml @@ -1,14 +1,5 @@ -uart: - - id: uart_sdm_sds011 - tx_pin: 4 - rx_pin: 5 - baud_rate: 115200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sds011 - pm_2_5: - name: SDS011 PM2.5 - pm_10_0: - name: SDS011 PM10.0 - rx_only: false - update_interval: 5min +<<: !include common.yaml diff --git a/tests/components/selec_meter/common.yaml b/tests/components/selec_meter/common.yaml new file mode 100644 index 0000000000..f2714ce828 --- /dev/null +++ b/tests/components/selec_meter/common.yaml @@ -0,0 +1,45 @@ +uart: + - id: uart_selec_meter + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: selec_meter + total_active_energy: + name: SelecEM2M Total Active Energy + import_active_energy: + name: SelecEM2M Import Active Energy + export_active_energy: + name: SelecEM2M Export Active Energy + total_reactive_energy: + name: SelecEM2M Total Reactive Energy + import_reactive_energy: + name: SelecEM2M Import Reactive Energy + export_reactive_energy: + name: SelecEM2M Export Reactive Energy + apparent_energy: + name: SelecEM2M Apparent Energy + active_power: + name: SelecEM2M Active Power + reactive_power: + name: SelecEM2M Reactive Power + apparent_power: + name: SelecEM2M Apparent Power + voltage: + name: SelecEM2M Voltage + current: + name: SelecEM2M Current + power_factor: + name: SelecEM2M Power Factor + frequency: + name: SelecEM2M Frequency + maximum_demand_active_power: + name: SelecEM2M Maximum Demand Active Power + disabled_by_default: true + maximum_demand_reactive_power: + name: SelecEM2M Maximum Demand Reactive Power + disabled_by_default: true + maximum_demand_apparent_power: + name: SelecEM2M Maximum Demand Apparent Power + disabled_by_default: true diff --git a/tests/components/selec_meter/test.esp32-ard.yaml b/tests/components/selec_meter/test.esp32-ard.yaml index 648adc1757..f486544afa 100644 --- a/tests/components/selec_meter/test.esp32-ard.yaml +++ b/tests/components/selec_meter/test.esp32-ard.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/selec_meter/test.esp32-c3-ard.yaml b/tests/components/selec_meter/test.esp32-c3-ard.yaml index 5f6e69f96f..b516342f3b 100644 --- a/tests/components/selec_meter/test.esp32-c3-ard.yaml +++ b/tests/components/selec_meter/test.esp32-c3-ard.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/selec_meter/test.esp32-c3-idf.yaml b/tests/components/selec_meter/test.esp32-c3-idf.yaml index 5f6e69f96f..b516342f3b 100644 --- a/tests/components/selec_meter/test.esp32-c3-idf.yaml +++ b/tests/components/selec_meter/test.esp32-c3-idf.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/selec_meter/test.esp32-idf.yaml b/tests/components/selec_meter/test.esp32-idf.yaml index 648adc1757..f486544afa 100644 --- a/tests/components/selec_meter/test.esp32-idf.yaml +++ b/tests/components/selec_meter/test.esp32-idf.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/selec_meter/test.esp8266-ard.yaml b/tests/components/selec_meter/test.esp8266-ard.yaml index 5f6e69f96f..b516342f3b 100644 --- a/tests/components/selec_meter/test.esp8266-ard.yaml +++ b/tests/components/selec_meter/test.esp8266-ard.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/selec_meter/test.rp2040-ard.yaml b/tests/components/selec_meter/test.rp2040-ard.yaml index 5f6e69f96f..b516342f3b 100644 --- a/tests/components/selec_meter/test.rp2040-ard.yaml +++ b/tests/components/selec_meter/test.rp2040-ard.yaml @@ -1,45 +1,5 @@ -uart: - - id: uart_selec_meter - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: selec_meter - total_active_energy: - name: SelecEM2M Total Active Energy - import_active_energy: - name: SelecEM2M Import Active Energy - export_active_energy: - name: SelecEM2M Export Active Energy - total_reactive_energy: - name: SelecEM2M Total Reactive Energy - import_reactive_energy: - name: SelecEM2M Import Reactive Energy - export_reactive_energy: - name: SelecEM2M Export Reactive Energy - apparent_energy: - name: SelecEM2M Apparent Energy - active_power: - name: SelecEM2M Active Power - reactive_power: - name: SelecEM2M Reactive Power - apparent_power: - name: SelecEM2M Apparent Power - voltage: - name: SelecEM2M Voltage - current: - name: SelecEM2M Current - power_factor: - name: SelecEM2M Power Factor - frequency: - name: SelecEM2M Frequency - maximum_demand_active_power: - name: SelecEM2M Maximum Demand Active Power - disabled_by_default: true - maximum_demand_reactive_power: - name: SelecEM2M Maximum Demand Reactive Power - disabled_by_default: true - maximum_demand_apparent_power: - name: SelecEM2M Maximum Demand Apparent Power - disabled_by_default: true +<<: !include common.yaml diff --git a/tests/components/sen0321/common.yaml b/tests/components/sen0321/common.yaml new file mode 100644 index 0000000000..8b9fdff4a1 --- /dev/null +++ b/tests/components/sen0321/common.yaml @@ -0,0 +1,10 @@ +i2c: + - id: i2c_sen0321 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sen0321 + name: Workshop Ozone Sensor + id: sen0321_ozone + update_interval: 10s diff --git a/tests/components/sen0321/test.esp32-ard.yaml b/tests/components/sen0321/test.esp32-ard.yaml index 44f76bf5e6..63c3bd6afd 100644 --- a/tests/components/sen0321/test.esp32-ard.yaml +++ b/tests/components/sen0321/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen0321/test.esp32-c3-ard.yaml b/tests/components/sen0321/test.esp32-c3-ard.yaml index 7fa461a7fa..ee2c29ca4e 100644 --- a/tests/components/sen0321/test.esp32-c3-ard.yaml +++ b/tests/components/sen0321/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen0321/test.esp32-c3-idf.yaml b/tests/components/sen0321/test.esp32-c3-idf.yaml index 7fa461a7fa..ee2c29ca4e 100644 --- a/tests/components/sen0321/test.esp32-c3-idf.yaml +++ b/tests/components/sen0321/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen0321/test.esp32-idf.yaml b/tests/components/sen0321/test.esp32-idf.yaml index 44f76bf5e6..63c3bd6afd 100644 --- a/tests/components/sen0321/test.esp32-idf.yaml +++ b/tests/components/sen0321/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen0321/test.esp8266-ard.yaml b/tests/components/sen0321/test.esp8266-ard.yaml index 7fa461a7fa..ee2c29ca4e 100644 --- a/tests/components/sen0321/test.esp8266-ard.yaml +++ b/tests/components/sen0321/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen0321/test.rp2040-ard.yaml b/tests/components/sen0321/test.rp2040-ard.yaml index 7fa461a7fa..ee2c29ca4e 100644 --- a/tests/components/sen0321/test.rp2040-ard.yaml +++ b/tests/components/sen0321/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sen0321 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen0321 - name: Workshop Ozone Sensor - id: sen0321_ozone - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sen21231/common.yaml b/tests/components/sen21231/common.yaml new file mode 100644 index 0000000000..6fa1d04aa2 --- /dev/null +++ b/tests/components/sen21231/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_sen21231 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sen21231 + id: sen21231_sensor1 + name: Person Sensor diff --git a/tests/components/sen21231/test.esp32-ard.yaml b/tests/components/sen21231/test.esp32-ard.yaml index 3173683f17..63c3bd6afd 100644 --- a/tests/components/sen21231/test.esp32-ard.yaml +++ b/tests/components/sen21231/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen21231/test.esp32-c3-ard.yaml b/tests/components/sen21231/test.esp32-c3-ard.yaml index efd7843f56..ee2c29ca4e 100644 --- a/tests/components/sen21231/test.esp32-c3-ard.yaml +++ b/tests/components/sen21231/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen21231/test.esp32-c3-idf.yaml b/tests/components/sen21231/test.esp32-c3-idf.yaml index efd7843f56..ee2c29ca4e 100644 --- a/tests/components/sen21231/test.esp32-c3-idf.yaml +++ b/tests/components/sen21231/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen21231/test.esp32-idf.yaml b/tests/components/sen21231/test.esp32-idf.yaml index 3173683f17..63c3bd6afd 100644 --- a/tests/components/sen21231/test.esp32-idf.yaml +++ b/tests/components/sen21231/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen21231/test.esp8266-ard.yaml b/tests/components/sen21231/test.esp8266-ard.yaml index efd7843f56..ee2c29ca4e 100644 --- a/tests/components/sen21231/test.esp8266-ard.yaml +++ b/tests/components/sen21231/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen21231/test.rp2040-ard.yaml b/tests/components/sen21231/test.rp2040-ard.yaml index efd7843f56..ee2c29ca4e 100644 --- a/tests/components/sen21231/test.rp2040-ard.yaml +++ b/tests/components/sen21231/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_sen21231 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen21231 - id: sen21231_sensor1 - name: Person Sensor +<<: !include common.yaml diff --git a/tests/components/sen5x/common.yaml b/tests/components/sen5x/common.yaml new file mode 100644 index 0000000000..9adf268048 --- /dev/null +++ b/tests/components/sen5x/common.yaml @@ -0,0 +1,49 @@ +i2c: + - id: i2c_sen5x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sen5x + id: sen54 + temperature: + name: Temperature + accuracy_decimals: 1 + humidity: + name: Humidity + accuracy_decimals: 0 + pm_1_0: + name: PM <1µm Weight concentration + id: pm_1_0 + accuracy_decimals: 1 + pm_2_5: + name: PM <2.5µm Weight concentration + id: pm_2_5 + accuracy_decimals: 1 + pm_4_0: + name: PM <4µm Weight concentration + id: pm_4_0 + accuracy_decimals: 1 + pm_10_0: + name: PM <10µm Weight concentration + id: pm_10_0 + accuracy_decimals: 1 + nox: + name: NOx + voc: + name: VOC + algorithm_tuning: + index_offset: 100 + learning_time_offset_hours: 12 + learning_time_gain_hours: 12 + gating_max_duration_minutes: 180 + std_initial: 50 + gain_factor: 230 + temperature_compensation: + offset: 0 + normalized_offset_slope: 0 + time_constant: 0 + auto_cleaning_interval: 604800s + acceleration_mode: low + store_baseline: true + address: 0x69 diff --git a/tests/components/sen5x/test.esp32-ard.yaml b/tests/components/sen5x/test.esp32-ard.yaml index b8f89c435f..63c3bd6afd 100644 --- a/tests/components/sen5x/test.esp32-ard.yaml +++ b/tests/components/sen5x/test.esp32-ard.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/sen5x/test.esp32-c3-ard.yaml b/tests/components/sen5x/test.esp32-c3-ard.yaml index 3352a59b17..ee2c29ca4e 100644 --- a/tests/components/sen5x/test.esp32-c3-ard.yaml +++ b/tests/components/sen5x/test.esp32-c3-ard.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/sen5x/test.esp32-c3-idf.yaml b/tests/components/sen5x/test.esp32-c3-idf.yaml index 3352a59b17..ee2c29ca4e 100644 --- a/tests/components/sen5x/test.esp32-c3-idf.yaml +++ b/tests/components/sen5x/test.esp32-c3-idf.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/sen5x/test.esp32-idf.yaml b/tests/components/sen5x/test.esp32-idf.yaml index b8f89c435f..63c3bd6afd 100644 --- a/tests/components/sen5x/test.esp32-idf.yaml +++ b/tests/components/sen5x/test.esp32-idf.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/sen5x/test.esp8266-ard.yaml b/tests/components/sen5x/test.esp8266-ard.yaml index 3352a59b17..ee2c29ca4e 100644 --- a/tests/components/sen5x/test.esp8266-ard.yaml +++ b/tests/components/sen5x/test.esp8266-ard.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/sen5x/test.rp2040-ard.yaml b/tests/components/sen5x/test.rp2040-ard.yaml index 3352a59b17..ee2c29ca4e 100644 --- a/tests/components/sen5x/test.rp2040-ard.yaml +++ b/tests/components/sen5x/test.rp2040-ard.yaml @@ -1,49 +1,5 @@ -i2c: - - id: i2c_sen5x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sen5x - id: sen54 - temperature: - name: Temperature - accuracy_decimals: 1 - humidity: - name: Humidity - accuracy_decimals: 0 - pm_1_0: - name: PM <1µm Weight concentration - id: pm_1_0 - accuracy_decimals: 1 - pm_2_5: - name: PM <2.5µm Weight concentration - id: pm_2_5 - accuracy_decimals: 1 - pm_4_0: - name: PM <4µm Weight concentration - id: pm_4_0 - accuracy_decimals: 1 - pm_10_0: - name: PM <10µm Weight concentration - id: pm_10_0 - accuracy_decimals: 1 - nox: - name: NOx - voc: - name: VOC - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - temperature_compensation: - offset: 0 - normalized_offset_slope: 0 - time_constant: 0 - auto_cleaning_interval: 604800s - acceleration_mode: low - store_baseline: true - address: 0x69 +<<: !include common.yaml diff --git a/tests/components/senseair/common.yaml b/tests/components/senseair/common.yaml new file mode 100644 index 0000000000..23a933affe --- /dev/null +++ b/tests/components/senseair/common.yaml @@ -0,0 +1,19 @@ +uart: + - id: uart_senseair + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: senseair + id: senseair0 + co2: + name: SenseAir CO2 Value + on_value: + then: + - senseair.background_calibration: senseair0 + - senseair.background_calibration_result: senseair0 + - senseair.abc_get_period: senseair0 + - senseair.abc_enable: senseair0 + - senseair.abc_disable: senseair0 + update_interval: 15s diff --git a/tests/components/senseair/test.esp32-ard.yaml b/tests/components/senseair/test.esp32-ard.yaml index daa4645f59..f486544afa 100644 --- a/tests/components/senseair/test.esp32-ard.yaml +++ b/tests/components/senseair/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/senseair/test.esp32-c3-ard.yaml b/tests/components/senseair/test.esp32-c3-ard.yaml index 41a441f496..b516342f3b 100644 --- a/tests/components/senseair/test.esp32-c3-ard.yaml +++ b/tests/components/senseair/test.esp32-c3-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/senseair/test.esp32-c3-idf.yaml b/tests/components/senseair/test.esp32-c3-idf.yaml index 41a441f496..b516342f3b 100644 --- a/tests/components/senseair/test.esp32-c3-idf.yaml +++ b/tests/components/senseair/test.esp32-c3-idf.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/senseair/test.esp32-idf.yaml b/tests/components/senseair/test.esp32-idf.yaml index daa4645f59..f486544afa 100644 --- a/tests/components/senseair/test.esp32-idf.yaml +++ b/tests/components/senseair/test.esp32-idf.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/senseair/test.esp8266-ard.yaml b/tests/components/senseair/test.esp8266-ard.yaml index 41a441f496..b516342f3b 100644 --- a/tests/components/senseair/test.esp8266-ard.yaml +++ b/tests/components/senseair/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/senseair/test.rp2040-ard.yaml b/tests/components/senseair/test.rp2040-ard.yaml index 41a441f496..b516342f3b 100644 --- a/tests/components/senseair/test.rp2040-ard.yaml +++ b/tests/components/senseair/test.rp2040-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_senseair - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: senseair - id: senseair0 - co2: - name: SenseAir CO2 Value - on_value: - then: - - senseair.background_calibration: senseair0 - - senseair.background_calibration_result: senseair0 - - senseair.abc_get_period: senseair0 - - senseair.abc_enable: senseair0 - - senseair.abc_disable: senseair0 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/servo/common.yaml b/tests/components/servo/common.yaml new file mode 100644 index 0000000000..2cfa370c32 --- /dev/null +++ b/tests/components/servo/common.yaml @@ -0,0 +1,19 @@ +esphome: + on_boot: + then: + - servo.write: + id: test_servo + level: -100.0% + - servo.detach: test_servo + +output: + - platform: ${output_platform} + id: servo_output_1 + pin: ${pin} + +servo: + id: test_servo + output: servo_output_1 + restore: true + min_level: 4% + max_level: 8% diff --git a/tests/components/servo/test.esp32-ard.yaml b/tests/components/servo/test.esp32-ard.yaml index e769f055b4..26da1ce1d6 100644 --- a/tests/components/servo/test.esp32-ard.yaml +++ b/tests/components/servo/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: ledc + pin: GPIO14 -output: - - platform: ledc - id: servo_output_1 - pin: 12 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/servo/test.esp32-c3-ard.yaml b/tests/components/servo/test.esp32-c3-ard.yaml index 29ebea3359..7476963591 100644 --- a/tests/components/servo/test.esp32-c3-ard.yaml +++ b/tests/components/servo/test.esp32-c3-ard.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: ledc + pin: GPIO4 -output: - - platform: ledc - id: servo_output_1 - pin: 1 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/servo/test.esp32-c3-idf.yaml b/tests/components/servo/test.esp32-c3-idf.yaml index 29ebea3359..7476963591 100644 --- a/tests/components/servo/test.esp32-c3-idf.yaml +++ b/tests/components/servo/test.esp32-c3-idf.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: ledc + pin: GPIO4 -output: - - platform: ledc - id: servo_output_1 - pin: 1 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/servo/test.esp32-idf.yaml b/tests/components/servo/test.esp32-idf.yaml index e769f055b4..26da1ce1d6 100644 --- a/tests/components/servo/test.esp32-idf.yaml +++ b/tests/components/servo/test.esp32-idf.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: ledc + pin: GPIO14 -output: - - platform: ledc - id: servo_output_1 - pin: 12 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/servo/test.esp8266-ard.yaml b/tests/components/servo/test.esp8266-ard.yaml index 48b4421641..23a7f43b42 100644 --- a/tests/components/servo/test.esp8266-ard.yaml +++ b/tests/components/servo/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: esp8266_pwm + pin: GPIO14 -output: - - platform: esp8266_pwm - id: servo_output_1 - pin: 12 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/servo/test.rp2040-ard.yaml b/tests/components/servo/test.rp2040-ard.yaml index 75efa9407e..d70f7c74ec 100644 --- a/tests/components/servo/test.rp2040-ard.yaml +++ b/tests/components/servo/test.rp2040-ard.yaml @@ -1,19 +1,5 @@ -esphome: - on_boot: - then: - - servo.write: - id: test_servo - level: -100.0% - - servo.detach: test_servo +substitutions: + output_platform: rp2040_pwm + pin: GPIO4 -output: - - platform: rp2040_pwm - id: servo_output_1 - pin: 12 - -servo: - id: test_servo - output: servo_output_1 - restore: true - min_level: 4% - max_level: 8% +<<: !include common.yaml diff --git a/tests/components/sfa30/common.yaml b/tests/components/sfa30/common.yaml new file mode 100644 index 0000000000..e3b38aa7fb --- /dev/null +++ b/tests/components/sfa30/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_sfa30 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sfa30 + formaldehyde: + name: SFA30 formaldehyde + temperature: + name: SFA30 temperature + humidity: + name: SFA30 humidity + address: 0x5D + update_interval: 30s diff --git a/tests/components/sfa30/test.esp32-ard.yaml b/tests/components/sfa30/test.esp32-ard.yaml index dc7e4988e5..63c3bd6afd 100644 --- a/tests/components/sfa30/test.esp32-ard.yaml +++ b/tests/components/sfa30/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sfa30/test.esp32-c3-ard.yaml b/tests/components/sfa30/test.esp32-c3-ard.yaml index 119059e4e2..ee2c29ca4e 100644 --- a/tests/components/sfa30/test.esp32-c3-ard.yaml +++ b/tests/components/sfa30/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sfa30/test.esp32-c3-idf.yaml b/tests/components/sfa30/test.esp32-c3-idf.yaml index 119059e4e2..ee2c29ca4e 100644 --- a/tests/components/sfa30/test.esp32-c3-idf.yaml +++ b/tests/components/sfa30/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sfa30/test.esp32-idf.yaml b/tests/components/sfa30/test.esp32-idf.yaml index dc7e4988e5..63c3bd6afd 100644 --- a/tests/components/sfa30/test.esp32-idf.yaml +++ b/tests/components/sfa30/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sfa30/test.esp8266-ard.yaml b/tests/components/sfa30/test.esp8266-ard.yaml index 119059e4e2..ee2c29ca4e 100644 --- a/tests/components/sfa30/test.esp8266-ard.yaml +++ b/tests/components/sfa30/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sfa30/test.rp2040-ard.yaml b/tests/components/sfa30/test.rp2040-ard.yaml index 119059e4e2..ee2c29ca4e 100644 --- a/tests/components/sfa30/test.rp2040-ard.yaml +++ b/tests/components/sfa30/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sfa30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sfa30 - formaldehyde: - name: "SFA30 formaldehyde" - temperature: - name: "SFA30 temperature" - humidity: - name: "SFA30 humidity" - address: 0x5D - update_interval: 30s +<<: !include common.yaml diff --git a/tests/components/sgp30/common.yaml b/tests/components/sgp30/common.yaml new file mode 100644 index 0000000000..1db5bc67d1 --- /dev/null +++ b/tests/components/sgp30/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_sgp30 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sgp30 + eco2: + name: Workshop eCO2 + accuracy_decimals: 1 + tvoc: + name: Workshop TVOC + accuracy_decimals: 1 + address: 0x58 + update_interval: 5s diff --git a/tests/components/sgp30/test.esp32-ard.yaml b/tests/components/sgp30/test.esp32-ard.yaml index 6ea23c25cd..63c3bd6afd 100644 --- a/tests/components/sgp30/test.esp32-ard.yaml +++ b/tests/components/sgp30/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp30/test.esp32-c3-ard.yaml b/tests/components/sgp30/test.esp32-c3-ard.yaml index 45de67e94b..ee2c29ca4e 100644 --- a/tests/components/sgp30/test.esp32-c3-ard.yaml +++ b/tests/components/sgp30/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp30/test.esp32-c3-idf.yaml b/tests/components/sgp30/test.esp32-c3-idf.yaml index 45de67e94b..ee2c29ca4e 100644 --- a/tests/components/sgp30/test.esp32-c3-idf.yaml +++ b/tests/components/sgp30/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp30/test.esp32-idf.yaml b/tests/components/sgp30/test.esp32-idf.yaml index 6ea23c25cd..63c3bd6afd 100644 --- a/tests/components/sgp30/test.esp32-idf.yaml +++ b/tests/components/sgp30/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp30/test.esp8266-ard.yaml b/tests/components/sgp30/test.esp8266-ard.yaml index 45de67e94b..ee2c29ca4e 100644 --- a/tests/components/sgp30/test.esp8266-ard.yaml +++ b/tests/components/sgp30/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp30/test.rp2040-ard.yaml b/tests/components/sgp30/test.rp2040-ard.yaml index 45de67e94b..ee2c29ca4e 100644 --- a/tests/components/sgp30/test.rp2040-ard.yaml +++ b/tests/components/sgp30/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_sgp30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp30 - eco2: - name: Workshop eCO2 - accuracy_decimals: 1 - tvoc: - name: Workshop TVOC - accuracy_decimals: 1 - address: 0x58 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/common.yaml b/tests/components/sgp4x/common.yaml new file mode 100644 index 0000000000..adb678d542 --- /dev/null +++ b/tests/components/sgp4x/common.yaml @@ -0,0 +1,27 @@ +i2c: + - id: i2c_sgp4x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sgp4x + voc: + name: VOC Index + id: sgp40_voc_index + algorithm_tuning: + index_offset: 100 + learning_time_offset_hours: 12 + learning_time_gain_hours: 12 + gating_max_duration_minutes: 180 + std_initial: 50 + gain_factor: 230 + nox: + name: NOx + algorithm_tuning: + index_offset: 100 + learning_time_offset_hours: 12 + learning_time_gain_hours: 12 + gating_max_duration_minutes: 180 + std_initial: 50 + gain_factor: 230 + update_interval: 5s diff --git a/tests/components/sgp4x/test.esp32-ard.yaml b/tests/components/sgp4x/test.esp32-ard.yaml index c7380b5a10..63c3bd6afd 100644 --- a/tests/components/sgp4x/test.esp32-ard.yaml +++ b/tests/components/sgp4x/test.esp32-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/test.esp32-c3-ard.yaml b/tests/components/sgp4x/test.esp32-c3-ard.yaml index b2876478bd..ee2c29ca4e 100644 --- a/tests/components/sgp4x/test.esp32-c3-ard.yaml +++ b/tests/components/sgp4x/test.esp32-c3-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/test.esp32-c3-idf.yaml b/tests/components/sgp4x/test.esp32-c3-idf.yaml index b2876478bd..ee2c29ca4e 100644 --- a/tests/components/sgp4x/test.esp32-c3-idf.yaml +++ b/tests/components/sgp4x/test.esp32-c3-idf.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/test.esp32-idf.yaml b/tests/components/sgp4x/test.esp32-idf.yaml index c7380b5a10..63c3bd6afd 100644 --- a/tests/components/sgp4x/test.esp32-idf.yaml +++ b/tests/components/sgp4x/test.esp32-idf.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/test.esp8266-ard.yaml b/tests/components/sgp4x/test.esp8266-ard.yaml index b2876478bd..ee2c29ca4e 100644 --- a/tests/components/sgp4x/test.esp8266-ard.yaml +++ b/tests/components/sgp4x/test.esp8266-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sgp4x/test.rp2040-ard.yaml b/tests/components/sgp4x/test.rp2040-ard.yaml index b2876478bd..ee2c29ca4e 100644 --- a/tests/components/sgp4x/test.rp2040-ard.yaml +++ b/tests/components/sgp4x/test.rp2040-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_sgp4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sgp4x - voc: - name: VOC Index - id: sgp40_voc_index - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - nox: - name: NOx - algorithm_tuning: - index_offset: 100 - learning_time_offset_hours: 12 - learning_time_gain_hours: 12 - gating_max_duration_minutes: 180 - std_initial: 50 - gain_factor: 230 - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/sht3xd/common.yaml b/tests/components/sht3xd/common.yaml new file mode 100644 index 0000000000..2426ebfbb9 --- /dev/null +++ b/tests/components/sht3xd/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_sht3xd + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sht3xd + temperature: + name: SHT3XD Temperature + humidity: + name: SHT3XD Humidity + address: 0x44 + update_interval: 15s diff --git a/tests/components/sht3xd/test.esp32-ard.yaml b/tests/components/sht3xd/test.esp32-ard.yaml index 2b6ee50760..63c3bd6afd 100644 --- a/tests/components/sht3xd/test.esp32-ard.yaml +++ b/tests/components/sht3xd/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht3xd/test.esp32-c3-ard.yaml b/tests/components/sht3xd/test.esp32-c3-ard.yaml index 0409ff65c6..ee2c29ca4e 100644 --- a/tests/components/sht3xd/test.esp32-c3-ard.yaml +++ b/tests/components/sht3xd/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht3xd/test.esp32-c3-idf.yaml b/tests/components/sht3xd/test.esp32-c3-idf.yaml index 0409ff65c6..ee2c29ca4e 100644 --- a/tests/components/sht3xd/test.esp32-c3-idf.yaml +++ b/tests/components/sht3xd/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht3xd/test.esp32-idf.yaml b/tests/components/sht3xd/test.esp32-idf.yaml index 2b6ee50760..63c3bd6afd 100644 --- a/tests/components/sht3xd/test.esp32-idf.yaml +++ b/tests/components/sht3xd/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht3xd/test.esp8266-ard.yaml b/tests/components/sht3xd/test.esp8266-ard.yaml index 0409ff65c6..ee2c29ca4e 100644 --- a/tests/components/sht3xd/test.esp8266-ard.yaml +++ b/tests/components/sht3xd/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht3xd/test.rp2040-ard.yaml b/tests/components/sht3xd/test.rp2040-ard.yaml index 0409ff65c6..ee2c29ca4e 100644 --- a/tests/components/sht3xd/test.rp2040-ard.yaml +++ b/tests/components/sht3xd/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht3xd - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht3xd - temperature: - name: SHT3XD Temperature - humidity: - name: SHT3XD Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/common.yaml b/tests/components/sht4x/common.yaml new file mode 100644 index 0000000000..703a8fa32b --- /dev/null +++ b/tests/components/sht4x/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_sht4x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sht4x + temperature: + name: SHT4X Temperature + humidity: + name: SHT4X Humidity + address: 0x44 + update_interval: 15s diff --git a/tests/components/sht4x/test.esp32-ard.yaml b/tests/components/sht4x/test.esp32-ard.yaml index 13ec524d7d..63c3bd6afd 100644 --- a/tests/components/sht4x/test.esp32-ard.yaml +++ b/tests/components/sht4x/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/test.esp32-c3-ard.yaml b/tests/components/sht4x/test.esp32-c3-ard.yaml index 0bcdd864f6..ee2c29ca4e 100644 --- a/tests/components/sht4x/test.esp32-c3-ard.yaml +++ b/tests/components/sht4x/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/test.esp32-c3-idf.yaml b/tests/components/sht4x/test.esp32-c3-idf.yaml index 0bcdd864f6..ee2c29ca4e 100644 --- a/tests/components/sht4x/test.esp32-c3-idf.yaml +++ b/tests/components/sht4x/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/test.esp32-idf.yaml b/tests/components/sht4x/test.esp32-idf.yaml index 13ec524d7d..63c3bd6afd 100644 --- a/tests/components/sht4x/test.esp32-idf.yaml +++ b/tests/components/sht4x/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/test.esp8266-ard.yaml b/tests/components/sht4x/test.esp8266-ard.yaml index 0bcdd864f6..ee2c29ca4e 100644 --- a/tests/components/sht4x/test.esp8266-ard.yaml +++ b/tests/components/sht4x/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sht4x/test.rp2040-ard.yaml b/tests/components/sht4x/test.rp2040-ard.yaml index 0bcdd864f6..ee2c29ca4e 100644 --- a/tests/components/sht4x/test.rp2040-ard.yaml +++ b/tests/components/sht4x/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_sht4x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sht4x - temperature: - name: SHT4X Temperature - humidity: - name: SHT4X Humidity - address: 0x44 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/common.yaml b/tests/components/shtcx/common.yaml new file mode 100644 index 0000000000..0211319124 --- /dev/null +++ b/tests/components/shtcx/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_shtcx + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: shtcx + temperature: + name: SHTCX Temperature + humidity: + name: SHTCX Humidity + address: 0x70 + update_interval: 15s diff --git a/tests/components/shtcx/test.esp32-ard.yaml b/tests/components/shtcx/test.esp32-ard.yaml index 619bac9548..63c3bd6afd 100644 --- a/tests/components/shtcx/test.esp32-ard.yaml +++ b/tests/components/shtcx/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/test.esp32-c3-ard.yaml b/tests/components/shtcx/test.esp32-c3-ard.yaml index c1c7a2a63f..ee2c29ca4e 100644 --- a/tests/components/shtcx/test.esp32-c3-ard.yaml +++ b/tests/components/shtcx/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/test.esp32-c3-idf.yaml b/tests/components/shtcx/test.esp32-c3-idf.yaml index c1c7a2a63f..ee2c29ca4e 100644 --- a/tests/components/shtcx/test.esp32-c3-idf.yaml +++ b/tests/components/shtcx/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/test.esp32-idf.yaml b/tests/components/shtcx/test.esp32-idf.yaml index 619bac9548..63c3bd6afd 100644 --- a/tests/components/shtcx/test.esp32-idf.yaml +++ b/tests/components/shtcx/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/test.esp8266-ard.yaml b/tests/components/shtcx/test.esp8266-ard.yaml index c1c7a2a63f..ee2c29ca4e 100644 --- a/tests/components/shtcx/test.esp8266-ard.yaml +++ b/tests/components/shtcx/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/shtcx/test.rp2040-ard.yaml b/tests/components/shtcx/test.rp2040-ard.yaml index c1c7a2a63f..ee2c29ca4e 100644 --- a/tests/components/shtcx/test.rp2040-ard.yaml +++ b/tests/components/shtcx/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_shtcx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: shtcx - temperature: - name: SHTCX Temperature - humidity: - name: SHTCX Humidity - address: 0x70 - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/sim800l/common.yaml b/tests/components/sim800l/common.yaml new file mode 100644 index 0000000000..1b4e2e1af6 --- /dev/null +++ b/tests/components/sim800l/common.yaml @@ -0,0 +1,37 @@ +esphome: + on_boot: + then: + - sim800l.send_sms: + recipient: '+15551234567' + message: Hello there + - sim800l.dial: + recipient: '+15551234567' + - sim800l.connect + - sim800l.disconnect + - sim800l.send_ussd: + ussd: test_ussd + +uart: + - id: uart_sim800l + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sim800l: + on_sms_received: + - lambda: |- + std::string str; + str = sender; + str = message; + - sim800l.send_sms: + message: hello you + recipient: "+1234" + - sim800l.dial: + recipient: "+1234" + on_incoming_call: + - logger.log: + format: "Incoming call from '%s'" + args: ["caller_id.c_str()"] + - sim800l.disconnect + on_ussd_received: + - logger.log: "ussd_received" diff --git a/tests/components/sim800l/test.esp32-ard.yaml b/tests/components/sim800l/test.esp32-ard.yaml index c116548c6f..f486544afa 100644 --- a/tests/components/sim800l/test.esp32-ard.yaml +++ b/tests/components/sim800l/test.esp32-ard.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -uart: - - id: uart_sim800l - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sim800l/test.esp32-c3-ard.yaml b/tests/components/sim800l/test.esp32-c3-ard.yaml index 7ff359d1e7..b516342f3b 100644 --- a/tests/components/sim800l/test.esp32-c3-ard.yaml +++ b/tests/components/sim800l/test.esp32-c3-ard.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_sim800l - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sim800l/test.esp32-c3-idf.yaml b/tests/components/sim800l/test.esp32-c3-idf.yaml index 7ff359d1e7..b516342f3b 100644 --- a/tests/components/sim800l/test.esp32-c3-idf.yaml +++ b/tests/components/sim800l/test.esp32-c3-idf.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_sim800l - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sim800l/test.esp32-idf.yaml b/tests/components/sim800l/test.esp32-idf.yaml index c116548c6f..f486544afa 100644 --- a/tests/components/sim800l/test.esp32-idf.yaml +++ b/tests/components/sim800l/test.esp32-idf.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -uart: - - id: uart_sim800l - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sim800l/test.esp8266-ard.yaml b/tests/components/sim800l/test.esp8266-ard.yaml index 7ff359d1e7..b516342f3b 100644 --- a/tests/components/sim800l/test.esp8266-ard.yaml +++ b/tests/components/sim800l/test.esp8266-ard.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_sim800l - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sim800l/test.rp2040-ard.yaml b/tests/components/sim800l/test.rp2040-ard.yaml index 7ff359d1e7..b516342f3b 100644 --- a/tests/components/sim800l/test.rp2040-ard.yaml +++ b/tests/components/sim800l/test.rp2040-ard.yaml @@ -1,37 +1,5 @@ -esphome: - on_boot: - then: - - sim800l.send_sms: - recipient: '+15551234567' - message: Hello there - - sim800l.dial: - recipient: '+15551234567' - - sim800l.connect - - sim800l.disconnect - - sim800l.send_ussd: - ussd: test_ussd +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -uart: - - id: uart_sim800l - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -sim800l: - on_sms_received: - - lambda: |- - std::string str; - str = sender; - str = message; - - sim800l.send_sms: - message: hello you - recipient: "+1234" - - sim800l.dial: - recipient: "+1234" - on_incoming_call: - - logger.log: - format: "Incoming call from '%s'" - args: ["caller_id.c_str()"] - - sim800l.disconnect - on_ussd_received: - - logger.log: "ussd_received" +<<: !include common.yaml diff --git a/tests/components/sm16716/common.yaml b/tests/components/sm16716/common.yaml index 3bf2712f4e..db61d0b1c2 100644 --- a/tests/components/sm16716/common.yaml +++ b/tests/components/sm16716/common.yaml @@ -1,6 +1,6 @@ sm16716: - clock_pin: 4 - data_pin: 5 + clock_pin: ${clock_pin} + data_pin: ${data_pin} num_channels: 3 num_chips: 1 diff --git a/tests/components/sm16716/test.esp32-ard.yaml b/tests/components/sm16716/test.esp32-ard.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm16716/test.esp32-ard.yaml +++ b/tests/components/sm16716/test.esp32-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm16716/test.esp32-c3-ard.yaml b/tests/components/sm16716/test.esp32-c3-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm16716/test.esp32-c3-ard.yaml +++ b/tests/components/sm16716/test.esp32-c3-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm16716/test.esp32-c3-idf.yaml b/tests/components/sm16716/test.esp32-c3-idf.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm16716/test.esp32-c3-idf.yaml +++ b/tests/components/sm16716/test.esp32-c3-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm16716/test.esp32-idf.yaml b/tests/components/sm16716/test.esp32-idf.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm16716/test.esp32-idf.yaml +++ b/tests/components/sm16716/test.esp32-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm16716/test.esp8266-ard.yaml b/tests/components/sm16716/test.esp8266-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm16716/test.esp8266-ard.yaml +++ b/tests/components/sm16716/test.esp8266-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm16716/test.rp2040-ard.yaml b/tests/components/sm16716/test.rp2040-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm16716/test.rp2040-ard.yaml +++ b/tests/components/sm16716/test.rp2040-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2135/common.yaml b/tests/components/sm2135/common.yaml index 9a0de60839..8f807a9be5 100644 --- a/tests/components/sm2135/common.yaml +++ b/tests/components/sm2135/common.yaml @@ -1,6 +1,6 @@ sm2135: - clock_pin: 4 - data_pin: 5 + clock_pin: ${clock_pin} + data_pin: ${data_pin} rgb_current: 20mA cw_current: 60mA diff --git a/tests/components/sm2135/test.esp32-ard.yaml b/tests/components/sm2135/test.esp32-ard.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2135/test.esp32-ard.yaml +++ b/tests/components/sm2135/test.esp32-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2135/test.esp32-c3-ard.yaml b/tests/components/sm2135/test.esp32-c3-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2135/test.esp32-c3-ard.yaml +++ b/tests/components/sm2135/test.esp32-c3-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2135/test.esp32-c3-idf.yaml b/tests/components/sm2135/test.esp32-c3-idf.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2135/test.esp32-c3-idf.yaml +++ b/tests/components/sm2135/test.esp32-c3-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2135/test.esp32-idf.yaml b/tests/components/sm2135/test.esp32-idf.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2135/test.esp32-idf.yaml +++ b/tests/components/sm2135/test.esp32-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2135/test.esp8266-ard.yaml b/tests/components/sm2135/test.esp8266-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2135/test.esp8266-ard.yaml +++ b/tests/components/sm2135/test.esp8266-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2135/test.rp2040-ard.yaml b/tests/components/sm2135/test.rp2040-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2135/test.rp2040-ard.yaml +++ b/tests/components/sm2135/test.rp2040-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2235/common.yaml b/tests/components/sm2235/common.yaml index 043d43d6f1..d97fa4eb6c 100644 --- a/tests/components/sm2235/common.yaml +++ b/tests/components/sm2235/common.yaml @@ -1,6 +1,6 @@ sm2235: - clock_pin: 4 - data_pin: 5 + clock_pin: ${clock_pin} + data_pin: ${data_pin} max_power_color_channels: 9 max_power_white_channels: 9 diff --git a/tests/components/sm2235/test.esp32-ard.yaml b/tests/components/sm2235/test.esp32-ard.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2235/test.esp32-ard.yaml +++ b/tests/components/sm2235/test.esp32-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2235/test.esp32-c3-ard.yaml b/tests/components/sm2235/test.esp32-c3-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2235/test.esp32-c3-ard.yaml +++ b/tests/components/sm2235/test.esp32-c3-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2235/test.esp32-c3-idf.yaml b/tests/components/sm2235/test.esp32-c3-idf.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2235/test.esp32-c3-idf.yaml +++ b/tests/components/sm2235/test.esp32-c3-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2235/test.esp32-idf.yaml b/tests/components/sm2235/test.esp32-idf.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2235/test.esp32-idf.yaml +++ b/tests/components/sm2235/test.esp32-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2235/test.esp8266-ard.yaml b/tests/components/sm2235/test.esp8266-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2235/test.esp8266-ard.yaml +++ b/tests/components/sm2235/test.esp8266-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2235/test.rp2040-ard.yaml b/tests/components/sm2235/test.rp2040-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2235/test.rp2040-ard.yaml +++ b/tests/components/sm2235/test.rp2040-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2335/common.yaml b/tests/components/sm2335/common.yaml index a5b2aedeb5..51d40aab21 100644 --- a/tests/components/sm2335/common.yaml +++ b/tests/components/sm2335/common.yaml @@ -1,6 +1,6 @@ sm2335: - clock_pin: 4 - data_pin: 5 + clock_pin: ${clock_pin} + data_pin: ${data_pin} max_power_color_channels: 9 max_power_white_channels: 9 diff --git a/tests/components/sm2335/test.esp32-ard.yaml b/tests/components/sm2335/test.esp32-ard.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2335/test.esp32-ard.yaml +++ b/tests/components/sm2335/test.esp32-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2335/test.esp32-c3-ard.yaml b/tests/components/sm2335/test.esp32-c3-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2335/test.esp32-c3-ard.yaml +++ b/tests/components/sm2335/test.esp32-c3-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2335/test.esp32-c3-idf.yaml b/tests/components/sm2335/test.esp32-c3-idf.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2335/test.esp32-c3-idf.yaml +++ b/tests/components/sm2335/test.esp32-c3-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2335/test.esp32-idf.yaml b/tests/components/sm2335/test.esp32-idf.yaml index dade44d145..d295973e3f 100644 --- a/tests/components/sm2335/test.esp32-idf.yaml +++ b/tests/components/sm2335/test.esp32-idf.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + <<: !include common.yaml diff --git a/tests/components/sm2335/test.esp8266-ard.yaml b/tests/components/sm2335/test.esp8266-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2335/test.esp8266-ard.yaml +++ b/tests/components/sm2335/test.esp8266-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm2335/test.rp2040-ard.yaml b/tests/components/sm2335/test.rp2040-ard.yaml index dade44d145..7808481215 100644 --- a/tests/components/sm2335/test.rp2040-ard.yaml +++ b/tests/components/sm2335/test.rp2040-ard.yaml @@ -1 +1,5 @@ +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + <<: !include common.yaml diff --git a/tests/components/sm300d2/common.yaml b/tests/components/sm300d2/common.yaml new file mode 100644 index 0000000000..a231b63816 --- /dev/null +++ b/tests/components/sm300d2/common.yaml @@ -0,0 +1,23 @@ +uart: + - id: uart_sm300d2 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: sm300d2 + co2: + name: SM300D2 CO2 Value + formaldehyde: + name: SM300D2 Formaldehyde Value + tvoc: + name: SM300D2 TVOC Value + pm_2_5: + name: SM300D2 PM2.5 Value + pm_10_0: + name: SM300D2 PM10 Value + temperature: + name: SM300D2 Temperature Value + humidity: + name: SM300D2 Humidity Value + update_interval: 60s diff --git a/tests/components/sm300d2/test.esp32-ard.yaml b/tests/components/sm300d2/test.esp32-ard.yaml index 92dba4fb3b..f486544afa 100644 --- a/tests/components/sm300d2/test.esp32-ard.yaml +++ b/tests/components/sm300d2/test.esp32-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sm300d2/test.esp32-c3-ard.yaml b/tests/components/sm300d2/test.esp32-c3-ard.yaml index bcd0a728b2..b516342f3b 100644 --- a/tests/components/sm300d2/test.esp32-c3-ard.yaml +++ b/tests/components/sm300d2/test.esp32-c3-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sm300d2/test.esp32-c3-idf.yaml b/tests/components/sm300d2/test.esp32-c3-idf.yaml index bcd0a728b2..b516342f3b 100644 --- a/tests/components/sm300d2/test.esp32-c3-idf.yaml +++ b/tests/components/sm300d2/test.esp32-c3-idf.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sm300d2/test.esp32-idf.yaml b/tests/components/sm300d2/test.esp32-idf.yaml index 92dba4fb3b..f486544afa 100644 --- a/tests/components/sm300d2/test.esp32-idf.yaml +++ b/tests/components/sm300d2/test.esp32-idf.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sm300d2/test.esp8266-ard.yaml b/tests/components/sm300d2/test.esp8266-ard.yaml index bcd0a728b2..b516342f3b 100644 --- a/tests/components/sm300d2/test.esp8266-ard.yaml +++ b/tests/components/sm300d2/test.esp8266-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sm300d2/test.rp2040-ard.yaml b/tests/components/sm300d2/test.rp2040-ard.yaml index bcd0a728b2..b516342f3b 100644 --- a/tests/components/sm300d2/test.rp2040-ard.yaml +++ b/tests/components/sm300d2/test.rp2040-ard.yaml @@ -1,23 +1,5 @@ -uart: - - id: uart_sm300d2 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: sm300d2 - co2: - name: SM300D2 CO2 Value - formaldehyde: - name: SM300D2 Formaldehyde Value - tvoc: - name: SM300D2 TVOC Value - pm_2_5: - name: SM300D2 PM2.5 Value - pm_10_0: - name: SM300D2 PM10 Value - temperature: - name: SM300D2 Temperature Value - humidity: - name: SM300D2 Humidity Value - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sml/common.yaml b/tests/components/sml/common.yaml new file mode 100644 index 0000000000..a50d25eeee --- /dev/null +++ b/tests/components/sml/common.yaml @@ -0,0 +1,31 @@ +uart: + - id: uart_sml + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sml: + id: mysml + on_data: + - logger.log: "SML on_data" + +sensor: + - platform: sml + name: Total energy + sml_id: mysml + server_id: 0123456789abcdef + obis_code: "1-0:1.8.0" + unit_of_measurement: kWh + accuracy_decimals: 1 + device_class: energy + state_class: total_increasing + filters: + - multiply: 0.0001 + +text_sensor: + - platform: sml + name: Manufacturer + sml_id: mysml + server_id: 0123456789abcdef + obis_code: "129-129:199.130.3" + format: text diff --git a/tests/components/sml/test.esp32-ard.yaml b/tests/components/sml/test.esp32-ard.yaml index 7217199380..f486544afa 100644 --- a/tests/components/sml/test.esp32-ard.yaml +++ b/tests/components/sml/test.esp32-ard.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/sml/test.esp32-c3-ard.yaml b/tests/components/sml/test.esp32-c3-ard.yaml index 903f968c26..b516342f3b 100644 --- a/tests/components/sml/test.esp32-c3-ard.yaml +++ b/tests/components/sml/test.esp32-c3-ard.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/sml/test.esp32-c3-idf.yaml b/tests/components/sml/test.esp32-c3-idf.yaml index 903f968c26..b516342f3b 100644 --- a/tests/components/sml/test.esp32-c3-idf.yaml +++ b/tests/components/sml/test.esp32-c3-idf.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/sml/test.esp32-idf.yaml b/tests/components/sml/test.esp32-idf.yaml index 7217199380..f486544afa 100644 --- a/tests/components/sml/test.esp32-idf.yaml +++ b/tests/components/sml/test.esp32-idf.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/sml/test.esp8266-ard.yaml b/tests/components/sml/test.esp8266-ard.yaml index 903f968c26..b516342f3b 100644 --- a/tests/components/sml/test.esp8266-ard.yaml +++ b/tests/components/sml/test.esp8266-ard.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/sml/test.rp2040-ard.yaml b/tests/components/sml/test.rp2040-ard.yaml index 903f968c26..b516342f3b 100644 --- a/tests/components/sml/test.rp2040-ard.yaml +++ b/tests/components/sml/test.rp2040-ard.yaml @@ -1,31 +1,5 @@ -uart: - - id: uart_sml - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sml: - id: mysml - on_data: - - logger.log: "SML on_data" - -sensor: - - platform: sml - name: Total energy - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "1-0:1.8.0" - unit_of_measurement: kWh - accuracy_decimals: 1 - device_class: energy - state_class: total_increasing - filters: - - multiply: 0.0001 - -text_sensor: - - platform: sml - name: Manufacturer - sml_id: mysml - server_id: 0123456789abcdef - obis_code: "129-129:199.130.3" - format: text +<<: !include common.yaml diff --git a/tests/components/smt100/common.yaml b/tests/components/smt100/common.yaml new file mode 100644 index 0000000000..f86bd762e7 --- /dev/null +++ b/tests/components/smt100/common.yaml @@ -0,0 +1,19 @@ +uart: + - id: uart_smt100 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +sensor: + - platform: smt100 + counts: + name: Counts + dielectric_constant: + name: Dielectric Constant + temperature: + name: Temperature + moisture: + name: Moisture + voltage: + name: Voltage + update_interval: 60s diff --git a/tests/components/smt100/test.esp32-ard.yaml b/tests/components/smt100/test.esp32-ard.yaml index 7c19f4bc45..f486544afa 100644 --- a/tests/components/smt100/test.esp32-ard.yaml +++ b/tests/components/smt100/test.esp32-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/smt100/test.esp32-c3-ard.yaml b/tests/components/smt100/test.esp32-c3-ard.yaml index 4277f2567b..b516342f3b 100644 --- a/tests/components/smt100/test.esp32-c3-ard.yaml +++ b/tests/components/smt100/test.esp32-c3-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/smt100/test.esp32-c3-idf.yaml b/tests/components/smt100/test.esp32-c3-idf.yaml index 4277f2567b..b516342f3b 100644 --- a/tests/components/smt100/test.esp32-c3-idf.yaml +++ b/tests/components/smt100/test.esp32-c3-idf.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/smt100/test.esp32-idf.yaml b/tests/components/smt100/test.esp32-idf.yaml index 7c19f4bc45..f486544afa 100644 --- a/tests/components/smt100/test.esp32-idf.yaml +++ b/tests/components/smt100/test.esp32-idf.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/smt100/test.esp8266-ard.yaml b/tests/components/smt100/test.esp8266-ard.yaml index 4277f2567b..b516342f3b 100644 --- a/tests/components/smt100/test.esp8266-ard.yaml +++ b/tests/components/smt100/test.esp8266-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/smt100/test.rp2040-ard.yaml b/tests/components/smt100/test.rp2040-ard.yaml index 4277f2567b..b516342f3b 100644 --- a/tests/components/smt100/test.rp2040-ard.yaml +++ b/tests/components/smt100/test.rp2040-ard.yaml @@ -1,19 +1,5 @@ -uart: - - id: uart_smt100 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: smt100 - counts: - name: Counts - dielectric_constant: - name: Dielectric Constant - temperature: - name: Temperature - moisture: - name: Moisture - voltage: - name: Voltage - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/sn74hc165/common.yaml b/tests/components/sn74hc165/common.yaml new file mode 100644 index 0000000000..f98711048d --- /dev/null +++ b/tests/components/sn74hc165/common.yaml @@ -0,0 +1,14 @@ +sn74hc165: + id: sn74hc165_hub + clock_pin: ${clock_pin} + data_pin: ${data_pin} + load_pin: ${load_pin} + clock_inhibit_pin: ${clock_inhibit_pin} + sr_count: 2 + +binary_sensor: + - platform: gpio + id: sn74hc165_pin_0 + pin: + sn74hc165: sn74hc165_hub + number: 0 diff --git a/tests/components/sn74hc165/test.esp32-ard.yaml b/tests/components/sn74hc165/test.esp32-ard.yaml index 55b06aec9b..27f963312f 100644 --- a/tests/components/sn74hc165/test.esp32-ard.yaml +++ b/tests/components/sn74hc165/test.esp32-ard.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 13 - data_pin: 14 - load_pin: 15 - clock_inhibit_pin: 16 - sr_count: 2 +substitutions: + clock_pin: GPIO13 + data_pin: GPIO14 + load_pin: GPIO15 + clock_inhibit_pin: GPIO16 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc165/test.esp32-c3-ard.yaml b/tests/components/sn74hc165/test.esp32-c3-ard.yaml index f687b23c9d..0a3db917b7 100644 --- a/tests/components/sn74hc165/test.esp32-c3-ard.yaml +++ b/tests/components/sn74hc165/test.esp32-c3-ard.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 3 - data_pin: 4 - load_pin: 5 - clock_inhibit_pin: 6 - sr_count: 2 +substitutions: + clock_pin: GPIO3 + data_pin: GPIO4 + load_pin: GPIO5 + clock_inhibit_pin: GPIO6 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc165/test.esp32-c3-idf.yaml b/tests/components/sn74hc165/test.esp32-c3-idf.yaml index f687b23c9d..0a3db917b7 100644 --- a/tests/components/sn74hc165/test.esp32-c3-idf.yaml +++ b/tests/components/sn74hc165/test.esp32-c3-idf.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 3 - data_pin: 4 - load_pin: 5 - clock_inhibit_pin: 6 - sr_count: 2 +substitutions: + clock_pin: GPIO3 + data_pin: GPIO4 + load_pin: GPIO5 + clock_inhibit_pin: GPIO6 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc165/test.esp32-idf.yaml b/tests/components/sn74hc165/test.esp32-idf.yaml index 55b06aec9b..27f963312f 100644 --- a/tests/components/sn74hc165/test.esp32-idf.yaml +++ b/tests/components/sn74hc165/test.esp32-idf.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 13 - data_pin: 14 - load_pin: 15 - clock_inhibit_pin: 16 - sr_count: 2 +substitutions: + clock_pin: GPIO13 + data_pin: GPIO14 + load_pin: GPIO15 + clock_inhibit_pin: GPIO16 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc165/test.esp8266-ard.yaml b/tests/components/sn74hc165/test.esp8266-ard.yaml index 55b06aec9b..27f963312f 100644 --- a/tests/components/sn74hc165/test.esp8266-ard.yaml +++ b/tests/components/sn74hc165/test.esp8266-ard.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 13 - data_pin: 14 - load_pin: 15 - clock_inhibit_pin: 16 - sr_count: 2 +substitutions: + clock_pin: GPIO13 + data_pin: GPIO14 + load_pin: GPIO15 + clock_inhibit_pin: GPIO16 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc165/test.rp2040-ard.yaml b/tests/components/sn74hc165/test.rp2040-ard.yaml index f687b23c9d..0a3db917b7 100644 --- a/tests/components/sn74hc165/test.rp2040-ard.yaml +++ b/tests/components/sn74hc165/test.rp2040-ard.yaml @@ -1,14 +1,7 @@ -sn74hc165: - id: sn74hc165_hub - clock_pin: 3 - data_pin: 4 - load_pin: 5 - clock_inhibit_pin: 6 - sr_count: 2 +substitutions: + clock_pin: GPIO3 + data_pin: GPIO4 + load_pin: GPIO5 + clock_inhibit_pin: GPIO6 -binary_sensor: - - platform: gpio - id: sn74hc165_pin_0 - pin: - sn74hc165: sn74hc165_hub - number: 0 +<<: !include common.yaml diff --git a/tests/components/sn74hc595/common.yaml b/tests/components/sn74hc595/common.yaml new file mode 100644 index 0000000000..fc297909f5 --- /dev/null +++ b/tests/components/sn74hc595/common.yaml @@ -0,0 +1,26 @@ +spi: + - id: spi_sn74hc595 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +sn74hc595: + - id: sn74hc595_hub + clock_pin: ${clock_pin} + data_pin: ${data_pin} + latch_pin: ${latch_pin1} + oe_pin: ${oe_pin1} + sr_count: 2 + - id: sn74hc595_hub_2 + latch_pin: ${latch_pin2} + oe_pin: ${oe_pin2} + type: spi + sr_count: 2 + +switch: + - platform: gpio + name: SN74HC595 Pin 0 + pin: + sn74hc595: sn74hc595_hub_2 + number: 0 + inverted: false diff --git a/tests/components/sn74hc595/test.esp32-ard.yaml b/tests/components/sn74hc595/test.esp32-ard.yaml index f695395797..a4bab64862 100644 --- a/tests/components/sn74hc595/test.esp32-ard.yaml +++ b/tests/components/sn74hc595/test.esp32-ard.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO18 + clock_pin: GPIO15 + data_pin: GPIO14 + latch_pin1: GPIO21 + oe_pin1: GPIO22 + latch_pin2: GPIO23 + oe_pin2: GPIO25 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 12 - data_pin: 13 - latch_pin: 14 - oe_pin: 18 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 21 - oe_pin: 22 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sn74hc595/test.esp32-c3-ard.yaml b/tests/components/sn74hc595/test.esp32-c3-ard.yaml index 9b093899d3..14c928be88 100644 --- a/tests/components/sn74hc595/test.esp32-c3-ard.yaml +++ b/tests/components/sn74hc595/test.esp32-c3-ard.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO8 + clock_pin: GPIO5 + data_pin: GPIO4 + latch_pin1: GPIO1 + oe_pin1: GPIO2 + latch_pin2: GPIO3 + oe_pin2: GPIO9 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 0 - data_pin: 1 - latch_pin: 2 - oe_pin: 3 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 8 - oe_pin: 9 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sn74hc595/test.esp32-c3-idf.yaml b/tests/components/sn74hc595/test.esp32-c3-idf.yaml index 9b093899d3..14c928be88 100644 --- a/tests/components/sn74hc595/test.esp32-c3-idf.yaml +++ b/tests/components/sn74hc595/test.esp32-c3-idf.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO8 + clock_pin: GPIO5 + data_pin: GPIO4 + latch_pin1: GPIO1 + oe_pin1: GPIO2 + latch_pin2: GPIO3 + oe_pin2: GPIO9 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 0 - data_pin: 1 - latch_pin: 2 - oe_pin: 3 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 8 - oe_pin: 9 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sn74hc595/test.esp32-idf.yaml b/tests/components/sn74hc595/test.esp32-idf.yaml index f695395797..a4bab64862 100644 --- a/tests/components/sn74hc595/test.esp32-idf.yaml +++ b/tests/components/sn74hc595/test.esp32-idf.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO18 + clock_pin: GPIO15 + data_pin: GPIO14 + latch_pin1: GPIO21 + oe_pin1: GPIO22 + latch_pin2: GPIO23 + oe_pin2: GPIO25 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 12 - data_pin: 13 - latch_pin: 14 - oe_pin: 18 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 21 - oe_pin: 22 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sn74hc595/test.esp8266-ard.yaml b/tests/components/sn74hc595/test.esp8266-ard.yaml index 64bf5d1925..cad11feca8 100644 --- a/tests/components/sn74hc595/test.esp8266-ard.yaml +++ b/tests/components/sn74hc595/test.esp8266-ard.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + clock_pin: GPIO5 + data_pin: GPIO4 + latch_pin1: GPIO2 + oe_pin1: GPIO0 + latch_pin2: GPIO3 + oe_pin2: GPIO1 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 0 - data_pin: 2 - latch_pin: 4 - oe_pin: 5 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 15 - oe_pin: 16 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sn74hc595/test.rp2040-ard.yaml b/tests/components/sn74hc595/test.rp2040-ard.yaml index de8e192659..14c928be88 100644 --- a/tests/components/sn74hc595/test.rp2040-ard.yaml +++ b/tests/components/sn74hc595/test.rp2040-ard.yaml @@ -1,27 +1,12 @@ -spi: - - id: spi_sn74hc595 - clk_pin: 6 - mosi_pin: 5 - miso_pin: 4 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO8 + clock_pin: GPIO5 + data_pin: GPIO4 + latch_pin1: GPIO1 + oe_pin1: GPIO2 + latch_pin2: GPIO3 + oe_pin2: GPIO9 -sn74hc595: - - id: sn74hc595_hub - clock_pin: 0 - data_pin: 1 - latch_pin: 2 - oe_pin: 3 - sr_count: 2 - - id: sn74hc595_hub_2 - latch_pin: 8 - oe_pin: 9 - spi_id: spi_sn74hc595 - type: spi - sr_count: 2 - -switch: - - platform: gpio - name: SN74HC595 Pin 0 - pin: - sn74hc595: sn74hc595_hub_2 - number: 0 - inverted: false +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/common.yaml b/tests/components/sonoff_d1/common.yaml new file mode 100644 index 0000000000..d2d4043b95 --- /dev/null +++ b/tests/components/sonoff_d1/common.yaml @@ -0,0 +1,12 @@ +uart: + - id: uart_sonoff_d1 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +light: + - platform: sonoff_d1 + id: d1_light + name: Sonoff D1 Dimmer + restore_mode: RESTORE_DEFAULT_OFF + use_rm433_remote: false diff --git a/tests/components/sonoff_d1/test.esp32-ard.yaml b/tests/components/sonoff_d1/test.esp32-ard.yaml index dc35e3b6ac..f486544afa 100644 --- a/tests/components/sonoff_d1/test.esp32-ard.yaml +++ b/tests/components/sonoff_d1/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_sonoff_d1 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -light: - - platform: sonoff_d1 - id: d1_light - name: Sonoff D1 Dimmer - restore_mode: RESTORE_DEFAULT_OFF - use_rm433_remote: false +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/test.esp32-c3-ard.yaml b/tests/components/sonoff_d1/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/sonoff_d1/test.esp32-c3-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/test.esp32-c3-idf.yaml b/tests/components/sonoff_d1/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/sonoff_d1/test.esp32-c3-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/test.esp32-idf.yaml b/tests/components/sonoff_d1/test.esp32-idf.yaml index dc35e3b6ac..f486544afa 100644 --- a/tests/components/sonoff_d1/test.esp32-idf.yaml +++ b/tests/components/sonoff_d1/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_sonoff_d1 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -light: - - platform: sonoff_d1 - id: d1_light - name: Sonoff D1 Dimmer - restore_mode: RESTORE_DEFAULT_OFF - use_rm433_remote: false +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/test.esp8266-ard.yaml b/tests/components/sonoff_d1/test.esp8266-ard.yaml index c4a62f4cb3..b516342f3b 100644 --- a/tests/components/sonoff_d1/test.esp8266-ard.yaml +++ b/tests/components/sonoff_d1/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -uart: - - id: uart_sonoff_d1 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -light: - - platform: sonoff_d1 - id: d1_light - name: Sonoff D1 Dimmer - restore_mode: RESTORE_DEFAULT_OFF - use_rm433_remote: false +<<: !include common.yaml diff --git a/tests/components/sonoff_d1/test.rp2040-ard.yaml b/tests/components/sonoff_d1/test.rp2040-ard.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/sonoff_d1/test.rp2040-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/speaker/audio_dac.esp32-ard.yaml b/tests/components/speaker/audio_dac.esp32-ard.yaml new file mode 100644 index 0000000000..75d9ddf92b --- /dev/null +++ b/tests/components/speaker/audio_dac.esp32-ard.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + i2s_bclk_pin: GPIO27 + i2s_lrclk_pin: GPIO26 + i2s_mclk_pin: GPIO25 + i2s_dout_pin: GPIO23 + +<<: !include common-audio_dac.yaml diff --git a/tests/components/speaker/audio_dac.esp32-c3-ard.yaml b/tests/components/speaker/audio_dac.esp32-c3-ard.yaml new file mode 100644 index 0000000000..1004d2143e --- /dev/null +++ b/tests/components/speaker/audio_dac.esp32-c3-ard.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + i2s_bclk_pin: GPIO7 + i2s_lrclk_pin: GPIO6 + i2s_mclk_pin: GPIO9 + i2s_dout_pin: GPIO8 + +<<: !include common-audio_dac.yaml diff --git a/tests/components/speaker/audio_dac.esp32-c3-idf.yaml b/tests/components/speaker/audio_dac.esp32-c3-idf.yaml new file mode 100644 index 0000000000..1004d2143e --- /dev/null +++ b/tests/components/speaker/audio_dac.esp32-c3-idf.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + i2s_bclk_pin: GPIO7 + i2s_lrclk_pin: GPIO6 + i2s_mclk_pin: GPIO9 + i2s_dout_pin: GPIO8 + +<<: !include common-audio_dac.yaml diff --git a/tests/components/speaker/audio_dac.esp32-idf.yaml b/tests/components/speaker/audio_dac.esp32-idf.yaml new file mode 100644 index 0000000000..75d9ddf92b --- /dev/null +++ b/tests/components/speaker/audio_dac.esp32-idf.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + i2s_bclk_pin: GPIO27 + i2s_lrclk_pin: GPIO26 + i2s_mclk_pin: GPIO25 + i2s_dout_pin: GPIO23 + +<<: !include common-audio_dac.yaml diff --git a/tests/components/speaker/common-audio_dac.yaml b/tests/components/speaker/common-audio_dac.yaml new file mode 100644 index 0000000000..41b994d4d4 --- /dev/null +++ b/tests/components/speaker/common-audio_dac.yaml @@ -0,0 +1,36 @@ +esphome: + on_boot: + then: + - speaker.mute_on: + - speaker.mute_off: + - if: + condition: speaker.is_stopped + then: + - speaker.play: [0, 1, 2, 3] + - speaker.volume_set: 0.9 + - if: + condition: speaker.is_playing + then: + - speaker.finish: + - speaker.stop: + +i2c: + - id: i2c_audio_dac + scl: ${scl_pin} + sda: ${sda_pin} + +i2s_audio: + i2s_lrclk_pin: ${i2s_bclk_pin} + i2s_bclk_pin: ${i2s_lrclk_pin} + i2s_mclk_pin: ${i2s_mclk_pin} + +audio_dac: + - platform: aic3204 + id: internal_dac + +speaker: + - platform: i2s_audio + id: speaker_with_audio_dac_id + audio_dac: internal_dac + dac_type: external + i2s_dout_pin: ${i2s_dout_pin} diff --git a/tests/components/speaker/common.yaml b/tests/components/speaker/common.yaml new file mode 100644 index 0000000000..c04674ee29 --- /dev/null +++ b/tests/components/speaker/common.yaml @@ -0,0 +1,26 @@ +esphome: + on_boot: + then: + - speaker.mute_on: + - speaker.mute_off: + - if: + condition: speaker.is_stopped + then: + - speaker.play: [0, 1, 2, 3] + - speaker.volume_set: 0.9 + - if: + condition: speaker.is_playing + then: + - speaker.finish: + - speaker.stop: + +i2s_audio: + i2s_lrclk_pin: ${i2s_bclk_pin} + i2s_bclk_pin: ${i2s_lrclk_pin} + i2s_mclk_pin: ${i2s_mclk_pin} + +speaker: + - platform: i2s_audio + id: speaker_id + dac_type: external + i2s_dout_pin: ${i2s_dout_pin} diff --git a/tests/components/speaker/test.esp32-ard.yaml b/tests/components/speaker/test.esp32-ard.yaml index 396b4d95ea..e2439ebdf2 100644 --- a/tests/components/speaker/test.esp32-ard.yaml +++ b/tests/components/speaker/test.esp32-ard.yaml @@ -1,26 +1,9 @@ -esphome: - on_boot: - then: - - speaker.mute_on: - - speaker.mute_off: - - if: - condition: speaker.is_stopped - then: - - speaker.play: [0, 1, 2, 3] - - speaker.volume_set: 0.9 - - if: - condition: speaker.is_playing - then: - - speaker.finish: - - speaker.stop: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + i2s_bclk_pin: GPIO27 + i2s_lrclk_pin: GPIO26 + i2s_mclk_pin: GPIO25 + i2s_dout_pin: GPIO23 -i2s_audio: - i2s_lrclk_pin: 16 - i2s_bclk_pin: 17 - i2s_mclk_pin: 15 - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 13 +<<: !include common.yaml diff --git a/tests/components/speaker/test.esp32-c3-ard.yaml b/tests/components/speaker/test.esp32-c3-ard.yaml index 636aeba766..ddcf051fab 100644 --- a/tests/components/speaker/test.esp32-c3-ard.yaml +++ b/tests/components/speaker/test.esp32-c3-ard.yaml @@ -1,26 +1,9 @@ -esphome: - on_boot: - then: - - speaker.mute_on: - - speaker.mute_off: - - if: - condition: speaker.is_stopped - then: - - speaker.play: [0, 1, 2, 3] - - speaker.volume_set: 0.9 - - if: - condition: speaker.is_playing - then: - - speaker.finish: - - speaker.stop: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + i2s_bclk_pin: GPIO7 + i2s_lrclk_pin: GPIO6 + i2s_mclk_pin: GPIO9 + i2s_dout_pin: GPIO8 -i2s_audio: - i2s_lrclk_pin: 6 - i2s_bclk_pin: 7 - i2s_mclk_pin: 5 - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 3 +<<: !include common.yaml diff --git a/tests/components/speaker/test.esp32-c3-idf.yaml b/tests/components/speaker/test.esp32-c3-idf.yaml index 636aeba766..ddcf051fab 100644 --- a/tests/components/speaker/test.esp32-c3-idf.yaml +++ b/tests/components/speaker/test.esp32-c3-idf.yaml @@ -1,26 +1,9 @@ -esphome: - on_boot: - then: - - speaker.mute_on: - - speaker.mute_off: - - if: - condition: speaker.is_stopped - then: - - speaker.play: [0, 1, 2, 3] - - speaker.volume_set: 0.9 - - if: - condition: speaker.is_playing - then: - - speaker.finish: - - speaker.stop: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + i2s_bclk_pin: GPIO7 + i2s_lrclk_pin: GPIO6 + i2s_mclk_pin: GPIO9 + i2s_dout_pin: GPIO8 -i2s_audio: - i2s_lrclk_pin: 6 - i2s_bclk_pin: 7 - i2s_mclk_pin: 5 - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 3 +<<: !include common.yaml diff --git a/tests/components/speaker/test.esp32-idf.yaml b/tests/components/speaker/test.esp32-idf.yaml index b69440b133..e2439ebdf2 100644 --- a/tests/components/speaker/test.esp32-idf.yaml +++ b/tests/components/speaker/test.esp32-idf.yaml @@ -1,35 +1,9 @@ -esphome: - on_boot: - then: - - speaker.mute_on: - - speaker.mute_off: - - if: - condition: speaker.is_stopped - then: - - speaker.play: [0, 1, 2, 3] - - speaker.volume_set: 0.9 - - if: - condition: speaker.is_playing - then: - - speaker.finish: - - speaker.stop: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + i2s_bclk_pin: GPIO27 + i2s_lrclk_pin: GPIO26 + i2s_mclk_pin: GPIO25 + i2s_dout_pin: GPIO23 -i2s_audio: - i2s_lrclk_pin: 16 - i2s_bclk_pin: 17 - i2s_mclk_pin: 15 - -i2c: - scl: 12 - sda: 10 - -audio_dac: - - platform: aic3204 - id: internal_dac - -speaker: - - platform: i2s_audio - id: speaker_with_audio_dac_id - audio_dac: internal_dac - dac_type: external - i2s_dout_pin: 14 +<<: !include common.yaml diff --git a/tests/components/speed/common.yaml b/tests/components/speed/common.yaml new file mode 100644 index 0000000000..be8172af7e --- /dev/null +++ b/tests/components/speed/common.yaml @@ -0,0 +1,9 @@ +output: + - platform: ${output_platform} + id: fan_output_1 + pin: ${pin} + +fan: + - platform: speed + id: fan_speed + output: fan_output_1 diff --git a/tests/components/speed/test.esp32-ard.yaml b/tests/components/speed/test.esp32-ard.yaml index 29a55e9edd..26da1ce1d6 100644 --- a/tests/components/speed/test.esp32-ard.yaml +++ b/tests/components/speed/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 12 +substitutions: + output_platform: ledc + pin: GPIO14 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/speed/test.esp32-c3-ard.yaml b/tests/components/speed/test.esp32-c3-ard.yaml index fa1920676e..7476963591 100644 --- a/tests/components/speed/test.esp32-c3-ard.yaml +++ b/tests/components/speed/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 2 +substitutions: + output_platform: ledc + pin: GPIO4 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/speed/test.esp32-c3-idf.yaml b/tests/components/speed/test.esp32-c3-idf.yaml index fa1920676e..7476963591 100644 --- a/tests/components/speed/test.esp32-c3-idf.yaml +++ b/tests/components/speed/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 2 +substitutions: + output_platform: ledc + pin: GPIO4 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/speed/test.esp32-idf.yaml b/tests/components/speed/test.esp32-idf.yaml index 29a55e9edd..26da1ce1d6 100644 --- a/tests/components/speed/test.esp32-idf.yaml +++ b/tests/components/speed/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -output: - - platform: ledc - id: fan_output_1 - pin: 12 +substitutions: + output_platform: ledc + pin: GPIO14 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/speed/test.esp8266-ard.yaml b/tests/components/speed/test.esp8266-ard.yaml index 6ed9949cf5..23a7f43b42 100644 --- a/tests/components/speed/test.esp8266-ard.yaml +++ b/tests/components/speed/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -output: - - platform: esp8266_pwm - id: fan_output_1 - pin: 12 +substitutions: + output_platform: esp8266_pwm + pin: GPIO14 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/speed/test.rp2040-ard.yaml b/tests/components/speed/test.rp2040-ard.yaml index 02b572db75..d70f7c74ec 100644 --- a/tests/components/speed/test.rp2040-ard.yaml +++ b/tests/components/speed/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -output: - - platform: rp2040_pwm - id: fan_output_1 - pin: 12 +substitutions: + output_platform: rp2040_pwm + pin: GPIO4 -fan: - - platform: speed - id: fan_speed - output: fan_output_1 +<<: !include common.yaml diff --git a/tests/components/spi/common.yaml b/tests/components/spi/common.yaml new file mode 100644 index 0000000000..04b4779957 --- /dev/null +++ b/tests/components/spi/common.yaml @@ -0,0 +1,5 @@ +spi: + - id: spi_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} diff --git a/tests/components/spi/test.esp32-ard.yaml b/tests/components/spi/test.esp32-ard.yaml index 1cdcf461dd..448e54fea6 100644 --- a/tests/components/spi/test.esp32-ard.yaml +++ b/tests/components/spi/test.esp32-ard.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + +<<: !include common.yaml diff --git a/tests/components/spi/test.esp32-c3-ard.yaml b/tests/components/spi/test.esp32-c3-ard.yaml index f49470ad07..bfa12b1755 100644 --- a/tests/components/spi/test.esp32-c3-ard.yaml +++ b/tests/components/spi/test.esp32-c3-ard.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/spi/test.esp32-c3-idf.yaml b/tests/components/spi/test.esp32-c3-idf.yaml index f49470ad07..bfa12b1755 100644 --- a/tests/components/spi/test.esp32-c3-idf.yaml +++ b/tests/components/spi/test.esp32-c3-idf.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/spi/test.esp32-idf.yaml b/tests/components/spi/test.esp32-idf.yaml index 1cdcf461dd..448e54fea6 100644 --- a/tests/components/spi/test.esp32-idf.yaml +++ b/tests/components/spi/test.esp32-idf.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 + +<<: !include common.yaml diff --git a/tests/components/spi/test.esp32-s3-idf.yaml b/tests/components/spi/test.esp32-s3-idf.yaml index 8db934023a..d394c5d7a4 100644 --- a/tests/components/spi/test.esp32-s3-idf.yaml +++ b/tests/components/spi/test.esp32-s3-idf.yaml @@ -9,8 +9,8 @@ spi: interface: hardware - id: quad_spi type: quad - clk_pin: 47 interface: spi3 + clk_pin: 47 data_pins: - number: 40 allow_other_uses: false @@ -18,7 +18,7 @@ spi: - 42 - 43 - id: spi_id_3 + interface: any clk_pin: 8 mosi_pin: 9 - interface: any diff --git a/tests/components/spi/test.esp8266-ard.yaml b/tests/components/spi/test.esp8266-ard.yaml index 83f110921f..b9545d4f6a 100644 --- a/tests/components/spi/test.esp8266-ard.yaml +++ b/tests/components/spi/test.esp8266-ard.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + +<<: !include common.yaml diff --git a/tests/components/spi/test.rp2040-ard.yaml b/tests/components/spi/test.rp2040-ard.yaml index 1e39d247fe..81a8acafd8 100644 --- a/tests/components/spi/test.rp2040-ard.yaml +++ b/tests/components/spi/test.rp2040-ard.yaml @@ -1,5 +1,6 @@ -spi: - - id: spi_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/spi_device/common.yaml b/tests/components/spi_device/common.yaml new file mode 100644 index 0000000000..636d82202b --- /dev/null +++ b/tests/components/spi_device/common.yaml @@ -0,0 +1,11 @@ +spi: + - id: spi_device1 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +spi_device: + id: spi_device_test + data_rate: 2MHz + spi_mode: 3 + bit_order: lsb_first diff --git a/tests/components/spi_device/test.esp32-ard.yaml b/tests/components/spi_device/test.esp32-ard.yaml index b539cb3ec4..448e54fea6 100644 --- a/tests/components/spi_device/test.esp32-ard.yaml +++ b/tests/components/spi_device/test.esp32-ard.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_device/test.esp32-c3-ard.yaml b/tests/components/spi_device/test.esp32-c3-ard.yaml index 99c0ac1ebb..bfa12b1755 100644 --- a/tests/components/spi_device/test.esp32-c3-ard.yaml +++ b/tests/components/spi_device/test.esp32-c3-ard.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_device/test.esp32-c3-idf.yaml b/tests/components/spi_device/test.esp32-c3-idf.yaml index 99c0ac1ebb..bfa12b1755 100644 --- a/tests/components/spi_device/test.esp32-c3-idf.yaml +++ b/tests/components/spi_device/test.esp32-c3-idf.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_device/test.esp32-idf.yaml b/tests/components/spi_device/test.esp32-idf.yaml index b539cb3ec4..448e54fea6 100644 --- a/tests/components/spi_device/test.esp32-idf.yaml +++ b/tests/components/spi_device/test.esp32-idf.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + miso_pin: GPIO15 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_device/test.esp8266-ard.yaml b/tests/components/spi_device/test.esp8266-ard.yaml index 988825ce2d..b9545d4f6a 100644 --- a/tests/components/spi_device/test.esp8266-ard.yaml +++ b/tests/components/spi_device/test.esp8266-ard.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_device/test.rp2040-ard.yaml b/tests/components/spi_device/test.rp2040-ard.yaml index 6020643f21..81a8acafd8 100644 --- a/tests/components/spi_device/test.rp2040-ard.yaml +++ b/tests/components/spi_device/test.rp2040-ard.yaml @@ -1,11 +1,6 @@ -spi: - - id: spi_device1 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 -spi_device: - id: spi_device_test - data_rate: 2MHz - spi_mode: 3 - bit_order: lsb_first +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/common.yaml b/tests/components/spi_led_strip/common.yaml new file mode 100644 index 0000000000..80b98a63a4 --- /dev/null +++ b/tests/components/spi_led_strip/common.yaml @@ -0,0 +1,12 @@ +spi: + - id: spi_spi_led_strip + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +light: + - platform: spi_led_strip + num_leds: 4 + color_correct: [80%, 60%, 100%] + id: rgb_led + name: RGB LED + data_rate: 8MHz diff --git a/tests/components/spi_led_strip/test.esp32-ard.yaml b/tests/components/spi_led_strip/test.esp32-ard.yaml index f4a760bf4c..8906602ef4 100644 --- a/tests/components/spi_led_strip/test.esp32-ard.yaml +++ b/tests/components/spi_led_strip/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/test.esp32-c3-ard.yaml b/tests/components/spi_led_strip/test.esp32-c3-ard.yaml index 983ad2863f..a85b587070 100644 --- a/tests/components/spi_led_strip/test.esp32-c3-ard.yaml +++ b/tests/components/spi_led_strip/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/test.esp32-c3-idf.yaml b/tests/components/spi_led_strip/test.esp32-c3-idf.yaml index 983ad2863f..a85b587070 100644 --- a/tests/components/spi_led_strip/test.esp32-c3-idf.yaml +++ b/tests/components/spi_led_strip/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/test.esp32-idf.yaml b/tests/components/spi_led_strip/test.esp32-idf.yaml index f4a760bf4c..8906602ef4 100644 --- a/tests/components/spi_led_strip/test.esp32-idf.yaml +++ b/tests/components/spi_led_strip/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/test.esp8266-ard.yaml b/tests/components/spi_led_strip/test.esp8266-ard.yaml index 8e76303b6a..7baaa62ed5 100644 --- a/tests/components/spi_led_strip/test.esp8266-ard.yaml +++ b/tests/components/spi_led_strip/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/spi_led_strip/test.rp2040-ard.yaml b/tests/components/spi_led_strip/test.rp2040-ard.yaml index 9d12f1592b..411cfbe00e 100644 --- a/tests/components/spi_led_strip/test.rp2040-ard.yaml +++ b/tests/components/spi_led_strip/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -spi: - - id: spi_spi_led_strip - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 -light: - - platform: spi_led_strip - num_leds: 4 - color_correct: [80%, 60%, 100%] - id: rgb_led - name: "RGB LED" - data_rate: 8MHz +<<: !include common.yaml diff --git a/tests/components/sps30/common.yaml b/tests/components/sps30/common.yaml new file mode 100644 index 0000000000..2fbe2c747a --- /dev/null +++ b/tests/components/sps30/common.yaml @@ -0,0 +1,36 @@ +i2c: + - id: i2c_sps30 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sps30 + pm_1_0: + name: Workshop PM <1µm Weight concentration + id: workshop_PM_1_0 + pm_2_5: + name: Workshop PM <2.5µm Weight concentration + id: workshop_PM_2_5 + pm_4_0: + name: Workshop PM <4µm Weight concentration + id: workshop_PM_4_0 + pm_10_0: + name: Workshop PM <10µm Weight concentration + id: workshop_PM_10_0 + pmc_0_5: + name: Workshop PM <0.5µm Number concentration + id: workshop_PMC_0_5 + pmc_1_0: + name: Workshop PM <1µm Number concentration + id: workshop_PMC_1_0 + pmc_2_5: + name: Workshop PM <2.5µm Number concentration + id: workshop_PMC_2_5 + pmc_4_0: + name: Workshop PM <4µm Number concentration + id: workshop_PMC_4_0 + pmc_10_0: + name: Workshop PM <10µm Number concentration + id: workshop_PMC_10_0 + address: 0x69 + update_interval: 10s diff --git a/tests/components/sps30/test.esp32-ard.yaml b/tests/components/sps30/test.esp32-ard.yaml index f9d1ee4e55..63c3bd6afd 100644 --- a/tests/components/sps30/test.esp32-ard.yaml +++ b/tests/components/sps30/test.esp32-ard.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sps30/test.esp32-c3-ard.yaml b/tests/components/sps30/test.esp32-c3-ard.yaml index e071a00936..ee2c29ca4e 100644 --- a/tests/components/sps30/test.esp32-c3-ard.yaml +++ b/tests/components/sps30/test.esp32-c3-ard.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sps30/test.esp32-c3-idf.yaml b/tests/components/sps30/test.esp32-c3-idf.yaml index e071a00936..ee2c29ca4e 100644 --- a/tests/components/sps30/test.esp32-c3-idf.yaml +++ b/tests/components/sps30/test.esp32-c3-idf.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sps30/test.esp32-idf.yaml b/tests/components/sps30/test.esp32-idf.yaml index f9d1ee4e55..63c3bd6afd 100644 --- a/tests/components/sps30/test.esp32-idf.yaml +++ b/tests/components/sps30/test.esp32-idf.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sps30/test.esp8266-ard.yaml b/tests/components/sps30/test.esp8266-ard.yaml index e071a00936..ee2c29ca4e 100644 --- a/tests/components/sps30/test.esp8266-ard.yaml +++ b/tests/components/sps30/test.esp8266-ard.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/sps30/test.rp2040-ard.yaml b/tests/components/sps30/test.rp2040-ard.yaml index e071a00936..ee2c29ca4e 100644 --- a/tests/components/sps30/test.rp2040-ard.yaml +++ b/tests/components/sps30/test.rp2040-ard.yaml @@ -1,36 +1,5 @@ -i2c: - - id: i2c_sps30 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sps30 - pm_1_0: - name: Workshop PM <1µm Weight concentration - id: workshop_PM_1_0 - pm_2_5: - name: Workshop PM <2.5µm Weight concentration - id: workshop_PM_2_5 - pm_4_0: - name: Workshop PM <4µm Weight concentration - id: workshop_PM_4_0 - pm_10_0: - name: Workshop PM <10µm Weight concentration - id: workshop_PM_10_0 - pmc_0_5: - name: Workshop PM <0.5µm Number concentration - id: workshop_PMC_0_5 - pmc_1_0: - name: Workshop PM <1µm Number concentration - id: workshop_PMC_1_0 - pmc_2_5: - name: Workshop PM <2.5µm Number concentration - id: workshop_PMC_2_5 - pmc_4_0: - name: Workshop PM <4µm Number concentration - id: workshop_PMC_4_0 - pmc_10_0: - name: Workshop PM <10µm Number concentration - id: workshop_PMC_10_0 - address: 0x69 - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/common.yaml b/tests/components/ssd1306_i2c/common.yaml new file mode 100644 index 0000000000..d17f83f03a --- /dev/null +++ b/tests/components/ssd1306_i2c/common.yaml @@ -0,0 +1,25 @@ +i2c: + - id: i2c_ssd1306_i2c + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1306_i2c + model: SSD1306_128X64 + reset_pin: ${reset_pin} + address: 0x3C + id: display1 + contrast: 60% + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, 10, 10); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1306_i2c/test.esp32-ard.yaml b/tests/components/ssd1306_i2c/test.esp32-ard.yaml index dddc67309c..1ca773e06c 100644 --- a/tests/components/ssd1306_i2c/test.esp32-ard.yaml +++ b/tests/components/ssd1306_i2c/test.esp32-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/test.esp32-c3-ard.yaml b/tests/components/ssd1306_i2c/test.esp32-c3-ard.yaml index f4a301db51..4eaff7fa4a 100644 --- a/tests/components/ssd1306_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1306_i2c/test.esp32-c3-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/test.esp32-c3-idf.yaml b/tests/components/ssd1306_i2c/test.esp32-c3-idf.yaml index f4a301db51..4eaff7fa4a 100644 --- a/tests/components/ssd1306_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1306_i2c/test.esp32-c3-idf.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/test.esp32-idf.yaml b/tests/components/ssd1306_i2c/test.esp32-idf.yaml index dddc67309c..1ca773e06c 100644 --- a/tests/components/ssd1306_i2c/test.esp32-idf.yaml +++ b/tests/components/ssd1306_i2c/test.esp32-idf.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/test.esp8266-ard.yaml b/tests/components/ssd1306_i2c/test.esp8266-ard.yaml index f4a301db51..af91c21a0d 100644 --- a/tests/components/ssd1306_i2c/test.esp8266-ard.yaml +++ b/tests/components/ssd1306_i2c/test.esp8266-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO2 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_i2c/test.rp2040-ard.yaml b/tests/components/ssd1306_i2c/test.rp2040-ard.yaml index f4a301db51..4eaff7fa4a 100644 --- a/tests/components/ssd1306_i2c/test.rp2040-ard.yaml +++ b/tests/components/ssd1306_i2c/test.rp2040-ard.yaml @@ -1,25 +1,6 @@ -i2c: - - id: i2c_ssd1306_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - model: SSD1306_128X64 - reset_pin: 3 - address: 0x3C - id: display1 - contrast: 60% - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/common.yaml b/tests/components/ssd1306_spi/common.yaml new file mode 100644 index 0000000000..71705f32d2 --- /dev/null +++ b/tests/components/ssd1306_spi/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_ssd1306_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1306_spi + model: SSD1306 128x64 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1306_spi/test.esp32-ard.yaml b/tests/components/ssd1306_spi/test.esp32-ard.yaml index b0e5e0f1a2..bad5241f79 100644 --- a/tests/components/ssd1306_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1306_spi/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1306_spi/test.esp32-c3-ard.yaml index 01b2d0e4a8..c5c932c92c 100644 --- a/tests/components/ssd1306_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1306_spi/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1306_spi/test.esp32-c3-idf.yaml index 01b2d0e4a8..c5c932c92c 100644 --- a/tests/components/ssd1306_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1306_spi/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/test.esp32-idf.yaml b/tests/components/ssd1306_spi/test.esp32-idf.yaml index b0e5e0f1a2..bad5241f79 100644 --- a/tests/components/ssd1306_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1306_spi/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/test.esp8266-ard.yaml b/tests/components/ssd1306_spi/test.esp8266-ard.yaml index 135e364bb2..3f023a60eb 100644 --- a/tests/components/ssd1306_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1306_spi/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1306_spi/test.rp2040-ard.yaml b/tests/components/ssd1306_spi/test.rp2040-ard.yaml index 94c4b85158..d7fd6ee294 100644 --- a/tests/components/ssd1306_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1306_spi/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1306_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_spi - model: SSD1306 128x64 - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/common.yaml b/tests/components/ssd1322_spi/common.yaml new file mode 100644 index 0000000000..b67392794c --- /dev/null +++ b/tests/components/ssd1322_spi/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_ssd1322_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1322_spi + model: SSD1322 256x64 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1322_spi/test.esp32-ard.yaml b/tests/components/ssd1322_spi/test.esp32-ard.yaml index aa6d0fbf01..bad5241f79 100644 --- a/tests/components/ssd1322_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1322_spi/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1322_spi/test.esp32-c3-ard.yaml index 4fa9f86594..c5c932c92c 100644 --- a/tests/components/ssd1322_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1322_spi/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1322_spi/test.esp32-c3-idf.yaml index 4fa9f86594..c5c932c92c 100644 --- a/tests/components/ssd1322_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1322_spi/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/test.esp32-idf.yaml b/tests/components/ssd1322_spi/test.esp32-idf.yaml index aa6d0fbf01..bad5241f79 100644 --- a/tests/components/ssd1322_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1322_spi/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/test.esp8266-ard.yaml b/tests/components/ssd1322_spi/test.esp8266-ard.yaml index a5aa565c09..3f023a60eb 100644 --- a/tests/components/ssd1322_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1322_spi/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1322_spi/test.rp2040-ard.yaml b/tests/components/ssd1322_spi/test.rp2040-ard.yaml index 59544e7878..d7fd6ee294 100644 --- a/tests/components/ssd1322_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1322_spi/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1322_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1322_spi - model: SSD1322 256x64 - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/common.yaml b/tests/components/ssd1325_spi/common.yaml new file mode 100644 index 0000000000..eaa8b619ca --- /dev/null +++ b/tests/components/ssd1325_spi/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_ssd1325_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1325_spi + model: SSD1325 128x64 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1325_spi/test.esp32-ard.yaml b/tests/components/ssd1325_spi/test.esp32-ard.yaml index 84d94eff28..bad5241f79 100644 --- a/tests/components/ssd1325_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1325_spi/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1325_spi/test.esp32-c3-ard.yaml index 0fa8cb6488..c5c932c92c 100644 --- a/tests/components/ssd1325_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1325_spi/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1325_spi/test.esp32-c3-idf.yaml index 0fa8cb6488..c5c932c92c 100644 --- a/tests/components/ssd1325_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1325_spi/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/test.esp32-idf.yaml b/tests/components/ssd1325_spi/test.esp32-idf.yaml index 84d94eff28..bad5241f79 100644 --- a/tests/components/ssd1325_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1325_spi/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/test.esp8266-ard.yaml b/tests/components/ssd1325_spi/test.esp8266-ard.yaml index 9d7e483585..3f023a60eb 100644 --- a/tests/components/ssd1325_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1325_spi/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1325_spi/test.rp2040-ard.yaml b/tests/components/ssd1325_spi/test.rp2040-ard.yaml index 869663c19d..d7fd6ee294 100644 --- a/tests/components/ssd1325_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1325_spi/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1325_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1325_spi - model: SSD1325 128x64 - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/common.yaml b/tests/components/ssd1327_i2c/common.yaml new file mode 100644 index 0000000000..72a122c3d7 --- /dev/null +++ b/tests/components/ssd1327_i2c/common.yaml @@ -0,0 +1,24 @@ +i2c: + - id: i2c_ssd1327_i2c + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1327_i2c + model: SSD1327_128x128 + reset_pin: ${reset_pin} + address: 0x3C + id: display1 + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, 10, 10); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1327_i2c/test.esp32-ard.yaml b/tests/components/ssd1327_i2c/test.esp32-ard.yaml index e72a9c7b7a..1ca773e06c 100644 --- a/tests/components/ssd1327_i2c/test.esp32-ard.yaml +++ b/tests/components/ssd1327_i2c/test.esp32-ard.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/test.esp32-c3-ard.yaml b/tests/components/ssd1327_i2c/test.esp32-c3-ard.yaml index cd28795ff1..4eaff7fa4a 100644 --- a/tests/components/ssd1327_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1327_i2c/test.esp32-c3-ard.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/test.esp32-c3-idf.yaml b/tests/components/ssd1327_i2c/test.esp32-c3-idf.yaml index cd28795ff1..4eaff7fa4a 100644 --- a/tests/components/ssd1327_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1327_i2c/test.esp32-c3-idf.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/test.esp32-idf.yaml b/tests/components/ssd1327_i2c/test.esp32-idf.yaml index e72a9c7b7a..1ca773e06c 100644 --- a/tests/components/ssd1327_i2c/test.esp32-idf.yaml +++ b/tests/components/ssd1327_i2c/test.esp32-idf.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/test.esp8266-ard.yaml b/tests/components/ssd1327_i2c/test.esp8266-ard.yaml index cd28795ff1..af91c21a0d 100644 --- a/tests/components/ssd1327_i2c/test.esp8266-ard.yaml +++ b/tests/components/ssd1327_i2c/test.esp8266-ard.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO2 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_i2c/test.rp2040-ard.yaml b/tests/components/ssd1327_i2c/test.rp2040-ard.yaml index cd28795ff1..4eaff7fa4a 100644 --- a/tests/components/ssd1327_i2c/test.rp2040-ard.yaml +++ b/tests/components/ssd1327_i2c/test.rp2040-ard.yaml @@ -1,24 +1,6 @@ -i2c: - - id: i2c_ssd1327_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: ssd1327_i2c - model: SSD1327_128x128 - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/common.yaml b/tests/components/ssd1327_spi/common.yaml new file mode 100644 index 0000000000..85f4d4736b --- /dev/null +++ b/tests/components/ssd1327_spi/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_ssd1327_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1327_spi + model: SSD1327 128x128 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1327_spi/test.esp32-ard.yaml b/tests/components/ssd1327_spi/test.esp32-ard.yaml index e103ded187..bad5241f79 100644 --- a/tests/components/ssd1327_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1327_spi/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1327_spi/test.esp32-c3-ard.yaml index ec5795d716..c5c932c92c 100644 --- a/tests/components/ssd1327_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1327_spi/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1327_spi/test.esp32-c3-idf.yaml index ec5795d716..c5c932c92c 100644 --- a/tests/components/ssd1327_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1327_spi/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/test.esp32-idf.yaml b/tests/components/ssd1327_spi/test.esp32-idf.yaml index e103ded187..bad5241f79 100644 --- a/tests/components/ssd1327_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1327_spi/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/test.esp8266-ard.yaml b/tests/components/ssd1327_spi/test.esp8266-ard.yaml index 30455d24ee..3f023a60eb 100644 --- a/tests/components/ssd1327_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1327_spi/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1327_spi/test.rp2040-ard.yaml b/tests/components/ssd1327_spi/test.rp2040-ard.yaml index f819ab2c41..d7fd6ee294 100644 --- a/tests/components/ssd1327_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1327_spi/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1327_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1327_spi - model: SSD1327 128x128 - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/common.yaml b/tests/components/ssd1331_spi/common.yaml new file mode 100644 index 0000000000..40726101e8 --- /dev/null +++ b/tests/components/ssd1331_spi/common.yaml @@ -0,0 +1,23 @@ +spi: + - id: spi_ssd1331_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1331_spi + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1331_spi/test.esp32-ard.yaml b/tests/components/ssd1331_spi/test.esp32-ard.yaml index e9eb8ea9ad..bad5241f79 100644 --- a/tests/components/ssd1331_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1331_spi/test.esp32-ard.yaml @@ -1,24 +1,8 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1331_spi - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1331_spi/test.esp32-c3-ard.yaml index 9a35918faf..c5c932c92c 100644 --- a/tests/components/ssd1331_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1331_spi/test.esp32-c3-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1331_spi - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1331_spi/test.esp32-c3-idf.yaml index 9a35918faf..c5c932c92c 100644 --- a/tests/components/ssd1331_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1331_spi/test.esp32-c3-idf.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1331_spi - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/test.esp32-idf.yaml b/tests/components/ssd1331_spi/test.esp32-idf.yaml index e9eb8ea9ad..bad5241f79 100644 --- a/tests/components/ssd1331_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1331_spi/test.esp32-idf.yaml @@ -1,24 +1,8 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1331_spi - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/test.esp8266-ard.yaml b/tests/components/ssd1331_spi/test.esp8266-ard.yaml index 3b319ef38e..3f023a60eb 100644 --- a/tests/components/ssd1331_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1331_spi/test.esp8266-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1331_spi - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1331_spi/test.rp2040-ard.yaml b/tests/components/ssd1331_spi/test.rp2040-ard.yaml index 947685b07a..d7fd6ee294 100644 --- a/tests/components/ssd1331_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1331_spi/test.rp2040-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_ssd1331_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1331_spi - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/common.yaml b/tests/components/ssd1351_spi/common.yaml new file mode 100644 index 0000000000..fa495ff0c3 --- /dev/null +++ b/tests/components/ssd1351_spi/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_ssd1351_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: ssd1351_spi + model: "SSD1351 128x128" + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/ssd1351_spi/test.esp32-ard.yaml b/tests/components/ssd1351_spi/test.esp32-ard.yaml index 8342cb972b..bad5241f79 100644 --- a/tests/components/ssd1351_spi/test.esp32-ard.yaml +++ b/tests/components/ssd1351_spi/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/test.esp32-c3-ard.yaml b/tests/components/ssd1351_spi/test.esp32-c3-ard.yaml index 2a7266f502..c5c932c92c 100644 --- a/tests/components/ssd1351_spi/test.esp32-c3-ard.yaml +++ b/tests/components/ssd1351_spi/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/test.esp32-c3-idf.yaml b/tests/components/ssd1351_spi/test.esp32-c3-idf.yaml index 2a7266f502..c5c932c92c 100644 --- a/tests/components/ssd1351_spi/test.esp32-c3-idf.yaml +++ b/tests/components/ssd1351_spi/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/test.esp32-idf.yaml b/tests/components/ssd1351_spi/test.esp32-idf.yaml index 8342cb972b..bad5241f79 100644 --- a/tests/components/ssd1351_spi/test.esp32-idf.yaml +++ b/tests/components/ssd1351_spi/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/test.esp8266-ard.yaml b/tests/components/ssd1351_spi/test.esp8266-ard.yaml index 7ed9a31dde..3f023a60eb 100644 --- a/tests/components/ssd1351_spi/test.esp8266-ard.yaml +++ b/tests/components/ssd1351_spi/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/ssd1351_spi/test.rp2040-ard.yaml b/tests/components/ssd1351_spi/test.rp2040-ard.yaml index 72936d046b..d7fd6ee294 100644 --- a/tests/components/ssd1351_spi/test.rp2040-ard.yaml +++ b/tests/components/ssd1351_spi/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_ssd1351_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1351_spi - model: "SSD1351 128x128" - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/common.yaml b/tests/components/st7567_i2c/common.yaml new file mode 100644 index 0000000000..41c65e5110 --- /dev/null +++ b/tests/components/st7567_i2c/common.yaml @@ -0,0 +1,23 @@ +i2c: + - id: i2c_st7567_i2c + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: st7567_i2c + reset_pin: ${reset_pin} + address: 0x3C + id: display1 + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, 10, 10); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/st7567_i2c/test.esp32-ard.yaml b/tests/components/st7567_i2c/test.esp32-ard.yaml index b7aee61b68..1ca773e06c 100644 --- a/tests/components/st7567_i2c/test.esp32-ard.yaml +++ b/tests/components/st7567_i2c/test.esp32-ard.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/test.esp32-c3-ard.yaml b/tests/components/st7567_i2c/test.esp32-c3-ard.yaml index d779040500..4eaff7fa4a 100644 --- a/tests/components/st7567_i2c/test.esp32-c3-ard.yaml +++ b/tests/components/st7567_i2c/test.esp32-c3-ard.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/test.esp32-c3-idf.yaml b/tests/components/st7567_i2c/test.esp32-c3-idf.yaml index d779040500..4eaff7fa4a 100644 --- a/tests/components/st7567_i2c/test.esp32-c3-idf.yaml +++ b/tests/components/st7567_i2c/test.esp32-c3-idf.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/test.esp32-idf.yaml b/tests/components/st7567_i2c/test.esp32-idf.yaml index b7aee61b68..1ca773e06c 100644 --- a/tests/components/st7567_i2c/test.esp32-idf.yaml +++ b/tests/components/st7567_i2c/test.esp32-idf.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + reset_pin: GPIO15 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/test.esp8266-ard.yaml b/tests/components/st7567_i2c/test.esp8266-ard.yaml index d779040500..af91c21a0d 100644 --- a/tests/components/st7567_i2c/test.esp8266-ard.yaml +++ b/tests/components/st7567_i2c/test.esp8266-ard.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO2 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_i2c/test.rp2040-ard.yaml b/tests/components/st7567_i2c/test.rp2040-ard.yaml index d779040500..4eaff7fa4a 100644 --- a/tests/components/st7567_i2c/test.rp2040-ard.yaml +++ b/tests/components/st7567_i2c/test.rp2040-ard.yaml @@ -1,23 +1,6 @@ -i2c: - - id: i2c_st7567_i2c - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 + reset_pin: GPIO3 -display: - - platform: st7567_i2c - reset_pin: 3 - address: 0x3C - id: display1 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, 10, 10); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/common.yaml b/tests/components/st7567_spi/common.yaml new file mode 100644 index 0000000000..037a700239 --- /dev/null +++ b/tests/components/st7567_spi/common.yaml @@ -0,0 +1,23 @@ +spi: + - id: spi_st7567_spi + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: st7567_spi + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/st7567_spi/test.esp32-ard.yaml b/tests/components/st7567_spi/test.esp32-ard.yaml index bb4530248f..bad5241f79 100644 --- a/tests/components/st7567_spi/test.esp32-ard.yaml +++ b/tests/components/st7567_spi/test.esp32-ard.yaml @@ -1,24 +1,8 @@ -spi: - - id: spi_st7567_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7567_spi - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/test.esp32-c3-ard.yaml b/tests/components/st7567_spi/test.esp32-c3-ard.yaml index b799ce7302..c5c932c92c 100644 --- a/tests/components/st7567_spi/test.esp32-c3-ard.yaml +++ b/tests/components/st7567_spi/test.esp32-c3-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_st7567_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7567_spi - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/test.esp32-c3-idf.yaml b/tests/components/st7567_spi/test.esp32-c3-idf.yaml index b799ce7302..c5c932c92c 100644 --- a/tests/components/st7567_spi/test.esp32-c3-idf.yaml +++ b/tests/components/st7567_spi/test.esp32-c3-idf.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_st7567_spi - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7567_spi - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/test.esp32-idf.yaml b/tests/components/st7567_spi/test.esp32-idf.yaml index bb4530248f..bad5241f79 100644 --- a/tests/components/st7567_spi/test.esp32-idf.yaml +++ b/tests/components/st7567_spi/test.esp32-idf.yaml @@ -1,24 +1,8 @@ -spi: - - id: spi_st7567_spi - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7567_spi - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/test.esp8266-ard.yaml b/tests/components/st7567_spi/test.esp8266-ard.yaml index bbc47e67f6..3f023a60eb 100644 --- a/tests/components/st7567_spi/test.esp8266-ard.yaml +++ b/tests/components/st7567_spi/test.esp8266-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_st7567_spi - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7567_spi - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7567_spi/test.rp2040-ard.yaml b/tests/components/st7567_spi/test.rp2040-ard.yaml index 1b491101a8..d7fd6ee294 100644 --- a/tests/components/st7567_spi/test.rp2040-ard.yaml +++ b/tests/components/st7567_spi/test.rp2040-ard.yaml @@ -1,24 +1,9 @@ -spi: - - id: spi_st7567_spi - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7567_spi - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7701s/common.yaml b/tests/components/st7701s/common.yaml index 6e4fccc9cb..b94fadfe52 100644 --- a/tests/components/st7701s/common.yaml +++ b/tests/components/st7701s/common.yaml @@ -1,21 +1,7 @@ -psram: - mode: octal - speed: 80MHz spi: - - id: lcd_spi - clk_pin: 41 - mosi_pin: 48 - -i2c: - sda: 39 - scl: 40 - scan: false - id: bus_a - -pca9554: - - id: p_c_a - pin_count: 16 - address: 0x20 + - id: spi_st7701s + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} display: - platform: st7701s @@ -28,16 +14,12 @@ display: transform: mirror_x: true mirror_y: true - cs_pin: - pca9554: p_c_a - number: 4 - reset_pin: - pca9554: p_c_a - number: 5 - de_pin: 18 - hsync_pin: 16 - vsync_pin: 17 - pclk_pin: 21 + cs_pin: ${cs_pin} + reset_pin: ${reset_pin} + de_pin: ${de_pin} + hsync_pin: ${hsync_pin} + vsync_pin: ${vsync_pin} + pclk_pin: ${pclk_pin} init_sequence: - 1 - [0x23, 0xA, 0xB] @@ -45,13 +27,11 @@ display: - [0x23, 0xA, 0xB] - delay 0.2s data_pins: - - number: 0 - ignore_strapping_warning: true + - 0 - 1 - 2 - 3 - - number: 4 - ignore_strapping_warning: false + - 4 - 5 - 6 - 7 diff --git a/tests/components/st7701s/test.esp32-s3-idf.yaml b/tests/components/st7701s/test.esp32-s3-idf.yaml index dade44d145..cd09b31f6e 100644 --- a/tests/components/st7701s/test.esp32-s3-idf.yaml +++ b/tests/components/st7701s/test.esp32-s3-idf.yaml @@ -1 +1,11 @@ +substitutions: + clk_pin: GPIO41 + mosi_pin: GPIO48 + cs_pin: GPIO44 + de_pin: GPIO18 + reset_pin: GPIO47 + hsync_pin: GPIO16 + vsync_pin: GPIO17 + pclk_pin: GPIO21 + <<: !include common.yaml diff --git a/tests/components/st7735/common.yaml b/tests/components/st7735/common.yaml new file mode 100644 index 0000000000..c140652eda --- /dev/null +++ b/tests/components/st7735/common.yaml @@ -0,0 +1,28 @@ +spi: + - id: spi_st7735 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: st7735 + model: INITR_18BLACKTAB + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + device_width: 128 + device_height: 160 + col_start: 0 + row_start: 0 + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/st7735/test.esp32-ard.yaml b/tests/components/st7735/test.esp32-ard.yaml index fd3f6cade6..bad5241f79 100644 --- a/tests/components/st7735/test.esp32-ard.yaml +++ b/tests/components/st7735/test.esp32-ard.yaml @@ -1,29 +1,8 @@ -spi: - - id: spi_st7735 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7735/test.esp32-c3-ard.yaml b/tests/components/st7735/test.esp32-c3-ard.yaml index fc6c2421c4..c5c932c92c 100644 --- a/tests/components/st7735/test.esp32-c3-ard.yaml +++ b/tests/components/st7735/test.esp32-c3-ard.yaml @@ -1,29 +1,9 @@ -spi: - - id: spi_st7735 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7735/test.esp32-c3-idf.yaml b/tests/components/st7735/test.esp32-c3-idf.yaml index fc6c2421c4..c5c932c92c 100644 --- a/tests/components/st7735/test.esp32-c3-idf.yaml +++ b/tests/components/st7735/test.esp32-c3-idf.yaml @@ -1,29 +1,9 @@ -spi: - - id: spi_st7735 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 2 - dc_pin: 3 - reset_pin: 4 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7735/test.esp32-idf.yaml b/tests/components/st7735/test.esp32-idf.yaml index fd3f6cade6..bad5241f79 100644 --- a/tests/components/st7735/test.esp32-idf.yaml +++ b/tests/components/st7735/test.esp32-idf.yaml @@ -1,29 +1,8 @@ -spi: - - id: spi_st7735 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7735/test.esp8266-ard.yaml b/tests/components/st7735/test.esp8266-ard.yaml index ea8fa93c36..3f023a60eb 100644 --- a/tests/components/st7735/test.esp8266-ard.yaml +++ b/tests/components/st7735/test.esp8266-ard.yaml @@ -1,29 +1,9 @@ -spi: - - id: spi_st7735 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7735/test.rp2040-ard.yaml b/tests/components/st7735/test.rp2040-ard.yaml index 828f9a3ae1..d7fd6ee294 100644 --- a/tests/components/st7735/test.rp2040-ard.yaml +++ b/tests/components/st7735/test.rp2040-ard.yaml @@ -1,29 +1,9 @@ -spi: - - id: spi_st7735 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7735 - model: "INITR_18BLACKTAB" - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - device_width: 128 - device_height: 160 - col_start: 0 - row_start: 0 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/common.yaml b/tests/components/st7789v/common.yaml new file mode 100644 index 0000000000..d5f74809e0 --- /dev/null +++ b/tests/components/st7789v/common.yaml @@ -0,0 +1,24 @@ +spi: + - id: spi_st7789v + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: st7789v + model: TTGO TDisplay 135x240 + cs_pin: ${cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/st7789v/test.esp32-ard.yaml b/tests/components/st7789v/test.esp32-ard.yaml index 54a9db6da1..bad5241f79 100644 --- a/tests/components/st7789v/test.esp32-ard.yaml +++ b/tests/components/st7789v/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_st7789v - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/test.esp32-c3-ard.yaml b/tests/components/st7789v/test.esp32-c3-ard.yaml index 1cb8d22fcb..c5c932c92c 100644 --- a/tests/components/st7789v/test.esp32-c3-ard.yaml +++ b/tests/components/st7789v/test.esp32-c3-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_st7789v - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 2 - dc_pin: 3 - reset_pin: 8 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/test.esp32-c3-idf.yaml b/tests/components/st7789v/test.esp32-c3-idf.yaml index 1cb8d22fcb..c5c932c92c 100644 --- a/tests/components/st7789v/test.esp32-c3-idf.yaml +++ b/tests/components/st7789v/test.esp32-c3-idf.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_st7789v - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 + dc_pin: GPIO9 + reset_pin: GPIO10 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 2 - dc_pin: 3 - reset_pin: 8 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/test.esp32-idf.yaml b/tests/components/st7789v/test.esp32-idf.yaml index 54a9db6da1..bad5241f79 100644 --- a/tests/components/st7789v/test.esp32-idf.yaml +++ b/tests/components/st7789v/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -spi: - - id: spi_st7789v - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 + dc_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 12 - dc_pin: 13 - reset_pin: 14 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/test.esp8266-ard.yaml b/tests/components/st7789v/test.esp8266-ard.yaml index deeceb8c9a..3f023a60eb 100644 --- a/tests/components/st7789v/test.esp8266-ard.yaml +++ b/tests/components/st7789v/test.esp8266-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_st7789v - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 15 - dc_pin: 16 - reset_pin: 5 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7789v/test.rp2040-ard.yaml b/tests/components/st7789v/test.rp2040-ard.yaml index 778aa2aa55..d7fd6ee294 100644 --- a/tests/components/st7789v/test.rp2040-ard.yaml +++ b/tests/components/st7789v/test.rp2040-ard.yaml @@ -1,25 +1,9 @@ -spi: - - id: spi_st7789v - clk_pin: 2 - mosi_pin: 3 - miso_pin: 8 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 + dc_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: st7789v - model: TTGO TDisplay 135x240 - cs_pin: 5 - dc_pin: 6 - reset_pin: 7 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/common.yaml b/tests/components/st7920/common.yaml new file mode 100644 index 0000000000..9ede271f01 --- /dev/null +++ b/tests/components/st7920/common.yaml @@ -0,0 +1,23 @@ +spi: + - id: spi_st7920 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: st7920 + cs_pin: ${cs_pin} + height: 128 + width: 64 + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - id: page2 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + on_page_change: + from: page1 + to: page2 + then: + lambda: |- + ESP_LOGD("display", "1 -> 2"); diff --git a/tests/components/st7920/test.esp32-ard.yaml b/tests/components/st7920/test.esp32-ard.yaml index cdcbc85642..04d2633d2b 100644 --- a/tests/components/st7920/test.esp32-ard.yaml +++ b/tests/components/st7920/test.esp32-ard.yaml @@ -1,24 +1,6 @@ -spi: - - id: spi_st7920 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 -display: - - platform: st7920 - cs_pin: 12 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/test.esp32-c3-ard.yaml b/tests/components/st7920/test.esp32-c3-ard.yaml index 84ae88461f..2415ba5dc6 100644 --- a/tests/components/st7920/test.esp32-c3-ard.yaml +++ b/tests/components/st7920/test.esp32-c3-ard.yaml @@ -1,24 +1,7 @@ -spi: - - id: spi_st7920 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -display: - - platform: st7920 - cs_pin: 2 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/test.esp32-c3-idf.yaml b/tests/components/st7920/test.esp32-c3-idf.yaml index 84ae88461f..2415ba5dc6 100644 --- a/tests/components/st7920/test.esp32-c3-idf.yaml +++ b/tests/components/st7920/test.esp32-c3-idf.yaml @@ -1,24 +1,7 @@ -spi: - - id: spi_st7920 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO5 + cs_pin: GPIO8 -display: - - platform: st7920 - cs_pin: 2 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/test.esp32-idf.yaml b/tests/components/st7920/test.esp32-idf.yaml index cdcbc85642..04d2633d2b 100644 --- a/tests/components/st7920/test.esp32-idf.yaml +++ b/tests/components/st7920/test.esp32-idf.yaml @@ -1,24 +1,6 @@ -spi: - - id: spi_st7920 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO12 -display: - - platform: st7920 - cs_pin: 12 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/test.esp8266-ard.yaml b/tests/components/st7920/test.esp8266-ard.yaml index 0450bf1c5e..bd5c203e35 100644 --- a/tests/components/st7920/test.esp8266-ard.yaml +++ b/tests/components/st7920/test.esp8266-ard.yaml @@ -1,24 +1,7 @@ -spi: - - id: spi_st7920 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + cs_pin: GPIO5 -display: - - platform: st7920 - cs_pin: 15 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/st7920/test.rp2040-ard.yaml b/tests/components/st7920/test.rp2040-ard.yaml index f442820e7b..f6c3f1eeca 100644 --- a/tests/components/st7920/test.rp2040-ard.yaml +++ b/tests/components/st7920/test.rp2040-ard.yaml @@ -1,24 +1,7 @@ -spi: - - id: spi_st7920 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + miso_pin: GPIO4 + cs_pin: GPIO5 -display: - - platform: st7920 - cs_pin: 5 - height: 128 - width: 64 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - id: page2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - on_page_change: - from: page1 - to: page2 - then: - lambda: |- - ESP_LOGD("display", "1 -> 2"); +<<: !include common.yaml diff --git a/tests/components/sts3x/common.yaml b/tests/components/sts3x/common.yaml new file mode 100644 index 0000000000..1feac4bc3f --- /dev/null +++ b/tests/components/sts3x/common.yaml @@ -0,0 +1,10 @@ +i2c: + - id: i2c_sts3x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: sts3x + id: sts3x_sensor + name: STS3X Temperature + address: 0x4A diff --git a/tests/components/sts3x/test.esp32-ard.yaml b/tests/components/sts3x/test.esp32-ard.yaml index a74d61e748..63c3bd6afd 100644 --- a/tests/components/sts3x/test.esp32-ard.yaml +++ b/tests/components/sts3x/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sts3x/test.esp32-c3-ard.yaml b/tests/components/sts3x/test.esp32-c3-ard.yaml index 87980ce3a7..ee2c29ca4e 100644 --- a/tests/components/sts3x/test.esp32-c3-ard.yaml +++ b/tests/components/sts3x/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sts3x/test.esp32-c3-idf.yaml b/tests/components/sts3x/test.esp32-c3-idf.yaml index 87980ce3a7..ee2c29ca4e 100644 --- a/tests/components/sts3x/test.esp32-c3-idf.yaml +++ b/tests/components/sts3x/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sts3x/test.esp32-idf.yaml b/tests/components/sts3x/test.esp32-idf.yaml index a74d61e748..63c3bd6afd 100644 --- a/tests/components/sts3x/test.esp32-idf.yaml +++ b/tests/components/sts3x/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sts3x/test.esp8266-ard.yaml b/tests/components/sts3x/test.esp8266-ard.yaml index 87980ce3a7..ee2c29ca4e 100644 --- a/tests/components/sts3x/test.esp8266-ard.yaml +++ b/tests/components/sts3x/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sts3x/test.rp2040-ard.yaml b/tests/components/sts3x/test.rp2040-ard.yaml index 87980ce3a7..ee2c29ca4e 100644 --- a/tests/components/sts3x/test.rp2040-ard.yaml +++ b/tests/components/sts3x/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -i2c: - - id: i2c_sts3x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: sts3x - id: sts3x_sensor - name: STS3X Temperature - address: 0x4A +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/common.yaml b/tests/components/sun_gtil2/common.yaml new file mode 100644 index 0000000000..15cc892d90 --- /dev/null +++ b/tests/components/sun_gtil2/common.yaml @@ -0,0 +1,40 @@ +uart: + - id: uart_sun_gtil2 + rx_pin: ${rx_pin} + baud_rate: 9600 + +sun_gtil2: + +sensor: + - platform: sun_gtil2 + temperature: + id: gtil_temperature + name: Heatsink Temperature + filters: + - throttle_average: 30s + dc_voltage: + id: gtil_dc_voltage + name: DC Voltage + filters: + - throttle_average: 30s + ac_voltage: + id: gtil_ac_voltage + name: AC Voltage + filters: + - throttle_average: 30s + ac_power: + id: gtil_ac_power + name: AC Power + dc_power: + id: gtil_dc_power + name: DC Power + limiter_power: + id: gtil_limiter_power + +text_sensor: + - platform: sun_gtil2 + state: + id: gtil_state + name: State + serial_number: + id: gtil_serial_number diff --git a/tests/components/sun_gtil2/test.esp32-ard.yaml b/tests/components/sun_gtil2/test.esp32-ard.yaml index ed1e68e574..ad420099ff 100644 --- a/tests/components/sun_gtil2/test.esp32-ard.yaml +++ b/tests/components/sun_gtil2/test.esp32-ard.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + rx_pin: GPIO16 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/test.esp32-c3-ard.yaml b/tests/components/sun_gtil2/test.esp32-c3-ard.yaml index 6ec834db98..b8a6b85616 100644 --- a/tests/components/sun_gtil2/test.esp32-c3-ard.yaml +++ b/tests/components/sun_gtil2/test.esp32-c3-ard.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + rx_pin: GPIO5 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/test.esp32-c3-idf.yaml b/tests/components/sun_gtil2/test.esp32-c3-idf.yaml index 6ec834db98..b8a6b85616 100644 --- a/tests/components/sun_gtil2/test.esp32-c3-idf.yaml +++ b/tests/components/sun_gtil2/test.esp32-c3-idf.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + rx_pin: GPIO5 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/test.esp32-idf.yaml b/tests/components/sun_gtil2/test.esp32-idf.yaml index ed1e68e574..ad420099ff 100644 --- a/tests/components/sun_gtil2/test.esp32-idf.yaml +++ b/tests/components/sun_gtil2/test.esp32-idf.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 16 - baud_rate: 9600 +substitutions: + rx_pin: GPIO16 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/test.esp8266-ard.yaml b/tests/components/sun_gtil2/test.esp8266-ard.yaml index 6ec834db98..b8a6b85616 100644 --- a/tests/components/sun_gtil2/test.esp8266-ard.yaml +++ b/tests/components/sun_gtil2/test.esp8266-ard.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + rx_pin: GPIO5 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sun_gtil2/test.rp2040-ard.yaml b/tests/components/sun_gtil2/test.rp2040-ard.yaml index 6ec834db98..b8a6b85616 100644 --- a/tests/components/sun_gtil2/test.rp2040-ard.yaml +++ b/tests/components/sun_gtil2/test.rp2040-ard.yaml @@ -1,44 +1,4 @@ -uart: - - id: control_to_display - rx_pin: - number: 5 - baud_rate: 9600 +substitutions: + rx_pin: GPIO5 -sun_gtil2: - uart_id: control_to_display - -sensor: - - platform: sun_gtil2 - temperature: - id: gtil_temperature - name: "Heatsink Temperature" - filters: - - throttle_average: 30s - dc_voltage: - id: gtil_dc_voltage - name: "DC Voltage" - filters: - - throttle_average: 30s - ac_voltage: - id: gtil_ac_voltage - name: "AC Voltage" - filters: - - throttle_average: 30s - ac_power: - id: gtil_ac_power - name: "AC Power" - dc_power: - id: gtil_dc_power - name: "DC Power" - limiter_power: - id: gtil_limiter_power - internal: true - -text_sensor: - - platform: sun_gtil2 - state: - id: gtil_state - name: "State" - serial_number: - id: gtil_serial_number - internal: true +<<: !include common.yaml diff --git a/tests/components/sx1509/common.yaml b/tests/components/sx1509/common.yaml new file mode 100644 index 0000000000..a09d850649 --- /dev/null +++ b/tests/components/sx1509/common.yaml @@ -0,0 +1,33 @@ +i2c: + - id: i2c_sx1509 + scl: ${scl_pin} + sda: ${sda_pin} + +sx1509: + - id: sx1509_hub + address: 0x3E + +binary_sensor: + - platform: gpio + name: GPIO SX1509 Test + pin: + sx1509: sx1509_hub + number: 3 + +switch: + - platform: gpio + name: GPIO SX1509 Test Out Open Drain + pin: + sx1509: sx1509_hub + number: 0 + mode: + output: true + open_drain: true + + - platform: gpio + name: GPIO SX1509 Test Out Standard + pin: + sx1509: sx1509_hub + number: 1 + mode: + output: true diff --git a/tests/components/sx1509/test.esp32-ard.yaml b/tests/components/sx1509/test.esp32-ard.yaml index aa1d161a43..63c3bd6afd 100644 --- a/tests/components/sx1509/test.esp32-ard.yaml +++ b/tests/components/sx1509/test.esp32-ard.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml diff --git a/tests/components/sx1509/test.esp32-c3-ard.yaml b/tests/components/sx1509/test.esp32-c3-ard.yaml index 0397812880..ee2c29ca4e 100644 --- a/tests/components/sx1509/test.esp32-c3-ard.yaml +++ b/tests/components/sx1509/test.esp32-c3-ard.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml diff --git a/tests/components/sx1509/test.esp32-c3-idf.yaml b/tests/components/sx1509/test.esp32-c3-idf.yaml index 0397812880..ee2c29ca4e 100644 --- a/tests/components/sx1509/test.esp32-c3-idf.yaml +++ b/tests/components/sx1509/test.esp32-c3-idf.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml diff --git a/tests/components/sx1509/test.esp32-idf.yaml b/tests/components/sx1509/test.esp32-idf.yaml index aa1d161a43..63c3bd6afd 100644 --- a/tests/components/sx1509/test.esp32-idf.yaml +++ b/tests/components/sx1509/test.esp32-idf.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml diff --git a/tests/components/sx1509/test.esp8266-ard.yaml b/tests/components/sx1509/test.esp8266-ard.yaml index 0397812880..ee2c29ca4e 100644 --- a/tests/components/sx1509/test.esp8266-ard.yaml +++ b/tests/components/sx1509/test.esp8266-ard.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml diff --git a/tests/components/sx1509/test.rp2040-ard.yaml b/tests/components/sx1509/test.rp2040-ard.yaml index 0397812880..ee2c29ca4e 100644 --- a/tests/components/sx1509/test.rp2040-ard.yaml +++ b/tests/components/sx1509/test.rp2040-ard.yaml @@ -1,33 +1,5 @@ -i2c: - - id: i2c_sx1509 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sx1509: - - id: sx1509_hub - address: 0x3E - -binary_sensor: - - platform: gpio - name: GPIO SX1509 Test - pin: - sx1509: sx1509_hub - number: 3 - -switch: - - platform: gpio - name: GPIO SX1509 Test Out Open Drain - pin: - sx1509: sx1509_hub - number: 0 - mode: - output: true - open_drain: true - - - platform: gpio - name: GPIO SX1509 Test Out Standard - pin: - sx1509: sx1509_hub - number: 1 - mode: - output: true +<<: !include common.yaml From dc8646cda65da5c17acb4c70a3b6ceaa2f54bbe7 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sun, 9 Feb 2025 15:43:17 -0600 Subject: [PATCH 03/79] [CI] Consolidate some tests (U, V, W, X, Y, Z) (#8210) --- tests/components/ufire_ec/common.yaml | 25 ++ tests/components/ufire_ec/test.esp32-ard.yaml | 28 +-- .../ufire_ec/test.esp32-c3-ard.yaml | 28 +-- .../ufire_ec/test.esp32-c3-idf.yaml | 28 +-- tests/components/ufire_ec/test.esp32-idf.yaml | 28 +-- .../components/ufire_ec/test.esp8266-ard.yaml | 28 +-- .../components/ufire_ec/test.rp2040-ard.yaml | 28 +-- tests/components/ufire_ise/common.yaml | 25 ++ .../components/ufire_ise/test.esp32-ard.yaml | 28 +-- .../ufire_ise/test.esp32-c3-ard.yaml | 28 +-- .../ufire_ise/test.esp32-c3-idf.yaml | 28 +-- .../components/ufire_ise/test.esp32-idf.yaml | 28 +-- .../ufire_ise/test.esp8266-ard.yaml | 28 +-- .../components/ufire_ise/test.rp2040-ard.yaml | 28 +-- tests/components/uln2003/common.yaml | 29 +++ tests/components/uln2003/test.esp32-ard.yaml | 34 +-- .../components/uln2003/test.esp32-c3-ard.yaml | 34 +-- .../components/uln2003/test.esp32-c3-idf.yaml | 34 +-- tests/components/uln2003/test.esp32-idf.yaml | 34 +-- .../components/uln2003/test.esp8266-ard.yaml | 34 +-- tests/components/uln2003/test.rp2040-ard.yaml | 34 +-- tests/components/vbus/common.yaml | 42 ++++ tests/components/vbus/test.esp32-ard.yaml | 45 +--- tests/components/vbus/test.esp32-c3-ard.yaml | 45 +--- tests/components/vbus/test.esp32-c3-idf.yaml | 45 +--- tests/components/vbus/test.esp32-idf.yaml | 45 +--- tests/components/vbus/test.esp8266-ard.yaml | 45 +--- tests/components/vbus/test.rp2040-ard.yaml | 45 +--- tests/components/veml3235/common.yaml | 15 ++ tests/components/veml3235/test.esp32-ard.yaml | 18 +- .../veml3235/test.esp32-c3-ard.yaml | 18 +- .../veml3235/test.esp32-c3-idf.yaml | 18 +- tests/components/veml3235/test.esp32-idf.yaml | 18 +- .../components/veml3235/test.esp8266-ard.yaml | 18 +- .../components/veml3235/test.rp2040-ard.yaml | 18 +- tests/components/veml7700/common.yaml | 5 + tests/components/veml7700/test.esp32-ard.yaml | 7 +- .../veml7700/test.esp32-c3-ard.yaml | 7 +- .../veml7700/test.esp32-c3-idf.yaml | 7 +- tests/components/veml7700/test.esp32-idf.yaml | 7 +- .../components/veml7700/test.esp8266-ard.yaml | 7 +- .../components/veml7700/test.rp2040-ard.yaml | 7 +- tests/components/vl53l0x/common.yaml | 12 + tests/components/vl53l0x/test.esp32-ard.yaml | 15 +- .../components/vl53l0x/test.esp32-c3-ard.yaml | 15 +- .../components/vl53l0x/test.esp32-c3-idf.yaml | 15 +- tests/components/vl53l0x/test.esp32-idf.yaml | 15 +- .../components/vl53l0x/test.esp8266-ard.yaml | 15 +- tests/components/vl53l0x/test.rp2040-ard.yaml | 15 +- tests/components/voice_assistant/common.yaml | 57 +++++ .../voice_assistant/test.esp32-ard.yaml | 63 +----- .../voice_assistant/test.esp32-c3-ard.yaml | 62 +---- .../voice_assistant/test.esp32-c3-idf.yaml | 62 +---- .../voice_assistant/test.esp32-idf.yaml | 62 +---- tests/components/waveshare_epaper/common.yaml | 190 ++++++++++++++++ .../waveshare_epaper/test.esp32-ard.yaml | 214 +----------------- .../waveshare_epaper/test.esp32-c3-ard.yaml | 130 +---------- .../waveshare_epaper/test.esp32-c3-idf.yaml | 130 +---------- .../waveshare_epaper/test.esp32-idf.yaml | 130 +---------- .../waveshare_epaper/test.esp8266-ard.yaml | 130 +---------- .../waveshare_epaper/test.rp2040-ard.yaml | 130 +---------- tests/components/whirlpool/common.yaml | 7 + .../components/whirlpool/test.esp32-ard.yaml | 9 +- .../whirlpool/test.esp32-c3-ard.yaml | 9 +- .../whirlpool/test.esp32-c3-idf.yaml | 9 +- .../components/whirlpool/test.esp32-idf.yaml | 9 +- .../whirlpool/test.esp8266-ard.yaml | 9 +- tests/components/whynter/common.yaml | 7 + tests/components/whynter/test.esp32-ard.yaml | 9 +- .../components/whynter/test.esp32-c3-ard.yaml | 9 +- .../components/whynter/test.esp32-c3-idf.yaml | 9 +- tests/components/whynter/test.esp32-idf.yaml | 9 +- .../components/whynter/test.esp8266-ard.yaml | 9 +- tests/components/wl_134/common.yaml | 10 + tests/components/wl_134/test.esp32-ard.yaml | 13 +- .../components/wl_134/test.esp32-c3-ard.yaml | 13 +- .../components/wl_134/test.esp32-c3-idf.yaml | 13 +- tests/components/wl_134/test.esp32-idf.yaml | 13 +- tests/components/wl_134/test.esp8266-ard.yaml | 13 +- tests/components/wl_134/test.rp2040-ard.yaml | 13 +- tests/components/x9c/common.yaml | 8 + tests/components/x9c/test.esp32-ard.yaml | 14 +- tests/components/x9c/test.esp32-c3-ard.yaml | 14 +- tests/components/x9c/test.esp32-c3-idf.yaml | 14 +- tests/components/x9c/test.esp32-idf.yaml | 14 +- tests/components/x9c/test.esp8266-ard.yaml | 14 +- tests/components/x9c/test.rp2040-ard.yaml | 14 +- tests/components/xgzp68xx/common.yaml | 12 + tests/components/xgzp68xx/test.esp32-ard.yaml | 15 +- .../xgzp68xx/test.esp32-c3-ard.yaml | 15 +- .../xgzp68xx/test.esp32-c3-idf.yaml | 15 +- tests/components/xgzp68xx/test.esp32-idf.yaml | 15 +- .../components/xgzp68xx/test.esp8266-ard.yaml | 15 +- .../components/xgzp68xx/test.rp2040-ard.yaml | 15 +- tests/components/xl9535/common.yaml | 26 +++ tests/components/xl9535/test.esp32-ard.yaml | 29 +-- .../components/xl9535/test.esp32-c3-ard.yaml | 29 +-- .../components/xl9535/test.esp32-c3-idf.yaml | 29 +-- tests/components/xl9535/test.esp32-idf.yaml | 29 +-- tests/components/xl9535/test.esp8266-ard.yaml | 29 +-- tests/components/xl9535/test.rp2040-ard.yaml | 29 +-- tests/components/xpt2046/common.yaml | 35 +++ tests/components/xpt2046/test.esp32-ard.yaml | 44 +--- .../components/xpt2046/test.esp32-c3-ard.yaml | 44 +--- .../components/xpt2046/test.esp32-c3-idf.yaml | 44 +--- tests/components/xpt2046/test.esp32-idf.yaml | 44 +--- .../components/xpt2046/test.esp32-s2-ard.yaml | 38 ---- .../components/xpt2046/test.esp8266-ard.yaml | 44 +--- tests/components/xpt2046/test.rp2040-ard.yaml | 44 +--- tests/components/yashima/common.yaml | 7 + tests/components/yashima/test.esp32-ard.yaml | 9 +- .../components/yashima/test.esp32-c3-ard.yaml | 9 +- .../components/yashima/test.esp32-c3-idf.yaml | 9 +- tests/components/yashima/test.esp32-idf.yaml | 9 +- .../components/yashima/test.esp8266-ard.yaml | 9 +- tests/components/zhlt01/common.yaml | 7 + tests/components/zhlt01/test.esp32-ard.yaml | 9 +- .../components/zhlt01/test.esp32-c3-ard.yaml | 9 +- .../components/zhlt01/test.esp32-c3-idf.yaml | 9 +- tests/components/zhlt01/test.esp32-idf.yaml | 9 +- tests/components/zhlt01/test.esp8266-ard.yaml | 9 +- tests/components/zio_ultrasonic/common.yaml | 9 + .../zio_ultrasonic/test.esp32-ard.yaml | 12 +- .../zio_ultrasonic/test.esp32-c3-ard.yaml | 12 +- .../zio_ultrasonic/test.esp32-c3-idf.yaml | 12 +- .../zio_ultrasonic/test.esp32-idf.yaml | 12 +- .../zio_ultrasonic/test.esp8266-ard.yaml | 12 +- .../zio_ultrasonic/test.rp2040-ard.yaml | 12 +- tests/components/zyaura/common.yaml | 10 + tests/components/zyaura/test.esp32-ard.yaml | 15 +- .../components/zyaura/test.esp32-c3-ard.yaml | 15 +- .../components/zyaura/test.esp32-c3-idf.yaml | 15 +- tests/components/zyaura/test.esp32-idf.yaml | 15 +- tests/components/zyaura/test.esp8266-ard.yaml | 15 +- tests/components/zyaura/test.rp2040-ard.yaml | 15 +- 135 files changed, 1070 insertions(+), 2701 deletions(-) create mode 100644 tests/components/ufire_ec/common.yaml create mode 100644 tests/components/ufire_ise/common.yaml create mode 100644 tests/components/uln2003/common.yaml create mode 100644 tests/components/vbus/common.yaml create mode 100644 tests/components/veml3235/common.yaml create mode 100644 tests/components/vl53l0x/common.yaml create mode 100644 tests/components/voice_assistant/common.yaml create mode 100644 tests/components/waveshare_epaper/common.yaml create mode 100644 tests/components/whirlpool/common.yaml create mode 100644 tests/components/whynter/common.yaml create mode 100644 tests/components/wl_134/common.yaml create mode 100644 tests/components/x9c/common.yaml create mode 100644 tests/components/xgzp68xx/common.yaml create mode 100644 tests/components/xl9535/common.yaml create mode 100644 tests/components/xpt2046/common.yaml delete mode 100644 tests/components/xpt2046/test.esp32-s2-ard.yaml create mode 100644 tests/components/yashima/common.yaml create mode 100644 tests/components/zhlt01/common.yaml create mode 100644 tests/components/zio_ultrasonic/common.yaml create mode 100644 tests/components/zyaura/common.yaml diff --git a/tests/components/ufire_ec/common.yaml b/tests/components/ufire_ec/common.yaml new file mode 100644 index 0000000000..dcc957aaee --- /dev/null +++ b/tests/components/ufire_ec/common.yaml @@ -0,0 +1,25 @@ +esphome: + on_boot: + then: + - ufire_ec.calibrate_probe: + id: ufire_ec_board + solution: 0.146 + temperature: !lambda "return id(test_sensor).state;" + - ufire_ec.reset: + +i2c: + - id: i2c_ufire_ec + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: template + id: test_sensor + lambda: "return 21;" + - platform: ufire_ec + id: ufire_ec_board + ec: + name: Ufire EC + temperature_sensor: test_sensor + temperature_compensation: 20.0 + temperature_coefficient: 0.019 diff --git a/tests/components/ufire_ec/test.esp32-ard.yaml b/tests/components/ufire_ec/test.esp32-ard.yaml index 5e6a0daa9e..63c3bd6afd 100644 --- a/tests/components/ufire_ec/test.esp32-ard.yaml +++ b/tests/components/ufire_ec/test.esp32-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_ufire_ec - scl: 16 - sda: 17 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ec/test.esp32-c3-ard.yaml b/tests/components/ufire_ec/test.esp32-c3-ard.yaml index aa72c992b8..ee2c29ca4e 100644 --- a/tests/components/ufire_ec/test.esp32-c3-ard.yaml +++ b/tests/components/ufire_ec/test.esp32-c3-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ec - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ec/test.esp32-c3-idf.yaml b/tests/components/ufire_ec/test.esp32-c3-idf.yaml index aa72c992b8..ee2c29ca4e 100644 --- a/tests/components/ufire_ec/test.esp32-c3-idf.yaml +++ b/tests/components/ufire_ec/test.esp32-c3-idf.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ec - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ec/test.esp32-idf.yaml b/tests/components/ufire_ec/test.esp32-idf.yaml index 5e6a0daa9e..63c3bd6afd 100644 --- a/tests/components/ufire_ec/test.esp32-idf.yaml +++ b/tests/components/ufire_ec/test.esp32-idf.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_ufire_ec - scl: 16 - sda: 17 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ec/test.esp8266-ard.yaml b/tests/components/ufire_ec/test.esp8266-ard.yaml index aa72c992b8..ee2c29ca4e 100644 --- a/tests/components/ufire_ec/test.esp8266-ard.yaml +++ b/tests/components/ufire_ec/test.esp8266-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ec - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ec/test.rp2040-ard.yaml b/tests/components/ufire_ec/test.rp2040-ard.yaml index aa72c992b8..ee2c29ca4e 100644 --- a/tests/components/ufire_ec/test.rp2040-ard.yaml +++ b/tests/components/ufire_ec/test.rp2040-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ec.calibrate_probe: - id: ufire_ec_board - solution: 0.146 - temperature: !lambda "return id(test_sensor).state;" - - ufire_ec.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ec - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ec - id: ufire_ec_board - ec: - name: Ufire EC - temperature_sensor: test_sensor - temperature_compensation: 20.0 - temperature_coefficient: 0.019 +<<: !include common.yaml diff --git a/tests/components/ufire_ise/common.yaml b/tests/components/ufire_ise/common.yaml new file mode 100644 index 0000000000..d6ead8c479 --- /dev/null +++ b/tests/components/ufire_ise/common.yaml @@ -0,0 +1,25 @@ +esphome: + on_boot: + then: + - ufire_ise.calibrate_probe_high: + id: ufire_ise_sensor + solution: 7.0 + - ufire_ise.calibrate_probe_low: + id: ufire_ise_sensor + solution: 4.0 + - ufire_ise.reset: + +i2c: + - id: i2c_ufire_ise + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: template + id: test_sensor + lambda: "return 21;" + - platform: ufire_ise + id: ufire_ise_sensor + temperature_sensor: test_sensor + ph: + name: Ufire pH diff --git a/tests/components/ufire_ise/test.esp32-ard.yaml b/tests/components/ufire_ise/test.esp32-ard.yaml index 9ed0ac433a..63c3bd6afd 100644 --- a/tests/components/ufire_ise/test.esp32-ard.yaml +++ b/tests/components/ufire_ise/test.esp32-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_ufire_ise - scl: 16 - sda: 17 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/ufire_ise/test.esp32-c3-ard.yaml b/tests/components/ufire_ise/test.esp32-c3-ard.yaml index 36aec73113..ee2c29ca4e 100644 --- a/tests/components/ufire_ise/test.esp32-c3-ard.yaml +++ b/tests/components/ufire_ise/test.esp32-c3-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ise - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/ufire_ise/test.esp32-c3-idf.yaml b/tests/components/ufire_ise/test.esp32-c3-idf.yaml index 36aec73113..ee2c29ca4e 100644 --- a/tests/components/ufire_ise/test.esp32-c3-idf.yaml +++ b/tests/components/ufire_ise/test.esp32-c3-idf.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ise - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/ufire_ise/test.esp32-idf.yaml b/tests/components/ufire_ise/test.esp32-idf.yaml index 9ed0ac433a..63c3bd6afd 100644 --- a/tests/components/ufire_ise/test.esp32-idf.yaml +++ b/tests/components/ufire_ise/test.esp32-idf.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -i2c: - - id: i2c_ufire_ise - scl: 16 - sda: 17 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/ufire_ise/test.esp8266-ard.yaml b/tests/components/ufire_ise/test.esp8266-ard.yaml index 36aec73113..ee2c29ca4e 100644 --- a/tests/components/ufire_ise/test.esp8266-ard.yaml +++ b/tests/components/ufire_ise/test.esp8266-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ise - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/ufire_ise/test.rp2040-ard.yaml b/tests/components/ufire_ise/test.rp2040-ard.yaml index 36aec73113..ee2c29ca4e 100644 --- a/tests/components/ufire_ise/test.rp2040-ard.yaml +++ b/tests/components/ufire_ise/test.rp2040-ard.yaml @@ -1,25 +1,5 @@ -esphome: - on_boot: - then: - - ufire_ise.calibrate_probe_high: - id: ufire_ise_sensor - solution: 7.0 - - ufire_ise.calibrate_probe_low: - id: ufire_ise_sensor - solution: 4.0 - - ufire_ise.reset: +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -i2c: - - id: i2c_ufire_ise - scl: 5 - sda: 4 - -sensor: - - platform: template - id: test_sensor - lambda: "return 21;" - - platform: ufire_ise - id: ufire_ise_sensor - temperature_sensor: test_sensor - ph: - name: Ufire pH +<<: !include common.yaml diff --git a/tests/components/uln2003/common.yaml b/tests/components/uln2003/common.yaml new file mode 100644 index 0000000000..f848030592 --- /dev/null +++ b/tests/components/uln2003/common.yaml @@ -0,0 +1,29 @@ +esphome: + on_boot: + then: + - stepper.report_position: + id: uln2003_stepper + position: 250 + - stepper.set_target: + id: uln2003_stepper + target: 250 + - stepper.set_acceleration: + id: uln2003_stepper + acceleration: 250 steps/s^2 + - stepper.set_deceleration: + id: uln2003_stepper + deceleration: 250 steps/s^2 + - stepper.set_speed: + id: uln2003_stepper + speed: 250 steps/s + +stepper: + - platform: uln2003 + id: uln2003_stepper + pin_a: ${pin_a} + pin_b: ${pin_b} + pin_c: ${pin_c} + pin_d: ${pin_d} + max_speed: 250 steps/s + acceleration: 100 steps/s^2 + deceleration: 200 steps/s^2 diff --git a/tests/components/uln2003/test.esp32-ard.yaml b/tests/components/uln2003/test.esp32-ard.yaml index 61a6e94396..ee4cff0923 100644 --- a/tests/components/uln2003/test.esp32-ard.yaml +++ b/tests/components/uln2003/test.esp32-ard.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO12 + pin_b: GPIO13 + pin_c: GPIO14 + pin_d: GPIO15 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 12 - pin_b: 13 - pin_c: 14 - pin_d: 15 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/uln2003/test.esp32-c3-ard.yaml b/tests/components/uln2003/test.esp32-c3-ard.yaml index 2d19d4dba3..11d16a4d5d 100644 --- a/tests/components/uln2003/test.esp32-c3-ard.yaml +++ b/tests/components/uln2003/test.esp32-c3-ard.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO0 + pin_b: GPIO1 + pin_c: GPIO2 + pin_d: GPIO3 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 0 - pin_b: 1 - pin_c: 2 - pin_d: 3 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/uln2003/test.esp32-c3-idf.yaml b/tests/components/uln2003/test.esp32-c3-idf.yaml index 2d19d4dba3..11d16a4d5d 100644 --- a/tests/components/uln2003/test.esp32-c3-idf.yaml +++ b/tests/components/uln2003/test.esp32-c3-idf.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO0 + pin_b: GPIO1 + pin_c: GPIO2 + pin_d: GPIO3 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 0 - pin_b: 1 - pin_c: 2 - pin_d: 3 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/uln2003/test.esp32-idf.yaml b/tests/components/uln2003/test.esp32-idf.yaml index 61a6e94396..ee4cff0923 100644 --- a/tests/components/uln2003/test.esp32-idf.yaml +++ b/tests/components/uln2003/test.esp32-idf.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO12 + pin_b: GPIO13 + pin_c: GPIO14 + pin_d: GPIO15 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 12 - pin_b: 13 - pin_c: 14 - pin_d: 15 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/uln2003/test.esp8266-ard.yaml b/tests/components/uln2003/test.esp8266-ard.yaml index 61a6e94396..ee4cff0923 100644 --- a/tests/components/uln2003/test.esp8266-ard.yaml +++ b/tests/components/uln2003/test.esp8266-ard.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO12 + pin_b: GPIO13 + pin_c: GPIO14 + pin_d: GPIO15 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 12 - pin_b: 13 - pin_c: 14 - pin_d: 15 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/uln2003/test.rp2040-ard.yaml b/tests/components/uln2003/test.rp2040-ard.yaml index 2d19d4dba3..11d16a4d5d 100644 --- a/tests/components/uln2003/test.rp2040-ard.yaml +++ b/tests/components/uln2003/test.rp2040-ard.yaml @@ -1,29 +1,7 @@ -esphome: - on_boot: - then: - - stepper.report_position: - id: uln2003_stepper - position: 250 - - stepper.set_target: - id: uln2003_stepper - target: 250 - - stepper.set_acceleration: - id: uln2003_stepper - acceleration: 250 steps/s^2 - - stepper.set_deceleration: - id: uln2003_stepper - deceleration: 250 steps/s^2 - - stepper.set_speed: - id: uln2003_stepper - speed: 250 steps/s +substitutions: + pin_a: GPIO0 + pin_b: GPIO1 + pin_c: GPIO2 + pin_d: GPIO3 -stepper: - - platform: uln2003 - id: uln2003_stepper - pin_a: 0 - pin_b: 1 - pin_c: 2 - pin_d: 3 - max_speed: 250 steps/s - acceleration: 100 steps/s^2 - deceleration: 200 steps/s^2 +<<: !include common.yaml diff --git a/tests/components/vbus/common.yaml b/tests/components/vbus/common.yaml new file mode 100644 index 0000000000..a1f94cd839 --- /dev/null +++ b/tests/components/vbus/common.yaml @@ -0,0 +1,42 @@ +uart: + - id: uart_vbus + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +vbus: + +binary_sensor: + - platform: vbus + model: deltasol_bs_plus + relay1: + name: Relay 1 On + relay2: + name: Relay 2 On + sensor1_error: + name: Sensor 1 Error + - platform: vbus + model: custom + command: 0x100 + source: 0x1234 + dest: 0x10 + binary_sensors: + - id: vcustom_b + name: VBus Custom Binary Sensor + lambda: return x[0] & 1; + +sensor: + - platform: vbus + model: deltasol c + temperature_1: + name: Temperature 1 + temperature_2: + name: Temperature 2 + temperature_3: + name: Temperature 3 + operating_hours_1: + name: Operating Hours 1 + heat_quantity: + name: Heat Quantity + time: + name: System Time diff --git a/tests/components/vbus/test.esp32-ard.yaml b/tests/components/vbus/test.esp32-ard.yaml index a0e5ca42cc..f486544afa 100644 --- a/tests/components/vbus/test.esp32-ard.yaml +++ b/tests/components/vbus/test.esp32-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/vbus/test.esp32-c3-ard.yaml b/tests/components/vbus/test.esp32-c3-ard.yaml index 67ee542031..b516342f3b 100644 --- a/tests/components/vbus/test.esp32-c3-ard.yaml +++ b/tests/components/vbus/test.esp32-c3-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/vbus/test.esp32-c3-idf.yaml b/tests/components/vbus/test.esp32-c3-idf.yaml index 67ee542031..b516342f3b 100644 --- a/tests/components/vbus/test.esp32-c3-idf.yaml +++ b/tests/components/vbus/test.esp32-c3-idf.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/vbus/test.esp32-idf.yaml b/tests/components/vbus/test.esp32-idf.yaml index a0e5ca42cc..f486544afa 100644 --- a/tests/components/vbus/test.esp32-idf.yaml +++ b/tests/components/vbus/test.esp32-idf.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/vbus/test.esp8266-ard.yaml b/tests/components/vbus/test.esp8266-ard.yaml index 67ee542031..b516342f3b 100644 --- a/tests/components/vbus/test.esp8266-ard.yaml +++ b/tests/components/vbus/test.esp8266-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/vbus/test.rp2040-ard.yaml b/tests/components/vbus/test.rp2040-ard.yaml index 67ee542031..b516342f3b 100644 --- a/tests/components/vbus/test.rp2040-ard.yaml +++ b/tests/components/vbus/test.rp2040-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_vbus - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -vbus: - -binary_sensor: - - platform: vbus - model: deltasol_bs_plus - relay1: - name: Relay 1 On - relay2: - name: Relay 2 On - sensor1_error: - name: Sensor 1 Error - - platform: vbus - model: custom - command: 0x100 - source: 0x1234 - dest: 0x10 - binary_sensors: - - id: vcustom_b - name: VBus Custom Binary Sensor - lambda: return x[0] & 1; - -sensor: - - platform: vbus - model: deltasol c - temperature_1: - name: Temperature 1 - temperature_2: - name: Temperature 2 - temperature_3: - name: Temperature 3 - operating_hours_1: - name: Operating Hours 1 - heat_quantity: - name: Heat Quantity - time: - name: System Time +<<: !include common.yaml diff --git a/tests/components/veml3235/common.yaml b/tests/components/veml3235/common.yaml new file mode 100644 index 0000000000..b89a9e12c7 --- /dev/null +++ b/tests/components/veml3235/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_veml3235 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: veml3235 + id: veml3235_sensor + name: VEML3235 Light Sensor + auto_gain: true + auto_gain_threshold_high: 90% + auto_gain_threshold_low: 15% + digital_gain: 1X + gain: 1X + integration_time: 50ms diff --git a/tests/components/veml3235/test.esp32-ard.yaml b/tests/components/veml3235/test.esp32-ard.yaml index 3442fa4317..63c3bd6afd 100644 --- a/tests/components/veml3235/test.esp32-ard.yaml +++ b/tests/components/veml3235/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml3235/test.esp32-c3-ard.yaml b/tests/components/veml3235/test.esp32-c3-ard.yaml index 1f79c5f50c..ee2c29ca4e 100644 --- a/tests/components/veml3235/test.esp32-c3-ard.yaml +++ b/tests/components/veml3235/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml3235/test.esp32-c3-idf.yaml b/tests/components/veml3235/test.esp32-c3-idf.yaml index 1f79c5f50c..ee2c29ca4e 100644 --- a/tests/components/veml3235/test.esp32-c3-idf.yaml +++ b/tests/components/veml3235/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml3235/test.esp32-idf.yaml b/tests/components/veml3235/test.esp32-idf.yaml index 3442fa4317..63c3bd6afd 100644 --- a/tests/components/veml3235/test.esp32-idf.yaml +++ b/tests/components/veml3235/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml3235/test.esp8266-ard.yaml b/tests/components/veml3235/test.esp8266-ard.yaml index 1f79c5f50c..ee2c29ca4e 100644 --- a/tests/components/veml3235/test.esp8266-ard.yaml +++ b/tests/components/veml3235/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml3235/test.rp2040-ard.yaml b/tests/components/veml3235/test.rp2040-ard.yaml index 1f79c5f50c..ee2c29ca4e 100644 --- a/tests/components/veml3235/test.rp2040-ard.yaml +++ b/tests/components/veml3235/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_veml3235 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: veml3235 - id: veml3235_sensor - name: VEML3235 Light Sensor - auto_gain: true - auto_gain_threshold_high: 90% - auto_gain_threshold_low: 15% - digital_gain: 1X - gain: 1X - integration_time: 50ms +<<: !include common.yaml diff --git a/tests/components/veml7700/common.yaml b/tests/components/veml7700/common.yaml index 6620c8d7e1..af4ebee6e7 100644 --- a/tests/components/veml7700/common.yaml +++ b/tests/components/veml7700/common.yaml @@ -1,3 +1,8 @@ +i2c: + - id: i2c_veml7700 + scl: ${scl_pin} + sda: ${sda_pin} + sensor: - platform: veml7700 address: 0x10 diff --git a/tests/components/veml7700/test.esp32-ard.yaml b/tests/components/veml7700/test.esp32-ard.yaml index 4b812a1392..63c3bd6afd 100644 --- a/tests/components/veml7700/test.esp32-ard.yaml +++ b/tests/components/veml7700/test.esp32-ard.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 <<: !include common.yaml diff --git a/tests/components/veml7700/test.esp32-c3-ard.yaml b/tests/components/veml7700/test.esp32-c3-ard.yaml index ce0fa0125b..ee2c29ca4e 100644 --- a/tests/components/veml7700/test.esp32-c3-ard.yaml +++ b/tests/components/veml7700/test.esp32-c3-ard.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/veml7700/test.esp32-c3-idf.yaml b/tests/components/veml7700/test.esp32-c3-idf.yaml index ce0fa0125b..ee2c29ca4e 100644 --- a/tests/components/veml7700/test.esp32-c3-idf.yaml +++ b/tests/components/veml7700/test.esp32-c3-idf.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/veml7700/test.esp32-idf.yaml b/tests/components/veml7700/test.esp32-idf.yaml index 4b812a1392..63c3bd6afd 100644 --- a/tests/components/veml7700/test.esp32-idf.yaml +++ b/tests/components/veml7700/test.esp32-idf.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 <<: !include common.yaml diff --git a/tests/components/veml7700/test.esp8266-ard.yaml b/tests/components/veml7700/test.esp8266-ard.yaml index ce0fa0125b..ee2c29ca4e 100644 --- a/tests/components/veml7700/test.esp8266-ard.yaml +++ b/tests/components/veml7700/test.esp8266-ard.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/veml7700/test.rp2040-ard.yaml b/tests/components/veml7700/test.rp2040-ard.yaml index ce0fa0125b..ee2c29ca4e 100644 --- a/tests/components/veml7700/test.rp2040-ard.yaml +++ b/tests/components/veml7700/test.rp2040-ard.yaml @@ -1,6 +1,5 @@ -i2c: - - id: i2c_veml7700 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 <<: !include common.yaml diff --git a/tests/components/vl53l0x/common.yaml b/tests/components/vl53l0x/common.yaml new file mode 100644 index 0000000000..973e481b1a --- /dev/null +++ b/tests/components/vl53l0x/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_vl53l0x + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: vl53l0x + name: VL53L0x Distance + address: 0x29 + enable_pin: 3 + timeout: 200us + update_interval: 60s diff --git a/tests/components/vl53l0x/test.esp32-ard.yaml b/tests/components/vl53l0x/test.esp32-ard.yaml index 8f35de0e72..63c3bd6afd 100644 --- a/tests/components/vl53l0x/test.esp32-ard.yaml +++ b/tests/components/vl53l0x/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/vl53l0x/test.esp32-c3-ard.yaml b/tests/components/vl53l0x/test.esp32-c3-ard.yaml index 832f7dcfbc..ee2c29ca4e 100644 --- a/tests/components/vl53l0x/test.esp32-c3-ard.yaml +++ b/tests/components/vl53l0x/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/vl53l0x/test.esp32-c3-idf.yaml b/tests/components/vl53l0x/test.esp32-c3-idf.yaml index 832f7dcfbc..ee2c29ca4e 100644 --- a/tests/components/vl53l0x/test.esp32-c3-idf.yaml +++ b/tests/components/vl53l0x/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/vl53l0x/test.esp32-idf.yaml b/tests/components/vl53l0x/test.esp32-idf.yaml index 8f35de0e72..63c3bd6afd 100644 --- a/tests/components/vl53l0x/test.esp32-idf.yaml +++ b/tests/components/vl53l0x/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/vl53l0x/test.esp8266-ard.yaml b/tests/components/vl53l0x/test.esp8266-ard.yaml index 832f7dcfbc..ee2c29ca4e 100644 --- a/tests/components/vl53l0x/test.esp8266-ard.yaml +++ b/tests/components/vl53l0x/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/vl53l0x/test.rp2040-ard.yaml b/tests/components/vl53l0x/test.rp2040-ard.yaml index 832f7dcfbc..ee2c29ca4e 100644 --- a/tests/components/vl53l0x/test.rp2040-ard.yaml +++ b/tests/components/vl53l0x/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_vl53l0x - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: vl53l0x - name: VL53L0x Distance - address: 0x29 - enable_pin: 3 - timeout: 200us - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/voice_assistant/common.yaml b/tests/components/voice_assistant/common.yaml new file mode 100644 index 0000000000..e7374941f7 --- /dev/null +++ b/tests/components/voice_assistant/common.yaml @@ -0,0 +1,57 @@ +esphome: + on_boot: + then: + - voice_assistant.start + - voice_assistant.start_continuous + - voice_assistant.stop + +wifi: + ssid: MySSID + password: password1 + +api: + +i2s_audio: + i2s_lrclk_pin: ${i2s_lrclk_pin} + i2s_bclk_pin: ${i2s_bclk_pin} + i2s_mclk_pin: ${i2s_mclk_pin} + +microphone: + - platform: i2s_audio + id: mic_id_external + i2s_din_pin: ${i2s_din_pin} + adc_type: external + pdm: false + +speaker: + - platform: i2s_audio + id: speaker_id + dac_type: external + i2s_dout_pin: ${i2s_dout_pin} + +voice_assistant: + microphone: mic_id_external + speaker: speaker_id + conversation_timeout: 60s + on_listening: + - logger.log: "Voice assistant microphone listening" + on_start: + - logger.log: "Voice assistant started" + on_stt_end: + - logger.log: + format: "Voice assistant STT ended with result %s" + args: [x.c_str()] + on_tts_start: + - logger.log: + format: "Voice assistant TTS started with text %s" + args: [x.c_str()] + on_tts_end: + - logger.log: + format: "Voice assistant TTS ended with url %s" + args: [x.c_str()] + on_end: + - logger.log: "Voice assistant ended" + on_error: + - logger.log: + format: "Voice assistant error - code %s, message: %s" + args: [code.c_str(), message.c_str()] diff --git a/tests/components/voice_assistant/test.esp32-ard.yaml b/tests/components/voice_assistant/test.esp32-ard.yaml index cbf9460087..f6e553f9dc 100644 --- a/tests/components/voice_assistant/test.esp32-ard.yaml +++ b/tests/components/voice_assistant/test.esp32-ard.yaml @@ -1,57 +1,8 @@ -esphome: - on_boot: - then: - - voice_assistant.start - - voice_assistant.start_continuous - - voice_assistant.stop +substitutions: + i2s_lrclk_pin: GPIO16 + i2s_bclk_pin: GPIO17 + i2s_mclk_pin: GPIO15 + i2s_din_pin: GPIO13 + i2s_dout_pin: GPIO12 -wifi: - ssid: MySSID - password: password1 - -api: - -i2s_audio: - i2s_lrclk_pin: 16 - i2s_bclk_pin: 17 - i2s_mclk_pin: 15 - -microphone: - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 13 - adc_type: external - pdm: false - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 12 - -voice_assistant: - microphone: mic_id_external - speaker: speaker_id - conversation_timeout: 60s - on_listening: - - logger.log: "Voice assistant microphone listening" - on_start: - - logger.log: "Voice assistant started" - on_stt_end: - - logger.log: - format: "Voice assistant STT ended with result %s" - args: [x.c_str()] - on_tts_start: - - logger.log: - format: "Voice assistant TTS started with text %s" - args: [x.c_str()] - on_tts_end: - - logger.log: - format: "Voice assistant TTS ended with url %s" - args: [x.c_str()] - on_end: - - logger.log: "Voice assistant ended" - on_error: - - logger.log: - format: "Voice assistant error - code %s, message: %s" - args: [code.c_str(), message.c_str()] +<<: !include common.yaml diff --git a/tests/components/voice_assistant/test.esp32-c3-ard.yaml b/tests/components/voice_assistant/test.esp32-c3-ard.yaml index 86357fad36..f596d927cb 100644 --- a/tests/components/voice_assistant/test.esp32-c3-ard.yaml +++ b/tests/components/voice_assistant/test.esp32-c3-ard.yaml @@ -1,56 +1,8 @@ -esphome: - on_boot: - then: - - voice_assistant.start - - voice_assistant.start_continuous - - voice_assistant.stop +substitutions: + i2s_lrclk_pin: GPIO6 + i2s_bclk_pin: GPIO7 + i2s_mclk_pin: GPIO5 + i2s_din_pin: GPIO3 + i2s_dout_pin: GPIO2 -wifi: - ssid: MySSID - password: password1 - -api: - -i2s_audio: - i2s_lrclk_pin: 6 - i2s_bclk_pin: 7 - i2s_mclk_pin: 5 - -microphone: - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 3 - adc_type: external - pdm: false - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 2 - -voice_assistant: - microphone: mic_id_external - speaker: speaker_id - on_listening: - - logger.log: "Voice assistant microphone listening" - on_start: - - logger.log: "Voice assistant started" - on_stt_end: - - logger.log: - format: "Voice assistant STT ended with result %s" - args: [x.c_str()] - on_tts_start: - - logger.log: - format: "Voice assistant TTS started with text %s" - args: [x.c_str()] - on_tts_end: - - logger.log: - format: "Voice assistant TTS ended with url %s" - args: [x.c_str()] - on_end: - - logger.log: "Voice assistant ended" - on_error: - - logger.log: - format: "Voice assistant error - code %s, message: %s" - args: [code.c_str(), message.c_str()] +<<: !include common.yaml diff --git a/tests/components/voice_assistant/test.esp32-c3-idf.yaml b/tests/components/voice_assistant/test.esp32-c3-idf.yaml index 86357fad36..f596d927cb 100644 --- a/tests/components/voice_assistant/test.esp32-c3-idf.yaml +++ b/tests/components/voice_assistant/test.esp32-c3-idf.yaml @@ -1,56 +1,8 @@ -esphome: - on_boot: - then: - - voice_assistant.start - - voice_assistant.start_continuous - - voice_assistant.stop +substitutions: + i2s_lrclk_pin: GPIO6 + i2s_bclk_pin: GPIO7 + i2s_mclk_pin: GPIO5 + i2s_din_pin: GPIO3 + i2s_dout_pin: GPIO2 -wifi: - ssid: MySSID - password: password1 - -api: - -i2s_audio: - i2s_lrclk_pin: 6 - i2s_bclk_pin: 7 - i2s_mclk_pin: 5 - -microphone: - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 3 - adc_type: external - pdm: false - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 2 - -voice_assistant: - microphone: mic_id_external - speaker: speaker_id - on_listening: - - logger.log: "Voice assistant microphone listening" - on_start: - - logger.log: "Voice assistant started" - on_stt_end: - - logger.log: - format: "Voice assistant STT ended with result %s" - args: [x.c_str()] - on_tts_start: - - logger.log: - format: "Voice assistant TTS started with text %s" - args: [x.c_str()] - on_tts_end: - - logger.log: - format: "Voice assistant TTS ended with url %s" - args: [x.c_str()] - on_end: - - logger.log: "Voice assistant ended" - on_error: - - logger.log: - format: "Voice assistant error - code %s, message: %s" - args: [code.c_str(), message.c_str()] +<<: !include common.yaml diff --git a/tests/components/voice_assistant/test.esp32-idf.yaml b/tests/components/voice_assistant/test.esp32-idf.yaml index da9b50721f..f6e553f9dc 100644 --- a/tests/components/voice_assistant/test.esp32-idf.yaml +++ b/tests/components/voice_assistant/test.esp32-idf.yaml @@ -1,56 +1,8 @@ -esphome: - on_boot: - then: - - voice_assistant.start - - voice_assistant.start_continuous - - voice_assistant.stop +substitutions: + i2s_lrclk_pin: GPIO16 + i2s_bclk_pin: GPIO17 + i2s_mclk_pin: GPIO15 + i2s_din_pin: GPIO13 + i2s_dout_pin: GPIO12 -wifi: - ssid: MySSID - password: password1 - -api: - -i2s_audio: - i2s_lrclk_pin: 16 - i2s_bclk_pin: 17 - i2s_mclk_pin: 15 - -microphone: - - platform: i2s_audio - id: mic_id_external - i2s_din_pin: 13 - adc_type: external - pdm: false - -speaker: - - platform: i2s_audio - id: speaker_id - dac_type: external - i2s_dout_pin: 12 - -voice_assistant: - microphone: mic_id_external - speaker: speaker_id - on_listening: - - logger.log: "Voice assistant microphone listening" - on_start: - - logger.log: "Voice assistant started" - on_stt_end: - - logger.log: - format: "Voice assistant STT ended with result %s" - args: [x.c_str()] - on_tts_start: - - logger.log: - format: "Voice assistant TTS started with text %s" - args: [x.c_str()] - on_tts_end: - - logger.log: - format: "Voice assistant TTS ended with url %s" - args: [x.c_str()] - on_end: - - logger.log: "Voice assistant ended" - on_error: - - logger.log: - format: "Voice assistant error - code %s, message: %s" - args: [code.c_str(), message.c_str()] +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml new file mode 100644 index 0000000000..92c443908e --- /dev/null +++ b/tests/components/waveshare_epaper/common.yaml @@ -0,0 +1,190 @@ +spi: + - id: spi_waveshare_epaper + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + +display: + - platform: waveshare_epaper + model: 2.13in-ttgo-b1 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.13in-ttgo-b74 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.90in + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + reset_duration: 200ms + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.90inv2 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.90in-dke + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.70in-b + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.70in-bv2 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 1.54in-m5coreink-m09 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.13inv3 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.13inv2 + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 7.50in-bv3-bwr + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); diff --git a/tests/components/waveshare_epaper/test.esp32-ard.yaml b/tests/components/waveshare_epaper/test.esp32-ard.yaml index 944f98a1e9..c658ea91ee 100644 --- a/tests/components/waveshare_epaper/test.esp32-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp32-ard.yaml @@ -1,207 +1,9 @@ ---- -spi: - - id: spi_id_1 - clk_pin: - number: GPIO18 - mosi_pin: - number: GPIO23 - miso_pin: - number: GPIO19 - interface: hardware +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO18 + dc_pin: GPIO19 + busy_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: waveshare_epaper - model: 2.13in-ttgo-b1 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.13in-ttgo-b74 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.90in - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.90inv2 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.90in-dke - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.70in-b - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.70in-bv2 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 1.54in-m5coreink-m09 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.13inv3 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.13inv2 - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 7.50in-bv3-bwr - spi_id: spi_id_1 - cs_pin: - allow_other_uses: true - number: GPIO25 - dc_pin: - allow_other_uses: true - number: GPIO26 - busy_pin: - allow_other_uses: true - number: GPIO27 - reset_pin: - allow_other_uses: true - number: GPIO32 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml b/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml index 5d651bd180..e2873f0fe9 100644 --- a/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml @@ -1,123 +1,9 @@ -spi: - - id: spi_waveshare_epaper - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + cs_pin: GPIO0 + dc_pin: GPIO5 + busy_pin: GPIO3 + reset_pin: GPIO4 -display: - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.13in-ttgo-b1 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90in - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90inv2 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-b - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-bv2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 1.54in-m5coreink-m09 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 7.50in-bv3-bwr - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml b/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml index 5d651bd180..e2873f0fe9 100644 --- a/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml +++ b/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml @@ -1,123 +1,9 @@ -spi: - - id: spi_waveshare_epaper - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + cs_pin: GPIO0 + dc_pin: GPIO5 + busy_pin: GPIO3 + reset_pin: GPIO4 -display: - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.13in-ttgo-b1 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90in - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90inv2 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-b - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-bv2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 1.54in-m5coreink-m09 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 7.50in-bv3-bwr - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-idf.yaml b/tests/components/waveshare_epaper/test.esp32-idf.yaml index 47f894d967..c658ea91ee 100644 --- a/tests/components/waveshare_epaper/test.esp32-idf.yaml +++ b/tests/components/waveshare_epaper/test.esp32-idf.yaml @@ -1,123 +1,9 @@ -spi: - - id: spi_bme280 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO16 + mosi_pin: GPIO17 + cs_pin: GPIO18 + dc_pin: GPIO19 + busy_pin: GPIO13 + reset_pin: GPIO14 -display: - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.13in-ttgo-b1 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90in - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90inv2 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-b - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-bv2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 1.54in-m5coreink-m09 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 7.50in-bv3-bwr - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp8266-ard.yaml b/tests/components/waveshare_epaper/test.esp8266-ard.yaml index ceda328598..bc178b7009 100644 --- a/tests/components/waveshare_epaper/test.esp8266-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp8266-ard.yaml @@ -1,123 +1,9 @@ -spi: - - id: spi_bme280 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + cs_pin: GPIO15 + dc_pin: GPIO12 + busy_pin: GPIO5 + reset_pin: GPIO4 -display: - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.13in-ttgo-b1 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90in - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.90inv2 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-b - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 2.70in-bv2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 1.54in-m5coreink-m09 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 4 - dc_pin: - allow_other_uses: true - number: 4 - busy_pin: - allow_other_uses: true - number: 4 - reset_pin: - allow_other_uses: true - number: 4 - model: 7.50in-bv3-bwr - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.rp2040-ard.yaml b/tests/components/waveshare_epaper/test.rp2040-ard.yaml index be7e780033..801b0b51c5 100644 --- a/tests/components/waveshare_epaper/test.rp2040-ard.yaml +++ b/tests/components/waveshare_epaper/test.rp2040-ard.yaml @@ -1,123 +1,9 @@ -spi: - - id: spi_bme280 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO2 + mosi_pin: GPIO3 + cs_pin: GPIO5 + dc_pin: GPIO4 + busy_pin: GPIO0 + reset_pin: GPIO1 -display: - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 2.13in-ttgo-b1 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 2.90in - full_update_every: 30 - reset_duration: 200ms - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 2.90inv2 - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 2.70in-b - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 2.70in-bv2 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 1.54in-m5coreink-m09 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - cs_pin: - allow_other_uses: true - number: 5 - dc_pin: - allow_other_uses: true - number: 5 - busy_pin: - allow_other_uses: true - number: 5 - reset_pin: - allow_other_uses: true - number: 5 - model: 7.50in-bv3-bwr - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); +<<: !include common.yaml diff --git a/tests/components/whirlpool/common.yaml b/tests/components/whirlpool/common.yaml new file mode 100644 index 0000000000..804c1aac26 --- /dev/null +++ b/tests/components/whirlpool/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: whirlpool + name: Whirlpool Climate diff --git a/tests/components/whirlpool/test.esp32-ard.yaml b/tests/components/whirlpool/test.esp32-ard.yaml index 4d0afc39a4..7b012aa64c 100644 --- a/tests/components/whirlpool/test.esp32-ard.yaml +++ b/tests/components/whirlpool/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whirlpool - name: Whirlpool Climate +<<: !include common.yaml diff --git a/tests/components/whirlpool/test.esp32-c3-ard.yaml b/tests/components/whirlpool/test.esp32-c3-ard.yaml index 4d0afc39a4..7b012aa64c 100644 --- a/tests/components/whirlpool/test.esp32-c3-ard.yaml +++ b/tests/components/whirlpool/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whirlpool - name: Whirlpool Climate +<<: !include common.yaml diff --git a/tests/components/whirlpool/test.esp32-c3-idf.yaml b/tests/components/whirlpool/test.esp32-c3-idf.yaml index 4d0afc39a4..7b012aa64c 100644 --- a/tests/components/whirlpool/test.esp32-c3-idf.yaml +++ b/tests/components/whirlpool/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whirlpool - name: Whirlpool Climate +<<: !include common.yaml diff --git a/tests/components/whirlpool/test.esp32-idf.yaml b/tests/components/whirlpool/test.esp32-idf.yaml index 4d0afc39a4..7b012aa64c 100644 --- a/tests/components/whirlpool/test.esp32-idf.yaml +++ b/tests/components/whirlpool/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whirlpool - name: Whirlpool Climate +<<: !include common.yaml diff --git a/tests/components/whirlpool/test.esp8266-ard.yaml b/tests/components/whirlpool/test.esp8266-ard.yaml index efd530c160..f5097fcf5f 100644 --- a/tests/components/whirlpool/test.esp8266-ard.yaml +++ b/tests/components/whirlpool/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: whirlpool - name: Whirlpool Climate +<<: !include common.yaml diff --git a/tests/components/whynter/common.yaml b/tests/components/whynter/common.yaml new file mode 100644 index 0000000000..04ad6bed54 --- /dev/null +++ b/tests/components/whynter/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: whynter + name: Whynter Climate diff --git a/tests/components/whynter/test.esp32-ard.yaml b/tests/components/whynter/test.esp32-ard.yaml index dc8fb9584d..7b012aa64c 100644 --- a/tests/components/whynter/test.esp32-ard.yaml +++ b/tests/components/whynter/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whynter - name: Whynter Climate +<<: !include common.yaml diff --git a/tests/components/whynter/test.esp32-c3-ard.yaml b/tests/components/whynter/test.esp32-c3-ard.yaml index dc8fb9584d..7b012aa64c 100644 --- a/tests/components/whynter/test.esp32-c3-ard.yaml +++ b/tests/components/whynter/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whynter - name: Whynter Climate +<<: !include common.yaml diff --git a/tests/components/whynter/test.esp32-c3-idf.yaml b/tests/components/whynter/test.esp32-c3-idf.yaml index dc8fb9584d..7b012aa64c 100644 --- a/tests/components/whynter/test.esp32-c3-idf.yaml +++ b/tests/components/whynter/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whynter - name: Whynter Climate +<<: !include common.yaml diff --git a/tests/components/whynter/test.esp32-idf.yaml b/tests/components/whynter/test.esp32-idf.yaml index dc8fb9584d..7b012aa64c 100644 --- a/tests/components/whynter/test.esp32-idf.yaml +++ b/tests/components/whynter/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: whynter - name: Whynter Climate +<<: !include common.yaml diff --git a/tests/components/whynter/test.esp8266-ard.yaml b/tests/components/whynter/test.esp8266-ard.yaml index a656a7427d..f5097fcf5f 100644 --- a/tests/components/whynter/test.esp8266-ard.yaml +++ b/tests/components/whynter/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: whynter - name: Whynter Climate +<<: !include common.yaml diff --git a/tests/components/wl_134/common.yaml b/tests/components/wl_134/common.yaml new file mode 100644 index 0000000000..71c50be79b --- /dev/null +++ b/tests/components/wl_134/common.yaml @@ -0,0 +1,10 @@ +uart: + - id: uart_wl_134 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +text_sensor: + - platform: wl_134 + name: Transponder Code + reset: true diff --git a/tests/components/wl_134/test.esp32-ard.yaml b/tests/components/wl_134/test.esp32-ard.yaml index d517889d28..f486544afa 100644 --- a/tests/components/wl_134/test.esp32-ard.yaml +++ b/tests/components/wl_134/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/wl_134/test.esp32-c3-ard.yaml b/tests/components/wl_134/test.esp32-c3-ard.yaml index 7cda1ba060..b516342f3b 100644 --- a/tests/components/wl_134/test.esp32-c3-ard.yaml +++ b/tests/components/wl_134/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/wl_134/test.esp32-c3-idf.yaml b/tests/components/wl_134/test.esp32-c3-idf.yaml index 7cda1ba060..b516342f3b 100644 --- a/tests/components/wl_134/test.esp32-c3-idf.yaml +++ b/tests/components/wl_134/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/wl_134/test.esp32-idf.yaml b/tests/components/wl_134/test.esp32-idf.yaml index d517889d28..f486544afa 100644 --- a/tests/components/wl_134/test.esp32-idf.yaml +++ b/tests/components/wl_134/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/wl_134/test.esp8266-ard.yaml b/tests/components/wl_134/test.esp8266-ard.yaml index 7cda1ba060..b516342f3b 100644 --- a/tests/components/wl_134/test.esp8266-ard.yaml +++ b/tests/components/wl_134/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/wl_134/test.rp2040-ard.yaml b/tests/components/wl_134/test.rp2040-ard.yaml index 7cda1ba060..b516342f3b 100644 --- a/tests/components/wl_134/test.rp2040-ard.yaml +++ b/tests/components/wl_134/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_wl_134 - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -text_sensor: - - platform: wl_134 - name: Transponder Code - reset: true +<<: !include common.yaml diff --git a/tests/components/x9c/common.yaml b/tests/components/x9c/common.yaml new file mode 100644 index 0000000000..07713c66c3 --- /dev/null +++ b/tests/components/x9c/common.yaml @@ -0,0 +1,8 @@ +output: + - platform: x9c + id: test_x9c + cs_pin: ${cs_pin} + inc_pin: ${inc_pin} + ud_pin: ${ud_pin} + initial_value: 0.5 + step_delay: 50us diff --git a/tests/components/x9c/test.esp32-ard.yaml b/tests/components/x9c/test.esp32-ard.yaml index f587b69b4f..6dfe3a67eb 100644 --- a/tests/components/x9c/test.esp32-ard.yaml +++ b/tests/components/x9c/test.esp32-ard.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 13 - inc_pin: 14 - ud_pin: 15 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO13 + inc_pin: GPIO14 + ud_pin: GPIO15 + +<<: !include common.yaml diff --git a/tests/components/x9c/test.esp32-c3-ard.yaml b/tests/components/x9c/test.esp32-c3-ard.yaml index 972c743fcd..b06e15a98c 100644 --- a/tests/components/x9c/test.esp32-c3-ard.yaml +++ b/tests/components/x9c/test.esp32-c3-ard.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 3 - inc_pin: 4 - ud_pin: 5 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO3 + inc_pin: GPIO4 + ud_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/x9c/test.esp32-c3-idf.yaml b/tests/components/x9c/test.esp32-c3-idf.yaml index 972c743fcd..b06e15a98c 100644 --- a/tests/components/x9c/test.esp32-c3-idf.yaml +++ b/tests/components/x9c/test.esp32-c3-idf.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 3 - inc_pin: 4 - ud_pin: 5 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO3 + inc_pin: GPIO4 + ud_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/x9c/test.esp32-idf.yaml b/tests/components/x9c/test.esp32-idf.yaml index f587b69b4f..6dfe3a67eb 100644 --- a/tests/components/x9c/test.esp32-idf.yaml +++ b/tests/components/x9c/test.esp32-idf.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 13 - inc_pin: 14 - ud_pin: 15 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO13 + inc_pin: GPIO14 + ud_pin: GPIO15 + +<<: !include common.yaml diff --git a/tests/components/x9c/test.esp8266-ard.yaml b/tests/components/x9c/test.esp8266-ard.yaml index f587b69b4f..6dfe3a67eb 100644 --- a/tests/components/x9c/test.esp8266-ard.yaml +++ b/tests/components/x9c/test.esp8266-ard.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 13 - inc_pin: 14 - ud_pin: 15 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO13 + inc_pin: GPIO14 + ud_pin: GPIO15 + +<<: !include common.yaml diff --git a/tests/components/x9c/test.rp2040-ard.yaml b/tests/components/x9c/test.rp2040-ard.yaml index 972c743fcd..b06e15a98c 100644 --- a/tests/components/x9c/test.rp2040-ard.yaml +++ b/tests/components/x9c/test.rp2040-ard.yaml @@ -1,8 +1,6 @@ -output: - - platform: x9c - id: test_x9c - cs_pin: 3 - inc_pin: 4 - ud_pin: 5 - initial_value: 0.5 - step_delay: 50us +substitutions: + cs_pin: GPIO3 + inc_pin: GPIO4 + ud_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/common.yaml b/tests/components/xgzp68xx/common.yaml new file mode 100644 index 0000000000..224dd9ed14 --- /dev/null +++ b/tests/components/xgzp68xx/common.yaml @@ -0,0 +1,12 @@ +i2c: + - id: i2c_xgzp68xx + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: xgzp68xx + k_value: 4096 + temperature: + name: Pressure Temperature + pressure: + name: Differential pressure diff --git a/tests/components/xgzp68xx/test.esp32-ard.yaml b/tests/components/xgzp68xx/test.esp32-ard.yaml index fb55421123..63c3bd6afd 100644 --- a/tests/components/xgzp68xx/test.esp32-ard.yaml +++ b/tests/components/xgzp68xx/test.esp32-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/test.esp32-c3-ard.yaml b/tests/components/xgzp68xx/test.esp32-c3-ard.yaml index 25df8cc225..ee2c29ca4e 100644 --- a/tests/components/xgzp68xx/test.esp32-c3-ard.yaml +++ b/tests/components/xgzp68xx/test.esp32-c3-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/test.esp32-c3-idf.yaml b/tests/components/xgzp68xx/test.esp32-c3-idf.yaml index 25df8cc225..ee2c29ca4e 100644 --- a/tests/components/xgzp68xx/test.esp32-c3-idf.yaml +++ b/tests/components/xgzp68xx/test.esp32-c3-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/test.esp32-idf.yaml b/tests/components/xgzp68xx/test.esp32-idf.yaml index fb55421123..63c3bd6afd 100644 --- a/tests/components/xgzp68xx/test.esp32-idf.yaml +++ b/tests/components/xgzp68xx/test.esp32-idf.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/test.esp8266-ard.yaml b/tests/components/xgzp68xx/test.esp8266-ard.yaml index 25df8cc225..ee2c29ca4e 100644 --- a/tests/components/xgzp68xx/test.esp8266-ard.yaml +++ b/tests/components/xgzp68xx/test.esp8266-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xgzp68xx/test.rp2040-ard.yaml b/tests/components/xgzp68xx/test.rp2040-ard.yaml index 25df8cc225..ee2c29ca4e 100644 --- a/tests/components/xgzp68xx/test.rp2040-ard.yaml +++ b/tests/components/xgzp68xx/test.rp2040-ard.yaml @@ -1,12 +1,5 @@ -i2c: - - id: i2c_xgzp68xx - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: xgzp68xx - k_value: 4096 - temperature: - name: Pressure Temperature - pressure: - name: Differential pressure +<<: !include common.yaml diff --git a/tests/components/xl9535/common.yaml b/tests/components/xl9535/common.yaml new file mode 100644 index 0000000000..e01163cf12 --- /dev/null +++ b/tests/components/xl9535/common.yaml @@ -0,0 +1,26 @@ +i2c: + - id: i2c_xl9535 + scl: ${scl_pin} + sda: ${sda_pin} + +xl9535: + - id: xl9535_hub + address: 0x20 + +binary_sensor: + - platform: gpio + name: XL9535 Pin 0 + pin: + xl9535: xl9535_hub + number: 0 + mode: + input: true + inverted: false + - platform: gpio + name: XL9535 Pin 17 + pin: + xl9535: xl9535_hub + number: 17 + mode: + input: true + inverted: false diff --git a/tests/components/xl9535/test.esp32-ard.yaml b/tests/components/xl9535/test.esp32-ard.yaml index a65aae890e..63c3bd6afd 100644 --- a/tests/components/xl9535/test.esp32-ard.yaml +++ b/tests/components/xl9535/test.esp32-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xl9535/test.esp32-c3-ard.yaml b/tests/components/xl9535/test.esp32-c3-ard.yaml index 178adf870e..ee2c29ca4e 100644 --- a/tests/components/xl9535/test.esp32-c3-ard.yaml +++ b/tests/components/xl9535/test.esp32-c3-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xl9535/test.esp32-c3-idf.yaml b/tests/components/xl9535/test.esp32-c3-idf.yaml index 178adf870e..ee2c29ca4e 100644 --- a/tests/components/xl9535/test.esp32-c3-idf.yaml +++ b/tests/components/xl9535/test.esp32-c3-idf.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xl9535/test.esp32-idf.yaml b/tests/components/xl9535/test.esp32-idf.yaml index a65aae890e..63c3bd6afd 100644 --- a/tests/components/xl9535/test.esp32-idf.yaml +++ b/tests/components/xl9535/test.esp32-idf.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xl9535/test.esp8266-ard.yaml b/tests/components/xl9535/test.esp8266-ard.yaml index 178adf870e..ee2c29ca4e 100644 --- a/tests/components/xl9535/test.esp8266-ard.yaml +++ b/tests/components/xl9535/test.esp8266-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xl9535/test.rp2040-ard.yaml b/tests/components/xl9535/test.rp2040-ard.yaml index 178adf870e..ee2c29ca4e 100644 --- a/tests/components/xl9535/test.rp2040-ard.yaml +++ b/tests/components/xl9535/test.rp2040-ard.yaml @@ -1,26 +1,5 @@ -i2c: - - id: i2c_xl9535 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -xl9535: - - id: xl9535_hub - address: 0x20 - -binary_sensor: - - platform: gpio - name: XL9535 Pin 0 - pin: - xl9535: xl9535_hub - number: 0 - mode: - input: true - inverted: false - - platform: gpio - name: XL9535 Pin 17 - pin: - xl9535: xl9535_hub - number: 17 - mode: - input: true - inverted: false +<<: !include common.yaml diff --git a/tests/components/xpt2046/common.yaml b/tests/components/xpt2046/common.yaml new file mode 100644 index 0000000000..9ef680cff4 --- /dev/null +++ b/tests/components/xpt2046/common.yaml @@ -0,0 +1,35 @@ +spi: + - id: spi_xpt2046 + clk_pin: ${clk_pin} + mosi_pin: ${mosi_pin} + miso_pin: ${miso_pin} + +display: + - platform: ili9xxx + id: xpt_display + dimensions: 320x240 + model: TFT 2.4 + cs_pin: ${disp_cs_pin} + dc_pin: ${dc_pin} + reset_pin: ${reset_pin} + invert_colors: false + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + +touchscreen: + - platform: xpt2046 + id: xpt_touchscreen + cs_pin: ${cs_pin} + interrupt_pin: ${interrupt_pin} + display: xpt_display + update_interval: 50ms + threshold: 400 + calibration: + x_min: 280 + x_max: 3860 + y_min: 340 + y_max: 3860 + on_touch: + - logger.log: + format: Touch at (%d, %d) + args: [touch.x, touch.y] diff --git a/tests/components/xpt2046/test.esp32-ard.yaml b/tests/components/xpt2046/test.esp32-ard.yaml index 9e305791e0..b39174947b 100644 --- a/tests/components/xpt2046/test.esp32-ard.yaml +++ b/tests/components/xpt2046/test.esp32-ard.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO17 + mosi_pin: GPIO18 + miso_pin: GPIO19 + dc_pin: GPIO13 + cs_pin: GPIO14 + disp_cs_pin: GPIO4 + interrupt_pin: GPIO21 + reset_pin: GPIO22 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 13 - dc_pin: 14 - reset_pin: 21 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 18 - interrupt_pin: 19 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 280 - x_max: 3860 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/xpt2046/test.esp32-c3-ard.yaml b/tests/components/xpt2046/test.esp32-c3-ard.yaml index c03fd6b345..79b84902ac 100644 --- a/tests/components/xpt2046/test.esp32-c3-ard.yaml +++ b/tests/components/xpt2046/test.esp32-c3-ard.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO4 + mosi_pin: GPIO5 + miso_pin: GPIO6 + dc_pin: GPIO7 + cs_pin: GPIO0 + disp_cs_pin: GPIO1 + interrupt_pin: GPIO3 + reset_pin: GPIO10 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 8 - dc_pin: 9 - reset_pin: 10 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 4 - interrupt_pin: 3 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 28 - x_max: 280 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/xpt2046/test.esp32-c3-idf.yaml b/tests/components/xpt2046/test.esp32-c3-idf.yaml index 787ca9b1ed..79b84902ac 100644 --- a/tests/components/xpt2046/test.esp32-c3-idf.yaml +++ b/tests/components/xpt2046/test.esp32-c3-idf.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 6 - mosi_pin: 7 - miso_pin: 5 +substitutions: + clk_pin: GPIO4 + mosi_pin: GPIO5 + miso_pin: GPIO6 + dc_pin: GPIO7 + cs_pin: GPIO0 + disp_cs_pin: GPIO1 + interrupt_pin: GPIO3 + reset_pin: GPIO10 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 8 - dc_pin: 9 - reset_pin: 10 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 4 - interrupt_pin: 3 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 50 - x_max: 280 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/xpt2046/test.esp32-idf.yaml b/tests/components/xpt2046/test.esp32-idf.yaml index e79997146b..b39174947b 100644 --- a/tests/components/xpt2046/test.esp32-idf.yaml +++ b/tests/components/xpt2046/test.esp32-idf.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 16 - mosi_pin: 17 - miso_pin: 15 +substitutions: + clk_pin: GPIO17 + mosi_pin: GPIO18 + miso_pin: GPIO19 + dc_pin: GPIO13 + cs_pin: GPIO14 + disp_cs_pin: GPIO4 + interrupt_pin: GPIO21 + reset_pin: GPIO22 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 13 - dc_pin: 14 - reset_pin: 21 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 18 - interrupt_pin: 19 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 50 - x_max: 280 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/xpt2046/test.esp32-s2-ard.yaml b/tests/components/xpt2046/test.esp32-s2-ard.yaml deleted file mode 100644 index df2a99b4f5..0000000000 --- a/tests/components/xpt2046/test.esp32-s2-ard.yaml +++ /dev/null @@ -1,38 +0,0 @@ -spi: - clk_pin: 7 - mosi_pin: 11 - miso_pin: 9 - -display: - - platform: ili9xxx - id: my_display - model: ili9341 - cs_pin: 5 - dc_pin: 12 - reset_pin: 33 - auto_clear_enabled: false - data_rate: 40MHz - dimensions: 320x240 - update_interval: never - invert_colors: false - transform: - mirror_y: false - mirror_x: false - swap_xy: true - -touchscreen: - - platform: xpt2046 - display: my_display - id: my_toucher - update_interval: 50ms - cs_pin: 18 - threshold: 300 - calibration: - x_min: 210 - x_max: 3890 - y_min: 170 - y_max: 3730 - transform: - mirror_x: false - mirror_y: true - swap_xy: true diff --git a/tests/components/xpt2046/test.esp8266-ard.yaml b/tests/components/xpt2046/test.esp8266-ard.yaml index ab71f7b8bc..246c5c8953 100644 --- a/tests/components/xpt2046/test.esp8266-ard.yaml +++ b/tests/components/xpt2046/test.esp8266-ard.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 14 - mosi_pin: 13 - miso_pin: 12 +substitutions: + clk_pin: GPIO14 + mosi_pin: GPIO13 + miso_pin: GPIO12 + dc_pin: GPIO15 + cs_pin: GPIO16 + disp_cs_pin: GPIO4 + interrupt_pin: GPIO5 + reset_pin: GPIO2 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 15 - dc_pin: 4 - reset_pin: 5 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 0 - interrupt_pin: 16 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 50 - x_max: 280 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/xpt2046/test.rp2040-ard.yaml b/tests/components/xpt2046/test.rp2040-ard.yaml index 622e69ac98..e693b363d9 100644 --- a/tests/components/xpt2046/test.rp2040-ard.yaml +++ b/tests/components/xpt2046/test.rp2040-ard.yaml @@ -1,35 +1,11 @@ -spi: - - id: spi_xpt2046 - clk_pin: 2 - mosi_pin: 3 - miso_pin: 4 +substitutions: + clk_pin: GPIO6 + mosi_pin: GPIO7 + miso_pin: GPIO8 + dc_pin: GPIO9 + cs_pin: GPIO0 + disp_cs_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ili9xxx - id: xpt_display - dimensions: 320x240 - model: TFT 2.4 - cs_pin: 8 - dc_pin: 9 - reset_pin: 10 - invert_colors: false - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: xpt2046 - id: xpt_touchscreen - cs_pin: 5 - interrupt_pin: 6 - display: xpt_display - update_interval: 50ms - threshold: 400 - calibration: - x_min: 280 - x_max: 3860 - y_min: 340 - y_max: 3860 - on_touch: - - logger.log: - format: Touch at (%d, %d) - args: [touch.x, touch.y] +<<: !include common.yaml diff --git a/tests/components/yashima/common.yaml b/tests/components/yashima/common.yaml new file mode 100644 index 0000000000..bfe181f1a6 --- /dev/null +++ b/tests/components/yashima/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: yashima + name: Yashima Climate diff --git a/tests/components/yashima/test.esp32-ard.yaml b/tests/components/yashima/test.esp32-ard.yaml index 4b6d6daee4..7b012aa64c 100644 --- a/tests/components/yashima/test.esp32-ard.yaml +++ b/tests/components/yashima/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: yashima - name: Yashima Climate +<<: !include common.yaml diff --git a/tests/components/yashima/test.esp32-c3-ard.yaml b/tests/components/yashima/test.esp32-c3-ard.yaml index 4b6d6daee4..7b012aa64c 100644 --- a/tests/components/yashima/test.esp32-c3-ard.yaml +++ b/tests/components/yashima/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: yashima - name: Yashima Climate +<<: !include common.yaml diff --git a/tests/components/yashima/test.esp32-c3-idf.yaml b/tests/components/yashima/test.esp32-c3-idf.yaml index 4b6d6daee4..7b012aa64c 100644 --- a/tests/components/yashima/test.esp32-c3-idf.yaml +++ b/tests/components/yashima/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: yashima - name: Yashima Climate +<<: !include common.yaml diff --git a/tests/components/yashima/test.esp32-idf.yaml b/tests/components/yashima/test.esp32-idf.yaml index 4b6d6daee4..7b012aa64c 100644 --- a/tests/components/yashima/test.esp32-idf.yaml +++ b/tests/components/yashima/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: yashima - name: Yashima Climate +<<: !include common.yaml diff --git a/tests/components/yashima/test.esp8266-ard.yaml b/tests/components/yashima/test.esp8266-ard.yaml index 296a7ede25..f5097fcf5f 100644 --- a/tests/components/yashima/test.esp8266-ard.yaml +++ b/tests/components/yashima/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: yashima - name: Yashima Climate +<<: !include common.yaml diff --git a/tests/components/zhlt01/common.yaml b/tests/components/zhlt01/common.yaml new file mode 100644 index 0000000000..0adbe77325 --- /dev/null +++ b/tests/components/zhlt01/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: zhlt01 + name: ZH/LT-01 Climate diff --git a/tests/components/zhlt01/test.esp32-ard.yaml b/tests/components/zhlt01/test.esp32-ard.yaml index d1dc3b4926..7b012aa64c 100644 --- a/tests/components/zhlt01/test.esp32-ard.yaml +++ b/tests/components/zhlt01/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: zhlt01 - name: ZH/LT-01 Climate +<<: !include common.yaml diff --git a/tests/components/zhlt01/test.esp32-c3-ard.yaml b/tests/components/zhlt01/test.esp32-c3-ard.yaml index d1dc3b4926..7b012aa64c 100644 --- a/tests/components/zhlt01/test.esp32-c3-ard.yaml +++ b/tests/components/zhlt01/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: zhlt01 - name: ZH/LT-01 Climate +<<: !include common.yaml diff --git a/tests/components/zhlt01/test.esp32-c3-idf.yaml b/tests/components/zhlt01/test.esp32-c3-idf.yaml index d1dc3b4926..7b012aa64c 100644 --- a/tests/components/zhlt01/test.esp32-c3-idf.yaml +++ b/tests/components/zhlt01/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: zhlt01 - name: ZH/LT-01 Climate +<<: !include common.yaml diff --git a/tests/components/zhlt01/test.esp32-idf.yaml b/tests/components/zhlt01/test.esp32-idf.yaml index d1dc3b4926..7b012aa64c 100644 --- a/tests/components/zhlt01/test.esp32-idf.yaml +++ b/tests/components/zhlt01/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: zhlt01 - name: ZH/LT-01 Climate +<<: !include common.yaml diff --git a/tests/components/zhlt01/test.esp8266-ard.yaml b/tests/components/zhlt01/test.esp8266-ard.yaml index 40a00bc458..f5097fcf5f 100644 --- a/tests/components/zhlt01/test.esp8266-ard.yaml +++ b/tests/components/zhlt01/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: zhlt01 - name: ZH/LT-01 Climate +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/common.yaml b/tests/components/zio_ultrasonic/common.yaml new file mode 100644 index 0000000000..e13853d8f1 --- /dev/null +++ b/tests/components/zio_ultrasonic/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_zio_ultrasonic + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: zio_ultrasonic + name: "Distance" + update_interval: 60s diff --git a/tests/components/zio_ultrasonic/test.esp32-ard.yaml b/tests/components/zio_ultrasonic/test.esp32-ard.yaml index ad4050307e..63c3bd6afd 100644 --- a/tests/components/zio_ultrasonic/test.esp32-ard.yaml +++ b/tests/components/zio_ultrasonic/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/test.esp32-c3-ard.yaml b/tests/components/zio_ultrasonic/test.esp32-c3-ard.yaml index 36e1697a38..ee2c29ca4e 100644 --- a/tests/components/zio_ultrasonic/test.esp32-c3-ard.yaml +++ b/tests/components/zio_ultrasonic/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/test.esp32-c3-idf.yaml b/tests/components/zio_ultrasonic/test.esp32-c3-idf.yaml index 36e1697a38..ee2c29ca4e 100644 --- a/tests/components/zio_ultrasonic/test.esp32-c3-idf.yaml +++ b/tests/components/zio_ultrasonic/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/test.esp32-idf.yaml b/tests/components/zio_ultrasonic/test.esp32-idf.yaml index ad4050307e..63c3bd6afd 100644 --- a/tests/components/zio_ultrasonic/test.esp32-idf.yaml +++ b/tests/components/zio_ultrasonic/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/test.esp8266-ard.yaml b/tests/components/zio_ultrasonic/test.esp8266-ard.yaml index 36e1697a38..ee2c29ca4e 100644 --- a/tests/components/zio_ultrasonic/test.esp8266-ard.yaml +++ b/tests/components/zio_ultrasonic/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zio_ultrasonic/test.rp2040-ard.yaml b/tests/components/zio_ultrasonic/test.rp2040-ard.yaml index 36e1697a38..ee2c29ca4e 100644 --- a/tests/components/zio_ultrasonic/test.rp2040-ard.yaml +++ b/tests/components/zio_ultrasonic/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_zio_ultrasonic - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: zio_ultrasonic - name: "Distance" - update_interval: 60s +<<: !include common.yaml diff --git a/tests/components/zyaura/common.yaml b/tests/components/zyaura/common.yaml new file mode 100644 index 0000000000..e2a994a317 --- /dev/null +++ b/tests/components/zyaura/common.yaml @@ -0,0 +1,10 @@ +sensor: + - platform: zyaura + clock_pin: ${clock_pin} + data_pin: ${data_pin} + co2: + name: ZyAura CO2 + temperature: + name: ZyAura Temperature + humidity: + name: ZyAura Humidity diff --git a/tests/components/zyaura/test.esp32-ard.yaml b/tests/components/zyaura/test.esp32-ard.yaml index 29116a978b..d295973e3f 100644 --- a/tests/components/zyaura/test.esp32-ard.yaml +++ b/tests/components/zyaura/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 16 - data_pin: 17 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/zyaura/test.esp32-c3-ard.yaml b/tests/components/zyaura/test.esp32-c3-ard.yaml index 90205c468c..7808481215 100644 --- a/tests/components/zyaura/test.esp32-c3-ard.yaml +++ b/tests/components/zyaura/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 5 - data_pin: 4 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/zyaura/test.esp32-c3-idf.yaml b/tests/components/zyaura/test.esp32-c3-idf.yaml index 90205c468c..7808481215 100644 --- a/tests/components/zyaura/test.esp32-c3-idf.yaml +++ b/tests/components/zyaura/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 5 - data_pin: 4 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/zyaura/test.esp32-idf.yaml b/tests/components/zyaura/test.esp32-idf.yaml index 29116a978b..d295973e3f 100644 --- a/tests/components/zyaura/test.esp32-idf.yaml +++ b/tests/components/zyaura/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 16 - data_pin: 17 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO16 + data_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/zyaura/test.esp8266-ard.yaml b/tests/components/zyaura/test.esp8266-ard.yaml index 90205c468c..7808481215 100644 --- a/tests/components/zyaura/test.esp8266-ard.yaml +++ b/tests/components/zyaura/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 5 - data_pin: 4 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + +<<: !include common.yaml diff --git a/tests/components/zyaura/test.rp2040-ard.yaml b/tests/components/zyaura/test.rp2040-ard.yaml index 90205c468c..7808481215 100644 --- a/tests/components/zyaura/test.rp2040-ard.yaml +++ b/tests/components/zyaura/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -sensor: - - platform: zyaura - clock_pin: 5 - data_pin: 4 - co2: - name: ZyAura CO2 - temperature: - name: ZyAura Temperature - humidity: - name: ZyAura Humidity +substitutions: + clock_pin: GPIO5 + data_pin: GPIO4 + +<<: !include common.yaml From 8897a9866d4c80df8e528aacd73d05c604ba83a7 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Sun, 9 Feb 2025 15:43:21 -0600 Subject: [PATCH 04/79] [CI] Consolidate some tests (T) (#8208) --- tests/components/t6615/common.yaml | 10 +++ tests/components/t6615/test.esp32-ard.yaml | 13 +-- tests/components/t6615/test.esp32-c3-ard.yaml | 13 +-- tests/components/t6615/test.esp32-c3-idf.yaml | 13 +-- tests/components/t6615/test.esp32-idf.yaml | 13 +-- tests/components/t6615/test.esp8266-ard.yaml | 13 +-- tests/components/t6615/test.rp2040-ard.yaml | 13 +-- tests/components/tc74/common.yaml | 8 ++ tests/components/tc74/test.esp32-ard.yaml | 11 +-- tests/components/tc74/test.esp32-c3-ard.yaml | 11 +-- tests/components/tc74/test.esp32-c3-idf.yaml | 11 +-- tests/components/tc74/test.esp32-idf.yaml | 11 +-- tests/components/tc74/test.esp8266-ard.yaml | 11 +-- tests/components/tc74/test.rp2040-ard.yaml | 11 +-- tests/components/tca9548a/common.yaml | 15 ++++ tests/components/tca9548a/test.esp32-ard.yaml | 18 +--- .../tca9548a/test.esp32-c3-ard.yaml | 18 +--- .../tca9548a/test.esp32-c3-idf.yaml | 18 +--- tests/components/tca9548a/test.esp32-idf.yaml | 18 +--- .../components/tca9548a/test.esp8266-ard.yaml | 18 +--- .../components/tca9548a/test.rp2040-ard.yaml | 18 +--- tests/components/tca9555/common.yaml | 27 ++++++ tests/components/tca9555/test.esp32-ard.yaml | 30 +------ .../components/tca9555/test.esp32-c3-ard.yaml | 30 +------ .../components/tca9555/test.esp32-c3-idf.yaml | 30 +------ tests/components/tca9555/test.esp32-idf.yaml | 30 +------ .../components/tca9555/test.esp8266-ard.yaml | 30 +------ tests/components/tca9555/test.rp2040-ard.yaml | 30 +------ tests/components/tcl112/common.yaml | 15 ++++ tests/components/tcl112/test.esp32-ard.yaml | 17 +--- .../components/tcl112/test.esp32-c3-ard.yaml | 17 +--- .../components/tcl112/test.esp32-c3-idf.yaml | 17 +--- tests/components/tcl112/test.esp32-idf.yaml | 17 +--- tests/components/tcl112/test.esp8266-ard.yaml | 17 +--- tests/components/tcs34725/common.yaml | 21 +++++ tests/components/tcs34725/test.esp32-ard.yaml | 24 +----- .../tcs34725/test.esp32-c3-ard.yaml | 24 +----- .../tcs34725/test.esp32-c3-idf.yaml | 24 +----- tests/components/tcs34725/test.esp32-idf.yaml | 24 +----- .../components/tcs34725/test.esp8266-ard.yaml | 24 +----- .../components/tcs34725/test.rp2040-ard.yaml | 24 +----- tests/components/tee501/common.yaml | 9 ++ tests/components/tee501/test.esp32-ard.yaml | 12 +-- .../components/tee501/test.esp32-c3-ard.yaml | 12 +-- .../components/tee501/test.esp32-c3-idf.yaml | 12 +-- tests/components/tee501/test.esp32-idf.yaml | 12 +-- tests/components/tee501/test.esp8266-ard.yaml | 12 +-- tests/components/tee501/test.rp2040-ard.yaml | 12 +-- tests/components/teleinfo/common.yaml | 42 ++++++++++ tests/components/teleinfo/test.esp32-ard.yaml | 45 +--------- .../teleinfo/test.esp32-c3-ard.yaml | 45 +--------- .../teleinfo/test.esp32-c3-idf.yaml | 45 +--------- tests/components/teleinfo/test.esp32-idf.yaml | 45 +--------- .../components/teleinfo/test.esp8266-ard.yaml | 45 +--------- .../components/teleinfo/test.rp2040-ard.yaml | 45 +--------- tests/components/tlc59208f/common.yaml | 50 +++++++++++ .../components/tlc59208f/test.esp32-ard.yaml | 53 +----------- .../tlc59208f/test.esp32-c3-ard.yaml | 53 +----------- .../tlc59208f/test.esp32-c3-idf.yaml | 53 +----------- .../components/tlc59208f/test.esp32-idf.yaml | 53 +----------- .../tlc59208f/test.esp8266-ard.yaml | 53 +----------- .../components/tlc59208f/test.rp2040-ard.yaml | 53 +----------- tests/components/tm1621/common.yaml | 12 +++ tests/components/tm1621/test.esp32-ard.yaml | 19 ++--- .../components/tm1621/test.esp32-c3-ard.yaml | 19 ++--- .../components/tm1621/test.esp32-c3-idf.yaml | 19 ++--- tests/components/tm1621/test.esp32-idf.yaml | 19 ++--- tests/components/tm1621/test.esp8266-ard.yaml | 19 ++--- tests/components/tm1621/test.rp2040-ard.yaml | 19 ++--- tests/components/tm1637/common.yaml | 7 ++ tests/components/tm1637/test.esp32-ard.yaml | 12 ++- .../components/tm1637/test.esp32-c3-ard.yaml | 12 ++- .../components/tm1637/test.esp32-c3-idf.yaml | 12 ++- tests/components/tm1637/test.esp32-idf.yaml | 12 ++- tests/components/tm1637/test.esp8266-ard.yaml | 12 ++- tests/components/tm1637/test.rp2040-ard.yaml | 12 ++- tests/components/tmp102/common.yaml | 8 ++ tests/components/tmp102/test.esp32-ard.yaml | 11 +-- .../components/tmp102/test.esp32-c3-ard.yaml | 11 +-- .../components/tmp102/test.esp32-c3-idf.yaml | 11 +-- tests/components/tmp102/test.esp32-idf.yaml | 11 +-- tests/components/tmp102/test.esp8266-ard.yaml | 11 +-- tests/components/tmp102/test.rp2040-ard.yaml | 11 +-- tests/components/tmp1075/common.yaml | 16 ++++ tests/components/tmp1075/test.esp32-ard.yaml | 19 +---- .../components/tmp1075/test.esp32-c3-ard.yaml | 19 +---- .../components/tmp1075/test.esp32-c3-idf.yaml | 19 +---- tests/components/tmp1075/test.esp32-idf.yaml | 19 +---- .../components/tmp1075/test.esp8266-ard.yaml | 19 +---- tests/components/tmp1075/test.rp2040-ard.yaml | 19 +---- tests/components/tmp117/common.yaml | 9 ++ tests/components/tmp117/test.esp32-ard.yaml | 12 +-- .../components/tmp117/test.esp32-c3-ard.yaml | 12 +-- .../components/tmp117/test.esp32-c3-idf.yaml | 12 +-- tests/components/tmp117/test.esp32-idf.yaml | 12 +-- tests/components/tmp117/test.esp8266-ard.yaml | 12 +-- tests/components/tmp117/test.rp2040-ard.yaml | 12 +-- tests/components/tof10120/common.yaml | 9 ++ tests/components/tof10120/test.esp32-ard.yaml | 12 +-- .../tof10120/test.esp32-c3-ard.yaml | 12 +-- .../tof10120/test.esp32-c3-idf.yaml | 12 +-- tests/components/tof10120/test.esp32-idf.yaml | 12 +-- .../components/tof10120/test.esp8266-ard.yaml | 12 +-- .../components/tof10120/test.rp2040-ard.yaml | 12 +-- tests/components/toshiba/common.yaml | 7 ++ tests/components/toshiba/test.esp32-ard.yaml | 9 +- .../components/toshiba/test.esp32-c3-ard.yaml | 9 +- .../components/toshiba/test.esp32-c3-idf.yaml | 9 +- tests/components/toshiba/test.esp32-idf.yaml | 9 +- .../components/toshiba/test.esp8266-ard.yaml | 9 +- .../components/total_daily_energy/common.yaml | 32 ++++++++ .../total_daily_energy/test.esp32-ard.yaml | 36 ++------ .../total_daily_energy/test.esp32-c3-ard.yaml | 36 ++------ .../total_daily_energy/test.esp32-c3-idf.yaml | 36 ++------ .../total_daily_energy/test.esp32-idf.yaml | 36 ++------ .../total_daily_energy/test.esp8266-ard.yaml | 36 ++------ .../total_daily_energy/test.rp2040-ard.yaml | 36 ++------ tests/components/tsl2561/common.yaml | 13 +++ tests/components/tsl2561/test.esp32-ard.yaml | 16 +--- .../components/tsl2561/test.esp32-c3-ard.yaml | 16 +--- .../components/tsl2561/test.esp32-c3-idf.yaml | 16 +--- tests/components/tsl2561/test.esp32-idf.yaml | 16 +--- .../components/tsl2561/test.esp8266-ard.yaml | 16 +--- tests/components/tsl2561/test.rp2040-ard.yaml | 16 +--- tests/components/tsl2591/common.yaml | 25 ++++++ tests/components/tsl2591/test.esp32-ard.yaml | 28 +------ .../components/tsl2591/test.esp32-c3-ard.yaml | 28 +------ .../components/tsl2591/test.esp32-c3-idf.yaml | 28 +------ tests/components/tsl2591/test.esp32-idf.yaml | 28 +------ .../components/tsl2591/test.esp8266-ard.yaml | 28 +------ tests/components/tsl2591/test.rp2040-ard.yaml | 28 +------ tests/components/tt21100/common.yaml | 25 ++++++ tests/components/tt21100/test.esp32-ard.yaml | 31 ++----- .../components/tt21100/test.esp32-c3-ard.yaml | 31 ++----- .../components/tt21100/test.esp32-c3-idf.yaml | 31 ++----- tests/components/tt21100/test.esp32-idf.yaml | 31 ++----- .../components/tt21100/test.esp32-s2-ard.yaml | 44 ---------- .../components/tt21100/test.esp8266-ard.yaml | 31 ++----- tests/components/tt21100/test.rp2040-ard.yaml | 31 ++----- tests/components/ttp229_bsf/common.yaml | 8 ++ .../components/ttp229_bsf/test.esp32-ard.yaml | 11 +-- .../ttp229_bsf/test.esp32-c3-ard.yaml | 11 +-- .../ttp229_bsf/test.esp32-c3-idf.yaml | 11 +-- .../components/ttp229_bsf/test.esp32-idf.yaml | 11 +-- .../ttp229_bsf/test.esp8266-ard.yaml | 11 +-- .../ttp229_bsf/test.rp2040-ard.yaml | 11 +-- tests/components/ttp229_lsf/common.yaml | 11 +++ .../components/ttp229_lsf/test.esp32-ard.yaml | 14 +--- .../ttp229_lsf/test.esp32-c3-ard.yaml | 14 +--- .../ttp229_lsf/test.esp32-c3-idf.yaml | 14 +--- .../components/ttp229_lsf/test.esp32-idf.yaml | 14 +--- .../ttp229_lsf/test.esp8266-ard.yaml | 14 +--- .../ttp229_lsf/test.rp2040-ard.yaml | 14 +--- tests/components/tuya/common.yaml | 78 ++++++++++++++++++ tests/components/tuya/test.esp32-ard.yaml | 82 ++----------------- tests/components/tuya/test.esp32-c3-ard.yaml | 82 ++----------------- tests/components/tuya/test.esp32-c3-idf.yaml | 82 ++----------------- tests/components/tuya/test.esp32-idf.yaml | 82 ++----------------- tests/components/tuya/test.esp8266-ard.yaml | 82 ++----------------- tests/components/tuya/test.rp2040-ard.yaml | 82 ++----------------- 160 files changed, 1045 insertions(+), 2640 deletions(-) create mode 100644 tests/components/t6615/common.yaml create mode 100644 tests/components/tc74/common.yaml create mode 100644 tests/components/tca9548a/common.yaml create mode 100644 tests/components/tca9555/common.yaml create mode 100644 tests/components/tcl112/common.yaml create mode 100644 tests/components/tcs34725/common.yaml create mode 100644 tests/components/tee501/common.yaml create mode 100644 tests/components/teleinfo/common.yaml create mode 100644 tests/components/tlc59208f/common.yaml create mode 100644 tests/components/tm1621/common.yaml create mode 100644 tests/components/tm1637/common.yaml create mode 100644 tests/components/tmp102/common.yaml create mode 100644 tests/components/tmp1075/common.yaml create mode 100644 tests/components/tmp117/common.yaml create mode 100644 tests/components/tof10120/common.yaml create mode 100644 tests/components/toshiba/common.yaml create mode 100644 tests/components/total_daily_energy/common.yaml create mode 100644 tests/components/tsl2561/common.yaml create mode 100644 tests/components/tsl2591/common.yaml create mode 100644 tests/components/tt21100/common.yaml delete mode 100644 tests/components/tt21100/test.esp32-s2-ard.yaml create mode 100644 tests/components/ttp229_bsf/common.yaml create mode 100644 tests/components/ttp229_lsf/common.yaml create mode 100644 tests/components/tuya/common.yaml diff --git a/tests/components/t6615/common.yaml b/tests/components/t6615/common.yaml new file mode 100644 index 0000000000..3ad715ae2b --- /dev/null +++ b/tests/components/t6615/common.yaml @@ -0,0 +1,10 @@ +uart: + - id: uart_t6615 + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 19200 + +sensor: + - platform: t6615 + co2: + name: CO2 Sensor diff --git a/tests/components/t6615/test.esp32-ard.yaml b/tests/components/t6615/test.esp32-ard.yaml index 2cfaa0ae5b..f486544afa 100644 --- a/tests/components/t6615/test.esp32-ard.yaml +++ b/tests/components/t6615/test.esp32-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 17 - rx_pin: 16 - baud_rate: 19200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/t6615/test.esp32-c3-ard.yaml b/tests/components/t6615/test.esp32-c3-ard.yaml index e8690c770f..b516342f3b 100644 --- a/tests/components/t6615/test.esp32-c3-ard.yaml +++ b/tests/components/t6615/test.esp32-c3-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 4 - rx_pin: 5 - baud_rate: 19200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/t6615/test.esp32-c3-idf.yaml b/tests/components/t6615/test.esp32-c3-idf.yaml index e8690c770f..b516342f3b 100644 --- a/tests/components/t6615/test.esp32-c3-idf.yaml +++ b/tests/components/t6615/test.esp32-c3-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 4 - rx_pin: 5 - baud_rate: 19200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/t6615/test.esp32-idf.yaml b/tests/components/t6615/test.esp32-idf.yaml index 2cfaa0ae5b..f486544afa 100644 --- a/tests/components/t6615/test.esp32-idf.yaml +++ b/tests/components/t6615/test.esp32-idf.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 17 - rx_pin: 16 - baud_rate: 19200 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/t6615/test.esp8266-ard.yaml b/tests/components/t6615/test.esp8266-ard.yaml index e8690c770f..b516342f3b 100644 --- a/tests/components/t6615/test.esp8266-ard.yaml +++ b/tests/components/t6615/test.esp8266-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 4 - rx_pin: 5 - baud_rate: 19200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/t6615/test.rp2040-ard.yaml b/tests/components/t6615/test.rp2040-ard.yaml index e8690c770f..b516342f3b 100644 --- a/tests/components/t6615/test.rp2040-ard.yaml +++ b/tests/components/t6615/test.rp2040-ard.yaml @@ -1,10 +1,5 @@ -uart: - - id: uart_t6615 - tx_pin: 4 - rx_pin: 5 - baud_rate: 19200 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -sensor: - - platform: t6615 - co2: - name: CO2 Sensor +<<: !include common.yaml diff --git a/tests/components/tc74/common.yaml b/tests/components/tc74/common.yaml new file mode 100644 index 0000000000..88f5c91e12 --- /dev/null +++ b/tests/components/tc74/common.yaml @@ -0,0 +1,8 @@ +i2c: + - id: i2c_tc74 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tc74 + name: TC74 Temperature diff --git a/tests/components/tc74/test.esp32-ard.yaml b/tests/components/tc74/test.esp32-ard.yaml index ef9b40e184..63c3bd6afd 100644 --- a/tests/components/tc74/test.esp32-ard.yaml +++ b/tests/components/tc74/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tc74/test.esp32-c3-ard.yaml b/tests/components/tc74/test.esp32-c3-ard.yaml index e1a373fbf4..ee2c29ca4e 100644 --- a/tests/components/tc74/test.esp32-c3-ard.yaml +++ b/tests/components/tc74/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tc74/test.esp32-c3-idf.yaml b/tests/components/tc74/test.esp32-c3-idf.yaml index e1a373fbf4..ee2c29ca4e 100644 --- a/tests/components/tc74/test.esp32-c3-idf.yaml +++ b/tests/components/tc74/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tc74/test.esp32-idf.yaml b/tests/components/tc74/test.esp32-idf.yaml index ef9b40e184..63c3bd6afd 100644 --- a/tests/components/tc74/test.esp32-idf.yaml +++ b/tests/components/tc74/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tc74/test.esp8266-ard.yaml b/tests/components/tc74/test.esp8266-ard.yaml index e1a373fbf4..ee2c29ca4e 100644 --- a/tests/components/tc74/test.esp8266-ard.yaml +++ b/tests/components/tc74/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tc74/test.rp2040-ard.yaml b/tests/components/tc74/test.rp2040-ard.yaml index e1a373fbf4..ee2c29ca4e 100644 --- a/tests/components/tc74/test.rp2040-ard.yaml +++ b/tests/components/tc74/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tc74 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tc74 - name: TC74 Temperature +<<: !include common.yaml diff --git a/tests/components/tca9548a/common.yaml b/tests/components/tca9548a/common.yaml new file mode 100644 index 0000000000..67e812e08b --- /dev/null +++ b/tests/components/tca9548a/common.yaml @@ -0,0 +1,15 @@ +i2c: + - id: i2c_tca9548a + scl: ${scl_pin} + sda: ${sda_pin} + +tca9548a: + - id: multiplex0 + address: 0x70 + channels: + - bus_id: multiplex0_chan0 + channel: 0 + i2c_id: i2c_tca9548a + - id: multiplex1 + address: 0x71 + i2c_id: multiplex0_chan0 diff --git a/tests/components/tca9548a/test.esp32-ard.yaml b/tests/components/tca9548a/test.esp32-ard.yaml index 7edb83c821..63c3bd6afd 100644 --- a/tests/components/tca9548a/test.esp32-ard.yaml +++ b/tests/components/tca9548a/test.esp32-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9548a/test.esp32-c3-ard.yaml b/tests/components/tca9548a/test.esp32-c3-ard.yaml index 2294530d14..ee2c29ca4e 100644 --- a/tests/components/tca9548a/test.esp32-c3-ard.yaml +++ b/tests/components/tca9548a/test.esp32-c3-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9548a/test.esp32-c3-idf.yaml b/tests/components/tca9548a/test.esp32-c3-idf.yaml index 2294530d14..ee2c29ca4e 100644 --- a/tests/components/tca9548a/test.esp32-c3-idf.yaml +++ b/tests/components/tca9548a/test.esp32-c3-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9548a/test.esp32-idf.yaml b/tests/components/tca9548a/test.esp32-idf.yaml index 7edb83c821..63c3bd6afd 100644 --- a/tests/components/tca9548a/test.esp32-idf.yaml +++ b/tests/components/tca9548a/test.esp32-idf.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9548a/test.esp8266-ard.yaml b/tests/components/tca9548a/test.esp8266-ard.yaml index 2294530d14..ee2c29ca4e 100644 --- a/tests/components/tca9548a/test.esp8266-ard.yaml +++ b/tests/components/tca9548a/test.esp8266-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9548a/test.rp2040-ard.yaml b/tests/components/tca9548a/test.rp2040-ard.yaml index 2294530d14..ee2c29ca4e 100644 --- a/tests/components/tca9548a/test.rp2040-ard.yaml +++ b/tests/components/tca9548a/test.rp2040-ard.yaml @@ -1,15 +1,5 @@ -i2c: - - id: i2c_tca9548a - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9548a: - - id: multiplex0 - address: 0x70 - channels: - - bus_id: multiplex0_chan0 - channel: 0 - i2c_id: i2c_tca9548a - - id: multiplex1 - address: 0x71 - i2c_id: multiplex0_chan0 +<<: !include common.yaml diff --git a/tests/components/tca9555/common.yaml b/tests/components/tca9555/common.yaml new file mode 100644 index 0000000000..0fc3086786 --- /dev/null +++ b/tests/components/tca9555/common.yaml @@ -0,0 +1,27 @@ +i2c: + - id: i2c_tca9555 + scl: ${scl_pin} + sda: ${sda_pin} + +tca9555: + - id: tca9555_hub + address: 0x21 + +binary_sensor: + - platform: gpio + id: tca9555_binary_sensor + name: TCA9555 Binary Sensor + pin: + tca9555: tca9555_hub + number: 1 + mode: INPUT + inverted: true + +output: + - platform: gpio + id: tca9555_output + pin: + tca9555: tca9555_hub + number: 0 + mode: OUTPUT + inverted: false diff --git a/tests/components/tca9555/test.esp32-ard.yaml b/tests/components/tca9555/test.esp32-ard.yaml index e0c046b443..63c3bd6afd 100644 --- a/tests/components/tca9555/test.esp32-ard.yaml +++ b/tests/components/tca9555/test.esp32-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tca9555/test.esp32-c3-ard.yaml b/tests/components/tca9555/test.esp32-c3-ard.yaml index 5c49b27640..ee2c29ca4e 100644 --- a/tests/components/tca9555/test.esp32-c3-ard.yaml +++ b/tests/components/tca9555/test.esp32-c3-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tca9555/test.esp32-c3-idf.yaml b/tests/components/tca9555/test.esp32-c3-idf.yaml index 5c49b27640..ee2c29ca4e 100644 --- a/tests/components/tca9555/test.esp32-c3-idf.yaml +++ b/tests/components/tca9555/test.esp32-c3-idf.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tca9555/test.esp32-idf.yaml b/tests/components/tca9555/test.esp32-idf.yaml index e0c046b443..63c3bd6afd 100644 --- a/tests/components/tca9555/test.esp32-idf.yaml +++ b/tests/components/tca9555/test.esp32-idf.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tca9555/test.esp8266-ard.yaml b/tests/components/tca9555/test.esp8266-ard.yaml index 5c49b27640..ee2c29ca4e 100644 --- a/tests/components/tca9555/test.esp8266-ard.yaml +++ b/tests/components/tca9555/test.esp8266-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tca9555/test.rp2040-ard.yaml b/tests/components/tca9555/test.rp2040-ard.yaml index 5c49b27640..ee2c29ca4e 100644 --- a/tests/components/tca9555/test.rp2040-ard.yaml +++ b/tests/components/tca9555/test.rp2040-ard.yaml @@ -1,27 +1,5 @@ -i2c: - - id: i2c_tca9555 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tca9555: - - id: tca9555_hub - address: 0x21 - -binary_sensor: - - platform: gpio - id: tca9555_binary_sensor - name: TCA9555 Binary Sensor - pin: - tca9555: tca9555_hub - number: 1 - mode: INPUT - inverted: true - -output: - - platform: gpio - id: tca9555_output - pin: - tca9555: tca9555_hub - number: 0 - mode: OUTPUT - inverted: false +<<: !include common.yaml diff --git a/tests/components/tcl112/common.yaml b/tests/components/tcl112/common.yaml new file mode 100644 index 0000000000..0e43de4a4a --- /dev/null +++ b/tests/components/tcl112/common.yaml @@ -0,0 +1,15 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +sensor: + - platform: template + id: tcl112_sensor + lambda: "return 21;" + +climate: + - platform: tcl112 + name: TCL112 Climate with Sensor + supports_heat: true + supports_cool: true + sensor: tcl112_sensor diff --git a/tests/components/tcl112/test.esp32-ard.yaml b/tests/components/tcl112/test.esp32-ard.yaml index 03c0e84fe5..7b012aa64c 100644 --- a/tests/components/tcl112/test.esp32-ard.yaml +++ b/tests/components/tcl112/test.esp32-ard.yaml @@ -1,15 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -sensor: - - platform: template - id: tcl112_sensor - lambda: "return 21;" - -climate: - - platform: tcl112 - name: TCL112 Climate with Sensor - supports_heat: true - supports_cool: true - sensor: tcl112_sensor +<<: !include common.yaml diff --git a/tests/components/tcl112/test.esp32-c3-ard.yaml b/tests/components/tcl112/test.esp32-c3-ard.yaml index 03c0e84fe5..7b012aa64c 100644 --- a/tests/components/tcl112/test.esp32-c3-ard.yaml +++ b/tests/components/tcl112/test.esp32-c3-ard.yaml @@ -1,15 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -sensor: - - platform: template - id: tcl112_sensor - lambda: "return 21;" - -climate: - - platform: tcl112 - name: TCL112 Climate with Sensor - supports_heat: true - supports_cool: true - sensor: tcl112_sensor +<<: !include common.yaml diff --git a/tests/components/tcl112/test.esp32-c3-idf.yaml b/tests/components/tcl112/test.esp32-c3-idf.yaml index 03c0e84fe5..7b012aa64c 100644 --- a/tests/components/tcl112/test.esp32-c3-idf.yaml +++ b/tests/components/tcl112/test.esp32-c3-idf.yaml @@ -1,15 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -sensor: - - platform: template - id: tcl112_sensor - lambda: "return 21;" - -climate: - - platform: tcl112 - name: TCL112 Climate with Sensor - supports_heat: true - supports_cool: true - sensor: tcl112_sensor +<<: !include common.yaml diff --git a/tests/components/tcl112/test.esp32-idf.yaml b/tests/components/tcl112/test.esp32-idf.yaml index 03c0e84fe5..7b012aa64c 100644 --- a/tests/components/tcl112/test.esp32-idf.yaml +++ b/tests/components/tcl112/test.esp32-idf.yaml @@ -1,15 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -sensor: - - platform: template - id: tcl112_sensor - lambda: "return 21;" - -climate: - - platform: tcl112 - name: TCL112 Climate with Sensor - supports_heat: true - supports_cool: true - sensor: tcl112_sensor +<<: !include common.yaml diff --git a/tests/components/tcl112/test.esp8266-ard.yaml b/tests/components/tcl112/test.esp8266-ard.yaml index 0a85536928..f5097fcf5f 100644 --- a/tests/components/tcl112/test.esp8266-ard.yaml +++ b/tests/components/tcl112/test.esp8266-ard.yaml @@ -1,15 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -sensor: - - platform: template - id: tcl112_sensor - lambda: "return 21;" - -climate: - - platform: tcl112 - name: TCL112 Climate with Sensor - supports_heat: true - supports_cool: true - sensor: tcl112_sensor +<<: !include common.yaml diff --git a/tests/components/tcs34725/common.yaml b/tests/components/tcs34725/common.yaml new file mode 100644 index 0000000000..5296988fa5 --- /dev/null +++ b/tests/components/tcs34725/common.yaml @@ -0,0 +1,21 @@ +i2c: + - id: i2c_tcs34725 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tcs34725 + red_channel: + name: Red Channel + green_channel: + name: Green Channel + blue_channel: + name: Blue Channel + clear_channel: + name: Clear Channel + illuminance: + name: Illuminance + color_temperature: + name: Color Temperature + integration_time: 614ms + gain: 60x diff --git a/tests/components/tcs34725/test.esp32-ard.yaml b/tests/components/tcs34725/test.esp32-ard.yaml index 86ef82962e..63c3bd6afd 100644 --- a/tests/components/tcs34725/test.esp32-ard.yaml +++ b/tests/components/tcs34725/test.esp32-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tcs34725/test.esp32-c3-ard.yaml b/tests/components/tcs34725/test.esp32-c3-ard.yaml index 9b459c9104..ee2c29ca4e 100644 --- a/tests/components/tcs34725/test.esp32-c3-ard.yaml +++ b/tests/components/tcs34725/test.esp32-c3-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tcs34725/test.esp32-c3-idf.yaml b/tests/components/tcs34725/test.esp32-c3-idf.yaml index 9b459c9104..ee2c29ca4e 100644 --- a/tests/components/tcs34725/test.esp32-c3-idf.yaml +++ b/tests/components/tcs34725/test.esp32-c3-idf.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tcs34725/test.esp32-idf.yaml b/tests/components/tcs34725/test.esp32-idf.yaml index 86ef82962e..63c3bd6afd 100644 --- a/tests/components/tcs34725/test.esp32-idf.yaml +++ b/tests/components/tcs34725/test.esp32-idf.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tcs34725/test.esp8266-ard.yaml b/tests/components/tcs34725/test.esp8266-ard.yaml index 9b459c9104..ee2c29ca4e 100644 --- a/tests/components/tcs34725/test.esp8266-ard.yaml +++ b/tests/components/tcs34725/test.esp8266-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tcs34725/test.rp2040-ard.yaml b/tests/components/tcs34725/test.rp2040-ard.yaml index 9b459c9104..ee2c29ca4e 100644 --- a/tests/components/tcs34725/test.rp2040-ard.yaml +++ b/tests/components/tcs34725/test.rp2040-ard.yaml @@ -1,21 +1,5 @@ -i2c: - - id: i2c_tcs34725 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tcs34725 - red_channel: - name: Red Channel - green_channel: - name: Green Channel - blue_channel: - name: Blue Channel - clear_channel: - name: Clear Channel - illuminance: - name: Illuminance - color_temperature: - name: Color Temperature - integration_time: 614ms - gain: 60x +<<: !include common.yaml diff --git a/tests/components/tee501/common.yaml b/tests/components/tee501/common.yaml new file mode 100644 index 0000000000..c01ab7e37a --- /dev/null +++ b/tests/components/tee501/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_tee501 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tee501 + name: TEE501 Temperature + address: 0x48 diff --git a/tests/components/tee501/test.esp32-ard.yaml b/tests/components/tee501/test.esp32-ard.yaml index acf6fed4bf..63c3bd6afd 100644 --- a/tests/components/tee501/test.esp32-ard.yaml +++ b/tests/components/tee501/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/tee501/test.esp32-c3-ard.yaml b/tests/components/tee501/test.esp32-c3-ard.yaml index 11991a6153..ee2c29ca4e 100644 --- a/tests/components/tee501/test.esp32-c3-ard.yaml +++ b/tests/components/tee501/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/tee501/test.esp32-c3-idf.yaml b/tests/components/tee501/test.esp32-c3-idf.yaml index 11991a6153..ee2c29ca4e 100644 --- a/tests/components/tee501/test.esp32-c3-idf.yaml +++ b/tests/components/tee501/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/tee501/test.esp32-idf.yaml b/tests/components/tee501/test.esp32-idf.yaml index acf6fed4bf..63c3bd6afd 100644 --- a/tests/components/tee501/test.esp32-idf.yaml +++ b/tests/components/tee501/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/tee501/test.esp8266-ard.yaml b/tests/components/tee501/test.esp8266-ard.yaml index 11991a6153..ee2c29ca4e 100644 --- a/tests/components/tee501/test.esp8266-ard.yaml +++ b/tests/components/tee501/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/tee501/test.rp2040-ard.yaml b/tests/components/tee501/test.rp2040-ard.yaml index 11991a6153..ee2c29ca4e 100644 --- a/tests/components/tee501/test.rp2040-ard.yaml +++ b/tests/components/tee501/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tee501 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tee501 - name: TEE501 Temperature - address: 0x48 +<<: !include common.yaml diff --git a/tests/components/teleinfo/common.yaml b/tests/components/teleinfo/common.yaml new file mode 100644 index 0000000000..90b684e977 --- /dev/null +++ b/tests/components/teleinfo/common.yaml @@ -0,0 +1,42 @@ +uart: + - id: uart_teleinfo + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 1200 + parity: EVEN + +button: + - platform: template + name: Poller component suspend test + on_press: + - component.suspend: test_teleinfo + - delay: 20s + - component.update: test_teleinfo + - delay: 20s + - component.resume: test_teleinfo + - delay: 20s + - component.resume: + id: test_teleinfo + update_interval: 2s + - delay: 20s + - component.resume: + id: test_teleinfo + update_interval: !lambda return 2500; + +teleinfo: + id: test_teleinfo + historical_mode: true + update_interval: 60s + +sensor: + - platform: teleinfo + name: hchc + tag_name: HCHC + teleinfo_id: test_teleinfo + unit_of_measurement: Wh + +text_sensor: + - platform: teleinfo + name: optarif + tag_name: OPTARIF + teleinfo_id: test_teleinfo diff --git a/tests/components/teleinfo/test.esp32-ard.yaml b/tests/components/teleinfo/test.esp32-ard.yaml index a5bd176143..f486544afa 100644 --- a/tests/components/teleinfo/test.esp32-ard.yaml +++ b/tests/components/teleinfo/test.esp32-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 17 - rx_pin: 16 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/teleinfo/test.esp32-c3-ard.yaml b/tests/components/teleinfo/test.esp32-c3-ard.yaml index 55641e1e01..b516342f3b 100644 --- a/tests/components/teleinfo/test.esp32-c3-ard.yaml +++ b/tests/components/teleinfo/test.esp32-c3-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/teleinfo/test.esp32-c3-idf.yaml b/tests/components/teleinfo/test.esp32-c3-idf.yaml index 55641e1e01..b516342f3b 100644 --- a/tests/components/teleinfo/test.esp32-c3-idf.yaml +++ b/tests/components/teleinfo/test.esp32-c3-idf.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/teleinfo/test.esp32-idf.yaml b/tests/components/teleinfo/test.esp32-idf.yaml index a5bd176143..f486544afa 100644 --- a/tests/components/teleinfo/test.esp32-idf.yaml +++ b/tests/components/teleinfo/test.esp32-idf.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 17 - rx_pin: 16 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/teleinfo/test.esp8266-ard.yaml b/tests/components/teleinfo/test.esp8266-ard.yaml index 55641e1e01..b516342f3b 100644 --- a/tests/components/teleinfo/test.esp8266-ard.yaml +++ b/tests/components/teleinfo/test.esp8266-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/teleinfo/test.rp2040-ard.yaml b/tests/components/teleinfo/test.rp2040-ard.yaml index 55641e1e01..b516342f3b 100644 --- a/tests/components/teleinfo/test.rp2040-ard.yaml +++ b/tests/components/teleinfo/test.rp2040-ard.yaml @@ -1,42 +1,5 @@ -uart: - - id: uart_teleinfo - tx_pin: 4 - rx_pin: 5 - baud_rate: 1200 - parity: EVEN +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 -button: - - platform: template - name: Poller component suspend test - on_press: - - component.suspend: test_teleinfo - - delay: 20s - - component.update: test_teleinfo - - delay: 20s - - component.resume: test_teleinfo - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: 2s - - delay: 20s - - component.resume: - id: test_teleinfo - update_interval: !lambda return 2500; - -teleinfo: - id: test_teleinfo - historical_mode: true - update_interval: 60s - -sensor: - - platform: teleinfo - name: hchc - tag_name: HCHC - teleinfo_id: test_teleinfo - unit_of_measurement: Wh - -text_sensor: - - platform: teleinfo - name: optarif - tag_name: OPTARIF - teleinfo_id: test_teleinfo +<<: !include common.yaml diff --git a/tests/components/tlc59208f/common.yaml b/tests/components/tlc59208f/common.yaml new file mode 100644 index 0000000000..49460dcefc --- /dev/null +++ b/tests/components/tlc59208f/common.yaml @@ -0,0 +1,50 @@ +i2c: + - id: i2c_tlc59208f + scl: ${scl_pin} + sda: ${sda_pin} + +tlc59208f: + - address: 0x20 + id: tlc59208f_1 + - address: 0x22 + id: tlc59208f_2 + - address: 0x24 + id: tlc59208f_3 + +output: + - platform: tlc59208f + id: tlc_0 + channel: 0 + tlc59208f_id: tlc59208f_1 + - platform: tlc59208f + id: tlc_1 + channel: 1 + tlc59208f_id: tlc59208f_1 + - platform: tlc59208f + id: tlc_2 + channel: 2 + tlc59208f_id: tlc59208f_1 + - platform: tlc59208f + id: tlc_3 + channel: 0 + tlc59208f_id: tlc59208f_2 + - platform: tlc59208f + id: tlc_4 + channel: 1 + tlc59208f_id: tlc59208f_2 + - platform: tlc59208f + id: tlc_5 + channel: 2 + tlc59208f_id: tlc59208f_2 + - platform: tlc59208f + id: tlc_6 + channel: 0 + tlc59208f_id: tlc59208f_3 + - platform: tlc59208f + id: tlc_7 + channel: 1 + tlc59208f_id: tlc59208f_3 + - platform: tlc59208f + id: tlc_8 + channel: 2 + tlc59208f_id: tlc59208f_3 diff --git a/tests/components/tlc59208f/test.esp32-ard.yaml b/tests/components/tlc59208f/test.esp32-ard.yaml index 2639de3b3d..63c3bd6afd 100644 --- a/tests/components/tlc59208f/test.esp32-ard.yaml +++ b/tests/components/tlc59208f/test.esp32-ard.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tlc59208f/test.esp32-c3-ard.yaml b/tests/components/tlc59208f/test.esp32-c3-ard.yaml index 923ea4b4a4..ee2c29ca4e 100644 --- a/tests/components/tlc59208f/test.esp32-c3-ard.yaml +++ b/tests/components/tlc59208f/test.esp32-c3-ard.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tlc59208f/test.esp32-c3-idf.yaml b/tests/components/tlc59208f/test.esp32-c3-idf.yaml index 923ea4b4a4..ee2c29ca4e 100644 --- a/tests/components/tlc59208f/test.esp32-c3-idf.yaml +++ b/tests/components/tlc59208f/test.esp32-c3-idf.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tlc59208f/test.esp32-idf.yaml b/tests/components/tlc59208f/test.esp32-idf.yaml index 2639de3b3d..63c3bd6afd 100644 --- a/tests/components/tlc59208f/test.esp32-idf.yaml +++ b/tests/components/tlc59208f/test.esp32-idf.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tlc59208f/test.esp8266-ard.yaml b/tests/components/tlc59208f/test.esp8266-ard.yaml index 923ea4b4a4..ee2c29ca4e 100644 --- a/tests/components/tlc59208f/test.esp8266-ard.yaml +++ b/tests/components/tlc59208f/test.esp8266-ard.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tlc59208f/test.rp2040-ard.yaml b/tests/components/tlc59208f/test.rp2040-ard.yaml index 923ea4b4a4..ee2c29ca4e 100644 --- a/tests/components/tlc59208f/test.rp2040-ard.yaml +++ b/tests/components/tlc59208f/test.rp2040-ard.yaml @@ -1,50 +1,5 @@ -i2c: - - id: i2c_tlc59208f - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -tlc59208f: - - address: 0x20 - id: tlc59208f_1 - - address: 0x22 - id: tlc59208f_2 - - address: 0x24 - id: tlc59208f_3 - -output: - - platform: tlc59208f - id: tlc_0 - channel: 0 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_1 - channel: 1 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_2 - channel: 2 - tlc59208f_id: tlc59208f_1 - - platform: tlc59208f - id: tlc_3 - channel: 0 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_4 - channel: 1 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_5 - channel: 2 - tlc59208f_id: tlc59208f_2 - - platform: tlc59208f - id: tlc_6 - channel: 0 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_7 - channel: 1 - tlc59208f_id: tlc59208f_3 - - platform: tlc59208f - id: tlc_8 - channel: 2 - tlc59208f_id: tlc59208f_3 +<<: !include common.yaml diff --git a/tests/components/tm1621/common.yaml b/tests/components/tm1621/common.yaml new file mode 100644 index 0000000000..77f7ae74fe --- /dev/null +++ b/tests/components/tm1621/common.yaml @@ -0,0 +1,12 @@ +display: + - platform: tm1621 + id: tm1621_display + cs_pin: ${cs_pin} + data_pin: ${data_pin} + read_pin: ${read_pin} + write_pin: ${write_pin} + lambda: |- + it.printf(0, "%.1f", 20.0); + it.display_celsius(true); + it.printf(1, "%.1f", 20.0); + it.display_humidity(true); diff --git a/tests/components/tm1621/test.esp32-ard.yaml b/tests/components/tm1621/test.esp32-ard.yaml index 8eab46f000..0441e4bffe 100644 --- a/tests/components/tm1621/test.esp32-ard.yaml +++ b/tests/components/tm1621/test.esp32-ard.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 15 - data_pin: 14 - read_pin: 12 - write_pin: 13 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO16 + data_pin: GPIO17 + read_pin: GPIO12 + write_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1621/test.esp32-c3-ard.yaml b/tests/components/tm1621/test.esp32-c3-ard.yaml index cddd64f31f..562ced7485 100644 --- a/tests/components/tm1621/test.esp32-c3-ard.yaml +++ b/tests/components/tm1621/test.esp32-c3-ard.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 7 - data_pin: 4 - read_pin: 5 - write_pin: 6 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO6 + data_pin: GPIO7 + read_pin: GPIO2 + write_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tm1621/test.esp32-c3-idf.yaml b/tests/components/tm1621/test.esp32-c3-idf.yaml index cddd64f31f..562ced7485 100644 --- a/tests/components/tm1621/test.esp32-c3-idf.yaml +++ b/tests/components/tm1621/test.esp32-c3-idf.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 7 - data_pin: 4 - read_pin: 5 - write_pin: 6 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO6 + data_pin: GPIO7 + read_pin: GPIO2 + write_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tm1621/test.esp32-idf.yaml b/tests/components/tm1621/test.esp32-idf.yaml index 8eab46f000..0441e4bffe 100644 --- a/tests/components/tm1621/test.esp32-idf.yaml +++ b/tests/components/tm1621/test.esp32-idf.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 15 - data_pin: 14 - read_pin: 12 - write_pin: 13 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO16 + data_pin: GPIO17 + read_pin: GPIO12 + write_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1621/test.esp8266-ard.yaml b/tests/components/tm1621/test.esp8266-ard.yaml index 8eab46f000..ee7b62ce35 100644 --- a/tests/components/tm1621/test.esp8266-ard.yaml +++ b/tests/components/tm1621/test.esp8266-ard.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 15 - data_pin: 14 - read_pin: 12 - write_pin: 13 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO15 + data_pin: GPIO14 + read_pin: GPIO12 + write_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1621/test.rp2040-ard.yaml b/tests/components/tm1621/test.rp2040-ard.yaml index cddd64f31f..562ced7485 100644 --- a/tests/components/tm1621/test.rp2040-ard.yaml +++ b/tests/components/tm1621/test.rp2040-ard.yaml @@ -1,12 +1,7 @@ -display: - - platform: tm1621 - id: tm1621_display - cs_pin: 7 - data_pin: 4 - read_pin: 5 - write_pin: 6 - lambda: |- - it.printf(0, "%.1f", 20.0); - it.display_celsius(true); - it.printf(1, "%.1f", 20.0); - it.display_humidity(true); +substitutions: + cs_pin: GPIO6 + data_pin: GPIO7 + read_pin: GPIO2 + write_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tm1637/common.yaml b/tests/components/tm1637/common.yaml new file mode 100644 index 0000000000..8d01e29877 --- /dev/null +++ b/tests/components/tm1637/common.yaml @@ -0,0 +1,7 @@ +display: + - platform: tm1637 + clk_pin: ${clk_pin} + dio_pin: ${dio_pin} + intensity: 3 + lambda: |- + it.print("1234"); diff --git a/tests/components/tm1637/test.esp32-ard.yaml b/tests/components/tm1637/test.esp32-ard.yaml index bf5f331cca..2c5786c47c 100644 --- a/tests/components/tm1637/test.esp32-ard.yaml +++ b/tests/components/tm1637/test.esp32-ard.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 15 - dio_pin: 14 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO14 + dio_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1637/test.esp32-c3-ard.yaml b/tests/components/tm1637/test.esp32-c3-ard.yaml index fa4c95b443..96f6708a3b 100644 --- a/tests/components/tm1637/test.esp32-c3-ard.yaml +++ b/tests/components/tm1637/test.esp32-c3-ard.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 5 - dio_pin: 4 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO4 + dio_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tm1637/test.esp32-c3-idf.yaml b/tests/components/tm1637/test.esp32-c3-idf.yaml index fa4c95b443..96f6708a3b 100644 --- a/tests/components/tm1637/test.esp32-c3-idf.yaml +++ b/tests/components/tm1637/test.esp32-c3-idf.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 5 - dio_pin: 4 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO4 + dio_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tm1637/test.esp32-idf.yaml b/tests/components/tm1637/test.esp32-idf.yaml index bf5f331cca..2c5786c47c 100644 --- a/tests/components/tm1637/test.esp32-idf.yaml +++ b/tests/components/tm1637/test.esp32-idf.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 15 - dio_pin: 14 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO14 + dio_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1637/test.esp8266-ard.yaml b/tests/components/tm1637/test.esp8266-ard.yaml index fa4c95b443..2c5786c47c 100644 --- a/tests/components/tm1637/test.esp8266-ard.yaml +++ b/tests/components/tm1637/test.esp8266-ard.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 5 - dio_pin: 4 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO14 + dio_pin: GPIO13 + +<<: !include common.yaml diff --git a/tests/components/tm1637/test.rp2040-ard.yaml b/tests/components/tm1637/test.rp2040-ard.yaml index fa4c95b443..96f6708a3b 100644 --- a/tests/components/tm1637/test.rp2040-ard.yaml +++ b/tests/components/tm1637/test.rp2040-ard.yaml @@ -1,7 +1,5 @@ -display: - - platform: tm1637 - clk_pin: 5 - dio_pin: 4 - intensity: 3 - lambda: |- - it.print("1234"); +substitutions: + clk_pin: GPIO4 + dio_pin: GPIO3 + +<<: !include common.yaml diff --git a/tests/components/tmp102/common.yaml b/tests/components/tmp102/common.yaml new file mode 100644 index 0000000000..afc4a27fad --- /dev/null +++ b/tests/components/tmp102/common.yaml @@ -0,0 +1,8 @@ +i2c: + - id: i2c_tmp102 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tmp102 + name: TMP102 Temperature diff --git a/tests/components/tmp102/test.esp32-ard.yaml b/tests/components/tmp102/test.esp32-ard.yaml index 840bf7edb3..63c3bd6afd 100644 --- a/tests/components/tmp102/test.esp32-ard.yaml +++ b/tests/components/tmp102/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp102/test.esp32-c3-ard.yaml b/tests/components/tmp102/test.esp32-c3-ard.yaml index c1d35fca3f..ee2c29ca4e 100644 --- a/tests/components/tmp102/test.esp32-c3-ard.yaml +++ b/tests/components/tmp102/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp102/test.esp32-c3-idf.yaml b/tests/components/tmp102/test.esp32-c3-idf.yaml index c1d35fca3f..ee2c29ca4e 100644 --- a/tests/components/tmp102/test.esp32-c3-idf.yaml +++ b/tests/components/tmp102/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp102/test.esp32-idf.yaml b/tests/components/tmp102/test.esp32-idf.yaml index 840bf7edb3..63c3bd6afd 100644 --- a/tests/components/tmp102/test.esp32-idf.yaml +++ b/tests/components/tmp102/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp102/test.esp8266-ard.yaml b/tests/components/tmp102/test.esp8266-ard.yaml index c1d35fca3f..ee2c29ca4e 100644 --- a/tests/components/tmp102/test.esp8266-ard.yaml +++ b/tests/components/tmp102/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp102/test.rp2040-ard.yaml b/tests/components/tmp102/test.rp2040-ard.yaml index c1d35fca3f..ee2c29ca4e 100644 --- a/tests/components/tmp102/test.rp2040-ard.yaml +++ b/tests/components/tmp102/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -i2c: - - id: i2c_tmp102 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp102 - name: TMP102 Temperature +<<: !include common.yaml diff --git a/tests/components/tmp1075/common.yaml b/tests/components/tmp1075/common.yaml new file mode 100644 index 0000000000..4c4c6c6f35 --- /dev/null +++ b/tests/components/tmp1075/common.yaml @@ -0,0 +1,16 @@ +i2c: + - id: i2c_tmp1075 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tmp1075 + name: Temperature TMP1075 + conversion_rate: 27.5ms + alert: + limit_low: 50 + limit_high: 75 + fault_count: 1 + polarity: active_high + function: comparator + update_interval: 10s diff --git a/tests/components/tmp1075/test.esp32-ard.yaml b/tests/components/tmp1075/test.esp32-ard.yaml index 6c50d0da77..63c3bd6afd 100644 --- a/tests/components/tmp1075/test.esp32-ard.yaml +++ b/tests/components/tmp1075/test.esp32-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp1075/test.esp32-c3-ard.yaml b/tests/components/tmp1075/test.esp32-c3-ard.yaml index 99433aa655..ee2c29ca4e 100644 --- a/tests/components/tmp1075/test.esp32-c3-ard.yaml +++ b/tests/components/tmp1075/test.esp32-c3-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp1075/test.esp32-c3-idf.yaml b/tests/components/tmp1075/test.esp32-c3-idf.yaml index 99433aa655..ee2c29ca4e 100644 --- a/tests/components/tmp1075/test.esp32-c3-idf.yaml +++ b/tests/components/tmp1075/test.esp32-c3-idf.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp1075/test.esp32-idf.yaml b/tests/components/tmp1075/test.esp32-idf.yaml index 6c50d0da77..63c3bd6afd 100644 --- a/tests/components/tmp1075/test.esp32-idf.yaml +++ b/tests/components/tmp1075/test.esp32-idf.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp1075/test.esp8266-ard.yaml b/tests/components/tmp1075/test.esp8266-ard.yaml index 99433aa655..ee2c29ca4e 100644 --- a/tests/components/tmp1075/test.esp8266-ard.yaml +++ b/tests/components/tmp1075/test.esp8266-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp1075/test.rp2040-ard.yaml b/tests/components/tmp1075/test.rp2040-ard.yaml index 99433aa655..ee2c29ca4e 100644 --- a/tests/components/tmp1075/test.rp2040-ard.yaml +++ b/tests/components/tmp1075/test.rp2040-ard.yaml @@ -1,16 +1,5 @@ -i2c: - - id: i2c_tmp1075 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp1075 - name: Temperature TMP1075 - conversion_rate: 27.5ms - alert: - limit_low: 50 - limit_high: 75 - fault_count: 1 - polarity: active_high - function: comparator - update_interval: 10s +<<: !include common.yaml diff --git a/tests/components/tmp117/common.yaml b/tests/components/tmp117/common.yaml new file mode 100644 index 0000000000..f4a5688933 --- /dev/null +++ b/tests/components/tmp117/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_tmp117 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tmp117 + name: TMP117 Temperature + update_interval: 5s diff --git a/tests/components/tmp117/test.esp32-ard.yaml b/tests/components/tmp117/test.esp32-ard.yaml index 03e0dd4e8e..63c3bd6afd 100644 --- a/tests/components/tmp117/test.esp32-ard.yaml +++ b/tests/components/tmp117/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tmp117/test.esp32-c3-ard.yaml b/tests/components/tmp117/test.esp32-c3-ard.yaml index 61fc2cc03d..ee2c29ca4e 100644 --- a/tests/components/tmp117/test.esp32-c3-ard.yaml +++ b/tests/components/tmp117/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tmp117/test.esp32-c3-idf.yaml b/tests/components/tmp117/test.esp32-c3-idf.yaml index 61fc2cc03d..ee2c29ca4e 100644 --- a/tests/components/tmp117/test.esp32-c3-idf.yaml +++ b/tests/components/tmp117/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tmp117/test.esp32-idf.yaml b/tests/components/tmp117/test.esp32-idf.yaml index 03e0dd4e8e..63c3bd6afd 100644 --- a/tests/components/tmp117/test.esp32-idf.yaml +++ b/tests/components/tmp117/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tmp117/test.esp8266-ard.yaml b/tests/components/tmp117/test.esp8266-ard.yaml index 61fc2cc03d..ee2c29ca4e 100644 --- a/tests/components/tmp117/test.esp8266-ard.yaml +++ b/tests/components/tmp117/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tmp117/test.rp2040-ard.yaml b/tests/components/tmp117/test.rp2040-ard.yaml index 61fc2cc03d..ee2c29ca4e 100644 --- a/tests/components/tmp117/test.rp2040-ard.yaml +++ b/tests/components/tmp117/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tmp117 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tmp117 - name: TMP117 Temperature - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/common.yaml b/tests/components/tof10120/common.yaml new file mode 100644 index 0000000000..67643323d9 --- /dev/null +++ b/tests/components/tof10120/common.yaml @@ -0,0 +1,9 @@ +i2c: + - id: i2c_tof10120 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tof10120 + name: Distance sensor + update_interval: 5s diff --git a/tests/components/tof10120/test.esp32-ard.yaml b/tests/components/tof10120/test.esp32-ard.yaml index 74541ecde8..63c3bd6afd 100644 --- a/tests/components/tof10120/test.esp32-ard.yaml +++ b/tests/components/tof10120/test.esp32-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/test.esp32-c3-ard.yaml b/tests/components/tof10120/test.esp32-c3-ard.yaml index 01cde0df6a..ee2c29ca4e 100644 --- a/tests/components/tof10120/test.esp32-c3-ard.yaml +++ b/tests/components/tof10120/test.esp32-c3-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/test.esp32-c3-idf.yaml b/tests/components/tof10120/test.esp32-c3-idf.yaml index 01cde0df6a..ee2c29ca4e 100644 --- a/tests/components/tof10120/test.esp32-c3-idf.yaml +++ b/tests/components/tof10120/test.esp32-c3-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/test.esp32-idf.yaml b/tests/components/tof10120/test.esp32-idf.yaml index 74541ecde8..63c3bd6afd 100644 --- a/tests/components/tof10120/test.esp32-idf.yaml +++ b/tests/components/tof10120/test.esp32-idf.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/test.esp8266-ard.yaml b/tests/components/tof10120/test.esp8266-ard.yaml index 01cde0df6a..ee2c29ca4e 100644 --- a/tests/components/tof10120/test.esp8266-ard.yaml +++ b/tests/components/tof10120/test.esp8266-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/tof10120/test.rp2040-ard.yaml b/tests/components/tof10120/test.rp2040-ard.yaml index 01cde0df6a..ee2c29ca4e 100644 --- a/tests/components/tof10120/test.rp2040-ard.yaml +++ b/tests/components/tof10120/test.rp2040-ard.yaml @@ -1,9 +1,5 @@ -i2c: - - id: i2c_tof10120 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tof10120 - name: Distance sensor - update_interval: 5s +<<: !include common.yaml diff --git a/tests/components/toshiba/common.yaml b/tests/components/toshiba/common.yaml new file mode 100644 index 0000000000..79a833980e --- /dev/null +++ b/tests/components/toshiba/common.yaml @@ -0,0 +1,7 @@ +remote_transmitter: + pin: ${pin} + carrier_duty_percent: 50% + +climate: + - platform: toshiba + name: Toshiba Climate diff --git a/tests/components/toshiba/test.esp32-ard.yaml b/tests/components/toshiba/test.esp32-ard.yaml index c134c7f5bd..7b012aa64c 100644 --- a/tests/components/toshiba/test.esp32-ard.yaml +++ b/tests/components/toshiba/test.esp32-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: toshiba - name: Toshiba Climate +<<: !include common.yaml diff --git a/tests/components/toshiba/test.esp32-c3-ard.yaml b/tests/components/toshiba/test.esp32-c3-ard.yaml index c134c7f5bd..7b012aa64c 100644 --- a/tests/components/toshiba/test.esp32-c3-ard.yaml +++ b/tests/components/toshiba/test.esp32-c3-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: toshiba - name: Toshiba Climate +<<: !include common.yaml diff --git a/tests/components/toshiba/test.esp32-c3-idf.yaml b/tests/components/toshiba/test.esp32-c3-idf.yaml index c134c7f5bd..7b012aa64c 100644 --- a/tests/components/toshiba/test.esp32-c3-idf.yaml +++ b/tests/components/toshiba/test.esp32-c3-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: toshiba - name: Toshiba Climate +<<: !include common.yaml diff --git a/tests/components/toshiba/test.esp32-idf.yaml b/tests/components/toshiba/test.esp32-idf.yaml index c134c7f5bd..7b012aa64c 100644 --- a/tests/components/toshiba/test.esp32-idf.yaml +++ b/tests/components/toshiba/test.esp32-idf.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 2 - carrier_duty_percent: 50% +substitutions: + pin: GPIO2 -climate: - - platform: toshiba - name: Toshiba Climate +<<: !include common.yaml diff --git a/tests/components/toshiba/test.esp8266-ard.yaml b/tests/components/toshiba/test.esp8266-ard.yaml index 8730a5d4ab..f5097fcf5f 100644 --- a/tests/components/toshiba/test.esp8266-ard.yaml +++ b/tests/components/toshiba/test.esp8266-ard.yaml @@ -1,7 +1,4 @@ -remote_transmitter: - pin: 5 - carrier_duty_percent: 50% +substitutions: + pin: GPIO5 -climate: - - platform: toshiba - name: Toshiba Climate +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/common.yaml b/tests/components/total_daily_energy/common.yaml new file mode 100644 index 0000000000..ae4d30408b --- /dev/null +++ b/tests/components/total_daily_energy/common.yaml @@ -0,0 +1,32 @@ +wifi: + ssid: MySSID + password: password1 + +time: + - platform: sntp + id: sntp_time + +sensor: + - platform: hlw8012 + sel_pin: ${sel_pin} + cf_pin: ${cf_pin} + cf1_pin: ${cf1_pin} + current: + name: HLW8012 Current + voltage: + name: HLW8012 Voltage + power: + name: HLW8012 Power + id: hlw8012_power + energy: + name: HLW8012 Energy + id: hlw8012_energy + update_interval: 15s + current_resistor: 0.001 ohm + voltage_divider: 2351 + change_mode_every: "never" + initial_mode: VOLTAGE + model: hlw8012 + - platform: total_daily_energy + name: HLW8012 Total Daily Energy + power_id: hlw8012_power diff --git a/tests/components/total_daily_energy/test.esp32-ard.yaml b/tests/components/total_daily_energy/test.esp32-ard.yaml index 34d452aae5..8b42b21b54 100644 --- a/tests/components/total_daily_energy/test.esp32-ard.yaml +++ b/tests/components/total_daily_energy/test.esp32-ard.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO12 + cf_pin: GPIO13 + cf1_pin: GPIO14 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 15 - cf_pin: 14 - cf1_pin: 13 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/test.esp32-c3-ard.yaml b/tests/components/total_daily_energy/test.esp32-c3-ard.yaml index 71afa45ed5..8b0d069ce2 100644 --- a/tests/components/total_daily_energy/test.esp32-c3-ard.yaml +++ b/tests/components/total_daily_energy/test.esp32-c3-ard.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO2 + cf_pin: GPIO3 + cf1_pin: GPIO4 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 5 - cf_pin: 4 - cf1_pin: 3 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/test.esp32-c3-idf.yaml b/tests/components/total_daily_energy/test.esp32-c3-idf.yaml index 71afa45ed5..8b0d069ce2 100644 --- a/tests/components/total_daily_energy/test.esp32-c3-idf.yaml +++ b/tests/components/total_daily_energy/test.esp32-c3-idf.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO2 + cf_pin: GPIO3 + cf1_pin: GPIO4 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 5 - cf_pin: 4 - cf1_pin: 3 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/test.esp32-idf.yaml b/tests/components/total_daily_energy/test.esp32-idf.yaml index 34d452aae5..8b42b21b54 100644 --- a/tests/components/total_daily_energy/test.esp32-idf.yaml +++ b/tests/components/total_daily_energy/test.esp32-idf.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO12 + cf_pin: GPIO13 + cf1_pin: GPIO14 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 15 - cf_pin: 14 - cf1_pin: 13 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/test.esp8266-ard.yaml b/tests/components/total_daily_energy/test.esp8266-ard.yaml index 34d452aae5..8b42b21b54 100644 --- a/tests/components/total_daily_energy/test.esp8266-ard.yaml +++ b/tests/components/total_daily_energy/test.esp8266-ard.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO12 + cf_pin: GPIO13 + cf1_pin: GPIO14 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 15 - cf_pin: 14 - cf1_pin: 13 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/total_daily_energy/test.rp2040-ard.yaml b/tests/components/total_daily_energy/test.rp2040-ard.yaml index 71afa45ed5..8b0d069ce2 100644 --- a/tests/components/total_daily_energy/test.rp2040-ard.yaml +++ b/tests/components/total_daily_energy/test.rp2040-ard.yaml @@ -1,32 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + sel_pin: GPIO2 + cf_pin: GPIO3 + cf1_pin: GPIO4 -time: - - platform: sntp - id: sntp_time - -sensor: - - platform: hlw8012 - sel_pin: 5 - cf_pin: 4 - cf1_pin: 3 - current: - name: HLW8012 Current - voltage: - name: HLW8012 Voltage - power: - name: HLW8012 Power - id: hlw8012_power - energy: - name: HLW8012 Energy - id: hlw8012_energy - update_interval: 15s - current_resistor: 0.001 ohm - voltage_divider: 2351 - change_mode_every: "never" - initial_mode: VOLTAGE - model: hlw8012 - - platform: total_daily_energy - name: HLW8012 Total Daily Energy - power_id: hlw8012_power +<<: !include common.yaml diff --git a/tests/components/tsl2561/common.yaml b/tests/components/tsl2561/common.yaml new file mode 100644 index 0000000000..d2b4f75df3 --- /dev/null +++ b/tests/components/tsl2561/common.yaml @@ -0,0 +1,13 @@ +i2c: + - id: i2c_tsl2561 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tsl2561 + name: TSL2561 Ambient Light + address: 0x39 + is_cs_package: true + integration_time: 402ms + gain: 16x + update_interval: 15s diff --git a/tests/components/tsl2561/test.esp32-ard.yaml b/tests/components/tsl2561/test.esp32-ard.yaml index 8d43c62414..63c3bd6afd 100644 --- a/tests/components/tsl2561/test.esp32-ard.yaml +++ b/tests/components/tsl2561/test.esp32-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2561/test.esp32-c3-ard.yaml b/tests/components/tsl2561/test.esp32-c3-ard.yaml index 1ea768c5d9..ee2c29ca4e 100644 --- a/tests/components/tsl2561/test.esp32-c3-ard.yaml +++ b/tests/components/tsl2561/test.esp32-c3-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2561/test.esp32-c3-idf.yaml b/tests/components/tsl2561/test.esp32-c3-idf.yaml index 1ea768c5d9..ee2c29ca4e 100644 --- a/tests/components/tsl2561/test.esp32-c3-idf.yaml +++ b/tests/components/tsl2561/test.esp32-c3-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2561/test.esp32-idf.yaml b/tests/components/tsl2561/test.esp32-idf.yaml index 8d43c62414..63c3bd6afd 100644 --- a/tests/components/tsl2561/test.esp32-idf.yaml +++ b/tests/components/tsl2561/test.esp32-idf.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2561/test.esp8266-ard.yaml b/tests/components/tsl2561/test.esp8266-ard.yaml index 1ea768c5d9..ee2c29ca4e 100644 --- a/tests/components/tsl2561/test.esp8266-ard.yaml +++ b/tests/components/tsl2561/test.esp8266-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2561/test.rp2040-ard.yaml b/tests/components/tsl2561/test.rp2040-ard.yaml index 1ea768c5d9..ee2c29ca4e 100644 --- a/tests/components/tsl2561/test.rp2040-ard.yaml +++ b/tests/components/tsl2561/test.rp2040-ard.yaml @@ -1,13 +1,5 @@ -i2c: - - id: i2c_tsl2561 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2561 - name: TSL2561 Ambient Light - address: 0x39 - is_cs_package: true - integration_time: 402ms - gain: 16x - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/common.yaml b/tests/components/tsl2591/common.yaml new file mode 100644 index 0000000000..d58c46fb48 --- /dev/null +++ b/tests/components/tsl2591/common.yaml @@ -0,0 +1,25 @@ +i2c: + - id: i2c_tsl2591 + scl: ${scl_pin} + sda: ${sda_pin} + +sensor: + - platform: tsl2591 + id: test_tsl2591 + address: 0x29 + integration_time: 600ms + gain: high + visible: + name: tsl2591 visible + id: tsl2591_vis + unit_of_measurement: pH + infrared: + name: tsl2591 infrared + id: tsl2591_ir + full_spectrum: + name: tsl2591 full_spectrum + id: tsl2591_fs + calculated_lux: + name: tsl2591 calculated_lux + id: tsl2591_cl + update_interval: 15s diff --git a/tests/components/tsl2591/test.esp32-ard.yaml b/tests/components/tsl2591/test.esp32-ard.yaml index 14f9311ae6..63c3bd6afd 100644 --- a/tests/components/tsl2591/test.esp32-ard.yaml +++ b/tests/components/tsl2591/test.esp32-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/test.esp32-c3-ard.yaml b/tests/components/tsl2591/test.esp32-c3-ard.yaml index de57ef548a..ee2c29ca4e 100644 --- a/tests/components/tsl2591/test.esp32-c3-ard.yaml +++ b/tests/components/tsl2591/test.esp32-c3-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/test.esp32-c3-idf.yaml b/tests/components/tsl2591/test.esp32-c3-idf.yaml index de57ef548a..ee2c29ca4e 100644 --- a/tests/components/tsl2591/test.esp32-c3-idf.yaml +++ b/tests/components/tsl2591/test.esp32-c3-idf.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/test.esp32-idf.yaml b/tests/components/tsl2591/test.esp32-idf.yaml index 14f9311ae6..63c3bd6afd 100644 --- a/tests/components/tsl2591/test.esp32-idf.yaml +++ b/tests/components/tsl2591/test.esp32-idf.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/test.esp8266-ard.yaml b/tests/components/tsl2591/test.esp8266-ard.yaml index de57ef548a..ee2c29ca4e 100644 --- a/tests/components/tsl2591/test.esp8266-ard.yaml +++ b/tests/components/tsl2591/test.esp8266-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tsl2591/test.rp2040-ard.yaml b/tests/components/tsl2591/test.rp2040-ard.yaml index de57ef548a..ee2c29ca4e 100644 --- a/tests/components/tsl2591/test.rp2040-ard.yaml +++ b/tests/components/tsl2591/test.rp2040-ard.yaml @@ -1,25 +1,5 @@ -i2c: - - id: i2c_tsl2591 - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -sensor: - - platform: tsl2591 - id: test_tsl2591 - address: 0x29 - integration_time: 600ms - gain: high - visible: - name: tsl2591 visible - id: tsl2591_vis - unit_of_measurement: pH - infrared: - name: tsl2591 infrared - id: tsl2591_ir - full_spectrum: - name: tsl2591 full_spectrum - id: tsl2591_fs - calculated_lux: - name: tsl2591 calculated_lux - id: tsl2591_cl - update_interval: 15s +<<: !include common.yaml diff --git a/tests/components/tt21100/common.yaml b/tests/components/tt21100/common.yaml new file mode 100644 index 0000000000..a5d7970429 --- /dev/null +++ b/tests/components/tt21100/common.yaml @@ -0,0 +1,25 @@ +i2c: + - id: i2c_tt21100 + scl: ${scl_pin} + sda: ${sda_pin} + +display: + - platform: ssd1306_i2c + id: ssd1306_display + model: SSD1306_128X64 + reset_pin: ${disp_reset_pin} + pages: + - id: page1 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + +touchscreen: + - platform: tt21100 + display: ssd1306_display + interrupt_pin: ${interrupt_pin} + reset_pin: ${reset_pin} + +binary_sensor: + - platform: tt21100 + name: Home Button + index: 1 diff --git a/tests/components/tt21100/test.esp32-ard.yaml b/tests/components/tt21100/test.esp32-ard.yaml index 2419b0ad6a..05598719f9 100644 --- a/tests/components/tt21100/test.esp32-ard.yaml +++ b/tests/components/tt21100/test.esp32-ard.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 16 - sda: 17 +substitutions: + disp_reset_pin: GPIO12 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 14 - reset_pin: 15 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/tt21100/test.esp32-c3-ard.yaml b/tests/components/tt21100/test.esp32-c3-ard.yaml index 17b8c8065a..36a8ce2778 100644 --- a/tests/components/tt21100/test.esp32-c3-ard.yaml +++ b/tests/components/tt21100/test.esp32-c3-ard.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 5 - sda: 4 +substitutions: + disp_reset_pin: GPIO10 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 6 - reset_pin: 7 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/tt21100/test.esp32-c3-idf.yaml b/tests/components/tt21100/test.esp32-c3-idf.yaml index 17b8c8065a..36a8ce2778 100644 --- a/tests/components/tt21100/test.esp32-c3-idf.yaml +++ b/tests/components/tt21100/test.esp32-c3-idf.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 5 - sda: 4 +substitutions: + disp_reset_pin: GPIO10 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 6 - reset_pin: 7 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/tt21100/test.esp32-idf.yaml b/tests/components/tt21100/test.esp32-idf.yaml index 2419b0ad6a..05598719f9 100644 --- a/tests/components/tt21100/test.esp32-idf.yaml +++ b/tests/components/tt21100/test.esp32-idf.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 16 - sda: 17 +substitutions: + disp_reset_pin: GPIO12 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 14 - reset_pin: 15 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/tt21100/test.esp32-s2-ard.yaml b/tests/components/tt21100/test.esp32-s2-ard.yaml deleted file mode 100644 index 86b9e7530d..0000000000 --- a/tests/components/tt21100/test.esp32-s2-ard.yaml +++ /dev/null @@ -1,44 +0,0 @@ -i2c: - sda: GPIO8 - scl: GPIO18 - -spi: - clk_pin: 7 - mosi_pin: 11 - miso_pin: 9 - -display: - - platform: ili9xxx - id: my_display - model: ili9341 - cs_pin: 5 - dc_pin: 12 - reset_pin: 33 - auto_clear_enabled: false - data_rate: 40MHz - dimensions: 320x240 - update_interval: never - invert_colors: false - transform: - mirror_y: false - mirror_x: false - swap_xy: true - -touchscreen: - - platform: tt21100 - address: 0x24 - interrupt_pin: GPIO3 - on_touch: - - logger.log: "Touchscreen:: Touched" - -binary_sensor: - - platform: tt21100 - index: 0 - name: "Home" - - - platform: touchscreen - name: FanLo - x_min: 0 - x_max: 105 - y_min: 0 - y_max: 80 diff --git a/tests/components/tt21100/test.esp8266-ard.yaml b/tests/components/tt21100/test.esp8266-ard.yaml index 1393019417..05598719f9 100644 --- a/tests/components/tt21100/test.esp8266-ard.yaml +++ b/tests/components/tt21100/test.esp8266-ard.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 5 - sda: 4 +substitutions: + disp_reset_pin: GPIO12 + scl_pin: GPIO13 + sda_pin: GPIO14 + interrupt_pin: GPIO15 + reset_pin: GPIO16 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 13 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 14 - reset_pin: 15 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/tt21100/test.rp2040-ard.yaml b/tests/components/tt21100/test.rp2040-ard.yaml index 17b8c8065a..36a8ce2778 100644 --- a/tests/components/tt21100/test.rp2040-ard.yaml +++ b/tests/components/tt21100/test.rp2040-ard.yaml @@ -1,25 +1,8 @@ -i2c: - - id: i2c_tt21100 - scl: 5 - sda: 4 +substitutions: + disp_reset_pin: GPIO10 + scl_pin: GPIO0 + sda_pin: GPIO1 + interrupt_pin: GPIO2 + reset_pin: GPIO3 -display: - - platform: ssd1306_i2c - id: ssd1306_display - model: SSD1306_128X64 - reset_pin: 3 - pages: - - id: page1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - -touchscreen: - - platform: tt21100 - display: ssd1306_display - interrupt_pin: 6 - reset_pin: 7 - -binary_sensor: - - platform: tt21100 - name: Home Button - index: 1 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/common.yaml b/tests/components/ttp229_bsf/common.yaml new file mode 100644 index 0000000000..42c26a5d51 --- /dev/null +++ b/tests/components/ttp229_bsf/common.yaml @@ -0,0 +1,8 @@ +ttp229_bsf: + scl_pin: ${scl_pin} + sdo_pin: ${sdo_pin} + +binary_sensor: + - platform: ttp229_bsf + name: TTP229 Channel 0 + channel: 0 diff --git a/tests/components/ttp229_bsf/test.esp32-ard.yaml b/tests/components/ttp229_bsf/test.esp32-ard.yaml index edee6d164e..80ed75293f 100644 --- a/tests/components/ttp229_bsf/test.esp32-ard.yaml +++ b/tests/components/ttp229_bsf/test.esp32-ard.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 16 - sdo_pin: 17 +substitutions: + scl_pin: GPIO16 + sdo_pin: GPIO17 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/test.esp32-c3-ard.yaml b/tests/components/ttp229_bsf/test.esp32-c3-ard.yaml index 2006061c6e..135b213edc 100644 --- a/tests/components/ttp229_bsf/test.esp32-c3-ard.yaml +++ b/tests/components/ttp229_bsf/test.esp32-c3-ard.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 5 - sdo_pin: 4 +substitutions: + scl_pin: GPIO5 + sdo_pin: GPIO4 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/test.esp32-c3-idf.yaml b/tests/components/ttp229_bsf/test.esp32-c3-idf.yaml index 2006061c6e..135b213edc 100644 --- a/tests/components/ttp229_bsf/test.esp32-c3-idf.yaml +++ b/tests/components/ttp229_bsf/test.esp32-c3-idf.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 5 - sdo_pin: 4 +substitutions: + scl_pin: GPIO5 + sdo_pin: GPIO4 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/test.esp32-idf.yaml b/tests/components/ttp229_bsf/test.esp32-idf.yaml index edee6d164e..80ed75293f 100644 --- a/tests/components/ttp229_bsf/test.esp32-idf.yaml +++ b/tests/components/ttp229_bsf/test.esp32-idf.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 16 - sdo_pin: 17 +substitutions: + scl_pin: GPIO16 + sdo_pin: GPIO17 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/test.esp8266-ard.yaml b/tests/components/ttp229_bsf/test.esp8266-ard.yaml index 2006061c6e..135b213edc 100644 --- a/tests/components/ttp229_bsf/test.esp8266-ard.yaml +++ b/tests/components/ttp229_bsf/test.esp8266-ard.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 5 - sdo_pin: 4 +substitutions: + scl_pin: GPIO5 + sdo_pin: GPIO4 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_bsf/test.rp2040-ard.yaml b/tests/components/ttp229_bsf/test.rp2040-ard.yaml index 2006061c6e..135b213edc 100644 --- a/tests/components/ttp229_bsf/test.rp2040-ard.yaml +++ b/tests/components/ttp229_bsf/test.rp2040-ard.yaml @@ -1,8 +1,5 @@ -ttp229_bsf: - scl_pin: 5 - sdo_pin: 4 +substitutions: + scl_pin: GPIO5 + sdo_pin: GPIO4 -binary_sensor: - - platform: ttp229_bsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/common.yaml b/tests/components/ttp229_lsf/common.yaml new file mode 100644 index 0000000000..5c0dbf9517 --- /dev/null +++ b/tests/components/ttp229_lsf/common.yaml @@ -0,0 +1,11 @@ +i2c: + - id: i2c_ttp229_lsf + scl: ${scl_pin} + sda: ${sda_pin} + +ttp229_lsf: + +binary_sensor: + - platform: ttp229_lsf + name: TTP229 Channel 0 + channel: 0 diff --git a/tests/components/ttp229_lsf/test.esp32-ard.yaml b/tests/components/ttp229_lsf/test.esp32-ard.yaml index 81fb965883..63c3bd6afd 100644 --- a/tests/components/ttp229_lsf/test.esp32-ard.yaml +++ b/tests/components/ttp229_lsf/test.esp32-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/test.esp32-c3-ard.yaml b/tests/components/ttp229_lsf/test.esp32-c3-ard.yaml index 3927aff40e..ee2c29ca4e 100644 --- a/tests/components/ttp229_lsf/test.esp32-c3-ard.yaml +++ b/tests/components/ttp229_lsf/test.esp32-c3-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/test.esp32-c3-idf.yaml b/tests/components/ttp229_lsf/test.esp32-c3-idf.yaml index 3927aff40e..ee2c29ca4e 100644 --- a/tests/components/ttp229_lsf/test.esp32-c3-idf.yaml +++ b/tests/components/ttp229_lsf/test.esp32-c3-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/test.esp32-idf.yaml b/tests/components/ttp229_lsf/test.esp32-idf.yaml index 81fb965883..63c3bd6afd 100644 --- a/tests/components/ttp229_lsf/test.esp32-idf.yaml +++ b/tests/components/ttp229_lsf/test.esp32-idf.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 16 - sda: 17 +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/test.esp8266-ard.yaml b/tests/components/ttp229_lsf/test.esp8266-ard.yaml index 3927aff40e..ee2c29ca4e 100644 --- a/tests/components/ttp229_lsf/test.esp8266-ard.yaml +++ b/tests/components/ttp229_lsf/test.esp8266-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/ttp229_lsf/test.rp2040-ard.yaml b/tests/components/ttp229_lsf/test.rp2040-ard.yaml index 3927aff40e..ee2c29ca4e 100644 --- a/tests/components/ttp229_lsf/test.rp2040-ard.yaml +++ b/tests/components/ttp229_lsf/test.rp2040-ard.yaml @@ -1,11 +1,5 @@ -i2c: - - id: i2c_ttp229_lsf - scl: 5 - sda: 4 +substitutions: + scl_pin: GPIO5 + sda_pin: GPIO4 -ttp229_lsf: - -binary_sensor: - - platform: ttp229_lsf - name: TTP229 Channel 0 - channel: 0 +<<: !include common.yaml diff --git a/tests/components/tuya/common.yaml b/tests/components/tuya/common.yaml new file mode 100644 index 0000000000..fcf8a2d96b --- /dev/null +++ b/tests/components/tuya/common.yaml @@ -0,0 +1,78 @@ +wifi: + ssid: MySSID + password: password1 + +uart: + - id: uart_tuya + tx_pin: ${tx_pin} + rx_pin: ${rx_pin} + baud_rate: 9600 + +tuya: + status_pin: + number: ${status_pin} + inverted: true + on_datapoint_update: + - sensor_datapoint: 6 + datapoint_type: raw + then: + - logger.log: Datapoint 6 updated + +binary_sensor: + - platform: tuya + id: tuya_binary_sensor + sensor_datapoint: 1 + +climate: + - platform: tuya + id: tuya_climate + switch_datapoint: 1 + target_temperature_datapoint: 3 + current_temperature_multiplier: 0.5 + target_temperature_multiplier: 0.5 + reports_fahrenheit: true + +cover: + - platform: tuya + id: tuya_cover + position_datapoint: 2 + +light: + - platform: tuya + id: tuya_light + switch_datapoint: 1 + dimmer_datapoint: 2 + min_value_datapoint: 3 + color_temperature_datapoint: 4 + min_value: 1 + max_value: 100 + cold_white_color_temperature: 153 mireds + warm_white_color_temperature: 500 mireds + gamma_correct: 1 + +number: + - platform: tuya + id: tuya_number + number_datapoint: 102 + min_value: 0 + max_value: 17 + step: 1 + +select: + - platform: tuya + id: tuya_select + enum_datapoint: 42 + options: + 0: Internal + 1: Floor + 2: Both + +sensor: + - platform: tuya + id: tuya_sensor + sensor_datapoint: 1 + +switch: + - platform: tuya + id: tuya_switch + switch_datapoint: 1 diff --git a/tests/components/tuya/test.esp32-ard.yaml b/tests/components/tuya/test.esp32-ard.yaml index 9105522dcd..926a46cf73 100644 --- a/tests/components/tuya/test.esp32-ard.yaml +++ b/tests/components/tuya/test.esp32-ard.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 + status_pin: GPIO12 -uart: - - id: uart_tuya - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -tuya: - status_pin: - number: 15 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml diff --git a/tests/components/tuya/test.esp32-c3-ard.yaml b/tests/components/tuya/test.esp32-c3-ard.yaml index 4892e807b1..c62a0b10f6 100644 --- a/tests/components/tuya/test.esp32-c3-ard.yaml +++ b/tests/components/tuya/test.esp32-c3-ard.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + status_pin: GPIO2 -uart: - - id: uart_tuya - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -tuya: - status_pin: - number: 6 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml diff --git a/tests/components/tuya/test.esp32-c3-idf.yaml b/tests/components/tuya/test.esp32-c3-idf.yaml index 4892e807b1..c62a0b10f6 100644 --- a/tests/components/tuya/test.esp32-c3-idf.yaml +++ b/tests/components/tuya/test.esp32-c3-idf.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + status_pin: GPIO2 -uart: - - id: uart_tuya - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -tuya: - status_pin: - number: 6 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml diff --git a/tests/components/tuya/test.esp32-idf.yaml b/tests/components/tuya/test.esp32-idf.yaml index 9105522dcd..926a46cf73 100644 --- a/tests/components/tuya/test.esp32-idf.yaml +++ b/tests/components/tuya/test.esp32-idf.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO17 + rx_pin: GPIO16 + status_pin: GPIO12 -uart: - - id: uart_tuya - tx_pin: 17 - rx_pin: 16 - baud_rate: 9600 - -tuya: - status_pin: - number: 15 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml diff --git a/tests/components/tuya/test.esp8266-ard.yaml b/tests/components/tuya/test.esp8266-ard.yaml index 56177fb982..11d46ed50e 100644 --- a/tests/components/tuya/test.esp8266-ard.yaml +++ b/tests/components/tuya/test.esp8266-ard.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + status_pin: GPIO12 -uart: - - id: uart_tuya - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -tuya: - status_pin: - number: 16 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml diff --git a/tests/components/tuya/test.rp2040-ard.yaml b/tests/components/tuya/test.rp2040-ard.yaml index 4892e807b1..11d46ed50e 100644 --- a/tests/components/tuya/test.rp2040-ard.yaml +++ b/tests/components/tuya/test.rp2040-ard.yaml @@ -1,78 +1,6 @@ -wifi: - ssid: MySSID - password: password1 +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + status_pin: GPIO12 -uart: - - id: uart_tuya - tx_pin: 4 - rx_pin: 5 - baud_rate: 9600 - -tuya: - status_pin: - number: 6 - inverted: true - on_datapoint_update: - - sensor_datapoint: 6 - datapoint_type: raw - then: - - logger.log: Datapoint 6 updated - -binary_sensor: - - platform: tuya - id: tuya_binary_sensor - sensor_datapoint: 1 - -climate: - - platform: tuya - id: tuya_climate - switch_datapoint: 1 - target_temperature_datapoint: 3 - current_temperature_multiplier: 0.5 - target_temperature_multiplier: 0.5 - reports_fahrenheit: true - -cover: - - platform: tuya - id: tuya_cover - position_datapoint: 2 - -light: - - platform: tuya - id: tuya_light - switch_datapoint: 1 - dimmer_datapoint: 2 - min_value_datapoint: 3 - color_temperature_datapoint: 4 - min_value: 1 - max_value: 100 - cold_white_color_temperature: 153 mireds - warm_white_color_temperature: 500 mireds - gamma_correct: 1 - -number: - - platform: tuya - id: tuya_number - number_datapoint: 102 - min_value: 0 - max_value: 17 - step: 1 - -select: - - platform: tuya - id: tuya_select - enum_datapoint: 42 - options: - 0: Internal - 1: Floor - 2: Both - -sensor: - - platform: tuya - id: tuya_sensor - sensor_datapoint: 1 - -switch: - - platform: tuya - id: tuya_switch - switch_datapoint: 1 +<<: !include common.yaml From 0cd3af2fcd475d4e724669de10b2ec0710ca60ab Mon Sep 17 00:00:00 2001 From: guillempages Date: Mon, 10 Feb 2025 01:17:29 +0100 Subject: [PATCH 05/79] [online_image]Pin specific version of JPEG library (#8217) --- esphome/components/online_image/__init__.py | 2 +- platformio.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/online_image/__init__.py b/esphome/components/online_image/__init__.py index c476270571..6b69bc240b 100644 --- a/esphome/components/online_image/__init__.py +++ b/esphome/components/online_image/__init__.py @@ -66,7 +66,7 @@ class JPEGFormat(Format): def actions(self): cg.add_define("USE_ONLINE_IMAGE_JPEG_SUPPORT") - cg.add_library("JPEGDEC", "1.6.2", "https://github.com/bitbank2/JPEGDEC") + cg.add_library("JPEGDEC", None, "https://github.com/bitbank2/JPEGDEC#ca1e0f2") class PNGFormat(Format): diff --git a/platformio.ini b/platformio.ini index cf11139b73..4153310480 100644 --- a/platformio.ini +++ b/platformio.ini @@ -42,7 +42,7 @@ lib_deps = pavlodn/HaierProtocol@0.9.31 ; haier kikuchan98/pngle@1.0.2 ; online_image ; Using the repository directly, otherwise ESP-IDF can't use the library - https://github.com/bitbank2/JPEGDEC.git#1.6.2 ; online_image + https://github.com/bitbank2/JPEGDEC.git#ca1e0f2 ; online_image ; This is using the repository until a new release is published to PlatformIO https://github.com/Sensirion/arduino-gas-index-algorithm.git#3.2.1 ; Sensirion Gas Index Algorithm Arduino Library lvgl/lvgl@8.4.0 ; lvgl From ff7d232ee6ed86b69e7abfa139a8d83af07c620b Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 10 Feb 2025 13:53:26 +1100 Subject: [PATCH 06/79] [logger] Add runtime level select (#8222) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- CODEOWNERS | 1 + esphome/components/logger/__init__.py | 48 ++++++++++++++++--- esphome/components/logger/logger.cpp | 27 ++++++----- esphome/components/logger/logger.h | 18 ++++--- esphome/components/logger/select/__init__.py | 29 +++++++++++ .../logger/select/logger_level_select.cpp | 27 +++++++++++ .../logger/select/logger_level_select.h | 15 ++++++ esphome/core/defines.h | 3 ++ .../logger/common-default_uart.yaml | 12 ++++- 9 files changed, 154 insertions(+), 26 deletions(-) create mode 100644 esphome/components/logger/select/__init__.py create mode 100644 esphome/components/logger/select/logger_level_select.cpp create mode 100644 esphome/components/logger/select/logger_level_select.h diff --git a/CODEOWNERS b/CODEOWNERS index eab02efffb..d4b3d7eff9 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -242,6 +242,7 @@ esphome/components/lightwaverf/* @max246 esphome/components/lilygo_t5_47/touchscreen/* @jesserockz esphome/components/lock/* @esphome/core esphome/components/logger/* @esphome/core +esphome/components/logger/select/* @clydebarrow esphome/components/ltr390/* @latonita @sjtrny esphome/components/ltr501/* @latonita esphome/components/ltr_als_ps/* @latonita diff --git a/esphome/components/logger/__init__.py b/esphome/components/logger/__init__.py index 6e92777058..a89bf95c77 100644 --- a/esphome/components/logger/__init__.py +++ b/esphome/components/logger/__init__.py @@ -35,7 +35,7 @@ from esphome.const import ( PLATFORM_RP2040, PLATFORM_RTL87XX, ) -from esphome.core import CORE, EsphomeError, Lambda, coroutine_with_priority +from esphome.core import CORE, Lambda, coroutine_with_priority CODEOWNERS = ["@esphome/core"] logger_ns = cg.esphome_ns.namespace("logger") @@ -77,6 +77,9 @@ USB_SERIAL_JTAG = "USB_SERIAL_JTAG" USB_CDC = "USB_CDC" DEFAULT = "DEFAULT" +CONF_INITIAL_LEVEL = "initial_level" +CONF_LOGGER_ID = "logger_id" + UART_SELECTION_ESP32 = { VARIANT_ESP32: [UART0, UART1, UART2], VARIANT_ESP32S2: [UART0, UART1, USB_CDC], @@ -154,11 +157,11 @@ def uart_selection(value): def validate_local_no_higher_than_global(value): - global_level = value.get(CONF_LEVEL, "DEBUG") + global_level = LOG_LEVEL_SEVERITY.index(value[CONF_LEVEL]) for tag, level in value.get(CONF_LOGS, {}).items(): - if LOG_LEVEL_SEVERITY.index(level) > LOG_LEVEL_SEVERITY.index(global_level): - raise EsphomeError( - f"The local log level {level} for {tag} must be less severe than the global log level {global_level}." + if LOG_LEVEL_SEVERITY.index(level) > global_level: + raise cv.Invalid( + f"The configured log level for {tag} ({level}) must be no more severe than the global log level {value[CONF_LEVEL]}." ) return value @@ -209,6 +212,7 @@ CONFIG_SCHEMA = cv.All( cv.string: is_log_level, } ), + cv.Optional(CONF_INITIAL_LEVEL): is_log_level, cv.Optional(CONF_ON_MESSAGE): automation.validate_automation( { cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(LoggerMessageTrigger), @@ -227,7 +231,14 @@ CONFIG_SCHEMA = cv.All( @coroutine_with_priority(90.0) async def to_code(config): baud_rate = config[CONF_BAUD_RATE] - log = cg.new_Pvariable(config[CONF_ID], baud_rate, config[CONF_TX_BUFFER_SIZE]) + level = config[CONF_LEVEL] + initial_level = LOG_LEVELS[config.get(CONF_INITIAL_LEVEL, level)] + log = cg.new_Pvariable( + config[CONF_ID], + baud_rate, + config[CONF_TX_BUFFER_SIZE], + ) + cg.add(log.set_log_level(initial_level)) if CONF_HARDWARE_UART in config: cg.add( log.set_uart_selection( @@ -239,7 +250,6 @@ async def to_code(config): for tag, level in config[CONF_LOGS].items(): cg.add(log.set_log_level(tag, LOG_LEVELS[level])) - level = config[CONF_LEVEL] cg.add_define("USE_LOGGER") this_severity = LOG_LEVEL_SEVERITY.index(level) cg.add_build_flag(f"-DESPHOME_LOG_LEVEL={LOG_LEVELS[level]}") @@ -367,3 +377,27 @@ async def logger_log_action_to_code(config, action_id, template_arg, args): lambda_ = await cg.process_lambda(Lambda(text), args, return_type=cg.void) return cg.new_Pvariable(action_id, template_arg, lambda_) + + +@automation.register_action( + "logger.set_level", + LambdaAction, + cv.maybe_simple_value( + { + cv.GenerateID(CONF_LOGGER_ID): cv.use_id(Logger), + cv.Required(CONF_LEVEL): is_log_level, + cv.Optional(CONF_TAG): cv.string, + }, + key=CONF_LEVEL, + ), +) +async def logger_set_level_to_code(config, action_id, template_arg, args): + level = LOG_LEVELS[config[CONF_LEVEL]] + logger = await cg.get_variable(config[CONF_LOGGER_ID]) + if tag := config.get(CONF_TAG): + text = str(cg.statement(logger.set_log_level(tag, level))) + else: + text = str(cg.statement(logger.set_log_level(level))) + + lambda_ = await cg.process_lambda(Lambda(text), args, return_type=cg.void) + return cg.new_Pvariable(action_id, template_arg, lambda_) diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index 36934c7459..79fc4cf499 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -105,12 +105,9 @@ int HOT Logger::level_for(const char *tag) { // Uses std::vector<> for low memory footprint, though the vector // could be sorted to minimize lookup times. This feature isn't used that // much anyway so it doesn't matter too much. - for (auto &it : this->log_levels_) { - if (it.tag == tag) { - return it.level; - } - } - return ESPHOME_LOG_LEVEL; + if (this->log_levels_.count(tag) != 0) + return this->log_levels_[tag]; + return this->current_level_; } void HOT Logger::log_message_(int level, const char *tag, int offset) { @@ -167,9 +164,7 @@ void Logger::loop() { #endif void Logger::set_baud_rate(uint32_t baud_rate) { this->baud_rate_ = baud_rate; } -void Logger::set_log_level(const std::string &tag, int log_level) { - this->log_levels_.push_back(LogLevelOverride{tag, log_level}); -} +void Logger::set_log_level(const std::string &tag, int log_level) { this->log_levels_[tag] = log_level; } #if defined(USE_ESP32) || defined(USE_ESP8266) || defined(USE_RP2040) || defined(USE_LIBRETINY) UARTSelection Logger::get_uart() const { return this->uart_; } @@ -183,18 +178,28 @@ const char *const LOG_LEVELS[] = {"NONE", "ERROR", "WARN", "INFO", "CONFIG", "DE void Logger::dump_config() { ESP_LOGCONFIG(TAG, "Logger:"); - ESP_LOGCONFIG(TAG, " Level: %s", LOG_LEVELS[ESPHOME_LOG_LEVEL]); + ESP_LOGCONFIG(TAG, " Max Level: %s", LOG_LEVELS[ESPHOME_LOG_LEVEL]); + ESP_LOGCONFIG(TAG, " Initial Level: %s", LOG_LEVELS[this->current_level_]); #ifndef USE_HOST ESP_LOGCONFIG(TAG, " Log Baud Rate: %" PRIu32, this->baud_rate_); ESP_LOGCONFIG(TAG, " Hardware UART: %s", get_uart_selection_()); #endif for (auto &it : this->log_levels_) { - ESP_LOGCONFIG(TAG, " Level for '%s': %s", it.tag.c_str(), LOG_LEVELS[it.level]); + ESP_LOGCONFIG(TAG, " Level for '%s': %s", it.first.c_str(), LOG_LEVELS[it.second]); } } void Logger::write_footer_() { this->write_to_buffer_(ESPHOME_LOG_RESET_COLOR, strlen(ESPHOME_LOG_RESET_COLOR)); } +void Logger::set_log_level(int level) { + if (level > ESPHOME_LOG_LEVEL) { + level = ESPHOME_LOG_LEVEL; + ESP_LOGW(TAG, "Cannot set log level higher than pre-compiled %s", LOG_LEVELS[ESPHOME_LOG_LEVEL]); + } + this->current_level_ = level; + this->level_callback_.call(level); +} + Logger *global_logger = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) } // namespace logger diff --git a/esphome/components/logger/logger.h b/esphome/components/logger/logger.h index b55cfb0771..c4c873e020 100644 --- a/esphome/components/logger/logger.h +++ b/esphome/components/logger/logger.h @@ -1,11 +1,12 @@ #pragma once #include -#include +#include #include "esphome/core/automation.h" #include "esphome/core/component.h" #include "esphome/core/defines.h" #include "esphome/core/helpers.h" +#include "esphome/core/log.h" #ifdef USE_ARDUINO #if defined(USE_ESP8266) || defined(USE_ESP32) @@ -74,8 +75,11 @@ class Logger : public Component { UARTSelection get_uart() const; #endif + /// Set the default log level for this logger. + void set_log_level(int level); /// Set the log level of the specified tag. void set_log_level(const std::string &tag, int log_level); + int get_log_level() { return this->current_level_; } // ========== INTERNAL METHODS ========== // (In most use cases you won't need these) @@ -88,6 +92,9 @@ class Logger : public Component { /// Register a callback that will be called for every log message sent void add_on_log_callback(std::function &&callback); + // add a listener for log level changes + void add_listener(std::function &&callback) { this->level_callback_.add(std::move(callback)); } + float get_setup_priority() const override; void log_vprintf_(int level, const char *tag, int line, const char *format, va_list args); // NOLINT @@ -159,17 +166,14 @@ class Logger : public Component { #ifdef USE_ESP_IDF uart_port_t uart_num_; #endif - struct LogLevelOverride { - std::string tag; - int level; - }; - std::vector log_levels_; + std::map log_levels_{}; CallbackManager log_callback_{}; + int current_level_{ESPHOME_LOG_LEVEL_VERY_VERBOSE}; /// Prevents recursive log calls, if true a log message is already being processed. bool recursion_guard_ = false; void *main_task_ = nullptr; + CallbackManager level_callback_{}; }; - extern Logger *global_logger; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) class LoggerMessageTrigger : public Trigger { diff --git a/esphome/components/logger/select/__init__.py b/esphome/components/logger/select/__init__.py new file mode 100644 index 0000000000..b1fc881537 --- /dev/null +++ b/esphome/components/logger/select/__init__.py @@ -0,0 +1,29 @@ +import esphome.codegen as cg +from esphome.components import select +import esphome.config_validation as cv +from esphome.const import CONF_LEVEL, CONF_LOGGER, ENTITY_CATEGORY_CONFIG, ICON_BUG +from esphome.core import CORE +from esphome.cpp_helpers import register_component, register_parented + +from .. import CONF_LOGGER_ID, LOG_LEVEL_SEVERITY, Logger, logger_ns + +CODEOWNERS = ["@clydebarrow"] + +LoggerLevelSelect = logger_ns.class_("LoggerLevelSelect", select.Select, cg.Component) + +CONFIG_SCHEMA = select.select_schema( + LoggerLevelSelect, icon=ICON_BUG, entity_category=ENTITY_CATEGORY_CONFIG +).extend( + { + cv.GenerateID(CONF_LOGGER_ID): cv.use_id(Logger), + } +) + + +async def to_code(config): + levels = LOG_LEVEL_SEVERITY + index = levels.index(CORE.config[CONF_LOGGER][CONF_LEVEL]) + levels = levels[: index + 1] + var = await select.new_select(config, options=levels) + await register_parented(var, config[CONF_LOGGER_ID]) + await register_component(var, config) diff --git a/esphome/components/logger/select/logger_level_select.cpp b/esphome/components/logger/select/logger_level_select.cpp new file mode 100644 index 0000000000..b71a6e02a2 --- /dev/null +++ b/esphome/components/logger/select/logger_level_select.cpp @@ -0,0 +1,27 @@ +#include "logger_level_select.h" + +namespace esphome { +namespace logger { + +void LoggerLevelSelect::publish_state(int level) { + auto value = this->at(level); + if (!value) { + return; + } + Select::publish_state(value.value()); +} + +void LoggerLevelSelect::setup() { + this->parent_->add_listener([this](int level) { this->publish_state(level); }); + this->publish_state(this->parent_->get_log_level()); +} + +void LoggerLevelSelect::control(const std::string &value) { + auto level = this->index_of(value); + if (!level) + return; + this->parent_->set_log_level(level.value()); +} + +} // namespace logger +} // namespace esphome diff --git a/esphome/components/logger/select/logger_level_select.h b/esphome/components/logger/select/logger_level_select.h new file mode 100644 index 0000000000..2c92c84d13 --- /dev/null +++ b/esphome/components/logger/select/logger_level_select.h @@ -0,0 +1,15 @@ +#pragma once + +#include "esphome/components/select/select.h" +#include "esphome/core/component.h" +#include "esphome/components/logger/logger.h" +namespace esphome { +namespace logger { +class LoggerLevelSelect : public Component, public select::Select, public Parented { + public: + void publish_state(int level); + void setup() override; + void control(const std::string &value) override; +}; +} // namespace logger +} // namespace esphome diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 8407391bce..dc0ac3c1e8 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -14,6 +14,9 @@ #define ESPHOME_PROJECT_VERSION_30 "v2" #define ESPHOME_VARIANT "ESP32" +// logger +#define ESPHOME_LOG_LEVEL ESPHOME_LOG_LEVEL_VERY_VERBOSE + // Feature flags #define USE_ALARM_CONTROL_PANEL #define USE_AUDIO_FLAC_SUPPORT diff --git a/tests/components/logger/common-default_uart.yaml b/tests/components/logger/common-default_uart.yaml index 70b485daac..e8b56043eb 100644 --- a/tests/components/logger/common-default_uart.yaml +++ b/tests/components/logger/common-default_uart.yaml @@ -1,7 +1,17 @@ esphome: on_boot: then: - - logger.log: Hello world + - logger.log: + level: warn + format: "Warning: Logger level is %d" + args: [id(logger_id).get_log_level()] + - logger.set_level: WARN logger: + id: logger_id level: DEBUG + initial_level: INFO + +select: + - platform: logger + name: Logger Level From 45b8810ab8a888a1cf43aae308770d159a87e25f Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Sun, 9 Feb 2025 21:55:16 -0500 Subject: [PATCH 07/79] [online_image] Set Accept header (#8216) --- .../components/online_image/online_image.cpp | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index b08c14b721..da0e88a904 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -100,7 +100,35 @@ void OnlineImage::update() { } ESP_LOGI(TAG, "Updating image %s", this->url_.c_str()); - this->downloader_ = this->parent_->get(this->url_); + std::list headers = {}; + + http_request::Header accept_header; + accept_header.name = "Accept"; + std::string accept_mime_type; + switch (this->format_) { +#ifdef USE_ONLINE_IMAGE_BMP_SUPPORT + case ImageFormat::BMP: + accept_mime_type = "image/bmp"; + break; +#endif // ONLINE_IMAGE_BMP_SUPPORT +#ifdef USE_ONLINE_IMAGE_JPEG_SUPPORT + case ImageFormat::JPEG: + accept_mime_type = "image/jpeg"; + break; +#endif // USE_ONLINE_IMAGE_JPEG_SUPPORT +#ifdef USE_ONLINE_IMAGE_PNG_SUPPORT + case ImageFormat::PNG: + accept_mime_type = "image/png"; + break; +#endif // ONLINE_IMAGE_PNG_SUPPORT + default: + accept_mime_type = "image/*"; + } + accept_header.value = (accept_mime_type + ",*/*;q=0.8").c_str(); + + headers.push_back(accept_header); + + this->downloader_ = this->parent_->get(this->url_, headers); if (this->downloader_ == nullptr) { ESP_LOGE(TAG, "Download failed."); From 66c35a943244c3b279dc79741cb4e47422f39f84 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 10 Feb 2025 14:46:05 +1100 Subject: [PATCH 08/79] [waveshare_epaper] Rationalise and complete tests (#8221) --- .../components/waveshare_epaper/display.py | 4 +- tests/components/waveshare_epaper/common.yaml | 765 ++++++++++++++++-- .../waveshare_epaper/test.esp32-ard.yaml | 12 +- .../waveshare_epaper/test.esp32-c3-ard.yaml | 8 +- .../waveshare_epaper/test.esp32-c3-idf.yaml | 8 +- .../waveshare_epaper/test.esp32-idf.yaml | 8 +- .../waveshare_epaper/test.esp8266-ard.yaml | 8 +- .../waveshare_epaper/test.rp2040-ard.yaml | 6 +- 8 files changed, 709 insertions(+), 110 deletions(-) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index d5240b2674..3a5151682f 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -120,7 +120,7 @@ MODELS = { "2.13in-ttgo-b74": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B74), "2.90in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN), "2.90inv2": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN_V2), - "gdew029t5": ("c", GDEW029T5), + "gdew029t5": ("b", GDEW029T5), "2.70in": ("b", WaveshareEPaper2P7In), "2.70in-b": ("b", WaveshareEPaper2P7InB), "2.70in-bv2": ("b", WaveshareEPaper2P7InBV2), @@ -143,7 +143,7 @@ MODELS = { "7.50in-hd-b": ("b", WaveshareEPaper7P5InHDB), "2.13in-ttgo-dke": ("c", WaveshareEPaper2P13InDKE), "2.13inv3": ("c", WaveshareEPaper2P13InV3), - "1.54in-m5coreink-m09": ("c", GDEW0154M09), + "1.54in-m5coreink-m09": ("b", GDEW0154M09), "13.3in-k": ("b", WaveshareEPaper13P3InK), } diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index 92c443908e..ff9ddb955f 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -4,8 +4,150 @@ spi: mosi_pin: ${mosi_pin} display: + # 1.54 inch displays - platform: waveshare_epaper + id: epd_1_54 + model: 1.54in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_1_54v2 + model: 1.54inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_1_54v2b + model: 1.54inv2-b + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_1_54m09 + model: 1.54in-m5coreink-m09 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 2.13 inch displays + - platform: waveshare_epaper + id: epd_2_13 + model: 2.13in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_13v2 + model: 2.13inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_13ttgo + model: 2.13in-ttgo + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_13ttgo_b1 model: 2.13in-ttgo-b1 + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} @@ -21,8 +163,31 @@ display: full_update_every: 30 lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + id: epd_2_13ttgo_b73 + model: 2.13in-ttgo-b73 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_13ttgo_b74 model: 2.13in-ttgo-b74 + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} @@ -38,8 +203,129 @@ display: full_update_every: 30 lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + id: epd_2_13dke + model: 2.13in-ttgo-dke + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_13v3 + model: 2.13inv3 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 2.7 inch displays + - platform: waveshare_epaper + id: epd_2_70 + model: 2.70in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_70b + model: 2.70in-b + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_70bv2 + model: 2.70in-bv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_70v2 + model: 2.70inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 2.9 inch displays + - platform: waveshare_epaper + id: epd_2_90 model: 2.90in + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} @@ -56,8 +342,400 @@ display: reset_duration: 200ms lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_90v2 + model: 2.90inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + reset_duration: 200ms + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_90b + model: 2.90in-b + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_90bv3 + model: 2.90in-bv3 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_90v2r2 + model: 2.90inv2-r2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_2_90dke + model: 2.90in-dke + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + reset_duration: 200ms + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_gdew029t5 + model: gdew029t5 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 4.2 inch displays + - platform: waveshare_epaper + id: epd_4_20 + model: 4.20in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_4_20bv2 + model: 4.20in-bv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 5.83 inch displays + - platform: waveshare_epaper + id: epd_5_83 + model: 5.83in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_5_83v2 + model: 5.83inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 7.5 inch displays + - platform: waveshare_epaper + id: epd_7_50 + model: 7.50in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50bv2 + model: 7.50in-bv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50bv3 + model: 7.50in-bv3 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50bv3_bwr + model: 7.50in-bv3-bwr + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50bc + model: 7.50in-bc + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50v2 + model: 7.50inv2 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50v2alt + model: 7.50inv2alt + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + id: epd_7_50hdb + model: 7.50in-hd-b + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + # 13.3 inch displays + - platform: waveshare_epaper + id: epd_13_3k + model: 13.3in-k + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + + - platform: waveshare_epaper + model: 2.90in + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + reset_duration: 200ms + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper model: 2.90inv2 + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} @@ -73,25 +751,10 @@ display: full_update_every: 30 lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.90in-dke - cs_pin: - allow_other_uses: true - number: ${cs_pin} - dc_pin: - allow_other_uses: true - number: ${dc_pin} - busy_pin: - allow_other_uses: true - number: ${busy_pin} - reset_pin: - allow_other_uses: true - number: ${reset_pin} - full_update_every: 1 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper model: 2.70in-b + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} @@ -106,74 +769,10 @@ display: number: ${reset_pin} lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper model: 2.70in-bv2 - cs_pin: - allow_other_uses: true - number: ${cs_pin} - dc_pin: - allow_other_uses: true - number: ${dc_pin} - busy_pin: - allow_other_uses: true - number: ${busy_pin} - reset_pin: - allow_other_uses: true - number: ${reset_pin} - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 1.54in-m5coreink-m09 - cs_pin: - allow_other_uses: true - number: ${cs_pin} - dc_pin: - allow_other_uses: true - number: ${dc_pin} - busy_pin: - allow_other_uses: true - number: ${busy_pin} - reset_pin: - allow_other_uses: true - number: ${reset_pin} - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.13inv3 - cs_pin: - allow_other_uses: true - number: ${cs_pin} - dc_pin: - allow_other_uses: true - number: ${dc_pin} - busy_pin: - allow_other_uses: true - number: ${busy_pin} - reset_pin: - allow_other_uses: true - number: ${reset_pin} - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 2.13inv2 - cs_pin: - allow_other_uses: true - number: ${cs_pin} - dc_pin: - allow_other_uses: true - number: ${dc_pin} - busy_pin: - allow_other_uses: true - number: ${busy_pin} - reset_pin: - allow_other_uses: true - number: ${reset_pin} - full_update_every: 30 - lambda: |- - it.rectangle(0, 0, it.get_width(), it.get_height()); - - platform: waveshare_epaper - model: 7.50in-bv3-bwr + spi_id: spi_waveshare_epaper cs_pin: allow_other_uses: true number: ${cs_pin} diff --git a/tests/components/waveshare_epaper/test.esp32-ard.yaml b/tests/components/waveshare_epaper/test.esp32-ard.yaml index c658ea91ee..c36345b984 100644 --- a/tests/components/waveshare_epaper/test.esp32-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp32-ard.yaml @@ -1,9 +1,9 @@ substitutions: - clk_pin: GPIO16 - mosi_pin: GPIO17 - cs_pin: GPIO18 - dc_pin: GPIO19 - busy_pin: GPIO13 - reset_pin: GPIO14 + clk_pin: GPIO18 + mosi_pin: GPIO23 + cs_pin: GPIO25 + dc_pin: GPIO26 + busy_pin: GPIO27 + reset_pin: GPIO32 <<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml b/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml index e2873f0fe9..4cb230f6f2 100644 --- a/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp32-c3-ard.yaml @@ -1,9 +1,9 @@ substitutions: clk_pin: GPIO6 mosi_pin: GPIO7 - cs_pin: GPIO0 - dc_pin: GPIO5 - busy_pin: GPIO3 - reset_pin: GPIO4 + cs_pin: GPIO4 + dc_pin: GPIO1 + busy_pin: GPIO2 + reset_pin: GPIO3 <<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml b/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml index e2873f0fe9..4cb230f6f2 100644 --- a/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml +++ b/tests/components/waveshare_epaper/test.esp32-c3-idf.yaml @@ -1,9 +1,9 @@ substitutions: clk_pin: GPIO6 mosi_pin: GPIO7 - cs_pin: GPIO0 - dc_pin: GPIO5 - busy_pin: GPIO3 - reset_pin: GPIO4 + cs_pin: GPIO4 + dc_pin: GPIO1 + busy_pin: GPIO2 + reset_pin: GPIO3 <<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp32-idf.yaml b/tests/components/waveshare_epaper/test.esp32-idf.yaml index c658ea91ee..9e8b2fdec8 100644 --- a/tests/components/waveshare_epaper/test.esp32-idf.yaml +++ b/tests/components/waveshare_epaper/test.esp32-idf.yaml @@ -1,9 +1,9 @@ substitutions: clk_pin: GPIO16 mosi_pin: GPIO17 - cs_pin: GPIO18 - dc_pin: GPIO19 - busy_pin: GPIO13 - reset_pin: GPIO14 + cs_pin: GPIO4 + dc_pin: GPIO5 + busy_pin: GPIO18 + reset_pin: GPIO19 <<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.esp8266-ard.yaml b/tests/components/waveshare_epaper/test.esp8266-ard.yaml index bc178b7009..ee8199bcc0 100644 --- a/tests/components/waveshare_epaper/test.esp8266-ard.yaml +++ b/tests/components/waveshare_epaper/test.esp8266-ard.yaml @@ -1,9 +1,9 @@ substitutions: clk_pin: GPIO14 mosi_pin: GPIO13 - cs_pin: GPIO15 - dc_pin: GPIO12 - busy_pin: GPIO5 - reset_pin: GPIO4 + cs_pin: GPIO4 + dc_pin: GPIO5 + busy_pin: GPIO15 + reset_pin: GPIO16 <<: !include common.yaml diff --git a/tests/components/waveshare_epaper/test.rp2040-ard.yaml b/tests/components/waveshare_epaper/test.rp2040-ard.yaml index 801b0b51c5..e92f6d421d 100644 --- a/tests/components/waveshare_epaper/test.rp2040-ard.yaml +++ b/tests/components/waveshare_epaper/test.rp2040-ard.yaml @@ -2,8 +2,8 @@ substitutions: clk_pin: GPIO2 mosi_pin: GPIO3 cs_pin: GPIO5 - dc_pin: GPIO4 - busy_pin: GPIO0 - reset_pin: GPIO1 + dc_pin: GPIO6 + busy_pin: GPIO7 + reset_pin: GPIO8 <<: !include common.yaml From fd24b1423c5957ee4c648904aa2d1a87467c1b27 Mon Sep 17 00:00:00 2001 From: Awesome Walrus <74941879+QRPp@users.noreply.github.com> Date: Mon, 10 Feb 2025 03:54:37 +0000 Subject: [PATCH 09/79] Fix pref conflict of WiFi creds and fast_connect (#8219) --- esphome/components/wifi/wifi_component.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index eef962b8c4..4a50553305 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -66,7 +66,7 @@ void WiFiComponent::start() { this->pref_ = global_preferences->make_preference(hash, true); if (this->fast_connect_) { - this->fast_connect_pref_ = global_preferences->make_preference(hash, false); + this->fast_connect_pref_ = global_preferences->make_preference(hash + 1, false); } SavedWifiSettings save{}; From 0d13e2040dbf0e488544fd357e38f88129155b67 Mon Sep 17 00:00:00 2001 From: Stefan Rado <628587+kroimon@users.noreply.github.com> Date: Mon, 10 Feb 2025 05:12:46 +0100 Subject: [PATCH 10/79] Don't activate venv in devcontainer (#8128) --- .pre-commit-config.yaml | 2 +- script/{run-in-env => run-in-env.py} | 36 +++++++++++++++++----------- 2 files changed, 23 insertions(+), 15 deletions(-) rename script/{run-in-env => run-in-env.py} (63%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index adf0ac6fc2..212d822ff8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,6 +45,6 @@ repos: hooks: - id: pylint name: pylint - entry: python script/run-in-env pylint + entry: python3 script/run-in-env.py pylint language: system types: [python] diff --git a/script/run-in-env b/script/run-in-env.py similarity index 63% rename from script/run-in-env rename to script/run-in-env.py index 57bfddccf7..57121266be 100644 --- a/script/run-in-env +++ b/script/run-in-env.py @@ -7,6 +7,13 @@ import sys def find_and_activate_virtualenv(): + if ( + ("VIRTUAL_ENV" in os.environ) + or os.environ.get("DEVCONTAINER", False) + or os.environ.get("ESPHOME_NO_VENV", False) + ): + return + try: # Get the top-level directory of the git repository my_path = subprocess.check_output( @@ -17,7 +24,7 @@ def find_and_activate_virtualenv(): "Error: Not a git repository or unable to determine the top-level directory.", file=sys.stderr, ) - sys.exit(1) + return # Check for virtual environments for venv in ["venv", ".venv", "."]: @@ -29,25 +36,26 @@ def find_and_activate_virtualenv(): ) if activate_path.exists(): # Activate the virtual environment by updating PATH - env = os.environ.copy() venv_bin_dir = activate_path.parent - env["PATH"] = f"{venv_bin_dir}{os.pathsep}{env['PATH']}" - env["VIRTUAL_ENV"] = str(venv_bin_dir.parent) + os.environ["PATH"] = f"{venv_bin_dir}{os.pathsep}{os.environ['PATH']}" + os.environ["VIRTUAL_ENV"] = str(venv_bin_dir.parent) print(f"Activated virtual environment: {venv_bin_dir.parent}") - - # Execute the remaining arguments in the new environment - if len(sys.argv) > 1: - subprocess.run(sys.argv[1:], env=env, check=False) - else: - print( - "No command provided to run in the virtual environment.", - file=sys.stderr, - ) return print("No virtual environment found.", file=sys.stderr) - sys.exit(1) + + +def run_command(): + # Execute the remaining arguments in the new environment + if len(sys.argv) > 1: + subprocess.run(sys.argv[1:], check=False) + else: + print( + "No command provided to run in the virtual environment.", + file=sys.stderr, + ) if __name__ == "__main__": find_and_activate_virtualenv() + run_command() From 1ab1768b6a21b0dd270706288a418f68df1fdb8c Mon Sep 17 00:00:00 2001 From: Igor Novgorodov Date: Mon, 10 Feb 2025 05:32:54 +0100 Subject: [PATCH 11/79] Add ADC sampling method option (#8131) Co-authored-by: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> --- esphome/components/adc/__init__.py | 8 +++ esphome/components/adc/adc_sensor.h | 17 ++++++ esphome/components/adc/adc_sensor_common.cpp | 55 +++++++++++++++++++ esphome/components/adc/adc_sensor_esp32.cpp | 13 +++-- esphome/components/adc/adc_sensor_esp8266.cpp | 16 ++++-- .../components/adc/adc_sensor_libretiny.cpp | 17 ++++-- esphome/components/adc/adc_sensor_rp2040.cpp | 23 ++++---- esphome/components/adc/sensor.py | 12 +++- tests/component_tests/sensor/test_sensor.yaml | 1 + 9 files changed, 132 insertions(+), 30 deletions(-) diff --git a/esphome/components/adc/__init__.py b/esphome/components/adc/__init__.py index d8d21523b9..be420475fb 100644 --- a/esphome/components/adc/__init__.py +++ b/esphome/components/adc/__init__.py @@ -36,6 +36,14 @@ ATTENUATION_MODES = { "auto": "auto", } +sampling_mode = adc_ns.enum("SamplingMode", is_class=True) + +SAMPLING_MODES = { + "avg": sampling_mode.AVG, + "min": sampling_mode.MIN, + "max": sampling_mode.MAX, +} + adc1_channel_t = cg.global_ns.enum("adc1_channel_t") adc2_channel_t = cg.global_ns.enum("adc2_channel_t") diff --git a/esphome/components/adc/adc_sensor.h b/esphome/components/adc/adc_sensor.h index 7a3e1c8da7..62f2461245 100644 --- a/esphome/components/adc/adc_sensor.h +++ b/esphome/components/adc/adc_sensor.h @@ -28,6 +28,21 @@ static const adc_atten_t ADC_ATTEN_DB_12_COMPAT = ADC_ATTEN_DB_11; #endif #endif // USE_ESP32 +enum class SamplingMode : uint8_t { AVG = 0, MIN = 1, MAX = 2 }; +const LogString *sampling_mode_to_str(SamplingMode mode); + +class Aggregator { + public: + void add_sample(uint32_t value); + uint32_t aggregate(); + Aggregator(SamplingMode mode); + + protected: + SamplingMode mode_{SamplingMode::AVG}; + uint32_t aggr_{0}; + uint32_t samples_{0}; +}; + class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage_sampler::VoltageSampler { public: #ifdef USE_ESP32 @@ -54,6 +69,7 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage void set_pin(InternalGPIOPin *pin) { this->pin_ = pin; } void set_output_raw(bool output_raw) { this->output_raw_ = output_raw; } void set_sample_count(uint8_t sample_count); + void set_sampling_mode(SamplingMode sampling_mode); float sample() override; #ifdef USE_ESP8266 @@ -68,6 +84,7 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage InternalGPIOPin *pin_; bool output_raw_{false}; uint8_t sample_count_{1}; + SamplingMode sampling_mode_{SamplingMode::AVG}; #ifdef USE_RP2040 bool is_temperature_{false}; diff --git a/esphome/components/adc/adc_sensor_common.cpp b/esphome/components/adc/adc_sensor_common.cpp index 2dccd55fcd..c7509c7c7a 100644 --- a/esphome/components/adc/adc_sensor_common.cpp +++ b/esphome/components/adc/adc_sensor_common.cpp @@ -6,6 +6,59 @@ namespace adc { static const char *const TAG = "adc.common"; +const LogString *sampling_mode_to_str(SamplingMode mode) { + switch (mode) { + case SamplingMode::AVG: + return LOG_STR("average"); + case SamplingMode::MIN: + return LOG_STR("minimum"); + case SamplingMode::MAX: + return LOG_STR("maximum"); + } + return LOG_STR("unknown"); +} + +Aggregator::Aggregator(SamplingMode mode) { + this->mode_ = mode; + // set to max uint if mode is "min" + if (mode == SamplingMode::MIN) { + this->aggr_ = UINT32_MAX; + } +} + +void Aggregator::add_sample(uint32_t value) { + this->samples_ += 1; + + switch (this->mode_) { + case SamplingMode::AVG: + this->aggr_ += value; + break; + + case SamplingMode::MIN: + if (value < this->aggr_) { + this->aggr_ = value; + } + break; + + case SamplingMode::MAX: + if (value > this->aggr_) { + this->aggr_ = value; + } + } +} + +uint32_t Aggregator::aggregate() { + if (this->mode_ == SamplingMode::AVG) { + if (this->samples_ == 0) { + return this->aggr_; + } + + return (this->aggr_ + (this->samples_ >> 1)) / this->samples_; // NOLINT(clang-analyzer-core.DivideZero) + } + + return this->aggr_; +} + void ADCSensor::update() { float value_v = this->sample(); ESP_LOGV(TAG, "'%s': Got voltage=%.4fV", this->get_name().c_str(), value_v); @@ -18,6 +71,8 @@ void ADCSensor::set_sample_count(uint8_t sample_count) { } } +void ADCSensor::set_sampling_mode(SamplingMode sampling_mode) { this->sampling_mode_ = sampling_mode; } + float ADCSensor::get_setup_priority() const { return setup_priority::DATA; } } // namespace adc diff --git a/esphome/components/adc/adc_sensor_esp32.cpp b/esphome/components/adc/adc_sensor_esp32.cpp index 24e3750091..0f1d802937 100644 --- a/esphome/components/adc/adc_sensor_esp32.cpp +++ b/esphome/components/adc/adc_sensor_esp32.cpp @@ -78,12 +78,14 @@ void ADCSensor::dump_config() { } } ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_); + ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_))); LOG_UPDATE_INTERVAL(this); } float ADCSensor::sample() { if (!this->autorange_) { - uint32_t sum = 0; + auto aggr = Aggregator(this->sampling_mode_); + for (uint8_t sample = 0; sample < this->sample_count_; sample++) { int raw = -1; if (this->channel1_ != ADC1_CHANNEL_MAX) { @@ -94,13 +96,14 @@ float ADCSensor::sample() { if (raw == -1) { return NAN; } - sum += raw; + + aggr.add_sample(raw); } - sum = (sum + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) if (this->output_raw_) { - return sum; + return aggr.aggregate(); } - uint32_t mv = esp_adc_cal_raw_to_voltage(sum, &this->cal_characteristics_[(int32_t) this->attenuation_]); + uint32_t mv = + esp_adc_cal_raw_to_voltage(aggr.aggregate(), &this->cal_characteristics_[(int32_t) this->attenuation_]); return mv / 1000.0f; } diff --git a/esphome/components/adc/adc_sensor_esp8266.cpp b/esphome/components/adc/adc_sensor_esp8266.cpp index c9b6f8b652..9a12009abc 100644 --- a/esphome/components/adc/adc_sensor_esp8266.cpp +++ b/esphome/components/adc/adc_sensor_esp8266.cpp @@ -31,23 +31,27 @@ void ADCSensor::dump_config() { LOG_PIN(" Pin: ", this->pin_); #endif // USE_ADC_SENSOR_VCC ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_); + ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_))); LOG_UPDATE_INTERVAL(this); } float ADCSensor::sample() { - uint32_t raw = 0; + auto aggr = Aggregator(this->sampling_mode_); + for (uint8_t sample = 0; sample < this->sample_count_; sample++) { + uint32_t raw = 0; #ifdef USE_ADC_SENSOR_VCC - raw += ESP.getVcc(); // NOLINT(readability-static-accessed-through-instance) + raw = ESP.getVcc(); // NOLINT(readability-static-accessed-through-instance) #else - raw += analogRead(this->pin_->get_pin()); // NOLINT + raw = analogRead(this->pin_->get_pin()); // NOLINT #endif // USE_ADC_SENSOR_VCC + aggr.add_sample(raw); } - raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) + if (this->output_raw_) { - return raw; + return aggr.aggregate(); } - return raw / 1024.0f; + return aggr.aggregate() / 1024.0f; } std::string ADCSensor::unique_id() { return get_mac_address() + "-adc"; } diff --git a/esphome/components/adc/adc_sensor_libretiny.cpp b/esphome/components/adc/adc_sensor_libretiny.cpp index cd04477b3f..9e75ed414c 100644 --- a/esphome/components/adc/adc_sensor_libretiny.cpp +++ b/esphome/components/adc/adc_sensor_libretiny.cpp @@ -23,23 +23,28 @@ void ADCSensor::dump_config() { LOG_PIN(" Pin: ", this->pin_); #endif // USE_ADC_SENSOR_VCC ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_); + ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_))); LOG_UPDATE_INTERVAL(this); } float ADCSensor::sample() { uint32_t raw = 0; + auto aggr = Aggregator(this->sampling_mode_); + if (this->output_raw_) { for (uint8_t sample = 0; sample < this->sample_count_; sample++) { - raw += analogRead(this->pin_->get_pin()); // NOLINT + raw = analogRead(this->pin_->get_pin()); // NOLINT + aggr.add_sample(raw); } - raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) - return raw; + return aggr.aggregate(); } + for (uint8_t sample = 0; sample < this->sample_count_; sample++) { - raw += analogReadVoltage(this->pin_->get_pin()); // NOLINT + raw = analogReadVoltage(this->pin_->get_pin()); // NOLINT + aggr.add_sample(raw); } - raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) - return raw / 1000.0f; + + return aggr.aggregate() / 1000.0f; } } // namespace adc diff --git a/esphome/components/adc/adc_sensor_rp2040.cpp b/esphome/components/adc/adc_sensor_rp2040.cpp index 520ff3bacc..f6cf1bac7a 100644 --- a/esphome/components/adc/adc_sensor_rp2040.cpp +++ b/esphome/components/adc/adc_sensor_rp2040.cpp @@ -34,24 +34,28 @@ void ADCSensor::dump_config() { #endif // USE_ADC_SENSOR_VCC } ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_); + ESP_LOGCONFIG(TAG, " Sampling mode: %s", LOG_STR_ARG(sampling_mode_to_str(this->sampling_mode_))); LOG_UPDATE_INTERVAL(this); } float ADCSensor::sample() { + uint32_t raw = 0; + auto aggr = Aggregator(this->sampling_mode_); + if (this->is_temperature_) { adc_set_temp_sensor_enabled(true); delay(1); adc_select_input(4); - uint32_t raw = 0; + for (uint8_t sample = 0; sample < this->sample_count_; sample++) { - raw += adc_read(); + raw = adc_read(); + aggr.add_sample(raw); } - raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) adc_set_temp_sensor_enabled(false); if (this->output_raw_) { - return raw; + return aggr.aggregate(); } - return raw * 3.3f / 4096.0f; + return aggr.aggregate() * 3.3f / 4096.0f; } uint8_t pin = this->pin_->get_pin(); @@ -68,11 +72,10 @@ float ADCSensor::sample() { adc_gpio_init(pin); adc_select_input(pin - 26); - uint32_t raw = 0; for (uint8_t sample = 0; sample < this->sample_count_; sample++) { - raw += adc_read(); + raw = adc_read(); + aggr.add_sample(raw); } - raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero) #ifdef CYW43_USES_VSYS_PIN if (pin == PICO_VSYS_PIN) { @@ -81,10 +84,10 @@ float ADCSensor::sample() { #endif // CYW43_USES_VSYS_PIN if (this->output_raw_) { - return raw; + return aggr.aggregate(); } float coeff = pin == PICO_VSYS_PIN ? 3.0f : 1.0f; - return raw * 3.3f / 4096.0f * coeff; + return aggr.aggregate() * 3.3f / 4096.0f * coeff; } } // namespace adc diff --git a/esphome/components/adc/sensor.py b/esphome/components/adc/sensor.py index 59ea9e184c..3309bd04c5 100644 --- a/esphome/components/adc/sensor.py +++ b/esphome/components/adc/sensor.py @@ -1,11 +1,9 @@ import logging import esphome.codegen as cg -import esphome.config_validation as cv -import esphome.final_validate as fv -from esphome.core import CORE from esphome.components import sensor, voltage_sampler from esphome.components.esp32 import get_esp32_variant +import esphome.config_validation as cv from esphome.const import ( CONF_ATTENUATION, CONF_ID, @@ -17,10 +15,14 @@ from esphome.const import ( STATE_CLASS_MEASUREMENT, UNIT_VOLT, ) +from esphome.core import CORE +import esphome.final_validate as fv + from . import ( ATTENUATION_MODES, ESP32_VARIANT_ADC1_PIN_TO_CHANNEL, ESP32_VARIANT_ADC2_PIN_TO_CHANNEL, + SAMPLING_MODES, adc_ns, validate_adc_pin, ) @@ -30,9 +32,11 @@ _LOGGER = logging.getLogger(__name__) AUTO_LOAD = ["voltage_sampler"] CONF_SAMPLES = "samples" +CONF_SAMPLING_MODE = "sampling_mode" _attenuation = cv.enum(ATTENUATION_MODES, lower=True) +_sampling_mode = cv.enum(SAMPLING_MODES, lower=True) def validate_config(config): @@ -88,6 +92,7 @@ CONFIG_SCHEMA = cv.All( cv.only_on_esp32, _attenuation ), cv.Optional(CONF_SAMPLES, default=1): cv.int_range(min=1, max=255), + cv.Optional(CONF_SAMPLING_MODE, default="avg"): _sampling_mode, } ) .extend(cv.polling_component_schema("60s")), @@ -112,6 +117,7 @@ async def to_code(config): cg.add(var.set_output_raw(config[CONF_RAW])) cg.add(var.set_sample_count(config[CONF_SAMPLES])) + cg.add(var.set_sampling_mode(config[CONF_SAMPLING_MODE])) if attenuation := config.get(CONF_ATTENUATION): if attenuation == "auto": diff --git a/tests/component_tests/sensor/test_sensor.yaml b/tests/component_tests/sensor/test_sensor.yaml index 612b8e5e56..0f0ad5e94e 100644 --- a/tests/component_tests/sensor/test_sensor.yaml +++ b/tests/component_tests/sensor/test_sensor.yaml @@ -10,5 +10,6 @@ sensor: pin: A0 id: s_1 name: test s1 + sampling_mode: min update_interval: 60s device_class: voltage From 8be9f02693fdd383b4bfcde3fb3216068472cc3e Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Sun, 9 Feb 2025 23:42:40 -0500 Subject: [PATCH 12/79] [ota] Increase socket timeout earlier in OTA script (#8129) --- esphome/espota2.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/esphome/espota2.py b/esphome/espota2.py index 94b845b246..4f2a08fb4a 100644 --- a/esphome/espota2.py +++ b/esphome/espota2.py @@ -249,6 +249,9 @@ def perform_ota( send_check(sock, result, "auth result") receive_exactly(sock, 1, "auth result", RESPONSE_AUTH_OK) + # Set higher timeout during upload + sock.settimeout(30.0) + upload_size = len(upload_contents) upload_size_encoded = [ (upload_size >> 24) & 0xFF, @@ -271,8 +274,6 @@ def perform_ota( # show the actual progress sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, UPLOAD_BUFFER_SIZE) - # Set higher timeout during upload - sock.settimeout(30.0) start_time = time.perf_counter() offset = 0 From 84836f15db00e8eecc73fa06b169fa7265ed653b Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Mon, 10 Feb 2025 13:00:23 -0600 Subject: [PATCH 13/79] [speaker] Media Player Components PR9 (#8171) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- CODEOWNERS | 1 + esphome/components/media_player/__init__.py | 59 +- esphome/components/media_player/automation.h | 13 +- .../components/media_player/media_player.cpp | 8 + .../components/media_player/media_player.h | 12 +- .../speaker/media_player/__init__.py | 458 ++++++++++++++ .../speaker/media_player/audio_pipeline.cpp | 560 +++++++++++++++++ .../speaker/media_player/audio_pipeline.h | 158 +++++ .../speaker/media_player/automation.h | 26 + .../media_player/speaker_media_player.cpp | 577 ++++++++++++++++++ .../media_player/speaker_media_player.h | 160 +++++ tests/components/media_player/common.yaml | 2 + .../speaker/common-media_player.yaml | 12 + .../speaker/media_player.esp32-idf.yaml | 9 + .../speaker/media_player.esp32-s3-idf.yaml | 9 + 15 files changed, 2043 insertions(+), 21 deletions(-) create mode 100644 esphome/components/speaker/media_player/__init__.py create mode 100644 esphome/components/speaker/media_player/audio_pipeline.cpp create mode 100644 esphome/components/speaker/media_player/audio_pipeline.h create mode 100644 esphome/components/speaker/media_player/automation.h create mode 100644 esphome/components/speaker/media_player/speaker_media_player.cpp create mode 100644 esphome/components/speaker/media_player/speaker_media_player.h create mode 100644 tests/components/speaker/common-media_player.yaml create mode 100644 tests/components/speaker/media_player.esp32-idf.yaml create mode 100644 tests/components/speaker/media_player.esp32-s3-idf.yaml diff --git a/CODEOWNERS b/CODEOWNERS index d4b3d7eff9..26e36befe5 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -390,6 +390,7 @@ esphome/components/sn74hc165/* @jesserockz esphome/components/socket/* @esphome/core esphome/components/sonoff_d1/* @anatoly-savchenkov esphome/components/speaker/* @jesserockz @kahrendt +esphome/components/speaker/media_player/* @kahrendt @synesthesiam esphome/components/spi/* @clydebarrow @esphome/core esphome/components/spi_device/* @clydebarrow esphome/components/spi_led_strip/* @clydebarrow diff --git a/esphome/components/media_player/__init__.py b/esphome/components/media_player/__init__.py index a46b30db29..b2543ac05f 100644 --- a/esphome/components/media_player/__init__.py +++ b/esphome/components/media_player/__init__.py @@ -1,5 +1,4 @@ from esphome import automation -from esphome.automation import maybe_simple_id import esphome.codegen as cg import esphome.config_validation as cv from esphome.const import ( @@ -21,6 +20,16 @@ media_player_ns = cg.esphome_ns.namespace("media_player") MediaPlayer = media_player_ns.class_("MediaPlayer") +MediaPlayerSupportedFormat = media_player_ns.struct("MediaPlayerSupportedFormat") + +MediaPlayerFormatPurpose = media_player_ns.enum( + "MediaPlayerFormatPurpose", is_class=True +) +MEDIA_PLAYER_FORMAT_PURPOSE_ENUM = { + "default": MediaPlayerFormatPurpose.PURPOSE_DEFAULT, + "announcement": MediaPlayerFormatPurpose.PURPOSE_ANNOUNCEMENT, +} + PlayAction = media_player_ns.class_( "PlayAction", automation.Action, cg.Parented.template(MediaPlayer) @@ -47,7 +56,7 @@ VolumeSetAction = media_player_ns.class_( "VolumeSetAction", automation.Action, cg.Parented.template(MediaPlayer) ) - +CONF_ANNOUNCEMENT = "announcement" CONF_ON_PLAY = "on_play" CONF_ON_PAUSE = "on_pause" CONF_ON_ANNOUNCEMENT = "on_announcement" @@ -125,7 +134,16 @@ MEDIA_PLAYER_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend( ) -MEDIA_PLAYER_ACTION_SCHEMA = maybe_simple_id({cv.GenerateID(): cv.use_id(MediaPlayer)}) +MEDIA_PLAYER_ACTION_SCHEMA = cv.Schema( + { + cv.GenerateID(): cv.use_id(MediaPlayer), + cv.Optional(CONF_ANNOUNCEMENT, default=False): cv.templatable(cv.boolean), + } +) + +MEDIA_PLAYER_CONDITION_SCHEMA = automation.maybe_simple_id( + {cv.GenerateID(): cv.use_id(MediaPlayer)} +) @automation.register_action( @@ -135,6 +153,7 @@ MEDIA_PLAYER_ACTION_SCHEMA = maybe_simple_id({cv.GenerateID(): cv.use_id(MediaPl { cv.GenerateID(): cv.use_id(MediaPlayer), cv.Required(CONF_MEDIA_URL): cv.templatable(cv.url), + cv.Optional(CONF_ANNOUNCEMENT, default=False): cv.templatable(cv.boolean), }, key=CONF_MEDIA_URL, ), @@ -143,7 +162,9 @@ async def media_player_play_media_action(config, action_id, template_arg, args): var = cg.new_Pvariable(action_id, template_arg) await cg.register_parented(var, config[CONF_ID]) media_url = await cg.templatable(config[CONF_MEDIA_URL], args, cg.std_string) + announcement = await cg.templatable(config[CONF_ANNOUNCEMENT], args, cg.bool_) cg.add(var.set_media_url(media_url)) + cg.add(var.set_announcement(announcement)) return var @@ -161,19 +182,27 @@ async def media_player_play_media_action(config, action_id, template_arg, args): @automation.register_action( "media_player.volume_down", VolumeDownAction, MEDIA_PLAYER_ACTION_SCHEMA ) -@automation.register_condition( - "media_player.is_idle", IsIdleCondition, MEDIA_PLAYER_ACTION_SCHEMA -) -@automation.register_condition( - "media_player.is_paused", IsPausedCondition, MEDIA_PLAYER_ACTION_SCHEMA -) -@automation.register_condition( - "media_player.is_playing", IsPlayingCondition, MEDIA_PLAYER_ACTION_SCHEMA -) -@automation.register_condition( - "media_player.is_announcing", IsAnnouncingCondition, MEDIA_PLAYER_ACTION_SCHEMA -) async def media_player_action(config, action_id, template_arg, args): + var = cg.new_Pvariable(action_id, template_arg) + await cg.register_parented(var, config[CONF_ID]) + announcement = await cg.templatable(config[CONF_ANNOUNCEMENT], args, cg.bool_) + cg.add(var.set_announcement(announcement)) + return var + + +@automation.register_condition( + "media_player.is_idle", IsIdleCondition, MEDIA_PLAYER_CONDITION_SCHEMA +) +@automation.register_condition( + "media_player.is_paused", IsPausedCondition, MEDIA_PLAYER_CONDITION_SCHEMA +) +@automation.register_condition( + "media_player.is_playing", IsPlayingCondition, MEDIA_PLAYER_CONDITION_SCHEMA +) +@automation.register_condition( + "media_player.is_announcing", IsAnnouncingCondition, MEDIA_PLAYER_CONDITION_SCHEMA +) +async def media_player_condition(config, action_id, template_arg, args): var = cg.new_Pvariable(action_id, template_arg) await cg.register_parented(var, config[CONF_ID]) return var diff --git a/esphome/components/media_player/automation.h b/esphome/components/media_player/automation.h index 7b9220c4a5..422c224a85 100644 --- a/esphome/components/media_player/automation.h +++ b/esphome/components/media_player/automation.h @@ -10,7 +10,10 @@ namespace media_player { template class MediaPlayerCommandAction : public Action, public Parented { public: - void play(Ts... x) override { this->parent_->make_call().set_command(Command).perform(); } + TEMPLATABLE_VALUE(bool, announcement); + void play(Ts... x) override { + this->parent_->make_call().set_command(Command).set_announcement(this->announcement_.value(x...)).perform(); + } }; template @@ -28,7 +31,13 @@ using VolumeDownAction = MediaPlayerCommandAction class PlayMediaAction : public Action, public Parented { TEMPLATABLE_VALUE(std::string, media_url) - void play(Ts... x) override { this->parent_->make_call().set_media_url(this->media_url_.value(x...)).perform(); } + TEMPLATABLE_VALUE(bool, announcement) + void play(Ts... x) override { + this->parent_->make_call() + .set_media_url(this->media_url_.value(x...)) + .set_announcement(this->announcement_.value(x...)) + .perform(); + } }; template class VolumeSetAction : public Action, public Parented { diff --git a/esphome/components/media_player/media_player.cpp b/esphome/components/media_player/media_player.cpp index b5190d8573..01304d9135 100644 --- a/esphome/components/media_player/media_player.cpp +++ b/esphome/components/media_player/media_player.cpp @@ -41,6 +41,14 @@ const char *media_player_command_to_string(MediaPlayerCommand command) { return "VOLUME_UP"; case MEDIA_PLAYER_COMMAND_VOLUME_DOWN: return "VOLUME_DOWN"; + case MEDIA_PLAYER_COMMAND_ENQUEUE: + return "ENQUEUE"; + case MEDIA_PLAYER_COMMAND_REPEAT_ONE: + return "REPEAT_ONE"; + case MEDIA_PLAYER_COMMAND_REPEAT_OFF: + return "REPEAT_OFF"; + case MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST: + return "CLEAR_PLAYLIST"; default: return "UNKNOWN"; } diff --git a/esphome/components/media_player/media_player.h b/esphome/components/media_player/media_player.h index 78b3ed6216..ee5889901c 100644 --- a/esphome/components/media_player/media_player.h +++ b/esphome/components/media_player/media_player.h @@ -24,6 +24,10 @@ enum MediaPlayerCommand : uint8_t { MEDIA_PLAYER_COMMAND_TOGGLE = 5, MEDIA_PLAYER_COMMAND_VOLUME_UP = 6, MEDIA_PLAYER_COMMAND_VOLUME_DOWN = 7, + MEDIA_PLAYER_COMMAND_ENQUEUE = 8, + MEDIA_PLAYER_COMMAND_REPEAT_ONE = 9, + MEDIA_PLAYER_COMMAND_REPEAT_OFF = 10, + MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST = 11, }; const char *media_player_command_to_string(MediaPlayerCommand command); @@ -72,10 +76,10 @@ class MediaPlayerCall { void perform(); - const optional &get_command() const { return command_; } - const optional &get_media_url() const { return media_url_; } - const optional &get_volume() const { return volume_; } - const optional &get_announcement() const { return announcement_; } + const optional &get_command() const { return this->command_; } + const optional &get_media_url() const { return this->media_url_; } + const optional &get_volume() const { return this->volume_; } + const optional &get_announcement() const { return this->announcement_; } protected: void validate_(); diff --git a/esphome/components/speaker/media_player/__init__.py b/esphome/components/speaker/media_player/__init__.py new file mode 100644 index 0000000000..14b72cacc0 --- /dev/null +++ b/esphome/components/speaker/media_player/__init__.py @@ -0,0 +1,458 @@ +"""Speaker Media Player Setup.""" + +import hashlib +import logging +from pathlib import Path + +from esphome import automation, external_files +import esphome.codegen as cg +from esphome.components import audio, esp32, media_player, speaker +import esphome.config_validation as cv +from esphome.const import ( + CONF_BUFFER_SIZE, + CONF_FILE, + CONF_FILES, + CONF_FORMAT, + CONF_ID, + CONF_NUM_CHANNELS, + CONF_PATH, + CONF_RAW_DATA_ID, + CONF_SAMPLE_RATE, + CONF_SPEAKER, + CONF_TASK_STACK_IN_PSRAM, + CONF_TYPE, + CONF_URL, +) +from esphome.core import CORE, HexInt +from esphome.core.entity_helpers import inherit_property_from +from esphome.external_files import download_content + +_LOGGER = logging.getLogger(__name__) + +AUTO_LOAD = ["audio", "psram"] + +CODEOWNERS = ["@kahrendt", "@synesthesiam"] +DOMAIN = "media_player" + +TYPE_LOCAL = "local" +TYPE_WEB = "web" + +CONF_ANNOUNCEMENT = "announcement" +CONF_ANNOUNCEMENT_PIPELINE = "announcement_pipeline" +CONF_CODEC_SUPPORT_ENABLED = "codec_support_enabled" +CONF_ENQUEUE = "enqueue" +CONF_MEDIA_FILE = "media_file" +CONF_MEDIA_PIPELINE = "media_pipeline" +CONF_ON_MUTE = "on_mute" +CONF_ON_UNMUTE = "on_unmute" +CONF_ON_VOLUME = "on_volume" +CONF_STREAM = "stream" +CONF_VOLUME_INCREMENT = "volume_increment" +CONF_VOLUME_MIN = "volume_min" +CONF_VOLUME_MAX = "volume_max" + + +speaker_ns = cg.esphome_ns.namespace("speaker") +SpeakerMediaPlayer = speaker_ns.class_( + "SpeakerMediaPlayer", + media_player.MediaPlayer, + cg.Component, +) + +AudioPipeline = speaker_ns.class_("AudioPipeline") +AudioPipelineType = speaker_ns.enum("AudioPipelineType", is_class=True) +AUDIO_PIPELINE_TYPE_ENUM = { + "MEDIA": AudioPipelineType.MEDIA, + "ANNOUNCEMENT": AudioPipelineType.ANNOUNCEMENT, +} + +PlayOnDeviceMediaAction = speaker_ns.class_( + "PlayOnDeviceMediaAction", + automation.Action, + cg.Parented.template(SpeakerMediaPlayer), +) +StopStreamAction = speaker_ns.class_( + "StopStreamAction", automation.Action, cg.Parented.template(SpeakerMediaPlayer) +) + + +def _compute_local_file_path(value: dict) -> Path: + url = value[CONF_URL] + h = hashlib.new("sha256") + h.update(url.encode()) + key = h.hexdigest()[:8] + base_dir = external_files.compute_local_file_dir(DOMAIN) + _LOGGER.debug("_compute_local_file_path: base_dir=%s", base_dir / key) + return base_dir / key + + +def _download_web_file(value): + url = value[CONF_URL] + path = _compute_local_file_path(value) + + download_content(url, path) + _LOGGER.debug("download_web_file: path=%s", path) + return value + + +# Returns a media_player.MediaPlayerSupportedFormat struct with the configured +# format, sample rate, number of channels, purpose, and bytes per sample +def _get_supported_format_struct(pipeline, type): + args = [ + media_player.MediaPlayerSupportedFormat, + ] + + if pipeline[CONF_FORMAT] == "FLAC": + args.append(("format", "flac")) + elif pipeline[CONF_FORMAT] == "MP3": + args.append(("format", "mp3")) + elif pipeline[CONF_FORMAT] == "WAV": + args.append(("format", "wav")) + + args.append(("sample_rate", pipeline[CONF_SAMPLE_RATE])) + args.append(("num_channels", pipeline[CONF_NUM_CHANNELS])) + + if type == "MEDIA": + args.append( + ( + "purpose", + media_player.MEDIA_PLAYER_FORMAT_PURPOSE_ENUM["default"], + ) + ) + elif type == "ANNOUNCEMENT": + args.append( + ( + "purpose", + media_player.MEDIA_PLAYER_FORMAT_PURPOSE_ENUM["announcement"], + ) + ) + if pipeline[CONF_FORMAT] != "MP3": + args.append(("sample_bytes", 2)) + + return cg.StructInitializer(*args) + + +def _file_schema(value): + if isinstance(value, str): + return _validate_file_shorthand(value) + return TYPED_FILE_SCHEMA(value) + + +def _read_audio_file_and_type(file_config): + conf_file = file_config[CONF_FILE] + file_source = conf_file[CONF_TYPE] + if file_source == TYPE_LOCAL: + path = CORE.relative_config_path(conf_file[CONF_PATH]) + elif file_source == TYPE_WEB: + path = _compute_local_file_path(conf_file) + else: + raise cv.Invalid("Unsupported file source.") + + with open(path, "rb") as f: + data = f.read() + + import puremagic + + file_type: str = puremagic.from_string(data) + if file_type.startswith("."): + file_type = file_type[1:] + + media_file_type = audio.AUDIO_FILE_TYPE_ENUM["NONE"] + if file_type in ("wav"): + media_file_type = audio.AUDIO_FILE_TYPE_ENUM["WAV"] + elif file_type in ("mp3", "mpeg", "mpga"): + media_file_type = audio.AUDIO_FILE_TYPE_ENUM["MP3"] + elif file_type in ("flac"): + media_file_type = audio.AUDIO_FILE_TYPE_ENUM["FLAC"] + + return data, media_file_type + + +def _validate_file_shorthand(value): + value = cv.string_strict(value) + if value.startswith("http://") or value.startswith("https://"): + return _file_schema( + { + CONF_TYPE: TYPE_WEB, + CONF_URL: value, + } + ) + return _file_schema( + { + CONF_TYPE: TYPE_LOCAL, + CONF_PATH: value, + } + ) + + +def _validate_pipeline(config): + # Inherit transcoder settings from speaker if not manually set + inherit_property_from(CONF_NUM_CHANNELS, CONF_SPEAKER)(config) + inherit_property_from(CONF_SAMPLE_RATE, CONF_SPEAKER)(config) + + # Validate the transcoder settings is compatible with the speaker + audio.final_validate_audio_schema( + "speaker media_player", + audio_device=CONF_SPEAKER, + bits_per_sample=16, + channels=config.get(CONF_NUM_CHANNELS), + sample_rate=config.get(CONF_SAMPLE_RATE), + )(config) + + return config + + +def _validate_repeated_speaker(config): + if (announcement_config := config.get(CONF_ANNOUNCEMENT_PIPELINE)) and ( + media_config := config.get(CONF_MEDIA_PIPELINE) + ): + if announcement_config[CONF_SPEAKER] == media_config[CONF_SPEAKER]: + raise cv.Invalid( + "The announcement and media pipelines cannot use the same speaker. Use the `mixer` speaker component to create two source speakers." + ) + + return config + + +def _validate_supported_local_file(config): + for file_config in config.get(CONF_FILES, []): + _, media_file_type = _read_audio_file_and_type(file_config) + if str(media_file_type) == str(audio.AUDIO_FILE_TYPE_ENUM["NONE"]): + raise cv.Invalid("Unsupported local media file.") + if not config[CONF_CODEC_SUPPORT_ENABLED] and str(media_file_type) != str( + audio.AUDIO_FILE_TYPE_ENUM["WAV"] + ): + # Only wav files are supported + raise cv.Invalid( + f"Unsupported local media file type, set {CONF_CODEC_SUPPORT_ENABLED} to true or convert the media file to wav" + ) + + return config + + +LOCAL_SCHEMA = cv.Schema( + { + cv.Required(CONF_PATH): cv.file_, + } +) + +WEB_SCHEMA = cv.All( + { + cv.Required(CONF_URL): cv.url, + }, + _download_web_file, +) + + +TYPED_FILE_SCHEMA = cv.typed_schema( + { + TYPE_LOCAL: LOCAL_SCHEMA, + TYPE_WEB: WEB_SCHEMA, + }, +) + + +MEDIA_FILE_TYPE_SCHEMA = cv.Schema( + { + cv.Required(CONF_ID): cv.declare_id(audio.AudioFile), + cv.Required(CONF_FILE): _file_schema, + cv.GenerateID(CONF_RAW_DATA_ID): cv.declare_id(cg.uint8), + } +) + +PIPELINE_SCHEMA = cv.Schema( + { + cv.GenerateID(): cv.declare_id(AudioPipeline), + cv.Required(CONF_SPEAKER): cv.use_id(speaker.Speaker), + cv.Optional(CONF_FORMAT, default="FLAC"): cv.enum(audio.AUDIO_FILE_TYPE_ENUM), + cv.Optional(CONF_SAMPLE_RATE): cv.int_range(min=1), + cv.Optional(CONF_NUM_CHANNELS): cv.int_range(1, 2), + } +) + +CONFIG_SCHEMA = cv.All( + media_player.MEDIA_PLAYER_SCHEMA.extend( + { + cv.GenerateID(): cv.declare_id(SpeakerMediaPlayer), + cv.Required(CONF_ANNOUNCEMENT_PIPELINE): PIPELINE_SCHEMA, + cv.Optional(CONF_MEDIA_PIPELINE): PIPELINE_SCHEMA, + cv.Optional(CONF_BUFFER_SIZE, default=1000000): cv.int_range( + min=4000, max=4000000 + ), + cv.Optional(CONF_CODEC_SUPPORT_ENABLED, default=True): cv.boolean, + cv.Optional(CONF_FILES): cv.ensure_list(MEDIA_FILE_TYPE_SCHEMA), + cv.Optional(CONF_TASK_STACK_IN_PSRAM, default=False): cv.boolean, + cv.Optional(CONF_VOLUME_INCREMENT, default=0.05): cv.percentage, + cv.Optional(CONF_VOLUME_MAX, default=1.0): cv.percentage, + cv.Optional(CONF_VOLUME_MIN, default=0.0): cv.percentage, + cv.Optional(CONF_ON_MUTE): automation.validate_automation(single=True), + cv.Optional(CONF_ON_UNMUTE): automation.validate_automation(single=True), + cv.Optional(CONF_ON_VOLUME): automation.validate_automation(single=True), + } + ), + cv.only_with_esp_idf, + _validate_repeated_speaker, +) + + +FINAL_VALIDATE_SCHEMA = cv.All( + cv.Schema( + { + cv.Optional(CONF_ANNOUNCEMENT_PIPELINE): _validate_pipeline, + cv.Optional(CONF_MEDIA_PIPELINE): _validate_pipeline, + }, + extra=cv.ALLOW_EXTRA, + ), + _validate_supported_local_file, +) + + +async def to_code(config): + if config[CONF_CODEC_SUPPORT_ENABLED]: + # Compile all supported audio codecs and optimize the wifi settings + + cg.add_define("USE_AUDIO_FLAC_SUPPORT", True) + cg.add_define("USE_AUDIO_MP3_SUPPORT", True) + + # Wifi settings based on https://github.com/espressif/esp-adf/issues/297#issuecomment-783811702 + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM", 16) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM", 512) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_STATIC_TX_BUFFER", True) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_TX_BUFFER_TYPE", 0) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_STATIC_TX_BUFFER_NUM", 8) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM", 32) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED", True) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_TX_BA_WIN", 16) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED", True) + esp32.add_idf_sdkconfig_option("CONFIG_ESP32_WIFI_RX_BA_WIN", 32) + esp32.add_idf_sdkconfig_option("CONFIG_LWIP_MAX_ACTIVE_TCP", 16) + esp32.add_idf_sdkconfig_option("CONFIG_LWIP_MAX_LISTENING_TCP", 16) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_MAXRTX", 12) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_SYNMAXRTX", 6) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_MSS", 1436) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_MSL", 60000) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_SND_BUF_DEFAULT", 65535) + esp32.add_idf_sdkconfig_option( + "CONFIG_TCP_WND_DEFAULT", 65535 + ) # Adjusted from referenced settings to avoid compilation error + esp32.add_idf_sdkconfig_option("CONFIG_TCP_RECVMBOX_SIZE", 512) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_QUEUE_OOSEQ", True) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_OVERSIZE_MSS", True) + esp32.add_idf_sdkconfig_option("CONFIG_LWIP_WND_SCALE", True) + esp32.add_idf_sdkconfig_option("CONFIG_TCP_RCV_SCALE", 3) + esp32.add_idf_sdkconfig_option("CONFIG_LWIP_TCPIP_RECVMBOX_SIZE", 512) + + # Allocate wifi buffers in PSRAM + esp32.add_idf_sdkconfig_option("CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP", True) + + var = cg.new_Pvariable(config[CONF_ID]) + await cg.register_component(var, config) + await media_player.register_media_player(var, config) + + cg.add_define("USE_OTA_STATE_CALLBACK") + + cg.add(var.set_buffer_size(config[CONF_BUFFER_SIZE])) + + cg.add(var.set_task_stack_in_psram(config[CONF_TASK_STACK_IN_PSRAM])) + if config[CONF_TASK_STACK_IN_PSRAM]: + esp32.add_idf_sdkconfig_option( + "CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY", True + ) + + cg.add(var.set_volume_increment(config[CONF_VOLUME_INCREMENT])) + cg.add(var.set_volume_max(config[CONF_VOLUME_MAX])) + cg.add(var.set_volume_min(config[CONF_VOLUME_MIN])) + + announcement_pipeline_config = config[CONF_ANNOUNCEMENT_PIPELINE] + spkr = await cg.get_variable(announcement_pipeline_config[CONF_SPEAKER]) + cg.add(var.set_announcement_speaker(spkr)) + if announcement_pipeline_config[CONF_FORMAT] != "NONE": + cg.add( + var.set_announcement_format( + _get_supported_format_struct( + announcement_pipeline_config, "ANNOUNCEMENT" + ) + ) + ) + + if media_pipeline_config := config.get(CONF_MEDIA_PIPELINE): + spkr = await cg.get_variable(media_pipeline_config[CONF_SPEAKER]) + cg.add(var.set_media_speaker(spkr)) + if media_pipeline_config[CONF_FORMAT] != "NONE": + cg.add( + var.set_media_format( + _get_supported_format_struct(media_pipeline_config, "MEDIA") + ) + ) + + if on_mute := config.get(CONF_ON_MUTE): + await automation.build_automation( + var.get_mute_trigger(), + [], + on_mute, + ) + if on_unmute := config.get(CONF_ON_UNMUTE): + await automation.build_automation( + var.get_unmute_trigger(), + [], + on_unmute, + ) + if on_volume := config.get(CONF_ON_VOLUME): + await automation.build_automation( + var.get_volume_trigger(), + [(cg.float_, "x")], + on_volume, + ) + + for file_config in config.get(CONF_FILES, []): + data, media_file_type = _read_audio_file_and_type(file_config) + + rhs = [HexInt(x) for x in data] + prog_arr = cg.progmem_array(file_config[CONF_RAW_DATA_ID], rhs) + + media_files_struct = cg.StructInitializer( + audio.AudioFile, + ( + "data", + prog_arr, + ), + ( + "length", + len(rhs), + ), + ( + "file_type", + media_file_type, + ), + ) + + cg.new_Pvariable( + file_config[CONF_ID], + media_files_struct, + ) + + +@automation.register_action( + "media_player.speaker.play_on_device_media_file", + PlayOnDeviceMediaAction, + cv.maybe_simple_value( + { + cv.GenerateID(): cv.use_id(SpeakerMediaPlayer), + cv.Required(CONF_MEDIA_FILE): cv.use_id(audio.AudioFile), + cv.Optional(CONF_ANNOUNCEMENT, default=False): cv.templatable(cv.boolean), + cv.Optional(CONF_ENQUEUE, default=False): cv.templatable(cv.boolean), + }, + key=CONF_MEDIA_FILE, + ), +) +async def play_on_device_media_media_action(config, action_id, template_arg, args): + var = cg.new_Pvariable(action_id, template_arg) + await cg.register_parented(var, config[CONF_ID]) + media_file = await cg.get_variable(config[CONF_MEDIA_FILE]) + announcement = await cg.templatable(config[CONF_ANNOUNCEMENT], args, cg.bool_) + enqueue = await cg.templatable(config[CONF_ENQUEUE], args, cg.bool_) + + cg.add(var.set_audio_file(media_file)) + cg.add(var.set_announcement(announcement)) + cg.add(var.set_enqueue(enqueue)) + return var diff --git a/esphome/components/speaker/media_player/audio_pipeline.cpp b/esphome/components/speaker/media_player/audio_pipeline.cpp new file mode 100644 index 0000000000..73ec5a3334 --- /dev/null +++ b/esphome/components/speaker/media_player/audio_pipeline.cpp @@ -0,0 +1,560 @@ +#include "audio_pipeline.h" + +#ifdef USE_ESP_IDF + +#include "esphome/core/defines.h" +#include "esphome/core/hal.h" +#include "esphome/core/helpers.h" +#include "esphome/core/log.h" + +namespace esphome { +namespace speaker { + +static const uint32_t INITIAL_BUFFER_MS = 1000; // Start playback after buffering this duration of the file + +static const uint32_t READ_TASK_STACK_SIZE = 5 * 1024; +static const uint32_t DECODE_TASK_STACK_SIZE = 3 * 1024; + +static const uint32_t INFO_ERROR_QUEUE_COUNT = 5; + +static const char *const TAG = "speaker_media_player.pipeline"; + +enum EventGroupBits : uint32_t { + // MESSAGE_* bits are only set by their respective tasks + + // Stops all activity in the pipeline elements; cleared by process_state() and set by stop() or by each task + PIPELINE_COMMAND_STOP = (1 << 0), + + // Read audio from an HTTP source; cleared by reader task and set by start_url + READER_COMMAND_INIT_HTTP = (1 << 4), + // Read audio from an audio file from the flash; cleared by reader task and set by start_file + READER_COMMAND_INIT_FILE = (1 << 5), + + // Audio file type is read after checking it is supported; cleared by decoder task + READER_MESSAGE_LOADED_MEDIA_TYPE = (1 << 6), + // Reader is done (either through a failure or just end of the stream); cleared by reader task + READER_MESSAGE_FINISHED = (1 << 7), + // Error reading the file; cleared by process_state() + READER_MESSAGE_ERROR = (1 << 8), + + // Decoder is done (either through a faiilure or the end of the stream); cleared by decoder task + DECODER_MESSAGE_FINISHED = (1 << 12), + // Error decoding the file; cleared by process_state() by decoder task + DECODER_MESSAGE_ERROR = (1 << 13), +}; + +AudioPipeline::AudioPipeline(speaker::Speaker *speaker, size_t buffer_size, bool task_stack_in_psram, + std::string base_name, UBaseType_t priority) + : base_name_(std::move(base_name)), + priority_(priority), + task_stack_in_psram_(task_stack_in_psram), + speaker_(speaker), + buffer_size_(buffer_size) { + this->allocate_communications_(); + this->transfer_buffer_size_ = std::min(buffer_size_ / 4, DEFAULT_TRANSFER_BUFFER_SIZE); +} + +void AudioPipeline::start_url(const std::string &uri) { + if (this->is_playing_) { + xEventGroupSetBits(this->event_group_, PIPELINE_COMMAND_STOP); + } + this->current_uri_ = uri; + this->pending_url_ = true; +} + +void AudioPipeline::start_file(audio::AudioFile *audio_file) { + if (this->is_playing_) { + xEventGroupSetBits(this->event_group_, PIPELINE_COMMAND_STOP); + } + this->current_audio_file_ = audio_file; + this->pending_file_ = true; +} + +esp_err_t AudioPipeline::stop() { + xEventGroupSetBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP); + + return ESP_OK; +} +void AudioPipeline::set_pause_state(bool pause_state) { + this->speaker_->set_pause_state(pause_state); + + this->pause_state_ = pause_state; +} + +void AudioPipeline::suspend_tasks() { + if (this->read_task_handle_ != nullptr) { + vTaskSuspend(this->read_task_handle_); + } + if (this->decode_task_handle_ != nullptr) { + vTaskSuspend(this->decode_task_handle_); + } +} + +void AudioPipeline::resume_tasks() { + if (this->read_task_handle_ != nullptr) { + vTaskResume(this->read_task_handle_); + } + if (this->decode_task_handle_ != nullptr) { + vTaskResume(this->decode_task_handle_); + } +} + +AudioPipelineState AudioPipeline::process_state() { + /* + * Log items from info error queue + */ + InfoErrorEvent event; + if (this->info_error_queue_ != nullptr) { + while (xQueueReceive(this->info_error_queue_, &event, 0)) { + switch (event.source) { + case InfoErrorSource::READER: + if (event.err.has_value()) { + ESP_LOGE(TAG, "Media reader encountered an error: %s", esp_err_to_name(event.err.value())); + } else if (event.file_type.has_value()) { + ESP_LOGD(TAG, "Reading %s file type", audio_file_type_to_string(event.file_type.value())); + } + + break; + case InfoErrorSource::DECODER: + if (event.err.has_value()) { + ESP_LOGE(TAG, "Decoder encountered an error: %s", esp_err_to_name(event.err.value())); + } + + if (event.audio_stream_info.has_value()) { + ESP_LOGD(TAG, "Decoded audio has %d channels, %" PRId32 " Hz sample rate, and %d bits per sample", + event.audio_stream_info.value().get_channels(), event.audio_stream_info.value().get_sample_rate(), + event.audio_stream_info.value().get_bits_per_sample()); + } + + if (event.decoding_err.has_value()) { + switch (event.decoding_err.value()) { + case DecodingError::FAILED_HEADER: + ESP_LOGE(TAG, "Failed to parse the file's header."); + break; + case DecodingError::INCOMPATIBLE_BITS_PER_SAMPLE: + ESP_LOGE(TAG, "Incompatible bits per sample. Only 16 bits per sample is supported"); + break; + case DecodingError::INCOMPATIBLE_CHANNELS: + ESP_LOGE(TAG, "Incompatible number of channels. Only 1 or 2 channel audio is supported."); + break; + } + } + break; + } + } + } + + /* + * Determine the current state based on the event group bits and tasks' status + */ + + EventBits_t event_bits = xEventGroupGetBits(this->event_group_); + + if (this->pending_url_ || this->pending_file_) { + // Init command pending + if (!(event_bits & EventGroupBits::PIPELINE_COMMAND_STOP)) { + // Only start if there is no pending stop command + if ((this->read_task_handle_ == nullptr) || (this->decode_task_handle_ == nullptr)) { + // At least one task isn't running + this->start_tasks_(); + } + + if (this->pending_url_) { + xEventGroupSetBits(this->event_group_, EventGroupBits::READER_COMMAND_INIT_HTTP); + this->playback_ms_ = 0; + this->pending_url_ = false; + } else if (this->pending_file_) { + xEventGroupSetBits(this->event_group_, EventGroupBits::READER_COMMAND_INIT_FILE); + this->playback_ms_ = 0; + this->pending_file_ = false; + } + + this->is_playing_ = true; + return AudioPipelineState::PLAYING; + } + } + + if ((event_bits & EventGroupBits::READER_MESSAGE_FINISHED) && + (!(event_bits & EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE) && + (event_bits & EventGroupBits::DECODER_MESSAGE_FINISHED))) { + // Tasks are finished and there's no media in between the reader and decoder + + if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) { + // Stop command is fully processed, so clear the command bit + xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP); + } + + if (!this->is_playing_) { + // The tasks have been stopped for two ``process_state`` calls in a row, so delete the tasks + if ((this->read_task_handle_ != nullptr) || (this->decode_task_handle_ != nullptr)) { + this->delete_tasks_(); + this->speaker_->stop(); + } + } + this->is_playing_ = false; + return AudioPipelineState::STOPPED; + } + + if ((event_bits & EventGroupBits::READER_MESSAGE_ERROR)) { + xEventGroupClearBits(this->event_group_, EventGroupBits::READER_MESSAGE_ERROR); + return AudioPipelineState::ERROR_READING; + } + + if ((event_bits & EventGroupBits::DECODER_MESSAGE_ERROR)) { + xEventGroupClearBits(this->event_group_, EventGroupBits::DECODER_MESSAGE_ERROR); + return AudioPipelineState::ERROR_DECODING; + } + + if (this->pause_state_) { + return AudioPipelineState::PAUSED; + } + + if ((this->read_task_handle_ == nullptr) && (this->decode_task_handle_ == nullptr)) { + // No tasks are running, so the pipeline is stopped. + xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP); + return AudioPipelineState::STOPPED; + } + + this->is_playing_ = true; + return AudioPipelineState::PLAYING; +} + +esp_err_t AudioPipeline::allocate_communications_() { + if (this->event_group_ == nullptr) + this->event_group_ = xEventGroupCreate(); + + if (this->event_group_ == nullptr) { + return ESP_ERR_NO_MEM; + } + + if (this->info_error_queue_ == nullptr) + this->info_error_queue_ = xQueueCreate(INFO_ERROR_QUEUE_COUNT, sizeof(InfoErrorEvent)); + + if (this->info_error_queue_ == nullptr) + return ESP_ERR_NO_MEM; + + return ESP_OK; +} + +esp_err_t AudioPipeline::start_tasks_() { + if (this->read_task_handle_ == nullptr) { + if (this->read_task_stack_buffer_ == nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + this->read_task_stack_buffer_ = stack_allocator.allocate(READ_TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + this->read_task_stack_buffer_ = stack_allocator.allocate(READ_TASK_STACK_SIZE); + } + } + + if (this->read_task_stack_buffer_ == nullptr) { + return ESP_ERR_NO_MEM; + } + + if (this->read_task_handle_ == nullptr) { + this->read_task_handle_ = + xTaskCreateStatic(read_task, (this->base_name_ + "_read").c_str(), READ_TASK_STACK_SIZE, (void *) this, + this->priority_, this->read_task_stack_buffer_, &this->read_task_stack_); + } + + if (this->read_task_handle_ == nullptr) { + return ESP_ERR_INVALID_STATE; + } + } + + if (this->decode_task_handle_ == nullptr) { + if (this->decode_task_stack_buffer_ == nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + this->decode_task_stack_buffer_ = stack_allocator.allocate(DECODE_TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + this->decode_task_stack_buffer_ = stack_allocator.allocate(DECODE_TASK_STACK_SIZE); + } + } + + if (this->decode_task_stack_buffer_ == nullptr) { + return ESP_ERR_NO_MEM; + } + + if (this->decode_task_handle_ == nullptr) { + this->decode_task_handle_ = + xTaskCreateStatic(decode_task, (this->base_name_ + "_decode").c_str(), DECODE_TASK_STACK_SIZE, (void *) this, + this->priority_, this->decode_task_stack_buffer_, &this->decode_task_stack_); + } + + if (this->decode_task_handle_ == nullptr) { + return ESP_ERR_INVALID_STATE; + } + } + + return ESP_OK; +} + +void AudioPipeline::delete_tasks_() { + if (this->read_task_handle_ != nullptr) { + vTaskDelete(this->read_task_handle_); + + if (this->read_task_stack_buffer_ != nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + stack_allocator.deallocate(this->read_task_stack_buffer_, READ_TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + stack_allocator.deallocate(this->read_task_stack_buffer_, READ_TASK_STACK_SIZE); + } + + this->read_task_stack_buffer_ = nullptr; + this->read_task_handle_ = nullptr; + } + } + + if (this->decode_task_handle_ != nullptr) { + vTaskDelete(this->decode_task_handle_); + + if (this->decode_task_stack_buffer_ != nullptr) { + if (this->task_stack_in_psram_) { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_EXTERNAL); + stack_allocator.deallocate(this->decode_task_stack_buffer_, DECODE_TASK_STACK_SIZE); + } else { + RAMAllocator stack_allocator(RAMAllocator::ALLOC_INTERNAL); + stack_allocator.deallocate(this->decode_task_stack_buffer_, DECODE_TASK_STACK_SIZE); + } + + this->decode_task_stack_buffer_ = nullptr; + this->decode_task_handle_ = nullptr; + } + } +} + +void AudioPipeline::read_task(void *params) { + AudioPipeline *this_pipeline = (AudioPipeline *) params; + + while (true) { + xEventGroupSetBits(this_pipeline->event_group_, EventGroupBits::READER_MESSAGE_FINISHED); + + // Wait until the pipeline notifies us the source of the media file + EventBits_t event_bits = + xEventGroupWaitBits(this_pipeline->event_group_, + EventGroupBits::READER_COMMAND_INIT_FILE | EventGroupBits::READER_COMMAND_INIT_HTTP | + EventGroupBits::PIPELINE_COMMAND_STOP, // Bit message to read + pdFALSE, // Clear the bit on exit + pdFALSE, // Wait for all the bits, + portMAX_DELAY); // Block indefinitely until bit is set + + if (!(event_bits & EventGroupBits::PIPELINE_COMMAND_STOP)) { + xEventGroupClearBits(this_pipeline->event_group_, EventGroupBits::READER_MESSAGE_FINISHED | + EventGroupBits::READER_COMMAND_INIT_FILE | + EventGroupBits::READER_COMMAND_INIT_HTTP); + InfoErrorEvent event; + event.source = InfoErrorSource::READER; + esp_err_t err = ESP_OK; + + std::unique_ptr reader = + make_unique(this_pipeline->transfer_buffer_size_); + + if (event_bits & EventGroupBits::READER_COMMAND_INIT_FILE) { + err = reader->start(this_pipeline->current_audio_file_, this_pipeline->current_audio_file_type_); + } else { + err = reader->start(this_pipeline->current_uri_, this_pipeline->current_audio_file_type_); + } + + if (err == ESP_OK) { + size_t file_ring_buffer_size = this_pipeline->buffer_size_; + + std::shared_ptr temp_ring_buffer; + + if (!this_pipeline->raw_file_ring_buffer_.use_count()) { + temp_ring_buffer = RingBuffer::create(file_ring_buffer_size); + this_pipeline->raw_file_ring_buffer_ = temp_ring_buffer; + } + + if (!this_pipeline->raw_file_ring_buffer_.use_count()) { + err = ESP_ERR_NO_MEM; + } else { + reader->add_sink(this_pipeline->raw_file_ring_buffer_); + } + } + + if (err != ESP_OK) { + // Send specific error message + event.err = err; + xQueueSend(this_pipeline->info_error_queue_, &event, portMAX_DELAY); + + // Setting up the reader failed, stop the pipeline + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::READER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + } else { + // Send the file type to the pipeline + event.file_type = this_pipeline->current_audio_file_type_; + xQueueSend(this_pipeline->info_error_queue_, &event, portMAX_DELAY); + xEventGroupSetBits(this_pipeline->event_group_, EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE); + } + + while (true) { + event_bits = xEventGroupGetBits(this_pipeline->event_group_); + + if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) { + break; + } + + audio::AudioReaderState reader_state = reader->read(); + + if (reader_state == audio::AudioReaderState::FINISHED) { + break; + } else if (reader_state == audio::AudioReaderState::FAILED) { + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::READER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + break; + } + } + event_bits = xEventGroupGetBits(this_pipeline->event_group_); + if ((event_bits & EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE) || + (this_pipeline->raw_file_ring_buffer_.use_count() == 1)) { + // Decoder task hasn't started yet, so delay a bit before releasing ownership of the ring buffer + delay(10); + } + } + } +} + +void AudioPipeline::decode_task(void *params) { + AudioPipeline *this_pipeline = (AudioPipeline *) params; + + while (true) { + xEventGroupSetBits(this_pipeline->event_group_, EventGroupBits::DECODER_MESSAGE_FINISHED); + + // Wait until the reader notifies us that the media type is available + EventBits_t event_bits = xEventGroupWaitBits(this_pipeline->event_group_, + EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE | + EventGroupBits::PIPELINE_COMMAND_STOP, // Bit message to read + pdFALSE, // Clear the bit on exit + pdFALSE, // Wait for all the bits, + portMAX_DELAY); // Block indefinitely until bit is set + + if (!(event_bits & EventGroupBits::PIPELINE_COMMAND_STOP)) { + xEventGroupClearBits(this_pipeline->event_group_, + EventGroupBits::DECODER_MESSAGE_FINISHED | EventGroupBits::READER_MESSAGE_LOADED_MEDIA_TYPE); + InfoErrorEvent event; + event.source = InfoErrorSource::DECODER; + + std::unique_ptr decoder = + make_unique(this_pipeline->transfer_buffer_size_, this_pipeline->transfer_buffer_size_); + + esp_err_t err = decoder->start(this_pipeline->current_audio_file_type_); + decoder->add_source(this_pipeline->raw_file_ring_buffer_); + + if (err != ESP_OK) { + // Send specific error message + event.err = err; + xQueueSend(this_pipeline->info_error_queue_, &event, portMAX_DELAY); + + // Setting up the decoder failed, stop the pipeline + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::DECODER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + } + + bool has_stream_info = false; + bool started_playback = false; + + size_t initial_bytes_to_buffer = 0; + + while (true) { + event_bits = xEventGroupGetBits(this_pipeline->event_group_); + + if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) { + break; + } + + // Update pause state + if (!started_playback) { + if (!(event_bits & EventGroupBits::READER_MESSAGE_FINISHED)) { + decoder->set_pause_output_state(true); + } else { + started_playback = true; + } + } else { + decoder->set_pause_output_state(this_pipeline->pause_state_); + } + + // Stop gracefully if the reader has finished + audio::AudioDecoderState decoder_state = decoder->decode(event_bits & EventGroupBits::READER_MESSAGE_FINISHED); + + if ((decoder_state == audio::AudioDecoderState::DECODING) || + (decoder_state == audio::AudioDecoderState::FINISHED)) { + this_pipeline->playback_ms_ = decoder->get_playback_ms(); + } + + if (decoder_state == audio::AudioDecoderState::FINISHED) { + break; + } else if (decoder_state == audio::AudioDecoderState::FAILED) { + if (!has_stream_info) { + event.decoding_err = DecodingError::FAILED_HEADER; + xQueueSend(this_pipeline->info_error_queue_, &event, portMAX_DELAY); + } + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::DECODER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + break; + } + + if (!has_stream_info && decoder->get_audio_stream_info().has_value()) { + has_stream_info = true; + + this_pipeline->current_audio_stream_info_ = decoder->get_audio_stream_info().value(); + + // Send the stream information to the pipeline + event.audio_stream_info = this_pipeline->current_audio_stream_info_; + + if (this_pipeline->current_audio_stream_info_.get_bits_per_sample() != 16) { + // Error state, incompatible bits per sample + event.decoding_err = DecodingError::INCOMPATIBLE_BITS_PER_SAMPLE; + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::DECODER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + } else if ((this_pipeline->current_audio_stream_info_.get_channels() > 2)) { + // Error state, incompatible number of channels + event.decoding_err = DecodingError::INCOMPATIBLE_CHANNELS; + xEventGroupSetBits(this_pipeline->event_group_, + EventGroupBits::DECODER_MESSAGE_ERROR | EventGroupBits::PIPELINE_COMMAND_STOP); + } else { + // Send audio directly to the speaker + this_pipeline->speaker_->set_audio_stream_info(this_pipeline->current_audio_stream_info_); + decoder->add_sink(this_pipeline->speaker_); + } + + initial_bytes_to_buffer = std::min(this_pipeline->current_audio_stream_info_.ms_to_bytes(INITIAL_BUFFER_MS), + this_pipeline->buffer_size_ * 3 / 4); + + switch (this_pipeline->current_audio_file_type_) { +#ifdef USE_AUDIO_MP3_SUPPORT + case audio::AudioFileType::MP3: + initial_bytes_to_buffer /= 8; // Estimate the MP3 compression factor is 8 + break; +#endif +#ifdef USE_AUDIO_FLAC_SUPPORT + case audio::AudioFileType::FLAC: + initial_bytes_to_buffer /= 2; // Estimate the FLAC compression factor is 2 + break; +#endif + default: + break; + } + xQueueSend(this_pipeline->info_error_queue_, &event, portMAX_DELAY); + } + + if (!started_playback && has_stream_info) { + // Verify enough data is available before starting playback + std::shared_ptr temp_ring_buffer = this_pipeline->raw_file_ring_buffer_.lock(); + if (temp_ring_buffer->available() >= initial_bytes_to_buffer) { + started_playback = true; + } + } + } + } + } +} + +} // namespace speaker +} // namespace esphome + +#endif diff --git a/esphome/components/speaker/media_player/audio_pipeline.h b/esphome/components/speaker/media_player/audio_pipeline.h new file mode 100644 index 0000000000..c382e1eebe --- /dev/null +++ b/esphome/components/speaker/media_player/audio_pipeline.h @@ -0,0 +1,158 @@ +#pragma once + +#ifdef USE_ESP_IDF + +#include "esphome/components/audio/audio.h" +#include "esphome/components/audio/audio_reader.h" +#include "esphome/components/audio/audio_decoder.h" +#include "esphome/components/speaker/speaker.h" + +#include "esphome/core/ring_buffer.h" + +#include "esp_err.h" + +#include +#include +#include + +namespace esphome { +namespace speaker { + +// Internal sink/source buffers for reader and decoder +static const size_t DEFAULT_TRANSFER_BUFFER_SIZE = 24 * 1024; + +enum class AudioPipelineType : uint8_t { + MEDIA, + ANNOUNCEMENT, +}; + +enum class AudioPipelineState : uint8_t { + STARTING_FILE, + STARTING_URL, + PLAYING, + STOPPING, + STOPPED, + PAUSED, + ERROR_READING, + ERROR_DECODING, +}; + +enum class InfoErrorSource : uint8_t { + READER = 0, + DECODER, +}; + +enum class DecodingError : uint8_t { + FAILED_HEADER = 0, + INCOMPATIBLE_BITS_PER_SAMPLE, + INCOMPATIBLE_CHANNELS, +}; + +// Used to pass information from each task. +struct InfoErrorEvent { + InfoErrorSource source; + optional err; + optional file_type; + optional audio_stream_info; + optional decoding_err; +}; + +class AudioPipeline { + public: + /// @param speaker ESPHome speaker component for pipeline's audio output + /// @param buffer_size Size of the buffer in bytes between the reader and decoder + /// @param task_stack_in_psram True if the task stack should be allocated in PSRAM, false otherwise + /// @param task_name FreeRTOS task base name + /// @param priority FreeRTOS task priority + AudioPipeline(speaker::Speaker *speaker, size_t buffer_size, bool task_stack_in_psram, std::string base_name, + UBaseType_t priority); + + /// @brief Starts an audio pipeline given a media url + /// @param uri media file url + /// @return ESP_OK if successful or an appropriate error if not + void start_url(const std::string &uri); + + /// @brief Starts an audio pipeline given a AudioFile pointer + /// @param audio_file pointer to an AudioFile object + /// @return ESP_OK if successful or an appropriate error if not + void start_file(audio::AudioFile *audio_file); + + /// @brief Stops the pipeline. Sends a stop signal to each task (if running) and clears the ring buffers. + /// @return ESP_OK if successful or ESP_ERR_TIMEOUT if the tasks did not indicate they stopped + esp_err_t stop(); + + /// @brief Processes the state of the audio pipeline based on the info_error_queue_ and event_group_. Handles creating + /// and stopping the pipeline tasks. Needs to be regularly called to update the internal pipeline state. + /// @return AudioPipelineState + AudioPipelineState process_state(); + + /// @brief Suspends any running tasks + void suspend_tasks(); + /// @brief Resumes any running tasks + void resume_tasks(); + + uint32_t get_playback_ms() { return this->playback_ms_; } + + void set_pause_state(bool pause_state); + + protected: + /// @brief Allocates the event group and info error queue. + /// @return ESP_OK if successful or ESP_ERR_NO_MEM if it is unable to allocate all parts + esp_err_t allocate_communications_(); + + /// @brief Common start code for the pipeline, regardless if the source is a file or url. + /// @return ESP_OK if successful or an appropriate error if not + esp_err_t start_tasks_(); + + /// @brief Resets the task related pointers and deallocates their stacks. + void delete_tasks_(); + + std::string base_name_; + UBaseType_t priority_; + + uint32_t playback_ms_{0}; + + bool is_playing_{false}; + bool pause_state_{false}; + bool task_stack_in_psram_; + + // Pending file start state used to ensure the pipeline fully stops before attempting to start the next file + bool pending_url_{false}; + bool pending_file_{false}; + + speaker::Speaker *speaker_{nullptr}; + + std::string current_uri_{}; + audio::AudioFile *current_audio_file_{nullptr}; + + audio::AudioFileType current_audio_file_type_; + audio::AudioStreamInfo current_audio_stream_info_; + + size_t buffer_size_; // Ring buffer between reader and decoder + size_t transfer_buffer_size_; // Internal source/sink buffers for the audio reader and decoder + + std::weak_ptr raw_file_ring_buffer_; + + // Handles basic control/state of the three tasks + EventGroupHandle_t event_group_{nullptr}; + + // Receives detailed info (file type, stream info, resampling info) or specific errors from the three tasks + QueueHandle_t info_error_queue_{nullptr}; + + // Handles reading the media file from flash or a url + static void read_task(void *params); + TaskHandle_t read_task_handle_{nullptr}; + StaticTask_t read_task_stack_; + StackType_t *read_task_stack_buffer_{nullptr}; + + // Decodes the media file into PCM audio + static void decode_task(void *params); + TaskHandle_t decode_task_handle_{nullptr}; + StaticTask_t decode_task_stack_; + StackType_t *decode_task_stack_buffer_{nullptr}; +}; + +} // namespace speaker +} // namespace esphome + +#endif diff --git a/esphome/components/speaker/media_player/automation.h b/esphome/components/speaker/media_player/automation.h new file mode 100644 index 0000000000..d1a01aabc4 --- /dev/null +++ b/esphome/components/speaker/media_player/automation.h @@ -0,0 +1,26 @@ +#pragma once + +#include "speaker_media_player.h" + +#ifdef USE_ESP_IDF + +#include "esphome/components/audio/audio.h" +#include "esphome/core/automation.h" + +namespace esphome { +namespace speaker { + +template class PlayOnDeviceMediaAction : public Action, public Parented { + TEMPLATABLE_VALUE(audio::AudioFile *, audio_file) + TEMPLATABLE_VALUE(bool, announcement) + TEMPLATABLE_VALUE(bool, enqueue) + void play(Ts... x) override { + this->parent_->play_file(this->audio_file_.value(x...), this->announcement_.value(x...), + this->enqueue_.value(x...)); + } +}; + +} // namespace speaker +} // namespace esphome + +#endif diff --git a/esphome/components/speaker/media_player/speaker_media_player.cpp b/esphome/components/speaker/media_player/speaker_media_player.cpp new file mode 100644 index 0000000000..0a2585ce60 --- /dev/null +++ b/esphome/components/speaker/media_player/speaker_media_player.cpp @@ -0,0 +1,577 @@ +#include "speaker_media_player.h" + +#ifdef USE_ESP_IDF + +#include "esphome/core/log.h" + +#include "esphome/components/audio/audio.h" +#ifdef USE_OTA +#include "esphome/components/ota/ota_backend.h" +#endif + +namespace esphome { +namespace speaker { + +// Framework: +// - Media player that can handle two streams: one for media and one for announcements +// - Each stream has an individual speaker component for output +// - Each stream is handled by an ``AudioPipeline`` object with two parts/tasks +// - ``AudioReader`` handles reading from an HTTP source or from a PROGMEM flash set at compile time +// - ``AudioDecoder`` handles decoding the audio file. All formats are limited to two channels and 16 bits per sample +// - FLAC +// - MP3 (based on the libhelix decoder) +// - WAV +// - Each task runs until it is done processing the file or it receives a stop command +// - Inter-task communication uses a FreeRTOS Event Group +// - The ``AudioPipeline`` sets up a ring buffer between the reader and decoder tasks. The decoder task outputs audio +// directly to a speaker component. +// - The pipelines internal state needs to be processed by regularly calling ``process_state``. +// - Generic media player commands are received by the ``control`` function. The commands are added to the +// ``media_control_command_queue_`` to be processed in the component's loop +// - Local file play back is initiatied with ``play_file`` and adds it to the ``media_control_command_queue_`` +// - Starting a stream intializes the appropriate pipeline or stops it if it is already running +// - Volume and mute commands are achieved by the ``mute``, ``unmute``, ``set_volume`` functions. +// - Volume commands are ignored if the media control queue is full to avoid crashing with rapid volume +// increases/decreases. +// - These functions all send the appropriate information to the speakers to implement. +// - Pausing is implemented in the decoder task and is also sent directly to the media speaker component to decrease +// latency. +// - The components main loop performs housekeeping: +// - It reads the media control queue and processes it directly +// - It determines the overall state of the media player by considering the state of each pipeline +// - announcement playback takes highest priority +// - Handles playlists and repeating by starting the appropriate file when a previous file is finished +// - Logging only happens in the main loop task to reduce task stack memory usage. + +static const uint32_t MEDIA_CONTROLS_QUEUE_LENGTH = 20; + +static const UBaseType_t MEDIA_PIPELINE_TASK_PRIORITY = 1; +static const UBaseType_t ANNOUNCEMENT_PIPELINE_TASK_PRIORITY = 1; + +static const float FIRST_BOOT_DEFAULT_VOLUME = 0.5f; + +static const char *const TAG = "speaker_media_player"; + +void SpeakerMediaPlayer::setup() { + state = media_player::MEDIA_PLAYER_STATE_IDLE; + + this->media_control_command_queue_ = xQueueCreate(MEDIA_CONTROLS_QUEUE_LENGTH, sizeof(MediaCallCommand)); + + this->pref_ = global_preferences->make_preference(this->get_object_id_hash()); + + VolumeRestoreState volume_restore_state; + if (this->pref_.load(&volume_restore_state)) { + this->set_volume_(volume_restore_state.volume); + this->set_mute_state_(volume_restore_state.is_muted); + } else { + this->set_volume_(FIRST_BOOT_DEFAULT_VOLUME); + this->set_mute_state_(false); + } + +#ifdef USE_OTA + ota::get_global_ota_callback()->add_on_state_callback( + [this](ota::OTAState state, float progress, uint8_t error, ota::OTAComponent *comp) { + if (state == ota::OTA_STARTED) { + if (this->media_pipeline_ != nullptr) { + this->media_pipeline_->suspend_tasks(); + } + if (this->announcement_pipeline_ != nullptr) { + this->announcement_pipeline_->suspend_tasks(); + } + } else if (state == ota::OTA_ERROR) { + if (this->media_pipeline_ != nullptr) { + this->media_pipeline_->resume_tasks(); + } + if (this->announcement_pipeline_ != nullptr) { + this->announcement_pipeline_->resume_tasks(); + } + } + }); +#endif + + this->announcement_pipeline_ = + make_unique(this->announcement_speaker_, this->buffer_size_, this->task_stack_in_psram_, "ann", + ANNOUNCEMENT_PIPELINE_TASK_PRIORITY); + + if (this->announcement_pipeline_ == nullptr) { + ESP_LOGE(TAG, "Failed to create announcement pipeline"); + this->mark_failed(); + } + + if (!this->single_pipeline_()) { + this->media_pipeline_ = make_unique(this->media_speaker_, this->buffer_size_, + this->task_stack_in_psram_, "ann", MEDIA_PIPELINE_TASK_PRIORITY); + + if (this->media_pipeline_ == nullptr) { + ESP_LOGE(TAG, "Failed to create media pipeline"); + this->mark_failed(); + } + + // Setup callback to track the duration of audio played by the media pipeline + this->media_speaker_->add_audio_output_callback( + [this](uint32_t new_playback_ms, uint32_t remainder_us, uint32_t pending_ms, uint32_t write_timestamp) { + this->playback_ms_ += new_playback_ms; + this->remainder_us_ = remainder_us; + this->pending_ms_ = pending_ms; + this->last_audio_write_timestamp_ = write_timestamp; + this->playback_us_ = this->playback_ms_ * 1000 + this->remainder_us_; + }); + } + + ESP_LOGI(TAG, "Set up speaker media player"); +} + +void SpeakerMediaPlayer::set_playlist_delay_ms(AudioPipelineType pipeline_type, uint32_t delay_ms) { + switch (pipeline_type) { + case AudioPipelineType::ANNOUNCEMENT: + this->announcement_playlist_delay_ms_ = delay_ms; + break; + case AudioPipelineType::MEDIA: + this->media_playlist_delay_ms_ = delay_ms; + break; + } +} + +void SpeakerMediaPlayer::watch_media_commands_() { + if (!this->is_ready()) { + return; + } + + MediaCallCommand media_command; + esp_err_t err = ESP_OK; + + if (xQueueReceive(this->media_control_command_queue_, &media_command, 0) == pdTRUE) { + bool new_url = media_command.new_url.has_value() && media_command.new_url.value(); + bool new_file = media_command.new_file.has_value() && media_command.new_file.value(); + + if (new_url || new_file) { + bool enqueue = media_command.enqueue.has_value() && media_command.enqueue.value(); + + if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { + // Announcement playlist/pipeline + + if (!enqueue) { + // Clear the queue and ensure the loaded next item doesn't start playing + this->cancel_timeout("next_ann"); + this->announcement_playlist_.clear(); + } + + PlaylistItem playlist_item; + if (new_url) { + playlist_item.url = this->announcement_url_; + if (!enqueue) { + // Not adding to the queue, so directly start playback and internally unpause the pipeline + this->announcement_pipeline_->start_url(playlist_item.url.value()); + this->announcement_pipeline_->set_pause_state(false); + } + } else { + playlist_item.file = this->announcement_file_; + if (!enqueue) { + // Not adding to the queue, so directly start playback and internally unpause the pipeline + this->announcement_pipeline_->start_file(playlist_item.file.value()); + this->announcement_pipeline_->set_pause_state(false); + } + } + this->announcement_playlist_.push_back(playlist_item); + } else { + // Media playlist/pipeline + + if (!enqueue) { + // Clear the queue and ensure the loaded next item doesn't start playing + this->cancel_timeout("next_media"); + this->media_playlist_.clear(); + } + + this->is_paused_ = false; + PlaylistItem playlist_item; + if (new_url) { + playlist_item.url = this->media_url_; + if (!enqueue) { + // Not adding to the queue, so directly start playback and internally unpause the pipeline + this->media_pipeline_->start_url(playlist_item.url.value()); + this->media_pipeline_->set_pause_state(false); + } + } else { + playlist_item.file = this->media_file_; + if (!enqueue) { + // Not adding to the queue, so directly start playback and internally unpause the pipeline + this->media_pipeline_->start_file(playlist_item.file.value()); + this->media_pipeline_->set_pause_state(false); + } + } + this->media_playlist_.push_back(playlist_item); + } + + if (err != ESP_OK) { + ESP_LOGE(TAG, "Error starting the audio pipeline: %s", esp_err_to_name(err)); + this->status_set_error(); + } else { + this->status_clear_error(); + } + + return; // Don't process the new file play command further + } + + if (media_command.volume.has_value()) { + this->set_volume_(media_command.volume.value()); + this->publish_state(); + } + + if (media_command.command.has_value()) { + switch (media_command.command.value()) { + case media_player::MEDIA_PLAYER_COMMAND_PLAY: + if ((this->media_pipeline_ != nullptr) && (this->is_paused_)) { + this->media_pipeline_->set_pause_state(false); + } + this->is_paused_ = false; + break; + case media_player::MEDIA_PLAYER_COMMAND_PAUSE: + if ((this->media_pipeline_ != nullptr) && (!this->is_paused_)) { + this->media_pipeline_->set_pause_state(true); + } + this->is_paused_ = true; + break; + case media_player::MEDIA_PLAYER_COMMAND_STOP: + if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { + if (this->announcement_pipeline_ != nullptr) { + this->cancel_timeout("next_ann"); + this->announcement_playlist_.clear(); + this->announcement_pipeline_->stop(); + } + } else { + if (this->media_pipeline_ != nullptr) { + this->cancel_timeout("next_media"); + this->media_playlist_.clear(); + this->media_pipeline_->stop(); + } + } + break; + case media_player::MEDIA_PLAYER_COMMAND_TOGGLE: + if (this->media_pipeline_ != nullptr) { + if (this->is_paused_) { + this->media_pipeline_->set_pause_state(false); + this->is_paused_ = false; + } else { + this->media_pipeline_->set_pause_state(true); + this->is_paused_ = true; + } + } + break; + case media_player::MEDIA_PLAYER_COMMAND_MUTE: { + this->set_mute_state_(true); + + this->publish_state(); + break; + } + case media_player::MEDIA_PLAYER_COMMAND_UNMUTE: + this->set_mute_state_(false); + this->publish_state(); + break; + case media_player::MEDIA_PLAYER_COMMAND_VOLUME_UP: + this->set_volume_(std::min(1.0f, this->volume + this->volume_increment_)); + this->publish_state(); + break; + case media_player::MEDIA_PLAYER_COMMAND_VOLUME_DOWN: + this->set_volume_(std::max(0.0f, this->volume - this->volume_increment_)); + this->publish_state(); + break; + case media_player::MEDIA_PLAYER_COMMAND_REPEAT_ONE: + if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { + this->announcement_repeat_one_ = true; + } else { + this->media_repeat_one_ = true; + } + break; + case media_player::MEDIA_PLAYER_COMMAND_REPEAT_OFF: + if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { + this->announcement_repeat_one_ = false; + } else { + this->media_repeat_one_ = false; + } + break; + case media_player::MEDIA_PLAYER_COMMAND_CLEAR_PLAYLIST: + if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { + if (this->announcement_playlist_.empty()) { + this->announcement_playlist_.resize(1); + } + } else { + if (this->media_playlist_.empty()) { + this->media_playlist_.resize(1); + } + } + break; + default: + break; + } + } + } +} + +void SpeakerMediaPlayer::loop() { + this->watch_media_commands_(); + + // Determine state of the media player + media_player::MediaPlayerState old_state = this->state; + + AudioPipelineState old_media_pipeline_state = this->media_pipeline_state_; + if (this->media_pipeline_ != nullptr) { + this->media_pipeline_state_ = this->media_pipeline_->process_state(); + this->decoded_playback_ms_ = this->media_pipeline_->get_playback_ms(); + } + + if (this->media_pipeline_state_ == AudioPipelineState::ERROR_READING) { + ESP_LOGE(TAG, "The media pipeline's file reader encountered an error."); + } else if (this->media_pipeline_state_ == AudioPipelineState::ERROR_DECODING) { + ESP_LOGE(TAG, "The media pipeline's audio decoder encountered an error."); + } + + AudioPipelineState old_announcement_pipeline_state = this->announcement_pipeline_state_; + if (this->announcement_pipeline_ != nullptr) { + this->announcement_pipeline_state_ = this->announcement_pipeline_->process_state(); + } + + if (this->announcement_pipeline_state_ == AudioPipelineState::ERROR_READING) { + ESP_LOGE(TAG, "The announcement pipeline's file reader encountered an error."); + } else if (this->announcement_pipeline_state_ == AudioPipelineState::ERROR_DECODING) { + ESP_LOGE(TAG, "The announcement pipeline's audio decoder encountered an error."); + } + + if (this->announcement_pipeline_state_ != AudioPipelineState::STOPPED) { + this->state = media_player::MEDIA_PLAYER_STATE_ANNOUNCING; + } else { + if (!this->announcement_playlist_.empty()) { + uint32_t timeout_ms = 0; + if (old_announcement_pipeline_state == AudioPipelineState::PLAYING) { + // Finished the current announcement file + if (!this->announcement_repeat_one_) { + // Pop item off the playlist if repeat is disabled + this->announcement_playlist_.pop_front(); + } + // Only delay starting playback if moving on the next playlist item or repeating the current item + timeout_ms = this->announcement_playlist_delay_ms_; + } + + if (!this->announcement_playlist_.empty()) { + // Start the next announcement file + PlaylistItem playlist_item = this->announcement_playlist_.front(); + if (playlist_item.url.has_value()) { + this->announcement_pipeline_->start_url(playlist_item.url.value()); + } else if (playlist_item.file.has_value()) { + this->announcement_pipeline_->start_file(playlist_item.file.value()); + } + + if (timeout_ms > 0) { + // Pause pipeline internally to facilitiate delay between items + this->announcement_pipeline_->set_pause_state(true); + // Internally unpause the pipeline after the delay between playlist items + this->set_timeout("next_ann", timeout_ms, + [this]() { this->announcement_pipeline_->set_pause_state(this->is_paused_); }); + } + } + } else { + if (this->is_paused_) { + this->state = media_player::MEDIA_PLAYER_STATE_PAUSED; + } else if (this->media_pipeline_state_ == AudioPipelineState::PLAYING) { + this->state = media_player::MEDIA_PLAYER_STATE_PLAYING; + } else if (this->media_pipeline_state_ == AudioPipelineState::STOPPED) { + // Reset playback durations + this->decoded_playback_ms_ = 0; + this->playback_us_ = 0; + this->playback_ms_ = 0; + this->remainder_us_ = 0; + this->pending_ms_ = 0; + + if (!media_playlist_.empty()) { + uint32_t timeout_ms = 0; + if (old_media_pipeline_state == AudioPipelineState::PLAYING) { + // Finished the current media file + if (!this->media_repeat_one_) { + // Pop item off the playlist if repeat is disabled + this->media_playlist_.pop_front(); + } + // Only delay starting playback if moving on the next playlist item or repeating the current item + timeout_ms = this->announcement_playlist_delay_ms_; + } + if (!this->media_playlist_.empty()) { + PlaylistItem playlist_item = this->media_playlist_.front(); + if (playlist_item.url.has_value()) { + this->media_pipeline_->start_url(playlist_item.url.value()); + } else if (playlist_item.file.has_value()) { + this->media_pipeline_->start_file(playlist_item.file.value()); + } + + if (timeout_ms > 0) { + // Pause pipeline internally to facilitiate delay between items + this->media_pipeline_->set_pause_state(true); + // Internally unpause the pipeline after the delay between playlist items + this->set_timeout("next_media", timeout_ms, + [this]() { this->media_pipeline_->set_pause_state(this->is_paused_); }); + } + } + } else { + this->state = media_player::MEDIA_PLAYER_STATE_IDLE; + } + } + } + } + + if (this->state != old_state) { + this->publish_state(); + ESP_LOGD(TAG, "State changed to %s", media_player::media_player_state_to_string(this->state)); + } +} + +void SpeakerMediaPlayer::play_file(audio::AudioFile *media_file, bool announcement, bool enqueue) { + if (!this->is_ready()) { + // Ignore any commands sent before the media player is setup + return; + } + + MediaCallCommand media_command; + + media_command.new_file = true; + if (this->single_pipeline_() || announcement) { + this->announcement_file_ = media_file; + media_command.announce = true; + } else { + this->media_file_ = media_file; + media_command.announce = false; + } + media_command.enqueue = enqueue; + xQueueSend(this->media_control_command_queue_, &media_command, portMAX_DELAY); +} + +void SpeakerMediaPlayer::control(const media_player::MediaPlayerCall &call) { + if (!this->is_ready()) { + // Ignore any commands sent before the media player is setup + return; + } + + MediaCallCommand media_command; + + if (this->single_pipeline_() || (call.get_announcement().has_value() && call.get_announcement().value())) { + media_command.announce = true; + } else { + media_command.announce = false; + } + + if (call.get_media_url().has_value()) { + std::string new_uri = call.get_media_url().value(); + + media_command.new_url = true; + if (this->single_pipeline_() || (call.get_announcement().has_value() && call.get_announcement().value())) { + this->announcement_url_ = new_uri; + } else { + this->media_url_ = new_uri; + } + + if (call.get_command().has_value()) { + if (call.get_command().value() == media_player::MEDIA_PLAYER_COMMAND_ENQUEUE) { + media_command.enqueue = true; + } + } + + xQueueSend(this->media_control_command_queue_, &media_command, portMAX_DELAY); + return; + } + + if (call.get_volume().has_value()) { + media_command.volume = call.get_volume().value(); + // Wait 0 ticks for queue to be free, volume sets aren't that important! + xQueueSend(this->media_control_command_queue_, &media_command, 0); + return; + } + + if (call.get_command().has_value()) { + media_command.command = call.get_command().value(); + TickType_t ticks_to_wait = portMAX_DELAY; + if ((call.get_command().value() == media_player::MEDIA_PLAYER_COMMAND_VOLUME_UP) || + (call.get_command().value() == media_player::MEDIA_PLAYER_COMMAND_VOLUME_DOWN)) { + ticks_to_wait = 0; // Wait 0 ticks for queue to be free, volume sets aren't that important! + } + xQueueSend(this->media_control_command_queue_, &media_command, ticks_to_wait); + return; + } +} + +media_player::MediaPlayerTraits SpeakerMediaPlayer::get_traits() { + auto traits = media_player::MediaPlayerTraits(); + if (!this->single_pipeline_()) { + traits.set_supports_pause(true); + } + + if (this->announcement_format_.has_value()) { + traits.get_supported_formats().push_back(this->announcement_format_.value()); + } + if (this->media_format_.has_value()) { + traits.get_supported_formats().push_back(this->media_format_.value()); + } else if (this->single_pipeline_() && this->announcement_format_.has_value()) { + // Only one pipeline is defined, so use the announcement format (if configured) for the default purpose + media_player::MediaPlayerSupportedFormat media_format = this->announcement_format_.value(); + media_format.purpose = media_player::MediaPlayerFormatPurpose::PURPOSE_DEFAULT; + traits.get_supported_formats().push_back(media_format); + } + + return traits; +}; + +void SpeakerMediaPlayer::save_volume_restore_state_() { + VolumeRestoreState volume_restore_state; + volume_restore_state.volume = this->volume; + volume_restore_state.is_muted = this->is_muted_; + this->pref_.save(&volume_restore_state); +} + +void SpeakerMediaPlayer::set_mute_state_(bool mute_state) { + if (this->media_speaker_ != nullptr) { + this->media_speaker_->set_mute_state(mute_state); + } + if (this->announcement_speaker_ != nullptr) { + this->announcement_speaker_->set_mute_state(mute_state); + } + + bool old_mute_state = this->is_muted_; + this->is_muted_ = mute_state; + + this->save_volume_restore_state_(); + + if (old_mute_state != mute_state) { + if (mute_state) { + this->defer([this]() { this->mute_trigger_->trigger(); }); + } else { + this->defer([this]() { this->unmute_trigger_->trigger(); }); + } + } +} + +void SpeakerMediaPlayer::set_volume_(float volume, bool publish) { + // Remap the volume to fit with in the configured limits + float bounded_volume = remap(volume, 0.0f, 1.0f, this->volume_min_, this->volume_max_); + + if (this->media_speaker_ != nullptr) { + this->media_speaker_->set_volume(bounded_volume); + } + + if (this->announcement_speaker_ != nullptr) { + this->announcement_speaker_->set_volume(bounded_volume); + } + + if (publish) { + this->volume = volume; + this->save_volume_restore_state_(); + } + + // Turn on the mute state if the volume is effectively zero, off otherwise + if (volume < 0.001) { + this->set_mute_state_(true); + } else { + this->set_mute_state_(false); + } + + this->defer([this, volume]() { this->volume_trigger_->trigger(volume); }); +} + +} // namespace speaker +} // namespace esphome + +#endif diff --git a/esphome/components/speaker/media_player/speaker_media_player.h b/esphome/components/speaker/media_player/speaker_media_player.h new file mode 100644 index 0000000000..6cbce91866 --- /dev/null +++ b/esphome/components/speaker/media_player/speaker_media_player.h @@ -0,0 +1,160 @@ +#pragma once + +#ifdef USE_ESP_IDF + +#include "audio_pipeline.h" + +#include "esphome/components/audio/audio.h" + +#include "esphome/components/media_player/media_player.h" +#include "esphome/components/speaker/speaker.h" + +#include "esphome/core/automation.h" +#include "esphome/core/component.h" +#include "esphome/core/preferences.h" + +#include +#include +#include + +namespace esphome { +namespace speaker { + +struct MediaCallCommand { + optional command; + optional volume; + optional announce; + optional new_url; + optional new_file; + optional enqueue; +}; + +struct PlaylistItem { + optional url; + optional file; +}; + +struct VolumeRestoreState { + float volume; + bool is_muted; +}; + +class SpeakerMediaPlayer : public Component, public media_player::MediaPlayer { + public: + float get_setup_priority() const override { return esphome::setup_priority::PROCESSOR; } + void setup() override; + void loop() override; + + // MediaPlayer implementations + media_player::MediaPlayerTraits get_traits() override; + bool is_muted() const override { return this->is_muted_; } + + void set_buffer_size(size_t buffer_size) { this->buffer_size_ = buffer_size; } + void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; } + + // Percentage to increase or decrease the volume for volume up or volume down commands + void set_volume_increment(float volume_increment) { this->volume_increment_ = volume_increment; } + + void set_volume_max(float volume_max) { this->volume_max_ = volume_max; } + void set_volume_min(float volume_min) { this->volume_min_ = volume_min; } + + void set_announcement_speaker(Speaker *announcement_speaker) { this->announcement_speaker_ = announcement_speaker; } + void set_announcement_format(const media_player::MediaPlayerSupportedFormat &announcement_format) { + this->announcement_format_ = announcement_format; + } + void set_media_speaker(Speaker *media_speaker) { this->media_speaker_ = media_speaker; } + void set_media_format(const media_player::MediaPlayerSupportedFormat &media_format) { + this->media_format_ = media_format; + } + + Trigger<> *get_mute_trigger() const { return this->mute_trigger_; } + Trigger<> *get_unmute_trigger() const { return this->unmute_trigger_; } + Trigger *get_volume_trigger() const { return this->volume_trigger_; } + + void play_file(audio::AudioFile *media_file, bool announcement, bool enqueue); + + uint32_t get_playback_ms() const { return this->playback_ms_; } + uint32_t get_playback_us() const { return this->playback_us_; } + uint32_t get_decoded_playback_ms() const { return this->decoded_playback_ms_; } + + void set_playlist_delay_ms(AudioPipelineType pipeline_type, uint32_t delay_ms); + + protected: + // Receives commands from HA or from the voice assistant component + // Sends commands to the media_control_commanda_queue_ + void control(const media_player::MediaPlayerCall &call) override; + + /// @brief Updates this->volume and saves volume/mute state to flash for restortation if publish is true. + void set_volume_(float volume, bool publish = true); + + /// @brief Sets the mute state. Restores previous volume if unmuting. Always saves volume/mute state to flash for + /// restoration. + /// @param mute_state If true, audio will be muted. If false, audio will be unmuted + void set_mute_state_(bool mute_state); + + /// @brief Saves the current volume and mute state to the flash for restoration. + void save_volume_restore_state_(); + + /// Returns true if the media player has only the announcement pipeline defined, false if both the announcement and + /// media pipelines are defined. + inline bool single_pipeline_() { return (this->media_speaker_ == nullptr); } + + // Processes commands from media_control_command_queue_. + void watch_media_commands_(); + + std::unique_ptr announcement_pipeline_; + std::unique_ptr media_pipeline_; + Speaker *media_speaker_{nullptr}; + Speaker *announcement_speaker_{nullptr}; + + optional media_format_; + AudioPipelineState media_pipeline_state_{AudioPipelineState::STOPPED}; + std::string media_url_{}; // only modified by control function + audio::AudioFile *media_file_{}; // only modified by play_file function + bool media_repeat_one_{false}; + uint32_t media_playlist_delay_ms_{0}; + + optional announcement_format_; + AudioPipelineState announcement_pipeline_state_{AudioPipelineState::STOPPED}; + std::string announcement_url_{}; // only modified by control function + audio::AudioFile *announcement_file_{}; // only modified by play_file function + bool announcement_repeat_one_{false}; + uint32_t announcement_playlist_delay_ms_{0}; + + QueueHandle_t media_control_command_queue_; + + std::deque announcement_playlist_; + std::deque media_playlist_; + + size_t buffer_size_; + + bool task_stack_in_psram_; + + bool is_paused_{false}; + bool is_muted_{false}; + + // The amount to change the volume on volume up/down commands + float volume_increment_; + + float volume_max_; + float volume_min_; + + // Used to save volume/mute state for restoration on reboot + ESPPreferenceObject pref_; + + Trigger<> *mute_trigger_ = new Trigger<>(); + Trigger<> *unmute_trigger_ = new Trigger<>(); + Trigger *volume_trigger_ = new Trigger(); + + uint32_t decoded_playback_ms_{0}; + uint32_t playback_us_{0}; + uint32_t playback_ms_{0}; + uint32_t remainder_us_{0}; + uint32_t pending_ms_{0}; + uint32_t last_audio_write_timestamp_{0}; +}; + +} // namespace speaker +} // namespace esphome + +#endif diff --git a/tests/components/media_player/common.yaml b/tests/components/media_player/common.yaml index af0d5c7765..763bc231c0 100644 --- a/tests/components/media_player/common.yaml +++ b/tests/components/media_player/common.yaml @@ -21,6 +21,8 @@ media_player: - media_player.pause: on_play: - media_player.stop: + - media_player.stop: + announcement: true on_pause: - media_player.toggle: - wait_until: diff --git a/tests/components/speaker/common-media_player.yaml b/tests/components/speaker/common-media_player.yaml new file mode 100644 index 0000000000..edc9f670fc --- /dev/null +++ b/tests/components/speaker/common-media_player.yaml @@ -0,0 +1,12 @@ +<<: !include common.yaml + +media_player: + - platform: speaker + id: speaker_media_player_id + announcement_pipeline: + speaker: speaker_id + buffer_size: 1000000 + volume_increment: 0.02 + volume_max: 0.95 + volume_min: 0.0 + task_stack_in_psram: true diff --git a/tests/components/speaker/media_player.esp32-idf.yaml b/tests/components/speaker/media_player.esp32-idf.yaml new file mode 100644 index 0000000000..4712e4bae8 --- /dev/null +++ b/tests/components/speaker/media_player.esp32-idf.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO16 + sda_pin: GPIO17 + i2s_bclk_pin: GPIO27 + i2s_lrclk_pin: GPIO26 + i2s_mclk_pin: GPIO25 + i2s_dout_pin: GPIO23 + +<<: !include common-media_player.yaml diff --git a/tests/components/speaker/media_player.esp32-s3-idf.yaml b/tests/components/speaker/media_player.esp32-s3-idf.yaml new file mode 100644 index 0000000000..b3eec04d23 --- /dev/null +++ b/tests/components/speaker/media_player.esp32-s3-idf.yaml @@ -0,0 +1,9 @@ +substitutions: + scl_pin: GPIO2 + sda_pin: GPIO3 + i2s_bclk_pin: GPIO4 + i2s_lrclk_pin: GPIO5 + i2s_mclk_pin: GPIO6 + i2s_dout_pin: GPIO7 + +<<: !include common-media_player.yaml From abdf215d3a54eff4b33b5d76207372245b5d1031 Mon Sep 17 00:00:00 2001 From: mystster Date: Tue, 11 Feb 2025 05:29:27 +0900 Subject: [PATCH 14/79] Add partial update of GDEW029T5 e-paper display (#8162) Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 2 +- .../waveshare_epaper/waveshare_epaper.cpp | 242 ++++++++++++++++-- .../waveshare_epaper/waveshare_epaper.h | 21 +- tests/components/waveshare_epaper/common.yaml | 1 + 4 files changed, 236 insertions(+), 30 deletions(-) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 3a5151682f..81afc159a5 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -120,7 +120,7 @@ MODELS = { "2.13in-ttgo-b74": ("a", WaveshareEPaperTypeAModel.TTGO_EPAPER_2_13_IN_B74), "2.90in": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN), "2.90inv2": ("a", WaveshareEPaperTypeAModel.WAVESHARE_EPAPER_2_9_IN_V2), - "gdew029t5": ("b", GDEW029T5), + "gdew029t5": ("c", GDEW029T5), "2.70in": ("b", WaveshareEPaper2P7In), "2.70in-b": ("b", WaveshareEPaper2P7InB), "2.70in-bv2": ("b", WaveshareEPaper2P7InBV2), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index fb9e8ff6e5..2ff271f999 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -1596,15 +1596,108 @@ void WaveshareEPaper2P9InV2R2::set_full_update_every(uint32_t full_update_every) // Datasheet: // - https://v4.cecdn.yun300.cn/100001_1909185148/SSD1680.pdf // - https://github.com/adafruit/Adafruit_EPD/blob/master/src/panels/ThinkInk_290_Grayscale4_T5.h +// - https://github.com/ZinggJM/GxEPD2/blob/master/src/epd/GxEPD2_290_T5.cpp +// - http://www.e-paper-display.com/GDEW029T5%20V3.1%20Specification5c22.pdf? // ======================================================== -void GDEW029T5::initialize() { - // from https://www.waveshare.com/w/upload/b/bb/2.9inch-e-paper-b-specification.pdf, page 37 - // EPD hardware init start - this->reset_(); +// full screen update LUT +static const uint8_t LUT_20_VCOMDC_29_5[] = { + 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x60, 0x28, 0x28, 0x00, 0x00, 0x01, 0x00, 0x14, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_21_WW_29_5[] = { + 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x40, 0x14, + 0x00, 0x00, 0x00, 0x01, 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_22_BW_29_5[] = { + 0x40, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x40, 0x14, + 0x00, 0x00, 0x00, 0x01, 0xA0, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_23_WB_29_5[] = { + 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14, + 0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_24_BB_29_5[] = { + 0x80, 0x08, 0x00, 0x00, 0x00, 0x02, 0x90, 0x28, 0x28, 0x00, 0x00, 0x01, 0x80, 0x14, + 0x00, 0x00, 0x00, 0x01, 0x50, 0x12, 0x12, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +// partial screen update LUT +static const uint8_t LUT_20_VCOMDC_PARTIAL_29_5[] = { + 0x00, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_21_WW_PARTIAL_29_5[] = { + 0x00, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_22_BW_PARTIAL_29_5[] = { + 0x80, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_23_WB_PARTIAL_29_5[] = { + 0x40, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const uint8_t LUT_24_BB_PARTIAL_29_5[] = { + 0x00, 0x20, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +void GDEW029T5::power_on_() { + if (!this->power_is_on_) { + this->command(0x04); + this->wait_until_idle_(); + } + this->power_is_on_ = true; +} + +void GDEW029T5::power_off_() { + this->command(0x02); + this->wait_until_idle_(); + this->power_is_on_ = false; +} + +void GDEW029T5::deep_sleep() { + this->power_off_(); + if (this->deep_sleep_between_updates_) { + this->command(0x07); // deep sleep + this->data(0xA5); // check code + ESP_LOGD(TAG, "go to deep sleep"); + this->is_deep_sleep_ = true; + } +} + +void GDEW029T5::init_display_() { + // from https://github.com/ZinggJM/GxEPD2/blob/master/src/epd/GxEPD2_290_T5.cpp + + // Hardware Initialization + if (this->deep_sleep_between_updates_ && this->is_deep_sleep_) { + ESP_LOGI(TAG, "wake up from deep sleep"); + this->reset_(); + this->is_deep_sleep_ = false; + } // COMMAND POWER SETTINGS - this->command(0x00); + this->command(0x01); this->data(0x03); this->data(0x00); this->data(0x2b); @@ -1617,40 +1710,122 @@ void GDEW029T5::initialize() { this->data(0x17); this->data(0x17); - // COMMAND POWER ON - this->command(0x04); - this->wait_until_idle_(); - - // Not sure what this does but it's in the Adafruit EPD library - this->command(0xFF); - this->wait_until_idle_(); + this->power_on_(); // COMMAND PANEL SETTING this->command(0x00); // 128x296 resolution: 10 - // LUT from OTP: 0 + // LUT from register: 1 // B/W mode (doesn't work): 1 // scan-up: 1 // shift-right: 1 // booster ON: 1 // no soft reset: 1 - this->data(0b10011111); + this->data(0b10111111); + this->data(0x0d); // VCOM to 0V fast + this->command(0x30); // PLL setting + this->data(0x3a); // 3a 100HZ 29 150Hz 39 200HZ 31 171HZ + this->command(0x61); // resolution setting + this->data(this->get_width_internal()); + this->data(this->get_height_internal() >> 8); + this->data(this->get_height_internal() & 0xFF); - // COMMAND RESOLUTION SETTING - // set to 128x296 by COMMAND PANEL SETTING - - // COMMAND VCOM AND DATA INTERVAL SETTING - // use defaults for white border and ESPHome image polarity - - // EPD hardware init end + ESP_LOGD(TAG, "panel setting done"); } + +void GDEW029T5::initialize() { + // from https://www.waveshare.com/w/upload/b/bb/2.9inch-e-paper-b-specification.pdf, page 37 + if (this->reset_pin_ != nullptr) + this->deep_sleep_between_updates_ = true; + + // old buffer for partial update + ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + this->old_buffer_ = allocator.allocate(this->get_buffer_length_()); + if (this->old_buffer_ == nullptr) { + ESP_LOGE(TAG, "Could not allocate old buffer for display!"); + return; + } + for (size_t i = 0; i < this->get_buffer_length_(); i++) { + this->old_buffer_[i] = 0xFF; + } +} + +// initialize for full(normal) update +void GDEW029T5::init_full_() { + this->init_display_(); + this->command(0x82); // vcom_DC setting + this->data(0x08); + this->command(0X50); // VCOM AND DATA INTERVAL SETTING + this->data(0x97); // WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7 + this->command(0x20); + this->write_lut_(LUT_20_VCOMDC_29_5, sizeof(LUT_20_VCOMDC_29_5)); + this->command(0x21); + this->write_lut_(LUT_21_WW_29_5, sizeof(LUT_21_WW_29_5)); + this->command(0x22); + this->write_lut_(LUT_22_BW_29_5, sizeof(LUT_22_BW_29_5)); + this->command(0x23); + this->write_lut_(LUT_23_WB_29_5, sizeof(LUT_23_WB_29_5)); + this->command(0x24); + this->write_lut_(LUT_24_BB_29_5, sizeof(LUT_24_BB_29_5)); + ESP_LOGD(TAG, "initialized full update"); +} + +// initialzie for partial update +void GDEW029T5::init_partial_() { + this->init_display_(); + this->command(0x82); // vcom_DC setting + this->data(0x08); + this->command(0X50); // VCOM AND DATA INTERVAL SETTING + this->data(0x17); // WBmode:VBDF 17|D7 VBDW 97 VBDB 57 WBRmode:VBDF F7 VBDW 77 VBDB 37 VBDR B7 + this->command(0x20); + this->write_lut_(LUT_20_VCOMDC_PARTIAL_29_5, sizeof(LUT_20_VCOMDC_PARTIAL_29_5)); + this->command(0x21); + this->write_lut_(LUT_21_WW_PARTIAL_29_5, sizeof(LUT_21_WW_PARTIAL_29_5)); + this->command(0x22); + this->write_lut_(LUT_22_BW_PARTIAL_29_5, sizeof(LUT_22_BW_PARTIAL_29_5)); + this->command(0x23); + this->write_lut_(LUT_23_WB_PARTIAL_29_5, sizeof(LUT_23_WB_PARTIAL_29_5)); + this->command(0x24); + this->write_lut_(LUT_24_BB_PARTIAL_29_5, sizeof(LUT_24_BB_PARTIAL_29_5)); + ESP_LOGD(TAG, "initialized partial update"); +} + void HOT GDEW029T5::display() { + bool full_update = this->at_update_ == 0; + if (full_update) { + this->init_full_(); + } else { + this->init_partial_(); + this->command(0x91); // partial in + // set partial window + this->command(0x90); + // this->data(0); + this->data(0); + // this->data(0); + this->data((this->get_width_internal() - 1) % 256); + this->data(0); + this->data(0); + this->data(((this->get_height_internal() - 1)) / 256); + this->data(((this->get_height_internal() - 1)) % 256); + this->data(0x01); + } + // input old buffer data + this->command(0x10); + delay(2); + this->start_data_(); + for (size_t i = 0; i < this->get_buffer_length_(); i++) { + this->write_byte(this->old_buffer_[i]); + } + this->end_data_(); + delay(2); + // COMMAND DATA START TRANSMISSION 2 (B/W only) this->command(0x13); delay(2); this->start_data_(); for (size_t i = 0; i < this->get_buffer_length_(); i++) { this->write_byte(this->buffer_[i]); + this->old_buffer_[i] = this->buffer_[i]; } this->end_data_(); delay(2); @@ -1660,10 +1835,28 @@ void HOT GDEW029T5::display() { delay(2); this->wait_until_idle_(); - // COMMAND POWER OFF - // NOTE: power off < deep sleep - this->command(0x02); + if (full_update) { + ESP_LOGD(TAG, "full update done"); + } else { + this->command(0x92); // partial out + ESP_LOGD(TAG, "partial update done"); + } + + this->at_update_ = (this->at_update_ + 1) % this->full_update_every_; + // COMMAND deep sleep + this->deep_sleep(); } + +void GDEW029T5::write_lut_(const uint8_t *lut, const uint8_t size) { + // COMMAND WRITE LUT REGISTER + this->start_data_(); + for (uint8_t i = 0; i < size; i++) + this->write_byte(lut[i]); + this->end_data_(); +} + +void GDEW029T5::set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; } + int GDEW029T5::get_width_internal() { return 128; } int GDEW029T5::get_height_internal() { return 296; } void GDEW029T5::dump_config() { @@ -1672,6 +1865,7 @@ void GDEW029T5::dump_config() { LOG_PIN(" Reset Pin: ", this->reset_pin_); LOG_PIN(" DC Pin: ", this->dc_pin_); LOG_PIN(" Busy Pin: ", this->busy_pin_); + ESP_LOGCONFIG(TAG, " Full Update Every: %" PRIu32, this->full_update_every_); LOG_UPDATE_INTERVAL(this); } diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 0fc1051268..e0c8001a50 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -254,16 +254,27 @@ class GDEW029T5 : public WaveshareEPaper { void dump_config() override; - void deep_sleep() override { - // COMMAND DEEP SLEEP - this->command(0x07); - this->data(0xA5); // check byte - } + void deep_sleep() override; + void set_full_update_every(uint32_t full_update_every); protected: + void init_display_(); + void init_full_(); + void init_partial_(); + void write_lut_(const uint8_t *lut, uint8_t size); + void power_off_(); + void power_on_(); int get_width_internal() override; int get_height_internal() override; + + private: + uint32_t full_update_every_{30}; + uint32_t at_update_{0}; + bool deep_sleep_between_updates_{false}; + bool power_is_on_{false}; + bool is_deep_sleep_{false}; + uint8_t *old_buffer_{nullptr}; }; class WaveshareEPaper2P7InV2 : public WaveshareEPaper { diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index ff9ddb955f..1d77e0cf38 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -459,6 +459,7 @@ display: reset_pin: allow_other_uses: true number: ${reset_pin} + full_update_every: 30 lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); From b667ceacedbbc5f248801460aef6432b62c6097c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=A1ta=20GEEK?= <63705187+TataGEEK@users.noreply.github.com> Date: Tue, 11 Feb 2025 01:35:56 +0100 Subject: [PATCH 15/79] Add waveshare 2.9inch e-Paper HAT (D) (#7906) Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 4 + .../waveshare_epaper/waveshare_epaper.cpp | 87 +++++++++++++++++++ .../waveshare_epaper/waveshare_epaper.h | 20 +++++ tests/components/waveshare_epaper/common.yaml | 19 ++++ 4 files changed, 130 insertions(+) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 81afc159a5..f0064c6a4d 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -55,6 +55,9 @@ GDEW029T5 = waveshare_epaper_ns.class_("GDEW029T5", WaveshareEPaper) WaveshareEPaper2P9InDKE = waveshare_epaper_ns.class_( "WaveshareEPaper2P9InDKE", WaveshareEPaper ) +WaveshareEPaper2P9InD = waveshare_epaper_ns.class_( + "WaveshareEPaper2P9InD", WaveshareEPaper +) WaveshareEPaper4P2In = waveshare_epaper_ns.class_( "WaveshareEPaper4P2In", WaveshareEPaper ) @@ -128,6 +131,7 @@ MODELS = { "2.90in-b": ("b", WaveshareEPaper2P9InB), "2.90in-bv3": ("b", WaveshareEPaper2P9InBV3), "2.90inv2-r2": ("c", WaveshareEPaper2P9InV2R2), + "2.90in-d": ("b", WaveshareEPaper2P9InD), "2.90in-dke": ("c", WaveshareEPaper2P9InDKE), "4.20in": ("b", WaveshareEPaper4P2In), "4.20in-bv2": ("b", WaveshareEPaper4P2InBV2), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 2ff271f999..f240c98096 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -1211,6 +1211,93 @@ void WaveshareEPaper2P9InB::dump_config() { LOG_UPDATE_INTERVAL(this); } +// ======================================================== +// Waveshare 2.9-inch E-Paper (Type D) +// Waveshare WIKI: https://www.waveshare.com/wiki/Pico-ePaper-2.9-D +// Datasheet: https://www.waveshare.com/w/upload/b/b5/2.9inch_e-Paper_(D)_Specification.pdf +// ======================================================== + +void WaveshareEPaper2P9InD::initialize() { + // EPD hardware init start + this->reset_(); + + // Booster Soft Start + this->command(0x06); // Command: BTST + this->data(0x17); // Soft start configuration Phase A + this->data(0x17); // Soft start configuration Phase B + this->data(0x17); // Soft start configuration Phase C + + // Power Setting + this->command(0x01); // Command: PWR + this->data(0x03); // Intern DC/DC for VDH/VDL and VGH/VGL + this->data(0x00); // Default configuration VCOM_HV and VGHL_LV + this->data(0x2b); // VDH = 10.8 V + this->data(0x2b); // VDL = -10.8 V + + // Power ON + this->command(0x04); // Command: PON + this->wait_until_idle_(); + + // Panel settings + this->command(0x00); // Command: PSR + this->data(0x1F); // LUT from OTP, black and white mode, default scan + + // PLL Control + this->command(0x30); // Command: PLL + this->data(0x3A); // Default PLL frequency + + // Resolution settings + this->command(0x61); // Command: TRES + this->data(0x80); // Width: 128 + this->data(0x01); // Height MSB: 296 + this->data(0x28); // Height LSB: 296 + + // VCOM and data interval settings + this->command(0x50); // Command: CDI + this->data(0x77); + + // VCOM_DC settings + this->command(0x82); // Command: VDCS + this->data(0x12); // Dafault VCOM_DC +} + +void WaveshareEPaper2P9InD::display() { + // Start transmitting old data (clearing buffer) + this->command(0x10); // Command: DTM1 (OLD frame data) + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + // Start transmitting new data (updated content) + this->command(0x13); // Command: DTM2 (NEW frame data) + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + // Refresh Display + this->command(0x12); // Command: DRF + this->wait_until_idle_(); + + // Enter Power Off + this->command(0x02); // Command: POF + this->wait_until_idle_(); + + // Enter Deep Sleep + this->command(0x07); // Command: DSLP + this->data(0xA5); +} + +int WaveshareEPaper2P9InD::get_width_internal() { return 128; } +int WaveshareEPaper2P9InD::get_height_internal() { return 296; } +void WaveshareEPaper2P9InD::dump_config() { + LOG_DISPLAY("", "Waveshare E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 2.9in (D)"); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} + // DKE 2.9 // https://www.badge.team/docs/badges/sha2017/hardware/#e-ink-display-the-dke-group-depg0290b1 // https://www.badge.team/docs/badges/sha2017/hardware/DEPG0290B01V3.0.pdf diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index e0c8001a50..c2277f2962 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -427,6 +427,26 @@ class WaveshareEPaper2P9InDKE : public WaveshareEPaper { int get_height_internal() override; }; +class WaveshareEPaper2P9InD : public WaveshareEPaper { + public: + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + // COMMAND DEEP SLEEP + this->command(0x07); + this->data(0xA5); + } + + protected: + int get_width_internal() override; + + int get_height_internal() override; +}; + class WaveshareEPaper4P2In : public WaveshareEPaper { public: void initialize() override; diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index 1d77e0cf38..4a67ccd67d 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -714,6 +714,25 @@ display: lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + model: 2.90in-d + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + reset_duration: 200ms + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper model: 2.90in spi_id: spi_waveshare_epaper From 8b7aa4c1102f2102d38a2d189e678b6761ee7d51 Mon Sep 17 00:00:00 2001 From: guillempages Date: Tue, 11 Feb 2025 01:39:03 +0100 Subject: [PATCH 16/79] [http_request]Use std::string for headers (#8225) --- esphome/components/http_request/http_request.h | 4 ++-- esphome/components/http_request/http_request_arduino.cpp | 2 +- esphome/components/http_request/http_request_idf.cpp | 2 +- esphome/components/online_image/online_image.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/esphome/components/http_request/http_request.h b/esphome/components/http_request/http_request.h index b2ce718ec4..e98fd1a475 100644 --- a/esphome/components/http_request/http_request.h +++ b/esphome/components/http_request/http_request.h @@ -18,8 +18,8 @@ namespace esphome { namespace http_request { struct Header { - const char *name; - const char *value; + std::string name; + std::string value; }; // Some common HTTP status codes diff --git a/esphome/components/http_request/http_request_arduino.cpp b/esphome/components/http_request/http_request_arduino.cpp index 85a1312aaa..b0067e7839 100644 --- a/esphome/components/http_request/http_request_arduino.cpp +++ b/esphome/components/http_request/http_request_arduino.cpp @@ -96,7 +96,7 @@ std::shared_ptr HttpRequestArduino::start(std::string url, std::s container->client_.setUserAgent(this->useragent_); } for (const auto &header : headers) { - container->client_.addHeader(header.name, header.value, false, true); + container->client_.addHeader(header.name.c_str(), header.value.c_str(), false, true); } // returned needed headers must be collected before the requests diff --git a/esphome/components/http_request/http_request_idf.cpp b/esphome/components/http_request/http_request_idf.cpp index 66f064c2ce..78c37403f5 100644 --- a/esphome/components/http_request/http_request_idf.cpp +++ b/esphome/components/http_request/http_request_idf.cpp @@ -84,7 +84,7 @@ std::shared_ptr HttpRequestIDF::start(std::string url, std::strin container->set_secure(secure); for (const auto &header : headers) { - esp_http_client_set_header(client, header.name, header.value); + esp_http_client_set_header(client, header.name.c_str(), header.value.c_str()); } const int body_len = body.length(); diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index da0e88a904..a1c530c2ab 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -124,7 +124,7 @@ void OnlineImage::update() { default: accept_mime_type = "image/*"; } - accept_header.value = (accept_mime_type + ",*/*;q=0.8").c_str(); + accept_header.value = accept_mime_type + ",*/*;q=0.8"; headers.push_back(accept_header); From c9e7562aff0b3a94c47baf3dc946646564432a3e Mon Sep 17 00:00:00 2001 From: guillempages Date: Tue, 11 Feb 2025 12:12:13 +0100 Subject: [PATCH 17/79] [online_image] Improve error handling (#8212) --- esphome/components/online_image/image_decoder.cpp | 12 +++++++++++- esphome/components/online_image/image_decoder.h | 11 ++++++----- esphome/components/online_image/jpeg_image.cpp | 7 ++++--- esphome/components/online_image/jpeg_image.h | 2 +- esphome/components/online_image/online_image.cpp | 7 ++++++- esphome/components/online_image/png_image.cpp | 7 ++++++- esphome/components/online_image/png_image.h | 2 +- 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/esphome/components/online_image/image_decoder.cpp b/esphome/components/online_image/image_decoder.cpp index 2958d8671d..d8c0cc33c4 100644 --- a/esphome/components/online_image/image_decoder.cpp +++ b/esphome/components/online_image/image_decoder.cpp @@ -25,6 +25,15 @@ void ImageDecoder::draw(int x, int y, int w, int h, const Color &color) { } } +DownloadBuffer::DownloadBuffer(size_t size) : size_(size) { + this->buffer_ = this->allocator_.allocate(size); + this->reset(); + if (!this->buffer_) { + ESP_LOGE(TAG, "Initial allocation of download buffer failed!"); + this->size_ = 0; + } +} + uint8_t *DownloadBuffer::data(size_t offset) { if (offset > this->size_) { ESP_LOGE(TAG, "Tried to access beyond download buffer bounds!!!"); @@ -46,12 +55,13 @@ size_t DownloadBuffer::resize(size_t size) { return size; } this->allocator_.deallocate(this->buffer_, this->size_); - this->size_ = size; this->buffer_ = this->allocator_.allocate(size); this->reset(); if (this->buffer_) { + this->size_ = size; return size; } else { + this->size_ = 0; return 0; } } diff --git a/esphome/components/online_image/image_decoder.h b/esphome/components/online_image/image_decoder.h index 957af49ac9..d11b8b46d3 100644 --- a/esphome/components/online_image/image_decoder.h +++ b/esphome/components/online_image/image_decoder.h @@ -29,8 +29,12 @@ class ImageDecoder { * @brief Initialize the decoder. * * @param download_size The total number of bytes that need to be downloaded for the image. + * @return int Returns 0 on success, a {@see DecodeError} value in case of an error. */ - virtual void prepare(size_t download_size) { this->download_size_ = download_size; } + virtual int prepare(size_t download_size) { + this->download_size_ = download_size; + return 0; + } /** * @brief Decode a part of the image. It will try reading from the buffer. @@ -83,10 +87,7 @@ class ImageDecoder { class DownloadBuffer { public: - DownloadBuffer(size_t size) : size_(size) { - this->buffer_ = this->allocator_.allocate(size); - this->reset(); - } + DownloadBuffer(size_t size); virtual ~DownloadBuffer() { this->allocator_.deallocate(this->buffer_, this->size_); } diff --git a/esphome/components/online_image/jpeg_image.cpp b/esphome/components/online_image/jpeg_image.cpp index 773b85a2c4..0aff576da8 100644 --- a/esphome/components/online_image/jpeg_image.cpp +++ b/esphome/components/online_image/jpeg_image.cpp @@ -41,13 +41,14 @@ static int draw_callback(JPEGDRAW *jpeg) { return 1; } -void JpegDecoder::prepare(size_t download_size) { +int JpegDecoder::prepare(size_t download_size) { ImageDecoder::prepare(download_size); auto size = this->image_->resize_download_buffer(download_size); if (size < download_size) { - ESP_LOGE(TAG, "Resize failed!"); - // TODO: return an error code; + ESP_LOGE(TAG, "Download buffer resize failed!"); + return DECODE_ERROR_OUT_OF_MEMORY; } + return 0; } int HOT JpegDecoder::decode(uint8_t *buffer, size_t size) { diff --git a/esphome/components/online_image/jpeg_image.h b/esphome/components/online_image/jpeg_image.h index f04a35655a..fd488d6138 100644 --- a/esphome/components/online_image/jpeg_image.h +++ b/esphome/components/online_image/jpeg_image.h @@ -21,7 +21,7 @@ class JpegDecoder : public ImageDecoder { JpegDecoder(OnlineImage *image) : ImageDecoder(image) {} ~JpegDecoder() override {} - void prepare(size_t download_size) override; + int prepare(size_t download_size) override; int HOT decode(uint8_t *buffer, size_t size) override; protected: diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index a1c530c2ab..3b3d00a044 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -178,7 +178,12 @@ void OnlineImage::update() { this->download_error_callback_.call(); return; } - this->decoder_->prepare(total_size); + auto prepare_result = this->decoder_->prepare(total_size); + if (prepare_result < 0) { + this->end_connection_(); + this->download_error_callback_.call(); + return; + } ESP_LOGI(TAG, "Downloading image (Size: %d)", total_size); this->start_time_ = ::time(nullptr); } diff --git a/esphome/components/online_image/png_image.cpp b/esphome/components/online_image/png_image.cpp index 6bc968c7ba..fc5fb554bf 100644 --- a/esphome/components/online_image/png_image.cpp +++ b/esphome/components/online_image/png_image.cpp @@ -40,11 +40,16 @@ static void draw_callback(pngle_t *pngle, uint32_t x, uint32_t y, uint32_t w, ui decoder->draw(x, y, w, h, color); } -void PngDecoder::prepare(size_t download_size) { +int PngDecoder::prepare(size_t download_size) { ImageDecoder::prepare(download_size); + if (!this->pngle_) { + ESP_LOGE(TAG, "PNG decoder engine not initialized!"); + return DECODE_ERROR_OUT_OF_MEMORY; + } pngle_set_user_data(this->pngle_, this); pngle_set_init_callback(this->pngle_, init_callback); pngle_set_draw_callback(this->pngle_, draw_callback); + return 0; } int HOT PngDecoder::decode(uint8_t *buffer, size_t size) { diff --git a/esphome/components/online_image/png_image.h b/esphome/components/online_image/png_image.h index c137227907..39f445c588 100644 --- a/esphome/components/online_image/png_image.h +++ b/esphome/components/online_image/png_image.h @@ -21,7 +21,7 @@ class PngDecoder : public ImageDecoder { PngDecoder(OnlineImage *image) : ImageDecoder(image), pngle_(pngle_new()) {} ~PngDecoder() override { pngle_destroy(this->pngle_); } - void prepare(size_t download_size) override; + int prepare(size_t download_size) override; int HOT decode(uint8_t *buffer, size_t size) override; protected: From 46d19d82c2df3885690ed3f67a78e95728bafb77 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Tue, 11 Feb 2025 12:14:59 -0600 Subject: [PATCH 18/79] [speaker] Bugfix: Ensure all audio is played after completely decoding a file (#8231) --- .../components/speaker/media_player/audio_pipeline.cpp | 10 +++++++++- .../components/speaker/media_player/audio_pipeline.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/esphome/components/speaker/media_player/audio_pipeline.cpp b/esphome/components/speaker/media_player/audio_pipeline.cpp index 73ec5a3334..b49cf3ddda 100644 --- a/esphome/components/speaker/media_player/audio_pipeline.cpp +++ b/esphome/components/speaker/media_player/audio_pipeline.cpp @@ -182,13 +182,21 @@ AudioPipelineState AudioPipeline::process_state() { if (event_bits & EventGroupBits::PIPELINE_COMMAND_STOP) { // Stop command is fully processed, so clear the command bit xEventGroupClearBits(this->event_group_, EventGroupBits::PIPELINE_COMMAND_STOP); + this->hard_stop_ = true; } if (!this->is_playing_) { // The tasks have been stopped for two ``process_state`` calls in a row, so delete the tasks if ((this->read_task_handle_ != nullptr) || (this->decode_task_handle_ != nullptr)) { this->delete_tasks_(); - this->speaker_->stop(); + if (this->hard_stop_) { + // Stop command was sent, so immediately end of the playback + this->speaker_->stop(); + this->hard_stop_ = false; + } else { + // Decoded all the audio, so let the speaker finish playing before stopping + this->speaker_->finish(); + } } } this->is_playing_ = false; diff --git a/esphome/components/speaker/media_player/audio_pipeline.h b/esphome/components/speaker/media_player/audio_pipeline.h index c382e1eebe..722d9cbb2a 100644 --- a/esphome/components/speaker/media_player/audio_pipeline.h +++ b/esphome/components/speaker/media_player/audio_pipeline.h @@ -112,6 +112,7 @@ class AudioPipeline { uint32_t playback_ms_{0}; + bool hard_stop_{false}; bool is_playing_{false}; bool pause_state_{false}; bool task_stack_in_psram_; From 33f9d66e8188ce68c7083aac909857cdd5281069 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Tue, 11 Feb 2025 12:20:39 -0600 Subject: [PATCH 19/79] [voice_assistant] Add announce support (#8232) --- .../voice_assistant/voice_assistant.cpp | 38 ++++++++++++------- .../voice_assistant/voice_assistant.h | 8 ++++ 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/esphome/components/voice_assistant/voice_assistant.cpp b/esphome/components/voice_assistant/voice_assistant.cpp index 6f164f69d3..4b02867967 100644 --- a/esphome/components/voice_assistant/voice_assistant.cpp +++ b/esphome/components/voice_assistant/voice_assistant.cpp @@ -1,4 +1,5 @@ #include "voice_assistant.h" +#include "esphome/core/defines.h" #ifdef USE_VOICE_ASSISTANT @@ -127,7 +128,7 @@ void VoiceAssistant::clear_buffers_() { } #ifdef USE_SPEAKER - if (this->speaker_buffer_ != nullptr) { + if ((this->speaker_ != nullptr) && (this->speaker_buffer_ != nullptr)) { memset(this->speaker_buffer_, 0, SPEAKER_BUFFER_SIZE); this->speaker_buffer_size_ = 0; @@ -159,7 +160,7 @@ void VoiceAssistant::deallocate_buffers_() { this->input_buffer_ = nullptr; #ifdef USE_SPEAKER - if (this->speaker_buffer_ != nullptr) { + if ((this->speaker_ != nullptr) && (this->speaker_buffer_ != nullptr)) { ExternalRAMAllocator speaker_deallocator(ExternalRAMAllocator::ALLOW_FAILURE); speaker_deallocator.deallocate(this->speaker_buffer_, SPEAKER_BUFFER_SIZE); this->speaker_buffer_ = nullptr; @@ -389,14 +390,7 @@ void VoiceAssistant::loop() { } #endif if (playing) { - this->set_timeout("playing", 2000, [this]() { - this->cancel_timeout("speaker-timeout"); - this->set_state_(State::IDLE, State::IDLE); - - api::VoiceAssistantAnnounceFinished msg; - msg.success = true; - this->api_client_->send_voice_assistant_announce_finished(msg); - }); + this->start_playback_timeout_(); } break; } @@ -614,6 +608,8 @@ void VoiceAssistant::request_stop() { this->desired_state_ = State::IDLE; break; case State::AWAITING_RESPONSE: + this->signal_stop_(); + break; case State::STREAMING_RESPONSE: case State::RESPONSE_FINISHED: break; // Let the incoming audio stream finish then it will go to idle. @@ -631,6 +627,17 @@ void VoiceAssistant::signal_stop_() { this->api_client_->send_voice_assistant_request(msg); } +void VoiceAssistant::start_playback_timeout_() { + this->set_timeout("playing", 100, [this]() { + this->cancel_timeout("speaker-timeout"); + this->set_state_(State::IDLE, State::IDLE); + + api::VoiceAssistantAnnounceFinished msg; + msg.success = true; + this->api_client_->send_voice_assistant_announce_finished(msg); + }); +} + void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) { ESP_LOGD(TAG, "Event Type: %" PRId32, msg.event_type); switch (msg.event_type) { @@ -715,6 +722,8 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) { #ifdef USE_MEDIA_PLAYER if (this->media_player_ != nullptr) { this->media_player_->make_call().set_media_url(url).set_announcement(true).perform(); + // Start the playback timeout, as the media player state isn't immediately updated + this->start_playback_timeout_(); } #endif this->tts_end_trigger_->trigger(url); @@ -725,7 +734,11 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) { } case api::enums::VOICE_ASSISTANT_RUN_END: { ESP_LOGD(TAG, "Assist Pipeline ended"); - if (this->state_ == State::STREAMING_MICROPHONE) { + if ((this->state_ == State::STARTING_PIPELINE) || (this->state_ == State::AWAITING_RESPONSE)) { + // Pipeline ended before starting microphone + // Or there wasn't a TTS start event ("nevermind") + this->set_state_(State::IDLE, State::IDLE); + } else if (this->state_ == State::STREAMING_MICROPHONE) { this->ring_buffer_->reset(); #ifdef USE_ESP_ADF if (this->use_wake_word_) { @@ -736,9 +749,6 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) { { this->set_state_(State::IDLE, State::IDLE); } - } else if (this->state_ == State::AWAITING_RESPONSE) { - // No TTS start event ("nevermind") - this->set_state_(State::IDLE, State::IDLE); } this->defer([this]() { this->end_trigger_->trigger(); }); break; diff --git a/esphome/components/voice_assistant/voice_assistant.h b/esphome/components/voice_assistant/voice_assistant.h index 0016d3157c..12124c1486 100644 --- a/esphome/components/voice_assistant/voice_assistant.h +++ b/esphome/components/voice_assistant/voice_assistant.h @@ -40,6 +40,7 @@ enum VoiceAssistantFeature : uint32_t { FEATURE_SPEAKER = 1 << 1, FEATURE_API_AUDIO = 1 << 2, FEATURE_TIMERS = 1 << 3, + FEATURE_ANNOUNCE = 1 << 4, }; enum class State { @@ -136,6 +137,12 @@ class VoiceAssistant : public Component { flags |= VoiceAssistantFeature::FEATURE_TIMERS; } +#ifdef USE_MEDIA_PLAYER + if (this->media_player_ != nullptr) { + flags |= VoiceAssistantFeature::FEATURE_ANNOUNCE; + } +#endif + return flags; } @@ -209,6 +216,7 @@ class VoiceAssistant : public Component { void set_state_(State state); void set_state_(State state, State desired_state); void signal_stop_(); + void start_playback_timeout_(); std::unique_ptr socket_ = nullptr; struct sockaddr_storage dest_addr_; From 6b3f3e1da6ed7725eaa5bacc65b069190f2787e3 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Tue, 11 Feb 2025 11:51:55 -0800 Subject: [PATCH 20/79] [prometheus] Adding valve entity metrics (#8223) --- .../prometheus/prometheus_handler.cpp | 54 +++++++++++++++++++ .../prometheus/prometheus_handler.h | 8 +++ tests/components/prometheus/common.yaml | 8 +++ 3 files changed, 70 insertions(+) diff --git a/esphome/components/prometheus/prometheus_handler.cpp b/esphome/components/prometheus/prometheus_handler.cpp index c31d34f000..794df299a1 100644 --- a/esphome/components/prometheus/prometheus_handler.cpp +++ b/esphome/components/prometheus/prometheus_handler.cpp @@ -83,6 +83,12 @@ void PrometheusHandler::handleRequest(AsyncWebServerRequest *req) { this->update_entity_row_(stream, obj, area, node, friendly_name); #endif +#ifdef USE_VALVE + this->valve_type_(stream); + for (auto *obj : App.get_valves()) + this->valve_row_(stream, obj, area, node, friendly_name); +#endif + req->send(stream); } @@ -770,6 +776,54 @@ void PrometheusHandler::update_entity_row_(AsyncResponseStream *stream, update:: } #endif +#ifdef USE_VALVE +void PrometheusHandler::valve_type_(AsyncResponseStream *stream) { + stream->print(F("#TYPE esphome_valve_operation gauge\n")); + stream->print(F("#TYPE esphome_valve_failed gauge\n")); + stream->print(F("#TYPE esphome_valve_position gauge\n")); +} + +void PrometheusHandler::valve_row_(AsyncResponseStream *stream, valve::Valve *obj, std::string &area, std::string &node, + std::string &friendly_name) { + if (obj->is_internal() && !this->include_internal_) + return; + stream->print(F("esphome_valve_failed{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} 0\n")); + // Data itself + stream->print(F("esphome_valve_operation{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\",operation=\"")); + stream->print(valve::valve_operation_to_str(obj->current_operation)); + stream->print(F("\"} ")); + stream->print(F("1.0")); + stream->print(F("\n")); + // Now see if position is supported + if (obj->get_traits().get_supports_position()) { + stream->print(F("esphome_valve_position{id=\"")); + stream->print(relabel_id_(obj).c_str()); + add_area_label_(stream, area); + add_node_label_(stream, node); + add_friendly_name_label_(stream, friendly_name); + stream->print(F("\",name=\"")); + stream->print(relabel_name_(obj).c_str()); + stream->print(F("\"} ")); + stream->print(obj->position); + stream->print(F("\n")); + } +} +#endif + } // namespace prometheus } // namespace esphome #endif diff --git a/esphome/components/prometheus/prometheus_handler.h b/esphome/components/prometheus/prometheus_handler.h index 08a6e8dc8a..b77dbc462b 100644 --- a/esphome/components/prometheus/prometheus_handler.h +++ b/esphome/components/prometheus/prometheus_handler.h @@ -161,6 +161,14 @@ class PrometheusHandler : public AsyncWebHandler, public Component { void handle_update_state_(AsyncResponseStream *stream, update::UpdateState state); #endif +#ifdef USE_VALVE + /// Return the type for prometheus + void valve_type_(AsyncResponseStream *stream); + /// Return the valve state as prometheus data point + void valve_row_(AsyncResponseStream *stream, valve::Valve *obj, std::string &area, std::string &node, + std::string &friendly_name); +#endif + web_server_base::WebServerBase *base_; bool include_internal_{false}; std::map relabel_map_id_; diff --git a/tests/components/prometheus/common.yaml b/tests/components/prometheus/common.yaml index 9205c27f2a..7c226b6782 100644 --- a/tests/components/prometheus/common.yaml +++ b/tests/components/prometheus/common.yaml @@ -121,6 +121,14 @@ number: max_value: 100 step: 1 +valve: + - platform: template + name: "Template Valve" + lambda: |- + return VALVE_OPEN; + optimistic: true + has_position: true + prometheus: include_internal: true relabel: From 14d7931bd6b12d4b91846af1a83196a9b06651e2 Mon Sep 17 00:00:00 2001 From: tmpeh <41875356+tmpeh@users.noreply.github.com> Date: Tue, 11 Feb 2025 21:41:52 +0100 Subject: [PATCH 21/79] Added Waveshare e-paper display model "7.50inv2p" to the waveshare_epaper component. (#7751) Co-authored-by: Tim Pehla Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 4 + .../waveshare_epaper/waveshare_epaper.cpp | 203 ++++++++++++++++++ .../waveshare_epaper/waveshare_epaper.h | 37 ++++ tests/components/waveshare_epaper/common.yaml | 20 ++ 4 files changed, 264 insertions(+) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index f0064c6a4d..2d8619bc5c 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -91,6 +91,9 @@ WaveshareEPaper7P5InV2 = waveshare_epaper_ns.class_( WaveshareEPaper7P5InV2alt = waveshare_epaper_ns.class_( "WaveshareEPaper7P5InV2alt", WaveshareEPaper ) +WaveshareEPaper7P5InV2P = waveshare_epaper_ns.class_( + "WaveshareEPaper7P5InV2P", WaveshareEPaper +) WaveshareEPaper7P5InHDB = waveshare_epaper_ns.class_( "WaveshareEPaper7P5InHDB", WaveshareEPaper ) @@ -144,6 +147,7 @@ MODELS = { "7.50in-bc": ("b", WaveshareEPaper7P5InBC), "7.50inv2": ("b", WaveshareEPaper7P5InV2), "7.50inv2alt": ("b", WaveshareEPaper7P5InV2alt), + "7.50inv2p": ("c", WaveshareEPaper7P5InV2P), "7.50in-hd-b": ("b", WaveshareEPaper7P5InHDB), "2.13in-ttgo-dke": ("c", WaveshareEPaper2P13InDKE), "2.13inv3": ("c", WaveshareEPaper2P13InV3), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index f240c98096..9f8c32721d 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -3100,6 +3100,209 @@ void WaveshareEPaper7P5InV2alt::dump_config() { LOG_UPDATE_INTERVAL(this); } +/* 7.50inV2 with partial and fast refresh */ +bool WaveshareEPaper7P5InV2P::wait_until_idle_() { + if (this->busy_pin_ == nullptr) { + return true; + } + + const uint32_t start = millis(); + while (this->busy_pin_->digital_read()) { + this->command(0x71); + if (millis() - start > this->idle_timeout_()) { + ESP_LOGE(TAG, "Timeout while displaying image!"); + return false; + } + App.feed_wdt(); + delay(10); + } + return true; +} + +void WaveshareEPaper7P5InV2P::reset_() { + if (this->reset_pin_ != nullptr) { + this->reset_pin_->digital_write(true); + delay(20); + this->reset_pin_->digital_write(false); + delay(2); + this->reset_pin_->digital_write(true); + delay(20); + } +} + +void WaveshareEPaper7P5InV2P::turn_on_display_() { + this->command(0x12); + delay(100); // NOLINT + this->wait_until_idle_(); +} + +void WaveshareEPaper7P5InV2P::initialize() { + this->reset_(); + + // COMMAND POWER SETTING + this->command(0x01); + this->data(0x07); + this->data(0x07); + this->data(0x3f); + this->data(0x3f); + + // COMMAND BOOSTER SOFT START + this->command(0x06); + this->data(0x17); + this->data(0x17); + this->data(0x28); + this->data(0x17); + + // COMMAND POWER DRIVER HAT UP + this->command(0x04); + delay(100); // NOLINT + this->wait_until_idle_(); + + // COMMAND PANEL SETTING + this->command(0x00); + this->data(0x1F); + + // COMMAND RESOLUTION SETTING + this->command(0x61); + this->data(0x03); + this->data(0x20); + this->data(0x01); + this->data(0xE0); + + // COMMAND DUAL SPI MM_EN, DUSPI_EN + this->command(0x15); + this->data(0x00); + + // COMMAND VCOM AND DATA INTERVAL SETTING + this->command(0x50); + this->data(0x10); + this->data(0x07); + + // COMMAND TCON SETTING + this->command(0x60); + this->data(0x22); + + // COMMAND ENABLE FAST UPDATE + this->command(0xE0); + this->data(0x02); + this->command(0xE5); + this->data(0x5A); + + // COMMAND POWER DRIVER HAT DOWN + this->command(0x02); +} + +void HOT WaveshareEPaper7P5InV2P::display() { + uint32_t buf_len = this->get_buffer_length_(); + + // COMMAND POWER ON + ESP_LOGI(TAG, "Power on the display and hat"); + + this->command(0x04); + delay(200); // NOLINT + this->wait_until_idle_(); + + if (this->full_update_every_ == 1) { + this->command(0x13); + for (uint32_t i = 0; i < buf_len; i++) { + this->data(~(this->buffer_[i])); + } + + this->turn_on_display_(); + + this->command(0x02); + this->wait_until_idle_(); + return; + } + + this->command(0x50); + this->data(0xA9); + this->data(0x07); + + if (this->at_update_ == 0) { + // Enable fast refresh + this->command(0xE5); + this->data(0x5A); + + this->command(0x92); + + this->command(0x10); + delay(2); + for (uint32_t i = 0; i < buf_len; i++) { + this->data(~(this->buffer_[i])); + } + + delay(100); // NOLINT + this->wait_until_idle_(); + + this->command(0x13); + delay(2); + for (uint32_t i = 0; i < buf_len; i++) { + this->data(this->buffer_[i]); + } + + delay(100); // NOLINT + this->wait_until_idle_(); + + this->turn_on_display_(); + + } else { + // Enable partial refresh + this->command(0xE5); + this->data(0x6E); + + // Activate partial refresh and set window bounds + this->command(0x91); + this->command(0x90); + + this->data(0x00); + this->data(0x00); + this->data((get_width_internal() - 1) >> 8 & 0xFF); + this->data((get_width_internal() - 1) & 0xFF); + + this->data(0x00); + this->data(0x00); + this->data((get_height_internal() - 1) >> 8 & 0xFF); + this->data((get_height_internal() - 1) & 0xFF); + + this->data(0x01); + + this->command(0x13); + delay(2); + for (uint32_t i = 0; i < buf_len; i++) { + this->data(this->buffer_[i]); + } + + delay(100); // NOLINT + this->wait_until_idle_(); + + this->turn_on_display_(); + } + + ESP_LOGV(TAG, "Before command(0x02) (>> power off)"); + this->command(0x02); + this->wait_until_idle_(); + ESP_LOGV(TAG, "After command(0x02) (>> power off)"); + + this->at_update_ = (this->at_update_ + 1) % this->full_update_every_; +} + +int WaveshareEPaper7P5InV2P::get_width_internal() { return 800; } +int WaveshareEPaper7P5InV2P::get_height_internal() { return 480; } +uint32_t WaveshareEPaper7P5InV2P::idle_timeout_() { return 10000; } +void WaveshareEPaper7P5InV2P::dump_config() { + LOG_DISPLAY("", "Waveshare E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 7.50inv2p"); + ESP_LOGCONFIG(TAG, " Full Update Every: %" PRIu32, this->full_update_every_); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} +void WaveshareEPaper7P5InV2P::set_full_update_every(uint32_t full_update_every) { + this->full_update_every_ = full_update_every; +} + /* 7.50in-bc */ void WaveshareEPaper7P5InBC::initialize() { /* The command sequence is similar to the 7P5In display but differs in subtle ways diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index c2277f2962..73090fa009 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -775,6 +775,43 @@ class WaveshareEPaper7P5InV2alt : public WaveshareEPaper7P5InV2 { }; }; +class WaveshareEPaper7P5InV2P : public WaveshareEPaper { + public: + bool wait_until_idle_(); + + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + // COMMAND POWER OFF + this->command(0x02); + this->wait_until_idle_(); + // COMMAND DEEP SLEEP + this->command(0x07); + this->data(0xA5); // check byte + } + + void set_full_update_every(uint32_t full_update_every); + + protected: + int get_width_internal() override; + + int get_height_internal() override; + + uint32_t idle_timeout_() override; + + uint32_t full_update_every_{30}; + uint32_t at_update_{0}; + + private: + void reset_(); + + void turn_on_display_(); +}; + class WaveshareEPaper7P5InHDB : public WaveshareEPaper { public: void initialize() override; diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index 4a67ccd67d..667bbb1bb0 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -675,6 +675,26 @@ display: lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + id: epd_7_50inv2p + model: 7.50inv2p + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper id: epd_7_50hdb model: 7.50in-hd-b From 0401ee94282c3b8e436c3983e23233171fad0c77 Mon Sep 17 00:00:00 2001 From: Rachasak Ragkamnerd Date: Wed, 12 Feb 2025 04:35:07 +0700 Subject: [PATCH 22/79] added Waveshare BWR Mode for the 4.2in Display (#7995) Co-authored-by: rrachasak Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 4 ++ .../waveshare_epaper/waveshare_epaper.cpp | 58 +++++++++++++++++++ .../waveshare_epaper/waveshare_epaper.h | 28 +++++++++ tests/components/waveshare_epaper/common.yaml | 19 ++++++ 4 files changed, 109 insertions(+) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 2d8619bc5c..f6e56c543d 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -64,6 +64,9 @@ WaveshareEPaper4P2In = waveshare_epaper_ns.class_( WaveshareEPaper4P2InBV2 = waveshare_epaper_ns.class_( "WaveshareEPaper4P2InBV2", WaveshareEPaper ) +WaveshareEPaper4P2InBV2BWR = waveshare_epaper_ns.class_( + "WaveshareEPaper4P2InBV2BWR", WaveshareEPaperBWR +) WaveshareEPaper5P8In = waveshare_epaper_ns.class_( "WaveshareEPaper5P8In", WaveshareEPaper ) @@ -138,6 +141,7 @@ MODELS = { "2.90in-dke": ("c", WaveshareEPaper2P9InDKE), "4.20in": ("b", WaveshareEPaper4P2In), "4.20in-bv2": ("b", WaveshareEPaper4P2InBV2), + "4.20in-bv2-bwr": ("b", WaveshareEPaper4P2InBV2BWR), "5.83in": ("b", WaveshareEPaper5P8In), "5.83inv2": ("b", WaveshareEPaper5P8InV2), "7.50in": ("b", WaveshareEPaper7P5In), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 9f8c32721d..a4439e2d7d 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -2274,6 +2274,64 @@ void WaveshareEPaper4P2InBV2::dump_config() { LOG_UPDATE_INTERVAL(this); } +// ======================================================== +// 4.20in Type B With Red colour support (LUT from OTP) +// Datasheet: +// - https://www.waveshare.com/w/upload/2/20/4.2inch-e-paper-module-user-manual-en.pdf +// - https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/c/lib/e-Paper/EPD_4in2b_V2.c +// The implementation is an adaptation of WaveshareEPaper4P2InBV2 class +// ======================================================== +void WaveshareEPaper4P2InBV2BWR::initialize() { + // these exact timings are required for a proper reset/init + this->reset_pin_->digital_write(false); + delay(2); + this->reset_pin_->digital_write(true); + delay(200); // NOLINT + + // COMMAND POWER ON + this->command(0x04); + this->wait_until_idle_(); + + // COMMAND PANEL SETTING + this->command(0x00); + this->data(0x0f); // LUT from OTP +} + +void HOT WaveshareEPaper4P2InBV2BWR::display() { + const uint32_t buf_len = this->get_buffer_length_() / 2u; + + this->command(0x10); // Send BW data Transmission + delay(2); // Delay to prevent Watchdog error + for (uint32_t i = 0; i < buf_len; ++i) { + this->data(this->buffer_[i]); + } + + this->command(0x13); // Send red data Transmission + delay(2); // Delay to prevent Watchdog error + for (uint32_t i = 0; i < buf_len; ++i) { + // Red color need to flip bit from the buffer. Otherwise, red will conqure the screen! + this->data(~this->buffer_[buf_len + i]); + } + + // COMMAND DISPLAY REFRESH + this->command(0x12); + this->wait_until_idle_(); + + // COMMAND POWER OFF + // NOTE: power off < deep sleep + this->command(0x02); +} +int WaveshareEPaper4P2InBV2BWR::get_width_internal() { return 400; } +int WaveshareEPaper4P2InBV2BWR::get_height_internal() { return 300; } +void WaveshareEPaper4P2InBV2BWR::dump_config() { + LOG_DISPLAY("", "Waveshare E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 4.2in (B V2) BWR-Mode"); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} + void WaveshareEPaper5P8In::initialize() { // COMMAND POWER SETTING this->command(0x01); diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 73090fa009..4d811228f1 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -518,6 +518,34 @@ class WaveshareEPaper4P2InBV2 : public WaveshareEPaper { int get_height_internal() override; }; +class WaveshareEPaper4P2InBV2BWR : public WaveshareEPaperBWR { + public: + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + // COMMAND VCOM AND DATA INTERVAL SETTING + this->command(0x50); + this->data(0xF7); // border floating + + // COMMAND POWER OFF + this->command(0x02); + this->wait_until_idle_(); + + // COMMAND DEEP SLEEP + this->command(0x07); + this->data(0xA5); // check code + } + + protected: + int get_width_internal() override; + + int get_height_internal() override; +}; + class WaveshareEPaper5P8In : public WaveshareEPaper { public: void initialize() override; diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index 667bbb1bb0..5889b4659e 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -502,6 +502,25 @@ display: lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + id: epd_4_20in_bv2_bwr + model: 4.20in-bv2-bwr + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + # 5.83 inch displays - platform: waveshare_epaper id: epd_5_83 From a2f1b902388f6d8c89b2f332199273e479beed65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Koek?= Date: Tue, 11 Feb 2025 23:16:33 +0000 Subject: [PATCH 23/79] Add GDEY029T94 support (#7931) Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 2 + .../waveshare_epaper/waveshare_epaper.cpp | 75 ++++++++++++++++++- .../waveshare_epaper/waveshare_epaper.h | 19 +++++ 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index f6e56c543d..7b51eb338c 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -52,6 +52,7 @@ WaveshareEPaper2P9InV2R2 = waveshare_epaper_ns.class_( "WaveshareEPaper2P9InV2R2", WaveshareEPaper ) GDEW029T5 = waveshare_epaper_ns.class_("GDEW029T5", WaveshareEPaper) +GDEY029T94 = waveshare_epaper_ns.class_("GDEY029T94", WaveshareEPaper) WaveshareEPaper2P9InDKE = waveshare_epaper_ns.class_( "WaveshareEPaper2P9InDKE", WaveshareEPaper ) @@ -136,6 +137,7 @@ MODELS = { "2.70inv2": ("b", WaveshareEPaper2P7InV2), "2.90in-b": ("b", WaveshareEPaper2P9InB), "2.90in-bv3": ("b", WaveshareEPaper2P9InBV3), + "gdey029t94": ("c", GDEY029T94), "2.90inv2-r2": ("c", WaveshareEPaper2P9InV2R2), "2.90in-d": ("b", WaveshareEPaper2P9InD), "2.90in-dke": ("c", WaveshareEPaper2P9InDKE), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index a4439e2d7d..1e8671bfa6 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -1677,9 +1677,82 @@ int WaveshareEPaper2P9InV2R2::get_width_controller() { return this->get_width_in void WaveshareEPaper2P9InV2R2::set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; } +// ======================================================== +// Good Display 2.9in black/white +// Datasheet: +// - https://files.seeedstudio.com/wiki/Other_Display/29-epaper/GDEY029T94.pdf +// - +// https://github.com/Allen-Kuang/e-ink_Demo/blob/main/2.9%20inch%20E-paper%20-%20monocolor%20128x296/example/Display_EPD_W21.cpp +// ======================================================== + +void GDEY029T94::initialize() { + // EPD hardware init start + this->reset_(); + + this->wait_until_idle_(); + this->command(0x12); // SWRESET + this->wait_until_idle_(); + + this->command(0x01); // Driver output control + this->data((this->get_height_internal() - 1) % 256); + this->data((this->get_height_internal() - 1) / 256); + this->data(0x00); + + this->command(0x11); // data entry mode + this->data(0x03); + + this->command(0x44); // set Ram-X address start/end position + this->data(0x00); + this->data(this->get_width_internal() / 8 - 1); + + this->command(0x45); // set Ram-Y address start/end position + this->data(0x00); + this->data(0x00); + this->data((this->get_height_internal() - 1) % 256); + this->data((this->get_height_internal() - 1) / 256); + + this->command(0x3C); // BorderWavefrom + this->data(0x05); + + this->command(0x21); // Display update control + this->data(0x00); + this->data(0x80); + + this->command(0x18); // Read built-in temperature sensor + this->data(0x80); + + this->command(0x4E); // set RAM x address count to 0; + this->data(0x00); + this->command(0x4F); // set RAM y address count to 0X199; + this->command(0x00); + this->command(0x00); + this->wait_until_idle_(); +} +void HOT GDEY029T94::display() { + this->command(0x24); // write RAM for black(0)/white (1) + this->start_data_(); + for (uint32_t i = 0; i < this->get_buffer_length_(); i++) { + this->write_byte(this->buffer_[i]); + } + this->end_data_(); + this->command(0x22); // Display Update Control + this->data(0xF7); + this->command(0x20); // Activate Display Update Sequence + this->wait_until_idle_(); +} +int GDEY029T94::get_width_internal() { return 128; } +int GDEY029T94::get_height_internal() { return 296; } +void GDEY029T94::dump_config() { + LOG_DISPLAY("", "E-Paper (Good Display)", this); + ESP_LOGCONFIG(TAG, " Model: 2.9in GDEY029T94"); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} // ======================================================== -// Good Display 2.9in black/white/grey +// Good Display 2.9in black/white // Datasheet: // - https://v4.cecdn.yun300.cn/100001_1909185148/SSD1680.pdf // - https://github.com/adafruit/Adafruit_EPD/blob/master/src/panels/ThinkInk_290_Grayscale4_T5.h diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 4d811228f1..54e7619ebc 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -277,6 +277,25 @@ class GDEW029T5 : public WaveshareEPaper { uint8_t *old_buffer_{nullptr}; }; +class GDEY029T94 : public WaveshareEPaper { + public: + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + this->command(0x10); // Enter deep sleep + this->data(0x01); + } + + protected: + int get_width_internal() override; + + int get_height_internal() override; +}; + class WaveshareEPaper2P7InV2 : public WaveshareEPaper { public: void initialize() override; From 88cfdc33d458475c4dc3fa67653f7abf355dd7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gr=C3=BCner?= Date: Wed, 12 Feb 2025 00:17:34 +0100 Subject: [PATCH 24/79] GDEY042T81 e-paper displays support (#8061) Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com> --- .../components/waveshare_epaper/display.py | 2 + .../waveshare_epaper/waveshare_epaper.cpp | 200 ++++++++++++++++++ .../waveshare_epaper/waveshare_epaper.h | 37 ++++ tests/components/waveshare_epaper/common.yaml | 20 ++ 4 files changed, 259 insertions(+) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 7b51eb338c..72823e4e36 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -56,6 +56,7 @@ GDEY029T94 = waveshare_epaper_ns.class_("GDEY029T94", WaveshareEPaper) WaveshareEPaper2P9InDKE = waveshare_epaper_ns.class_( "WaveshareEPaper2P9InDKE", WaveshareEPaper ) +GDEY042T81 = waveshare_epaper_ns.class_("GDEY042T81", WaveshareEPaper) WaveshareEPaper2P9InD = waveshare_epaper_ns.class_( "WaveshareEPaper2P9InD", WaveshareEPaper ) @@ -141,6 +142,7 @@ MODELS = { "2.90inv2-r2": ("c", WaveshareEPaper2P9InV2R2), "2.90in-d": ("b", WaveshareEPaper2P9InD), "2.90in-dke": ("c", WaveshareEPaper2P9InDKE), + "gdey042t81": ("c", GDEY042T81), "4.20in": ("b", WaveshareEPaper4P2In), "4.20in-bv2": ("b", WaveshareEPaper4P2InBV2), "4.20in-bv2-bwr": ("b", WaveshareEPaper4P2InBV2BWR), diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 1e8671bfa6..2a540a1b75 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -2169,6 +2169,206 @@ void GDEW0154M09::dump_config() { LOG_UPDATE_INTERVAL(this); } +// ======================================================== +// Good Display 4.2in black/white GDEY042T81 (SSD1683) +// Product page: +// - https://www.good-display.com/product/386.html +// Datasheet: +// - https://v4.cecdn.yun300.cn/100001_1909185148/GDEY042T81.pdf +// - https://v4.cecdn.yun300.cn/100001_1909185148/SSD1683.PDF +// Reference code from GoodDisplay: +// - https://www.good-display.com/companyfile/1572.html (2024-08-01 15:40:41) +// Other reference code: +// - https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp +// ======================================================== + +void GDEY042T81::initialize() { + this->init_display_(); + ESP_LOGD(TAG, "Initialization complete, set the display to deep sleep"); + this->deep_sleep(); +} + +// conflicting documentation / examples regarding reset timings +// https://v4.cecdn.yun300.cn/100001_1909185148/SSD1683.PDF -> 10ms +// GD sample code (Display_EPD_W21.cpp, see above) -> 10 ms +// https://v4.cecdn.yun300.cn/100001_1909185148/GDEY042T81.pdf (section 14.2) -> 0.2ms (200us) +// https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L351 +// -> 10ms +// 10 ms seems to work, so we use this +GDEY042T81::GDEY042T81() { this->reset_duration_ = 10; } + +void GDEY042T81::reset_() { + if (this->reset_pin_ != nullptr) { + this->reset_pin_->digital_write(false); + delay(reset_duration_); // NOLINT + this->reset_pin_->digital_write(true); + delay(reset_duration_); // NOLINT + } +} + +void GDEY042T81::init_display_() { + this->reset_(); + + this->wait_until_idle_(); + this->command(0x12); // SWRESET + this->wait_until_idle_(); + + // Specify number of lines for the driver: 300 (MUX 300) + // https://v4.cecdn.yun300.cn/100001_1909185148/SSD1683.PDF (section 8.1) + // https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L354 + this->command(0x01); // driver output control + this->data(0x2B); // (height - 1) % 256 + this->data(0x01); // (height - 1) / 256 + this->data(0x00); + + // https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L360 + this->command(0x3C); // BorderWaveform + this->data(0x01); + this->command(0x18); // Read built-in temperature sensor + this->data(0x80); + + // GD sample code (Display_EPD_W21.cpp@90ff) + this->command(0x11); // data entry mode + this->data(0x03); + // set windows (0,0,400,300) + this->command(0x44); // set Ram-X address start/end position + this->data(0); + this->data(0x31); // (width / 8 -1) + + this->command(0x45); // set Ram-y address start/end position + this->data(0); + this->data(0); + this->data(0x2B); // (height - 1) % 256 + this->data(0x01); // (height - 1) / 256 + + // set cursor (0,0) + this->command(0x4E); // set RAM x address count to 0; + this->data(0); + this->command(0x4F); // set RAM y address count to 0; + this->data(0); + this->data(0); + + this->wait_until_idle_(); +} + +// https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L366 +void GDEY042T81::update_full_() { + this->command(0x21); // display update control + this->data(0x40); // bypass RED as 0 + this->data(0x00); // single chip application + + // only ever do a fast update because slow updates are only relevant + // for lower operating temperatures + // see + // https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_290_GDEY029T94.h#L30 + // + // Should slow/fast updates be made configurable similar to how GxEPD2 does it? No idea if anyone would need it... + this->command(0x1A); // Write to temperature register + this->data(0x6E); + this->command(0x22); + this->data(0xd7); + + this->command(0x20); + this->wait_until_idle_(); +} + +// https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L389 +void GDEY042T81::update_part_() { + this->command(0x21); // display update control + this->data(0x00); // RED normal + this->data(0x00); // single chip application + + this->command(0x22); + this->data(0xfc); + + this->command(0x20); + this->wait_until_idle_(); +} + +void HOT GDEY042T81::display() { + ESP_LOGD(TAG, "Wake up the display"); + this->init_display_(); + + if (!this->wait_until_idle_()) { + this->status_set_warning(); + ESP_LOGE(TAG, "Failed to perform update, display is busy"); + return; + } + + // basic code structure copied from WaveshareEPaper2P9InV2R2 + if (this->full_update_every_ == 1) { + ESP_LOGD(TAG, "Full update"); + // do single full update + this->command(0x24); + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + // TurnOnDisplay + this->update_full_(); + return; + } + + // if (this->full_update_every_ == 1 || + if (this->at_update_ == 0) { + ESP_LOGD(TAG, "Update"); + // do base update + this->command(0x24); + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + this->command(0x26); + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + // TurnOnDisplay; + this->update_full_(); + } else { + // do partial update (full screen) + // no need to load a LUT for GoodDisplays as they seem to have the LUT onboard + // GD example code (Display_EPD_W21.cpp@283ff) + // + // not setting the BorderWaveform here again (contrary to the GD example) because according to + // https://github.com/ZinggJM/GxEPD2/blob/03d8e7a533c1493f762e392ead12f1bcb7fab8f9/src/gdey/GxEPD2_420_GDEY042T81.cpp#L358 + // it seems to be enough to set it during display initialization + ESP_LOGD(TAG, "Partial update"); + this->reset_(); + if (!this->wait_until_idle_()) { + this->status_set_warning(); + ESP_LOGE(TAG, "Failed to perform partial update, display is busy"); + return; + } + + this->command(0x24); + this->start_data_(); + this->write_array(this->buffer_, this->get_buffer_length_()); + this->end_data_(); + + // TurnOnDisplay + this->update_part_(); + } + + this->at_update_ = (this->at_update_ + 1) % this->full_update_every_; + this->wait_until_idle_(); + ESP_LOGD(TAG, "Set the display back to deep sleep"); + this->deep_sleep(); +} +void GDEY042T81::set_full_update_every(uint32_t full_update_every) { this->full_update_every_ = full_update_every; } +int GDEY042T81::get_width_internal() { return 400; } +int GDEY042T81::get_height_internal() { return 300; } +uint32_t GDEY042T81::idle_timeout_() { return 5000; } +void GDEY042T81::dump_config() { + LOG_DISPLAY("", "GoodDisplay E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 4.2in B/W GDEY042T81"); + ESP_LOGCONFIG(TAG, " Full Update Every: %" PRIu32, this->full_update_every_); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} + static const uint8_t LUT_VCOM_DC_4_2[] = { 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, 0x00, 0x17, 0x17, 0x00, 0x00, 0x02, 0x00, 0x0A, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 54e7619ebc..1e7cb6c6c7 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -466,6 +466,43 @@ class WaveshareEPaper2P9InD : public WaveshareEPaper { int get_height_internal() override; }; +class GDEY042T81 : public WaveshareEPaper { + public: + GDEY042T81(); + + void initialize() override; + + void display() override; + + void dump_config() override; + + void deep_sleep() override { + // COMMAND POWER OFF + this->command(0x22); + this->data(0x83); + this->command(0x20); + // COMMAND DEEP SLEEP + this->command(0x10); + this->data(0x01); + } + + void set_full_update_every(uint32_t full_update_every); + + protected: + uint32_t full_update_every_{30}; + uint32_t at_update_{0}; + + int get_width_internal() override; + int get_height_internal() override; + uint32_t idle_timeout_() override; + + private: + void reset_(); + void update_full_(); + void update_part_(); + void init_display_(); +}; + class WaveshareEPaper4P2In : public WaveshareEPaper { public: void initialize() override; diff --git a/tests/components/waveshare_epaper/common.yaml b/tests/components/waveshare_epaper/common.yaml index 5889b4659e..09ba1af778 100644 --- a/tests/components/waveshare_epaper/common.yaml +++ b/tests/components/waveshare_epaper/common.yaml @@ -463,6 +463,26 @@ display: lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height()); + - platform: waveshare_epaper + id: epd_gdew042t81 + model: gdey042t81 + spi_id: spi_waveshare_epaper + cs_pin: + allow_other_uses: true + number: ${cs_pin} + dc_pin: + allow_other_uses: true + number: ${dc_pin} + busy_pin: + allow_other_uses: true + number: ${busy_pin} + reset_pin: + allow_other_uses: true + number: ${reset_pin} + full_update_every: 30 + lambda: |- + it.rectangle(0, 0, it.get_width(), it.get_height()); + # 4.2 inch displays - platform: waveshare_epaper id: epd_4_20 From 7bb2c3c4968185d6cc4848986b0f3cdc71e7da5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Neil=20S=C3=A9gard?= <55683504+NeilSCGH@users.noreply.github.com> Date: Wed, 12 Feb 2025 00:31:56 +0100 Subject: [PATCH 25/79] Add support for Waveshare 7.3" ACeP 7-Color display (#6380) --- .../components/waveshare_epaper/display.py | 5 + .../waveshare_epaper/waveshare_213v3.cpp | 6 +- .../waveshare_epaper/waveshare_epaper.cpp | 311 +++++++++++++++++- .../waveshare_epaper/waveshare_epaper.h | 56 +++- 4 files changed, 369 insertions(+), 9 deletions(-) diff --git a/esphome/components/waveshare_epaper/display.py b/esphome/components/waveshare_epaper/display.py index 72823e4e36..8acb6ac68f 100644 --- a/esphome/components/waveshare_epaper/display.py +++ b/esphome/components/waveshare_epaper/display.py @@ -24,6 +24,7 @@ WaveshareEPaper = waveshare_epaper_ns.class_("WaveshareEPaper", WaveshareEPaperB WaveshareEPaperBWR = waveshare_epaper_ns.class_( "WaveshareEPaperBWR", WaveshareEPaperBase ) +WaveshareEPaper7C = waveshare_epaper_ns.class_("WaveshareEPaper7C", WaveshareEPaperBase) WaveshareEPaperTypeA = waveshare_epaper_ns.class_( "WaveshareEPaperTypeA", WaveshareEPaper ) @@ -75,6 +76,9 @@ WaveshareEPaper5P8In = waveshare_epaper_ns.class_( WaveshareEPaper5P8InV2 = waveshare_epaper_ns.class_( "WaveshareEPaper5P8InV2", WaveshareEPaper ) +WaveshareEPaper7P3InF = waveshare_epaper_ns.class_( + "WaveshareEPaper7P3InF", WaveshareEPaper7C +) WaveshareEPaper7P5In = waveshare_epaper_ns.class_( "WaveshareEPaper7P5In", WaveshareEPaper ) @@ -148,6 +152,7 @@ MODELS = { "4.20in-bv2-bwr": ("b", WaveshareEPaper4P2InBV2BWR), "5.83in": ("b", WaveshareEPaper5P8In), "5.83inv2": ("b", WaveshareEPaper5P8InV2), + "7.30in-f": ("b", WaveshareEPaper7P3InF), "7.50in": ("b", WaveshareEPaper7P5In), "7.50in-bv2": ("b", WaveshareEPaper7P5InBV2), "7.50in-bv3": ("b", WaveshareEPaper7P5InBV3), diff --git a/esphome/components/waveshare_epaper/waveshare_213v3.cpp b/esphome/components/waveshare_epaper/waveshare_213v3.cpp index 85d7033d4b..316cd80ccd 100644 --- a/esphome/components/waveshare_epaper/waveshare_213v3.cpp +++ b/esphome/components/waveshare_epaper/waveshare_213v3.cpp @@ -87,7 +87,11 @@ void WaveshareEPaper2P13InV3::send_reset_() { } void WaveshareEPaper2P13InV3::setup() { - setup_pins_(); + this->init_internal_(this->get_buffer_length_()); + this->setup_pins_(); + this->spi_setup(); + this->reset_(); + delay(20); this->send_reset_(); // as a one-off delay this is not worth working around. diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.cpp b/esphome/components/waveshare_epaper/waveshare_epaper.cpp index 2a540a1b75..96fc82fcdd 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.cpp +++ b/esphome/components/waveshare_epaper/waveshare_epaper.cpp @@ -3,6 +3,7 @@ #include "esphome/core/application.h" #include "esphome/core/helpers.h" #include +#include namespace esphome { namespace waveshare_epaper { @@ -110,8 +111,14 @@ static const uint8_t PARTIAL_UPD_2IN9_LUT[PARTIAL_UPD_2IN9_LUT_SIZE] = }; // clang-format on -void WaveshareEPaperBase::setup_pins_() { +void WaveshareEPaperBase::setup() { this->init_internal_(this->get_buffer_length_()); + this->setup_pins_(); + this->spi_setup(); + this->reset_(); + this->initialize(); +} +void WaveshareEPaperBase::setup_pins_() { this->dc_pin_->setup(); // OUTPUT this->dc_pin_->digital_write(false); if (this->reset_pin_ != nullptr) { @@ -121,9 +128,6 @@ void WaveshareEPaperBase::setup_pins_() { if (this->busy_pin_ != nullptr) { this->busy_pin_->setup(); // INPUT } - this->spi_setup(); - - this->reset_(); } float WaveshareEPaperBase::get_setup_priority() const { return setup_priority::PROCESSOR; } void WaveshareEPaperBase::command(uint8_t value) { @@ -173,6 +177,87 @@ void WaveshareEPaper::fill(Color color) { for (uint32_t i = 0; i < this->get_buffer_length_(); i++) this->buffer_[i] = fill; } +void WaveshareEPaper7C::setup() { + this->init_internal_7c_(this->get_buffer_length_()); + this->setup_pins_(); + this->spi_setup(); + this->reset_(); + this->initialize(); +} +void WaveshareEPaper7C::init_internal_7c_(uint32_t buffer_length) { + ExternalRAMAllocator allocator(ExternalRAMAllocator::ALLOW_FAILURE); + uint32_t small_buffer_length = buffer_length / NUM_BUFFERS; + + for (int i = 0; i < NUM_BUFFERS; i++) { + this->buffers_[i] = allocator.allocate(small_buffer_length); + if (this->buffers_[i] == nullptr) { + ESP_LOGE(TAG, "Could not allocate buffer %d for display!", i); + for (auto &buffer : this->buffers_) { + allocator.deallocate(buffer, small_buffer_length); + buffer = nullptr; + } + return; + } + } + this->clear(); +} +uint8_t WaveshareEPaper7C::color_to_hex(Color color) { + uint8_t hex_code; + if (color.red > 127) { + if (color.green > 170) { + if (color.blue > 127) { + hex_code = 0x1; // White + } else { + hex_code = 0x5; // Yellow + } + } else if (color.green > 85) { + hex_code = 0x6; // Orange + } else { + hex_code = 0x4; // Red (or Magenta) + } + } else { + if (color.green > 127) { + if (color.blue > 127) { + hex_code = 0x3; // Cyan -> Blue + } else { + hex_code = 0x2; // Green + } + } else { + if (color.blue > 127) { + hex_code = 0x3; // Blue + } else { + hex_code = 0x0; // Black + } + } + } + + return hex_code; +} +void WaveshareEPaper7C::fill(Color color) { + uint8_t pixel_color; + if (color.is_on()) { + pixel_color = this->color_to_hex(color); + } else { + pixel_color = 0x1; + } + + if (this->buffers_[0] == nullptr) { + ESP_LOGE(TAG, "Buffer unavailable!"); + } else { + uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS; + for (auto &buffer : this->buffers_) { + for (uint32_t buffer_pos = 0; buffer_pos < small_buffer_length; buffer_pos += 3) { + // We store 8 bitset<3> in 3 bytes + // | byte 1 | byte 2 | byte 3 | + // |aaabbbaa|abbbaaab|bbaaabbb| + buffer[buffer_pos + 0] = pixel_color << 5 | pixel_color << 2 | pixel_color >> 1; + buffer[buffer_pos + 1] = pixel_color << 7 | pixel_color << 4 | pixel_color << 1 | pixel_color >> 2; + buffer[buffer_pos + 2] = pixel_color << 6 | pixel_color << 3 | pixel_color << 0; + } + App.feed_wdt(); + } + } +} void HOT WaveshareEPaper::draw_absolute_pixel_internal(int x, int y, Color color) { if (x >= this->get_width_internal() || y >= this->get_height_internal() || x < 0 || y < 0) return; @@ -193,6 +278,9 @@ uint32_t WaveshareEPaper::get_buffer_length_() { uint32_t WaveshareEPaperBWR::get_buffer_length_() { return this->get_width_controller() * this->get_height_internal() / 4u; } // black and red buffer +uint32_t WaveshareEPaper7C::get_buffer_length_() { + return this->get_width_controller() * this->get_height_internal() / 8u * 3u; +} // 7 colors buffer, 1 pixel = 3 bits, we will store 8 pixels in 24 bits = 3 bytes void WaveshareEPaperBWR::fill(Color color) { this->filled_rectangle(0, 0, this->get_width(), this->get_height(), color); @@ -219,7 +307,33 @@ void HOT WaveshareEPaperBWR::draw_absolute_pixel_internal(int x, int y, Color co this->buffer_[pos + buf_half_len] &= ~(0x80 >> subpos); } } +void HOT WaveshareEPaper7C::draw_absolute_pixel_internal(int x, int y, Color color) { + if (x >= this->get_width_internal() || y >= this->get_height_internal() || x < 0 || y < 0) + return; + uint8_t pixel_bits = this->color_to_hex(color); + uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS; + uint32_t pixel_position = x + y * this->get_width_controller(); + uint32_t first_bit_position = pixel_position * 3; + uint32_t byte_position = first_bit_position / 8u; + uint32_t byte_subposition = first_bit_position % 8u; + uint32_t buffer_position = byte_position / small_buffer_length; + uint32_t buffer_subposition = byte_position % small_buffer_length; + + if (byte_subposition <= 5) { + this->buffers_[buffer_position][buffer_subposition] = + (this->buffers_[buffer_position][buffer_subposition] & (0xFF ^ (0b111 << (5 - byte_subposition)))) | + (pixel_bits << (5 - byte_subposition)); + } else { + this->buffers_[buffer_position][buffer_subposition + 0] = + (this->buffers_[buffer_position][buffer_subposition + 0] & (0xFF ^ (0b111 >> (byte_subposition - 5)))) | + (pixel_bits >> (byte_subposition - 5)); + + this->buffers_[buffer_position][buffer_subposition + 1] = (this->buffers_[buffer_position][buffer_subposition + 1] & + (0xFF ^ (0xFF & (0b111 << (13 - byte_subposition))))) | + (pixel_bits << (13 - byte_subposition)); + } +} void WaveshareEPaperBase::start_command_() { this->dc_pin_->digital_write(false); this->enable(); @@ -3193,6 +3307,195 @@ void WaveshareEPaper7P5In::dump_config() { LOG_PIN(" Busy Pin: ", this->busy_pin_); LOG_UPDATE_INTERVAL(this); } +void WaveshareEPaper7P3InF::initialize() { + if (this->buffers_[0] == nullptr) { + ESP_LOGE(TAG, "Buffer unavailable!"); + return; + } + + this->reset_(); + delay(20); + this->wait_until_idle_(); + + // COMMAND CMDH + this->command(0xAA); + this->data(0x49); + this->data(0x55); + this->data(0x20); + this->data(0x08); + this->data(0x09); + this->data(0x18); + + this->command(0x01); + this->data(0x3F); + this->data(0x00); + this->data(0x32); + this->data(0x2A); + this->data(0x0E); + this->data(0x2A); + + this->command(0x00); + this->data(0x5F); + this->data(0x69); + + this->command(0x03); + this->data(0x00); + this->data(0x54); + this->data(0x00); + this->data(0x44); + + this->command(0x05); + this->data(0x40); + this->data(0x1F); + this->data(0x1F); + this->data(0x2C); + + this->command(0x06); + this->data(0x6F); + this->data(0x1F); + this->data(0x1F); + this->data(0x22); + + this->command(0x08); + this->data(0x6F); + this->data(0x1F); + this->data(0x1F); + this->data(0x22); + + // COMMAND IPC + this->command(0x13); + this->data(0x00); + this->data(0x04); + + this->command(0x30); + this->data(0x3C); + + // COMMAND TSE + this->command(0x41); + this->data(0x00); + + this->command(0x50); + this->data(0x3F); + + this->command(0x60); + this->data(0x02); + this->data(0x00); + + this->command(0x61); + this->data(0x03); + this->data(0x20); + this->data(0x01); + this->data(0xE0); + + this->command(0x82); + this->data(0x1E); + + this->command(0x84); + this->data(0x00); + + // COMMAND AGID + this->command(0x86); + this->data(0x00); + + this->command(0xE3); + this->data(0x2F); + + // COMMAND CCSET + this->command(0xE0); + this->data(0x00); + + // COMMAND TSSET + this->command(0xE6); + this->data(0x00); + + ESP_LOGI(TAG, "Display initialized successfully"); +} +void HOT WaveshareEPaper7P3InF::display() { + if (this->buffers_[0] == nullptr) { + ESP_LOGE(TAG, "Buffer unavailable!"); + return; + } + + // INITIALIZATION + ESP_LOGI(TAG, "Initialise the display"); + this->initialize(); + + // COMMAND DATA START TRANSMISSION + ESP_LOGI(TAG, "Sending data to the display"); + this->command(0x10); + uint32_t small_buffer_length = this->get_buffer_length_() / NUM_BUFFERS; + uint8_t byte_to_send; + for (auto &buffer : this->buffers_) { + for (uint32_t buffer_pos = 0; buffer_pos < small_buffer_length; buffer_pos += 3) { + std::bitset<24> triplet = + buffer[buffer_pos + 0] << 16 | buffer[buffer_pos + 1] << 8 | buffer[buffer_pos + 2] << 0; + // 8 bitset<3> are stored in 3 bytes + // |aaabbbaa|abbbaaab|bbaaabbb| + // | byte 1 | byte 2 | byte 3 | + byte_to_send = ((triplet >> 17).to_ulong() & 0b01110000) | ((triplet >> 18).to_ulong() & 0b00000111); + this->data(byte_to_send); + + byte_to_send = ((triplet >> 11).to_ulong() & 0b01110000) | ((triplet >> 12).to_ulong() & 0b00000111); + this->data(byte_to_send); + + byte_to_send = ((triplet >> 5).to_ulong() & 0b01110000) | ((triplet >> 6).to_ulong() & 0b00000111); + this->data(byte_to_send); + + byte_to_send = ((triplet << 1).to_ulong() & 0b01110000) | ((triplet << 0).to_ulong() & 0b00000111); + this->data(byte_to_send); + } + App.feed_wdt(); + } + + // COMMAND POWER ON + ESP_LOGI(TAG, "Power on the display"); + this->command(0x04); + this->wait_until_idle_(); + + // COMMAND REFRESH SCREEN + ESP_LOGI(TAG, "Refresh the display"); + this->command(0x12); + this->data(0x00); + this->wait_until_idle_(); + + // COMMAND POWER OFF + ESP_LOGI(TAG, "Power off the display"); + this->command(0x02); + this->data(0x00); + this->wait_until_idle_(); + + ESP_LOGI(TAG, "Set the display to deep sleep"); + this->command(0x07); + this->data(0xA5); +} +int WaveshareEPaper7P3InF::get_width_internal() { return 800; } +int WaveshareEPaper7P3InF::get_height_internal() { return 480; } +uint32_t WaveshareEPaper7P3InF::idle_timeout_() { return 35000; } +void WaveshareEPaper7P3InF::dump_config() { + LOG_DISPLAY("", "Waveshare E-Paper", this); + ESP_LOGCONFIG(TAG, " Model: 7.3in-F"); + LOG_PIN(" Reset Pin: ", this->reset_pin_); + LOG_PIN(" DC Pin: ", this->dc_pin_); + LOG_PIN(" Busy Pin: ", this->busy_pin_); + LOG_UPDATE_INTERVAL(this); +} + +bool WaveshareEPaper7P3InF::wait_until_idle_() { + if (this->busy_pin_ == nullptr) { + return true; + } + const uint32_t start = millis(); + while (this->busy_pin_->digital_read()) { + if (millis() - start > this->idle_timeout_()) { + ESP_LOGE(TAG, "Timeout while displaying image!"); + return false; + } + App.feed_wdt(); + delay(10); + } + delay(200); // NOLINT + return true; +} bool WaveshareEPaper7P5InV2::wait_until_idle_() { if (this->busy_pin_ == nullptr) { return true; diff --git a/esphome/components/waveshare_epaper/waveshare_epaper.h b/esphome/components/waveshare_epaper/waveshare_epaper.h index 1e7cb6c6c7..d6387cd643 100644 --- a/esphome/components/waveshare_epaper/waveshare_epaper.h +++ b/esphome/components/waveshare_epaper/waveshare_epaper.h @@ -27,10 +27,7 @@ class WaveshareEPaperBase : public display::DisplayBuffer, void update() override; - void setup() override { - this->setup_pins_(); - this->initialize(); - } + void setup() override; void on_safe_shutdown() override; @@ -86,6 +83,23 @@ class WaveshareEPaperBWR : public WaveshareEPaperBase { uint32_t get_buffer_length_() override; }; +class WaveshareEPaper7C : public WaveshareEPaperBase { + public: + uint8_t color_to_hex(Color color); + void fill(Color color) override; + + display::DisplayType get_display_type() override { return display::DisplayType::DISPLAY_TYPE_COLOR; } + + protected: + void draw_absolute_pixel_internal(int x, int y, Color color) override; + uint32_t get_buffer_length_() override; + void setup() override; + void init_internal_7c_(uint32_t buffer_length); + + static const int NUM_BUFFERS = 10; + uint8_t *buffers_[NUM_BUFFERS]; +}; + enum WaveshareEPaperTypeAModel { WAVESHARE_EPAPER_1_54_IN = 0, WAVESHARE_EPAPER_1_54_IN_V2, @@ -160,6 +174,7 @@ enum WaveshareEPaperTypeBModel { WAVESHARE_EPAPER_2_7_IN_B_V2, WAVESHARE_EPAPER_4_2_IN, WAVESHARE_EPAPER_4_2_IN_B_V2, + WAVESHARE_EPAPER_7_3_IN_F, WAVESHARE_EPAPER_7_5_IN, WAVESHARE_EPAPER_7_5_INV2, WAVESHARE_EPAPER_7_5_IN_B_V2, @@ -668,6 +683,39 @@ class WaveshareEPaper5P8InV2 : public WaveshareEPaper { int get_height_internal() override; }; +class WaveshareEPaper7P3InF : public WaveshareEPaper7C { + public: + void initialize() override; + + void display() override; + + void dump_config() override; + + protected: + int get_width_internal() override; + + int get_height_internal() override; + + uint32_t idle_timeout_() override; + + void deep_sleep() override { ; } + + bool wait_until_idle_(); + + bool deep_sleep_between_updates_{true}; + + void reset_() { + if (this->reset_pin_ != nullptr) { + this->reset_pin_->digital_write(true); + delay(20); + this->reset_pin_->digital_write(false); + delay(1); + this->reset_pin_->digital_write(true); + delay(20); + } + }; +}; + class WaveshareEPaper7P5In : public WaveshareEPaper { public: void initialize() override; From 0b6c416680b24efb217d39a88d1bac5e6daed665 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:16:17 +1300 Subject: [PATCH 26/79] Bump esphome-dashboard to 20250212.0 (#8235) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0d93c3cc2d..bbf0ae7f3d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ pyserial==3.5 platformio==6.1.16 # When updating platformio, also update Dockerfile esptool==4.7.0 click==8.1.7 -esphome-dashboard==20241217.1 +esphome-dashboard==20250212.0 aioesphomeapi==24.6.2 zeroconf==0.143.0 puremagic==1.27 From 2b75e34719acfea017f436c63036050f1c9f3651 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:53:43 +1300 Subject: [PATCH 27/79] Bump version to 2025.2.0b1 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 16bfda9478..696cc599fc 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.0-dev" +__version__ = "2025.2.0b1" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From ab0d38fbdae7fe5f3d95cdf5c5675d8f6fee3deb Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:53:43 +1300 Subject: [PATCH 28/79] Bump version to 2025.3.0-dev --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 16bfda9478..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 = ( From 3b7a7a2262183682502e74b969b9d52938f93385 Mon Sep 17 00:00:00 2001 From: guillempages Date: Wed, 12 Feb 2025 10:55:32 +0100 Subject: [PATCH 29/79] [online_image]Fix reset if buffer not allocated (#8236) --- .../components/online_image/image_decoder.cpp | 11 +++++++---- esphome/components/online_image/jpeg_image.cpp | 6 ++++-- .../components/online_image/online_image.cpp | 15 ++++++++------- esphome/components/online_image/online_image.h | 17 +++++++++++++++-- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/esphome/components/online_image/image_decoder.cpp b/esphome/components/online_image/image_decoder.cpp index d8c0cc33c4..0ab7dadde3 100644 --- a/esphome/components/online_image/image_decoder.cpp +++ b/esphome/components/online_image/image_decoder.cpp @@ -9,10 +9,10 @@ namespace online_image { static const char *const TAG = "online_image.decoder"; bool ImageDecoder::set_size(int width, int height) { - bool resized = this->image_->resize_(width, 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 resized; + return success; } void ImageDecoder::draw(int x, int y, int w, int h, const Color &color) { @@ -51,8 +51,9 @@ size_t DownloadBuffer::read(size_t len) { } size_t DownloadBuffer::resize(size_t size) { - if (this->size_ == size) { - return 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); @@ -61,6 +62,8 @@ size_t DownloadBuffer::resize(size_t size) { 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; } diff --git a/esphome/components/online_image/jpeg_image.cpp b/esphome/components/online_image/jpeg_image.cpp index 0aff576da8..e5ee3dd8bf 100644 --- a/esphome/components/online_image/jpeg_image.cpp +++ b/esphome/components/online_image/jpeg_image.cpp @@ -58,7 +58,7 @@ int HOT JpegDecoder::decode(uint8_t *buffer, size_t size) { } if (!this->jpeg_.openRAM(buffer, size, draw_callback)) { - ESP_LOGE(TAG, "Could not open image for decoding."); + ESP_LOGE(TAG, "Could not open image for decoding: %d", this->jpeg_.getLastError()); return DECODE_ERROR_INVALID_TYPE; } auto jpeg_type = this->jpeg_.getJPEGType(); @@ -73,7 +73,9 @@ int HOT JpegDecoder::decode(uint8_t *buffer, size_t size) { this->jpeg_.setUserPointer(this); this->jpeg_.setPixelType(RGB8888); - this->set_size(this->jpeg_.getWidth(), this->jpeg_.getHeight()); + 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(); diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index 3b3d00a044..3411018901 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -64,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() { diff --git a/esphome/components/online_image/online_image.h b/esphome/components/online_image/online_image.h index 4abc047083..2d10e528b1 100644 --- a/esphome/components/online_image/online_image.h +++ b/esphome/components/online_image/online_image.h @@ -99,9 +99,22 @@ class OnlineImage : public PollingComponent, 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. From 43319d4c8aa0ec0a3718c5c01e6e2c383b7918b7 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:05:46 +1300 Subject: [PATCH 30/79] [core] Ignore dot-prefixed config entries when looking for target platform (#8240) --- esphome/core/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/core/config.py b/esphome/core/config.py index 7152414463..2077af02a7 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -217,6 +217,8 @@ def preload_core_config(config, result) -> str: target_platforms = [] for domain, _ in config.items(): + if domain.startswith("."): + continue if _is_target_platform(domain): target_platforms += [domain] From 4a95468fd26f5d4c30d43396b775644853776835 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 12 Feb 2025 19:17:00 -0600 Subject: [PATCH 31/79] Bump zeroconf to 0.144.1 (#8238) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index bbf0ae7f3d..8eca21c4bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ esptool==4.7.0 click==8.1.7 esphome-dashboard==20250212.0 aioesphomeapi==24.6.2 -zeroconf==0.143.0 +zeroconf==0.144.1 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import glyphsets==1.0.0 From 72f64618717e3e21d769d5d5940b423f97fdc1d9 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 13 Feb 2025 15:57:57 +1300 Subject: [PATCH 32/79] [core] Fix ``config_dir`` for dashboard (#8242) --- esphome/core/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index 2d856d99c5..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(os.path.abspath(self.config_path)) + return os.path.abspath(os.path.dirname(self.config_path)) @property def data_dir(self): From 2868210d463f81e5057cb42b5f8e75a145d24b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Poczkodi?= Date: Thu, 13 Feb 2025 04:07:14 +0100 Subject: [PATCH 33/79] [cse7766] Remove stream dependency (#7720) Co-authored-by: Keith Burzinski --- esphome/components/cse7766/cse7766.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) 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 } From e190ef9e9bf4d50f0c683e415c7a5e2abd0a2368 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Wed, 12 Feb 2025 21:37:29 -0600 Subject: [PATCH 34/79] [graph] Remove ``stream`` dependency (#8243) --- esphome/components/graph/graph.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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(); } From ace953bd501d299ec95f86432477fe0b47a26767 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Wed, 12 Feb 2025 22:34:16 -0600 Subject: [PATCH 35/79] [modbus_controller] Remove `stream` dependency (#8244) --- .../text_sensor/modbus_textsensor.cpp | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) 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 From fa029e8fc7b553472baf81a1b200fe138a9554a5 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Thu, 13 Feb 2025 01:40:02 -0600 Subject: [PATCH 36/79] [modbus_controller] Extend tests (#8245) --- .../components/modbus_controller/common.yaml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tests/components/modbus_controller/common.yaml b/tests/components/modbus_controller/common.yaml index 93d8391ff5..7fa9f8dae3 100644 --- a/tests/components/modbus_controller/common.yaml +++ b/tests/components/modbus_controller/common.yaml @@ -33,3 +33,73 @@ modbus_controller: 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 From 077ee5b7143d1ea033ec513f354b07e07be1b62c Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:05:46 +1300 Subject: [PATCH 37/79] [core] Ignore dot-prefixed config entries when looking for target platform (#8240) --- esphome/core/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/core/config.py b/esphome/core/config.py index 7152414463..2077af02a7 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -217,6 +217,8 @@ def preload_core_config(config, result) -> str: target_platforms = [] for domain, _ in config.items(): + if domain.startswith("."): + continue if _is_target_platform(domain): target_platforms += [domain] From c8e7e275a4bedde565867288416acb06bbe0cc51 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 12 Feb 2025 19:17:00 -0600 Subject: [PATCH 38/79] Bump zeroconf to 0.144.1 (#8238) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index bbf0ae7f3d..8eca21c4bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ esptool==4.7.0 click==8.1.7 esphome-dashboard==20250212.0 aioesphomeapi==24.6.2 -zeroconf==0.143.0 +zeroconf==0.144.1 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import glyphsets==1.0.0 From 4740f12ce8e5e6d63278496e3e8dc909d5a33ab3 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 13 Feb 2025 15:57:57 +1300 Subject: [PATCH 39/79] [core] Fix ``config_dir`` for dashboard (#8242) --- esphome/core/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index 2d856d99c5..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(os.path.abspath(self.config_path)) + return os.path.abspath(os.path.dirname(self.config_path)) @property def data_dir(self): From 35d303809e8d5b4ed11e0b6bc70065bf417aed75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Poczkodi?= Date: Thu, 13 Feb 2025 04:07:14 +0100 Subject: [PATCH 40/79] [cse7766] Remove stream dependency (#7720) Co-authored-by: Keith Burzinski --- esphome/components/cse7766/cse7766.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) 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 } From e9a537784e314484dff0e2bd32377177465c33fe Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Wed, 12 Feb 2025 21:37:29 -0600 Subject: [PATCH 41/79] [graph] Remove ``stream`` dependency (#8243) --- esphome/components/graph/graph.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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(); } From be5639faf1b34fccc0a99c77dabeb87417eb3332 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Wed, 12 Feb 2025 22:34:16 -0600 Subject: [PATCH 42/79] [modbus_controller] Remove `stream` dependency (#8244) --- .../text_sensor/modbus_textsensor.cpp | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) 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 From b0f6dd7d9c44690b8e33c87b63acd033a72dc233 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 13 Feb 2025 20:44:12 +1300 Subject: [PATCH 43/79] Bump version to 2025.2.0b2 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 696cc599fc..7390187d7e 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.0b1" +__version__ = "2025.2.0b2" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From 46b6dcdfbf63b660be98e4c6c8448e59b1fae153 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Thu, 13 Feb 2025 14:56:08 -0500 Subject: [PATCH 44/79] [logger] Fix bug causing global log level to be overwritten (#8248) --- esphome/components/logger/__init__.py | 4 ++-- esphome/components/logger/logger.cpp | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/esphome/components/logger/__init__.py b/esphome/components/logger/__init__.py index a89bf95c77..113f306327 100644 --- a/esphome/components/logger/__init__.py +++ b/esphome/components/logger/__init__.py @@ -247,8 +247,8 @@ 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])) cg.add_define("USE_LOGGER") this_severity = LOG_LEVEL_SEVERITY.index(level) diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index 79fc4cf499..57f0ba9f9a 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -102,9 +102,6 @@ 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. if (this->log_levels_.count(tag) != 0) return this->log_levels_[tag]; return this->current_level_; From 788c41e6f4365f4b3dd6b7fd28d245ac3007dbd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20M=C3=A1rai?= Date: Fri, 14 Feb 2025 01:15:01 +0100 Subject: [PATCH 45/79] Add support for the DAC on the S2 (#8030) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/esp32_dac/esp32_dac.cpp | 23 +++++++++++++++------- esphome/components/esp32_dac/esp32_dac.h | 8 ++++++++ esphome/components/esp32_dac/output.py | 20 +++++++++++++++---- 3 files changed, 40 insertions(+), 11 deletions(-) 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 From 143b0d3de429a0d9adca0f888829af56ab10904d Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 14 Feb 2025 14:27:11 +1300 Subject: [PATCH 46/79] Fix crash when storage file doesnt exist yet (#8249) --- esphome/dashboard/web_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 1111aa167f319bad7a778b54745cf495662e8138 Mon Sep 17 00:00:00 2001 From: guillempages Date: Wed, 12 Feb 2025 10:55:32 +0100 Subject: [PATCH 47/79] [online_image]Fix reset if buffer not allocated (#8236) --- .../components/online_image/image_decoder.cpp | 11 +++++++---- esphome/components/online_image/jpeg_image.cpp | 6 ++++-- .../components/online_image/online_image.cpp | 15 ++++++++------- esphome/components/online_image/online_image.h | 17 +++++++++++++++-- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/esphome/components/online_image/image_decoder.cpp b/esphome/components/online_image/image_decoder.cpp index d8c0cc33c4..0ab7dadde3 100644 --- a/esphome/components/online_image/image_decoder.cpp +++ b/esphome/components/online_image/image_decoder.cpp @@ -9,10 +9,10 @@ namespace online_image { static const char *const TAG = "online_image.decoder"; bool ImageDecoder::set_size(int width, int height) { - bool resized = this->image_->resize_(width, 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 resized; + return success; } void ImageDecoder::draw(int x, int y, int w, int h, const Color &color) { @@ -51,8 +51,9 @@ size_t DownloadBuffer::read(size_t len) { } size_t DownloadBuffer::resize(size_t size) { - if (this->size_ == size) { - return 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); @@ -61,6 +62,8 @@ size_t DownloadBuffer::resize(size_t size) { 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; } diff --git a/esphome/components/online_image/jpeg_image.cpp b/esphome/components/online_image/jpeg_image.cpp index 0aff576da8..e5ee3dd8bf 100644 --- a/esphome/components/online_image/jpeg_image.cpp +++ b/esphome/components/online_image/jpeg_image.cpp @@ -58,7 +58,7 @@ int HOT JpegDecoder::decode(uint8_t *buffer, size_t size) { } if (!this->jpeg_.openRAM(buffer, size, draw_callback)) { - ESP_LOGE(TAG, "Could not open image for decoding."); + ESP_LOGE(TAG, "Could not open image for decoding: %d", this->jpeg_.getLastError()); return DECODE_ERROR_INVALID_TYPE; } auto jpeg_type = this->jpeg_.getJPEGType(); @@ -73,7 +73,9 @@ int HOT JpegDecoder::decode(uint8_t *buffer, size_t size) { this->jpeg_.setUserPointer(this); this->jpeg_.setPixelType(RGB8888); - this->set_size(this->jpeg_.getWidth(), this->jpeg_.getHeight()); + 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(); diff --git a/esphome/components/online_image/online_image.cpp b/esphome/components/online_image/online_image.cpp index 3b3d00a044..3411018901 100644 --- a/esphome/components/online_image/online_image.cpp +++ b/esphome/components/online_image/online_image.cpp @@ -64,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() { diff --git a/esphome/components/online_image/online_image.h b/esphome/components/online_image/online_image.h index 4abc047083..2d10e528b1 100644 --- a/esphome/components/online_image/online_image.h +++ b/esphome/components/online_image/online_image.h @@ -99,9 +99,22 @@ class OnlineImage : public PollingComponent, 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. From 92ad6286aa0440292caac66eb9374474608bdd36 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Thu, 13 Feb 2025 14:56:08 -0500 Subject: [PATCH 48/79] [logger] Fix bug causing global log level to be overwritten (#8248) --- esphome/components/logger/__init__.py | 4 ++-- esphome/components/logger/logger.cpp | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/esphome/components/logger/__init__.py b/esphome/components/logger/__init__.py index a89bf95c77..113f306327 100644 --- a/esphome/components/logger/__init__.py +++ b/esphome/components/logger/__init__.py @@ -247,8 +247,8 @@ 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])) cg.add_define("USE_LOGGER") this_severity = LOG_LEVEL_SEVERITY.index(level) diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index 79fc4cf499..57f0ba9f9a 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -102,9 +102,6 @@ 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. if (this->log_levels_.count(tag) != 0) return this->log_levels_[tag]; return this->current_level_; From 6999cc0581ae1e69fbbaab8027e0e43d77670849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20M=C3=A1rai?= Date: Fri, 14 Feb 2025 01:15:01 +0100 Subject: [PATCH 49/79] Add support for the DAC on the S2 (#8030) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/esp32_dac/esp32_dac.cpp | 23 +++++++++++++++------- esphome/components/esp32_dac/esp32_dac.h | 8 ++++++++ esphome/components/esp32_dac/output.py | 20 +++++++++++++++---- 3 files changed, 40 insertions(+), 11 deletions(-) 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 From daa796003174623ab31532158c8d3d8ef484b9e5 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 14 Feb 2025 14:27:11 +1300 Subject: [PATCH 50/79] Fix crash when storage file doesnt exist yet (#8249) --- esphome/dashboard/web_server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From e17582544e51aad38233ae8e2f249572d91bfe54 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 14 Feb 2025 14:28:42 +1300 Subject: [PATCH 51/79] Bump version to 2025.2.0b3 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 7390187d7e..2f3854b8b3 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.0b2" +__version__ = "2025.2.0b3" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From 93c2878c213acb8cbb88f604b21abeb1302ab2ba Mon Sep 17 00:00:00 2001 From: Samuel Sieb Date: Sat, 15 Feb 2025 23:02:51 -0800 Subject: [PATCH 52/79] don't crash on null pages (#8254) Co-authored-by: Samuel Sieb --- esphome/components/display/display.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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; } From e21ef22706e5241a8c1cd3dc6b1583d3f061898d Mon Sep 17 00:00:00 2001 From: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> Date: Sun, 16 Feb 2025 20:09:42 +0100 Subject: [PATCH 53/79] [scd30] Increase minimal CONF_UPDATE_INTERVAL from 1 to 2 seconds (#8256) --- esphome/components/scd30/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) ), ), } From 2e66b3367258a1fd4cb02d46cdcbd32002498c06 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 16 Feb 2025 11:53:19 -0800 Subject: [PATCH 54/79] Bump zeroconf to 0.144.3 (#8253) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8eca21c4bb..bb5bc768e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ esptool==4.7.0 click==8.1.7 esphome-dashboard==20250212.0 aioesphomeapi==24.6.2 -zeroconf==0.144.1 +zeroconf==0.144.3 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import glyphsets==1.0.0 From a47e27885fe1c249f7594da8249d4f8d6891def2 Mon Sep 17 00:00:00 2001 From: Ali Jafri Date: Mon, 17 Feb 2025 03:35:54 +0530 Subject: [PATCH 55/79] DHT platform now supports modules with inbuilt external resistor (#8257) --- esphome/components/dht/dht.cpp | 3 ++- esphome/components/dht/sensor.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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, From a67b85eabf4f584ef4a7d136bee5f04421d8defe Mon Sep 17 00:00:00 2001 From: Samuel Sieb Date: Sat, 15 Feb 2025 23:02:51 -0800 Subject: [PATCH 56/79] don't crash on null pages (#8254) Co-authored-by: Samuel Sieb --- esphome/components/display/display.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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; } From c0804d665d5eed0e82474304c399b87b0a25e0ab Mon Sep 17 00:00:00 2001 From: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> Date: Sun, 16 Feb 2025 20:09:42 +0100 Subject: [PATCH 57/79] [scd30] Increase minimal CONF_UPDATE_INTERVAL from 1 to 2 seconds (#8256) --- esphome/components/scd30/sensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) ), ), } From e89603fe3b1b489b57ec91436d192ed651bb0048 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 16 Feb 2025 11:53:19 -0800 Subject: [PATCH 58/79] Bump zeroconf to 0.144.3 (#8253) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 8eca21c4bb..bb5bc768e1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ esptool==4.7.0 click==8.1.7 esphome-dashboard==20250212.0 aioesphomeapi==24.6.2 -zeroconf==0.144.1 +zeroconf==0.144.3 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import glyphsets==1.0.0 From 9ee5227fe05f8f91b9a907644dc0565136a3afdd Mon Sep 17 00:00:00 2001 From: Ali Jafri Date: Mon, 17 Feb 2025 03:35:54 +0530 Subject: [PATCH 59/79] DHT platform now supports modules with inbuilt external resistor (#8257) --- esphome/components/dht/dht.cpp | 3 ++- esphome/components/dht/sensor.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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, From 78b55e22ee4148d3769c50548d73e752b3765bb4 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:14:06 +1300 Subject: [PATCH 60/79] Bump version to 2025.2.0b4 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 2f3854b8b3..7c96e6eefb 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.0b3" +__version__ = "2025.2.0b4" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From 1eb658cc5b0c8bdae8c7601298714e60eef9c415 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 17 Feb 2025 15:48:24 -0600 Subject: [PATCH 61/79] Replace glyphsets with esphome_glyphsets (#8261) --- esphome/components/font/__init__.py | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/requirements.txt b/requirements.txt index bb5bc768e1..b3a48a0442 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ aioesphomeapi==24.6.2 zeroconf==0.144.3 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 From c21b8bd4172c6b4bd7468b5d9e74de85078fb7c8 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 17 Feb 2025 16:19:11 -0600 Subject: [PATCH 62/79] Switch to native arm runners for docker CI (#8262) --- .github/workflows/ci-docker.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 8de6191205..303a6a777f 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -33,11 +33,11 @@ concurrency: jobs: check-docker: name: Build docker containers - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - arch: [amd64, aarch64] + os: ["ubuntu-latest", "ubuntu-24.04-arm"] build_type: ["ha-addon", "docker", "lint"] steps: - uses: actions/checkout@v4.1.7 @@ -47,8 +47,6 @@ jobs: python-version: "3.9" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.9.0 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3.4.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 From 74f7197543e2792262507595b5eccfd8dc0b32f4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 17 Feb 2025 16:27:06 -0600 Subject: [PATCH 63/79] Bump aioesphomeapi to 29.1.0 (#8105) --- esphome/components/api/client.py | 11 ++++++++--- requirements.txt | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) 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/requirements.txt b/requirements.txt index b3a48a0442..c15dcbbbf7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ platformio==6.1.16 # When updating platformio, also update Dockerfile esptool==4.7.0 click==8.1.7 esphome-dashboard==20250212.0 -aioesphomeapi==24.6.2 +aioesphomeapi==29.1.0 zeroconf==0.144.3 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import From f9da8dbfb85e329be30dfcf02bfc6431ef1fa81c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 17 Feb 2025 15:48:24 -0600 Subject: [PATCH 64/79] Replace glyphsets with esphome_glyphsets (#8261) --- esphome/components/font/__init__.py | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/requirements.txt b/requirements.txt index bb5bc768e1..b3a48a0442 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ aioesphomeapi==24.6.2 zeroconf==0.144.3 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 From 64c8bcef2e562ebdb2d398d5c66c80c417b8129f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 17 Feb 2025 16:27:06 -0600 Subject: [PATCH 65/79] Bump aioesphomeapi to 29.1.0 (#8105) --- esphome/components/api/client.py | 11 ++++++++--- requirements.txt | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) 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/requirements.txt b/requirements.txt index b3a48a0442..c15dcbbbf7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ platformio==6.1.16 # When updating platformio, also update Dockerfile esptool==4.7.0 click==8.1.7 esphome-dashboard==20250212.0 -aioesphomeapi==24.6.2 +aioesphomeapi==29.1.0 zeroconf==0.144.3 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import From 6583e178107e63446ad9a21b3ebf82b7533d8c93 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:39:42 +1300 Subject: [PATCH 66/79] Bump version to 2025.2.0b5 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 7c96e6eefb..7f576fce67 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.0b4" +__version__ = "2025.2.0b5" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From abbd72e8028d8fdfdd5caf3fd46023d19ce0dea4 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 18 Feb 2025 11:10:33 -0600 Subject: [PATCH 67/79] Use the process CPU count to determine how many children to create (#8268) --- esphome/core/config.py | 16 ++++++++++++---- script/clang-format | 22 +++++++++++++++------- script/clang-tidy | 4 ++-- script/helpers.py | 11 +++++++++++ 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/esphome/core/config.py b/esphome/core/config.py index 2077af02a7..359b78acf1 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -1,5 +1,4 @@ import logging -import multiprocessing import os from pathlib import Path @@ -94,10 +93,19 @@ 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 @@ -156,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, 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() + ) From 56034e3e79331e9b38db5f4a733486929da753c3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 18 Feb 2025 11:11:58 -0600 Subject: [PATCH 68/79] Bump openssh-client to 1:9.2p1-2+deb12u4 to fix docker builds (#8269) --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1db1ee7b51..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 \ From b3db04a3d300838c1a3154eed77dc6220d5655eb Mon Sep 17 00:00:00 2001 From: G-Two <7310260+G-Two@users.noreply.github.com> Date: Tue, 18 Feb 2025 12:30:03 -0500 Subject: [PATCH 69/79] Increase default repeat delay for Toto remote transmitter protocol (#8265) --- esphome/components/remote_base/toto_protocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/remote_base/toto_protocol.h b/esphome/components/remote_base/toto_protocol.h index e62714bbbf..6a635b0f7c 100644 --- a/esphome/components/remote_base/toto_protocol.h +++ b/esphome/components/remote_base/toto_protocol.h @@ -36,7 +36,7 @@ template class TotoAction : public RemoteTransmitterActionBaserc_code_2_.value(x...); data.command = this->command_.value(x...); this->set_send_times(this->send_times_.value_or(x..., 3)); - this->set_send_wait(this->send_wait_.value_or(x..., 32000)); + this->set_send_wait(this->send_wait_.value_or(x..., 36000)); TotoProtocol().encode(dst, data); } }; From 02bf33c54887103ec957a78245d5a41f66151212 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 18 Feb 2025 11:38:41 -0600 Subject: [PATCH 70/79] Bump zeroconf to 0.145.1 (#8267) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c15dcbbbf7..1de6e3dd06 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ esptool==4.7.0 click==8.1.7 esphome-dashboard==20250212.0 aioesphomeapi==29.1.0 -zeroconf==0.144.3 +zeroconf==0.145.1 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import esphome-glyphsets==0.1.0 From d9b419eaf543e2a51674c3eb61d87b84d04eb172 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 18 Feb 2025 11:11:58 -0600 Subject: [PATCH 71/79] Bump openssh-client to 1:9.2p1-2+deb12u4 to fix docker builds (#8269) --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1db1ee7b51..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 \ From a973adda67ab9ed8df5dabf3e314745d0b0dec99 Mon Sep 17 00:00:00 2001 From: G-Two <7310260+G-Two@users.noreply.github.com> Date: Tue, 18 Feb 2025 12:30:03 -0500 Subject: [PATCH 72/79] Increase default repeat delay for Toto remote transmitter protocol (#8265) --- esphome/components/remote_base/toto_protocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/remote_base/toto_protocol.h b/esphome/components/remote_base/toto_protocol.h index e62714bbbf..6a635b0f7c 100644 --- a/esphome/components/remote_base/toto_protocol.h +++ b/esphome/components/remote_base/toto_protocol.h @@ -36,7 +36,7 @@ template class TotoAction : public RemoteTransmitterActionBaserc_code_2_.value(x...); data.command = this->command_.value(x...); this->set_send_times(this->send_times_.value_or(x..., 3)); - this->set_send_wait(this->send_wait_.value_or(x..., 32000)); + this->set_send_wait(this->send_wait_.value_or(x..., 36000)); TotoProtocol().encode(dst, data); } }; From c5ebf7683e06ac9bf8c9a5aaa7da47da6bffde8a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 18 Feb 2025 11:38:41 -0600 Subject: [PATCH 73/79] Bump zeroconf to 0.145.1 (#8267) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c15dcbbbf7..1de6e3dd06 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ esptool==4.7.0 click==8.1.7 esphome-dashboard==20250212.0 aioesphomeapi==29.1.0 -zeroconf==0.144.3 +zeroconf==0.145.1 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import esphome-glyphsets==0.1.0 From 4d380214df3bf0f3554bb24bf4f4c9d8a15daef8 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 19 Feb 2025 09:22:52 +1300 Subject: [PATCH 74/79] Bump version to 2025.2.0b6 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 7f576fce67..fe4ed20c57 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.0b5" +__version__ = "2025.2.0b6" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From 7006bd24a5b85ff4bd93e7218dbf230b2fe0a991 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 23:23:56 +0000 Subject: [PATCH 75/79] Bump actions/cache from 4.2.0 to 4.2.1 in /.github/actions/restore-python (#8273) --- .github/actions/restore-python/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/restore-python/action.yml b/.github/actions/restore-python/action.yml index e95eb6331f..c53e64a7b9 100644 --- a/.github/actions/restore-python/action.yml +++ b/.github/actions/restore-python/action.yml @@ -22,7 +22,7 @@ runs: 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 From ba79e2d7b1216aed0ca2c0f0a9d113077720992b Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:40:15 +1300 Subject: [PATCH 76/79] Bump version to 2025.2.0 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index fe4ed20c57..9f765dbf81 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.2.0b6" +__version__ = "2025.2.0" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From 7529fb10b462c4d9c75b68942746f4052dfda570 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Feb 2025 16:46:22 +1300 Subject: [PATCH 77/79] Bump actions/cache from 4.2.0 to 4.2.1 (#8271) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab77db5ca5..bd79356b3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: 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 @@ -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 }} From 302008356471506fdd37d9a0cbe2548642cbaa15 Mon Sep 17 00:00:00 2001 From: Katherine Whitlock Date: Wed, 19 Feb 2025 14:24:43 -0500 Subject: [PATCH 78/79] Ruff format for CI (#8276) --- .github/workflows/ci.yml | 12 ++++---- .pre-commit-config.yaml | 2 +- esphome/__main__.py | 2 +- esphome/components/climate/__init__.py | 1 - .../components/esp32_ble_beacon/__init__.py | 4 ++- esphome/components/esp8266/gpio.py | 3 +- esphome/components/haier/climate.py | 23 +++++++------- esphome/components/mqtt/__init__.py | 4 +-- .../components/nfc/binary_sensor/__init__.py | 8 ++--- .../opentherm/binary_sensor/__init__.py | 8 ++--- esphome/components/opentherm/generate.py | 12 ++++---- .../components/opentherm/sensor/__init__.py | 11 ++++--- esphome/components/pn532/binary_sensor.py | 8 ++--- esphome/components/rc522/binary_sensor.py | 8 ++--- esphome/components/thermostat/climate.py | 2 +- esphome/config_validation.py | 3 +- esphome/cpp_generator.py | 6 ++-- esphome/wizard.py | 30 ++++++++----------- esphome/writer.py | 4 +-- requirements_test.txt | 2 +- tests/unit_tests/test_cpp_generator.py | 9 ++---- 21 files changed, 75 insertions(+), 87 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd79356b3c..59dc31e9f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -482,7 +482,7 @@ jobs: runs-on: ubuntu-24.04 needs: - common - - black + - ruff - ci-custom - clang-format - flake8 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 212d822ff8..667a8f2e8b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ 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 diff --git a/esphome/__main__.py b/esphome/__main__.py index 2a0bd8f2b3..770c1a8fcf 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -66,7 +66,7 @@ def choose_prompt(options, purpose: str = None): return options[0][1] safe_print( - f'Found multiple options{f" for {purpose}" if purpose else ""}, please choose one:' + f"Found multiple options{f' for {purpose}' if purpose else ''}, please choose one:" ) for i, (desc, _) in enumerate(options): safe_print(f" [{i + 1}] {desc}") diff --git a/esphome/components/climate/__init__.py b/esphome/components/climate/__init__.py index aa705e7332..445507c620 100644 --- a/esphome/components/climate/__init__.py +++ b/esphome/components/climate/__init__.py @@ -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/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/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/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/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/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/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/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/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/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/config_validation.py b/esphome/config_validation.py index 27d11e4ded..9f7ce4d2e3 100644 --- a/esphome/config_validation.py +++ b/esphome/config_validation.py @@ -1223,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/cpp_generator.py b/esphome/cpp_generator.py index 4e283868e1..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) 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/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/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): From bf739506c352fd24881f32aa79fef6a2e81298a8 Mon Sep 17 00:00:00 2001 From: Hareesh M U Date: Thu, 20 Feb 2025 14:46:08 +0530 Subject: [PATCH 79/79] [ld2450] Add new component (#5674) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Co-authored-by: Marcus Better Co-authored-by: Trevor Schirmer <24777085+TrevorSchirmer@users.noreply.github.com> Co-authored-by: Keith Burzinski --- CODEOWNERS | 1 + esphome/components/ld2450/__init__.py | 51 ++ esphome/components/ld2450/binary_sensor.py | 47 + esphome/components/ld2450/button/__init__.py | 45 + .../components/ld2450/button/reset_button.cpp | 9 + .../components/ld2450/button/reset_button.h | 18 + .../ld2450/button/restart_button.cpp | 9 + .../components/ld2450/button/restart_button.h | 18 + esphome/components/ld2450/ld2450.cpp | 867 ++++++++++++++++++ esphome/components/ld2450/ld2450.h | 231 +++++ esphome/components/ld2450/number/__init__.py | 120 +++ .../ld2450/number/presence_timeout_number.cpp | 12 + .../ld2450/number/presence_timeout_number.h | 18 + .../ld2450/number/zone_coordinate_number.cpp | 14 + .../ld2450/number/zone_coordinate_number.h | 19 + esphome/components/ld2450/select/__init__.py | 56 ++ .../ld2450/select/baud_rate_select.cpp | 12 + .../ld2450/select/baud_rate_select.h | 18 + .../ld2450/select/zone_type_select.cpp | 12 + .../ld2450/select/zone_type_select.h | 18 + esphome/components/ld2450/sensor.py | 156 ++++ esphome/components/ld2450/switch/__init__.py | 45 + .../ld2450/switch/bluetooth_switch.cpp | 12 + .../ld2450/switch/bluetooth_switch.h | 18 + .../ld2450/switch/multi_target_switch.cpp | 12 + .../ld2450/switch/multi_target_switch.h | 18 + esphome/components/ld2450/text_sensor.py | 62 ++ tests/components/ld2450/common.yaml | 168 ++++ tests/components/ld2450/test.esp32-ard.yaml | 5 + .../components/ld2450/test.esp32-c3-ard.yaml | 5 + .../components/ld2450/test.esp32-c3-idf.yaml | 5 + tests/components/ld2450/test.esp32-idf.yaml | 5 + tests/components/ld2450/test.esp8266-ard.yaml | 5 + tests/components/ld2450/test.rp2040-ard.yaml | 5 + 34 files changed, 2116 insertions(+) create mode 100644 esphome/components/ld2450/__init__.py create mode 100644 esphome/components/ld2450/binary_sensor.py create mode 100644 esphome/components/ld2450/button/__init__.py create mode 100644 esphome/components/ld2450/button/reset_button.cpp create mode 100644 esphome/components/ld2450/button/reset_button.h create mode 100644 esphome/components/ld2450/button/restart_button.cpp create mode 100644 esphome/components/ld2450/button/restart_button.h create mode 100644 esphome/components/ld2450/ld2450.cpp create mode 100644 esphome/components/ld2450/ld2450.h create mode 100644 esphome/components/ld2450/number/__init__.py create mode 100644 esphome/components/ld2450/number/presence_timeout_number.cpp create mode 100644 esphome/components/ld2450/number/presence_timeout_number.h create mode 100644 esphome/components/ld2450/number/zone_coordinate_number.cpp create mode 100644 esphome/components/ld2450/number/zone_coordinate_number.h create mode 100644 esphome/components/ld2450/select/__init__.py create mode 100644 esphome/components/ld2450/select/baud_rate_select.cpp create mode 100644 esphome/components/ld2450/select/baud_rate_select.h create mode 100644 esphome/components/ld2450/select/zone_type_select.cpp create mode 100644 esphome/components/ld2450/select/zone_type_select.h create mode 100644 esphome/components/ld2450/sensor.py create mode 100644 esphome/components/ld2450/switch/__init__.py create mode 100644 esphome/components/ld2450/switch/bluetooth_switch.cpp create mode 100644 esphome/components/ld2450/switch/bluetooth_switch.h create mode 100644 esphome/components/ld2450/switch/multi_target_switch.cpp create mode 100644 esphome/components/ld2450/switch/multi_target_switch.h create mode 100644 esphome/components/ld2450/text_sensor.py create mode 100644 tests/components/ld2450/common.yaml create mode 100644 tests/components/ld2450/test.esp32-ard.yaml create mode 100644 tests/components/ld2450/test.esp32-c3-ard.yaml create mode 100644 tests/components/ld2450/test.esp32-c3-idf.yaml create mode 100644 tests/components/ld2450/test.esp32-idf.yaml create mode 100644 tests/components/ld2450/test.esp8266-ard.yaml create mode 100644 tests/components/ld2450/test.rp2040-ard.yaml diff --git a/CODEOWNERS b/CODEOWNERS index 26e36befe5..c725c2e736 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -234,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 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/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