mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-29 22:24:26 +00:00 
			
		
		
		
	Initial Commit 🎉
This commit is contained in:
		
							
								
								
									
										25
									
								
								esphomeyaml/components/switch/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								esphomeyaml/components/switch/__init__.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| import voluptuous as vol | ||||
|  | ||||
| import esphomeyaml.config_validation as cv | ||||
| from esphomeyaml.const import CONF_ICON, CONF_ID, CONF_NAME | ||||
| from esphomeyaml.helpers import App, Pvariable, add, setup_mqtt_component | ||||
|  | ||||
| PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({ | ||||
|  | ||||
| }) | ||||
|  | ||||
| MQTT_SWITCH_SCHEMA = cv.MQTT_COMMAND_COMPONENT_SCHEMA.extend({ | ||||
|     vol.Optional(CONF_ICON): cv.icon, | ||||
| }) | ||||
|  | ||||
|  | ||||
| def setup_mqtt_switch(obj, config): | ||||
|     if CONF_ICON in config: | ||||
|         add(obj.set_icon(config[CONF_ICON])) | ||||
|     setup_mqtt_component(obj, config) | ||||
|  | ||||
|  | ||||
| def make_mqtt_switch_for(exp, config): | ||||
|     rhs = App.make_mqtt_switch_for(exp, config[CONF_NAME]) | ||||
|     mqtt_switch = Pvariable('switch_::MQTTSwitchComponent', config[CONF_ID], rhs) | ||||
|     setup_mqtt_switch(mqtt_switch, config) | ||||
		Reference in New Issue
	
	Block a user