Replace Tasmota smart socket without losing power monitoring data

Summary: Failed smart socket (power monitoring, Tasmota). How to replace with a new one, maintaining the power monitoring data for energy graphs

I have reviewed documentation, but it seems geared towards initial setup and then everything working happily forever :confused:. I’m more than happy to be shown to right docs or even to write them up if I understand it well enough after we’ve solved this.

Detail:
One of my power monitoring, switched, smart sockets has died and I want to replace it with the least disruption to my Home Assistant setup. Especially as I expect to have to do this a few times a year as these devices age out and fail.
Updating the automations and groups is fairly trivial, but it’s the energy graphs I’m concerned about.

I want the new device to be recognised as the old device or at least for it to be transparent to the UI as a continuation of the old device’s data. This is mainly so that I can continue to seamlessly compare the energy usage of (in this case) the dishwasher over time.

The sockets are these, pictured below and linked here .

I am comfortable making direct DB SOQL updates or even manipulating the ./storage registry and energy files.

Energy monitoring config override for these sockets. I don’t mind creating a separate entry for the new replacement socket if needed.

homeassistant:
  customize_glob:   
    sensor.socket_*_energy_total:
      last_reset: "1970-01-01T00:00:00+00:00"
      device_class: energy
      state_class: total_increasing

Environment:

  • HA 2022.10 - VM - Synology
  • Mosquitto - Docker - Synology
  • MariaDB - Docker - Synology
1 Like

See this thread. There are complaints and solutions suggested.
Long story short:

1 Like

[quote=“cisor, post:1, topic:479001”]

I just noticed something else about your setup. last_reset is deprecated. I don’t believe that is actually and issue but you should know
This approach has been deprecated and will be interpreted as a total_increasing state class instead with an automatic last reset.

1 Like

Thanks for the guidance @giqcass, this worked quite well.

  1. Shutdown Home Assistant
    “core stop” from console (connected via Synology VM manager)
  2. For the old device:
    a. I deleted the old device’s entries in core.entity_registry and core.device_registry.
    b. Noted the entity_ids of each
  3. For the new device:
    a. Updated all the core.entity_registry and core.device_registry entries editing the entity_id property to that of the device/ entity each was replacing
  4. Started Home Assistant
    a. “core start” from console (connected via Synology VM manager)

What I didn’t mention is that I was re-purposing another smart plug which had already been used. Unfortunately it was reading 40kWh and has over reported this to HA Energy. No big deal, but worth mentioning in case anyone else reads this who needs to do the same.
I suspect that I might have been able to avoid this with some manipulation of other properties or a DB change, but I would advise others to reset the counts on the smart plug device manually to avoid this issue

Thanks again

There is an option in the developer menu under the statistics tab. On the far right if you see a little ramp you can click that to fix data.