Energy measurement with mqtt sensor

Maybe this (or the following posts) is the answer, it uses a last reset attribute: