예제 #1
0
def setup_text_sensor(text_sensor_obj, mqtt_obj, config):
    sensor_var = Pvariable(config[CONF_ID],
                           text_sensor_obj,
                           has_side_effects=False)
    mqtt_var = Pvariable(config[CONF_MQTT_ID],
                         mqtt_obj,
                         has_side_effects=False)
    CORE.add_job(setup_text_sensor_core_, sensor_var, mqtt_var, config)
예제 #2
0
def setup_binary_sensor(binary_sensor_obj, mqtt_obj, config):
    binary_sensor_var = Pvariable(config[CONF_ID],
                                  binary_sensor_obj,
                                  has_side_effects=False)
    mqtt_var = Pvariable(config[CONF_MQTT_ID],
                         mqtt_obj,
                         has_side_effects=False)
    CORE.add_job(setup_binary_sensor_core_, binary_sensor_var, mqtt_var,
                 config)
예제 #3
0
def write_cpp(config):
    _LOGGER.info("Generating C++ source...")

    CORE.add_job(core_config.to_code,
                 config[CONF_ESPHOMEYAML],
                 domain='esphomeyaml')
    for domain in PRE_INITIALIZE:
        if domain == CONF_ESPHOMEYAML or domain not in config:
            continue
        CORE.add_job(get_component(domain).to_code,
                     config[domain],
                     domain=domain)

    for domain, component, conf in iter_components(config):
        if domain in PRE_INITIALIZE or not hasattr(component, 'to_code'):
            continue
        CORE.add_job(component.to_code, conf, domain=domain)

    CORE.flush_tasks()
    add(RawStatement(''))
    add(RawStatement(''))
    all_code = []
    for exp in CORE.expressions:
        if not config[CONF_ESPHOMEYAML][CONF_USE_CUSTOM_CODE]:
            if isinstance(exp, Expression) and not exp.required:
                continue
        all_code.append(text_type(statement(exp)))

    writer.write_platformio_project()

    code_s = indent('\n'.join(line.rstrip() for line in all_code))
    writer.write_cpp(code_s)
    return 0
예제 #4
0
def setup_time(time_var, config):
    CORE.add_job(setup_time_core_, time_var, config)
예제 #5
0
def register_sensor(var, config):
    sensor_var = Pvariable(config[CONF_ID], var, has_side_effects=True)
    rhs = App.register_sensor(sensor_var)
    mqtt_var = Pvariable(config[CONF_MQTT_ID], rhs, has_side_effects=True)
    CORE.add_job(setup_sensor_core_, sensor_var, mqtt_var, config)
예제 #6
0
def build_automation(trigger, arg_type, config):
    CORE.add_job(build_automation_, trigger, arg_type, config)
예제 #7
0
def setup_light(light_obj, mqtt_obj, config):
    light_var = Pvariable(config[CONF_ID], light_obj, has_side_effects=False)
    mqtt_var = Pvariable(config[CONF_MQTT_ID], mqtt_obj, has_side_effects=False)
    CORE.add_job(setup_light_core_, light_var, mqtt_var, config)
예제 #8
0
def setup_stepper(stepper_var, config):
    CORE.add_job(setup_stepper_core_, stepper_var, config)
예제 #9
0
def setup_display(display_var, config):
    CORE.add_job(setup_display_core_, display_var, config)