How can one compute the CPI All items index from the component indexes? How can one compute the CPI All items index given the CPI energy index and the less energy index? I used the relative importance as component weighted value but it isn't true.
I'm afraid that with the information you state, this is impossible.

Say there are three items in the CPI: housing, food, and energy. Define the weight of each component in total CPI, weight which can vary over period, as $w_{h,t}$, $w_{f,t}$, and $w_{e,t}$ respectively. By definition, they add up to 1. Similarly, define the CPI series of each item as $P_{h,t}$, $P_{f,t}$, and $P_{e,t}$ respectively. 

The CPI index for all but energy goods, $P_{hf,t}$ is given by:

$$ P_{hf,t} \equiv \frac{w_{h,t}}{w_{h,t}+w_{f,t}}P_{h,t} + \frac{w_{f,t}}{w_{h,t}+w_{f,t}}P_{f,t}$$

Although you know $P_{hf,t}$, you do not know any of the other 4 terms, for each period. As such, this is an undetermined system. In the case of a CPI with $N$ items, the system has $2(N-1)$ unknowns.

If weights are constant, you cannot get much further either. Say that you have $T$ number of periods. Then, you have a system of equations like

$$ A_{t} = bX_{t} + cY_{t} $$

where only $A_{t}$ is known. This is also undetermined. You can only write $X_{t}$ as a function of $Y_{t}$, $b$ and $c$. (and viceversa).

A second best approach?

You have one option though. You could compute the "vector distribution" of the all-CPI index. To see this, notice that the total price index, $P_{t}$ is

$$ P_{t} \equiv w_{h,t}P_{h,t} + w_{f,t}P_{f,t} + w_{e,t}P_{e,t} $$

This is equal to

$$ P_{t} = (w_{h,t}+w_{f,t})P_{hf,t} + w_{e,t}P_{e,t} $$

But weights add up to one. Therefore, 

$$ P_{t} = (1-w_{e,t})P_{hf,t} + w_{e,t}P_{e,t} $$

Or better:

$$ P_{t} = P_{hf,t} + w_{e,t}(P_{e,t}-P_{hf,t}) $$

Now, since you know the CPI index for energy-only ($P_{e,t}$) and for all-but-energy ($P_{hf,t}$), you could compute $P_{t}$ for a given assumption on the energy weight on total CPI. You can, for instance, look into other similar countries and see how much this weight is. Or look for related information on this respect. This number cannot be wildly different across countries. So you can still get a rough idea of general CPI.