mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-26 12:43:48 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			709 B
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			709 B
		
	
	
	
		
			YAML
		
	
	
	
	
	
| binary_sensor:
 | |
|   - platform: switch
 | |
|     id: some_binary_sensor
 | |
|     name: "Template Switch State"
 | |
|     source_id: the_switch
 | |
| 
 | |
| switch:
 | |
|   - platform: template
 | |
|     name: "Template Switch"
 | |
|     id: the_switch
 | |
|     optimistic: true
 | |
|     on_state:
 | |
|       - if:
 | |
|           condition:
 | |
|             - lambda: return x;
 | |
|           then:
 | |
|             - logger.log: "Switch turned ON"
 | |
|           else:
 | |
|             - logger.log: "Switch turned OFF"
 | |
|     on_turn_on:
 | |
|       - logger.log: "Switch is now ON"
 | |
|     on_turn_off:
 | |
|       - logger.log: "Switch is now OFF"
 | |
| 
 | |
| esphome:
 | |
|   on_boot:
 | |
|     - switch.turn_on: the_switch
 | |
|     - switch.turn_off: the_switch
 | |
|     - switch.control:
 | |
|         id: the_switch
 | |
|         state: !lambda return (1 > 2);
 |