How to clean / prevent duplicate REST sensors

I’m a fairly new Home Assistant user. I’ve made a couple of RESTful sensors (one based on DIY OVMS (Open Vehicles) Integration for OVMS, and another to get my ISP data usage / remaining). For some reason, these sensors periodically get duplicated.

For example, after creating my OVMS REST sensor a few days ago with name (say) ovms_car_status, when I look in the Developer Tools → States, there are ovms_car_status, ovms_car_status_2, and now also ovms_car_status_3. Only the last of these seems to be getting updated any more. Since I have template sensors referring to the entity ovms_car_status, these no longer get updates.

Three questions:

  1. What triggers these sensors to be duplicated?
  2. How can I force the RESTful sensor to always go to a particular state/entity?
  3. How can I delete the existing duplicates?

For reference, here is a section of the REST sensor configuration:

  - platform: rest
    scan_interval: 60
    name: ovms_car_status
    resource: !secret ovms_car_status_url
    value_template: "{{ value_json.soc }}"
      - chargestate
      - charging
      - charging_12v
      - estimatedrange
      - odometer
      - soc
      - soh
      - speed

Somewhat answering my own questions…

  1. I still don’t know why these get created
  2. It seems not possible to explicitly assign a unique_id to a RESTful sensor
  3. Restarting home assistant resulted in the duplicates being removed

Yea, this is kind of a pain in the proverbial 'arss '…

You can assign a unique_id to a Rest sensor these days (since mid-2022). Have you tried that?