Wish to calculate remaining Wh from 2 batteries

Hi,
What is the best way to create a new sensor that gives me the estimated Wh available from 2 installed batteries (totalled).

So far instance, both batteries give me these as available capacities:-
9905.28 + 9832.32 = 19737.60.

Thats what the batteries capacities are.

I also know that the capacity left in both batteries is 27% (ive added both together already in a separate template).

How can I get these pieces of information outputted to a new sensor giving me an estimate of how many Wh I have remaining?

I would do 19737.60 x 0.27 = 5329.15 but I’m unsure how to translate 27% from my created template to 0.27.

Thanks for any assistance, I’m relatively new to the power of templates.

Post your current code, then we can adjust that.
And also post the sensor outputs from developer tools, so we can see how the values is coming into HA.