Restored and doubled Entities from ESP


Hi Colleagues,
after some strange restarts of node MCU which serves as a pulse counter and totalizer for energy water and gas consumption, yesterday I noticed my entities has doubled, HA added *_2 to all sensors and started to write new history for them. all previous ones are now “restored: true”.
What does this mean? how can i revert to have the originals with their history continued?
Thanks in advance

1 Like

Do you happen to have an MQTT and API definition in your sensors ?

nope, don’t use MQTT, they are straight from ESP YAML like this:

  - platform: pulse_counter
    id: energy_pulse
    pin: 13
  #  number: 031
   # pin_mode: INPUT_PULLUP
    internal: true
    name: “Pulse Counter energy”
    update_interval: 1s
    filters:
        lambda: |-
          static float total_pulses_energy = 0.00;
          total_pulses_energy += x * 1 / 60.00;
          id(lifetime_counter_energy).publish_state(total_pulses_energy/1000);
          return x ;

  - platform: template
    id: lifetime_counter_energy
    name: “Energy Total”
    accuracy_decimals: 2
    unit_of_measurement: 'kWh'

  - platform: template
    name: “energy Flow Rate”
    id: energy_flow_rate
    accuracy_decimals: 2
    unit_of_measurement: 'kW'
    icon: 'mdi:energy'
    lambda: return (id(energy_pulse).state/1000);
    update_interval: 3s

Delete the corresponding esphome integration of that device in ha (check if the entities are gone - if not delete them manually) and than ad the integration again.

This scenario normally only happens if you flash the same yaml (or yamls which contain the same sensor names) to more than one devices.

1 Like

that will make the history for them vanish as well?

No, history is untouched. But it will not merge your two different histories you have at the moment but just continue with the “first” ones (without the “_2”)

so simple… THANK YOU, all back to normal.

1 Like