예제 #1
0
def setup_sensor_core_(sensor_var, mqtt_var, config):
    if CONF_UNIT_OF_MEASUREMENT in config:
        add(
            sensor_var.set_unit_of_measurement(
                config[CONF_UNIT_OF_MEASUREMENT]))
    if CONF_ICON in config:
        add(sensor_var.set_icon(config[CONF_ICON]))
    if CONF_ACCURACY_DECIMALS in config:
        add(sensor_var.set_accuracy_decimals(config[CONF_ACCURACY_DECIMALS]))
    if CONF_FILTERS in config:
        add(sensor_var.set_filters(setup_filters(config[CONF_FILTERS])))

    for conf in config.get(CONF_ON_VALUE, []):
        rhs = sensor_var.make_value_trigger()
        trigger = Pvariable(SensorValueTrigger, conf[CONF_TRIGGER_ID], rhs)
        automation.build_automation(trigger, float_, conf)
    for conf in config.get(CONF_ON_RAW_VALUE, []):
        rhs = sensor_var.make_raw_value_trigger()
        trigger = Pvariable(RawSensorValueTrigger, conf[CONF_TRIGGER_ID], rhs)
        automation.build_automation(trigger, float_, conf)
    for conf in config.get(CONF_ON_VALUE_RANGE, []):
        rhs = sensor_var.make_value_range_trigger()
        trigger = Pvariable(ValueRangeTrigger, conf[CONF_TRIGGER_ID], rhs)
        if CONF_ABOVE in conf:
            trigger.set_min(templatable(conf[CONF_ABOVE], float_, float_))
        if CONF_BELOW in conf:
            trigger.set_max(templatable(conf[CONF_BELOW], float_, float_))
        automation.build_automation(trigger, float_, conf)

    if CONF_EXPIRE_AFTER in config:
        if config[CONF_EXPIRE_AFTER] is None:
            add(mqtt_var.disable_expire_after())
        else:
            add(mqtt_var.set_expire_after(config[CONF_EXPIRE_AFTER]))
    setup_mqtt_component(mqtt_var, config)
예제 #2
0
def build_condition(config, arg_type):
    template_arg = TemplateArguments(arg_type)
    if CONF_AND in config:
        yield AndCondition.new(
            template_arg, build_conditions(config[CONF_AND], template_arg))
    elif CONF_OR in config:
        yield OrCondition.new(template_arg,
                              build_conditions(config[CONF_OR], template_arg))
    elif CONF_LAMBDA in config:
        lambda_ = None
        for lambda_ in process_lambda(config[CONF_LAMBDA], [(arg_type, 'x')]):
            yield
        yield LambdaCondition.new(template_arg, lambda_)
    elif CONF_RANGE in config:
        conf = config[CONF_RANGE]
        rhs = RangeCondition.new(template_arg)
        type = RangeCondition.template(template_arg)
        condition = Pvariable(config[CONF_CONDITION_ID], rhs, type=type)
        if CONF_ABOVE in conf:
            template_ = None
            for template_ in templatable(conf[CONF_ABOVE], arg_type, float_):
                yield
            condition.set_min(template_)
        if CONF_BELOW in conf:
            template_ = None
            for template_ in templatable(conf[CONF_BELOW], arg_type, float_):
                yield
            condition.set_max(template_)
        yield condition
    else:
        raise ESPHomeYAMLError(u"Unsupported condition {}".format(config))
예제 #3
0
def fan_turn_on_to_code(config, action_id, arg_type):
    template_arg = TemplateArguments(arg_type)
    for var in get_variable(config[CONF_ID]):
        yield None
    rhs = var.make_turn_on_action(template_arg)
    type = TurnOnAction.template(arg_type)
    action = Pvariable(action_id, rhs, type=type)
    if CONF_OSCILLATING in config:
        for template_ in templatable(config[CONF_OSCILLATING], arg_type,
                                     bool_):
            yield None
        add(action.set_oscillating(template_))
    if CONF_SPEED in config:
        for template_ in templatable(config[CONF_SPEED], arg_type, FanSpeed):
            yield None
        add(action.set_speed(template_))
    yield action
예제 #4
0
def delay_action_to_code(config, action_id, arg_type):
    template_arg = TemplateArguments(arg_type)
    rhs = App.register_component(DelayAction.new(template_arg))
    type = DelayAction.template(template_arg)
    action = Pvariable(action_id, rhs, type=type)
    for template_ in templatable(config, arg_type, uint32):
        yield
    add(action.set_delay(template_))
    yield action
