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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)