def to_code(config): interval = config[CONF_UPDATE_INTERVAL] del config[CONF_UPDATE_INTERVAL] fan_state = yield fan.create_fan_state(config) config[CONF_UPDATE_INTERVAL] = interval var = cg.new_Pvariable(config[CONF_OUTPUT_ID], fan_state) yield cg.register_component(var, config) speeds = config[CONF_SPEED] if CONF_LOW in speeds: speed = speeds[CONF_LOW] state = yield state_hex_expression(speed[CONF_STATE]) command = yield command_hex_expression(speed[CONF_COMMAND]) cg.add(var.set_speed_low(state, command)) if CONF_MEDIUM in speeds: speed = speeds[CONF_MEDIUM] state = yield state_hex_expression(speed[CONF_STATE]) command = yield command_hex_expression(speed[CONF_COMMAND]) cg.add(var.set_speed_medium(state, command)) if CONF_HIGH in speeds: speed = speeds[CONF_HIGH] state = yield state_hex_expression(speed[CONF_STATE]) command = yield command_hex_expression(speed[CONF_COMMAND]) cg.add(var.set_speed_high(state, command)) yield rs485.register_rs485_device(var, config)
def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) yield cg.register_component(var, config) fan_ = yield fan.create_fan_state(config) cg.add(var.set_fan(fan_)) output_ = yield cg.get_variable(config[CONF_OUTPUT]) cg.add(var.set_output(output_)) if CONF_OSCILLATION_OUTPUT in config: oscillation_output = yield cg.get_variable( config[CONF_OSCILLATION_OUTPUT]) cg.add(var.set_oscillation(oscillation_output))
def to_code(config): output_ = yield cg.get_variable(config[CONF_OUTPUT]) state = yield fan.create_fan_state(config) var = cg.new_Pvariable(config[CONF_OUTPUT_ID], state, output_) yield cg.register_component(var, config) speeds = config[CONF_SPEED] cg.add( var.set_speeds(speeds[CONF_LOW], speeds[CONF_MEDIUM], speeds[CONF_HIGH])) if CONF_OSCILLATION_OUTPUT in config: oscillation_output = yield cg.get_variable( config[CONF_OSCILLATION_OUTPUT]) cg.add(var.set_oscillating(oscillation_output))
def to_code(config): output_ = yield cg.get_variable(config[CONF_OUTPUT]) state = yield fan.create_fan_state(config) var = cg.new_Pvariable(config[CONF_OUTPUT_ID], state, output_, config[CONF_SPEED_COUNT]) yield cg.register_component(var, config) if CONF_OSCILLATION_OUTPUT in config: oscillation_output = yield cg.get_variable( config[CONF_OSCILLATION_OUTPUT]) cg.add(var.set_oscillating(oscillation_output)) if CONF_DIRECTION_OUTPUT in config: direction_output = yield cg.get_variable(config[CONF_DIRECTION_OUTPUT]) cg.add(var.set_direction(direction_output))
def to_code(config): var = cg.new_Pvariable(config[CONF_OUTPUT_ID]) yield cg.register_component(var, config) paren = yield cg.get_variable(config[CONF_TUYA_ID]) fan_ = yield fan.create_fan_state(config) cg.add(var.set_tuya_parent(paren)) cg.add(var.set_fan(fan_)) if CONF_SPEED_DATAPOINT in config: cg.add(var.set_speed_id(config[CONF_SPEED_DATAPOINT])) if CONF_SWITCH_DATAPOINT in config: cg.add(var.set_switch_id(config[CONF_SWITCH_DATAPOINT])) if CONF_OSCILLATION_DATAPOINT in config: cg.add(var.set_oscillation_id(config[CONF_OSCILLATION_DATAPOINT]))
def to_code(config): parent = yield cg.get_variable(config[CONF_TUYA_ID]) state = yield fan.create_fan_state(config) var = cg.new_Pvariable(config[CONF_OUTPUT_ID], parent, state, config[CONF_SPEED_COUNT]) yield cg.register_component(var, config) if CONF_SPEED_DATAPOINT in config: cg.add(var.set_speed_id(config[CONF_SPEED_DATAPOINT])) if CONF_SWITCH_DATAPOINT in config: cg.add(var.set_switch_id(config[CONF_SWITCH_DATAPOINT])) if CONF_OSCILLATION_DATAPOINT in config: cg.add(var.set_oscillation_id(config[CONF_OSCILLATION_DATAPOINT])) if CONF_DIRECTION_DATAPOINT in config: cg.add(var.set_direction_id(config[CONF_DIRECTION_DATAPOINT]))
def to_code(config): state = yield fan.create_fan_state(config) var = cg.new_Pvariable(config[CONF_OUTPUT_ID], state) yield cg.register_component(var, config)