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.]

3 Likes

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:

2 Likes

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…

2 Likes

Hi. I’m a new user of HA, for about 1 year, with some skills in computing, but some :slight_smile:

Yesterday I made successfully the change of 1 device that measure energy for another new, both brand Shelly, and then reuse the first (old) in other stuff inside HA too.

The changes in my house were: disconnect the shelly PM plus (red) keeping the energy and power consumption data, for connecting the new Shelly “energy monitor” (white, with not relay inside) for a split HVAC device), and then reuse the PM plus (red) for another new resistive heater in the bathroom.

The process was easy:

  1. Connect and power-on my new energy monitor device (shelly white). No more action needed.

  2. Take note of the entity (or entities) that I want to conserve his history (the old device’s entity) and taking note of the full “entity ID” (not the fantasy name).

  3. Physically unplug the old device.

  4. Now, in HA, go to the Shelly devices, delete the device listed in red (for “no connection”). This step makes the trick.

  5. Now, in HA too, if you check the entity that report, for example, “energy data”, you will see an empty history record. That’s no problem, because in this step, you need to go to that entity, click on the gear associated to that entity, and paste the entity ID used for the old device.

  6. Instantly you will see the full history data, with a gap in the time between de disconnection of the old device and the connection of the new, but that is a short lost of data.

  7. Now you can connect the old device, and HA will integrate with a new entity ID. Your transplant is done.

Regards from Chile.