Update sensor attribute value with automation or script

I use a template sensor like here, the attribute is last_reset so it can be used in energy dashboard. How an I update this attribute with script or automation every midnight?

Trigger based template sensor

Time trigger