Result values from utility meter

I want to have weekly values of my power and gas consumption, so I use the “utility meter” integration. The result is a sensor value which is increasing during the week and then set to 0. If I want to send the weekly values to influxdb, I have to create a template sensor and copy the “last_period” attribute from the utlity sensor. Is this the right way to do it?

No. Just send the utility meter to influx. You can then select the maximum value per week in Grafana (assuming that was your end goal).

This seems to be a dirty work around. Because if I want to do more analyses with my data, it will fail.

What sort of analysis?

You can always do the same thing with your query.