How to keep old energy statistics history when changing the main meter sensor?

Hi there,

Forgive me, I’m new to this.

My system is tracking our home’s total energy consumption using a Shelly 3EM. In a few weeks, the old Ferraris meter will be replaced by a modern smart meter that HA will be able to read from.

Since the new smart meter will make the Shelly 3EM obsolete, I want to remove the 3EM from the system (or use it for a different purpose). However, I want to keep the home’s energy statistics, e.g. so that I can compare my current consumption to historic consumption.

How can I simply continue the total energy consumption history tracking while using a different sensor?

Thank you!

[I found this older similar topic Changing Energy-meter but want to keep old readings that never got a response.]


I’m not an expert on this, but I noticed that so far no one else has responded. So I’ll give it a go.

First, I’d leave the Shelly’s in place for awhile and compare data compared to your Smart Meter data. The Shellys are not too expensive and perhaps you would wish to keep them in place and buy new ones for your other project.

Also, I assume you are referring to the Energy Dashboard. Otherwise I don’t think there is necessarily an issue to solve … depending on your needs.

I THINK that you may be able to update your Energy Dashboard as follows to switch sensors and keep historical displays.

  1. Enable the Smart Meter in HA and collect data. Ensure the entities are configured correctly for use with the dashboard (especially if you use manual integration):
    Integrating your electricity grid

  2. Disable the primary entities for the Shelly’s, but to not disable the integration entities. This should hopefully stop the integration (value will stop increasing). I’ve not tested this - just my best guess.

  3. (Promptly) Add the appropriate entities to your Energy Dashboard (e.g. Add Consumption, Return etc.):

Wait a couple of hours and hopefully your new sensors will be reporting.

Good luck. If you try this please let me know if it works.

I’m interested in solving the same problem and thought maybe the solution is what is proposed above. But it is messy. I’m also wondering if it is possible to update the meter data in the database to reflect the changes.

I do not know how to solve this for past data. However, I solved it using template sensors that function as proxies or copies of the real sensors.
Consider for example my electricity consumption. The original sensor is called sensor.tasmota_mt175_bezug. With that I made a template sensor:

- name: "Stromzähler Bezug"
  unique_id: "strom_bezug"
  unit_of_measurement: "kWh"
  device_class: "energy"
  state_class: "total_increasing"
  availability: "{{ states('sensor.tasmota_mt175_bezug') | is_number }}"
  state: >-
    {{ float(states('sensor.tasmota_mt175_bezug')) }}

Now I can use that in my energy dashboard, feed it to a utility meter, or whatever. If the source sensor changes, I do not have to remove it from the energy dashboard. I just have to substitute the old sensor for the new one in that template sensor shown above.

I’d be happy to hear about better solutions though :slight_smile:


So there is no official easy way to replace one sensor with another for the same task?

This has been discussed several times, as far as I remember. Aliases have been the idea to go for, but not sure it was ever introduced.
When I changed my PV inverter, I simply added a second PV source to the dashboard. Since the old inverter is no longer delivering values, HA reports this as an error, but still pulls the old data. So when I want to look at the graphs from last year, it pulls data from the old integration. Looking at data from last week, it reads the data from the new inverter. Doesn’t bother me that the old integration shows an error, I am just interested in the Data.

Although it is no solution to your original question, you may want to consider to take this “practical” approach to handling your old and new data…

1 Like