def invert_filter_to_code(config, filter_id): yield cg.new_Pvariable(filter_id)
async def delta_filter_to_code(config, filter_id): return cg.new_Pvariable(filter_id, config)
async def throttle_filter_to_code(config, filter_id): return cg.new_Pvariable(filter_id, config)
async def to_code(config): var = cg.new_Pvariable(config[CONF_ID], config[CONF_TAG_NAME]) await cg.register_component(var, config) await text_sensor.register_text_sensor(var, config) teleinfo = await cg.get_variable(config[CONF_TELEINFO_ID]) cg.add(teleinfo.register_teleinfo_listener(var))
async def throttle_average_filter_to_code(config, filter_id): var = cg.new_Pvariable(filter_id, config) await cg.register_component(var, {}) return var
async def ledc_set_frequency_to_code(config, action_id, template_arg, args): paren = await cg.get_variable(config[CONF_ID]) var = cg.new_Pvariable(action_id, template_arg, paren) template_ = await cg.templatable(config[CONF_FREQUENCY], args, float) cg.add(var.set_frequency(template_)) return var
async def new_func(config): var = cg.new_Pvariable(config[CONF_TRIGGER_ID]) await register_listener(var, config) await coroutine(func)(var, config) await automation.build_automation(var, [(data_type, "x")], config) return var
def delta_filter_to_code(config, filter_id): yield cg.new_Pvariable(filter_id, config)
def or_filter_to_code(config, filter_id): filters = yield build_filters(config) yield cg.new_Pvariable(filter_id, filters)
def multiply_filter_to_code(config, filter_id): yield cg.new_Pvariable(filter_id, config)
def exponential_moving_average_filter_to_code(config, filter_id): yield cg.new_Pvariable(filter_id, config[CONF_ALPHA], config[CONF_SEND_EVERY])
def offset_filter_to_code(config, filter_id): yield cg.new_Pvariable(filter_id, config)
async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await text_sensor.register_text_sensor(var, config) await cg.register_component(var, config) cg.add(var.set_hide_timestamp(config[CONF_HIDE_TIMESTAMP]))
def lambda_filter_to_code(config, filter_id): lambda_ = yield cg.process_lambda(config, [(bool, 'x')], return_type=cg.optional.template(bool)) yield cg.new_Pvariable(filter_id, lambda_)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) cg.add(var.set_method(METHODS[config[CONF_METHOD]]))
def throttle_filter_to_code(config, filter_id): yield cg.new_Pvariable(filter_id, config)
async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await cg.register_component(var, config) await climate.register_climate(var, config) heat_cool_mode_available = CONF_HEAT_ACTION in config and CONF_COOL_ACTION in config two_points_available = CONF_HEAT_ACTION in config and ( CONF_COOL_ACTION in config or CONF_FAN_ONLY_ACTION in config ) sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) cg.add(var.set_hysteresis(config[CONF_HYSTERESIS])) if two_points_available is True: cg.add(var.set_supports_two_points(True)) normal_config = ThermostatClimateTargetTempConfig( config[CONF_DEFAULT_TARGET_TEMPERATURE_LOW], config[CONF_DEFAULT_TARGET_TEMPERATURE_HIGH], ) elif CONF_DEFAULT_TARGET_TEMPERATURE_HIGH in config: cg.add(var.set_supports_two_points(False)) normal_config = ThermostatClimateTargetTempConfig( config[CONF_DEFAULT_TARGET_TEMPERATURE_HIGH] ) elif CONF_DEFAULT_TARGET_TEMPERATURE_LOW in config: cg.add(var.set_supports_two_points(False)) normal_config = ThermostatClimateTargetTempConfig( config[CONF_DEFAULT_TARGET_TEMPERATURE_LOW] ) cg.add(var.set_normal_config(normal_config)) await automation.build_automation( var.get_idle_action_trigger(), [], config[CONF_IDLE_ACTION] ) if heat_cool_mode_available is True: cg.add(var.set_supports_heat_cool(True)) else: cg.add(var.set_supports_heat_cool(False)) if CONF_COOL_ACTION in config: await automation.build_automation( var.get_cool_action_trigger(), [], config[CONF_COOL_ACTION] ) cg.add(var.set_supports_cool(True)) if CONF_DRY_ACTION in config: await automation.build_automation( var.get_dry_action_trigger(), [], config[CONF_DRY_ACTION] ) cg.add(var.set_supports_dry(True)) if CONF_FAN_ONLY_ACTION in config: await automation.build_automation( var.get_fan_only_action_trigger(), [], config[CONF_FAN_ONLY_ACTION] ) cg.add(var.set_supports_fan_only(True)) if CONF_HEAT_ACTION in config: await automation.build_automation( var.get_heat_action_trigger(), [], config[CONF_HEAT_ACTION] ) cg.add(var.set_supports_heat(True)) if CONF_AUTO_MODE in config: await automation.build_automation( var.get_auto_mode_trigger(), [], config[CONF_AUTO_MODE] ) if CONF_COOL_MODE in config: await automation.build_automation( var.get_cool_mode_trigger(), [], config[CONF_COOL_MODE] ) cg.add(var.set_supports_cool(True)) if CONF_DRY_MODE in config: await automation.build_automation( var.get_dry_mode_trigger(), [], config[CONF_DRY_MODE] ) cg.add(var.set_supports_dry(True)) if CONF_FAN_ONLY_MODE in config: await automation.build_automation( var.get_fan_only_mode_trigger(), [], config[CONF_FAN_ONLY_MODE] ) cg.add(var.set_supports_fan_only(True)) if CONF_HEAT_MODE in config: await automation.build_automation( var.get_heat_mode_trigger(), [], config[CONF_HEAT_MODE] ) cg.add(var.set_supports_heat(True)) if CONF_OFF_MODE in config: await automation.build_automation( var.get_off_mode_trigger(), [], config[CONF_OFF_MODE] ) if CONF_FAN_MODE_ON_ACTION in config: await automation.build_automation( var.get_fan_mode_on_trigger(), [], config[CONF_FAN_MODE_ON_ACTION] ) cg.add(var.set_supports_fan_mode_on(True)) if CONF_FAN_MODE_OFF_ACTION in config: await automation.build_automation( var.get_fan_mode_off_trigger(), [], config[CONF_FAN_MODE_OFF_ACTION] ) cg.add(var.set_supports_fan_mode_off(True)) if CONF_FAN_MODE_AUTO_ACTION in config: await automation.build_automation( var.get_fan_mode_auto_trigger(), [], config[CONF_FAN_MODE_AUTO_ACTION] ) cg.add(var.set_supports_fan_mode_auto(True)) if CONF_FAN_MODE_LOW_ACTION in config: await automation.build_automation( var.get_fan_mode_low_trigger(), [], config[CONF_FAN_MODE_LOW_ACTION] ) cg.add(var.set_supports_fan_mode_low(True)) if CONF_FAN_MODE_MEDIUM_ACTION in config: await automation.build_automation( var.get_fan_mode_medium_trigger(), [], config[CONF_FAN_MODE_MEDIUM_ACTION] ) cg.add(var.set_supports_fan_mode_medium(True)) if CONF_FAN_MODE_HIGH_ACTION in config: await automation.build_automation( var.get_fan_mode_high_trigger(), [], config[CONF_FAN_MODE_HIGH_ACTION] ) cg.add(var.set_supports_fan_mode_high(True)) if CONF_FAN_MODE_MIDDLE_ACTION in config: await automation.build_automation( var.get_fan_mode_middle_trigger(), [], config[CONF_FAN_MODE_MIDDLE_ACTION] ) cg.add(var.set_supports_fan_mode_middle(True)) if CONF_FAN_MODE_FOCUS_ACTION in config: await automation.build_automation( var.get_fan_mode_focus_trigger(), [], config[CONF_FAN_MODE_FOCUS_ACTION] ) cg.add(var.set_supports_fan_mode_focus(True)) if CONF_FAN_MODE_DIFFUSE_ACTION in config: await automation.build_automation( var.get_fan_mode_diffuse_trigger(), [], config[CONF_FAN_MODE_DIFFUSE_ACTION] ) cg.add(var.set_supports_fan_mode_diffuse(True)) if CONF_SWING_BOTH_ACTION in config: await automation.build_automation( var.get_swing_mode_both_trigger(), [], config[CONF_SWING_BOTH_ACTION] ) cg.add(var.set_supports_swing_mode_both(True)) if CONF_SWING_HORIZONTAL_ACTION in config: await automation.build_automation( var.get_swing_mode_horizontal_trigger(), [], config[CONF_SWING_HORIZONTAL_ACTION], ) cg.add(var.set_supports_swing_mode_horizontal(True)) if CONF_SWING_OFF_ACTION in config: await automation.build_automation( var.get_swing_mode_off_trigger(), [], config[CONF_SWING_OFF_ACTION] ) cg.add(var.set_supports_swing_mode_off(True)) if CONF_SWING_VERTICAL_ACTION in config: await automation.build_automation( var.get_swing_mode_vertical_trigger(), [], config[CONF_SWING_VERTICAL_ACTION], ) cg.add(var.set_supports_swing_mode_vertical(True)) if CONF_AWAY_CONFIG in config: away = config[CONF_AWAY_CONFIG] if two_points_available is True: away_config = ThermostatClimateTargetTempConfig( away[CONF_DEFAULT_TARGET_TEMPERATURE_LOW], away[CONF_DEFAULT_TARGET_TEMPERATURE_HIGH], ) elif CONF_DEFAULT_TARGET_TEMPERATURE_HIGH in away: away_config = ThermostatClimateTargetTempConfig( away[CONF_DEFAULT_TARGET_TEMPERATURE_HIGH] ) elif CONF_DEFAULT_TARGET_TEMPERATURE_LOW in away: away_config = ThermostatClimateTargetTempConfig( away[CONF_DEFAULT_TARGET_TEMPERATURE_LOW] ) cg.add(var.set_away_config(away_config))
def debounce_filter_to_code(config, filter_id): var = cg.new_Pvariable(filter_id, config) yield cg.register_component(var, {}) yield var
async def new_func(config, action_id, template_arg, args): ac_ = await cg.get_variable(config[CONF_ID]) var = cg.new_Pvariable(action_id, template_arg) cg.add(var.set_parent(ac_)) await coroutine(func)(var, config, args) return var
def new_sensor(config): var = cg.new_Pvariable(config[CONF_ID]) yield register_sensor(var, config) yield var
async def new_func(config, dumper_id): var = cg.new_Pvariable(dumper_id) await coroutine(func)(var, config) return var
async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) cg.add(var.set_duration(config[CONF_DURATION])) cg.add(var.set_width(config[CONF_WIDTH])) cg.add(var.set_height(config[CONF_HEIGHT])) await cg.register_component(var, config) # Graph options if CONF_X_GRID in config: cg.add(var.set_grid_x(config[CONF_X_GRID])) if CONF_Y_GRID in config: cg.add(var.set_grid_y(config[CONF_Y_GRID])) if CONF_BORDER in config: cg.add(var.set_border(config[CONF_BORDER])) # Axis related options if CONF_MIN_VALUE in config: cg.add(var.set_min_value(config[CONF_MIN_VALUE])) if CONF_MAX_VALUE in config: cg.add(var.set_max_value(config[CONF_MAX_VALUE])) if CONF_MIN_RANGE in config: cg.add(var.set_min_range(config[CONF_MIN_RANGE])) if CONF_MAX_RANGE in config: cg.add(var.set_max_range(config[CONF_MAX_RANGE])) # Trace options for trace in config[CONF_TRACES]: tr = cg.new_Pvariable(trace[CONF_ID], GraphTrace()) sens = await cg.get_variable(trace[CONF_SENSOR]) cg.add(tr.set_sensor(sens)) if CONF_NAME in trace: cg.add(tr.set_name(trace[CONF_NAME])) else: cg.add(tr.set_name(trace[CONF_SENSOR].id)) if CONF_LINE_THICKNESS in trace: cg.add(tr.set_line_thickness(trace[CONF_LINE_THICKNESS])) if CONF_LINE_TYPE in trace: cg.add(tr.set_line_type(trace[CONF_LINE_TYPE])) if CONF_COLOR in trace: c = await cg.get_variable(trace[CONF_COLOR]) cg.add(tr.set_line_color(c)) cg.add(var.add_trace(tr)) # Add legend if CONF_LEGEND in config: lgd = config[CONF_LEGEND][0] legend = cg.new_Pvariable(lgd[CONF_ID], GraphLegend()) if CONF_NAME_FONT in lgd: font = await cg.get_variable(lgd[CONF_NAME_FONT]) cg.add(legend.set_name_font(font)) if CONF_VALUE_FONT in lgd: font = await cg.get_variable(lgd[CONF_VALUE_FONT]) cg.add(legend.set_value_font(font)) if CONF_WIDTH in lgd: cg.add(legend.set_width(lgd[CONF_WIDTH])) if CONF_HEIGHT in lgd: cg.add(legend.set_height(lgd[CONF_HEIGHT])) if CONF_BORDER in lgd: cg.add(legend.set_border(lgd[CONF_BORDER])) if CONF_SHOW_LINES in lgd: cg.add(legend.set_lines(lgd[CONF_SHOW_LINES])) if CONF_SHOW_VALUES in lgd: cg.add(legend.set_values(lgd[CONF_SHOW_VALUES])) if CONF_SHOW_UNITS in lgd: cg.add(legend.set_units(lgd[CONF_SHOW_UNITS])) if CONF_DIRECTION in lgd: cg.add(legend.set_direction(lgd[CONF_DIRECTION])) cg.add(var.add_legend(legend)) cg.add_define("USE_GRAPH")
async def multiply_filter_to_code(config, filter_id): return cg.new_Pvariable(filter_id, config)
def wifi_connected_to_code(config, condition_id, template_arg, args): yield cg.new_Pvariable(condition_id, template_arg)
async def lambda_filter_to_code(config, filter_id): lambda_ = await cg.process_lambda(config, [(float, "x")], return_type=cg.optional.template(float)) return cg.new_Pvariable(filter_id, lambda_)
def new_func(config): var = cg.new_Pvariable(config[CONF_TRIGGER_ID]) yield register_listener(var, config) yield coroutine(func)(var, config) yield automation.build_automation(var, [(data_type, 'x')], config) yield var
async def or_filter_to_code(config, filter_id): filters = await build_filters(config) return cg.new_Pvariable(filter_id, filters)
def new_func(config, dumper_id): var = cg.new_Pvariable(dumper_id) yield coroutine(func)(var, config) yield var
async def heartbeat_filter_to_code(config, filter_id): var = cg.new_Pvariable(filter_id, config) await cg.register_component(var, {}) return var
def binary_sensor_is_off_to_code(config, condition_id, template_arg, args): paren = yield cg.get_variable(config[CONF_ID]) yield cg.new_Pvariable(condition_id, template_arg, paren, False)