예제 #5
0
def light_turn_on_to_code(config, action_id, arg_type):
    template_arg = TemplateArguments(arg_type)
    for var in get_variable(config[CONF_ID]):
        yield None
    rhs = var.make_turn_on_action(template_arg)
    type = TurnOnAction.template(template_arg)
    action = Pvariable(action_id, rhs, type=type)
    if CONF_TRANSITION_LENGTH in config:
        for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type,
                                     uint32):
            yield None
        add(action.set_transition_length(template_))
    if CONF_FLASH_LENGTH in config:
        for template_ in templatable(config[CONF_FLASH_LENGTH], arg_type,
                                     uint32):
            yield None
        add(action.set_flash_length(template_))
    if CONF_BRIGHTNESS in config:
        for template_ in templatable(config[CONF_BRIGHTNESS], arg_type,
                                     float_):
            yield None
        add(action.set_brightness(template_))
    if CONF_RED in config:
        for template_ in templatable(config[CONF_RED], arg_type, float_):
            yield None
        add(action.set_red(template_))
    if CONF_GREEN in config:
        for template_ in templatable(config[CONF_GREEN], arg_type, float_):
            yield None
        add(action.set_green(template_))
    if CONF_BLUE in config:
        for template_ in templatable(config[CONF_BLUE], arg_type, float_):
            yield None
        add(action.set_blue(template_))
    if CONF_WHITE in config:
        for template_ in templatable(config[CONF_WHITE], arg_type, float_):
            yield None
        add(action.set_white(template_))
    if CONF_COLOR_TEMPERATURE in config:
        for template_ in templatable(config[CONF_COLOR_TEMPERATURE], arg_type,
                                     float_):
            yield None
        add(action.set_color_temperature(template_))
    if CONF_EFFECT in config:
        for template_ in templatable(config[CONF_EFFECT], arg_type,
                                     std_string):
            yield None
        add(action.set_effect(template_))
    yield action
예제 #6
0
def stepper_set_target_to_code(config, action_id, arg_type):
    template_arg = TemplateArguments(arg_type)
    for var in get_variable(config[CONF_ID]):
        yield None
    rhs = var.make_set_target_action(template_arg)
    type = SetTargetAction.template(arg_type)
    action = Pvariable(action_id, rhs, type=type)
    for template_ in templatable(config[CONF_TARGET], arg_type, int32):
        yield None
    add(action.set_target(template_))
    yield action
예제 #7
0
def stepper_report_position_to_code(config, action_id, arg_type):
    template_arg = TemplateArguments(arg_type)
    for var in get_variable(config[CONF_ID]):
        yield None
    rhs = var.make_report_position_action(template_arg)
    type = ReportPositionAction.template(arg_type)
    action = Pvariable(action_id, rhs, type=type)
    for template_ in templatable(config[CONF_POSITION], arg_type, int32):
        yield None
    add(action.set_target(template_))
    yield action
예제 #8
0
def output_set_level_to_code(config, action_id, arg_type):
    template_arg = TemplateArguments(arg_type)
    for var in get_variable(config[CONF_ID]):
        yield None
    rhs = var.make_set_level_action(template_arg)
    type = SetLevelAction.template(arg_type)
    action = Pvariable(action_id, rhs, type=type)
    for template_ in templatable(config[CONF_LEVEL], arg_type, bool_):
        yield None
    add(action.set_level(template_))
    yield action
예제 #9
0
def light_turn_off_to_code(config, action_id, arg_type):
    template_arg = TemplateArguments(arg_type)
    for var in get_variable(config[CONF_ID]):
        yield None
    rhs = var.make_turn_off_action(template_arg)
    type = TurnOffAction.template(template_arg)
    action = Pvariable(action_id, rhs, type=type)
    if CONF_TRANSITION_LENGTH in config:
        for template_ in templatable(config[CONF_TRANSITION_LENGTH], arg_type, uint32):
            yield None
        add(action.set_transition_length(template_))
    yield action
예제 #10
0
def mqtt_publish_action_to_code(config, action_id, arg_type):
    template_arg = TemplateArguments(arg_type)
    rhs = App.Pget_mqtt_client().Pmake_publish_action(template_arg)
    type = MQTTPublishAction.template(template_arg)
    action = Pvariable(action_id, rhs, type=type)
    for template_ in templatable(config[CONF_TOPIC], arg_type, std_string):
        yield None
    add(action.set_topic(template_))

    for template_ in templatable(config[CONF_PAYLOAD], arg_type, std_string):
        yield None
    add(action.set_payload(template_))
    if CONF_QOS in config:
        for template_ in templatable(config[CONF_QOS], arg_type, uint8):
            yield
        add(action.set_qos(template_))
    if CONF_RETAIN in config:
        for template_ in templatable(config[CONF_RETAIN], arg_type, bool_):
            yield None
        add(action.set_retain(template_))
    yield action
