Best approach for replacing P1 cable (DSMR integration) while maintaining historic data

In short: what would be the best approach to replace the P1 USB cable between my ESMR/DSMR 5 meter and HA RPi, without losing any historic energy data?

I’m using the DSMR Slimme Meter integration with a P1 USB cable connected to my Sagemcom XS210 ESMR5 electricity/gas meter for a while now and it is working perfectly fine with the Energy dashboard in HA.

After installation of a 9HU patch rack and moving all the networking equipment to it, I wanted to move my HA RPi 4 too. The current P1 USB cable is too short, so I ordered a 5m version.

I assumed, perhaps somewhat naively, that it would be a matter of just replacing the cable and everything would continu to work. Clearly, that’s not the case :frowning:

The integration shows one hub for the original P1 USB cable:
/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A906SIE4-if00-port0
It has 2 devices (electricity and gas meter) and 29 entities.

When I simply disconnect the original P1 cable and connect the 5m version to the same USB port, it doesn’t work, so I added another hub for the new cable (/dev/ttyUSB1 - FT232R USB UART - FT232R USB UART, s/n: A68K38M5 - FTDI). As I interpret, only the cable’s s/n is different.

By default, DSMR 5S is selected, but that’s not the correct setting for The Netherlands. It only finds the electricity meter (not gas meter). When I select DSMR 5, it says the device is already configured.

I guess I will have to delete the existing hub / cable to be able to configure the new cable as DSMR 5 hub. But, with deleting the existing configuration, I suppose both the electricity and gas meter device as well as the underlying entities will get deleted?

Is there any chance to “simply” replace one P1 USB cable with another to continu monitoring the same ESMR/DSMR 5 meter, maintaining the historic data? For example, by altering the s/n of the cable in some config file?

Update: here are some screenshots to illustrate what I mean:

The existing P1 USB cable:

The existing devices (electricity and gas meter):

The discovered new P1 USB cable:

The message it shows when I try to add the new cable as “hub” with DSMR 5 config:

No one?
I just added some screenshots to support my post.

The trick is that both cables need to get the exact same name (or better explained: the sensors need to have the exact same name, but usually changing the device name also results in the right sensor names. It can be that you need to delete your old cable first to free up the sensor name as having 2 sensors with the same name is not possible)

So if you change your new cable to have the same as your previous one then it should work. It might be the case that you get a big spike in the first day, but that can be adjusted in developer tools → statistics.

Edit: and don’t forget to backup!

@fversteegen Thanks for the feedback!

So, basically you say it should work by simply:

  • Making a backup
    (I always make a regular full backup to my NAS + copy of the database files…the latter because I discovered some time ago that the Energy data is - or at least was - apparently not part of the full backup and I therefore lost all data);
  • Unplugging the current/old (shorter) P1 USB cable;
  • Deleting the existing cable / hub in the config;
  • Plugging in the new (longer) P1 USB cable;
  • Adding a new hub with DSMR 5;
  • Selecting the rename option and rename the new cable to the name of the old one;
  • Restarting anything?;
  • Keeping fingers crossed that all the original devices and entities remain intact/available and will be updated with new data from the new cable.

I’m surprised if it indeed depends completely on the hub’s name, but I will give it a try asap :slight_smile:

Those are indeed the steps! It would also be good to write down the exact device name and the sensor names of the old P1 cable.

@fversteegen It seems to work! :+1:

I followed the steps from my previous post.

  • As expected, I had to delete the old cable / hub configuration to be able to ad a new one with DSMR 5 profile.
  • When deleting the old cable / hub, HA warned that the devices and entities would be deleted permanently.
  • After plugging in the new cable and adding it with DSMR 5, the correct 2 devices were detected. Instead of 29 entities, only 16 entities were discovered, but the rest was already inactive before, so no problem.
  • The new entities seemed to work, but in the Energy dashboard settings and Lovelace interface of HA, errors were shown as the original entities / sensors were not available anymore.
  • I renamed the cable / hub and all active entities / sensors to the old / original names. Only after a restart of HA, alle warnings were gone.
  • Because it’s night, there is no energy production from the solar panels, but the actual live energy consumption - both gas and electricity - is updated every 10 seconds, so as far as I can see now all works as it should.
  • I will check tomorrow morning if the production sensors do their job too and if the Energy dashboard (incl. history) is being updated.

If all this keeps running, I can move my HA RPi to my patch rack :sunglasses:

Thanks for your assistance!

1 Like