def to_code(config): sender = yield cg.get_variable(config[GCodeSender.CONF_GCODE_SENDER]) var = cg.new_Pvariable(config[CONF_ID], sender, config[CONF_HEATER_ELEMENTS], config[CONF_TOOL_INDEX]) yield cg.register_component(var, config) yield GCodeQueue.register_gcode_analyzer(var, config) yield climate.register_climate(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) paren = yield cg.get_variable(config[CONF_TUYA_ID]) cg.add(var.set_tuya_parent(paren)) if CONF_SWITCH_DATAPOINT in config: cg.add(var.set_switch_id(config[CONF_SWITCH_DATAPOINT])) if CONF_TARGET_TEMPERATURE_DATAPOINT in config: cg.add( var.set_target_temperature_id( config[CONF_TARGET_TEMPERATURE_DATAPOINT])) if CONF_CURRENT_TEMPERATURE_DATAPOINT in config: cg.add( var.set_current_temperature_id( config[CONF_CURRENT_TEMPERATURE_DATAPOINT])) if CONF_TEMPERATURE_MULTIPLIER in config: cg.add( var.set_target_temperature_multiplier( config[CONF_TEMPERATURE_MULTIPLIER])) cg.add( var.set_current_temperature_multiplier( config[CONF_TEMPERATURE_MULTIPLIER])) else: cg.add( var.set_current_temperature_multiplier( config[CONF_CURRENT_TEMPERATURE_MULTIPLIER])) cg.add( var.set_target_temperature_multiplier( config[CONF_TARGET_TEMPERATURE_MULTIPLIER]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) sens = yield cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) normal_config = BangBangClimateTargetTempConfig( config[CONF_DEFAULT_TARGET_TEMPERATURE_LOW], config[CONF_DEFAULT_TARGET_TEMPERATURE_HIGH]) cg.add(var.set_normal_config(normal_config)) yield automation.build_automation(var.get_idle_trigger(), [], config[CONF_IDLE_ACTION]) if CONF_COOL_ACTION in config: yield automation.build_automation(var.get_cool_trigger(), [], config[CONF_COOL_ACTION]) cg.add(var.set_supports_cool(True)) if CONF_HEAT_ACTION in config: yield automation.build_automation(var.get_heat_trigger(), [], config[CONF_HEAT_ACTION]) cg.add(var.set_supports_heat(True)) if CONF_AWAY_CONFIG in config: away = config[CONF_AWAY_CONFIG] away_config = BangBangClimateTargetTempConfig( away[CONF_DEFAULT_TARGET_TEMPERATURE_LOW], away[CONF_DEFAULT_TARGET_TEMPERATURE_HIGH]) cg.add(var.set_away_config(away_config))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) sens = yield cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) if CONF_COOL_OUTPUT in config: out = yield cg.get_variable(config[CONF_COOL_OUTPUT]) cg.add(var.set_cool_output(out)) if CONF_HEAT_OUTPUT in config: out = yield cg.get_variable(config[CONF_HEAT_OUTPUT]) cg.add(var.set_heat_output(out)) params = config[CONF_CONTROL_PARAMETERS] cg.add(var.set_kp(params[CONF_KP])) cg.add(var.set_ki(params[CONF_KI])) cg.add(var.set_kd(params[CONF_KD])) if CONF_MIN_INTEGRAL in params: cg.add(var.set_min_integral(params[CONF_MIN_INTEGRAL])) if CONF_MAX_INTEGRAL in params: cg.add(var.set_max_integral(params[CONF_MAX_INTEGRAL])) cg.add( var.set_default_target_temperature( config[CONF_DEFAULT_TARGET_TEMPERATURE]))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) time_ = yield cg.get_variable(config[CONF_TIME_ID]) cg.add(var.set_time(time_)) if CONF_TEMP in config: sens = yield cg.get_variable(config[CONF_TEMP]) cg.add(var.set_temperature_sensor(sens)) if CONF_VALVE in config: sens = yield sensor.new_sensor(config[CONF_VALVE]) cg.add(var.set_valve(sens)) if CONF_ECO in config: sens = yield sensor.new_sensor(config[CONF_ECO]) cg.add(var.set_eco(sens)) if CONF_COMFORT in config: sens = yield sensor.new_sensor(config[CONF_COMFORT]) cg.add(var.set_comfort(sens)) cg.add(var.set_offset(config[CONF_OFFSET]))
def to_code(config): genvex = yield cg.get_variable(config[CONF_GENVEX_ID]) var = cg.new_Pvariable(config[CONF_ID], genvex) yield cg.register_component(var, config) yield climate.register_climate(var, config) sens = yield cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens))
def to_code(config): template_ = yield cg.process_lambda(config[CONF_LAMBDA], [], return_type=cg.std_vector.template( climate.Climate.operator('ptr'))) rhs = CustomClimateConstructor(template_) custom = cg.variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_CLIMATES]): rhs = custom.Pget_climate(i) yield climate.register_climate(rhs, conf)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) if CONF_SENSOR in config: sens = yield cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) transmitter = yield cg.get_variable(config[CONF_TRANSMITTER_ID]) cg.add(var.set_transmitter(transmitter))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) number_set_temp = yield cg.get_variable(config[CONF_TARGET_TEMP]) cg.add(var.set_temp_setpoint_number(number_set_temp)) sens_current_temp = yield cg.get_variable(config[CONF_CURRENT_TEMP]) cg.add(var.current_temp_sensor(sens_current_temp)) read_mode = yield cg.get_variable(config[CONF_MODE]) cg.add(var.mode_select(read_mode))
def to_code(config): wavin = yield cg.get_variable(config[CONF_WAVINAHC9000_ID]) var = cg.new_Pvariable(config[CONF_ID], wavin) yield cg.register_component(var, config) yield climate.register_climate(var, config) cg.add(var.set_channel(config[CONF_CHANNEL] - 1)) if CONF_BATTERY_LEVEL in config: sens = yield sensor.new_sensor(config[CONF_BATTERY_LEVEL]) cg.add(var.set_battery_level_sensor(sens)) if CONF_CURRENT_TEMP in config: sens = yield sensor.new_sensor(config[CONF_CURRENT_TEMP]) cg.add(var.set_current_temp_sensor(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) cg.add(var.set_supports_cool(config[CONF_SUPPORTS_COOL])) cg.add(var.set_supports_heat(config[CONF_SUPPORTS_HEAT])) if CONF_SENSOR in config: sens = yield cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) transmitter = yield cg.get_variable(config[CONF_TRANSMITTER_ID]) cg.add(var.set_transmitter(transmitter))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) cg.add_library('IRRemoteESP8266', None) # cg.add_library('IRRemoteESP8266', '2.7.7') yield cg.register_component(var, config) yield climate.register_climate(var, config) # cg.add(var.set_pin(config[CONF_PIN])) pin = yield gpio_pin_expression(config[CONF_PIN]) cg.add(var.set_pin(pin)) if CONF_SENSOR in config: sens = yield cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) cg.add(var.set_address(config[CONF_MAC_ADDRESS].as_hex)) cg.add(var.set_pin(config[CONF_PIN])) cg.add(var.set_temperature_offset(config[CONF_TEMPERATURE_OFFSET])) cg.add( var.set_window_open_config(config[CONF_WINDOW_OPEN_SENSITIVITY], config[CONF_WINDOW_OPEN_MINUTES])) time_ = yield cg.get_variable(config[CONF_TIME_ID]) cg.add(var.set_time(time_))
def register_climate_ir(var, config): yield cg.register_component(var, config) yield climate.register_climate(var, config) cg.add(var.set_supports_cool(config[CONF_SUPPORTS_COOL])) cg.add(var.set_supports_heat(config[CONF_SUPPORTS_HEAT])) if CONF_SENSOR in config: sens = yield cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) if CONF_RECEIVER_ID in config: receiver = yield cg.get_variable(config[CONF_RECEIVER_ID]) cg.add(receiver.register_listener(var)) transmitter = yield cg.get_variable(config[CONF_TRANSMITTER_ID]) cg.add(var.set_transmitter(transmitter))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) number_set_temp = yield cg.get_variable(config[CONF_TARGET_TEMP]) cg.add(var.set_temp_setpoint_number(number_set_temp)) sens_current_temp = yield cg.get_variable(config[CONF_CURRENT_TEMP]) cg.add(var.set_current_temp_sensor(sens_current_temp)) switch_mode = yield cg.get_variable(config[CONF_MODE]) cg.add(var.set_mode_switch(switch_mode)) hvac_action = yield cg.get_variable(config[CONF_ACTION]) cg.add(var.set_hvac_action(hvac_action))
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) paren = yield cg.get_variable(config[CONF_MIDEA_DONGLE_ID]) cg.add(var.set_midea_dongle_parent(paren)) cg.add(var.set_beeper_feedback(config[CONF_BEEPER])) cg.add(var.set_swing_horizontal(config[CONF_SWING_HORIZONTAL])) cg.add(var.set_swing_both(config[CONF_SWING_BOTH])) if CONF_OUTDOOR_TEMPERATURE in config: sens = yield sensor.new_sensor(config[CONF_OUTDOOR_TEMPERATURE]) cg.add(var.set_outdoor_temperature_sensor(sens)) if CONF_POWER_USAGE in config: sens = yield sensor.new_sensor(config[CONF_POWER_USAGE]) cg.add(var.set_power_sensor(sens)) if CONF_HUMIDITY_SETPOINT in config: sens = yield sensor.new_sensor(config[CONF_HUMIDITY_SETPOINT]) cg.add(var.set_humidity_setpoint_sensor(sens))
def to_code(config): serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f'&{serial}')) if CONF_BAUD_RATE in config: cg.add(var.set_baud_rate(config[CONF_BAUD_RATE])) traits = [] for mode in config[CONF_SUPPORTS][CONF_MODE]: if mode == 'OFF': continue traits.append(f'set_supports_{mode.lower()}_mode') for mode in config[CONF_SUPPORTS][CONF_FAN_MODE]: traits.append(f'set_supports_fan_mode_{mode.lower()}') for mode in config[CONF_SUPPORTS][CONF_SWING_MODE]: traits.append(f'set_supports_swing_mode_{mode.lower()}') for trait in traits: cg.add(getattr(var.config_traits(), trait)(True)) yield cg.register_component(var, config) yield climate.register_climate(var, config) cg.add_library("https://github.com/SwiCago/HeatPump", None)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) auto_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 = yield 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)) yield automation.build_automation(var.get_idle_action_trigger(), [], config[CONF_IDLE_ACTION]) if auto_mode_available is True: cg.add(var.set_supports_auto(True)) else: cg.add(var.set_supports_auto(False)) if CONF_COOL_ACTION in config: yield 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: yield 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: yield 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: yield 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: yield automation.build_automation(var.get_auto_mode_trigger(), [], config[CONF_AUTO_MODE]) if CONF_COOL_MODE in config: yield 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: yield 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: yield 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: yield 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: yield automation.build_automation(var.get_off_mode_trigger(), [], config[CONF_OFF_MODE]) if CONF_FAN_MODE_ON_ACTION in config: yield 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: yield 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: yield 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: yield 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: yield 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: yield 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: yield 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: yield 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: yield 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: yield 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: yield 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: yield 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: yield 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 to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) yield ble_client.register_ble_node(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) yield climate.register_climate(var, config) yield rs485.register_rs485_device(var, config) templ = yield cg.templatable(config[CONF_COMMAND_TEMPERATURE], [(cg.float_.operator('const'), 'x')], cmd_hex_t) cg.add(var.set_command_temperature(templ)) state = config[CONF_STATE_TARGET] if cg.is_template(state): templ = yield cg.templatable(state, [(uint8_ptr_const, 'data'), (num_t_const, 'len')], cg.float_) cg.add(var.set_state_target(templ)) else: args = yield state[CONF_OFFSET], state[CONF_LENGTH], state[ CONF_PRECISION] cg.add(var.set_state_target(args)) if CONF_SENSOR in config: sens = yield cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) if CONF_STATE_CURRENT in config: state = config[CONF_STATE_CURRENT] if cg.is_template(state): templ = yield cg.templatable(state, [(uint8_ptr_const, 'data'), (num_t_const, 'len')], cg.float_) cg.add(var.set_state_current(templ)) else: args = yield state[CONF_OFFSET], state[CONF_LENGTH], state[ CONF_PRECISION] cg.add(var.set_state_current(args)) if CONF_STATE_AUTO in config: args = yield state_hex_expression(config[CONF_STATE_AUTO]) cg.add(var.set_state_auto(args)) if CONF_STATE_HEAT in config: args = yield state_hex_expression(config[CONF_STATE_HEAT]) cg.add(var.set_state_heat(args)) if CONF_STATE_COOL in config: args = yield state_hex_expression(config[CONF_STATE_COOL]) cg.add(var.set_state_cool(args)) if CONF_STATE_AWAY in config: args = yield state_hex_expression(config[CONF_STATE_AWAY]) cg.add(var.set_state_away(args)) if CONF_COMMAND_AUTO in config: args = yield command_hex_expression(config[CONF_COMMAND_AUTO]) cg.add(var.set_command_auto(args)) if CONF_COMMAND_HEAT in config: args = yield command_hex_expression(config[CONF_COMMAND_HEAT]) cg.add(var.set_command_heat(args)) if CONF_COMMAND_COOL in config: args = yield command_hex_expression(config[CONF_COMMAND_COOL]) cg.add(var.set_command_cool(args)) if CONF_COMMAND_AWAY in config: args = yield command_hex_expression(config[CONF_COMMAND_AWAY]) cg.add(var.set_command_away(args))