예제 #11
0
def build_condition(config, arg_type):
    template_arg = TemplateArguments(arg_type)
    if CONF_AND in config:
        return AndCondition.new(
            template_arg, build_conditions(config[CONF_AND], template_arg))
    if CONF_OR in config:
        return OrCondition.new(template_arg,
                               build_conditions(config[CONF_OR], template_arg))
    if CONF_LAMBDA in config:
        return LambdaCondition.new(
            template_arg, process_lambda(config[CONF_LAMBDA],
                                         [(arg_type, 'x')]))
    if CONF_RANGE in config:
        conf = config[CONF_RANGE]
        rhs = RangeCondition.new(template_arg)
        condition = Pvariable(RangeCondition.template(template_arg),
                              config[CONF_CONDITION_ID], rhs)
        if CONF_ABOVE in conf:
            condition.set_min(templatable(conf[CONF_ABOVE], arg_type, float_))
        if CONF_BELOW in conf:
            condition.set_max(templatable(conf[CONF_BELOW], arg_type, float_))
        return condition
    raise ESPHomeYAMLError(u"Unsupported condition {}".format(config))
예제 #12
0
def mqtt_publish_json_action_to_code(config, action_id, arg_type):
    template_arg = TemplateArguments(arg_type)
    rhs = App.Pget_mqtt_client().Pmake_publish_json_action(template_arg)
    type = MQTTPublishJsonAction.template(template_arg)
    action = Pvariable(action_id, rhs, type=type)
    for template_ in templatable(config[CONF_TOPIC], arg_type, std_string):
        yield None
    add(action.set_topic(template_))

    for lambda_ in process_lambda(config[CONF_PAYLOAD], [(arg_type, 'x'), (JsonObjectRef, 'root')]):
        yield None
    add(action.set_payload(lambda_))
    if CONF_QOS in config:
        add(action.set_qos(config[CONF_QOS]))
    if CONF_RETAIN in config:
        add(action.set_retain(config[CONF_RETAIN]))
    yield action
