32 lines
		
	
	
	
		
			843 B
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			843 B
		
	
	
	
		
			YAML
		
	
	
	
	
	
| substitutions:
 | |
|   hostname: heating-downstairs
 | |
|   friendly_name: Heating Downstairs
 | |
|   relay_on_action: turn_on
 | |
| 
 | |
| wifi:
 | |
|   use_address: 192.168.10.18
 | |
| 
 | |
| packages:
 | |
|   device: !include devices/sonoff-basic.yaml
 | |
| 
 | |
| # Give the user a graphical control over the timeout
 | |
| # See: https://esphome.io/components/number/template.html
 | |
| number:
 | |
|   - name: "${friendly_name} Timeout"
 | |
|     id: timeout_length
 | |
|     platform: template
 | |
|     # TODO: maybe it's a better UX to do this in hours and minutes and do the conversion in esphome
 | |
|     unit_of_measurement: minutes
 | |
|     min_value: 10
 | |
|     # Never want it on for more than 3 hours
 | |
|     # 3*60 = 180
 | |
|     max_value: 180
 | |
|     initial_value: 60
 | |
|     step: 10
 | |
|     optimistic: true
 | |
| 
 | |
| script:
 | |
|   - id: turn_on
 | |
|     then:
 | |
|       - delay: !lambda 'return id(timeout_length).state * 60 * 1000;'
 | |
|       - lambda: !lambda id(relay).turn_off();
 |