Fronius solar - how to calculate energy consumption or load in Wh

I’m sure this is a stupid thing I am doing wrong so apologies.

So I think that I have energy dashboard setup correctly as I see the data in HA is showing the same info as the fronius app.

I do not have a battery so my simple maths to calculate energy consumed (used) is

solar energy produced - energy exported to grid + energy imported from grid

I have all three of the data above from the integration so I have a template sensor to calculate energy consumed.

Is this correct? I am asking as I have a slight decrease in energy consumed and this should not be possible.

Maybe a small glitch in the data? Or if the sampling rate is different between the source data sensors?

So after a bit of investigating I see that energy exported and energy imported are updated every minute but solar production is updated every 5 minutes in HA.

This explains the issue I am seeing as I am not getting updated solar production data but energy exported includes new solar production.

I’m thinking the easiest fix is to use a time triggered template sensor and update every 5 mins.