mirror of
https://github.com/esphome/esphome.git
synced 2025-10-26 20:53:50 +00:00
fix flakey test
This commit is contained in:
@@ -33,31 +33,52 @@ sensor:
|
|||||||
send_every: 5
|
send_every: 5
|
||||||
send_first_at: 1
|
send_first_at: 1
|
||||||
|
|
||||||
|
script:
|
||||||
|
- id: publish_nan_values_script
|
||||||
|
then:
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_nan_sensor
|
||||||
|
state: 10.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_nan_sensor
|
||||||
|
state: !lambda 'return NAN;'
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_nan_sensor
|
||||||
|
state: 5.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_nan_sensor
|
||||||
|
state: !lambda 'return NAN;'
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_nan_sensor
|
||||||
|
state: 15.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_nan_sensor
|
||||||
|
state: 8.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_nan_sensor
|
||||||
|
state: !lambda 'return NAN;'
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_nan_sensor
|
||||||
|
state: 12.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_nan_sensor
|
||||||
|
state: 3.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_nan_sensor
|
||||||
|
state: !lambda 'return NAN;'
|
||||||
|
|
||||||
button:
|
button:
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Publish NaN Values Button"
|
name: "Publish NaN Values Button"
|
||||||
id: publish_nan_button
|
id: publish_nan_button
|
||||||
on_press:
|
on_press:
|
||||||
- lambda: |-
|
- script.execute: publish_nan_values_script
|
||||||
// Publish 10 values with NaN mixed in: 10, NaN, 5, NaN, 15, 8, NaN, 12, 3, NaN
|
|
||||||
// Small delay to ensure API can process each state update
|
|
||||||
id(source_nan_sensor).publish_state(10.0);
|
|
||||||
delay(10);
|
|
||||||
id(source_nan_sensor).publish_state(NAN);
|
|
||||||
delay(10);
|
|
||||||
id(source_nan_sensor).publish_state(5.0);
|
|
||||||
delay(10);
|
|
||||||
id(source_nan_sensor).publish_state(NAN);
|
|
||||||
delay(10);
|
|
||||||
id(source_nan_sensor).publish_state(15.0);
|
|
||||||
delay(10);
|
|
||||||
id(source_nan_sensor).publish_state(8.0);
|
|
||||||
delay(10);
|
|
||||||
id(source_nan_sensor).publish_state(NAN);
|
|
||||||
delay(10);
|
|
||||||
id(source_nan_sensor).publish_state(12.0);
|
|
||||||
delay(10);
|
|
||||||
id(source_nan_sensor).publish_state(3.0);
|
|
||||||
delay(10);
|
|
||||||
id(source_nan_sensor).publish_state(NAN);
|
|
||||||
delay(10);
|
|
||||||
|
|||||||
@@ -57,21 +57,59 @@ sensor:
|
|||||||
send_first_at: 1
|
send_first_at: 1
|
||||||
|
|
||||||
# Button to trigger publishing test values
|
# Button to trigger publishing test values
|
||||||
|
script:
|
||||||
|
- id: publish_values_script
|
||||||
|
then:
|
||||||
|
# Publish 10 values: 1.0, 2.0, ..., 10.0
|
||||||
|
# With window_size=5, send_every=2, send_first_at=1:
|
||||||
|
# - Output at position 1: window=[1], min=1, max=1, median=1, avg=1
|
||||||
|
# - Output at position 3: window=[1,2,3], min=1, max=3, median=2, avg=2
|
||||||
|
# - Output at position 5: window=[1,2,3,4,5], min=1, max=5, median=3, avg=3
|
||||||
|
# - Output at position 7: window=[3,4,5,6,7], min=3, max=7, median=5, avg=5
|
||||||
|
# - Output at position 9: window=[5,6,7,8,9], min=5, max=9, median=7, avg=7
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 1.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 2.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 3.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 4.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 5.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 6.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 7.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 8.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 9.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 10.0
|
||||||
|
|
||||||
button:
|
button:
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Publish Values Button"
|
name: "Publish Values Button"
|
||||||
id: publish_button
|
id: publish_button
|
||||||
on_press:
|
on_press:
|
||||||
- lambda: |-
|
- script.execute: publish_values_script
|
||||||
// Publish 10 values: 1.0, 2.0, ..., 10.0
|
|
||||||
// With window_size=5, send_every=2, send_first_at=1:
|
|
||||||
// - Output at position 1: window=[1], min=1, max=1, median=1, avg=1
|
|
||||||
// - Output at position 3: window=[1,2,3], min=1, max=3, median=2, avg=2
|
|
||||||
// - Output at position 5: window=[1,2,3,4,5], min=1, max=5, median=3, avg=3
|
|
||||||
// - Output at position 7: window=[3,4,5,6,7], min=3, max=7, median=5, avg=5
|
|
||||||
// - Output at position 9: window=[5,6,7,8,9], min=5, max=9, median=7, avg=7
|
|
||||||
// Small delay to ensure API can process each state update
|
|
||||||
for (int i = 1; i <= 10; i++) {
|
|
||||||
id(source_sensor).publish_state(float(i));
|
|
||||||
delay(10);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,17 +23,50 @@ sensor:
|
|||||||
send_every: 3
|
send_every: 3
|
||||||
send_first_at: 1
|
send_first_at: 1
|
||||||
|
|
||||||
|
script:
|
||||||
|
- id: publish_wraparound_script
|
||||||
|
then:
|
||||||
|
# Publish 9 values to test ring buffer wraparound
|
||||||
|
# Values: 10, 20, 30, 5, 25, 15, 40, 35, 20
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_wraparound
|
||||||
|
state: 10.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_wraparound
|
||||||
|
state: 20.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_wraparound
|
||||||
|
state: 30.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_wraparound
|
||||||
|
state: 5.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_wraparound
|
||||||
|
state: 25.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_wraparound
|
||||||
|
state: 15.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_wraparound
|
||||||
|
state: 40.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_wraparound
|
||||||
|
state: 35.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_wraparound
|
||||||
|
state: 20.0
|
||||||
|
|
||||||
button:
|
button:
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Publish Wraparound Button"
|
name: "Publish Wraparound Button"
|
||||||
id: publish_wraparound_button
|
id: publish_wraparound_button
|
||||||
on_press:
|
on_press:
|
||||||
- lambda: |-
|
- script.execute: publish_wraparound_script
|
||||||
// Publish 9 values to test ring buffer wraparound
|
|
||||||
// Values: 10, 20, 30, 5, 25, 15, 40, 35, 20
|
|
||||||
// Small delay to ensure API can process each state update
|
|
||||||
float values[] = {10.0, 20.0, 30.0, 5.0, 25.0, 15.0, 40.0, 35.0, 20.0};
|
|
||||||
for (int i = 0; i < 9; i++) {
|
|
||||||
id(source_wraparound).publish_state(values[i]);
|
|
||||||
delay(10);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -70,16 +70,54 @@ sensor:
|
|||||||
send_every: 5
|
send_every: 5
|
||||||
send_first_at: 1
|
send_first_at: 1
|
||||||
|
|
||||||
|
# Script to publish values with delays
|
||||||
|
script:
|
||||||
|
- id: publish_values_script
|
||||||
|
then:
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 1.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 2.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 3.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 4.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 5.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 6.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 7.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 8.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 9.0
|
||||||
|
- delay: 20ms
|
||||||
|
- sensor.template.publish:
|
||||||
|
id: source_sensor
|
||||||
|
state: 10.0
|
||||||
|
|
||||||
# Button to trigger publishing test values
|
# Button to trigger publishing test values
|
||||||
button:
|
button:
|
||||||
- platform: template
|
- platform: template
|
||||||
name: "Publish Values Button"
|
name: "Publish Values Button"
|
||||||
id: publish_button
|
id: publish_button
|
||||||
on_press:
|
on_press:
|
||||||
- lambda: |-
|
- script.execute: publish_values_script
|
||||||
// Publish 10 values: 1.0, 2.0, ..., 10.0
|
|
||||||
// Small delay to ensure API can process each state update
|
|
||||||
for (int i = 1; i <= 10; i++) {
|
|
||||||
id(source_sensor).publish_state(float(i));
|
|
||||||
delay(10);
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user