1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 03:12:20 +01:00

Proposal: Test yaml for each component (#5398)

* Test for each component.

* When possible use commandline substitution.

* Add wildcard support.

* end file with new line.

* Move component tests into subfolder.

* Add component test to pipeline.

* Remove trailing whitespace.

* add restore python step.

* Add `. venv/bin/activate` to pipeline.

* step `changed-components` needs `common` step.

* start `list-components-changed.py` different.

* iterate on pipeline stage `list-components`.

* Update `checkout` action.

* Rename test folder from `tests` to `_test`.

* validate file exists.

* Move component test folder.

* extend list-components to include child components.

* File does not end with a newline

* Handle empty list-components matrix.

* list-components also check for changes in tests folder.

* Improve `list-components.py`.

* `*` is a forbidden character for filenames on windows.

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
This commit is contained in:
Fabian
2024-01-18 08:13:40 +01:00
committed by GitHub
parent c9c8d39778
commit c6f528583b
23 changed files with 687 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
sensor:
- platform: adc
id: my_sensor
pin: 4
attenuation: 11db

View File

@@ -0,0 +1,11 @@
sensor:
- platform: adc
pin: A0
name: Living Room Brightness
update_interval: "1:01"
attenuation: 2.5db
unit_of_measurement: "°C"
icon: "mdi:water-percent"
accuracy_decimals: 5
setup_priority: -100
force_update: true

View File

@@ -0,0 +1,5 @@
sensor:
- platform: adc
id: my_sensor
pin: 1
attenuation: 11db

View File

@@ -0,0 +1,5 @@
sensor:
- platform: adc
id: my_sensor
pin: 1
attenuation: 11db

View File

@@ -0,0 +1,11 @@
sensor:
- platform: adc
pin: A0
name: Living Room Brightness
update_interval: "1:01"
attenuation: 2.5db
unit_of_measurement: "°C"
icon: "mdi:water-percent"
accuracy_decimals: 5
setup_priority: -100
force_update: true

View File

@@ -0,0 +1,4 @@
sensor:
- platform: adc
id: my_sensor
pin: VCC

View File

@@ -0,0 +1,4 @@
sensor:
- platform: adc
pin: VCC
name: VSYS

View File

@@ -0,0 +1,16 @@
esp32_ble_tracker:
sensor:
# Example using 11kg 100% propane tank.
- platform: mopeka_std_check
mac_address: D3:75:F2:DC:16:91
tank_type: Europe_11kg
temperature:
name: "Propane test temp"
level:
name: "Propane test level"
distance:
name: "Propane test distance"
battery_level:
name: "Propane test battery level"

View File

@@ -0,0 +1,127 @@
sensor:
- platform: template
name: "Template Sensor"
id: template_sens
lambda: |-
if (id(some_binary_sensor).state) {
return 42.0;
} else {
return 0.0;
}
update_interval: 60s
esphome:
on_boot:
- sensor.template.publish:
id: template_sens
state: 42.0
# Templated
- sensor.template.publish:
id: template_sens
state: !lambda 'return 42.0;'
binary_sensor:
- platform: template
id: some_binary_sensor
name: "Garage Door Open"
lambda: |-
if (id(template_sens).state > 30) {
// Garage Door is open.
return true;
} else {
// Garage Door is closed.
return false;
}
output:
- platform: template
id: outputsplit
type: float
write_action:
- logger.log: "write_action"
switch:
- platform: template
name: "Template Switch"
lambda: |-
if (id(some_binary_sensor).state) {
return true;
} else {
return false;
}
turn_on_action:
- logger.log: "turn_on_action"
turn_off_action:
- logger.log: "turn_off_action"
button:
- platform: template
name: "Template Button"
on_press:
- logger.log: Button Pressed
cover:
- platform: template
name: "Template Cover"
lambda: |-
if (id(some_binary_sensor).state) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- logger.log: open_action
close_action:
- logger.log: close_action
stop_action:
- logger.log: stop_action
optimistic: true
number:
- platform: template
name: "Template number"
optimistic: true
min_value: 0
max_value: 100
step: 1
select:
- platform: template
name: "Template select"
optimistic: true
options:
- one
- two
- three
initial_option: two
lock:
- platform: template
name: "Template Lock"
lambda: |-
if (id(some_binary_sensor).state) {
return LOCK_STATE_LOCKED;
} else {
return LOCK_STATE_UNLOCKED;
}
lock_action:
- logger.log: lock_action
unlock_action:
- logger.log: unlock_action
open_action:
- logger.log: open_action
text:
- platform: template
name: "Template text"
optimistic: true
min_length: 0
max_length: 100
mode: text
alarm_control_panel:
- platform: template
name: Alarm Panel
codes:
- "1234"

View File

@@ -0,0 +1,20 @@
esphome:
name: componenttestesp32ard
friendly_name: $component_name
esp32:
board: nodemcu-32s
framework:
type: arduino
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file

View File

@@ -0,0 +1,20 @@
esphome:
name: componenttestesp32c3ard
friendly_name: $component_name
esp32:
board: lolin_c3_mini
framework:
type: arduino
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file

View File

@@ -0,0 +1,20 @@
esphome:
name: componenttestesp32c3idf
friendly_name: $component_name
esp32:
board: lolin_c3_mini
framework:
type: esp-idf
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file

View File

@@ -0,0 +1,20 @@
esphome:
name: componenttestesp32idf
friendly_name: $component_name
esp32:
board: nodemcu-32s
framework:
type: esp-idf
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file

View File

@@ -0,0 +1,21 @@
esphome:
name: componenttestesp32s2ard
friendly_name: $component_name
esp32:
board: esp32-s2-saola-1
variant: ESP32S2
framework:
type: arduino
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file

View File

@@ -0,0 +1,21 @@
esphome:
name: componenttestesp32s2ard
friendly_name: $component_name
esp32:
board: esp32-s2-saola-1
variant: ESP32S2
framework:
type: esp-idf
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file

View File

@@ -0,0 +1,21 @@
esphome:
name: componenttestesp32s3ard
friendly_name: $component_name
esp32:
board: esp32s3box
variant: ESP32S3
framework:
type: arduino
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file

View File

@@ -0,0 +1,21 @@
esphome:
name: componenttestesp32s3ard
friendly_name: $component_name
esp32:
board: esp32s3box
variant: ESP32S3
framework:
type: esp-idf
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file

View File

@@ -0,0 +1,18 @@
esphome:
name: componenttestesp8266
friendly_name: $component_name
esp8266:
board: d1_mini
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file

View File

@@ -0,0 +1,21 @@
esphome:
name: componenttestrp2040
friendly_name: $component_name
rp2040:
board: rpipicow
framework:
# Waiting for https://github.com/platformio/platform-raspberrypi/pull/36
platform_version: https://github.com/maxgerhardt/platform-raspberrypi.git
logger:
level: VERY_VERBOSE
packages:
component_under_test: !include
file: $component_test_file
vars:
component_name: $component_name
test_name: $test_name
target_platform: $target_platform
component_test_file: $component_test_file