The reason is usually that the sensor changes large value → 0 → large value. So the energy dashboard sees that large step and adds it.
What your sensor should have done was go large value → unknown → large value. The energy dashboard does not add the massive step in that case.
If the integration is causing this, log an issue. Or filter the value through a template sensor that rejects all readings less than <large_value> minus 10%, and has an availability template.
If the integration is using a value_template or template sensor, this needs adjustment to include an availability t template.
See here for an example: How To Prevent Entity From Resetting To 0? - #2 by tom_l