示例#1
0
def to_code(config):
    rhs = App.make_template_switch(config[CONF_NAME])
    make = variable(config[CONF_MAKE_ID], rhs)
    template = make.Ptemplate_

    switch.setup_switch(template, make.Pmqtt, config)

    if CONF_LAMBDA in config:
        for template_ in process_lambda(config[CONF_LAMBDA], [],
                                        return_type=optional.template(bool_)):
            yield
        add(template.set_state_lambda(template_))
    if CONF_TURN_OFF_ACTION in config:
        automation.build_automation(template.get_turn_off_trigger(), NoArg,
                                    config[CONF_TURN_OFF_ACTION])
    if CONF_TURN_ON_ACTION in config:
        automation.build_automation(template.get_turn_on_trigger(), NoArg,
                                    config[CONF_TURN_ON_ACTION])
    if CONF_OPTIMISTIC in config:
        add(template.set_optimistic(config[CONF_OPTIMISTIC]))

    if CONF_RESTORE_STATE in config:
        add(template.set_restore_state(config[CONF_RESTORE_STATE]))

    setup_component(template, config)
示例#2
0
def to_code(config):
    output = None
    for output in get_variable(config[CONF_OUTPUT]):
        yield
    rhs = App.make_simple_switch(config[CONF_NAME], output)
    gpio = variable(config[CONF_MAKE_ID], rhs)
    switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
示例#3
0
文件: gpio.py 项目: apeeters/esphome
def to_code(config):
    pin = None
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_gpio_switch(config[CONF_NAME], pin)
    gpio = variable(config[CONF_MAKE_ID], rhs)
    switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
示例#4
0
def to_code(config):
    rhs = App.make_template_switch(config[CONF_NAME])
    make = variable(config[CONF_MAKE_ID], rhs)

    if CONF_LAMBDA in config:
        template_ = None
        for template_ in process_lambda(config[CONF_LAMBDA], [],
                                        return_type=optional.template(bool_)):
            yield
        add(make.Ptemplate_.set_state_lambda(template_))
    if CONF_TURN_OFF_ACTION in config:
        actions = None
        for actions in automation.build_actions(config[CONF_TURN_OFF_ACTION],
                                                NoArg):
            yield
        add(make.Ptemplate_.add_turn_off_actions(actions))
    if CONF_TURN_ON_ACTION in config:
        actions = None
        for actions in automation.build_actions(config[CONF_TURN_ON_ACTION],
                                                NoArg):
            yield
        add(make.Ptemplate_.add_turn_on_actions(actions))
    if CONF_OPTIMISTIC in config:
        add(make.Ptemplate_.set_optimistic(config[CONF_OPTIMISTIC]))

    switch.setup_switch(make.Ptemplate_, make.Pmqtt, config)
示例#5
0
def to_code(config):
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_gpio_switch(config[CONF_NAME], pin)
    make = variable(config[CONF_MAKE_ID], rhs)
    gpio = make.Pswitch_

    switch.setup_switch(gpio, make.Pmqtt, config)
    setup_component(gpio, config)
示例#6
0
def to_code(config):
    for output_ in get_variable(config[CONF_OUTPUT]):
        yield
    rhs = App.make_output_switch(config[CONF_NAME], output_)
    make = variable(config[CONF_MAKE_ID], rhs)
    switch_ = make.Pswitch_

    switch.setup_switch(switch_, make.Pmqtt, config)
    setup_component(switch, config)
示例#7
0
def to_code(config):
    for uart_ in get_variable(config[CONF_UART_ID]):
        yield
    data = config[CONF_DATA]
    if isinstance(data, str):
        data = [HexInt(ord(x)) for x in data]
    rhs = App.make_uart_switch(uart_, config[CONF_NAME],
                               ArrayInitializer(*data, multiline=False))
    restart = variable(config[CONF_MAKE_ID], rhs)
    switch.setup_switch(restart.Puart, restart.Pmqtt, config)
