Files
esphome/tests/integration/fixtures/loop_disable_enable_simple.yaml
J. Nick Koston 80a8f1437e tests
2025-06-15 19:38:13 -05:00

44 lines
1.1 KiB
YAML

esphome:
name: loop-test
on_boot:
priority: -100 # After all components are initialized
then:
- logger.log: "Boot complete, testing loop disable/enable"
host:
api:
logger:
level: DEBUG
# Use interval component which already supports disable/enable
interval:
- interval: 100ms
id: test_interval_1
then:
- lambda: |-
static int count = 0;
count++;
ESP_LOGD("test", "Interval 1 count: %d", count);
if (count == 10) {
ESP_LOGD("test", "Disabling interval 1 after 10 iterations");
id(test_interval_1).disable();
}
- interval: 200ms
id: test_interval_2
then:
- lambda: |-
static int count = 0;
count++;
ESP_LOGD("test", "Interval 2 count: %d", count);
// Re-enable interval 1 after 5 iterations
if (count == 5) {
ESP_LOGD("test", "Re-enabling interval 1");
id(test_interval_1).enable();
}
if (count == 15) {
ESP_LOGD("test", "Disabling interval 2");
id(test_interval_2).disable();
}