Statistics not being generated on Template Sensor

Hi, I have created a sensor using the old methodology, which is

sensor:  
- platform: template    
  sensors:       
    currentelectriccost:        
       friendly_name: "Current Electric Cost"        
       unit_of_measurement: "GBP"        
       value_template: "{{ (states('sensor.lux_power_from_grid_live') | float) * ((states('sensor.octopus_energy_electricity_21e5390550_2321143881010_current_rate')|float )/1000) }} "

this works fine in collecting statistics as you can see here:

Screenshot 2023-04-13 at 16.03.25

Yet when I convert it to the new methodology:

template:  
- sensor:    
  - name: "CurrentElectricCost2"      
   unique_id: "CurrentElectricCost2"      
   device_class: monetary
   state_class: total
   state: <-
      "{{ (states('sensor.lux_power_from_grid_live') | float) * ((states('sensor.octopus_energy_electricity_21e5390550_2321143881010_current_rate')|float )/1000) }} "
      

It does not generate any history, as you can see here:

Screenshot 2023-04-13 at 16.03.34

Do I have to set up a separate Statistics template to do this?

Any help greatly appreciated.

Mike