示例#8
0
def to_code(config):
    pin = None
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_gpio_switch(config[CONF_NAME], pin)
    gpio = variable(config[CONF_MAKE_ID], rhs)

    if CONF_POWER_ON_VALUE in config:
        add(gpio.Pswitch_.set_power_on_value(config[CONF_POWER_ON_VALUE]))

    switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
示例#9
0
def to_code(config):
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_gpio_switch(config[CONF_NAME], pin)
    make = variable(config[CONF_MAKE_ID], rhs)
    gpio = make.Pswitch_

    if CONF_RESTORE_MODE in config:
        add(gpio.set_restore_mode(RESTORE_MODES[config[CONF_RESTORE_MODE]]))

    switch.setup_switch(gpio, make.Pmqtt, config)
    setup_component(gpio, config)
示例#10
0
def to_code(config):
    rhs = App.make_template_switch(config[CONF_NAME])
    make = variable(MakeTemplateSwitch, config[CONF_MAKE_ID], rhs)

    if CONF_LAMBDA in config:
        template_ = process_lambda(config[CONF_LAMBDA], [])
        add(make.Ptemplate.set_state_lambda(template_))
    if CONF_TURN_OFF_ACTION in config:
        actions = automation.build_actions(config[CONF_TURN_OFF_ACTION], NoArg)
        add(make.Ptemplate_.add_turn_off_actions(actions))
    if CONF_TURN_ON_ACTION in config:
        actions = automation.build_actions(config[CONF_TURN_ON_ACTION], NoArg)
        add(make.Ptemplate_.add_turn_on_actions(actions))
    if CONF_OPTIMISTIC in config:
        add(make.Ptemplate_.set_optimistic(config[CONF_OPTIMISTIC]))

    switch.setup_switch(make.Ptemplate_, make.Pmqtt, config)
示例#11
0
def to_code(config):
    rhs = App.make_restart_switch(config[CONF_NAME])
    restart = variable(config[CONF_MAKE_ID], rhs)
    switch.setup_switch(restart.Prestart, restart.Pmqtt, config)
示例#12
0
文件: gpio.py 项目: brandond/esphome
def to_code(config):
    rhs = App.make_gpio_switch(config[CONF_NAME],
                               gpio_output_pin_expression(config[CONF_PIN]))
    gpio = variable(MakeGPIOSwitch, config[CONF_MAKE_ID], rhs)
    switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
示例#13
0
def to_code(config):
    output = get_variable(config[CONF_OUTPUT])
    rhs = App.make_simple_switch(config[CONF_NAME], output)
    gpio = variable('Application::MakeSimpleSwitch', config[CONF_ID], rhs)
    switch.setup_switch(gpio.Pswitch_, config)
    switch.setup_mqtt_switch(gpio.Pmqtt, config)
示例#14
0
def to_code(config):
    output = get_variable(config[CONF_OUTPUT])
    rhs = App.make_simple_switch(config[CONF_NAME], output)
    gpio = variable(MakeSimpleSwitch, config[CONF_MAKE_ID], rhs)
    switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
示例#15
0
def to_code(config):
    rhs = App.make_shutdown_switch(config[CONF_NAME])
    shutdown = variable('Application::MakeShutdownSwitch', config[CONF_ID],
                        rhs)
    switch.setup_switch(shutdown.Pshutdown, config)
    switch.setup_mqtt_switch(shutdown.Pmqtt, config)
示例#16
0
def to_code(config):
    rhs = App.make_shutdown_switch(config[CONF_NAME])
    shutdown = variable(config[CONF_MAKE_ID], rhs)
    switch.setup_switch(shutdown.Pshutdown, shutdown.Pmqtt, config)
示例#17
0
def to_code(config):
    rhs = App.make_gpio_switch(config[CONF_NAME],
                               exp_gpio_output_pin(config[CONF_PIN]))
    gpio = variable('Application::MakeGPIOSwitch', config[CONF_ID], rhs)
    switch.setup_switch(gpio.Pswitch_, config)
    switch.setup_mqtt_switch(gpio.Pmqtt, config)
示例#18
0
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)