1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-11 07:42:26 +01:00

Automation API & Cleanup

This commit is contained in:
Otto Winter
2018-05-20 12:41:52 +02:00
parent 061798839d
commit 374ea7044c
75 changed files with 1554 additions and 730 deletions

View File

@@ -2,20 +2,21 @@ import voluptuous as vol
import esphomeyaml.config_validation as cv
from esphomeyaml.components import switch
from esphomeyaml.const import CONF_ID, CONF_NAME, CONF_INVERTED
from esphomeyaml.helpers import App, variable
from esphomeyaml.const import CONF_INVERTED, CONF_MAKE_ID, CONF_NAME
from esphomeyaml.helpers import App, Application, variable
PLATFORM_SCHEMA = switch.PLATFORM_SCHEMA.extend({
cv.GenerateID('restart_switch'): cv.register_variable_id,
cv.GenerateID('restart_switch', CONF_MAKE_ID): cv.register_variable_id,
vol.Optional(CONF_INVERTED): cv.invalid("Restart switches do not support inverted mode!"),
}).extend(switch.MQTT_SWITCH_SCHEMA.schema)
}).extend(switch.SWITCH_SCHEMA.schema)
MakeRestartSwitch = Application.MakeRestartSwitch
def to_code(config):
rhs = App.make_restart_switch(config[CONF_NAME])
restart = variable('Application::MakeRestartSwitch', config[CONF_ID], rhs)
switch.setup_switch(restart.Prestart, config)
switch.setup_mqtt_switch(restart.Pmqtt, config)
restart = variable(MakeRestartSwitch, config[CONF_MAKE_ID], rhs)
switch.setup_switch(restart.Prestart, restart.Pmqtt, config)
BUILD_FLAGS = '-DUSE_RESTART_SWITCH'