[SOLVED] Replacing (custom) sensor with group sensor (SUM) - without loosing Energy Data

Hi everyone,

since there is an option on the recent release (02.2023) to create a group unsing sensors as members, I would like to create one sensor group os current power consuption (SUM).

However, I have a custom sensor which is doing this since a few months:

# ******** STROM akt.
- platform: template # Leistungsaufnahme aktuell in W (Sum of all known consumption values)
  sensors:
    energy_consumption_current_w:
      friendly_name: Stromverbrauch akt. [W]
      unique_id: sensor_energy_consumption_current_w
      unit_of_measurement: "W"
      icon_template: "mdi:flash"
      device_class: energy
      value_template: "{{ (states ('sensor.energy_consumption_base_w') | float(2) | round (1)
      + states ('sensor.bogenlampe_power_2') | float(2) | round (1)
      + states ('sensor.wohnzimmerstrom_power_3') | float(2) | round (1)
      + states ('sensor.kaffeemaschine_power') | float(2) | round (1)
      + states ('sensor.tasmota_buro_energy_power') | float(2) | round (1)
      + states ('sensor.tasmota_drucker_tasmota_energy_power') | float(2) | round (1)
      + states ('sensor.tasmota_desk_energy_power') | float(2) | round (1)
      + states ('sensor.zirkulationspumpe_power') | float(2) | round (1)
      + states ('sensor.bambuslicht_power_4') | float(2) | round (1)
      + states ('sensor.tasmota_serverpark_energy_power') | float(2) | round (1)
      + states ('sensor.tasmota_wama_energy_power') | float(2) | round (1) )
      + states ('sensor.ofen_tasmota_energy_power') | float(2) | round (1)
      | float(2) | round (1) }}"

Is it possible to migrate the old (custom) to the new (group) sensor using the same UID without loosing data (of the custom sensor)?

From my experience the ID will be changed if there is another one with the same UID (e.g. by appending _2)

Pretty sure that does not matter. LTS uses the entity_id. So just make sure that matches and you should be good.

1 Like

I changed out all my template temp sensors yesterday from yaml to the new sensor groups and once deleting the old templates and removing the _1 appendix from the entity_id the history was intact with nothing lost.

2 Likes

@tom_l and @rossk

Wow, that was a lightning fast response! :smiley:
Thank you both for your help!

Thanks, guys - works as predicted… :slight_smile:

1 Like