예제 #13
0
def build_action(full_config, arg_type):
    from esphomeyaml.components import light, mqtt, switch

    template_arg = TemplateArguments(arg_type)
    # Keep pylint from freaking out
    var = None
    action_id = full_config[CONF_ACTION_ID]
    key, config = next(
        (k, v) for k, v in full_config.items() if k in ACTION_KEYS)
    if key == CONF_DELAY:
        rhs = App.register_component(DelayAction.new(template_arg))
        type = DelayAction.template(template_arg)
        action = Pvariable(action_id, rhs, type=type)
        for template_ in templatable(config, arg_type, uint32):
            yield
        add(action.set_delay(template_))
        yield action
    elif key == CONF_LAMBDA:
        for lambda_ in process_lambda(config, [(arg_type, 'x')]):
            yield None
        rhs = LambdaAction.new(template_arg, lambda_)
        type = LambdaAction.template(template_arg)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_MQTT_PUBLISH:
        rhs = App.Pget_mqtt_client().Pmake_publish_action(template_arg)
        type = mqtt.MQTTPublishAction.template(template_arg)
        action = Pvariable(action_id, rhs, type=type)
        for template_ in templatable(config[CONF_TOPIC], arg_type, std_string):
            yield None
        add(action.set_topic(template_))

        for template_ in templatable(config[CONF_PAYLOAD], arg_type,
                                     std_string):
            yield None
        add(action.set_payload(template_))
        if CONF_QOS in config:
            for template_ in templatable(config[CONF_QOS], arg_type, uint8):
                yield
            add(action.set_qos(template_))
        if CONF_RETAIN in config:
            for template_ in templatable(config[CONF_RETAIN], arg_type, bool_):
                yield None
            add(action.set_retain(template_))
        yield action
    elif key == CONF_LIGHT_TOGGLE:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_toggle_action(template_arg)
        type = light.ToggleAction.template(template_arg)
        action = Pvariable(action_id, rhs, type=type)
        if CONF_TRANSITION_LENGTH in config:
            for template_ in templatable(config[CONF_TRANSITION_LENGTH],
                                         arg_type, uint32):
                yield None
            add(action.set_transition_length(template_))
        yield action
    elif key == CONF_LIGHT_TURN_OFF:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_turn_off_action(template_arg)
        type = light.TurnOffAction.template(template_arg)
        action = Pvariable(action_id, rhs, type=type)
        if CONF_TRANSITION_LENGTH in config:
            for template_ in templatable(config[CONF_TRANSITION_LENGTH],
                                         arg_type, uint32):
                yield None
            add(action.set_transition_length(template_))
        yield action
    elif key == CONF_LIGHT_TURN_ON:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_turn_on_action(template_arg)
        type = light.TurnOnAction.template(template_arg)
        action = Pvariable(action_id, rhs, type=type)
        if CONF_TRANSITION_LENGTH in config:
            for template_ in templatable(config[CONF_TRANSITION_LENGTH],
                                         arg_type, uint32):
                yield None
            add(action.set_transition_length(template_))
        if CONF_FLASH_LENGTH in config:
            for template_ in templatable(config[CONF_FLASH_LENGTH], arg_type,
                                         uint32):
                yield None
            add(action.set_flash_length(template_))
        if CONF_BRIGHTNESS in config:
            for template_ in templatable(config[CONF_BRIGHTNESS], arg_type,
                                         float_):
                yield None
            add(action.set_brightness(template_))
        if CONF_RED in config:
            for template_ in templatable(config[CONF_RED], arg_type, float_):
                yield None
            add(action.set_red(template_))
        if CONF_GREEN in config:
            for template_ in templatable(config[CONF_GREEN], arg_type, float_):
                yield None
            add(action.set_green(template_))
        if CONF_BLUE in config:
            for template_ in templatable(config[CONF_BLUE], arg_type, float_):
                yield None
            add(action.set_blue(template_))
        if CONF_WHITE in config:
            for template_ in templatable(config[CONF_WHITE], arg_type, float_):
                yield None
            add(action.set_white(template_))
        if CONF_COLOR_TEMPERATURE in config:
            for template_ in templatable(config[CONF_COLOR_TEMPERATURE],
                                         arg_type, float_):
                yield None
            add(action.set_color_temperature(template_))
        if CONF_EFFECT in config:
            for template_ in templatable(config[CONF_EFFECT], arg_type,
                                         std_string):
                yield None
            add(action.set_effect(template_))
        yield action
    elif key == CONF_SWITCH_TOGGLE:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_toggle_action(template_arg)
        type = switch.ToggleAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_SWITCH_TURN_OFF:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_turn_off_action(template_arg)
        type = switch.TurnOffAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_SWITCH_TURN_ON:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_turn_on_action(template_arg)
        type = switch.TurnOnAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_COVER_OPEN:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_open_action(template_arg)
        type = cover.OpenAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_COVER_CLOSE:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_close_action(template_arg)
        type = cover.CloseAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_COVER_STOP:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_stop_action(template_arg)
        type = cover.StopAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_FAN_TOGGLE:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_toggle_action(template_arg)
        type = fan.ToggleAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_FAN_TURN_OFF:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_turn_off_action(template_arg)
        type = fan.TurnOffAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_FAN_TURN_ON:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_turn_on_action(template_arg)
        type = fan.TurnOnAction.template(arg_type)
        action = Pvariable(action_id, rhs, type=type)
        if CONF_OSCILLATING in config:
            for template_ in templatable(config[CONF_OSCILLATING], arg_type,
                                         bool_):
                yield None
            add(action.set_oscillating(template_))
        if CONF_SPEED in config:
            for template_ in templatable(config[CONF_SPEED], arg_type,
                                         fan.FanSpeed):
                yield None
            add(action.set_speed(template_))
        yield action
    elif key == CONF_OUTPUT_TURN_OFF:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_turn_off_action(template_arg)
        type = output.TurnOffAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_OUTPUT_TURN_ON:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_turn_on_action(template_arg)
        type = output.TurnOnAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_OUTPUT_SET_LEVEL:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_set_level_action(template_arg)
        type = output.SetLevelAction.template(arg_type)
        action = Pvariable(action_id, rhs, type=type)
        for template_ in templatable(config[CONF_LEVEL], arg_type, bool_):
            yield None
        add(action.set_level(template_))
        yield action
    elif key == CONF_IF:
        for conditions in build_conditions(config[CONF_CONDITION], arg_type):
            yield None
        rhs = IfAction.new(template_arg, conditions)
        type = IfAction.template(template_arg)
        action = Pvariable(action_id, rhs, type=type)
        if CONF_THEN in config:
            for actions in build_actions(config[CONF_THEN], arg_type):
                yield None
            add(action.add_then(actions))
        if CONF_ELSE in config:
            for actions in build_actions(config[CONF_ELSE], arg_type):
                yield None
            add(action.add_else(actions))
        yield action
    elif key == CONF_DEEP_SLEEP_ENTER:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_enter_deep_sleep_action(template_arg)
        type = deep_sleep.EnterDeepSleepAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    elif key == CONF_DEEP_SLEEP_PREVENT:
        for var in get_variable(config[CONF_ID]):
            yield None
        rhs = var.make_prevent_deep_sleep_action(template_arg)
        type = deep_sleep.PreventDeepSleepAction.template(arg_type)
        yield Pvariable(action_id, rhs, type=type)
    else:
        raise ESPHomeYAMLError(u"Unsupported action {}".format(config))
