esphome: name: loop-interval-decouple on_boot: priority: -100 then: - lambda: |- // Raise loop_interval_ to 500ms. With the decoupling fix the // component phase should run ~twice per second while the 50ms // scheduler interval below still fires at its requested cadence. App.set_loop_interval(500); # Start measurement after 1s so boot transients settle. - delay: 1000ms - lambda: |- id(loop_at_start) = id(loop_counter)->get_loop_count(); id(sched_at_start) = id(sched_count); ESP_LOGI("test", "MEASUREMENT_STARTED loop=%d sched=%d", id(loop_at_start), id(sched_at_start)); # Observe for 2s. - delay: 2000ms - lambda: |- int loop_delta = id(loop_counter)->get_loop_count() - id(loop_at_start); int sched_delta = id(sched_count) - id(sched_at_start); ESP_LOGI("test", "MEASUREMENT_DONE loop_delta=%d sched_delta=%d", loop_delta, sched_delta); host: api: logger: level: INFO logs: loop_test_component: WARN # Silence per-loop log spam external_components: - source: type: local path: EXTERNAL_COMPONENT_PATH globals: - id: sched_count type: int initial_value: "0" - id: loop_at_start type: int initial_value: "0" - id: sched_at_start type: int initial_value: "0" loop_test_component: components: - id: loop_counter name: loop_counter interval: # Fast scheduler interval — with the decoupling fix this should fire at # its requested 50ms cadence regardless of loop_interval_. - interval: 50ms then: - lambda: |- id(sched_count) += 1;