I have two actual sensors one is solar production and one is home consumption and it comes from ongrid solar system. I created a template sensor return to grid by subtracting the house consumption from solar production which gives return to grid. But the value in energy dashboard of that sensor does not match the actual value of that sensor.
sensors:
for solar production i have used same solar sensor
for grid consumption i have used house consumption sensor
and for return to grid I have use that template sensor ( state_class total and device_class energy) tried state_class as total increasing also.