OK I think it is because your "idxCompteurIntelligent" is new and it has now initial value, so it return a nil value.
For the first time, the new CompteurIntelligent need to be initialize.
Can you add these lines before : EnergyImport = EnergyImportLow + EnergyImportHigh

-- For the first time, the value are not initilize in the smart counter, we set 0 by default.
if(EnergyImportLow == nil)then
EnergyImportLow =0
EnergyImportHigh =0
EnergyExportLow = 0
EnergyExportHigh =0
PowerImport = 0
PowerExport = 0
end