def to_code(config): rhs = App.init_api_server() api = Pvariable(config[CONF_ID], rhs) if config[CONF_PORT] != 6053: add(api.set_port(config[CONF_PORT])) if config.get(CONF_PASSWORD): add(api.set_password(config[CONF_PASSWORD])) if CONF_REBOOT_TIMEOUT in config: add(api.set_reboot_timeout(config[CONF_REBOOT_TIMEOUT])) for conf in config.get(CONF_SERVICES, []): template_args = [] func_args = [] service_type_args = [] for name, var_ in conf[CONF_VARIABLES].items(): native = SERVICE_ARG_NATIVE_TYPES[var_] template_args.append(native) func_args.append((native, name)) service_type_args.append(ServiceTypeArgument(name, SERVICE_ARG_TYPES[var_])) func = api.make_user_service_trigger.template(*template_args) rhs = func(conf[CONF_SERVICE], service_type_args) type_ = UserService.template(*template_args) trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs, type=type_) automation.build_automations(trigger, func_args, conf) setup_component(api, config)
def to_code(config): rhs = App.init_api_server() api = Pvariable(config[CONF_ID], rhs) if config[CONF_PORT] != 6053: add(api.set_port(config[CONF_PORT])) if config.get(CONF_PASSWORD): add(api.set_password(config[CONF_PASSWORD])) if CONF_REBOOT_TIMEOUT in config: add(api.set_reboot_timeout(config[CONF_REBOOT_TIMEOUT])) setup_component(api, config)