The doc pages are editable by anyone, so you can make that change.
As far as I can see, it was duplicating rest & template sensors when I updated them (changed scan_interval and value_template) after which I reloaded yaml configs and saw duplicates, this is happening since my upgrade to 2024.1.5. The same process did not lead to duplicates previously, although I was behind a fair bit, 2023.6.# I believe.
However, after a reboot, the duplicates (_2) have disappeared, but I lost my state history for these sensors, it seems the old sensors were deleted and the new one renamed?
Not true. This is how yaml integrations work when you reload. If the entity exists, reloading does not delete them. So HA sees that the entity_id is taken and appends a _2. Use a unique_id to avoid this 100%.
Yes, because when you restart, HA is starting fresh with 0 entities and loads each integration.
I’ve explained this in previous posts in this thread already.
This has always been a drawback of yaml integrations, because HA has no way of knowing if you made a mistake by creating an entity with the same name or if you reloaded. The only way HA can account for that via yaml is if the yaml creates an entry in the entity registry via the unique_id.
You seem to know it all, why didn’t you contribute and document it? Instead you go out of your way to bash me, when I’ve only reported an issue I didn’t understand and suggested an improvement to the documentation? You seem to have misunderstood the role of a moderator.
Sorry? I’m not sure where any of my comments are “bashing you”.
How does this apply to the 600 entities I have?
I’m currently dealing with this and having to manually rename devices in the UI to ‘…_3’, going back and changing all of the duplicates by removing ‘_2’, then going and deleting the original duplicates with ‘3’. What am I doing wrong?
It’s strange how I am still at a roadblock trying to delete some duplicated sensors with _2 at the end of them because they do not have the infamous unique_id - which I cannot set on any yaml because I have not created said sensor anywhere…
And all this after 20 messages in a conversation back and forth about it
Here are 3 ways entities are retained which I’ve said in this back and forth.
-
The sensors exist in your system because you haven’t restarted after removing them from yaml.
Solution: Restart.
Reason: Reloading an integration doesn’t unload existing entities.
-
The sensors still exist after YAML removal & restart.
Solution: Clear your browser cache
Reason: The browser doesn’t automatically refresh the entity list in some pages, it’s gathered from cache.
-
The sensors still exist after YAML removal & a restart & a browser cache clear.
Solution: Wait until the entities are purged from your recorder or manually purge them yourself. This will take time. Purges occur at midnight every night, and the default history retention period is 10 days.
Reason: History is still linked to the entity.
If these are devices that are generated in the UI, something is going wrong with the integration that is creating those devices. This means that your devices are no longer unique and HA thinks they are new devices. What integration is causing this?
It was a bit more complicated than any of those options, but I have finally solved it.
It was from a sensor defined on the configuration.yaml (a restful sensor), which for some reason ended up being created twice (listed on the entities tab twice, sensor.apicall, sensor.apicall_2).
Neither could be deleted because they did not have any unique_id.
So process was:
- Add unique_id to the sensor created on
configuration.yaml
(simply addingunique_id: apicall
on the definition) - Add a duplicate of the sensor on
configuration.yaml
, with theunique_id: apicall_2
andname: apicall_2
. - Restart HA.
- Go back to Entities tab, see that this time the cog is clickable (even though it is still not deletable from the UI).
- Remove the duplicate created on Step 2.
- Restart HA.
- Refresh without cache (ctrl+shift+R) the page.
Burdensome and quite far from user friendliness, but leaving this here for future unwary ones finding this annoying!
Cheers to all.
If they don’t have a unique_id then removing the yaml allows them to disappear on restart of HA.
I’m not mincing my words here. This is how yaml only entities work. Don’t reload, restart after removing the yaml.
If that doesn’t work, then they are in your browser cache.
If clearing cache doesn’t work, they are in your history and you have to wait for the purge.
Adding a unique_id just allows you to edit the entity from the UI, and you effectively create a config entry. Then you can manage the entity from the UI.
So to clarify for YAML entries without unique_id:
- Delete yaml.
- Restart HA.
- Clear Cache if entities still show up in entity lists.
YAML Entries with unique_id:
- Delete yaml.
- Restart HA.
- Click delete in the UI on the entity.