Its the right idea, but a little over-complicated. Actually [Wikipdia][1]Wikipdia shows explains it nicely:
$$\langle E\rangle =\sum_s E_s P_s =\frac{1}{Z}\sum_sE_s e^{-\beta E_s}=-\frac{1}{Z}\frac{\partial}{\partial \beta}Z=-\frac{\partial \ln Z}{\partial \beta }$$
The difference between your calculation and the one above is that in the one above the partition function is not exlicitly calculated until the end. [1]: https://en.wikipedia.org/wiki/Partition_function_(statistical_mechanics)#Calculating_the_thermodynamic_total_energy