예제 #14
0
def build_action(config, arg_type):
    from esphomeyaml.components import light, mqtt, switch

    template_arg = TemplateArguments(arg_type)
    # Keep pylint from freaking out
    var = None
    if CONF_DELAY in config:
        rhs = App.register_component(DelayAction.new(template_arg))
        type = DelayAction.template(template_arg)
        action = Pvariable(config[CONF_ACTION_ID], rhs, type=type)
        template_ = None
        for template_ in templatable(config[CONF_DELAY], arg_type, uint32):
            yield
        add(action.set_delay(template_))
        yield action
    elif CONF_LAMBDA in config:
        lambda_ = None
        for lambda_ in process_lambda(config[CONF_LAMBDA], [(arg_type, 'x')]):
            yield None
        rhs = LambdaAction.new(template_arg, lambda_)
        type = LambdaAction.template(template_arg)
        yield Pvariable(config[CONF_ACTION_ID], rhs, type=type)
    elif CONF_MQTT_PUBLISH in config:
        conf = config[CONF_MQTT_PUBLISH]
        rhs = App.Pget_mqtt_client().Pmake_publish_action(template_arg)
        type = mqtt.MQTTPublishAction.template(template_arg)
        action = Pvariable(config[CONF_ACTION_ID], rhs, type=type)
        template_ = None
        for template_ in templatable(conf[CONF_TOPIC], arg_type, std_string):
            yield None
        add(action.set_topic(template_))

        template_ = None
        for template_ in templatable(conf[CONF_PAYLOAD], arg_type, std_string):
            yield None
        add(action.set_payload(template_))
        if CONF_QOS in conf:
            template_ = None
            for template_ in templatable(conf[CONF_QOS], arg_type, uint8):
                yield
            add(action.set_qos(template_))
        if CONF_RETAIN in conf:
            template_ = None
            for template_ in templatable(conf[CONF_RETAIN], arg_type, bool_):
                yield None
            add(action.set_retain(template_))
        yield action
    elif CONF_LIGHT_TOGGLE in config:
        conf = config[CONF_LIGHT_TOGGLE]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_toggle_action(template_arg)
        type = light.ToggleAction.template(template_arg)
        action = Pvariable(config[CONF_ACTION_ID], rhs, type=type)
        if CONF_TRANSITION_LENGTH in conf:
            template_ = None
            for template_ in templatable(conf[CONF_TRANSITION_LENGTH],
                                         arg_type, uint32):
                yield None
            add(action.set_transition_length(template_))
        yield action
    elif CONF_LIGHT_TURN_OFF in config:
        conf = config[CONF_LIGHT_TURN_OFF]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_turn_off_action(template_arg)
        type = light.TurnOffAction.template(template_arg)
        action = Pvariable(config[CONF_ACTION_ID], rhs, type=type)
        if CONF_TRANSITION_LENGTH in conf:
            template_ = None
            for template_ in templatable(conf[CONF_TRANSITION_LENGTH],
                                         arg_type, uint32):
                yield None
            add(action.set_transition_length(template_))
        yield action
    elif CONF_LIGHT_TURN_ON in config:
        conf = config[CONF_LIGHT_TURN_ON]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_turn_on_action(template_arg)
        type = light.TurnOnAction.template(template_arg)
        action = Pvariable(config[CONF_ACTION_ID], rhs, type=type)
        if CONF_TRANSITION_LENGTH in conf:
            template_ = None
            for template_ in templatable(conf[CONF_TRANSITION_LENGTH],
                                         arg_type, uint32):
                yield None
            add(action.set_transition_length(template_))
        if CONF_FLASH_LENGTH in conf:
            template_ = None
            for template_ in templatable(conf[CONF_FLASH_LENGTH], arg_type,
                                         uint32):
                yield None
            add(action.set_flash_length(template_))
        if CONF_BRIGHTNESS in conf:
            template_ = None
            for template_ in templatable(conf[CONF_BRIGHTNESS], arg_type,
                                         float_):
                yield None
            add(action.set_brightness(template_))
        if CONF_RED in conf:
            template_ = None
            for template_ in templatable(conf[CONF_RED], arg_type, float_):
                yield None
            add(action.set_red(template_))
        if CONF_GREEN in conf:
            template_ = None
            for template_ in templatable(conf[CONF_GREEN], arg_type, float_):
                yield None
            add(action.set_green(template_))
        if CONF_BLUE in conf:
            template_ = None
            for template_ in templatable(conf[CONF_BLUE], arg_type, float_):
                yield None
            add(action.set_blue(template_))
        if CONF_WHITE in conf:
            template_ = None
            for template_ in templatable(conf[CONF_WHITE], arg_type, float_):
                yield None
            add(action.set_white(template_))
        if CONF_EFFECT in conf:
            template_ = None
            for template_ in templatable(conf[CONF_EFFECT], arg_type,
                                         std_string):
                yield None
            add(action.set_effect(template_))
        yield action
    elif CONF_SWITCH_TOGGLE in config:
        conf = config[CONF_SWITCH_TOGGLE]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_toggle_action(template_arg)
        type = switch.ToggleAction.template(arg_type)
        yield Pvariable(config[CONF_ACTION_ID], rhs, type=type)
    elif CONF_SWITCH_TURN_OFF in config:
        conf = config[CONF_SWITCH_TURN_OFF]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_turn_off_action(template_arg)
        type = switch.TurnOffAction.template(arg_type)
        yield Pvariable(config[CONF_ACTION_ID], rhs, type=type)
    elif CONF_SWITCH_TURN_ON in config:
        conf = config[CONF_SWITCH_TURN_ON]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_turn_on_action(template_arg)
        type = switch.TurnOnAction.template(arg_type)
        yield Pvariable(config[CONF_ACTION_ID], rhs, type=type)
    elif CONF_COVER_OPEN in config:
        conf = config[CONF_COVER_OPEN]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_open_action(template_arg)
        type = cover.OpenAction.template(arg_type)
        yield Pvariable(config[CONF_ACTION_ID], rhs, type=type)
    elif CONF_COVER_CLOSE in config:
        conf = config[CONF_COVER_CLOSE]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_close_action(template_arg)
        type = cover.CloseAction.template(arg_type)
        yield Pvariable(config[CONF_ACTION_ID], rhs, type=type)
    elif CONF_COVER_STOP in config:
        conf = config[CONF_COVER_STOP]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_stop_action(template_arg)
        type = cover.StopAction.template(arg_type)
        yield Pvariable(config[CONF_ACTION_ID], rhs, type=type)
    elif CONF_FAN_TOGGLE in config:
        conf = config[CONF_FAN_TOGGLE]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_toggle_action(template_arg)
        type = fan.ToggleAction.template(arg_type)
        yield Pvariable(config[CONF_ACTION_ID], rhs, type=type)
    elif CONF_FAN_TURN_OFF in config:
        conf = config[CONF_FAN_TURN_OFF]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_turn_off_action(template_arg)
        type = fan.TurnOffAction.template(arg_type)
        yield Pvariable(config[CONF_ACTION_ID], rhs, type=type)
    elif CONF_FAN_TURN_ON in config:
        conf = config[CONF_FAN_TURN_ON]
        for var in get_variable(conf[CONF_ID]):
            yield None
        rhs = var.make_turn_on_action(template_arg)
        type = fan.TurnOnAction.template(arg_type)
        action = Pvariable(config[CONF_ACTION_ID], rhs, type=type)
        if CONF_OSCILLATING in config:
            template_ = None
            for template_ in templatable(conf[CONF_OSCILLATING], arg_type,
                                         bool_):
                yield None
            add(action.set_oscillating(template_))
        if CONF_SPEED in config:
            template_ = None
            for template_ in templatable(conf[CONF_SPEED], arg_type,
                                         fan.FanSpeed):
                yield None
            add(action.set_speed(template_))
        yield action
    else:
        raise ESPHomeYAMLError(u"Unsupported action {}".format(config))