mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| esphome:
 | |
|   name: test-parallel-delays
 | |
| 
 | |
| host:
 | |
| 
 | |
| logger:
 | |
|   level: DEBUG
 | |
| 
 | |
| api:
 | |
|   actions:
 | |
|     - action: test_parallel_delays
 | |
|       then:
 | |
|         # Start three parallel script instances with small delays between starts
 | |
|         - globals.set:
 | |
|             id: instance_counter
 | |
|             value: '1'
 | |
|         - script.execute: parallel_delay_script
 | |
|         - delay: 10ms
 | |
|         - globals.set:
 | |
|             id: instance_counter
 | |
|             value: '2'
 | |
|         - script.execute: parallel_delay_script
 | |
|         - delay: 10ms
 | |
|         - globals.set:
 | |
|             id: instance_counter
 | |
|             value: '3'
 | |
|         - script.execute: parallel_delay_script
 | |
| 
 | |
| globals:
 | |
|   - id: instance_counter
 | |
|     type: int
 | |
|     initial_value: '0'
 | |
| 
 | |
| script:
 | |
|   - id: parallel_delay_script
 | |
|     mode: parallel
 | |
|     then:
 | |
|       - lambda: !lambda |-
 | |
|           int instance = id(instance_counter);
 | |
|           ESP_LOGI("TEST", "Parallel script instance %d started", instance);
 | |
|       - delay: 1s
 | |
|       - lambda: !lambda |-
 | |
|           static int completed_counter = 0;
 | |
|           completed_counter++;
 | |
|           ESP_LOGI("TEST", "Parallel script instance %d completed after delay", completed_counter);
 |