mirror of
https://github.com/esphome/esphome.git
synced 2025-10-30 14:43:51 +00:00
tests
This commit is contained in:
50
tests/integration/fixtures/sensor_filters_nan_handling.yaml
Normal file
50
tests/integration/fixtures/sensor_filters_nan_handling.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
esphome:
|
||||
name: test-nan-handling
|
||||
|
||||
host:
|
||||
api:
|
||||
batch_delay: 0ms # Disable batching to receive all state updates
|
||||
logger:
|
||||
level: DEBUG
|
||||
|
||||
sensor:
|
||||
- platform: template
|
||||
name: "Source NaN Sensor"
|
||||
id: source_nan_sensor
|
||||
accuracy_decimals: 2
|
||||
|
||||
- platform: copy
|
||||
source_id: source_nan_sensor
|
||||
name: "Min NaN Sensor"
|
||||
id: min_nan_sensor
|
||||
filters:
|
||||
- min:
|
||||
window_size: 5
|
||||
send_every: 5
|
||||
|
||||
- platform: copy
|
||||
source_id: source_nan_sensor
|
||||
name: "Max NaN Sensor"
|
||||
id: max_nan_sensor
|
||||
filters:
|
||||
- max:
|
||||
window_size: 5
|
||||
send_every: 5
|
||||
|
||||
button:
|
||||
- platform: template
|
||||
name: "Publish NaN Values Button"
|
||||
id: publish_nan_button
|
||||
on_press:
|
||||
- lambda: |-
|
||||
// Publish 10 values with NaN mixed in: 10, NaN, 5, NaN, 15, 8, NaN, 12, 3, NaN
|
||||
id(source_nan_sensor).publish_state(10.0);
|
||||
id(source_nan_sensor).publish_state(NAN);
|
||||
id(source_nan_sensor).publish_state(5.0);
|
||||
id(source_nan_sensor).publish_state(NAN);
|
||||
id(source_nan_sensor).publish_state(15.0);
|
||||
id(source_nan_sensor).publish_state(8.0);
|
||||
id(source_nan_sensor).publish_state(NAN);
|
||||
id(source_nan_sensor).publish_state(12.0);
|
||||
id(source_nan_sensor).publish_state(3.0);
|
||||
id(source_nan_sensor).publish_state(NAN);
|
||||
@@ -0,0 +1,36 @@
|
||||
esphome:
|
||||
name: test-ring-buffer-wraparound
|
||||
|
||||
host:
|
||||
api:
|
||||
batch_delay: 0ms # Disable batching to receive all state updates
|
||||
logger:
|
||||
level: DEBUG
|
||||
|
||||
sensor:
|
||||
- platform: template
|
||||
name: "Source Wraparound Sensor"
|
||||
id: source_wraparound
|
||||
accuracy_decimals: 2
|
||||
|
||||
- platform: copy
|
||||
source_id: source_wraparound
|
||||
name: "Wraparound Min Sensor"
|
||||
id: wraparound_min_sensor
|
||||
filters:
|
||||
- min:
|
||||
window_size: 3
|
||||
send_every: 3
|
||||
|
||||
button:
|
||||
- platform: template
|
||||
name: "Publish Wraparound Button"
|
||||
id: publish_wraparound_button
|
||||
on_press:
|
||||
- lambda: |-
|
||||
// Publish 9 values to test ring buffer wraparound
|
||||
// Values: 10, 20, 30, 5, 25, 15, 40, 35, 20
|
||||
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]);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
esphome:
|
||||
name: test-sliding-window-filters
|
||||
|
||||
host:
|
||||
api:
|
||||
batch_delay: 0ms # Disable batching to receive all state updates
|
||||
logger:
|
||||
level: DEBUG
|
||||
|
||||
# Template sensor that we'll use to publish values
|
||||
sensor:
|
||||
- platform: template
|
||||
name: "Source Sensor"
|
||||
id: source_sensor
|
||||
accuracy_decimals: 2
|
||||
|
||||
# Min filter sensor
|
||||
- platform: copy
|
||||
source_id: source_sensor
|
||||
name: "Min Sensor"
|
||||
id: min_sensor
|
||||
filters:
|
||||
- min:
|
||||
window_size: 5
|
||||
send_every: 5
|
||||
|
||||
# Max filter sensor
|
||||
- platform: copy
|
||||
source_id: source_sensor
|
||||
name: "Max Sensor"
|
||||
id: max_sensor
|
||||
filters:
|
||||
- max:
|
||||
window_size: 5
|
||||
send_every: 5
|
||||
|
||||
# Median filter sensor
|
||||
- platform: copy
|
||||
source_id: source_sensor
|
||||
name: "Median Sensor"
|
||||
id: median_sensor
|
||||
filters:
|
||||
- median:
|
||||
window_size: 5
|
||||
send_every: 5
|
||||
|
||||
# Quantile filter sensor (90th percentile)
|
||||
- platform: copy
|
||||
source_id: source_sensor
|
||||
name: "Quantile Sensor"
|
||||
id: quantile_sensor
|
||||
filters:
|
||||
- quantile:
|
||||
window_size: 5
|
||||
send_every: 5
|
||||
quantile: 0.9
|
||||
|
||||
# Moving average filter sensor
|
||||
- platform: copy
|
||||
source_id: source_sensor
|
||||
name: "Moving Avg Sensor"
|
||||
id: moving_avg_sensor
|
||||
filters:
|
||||
- sliding_window_moving_average:
|
||||
window_size: 5
|
||||
send_every: 5
|
||||
|
||||
# Button to trigger publishing test values
|
||||
button:
|
||||
- platform: template
|
||||
name: "Publish Values Button"
|
||||
id: publish_button
|
||||
on_press:
|
||||
- lambda: |-
|
||||
// Publish 10 values: 1.0, 2.0, ..., 10.0
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
id(source_sensor).publish_state(float(i));
|
||||
}
|
||||
Reference in New Issue
Block a user