Duplicated entities, what's happening?

The following template sensor:-

- sensor:
    - name: Main_HDD_Health
      state: >
        {% if states('sensor.main_hdd_health_rest')!='unknown' %}
        {{ states('sensor.main_hdd_health_rest') }}
        {%else%}
        {{ this.state }}
        {%endif%}

Gets its data from this rest sensor:-

- resource: http://192.168.0.203:8000/PrimaryHDD.txt
  scan_interval: 300
  sensor:
    - name: main_hdd_health_rest
      value_template: >
        {% if "SMART overall-health self-assessment test result:" in value %}
        {{ (value|regex_findall("SMART overall-health self-assessment test result:.*"))[0].split(":")[1] }}
        {%else%}
        unknown
        {%endif%}

But in my entities list I see this:-

I really only want the top one and the bottom one.

And all of them seem to be getting updates…

I think its because I have editted and changed this over time, so how do I get rid of the old entries ?

Hi Ro,

Template Sensors you can add a unique_id: to lock things down. I suggest that.
Should be able to delete the ones you don’t want.

So I noticed I hadn’t added unique_id to that sensor (where I have for others), but how do I actually delete the ones I don’t want. I have created them in yaml, not the UI, and I get this message when trying to delete them:-

This entity (‘sensor.main_hdd_mode_rest’) does not have a unique ID, therefore its settings cannot be managed from the UI.

UPDATE:- I removed them by editting the core.entity_registry file, but I understand this approach should be done with caution.