Entity re-appears with wrong entity_id & name

I’ve recently re-organized my group addresses and am struggling to understand where Home Assistant is taking the entity ID and name from the sensor, after removing the entity altogether and adding the group address back with a different name.

For most addresses I’ve done the following:

  • Comment out entities in configuration
  • Reload KNX configuration
  • Remove entities from Home Assistant (config/entities)
  • Comment entities in configuration back in with correct group address and in some cases with corrected name.

This worked for most entities. However I’m currently struggling with a particular set of entities, which won’t work. I can remove them as described above, but once I add them back, they will re-appear with the previous entity_id.

I understand that the unique_id in case of knx is somehow bound to the group address. However I don’t get where the old entity_id is even taken from. I’ve even stopped Home Assistant, removed everything related to this entity_id from the core registry, and restarted Home Assistant and I’m still getting the entity back with the old (wrong) entity_id. I’ve grepped through everything within config and config/.storageand cannot find this old string anymore, so I’m wondering where this is taken from.

To be more specific. I have the following entity:

This is currently bound to this configuration:

knx:
  sensor:
    - name: "eg_kew_ta1_temperature"
      state_address: "3/2/5"
      type: temperature
      sync_state: expire 30

As you can see there is typo / mismatch in the name of the sensor eg_kew_ta1_temperature vs. it’s entity_id, which is eg_kew_ta1_temperatur (German spelling without e at the end.

Also it is being shown as EG-KEW-TA1 Temperatur in the overview:

I don’t understand where this name is coming from. Probably I’ve set it somewhere in the past, but I cannot find it by grepping through .config. Also I cannot just delete this entity (as you can see its greyed out).

Also I get an error in the log when trying to add this group address with another sensor / name:

I haven’t added this entity via Config Flow, as I’m configuring everything via YAML files.

By now I’m kind of lost where this entity is coming from and how I can remove it. I have similar such entities, so I would like to understand what is going on here. Re-setting everything is also not really an option at this point for me, since I don’t want to loose the history of everything and have quite a lot of thing set up (besides KNX).

Getting some instructions on where to look would be helpful. Thank you.

Hi :wave:!
Try to grep your knx sensor configs for the group address “3/2/5”. It is probably in use - maybe by another entity or you just have overlooked to remove the old instance of this config.

The name info for the entity name should be stored in config/.storage/core.entity_registry - you should be able to find it by searching for the string "unique_id":"3/2/5".

Re-organizing group addresses is not really a good idea with regards to the HA knx integration :grimacing: good luck!

I’ve already done this, but didn’t have a lot of success:

I can find the following entry when grepping for 3/2/5:

.storage/core.entity_registry:1395:      {"aliases":[],"area_id":null,"categories":{},"capabilities":null,"config_entry_id":"01JQ01ZC99X9QZQHAFRR0HDAZN","config_subentry_id":null,"created_at":"2025-03-24T21:11:12.038985+00:00","device_class":null,"device_id":null,"disabled_by":null,"entity_category":null,"entity_id":"sensor.eg_kew_ta1_temperatur","hidden_by":null,"icon":null,"id":"528149359e21795b6401b63b7119fd8e","has_entity_name":false,"labels":[],"modified_at":"2025-03-24T21:11:36.924054+00:00","name":null,"options":{"cloud.alexa":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":"temperature","original_icon":null,"original_name":"EG-KEW-TA1 Temperatur","platform":"knx","supported_features":0,"translation_key":null,"unique_id":"3/2/5","previous_unique_id":null,"unit_of_measurement":"°C"}

Now I’m stopping Home Assistant:

ha core stop

Delete this line and restart Home Assistant again:

ha core start

Once Home Assistant is up and running again, I don’t find any entry for 3/2/5 within the core.entity_registry any more, but the sensor is still available (and getting data :slight_smile:) and still cannot be removed.

After a while (approx. 2-3 minutes) the entry is back again:

.storage/core.entity_registry:1395:      {"aliases":[],"area_id":null,"categories":{},"capabilities":null,"config_entry_id":"01JQ01ZC99X9QZQHAFRR0HDAZN","config_subentry_id":null,"created_at":"2025-03-24T21:19:54.408907+00:00","device_class":null,"device_id":null,"disabled_by":null,"entity_category":null,"entity_id":"sensor.eg_kew_ta1_temperatur","hidden_by":null,"icon":null,"id":"8558ab168dae1b940a5fcf785fc3dbd7","has_entity_name":false,"labels":[],"modified_at":"2025-03-24T21:20:17.246037+00:00","name":null,"options":{"cloud.alexa":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":"temperature","original_icon":null,"original_name":"EG-KEW-TA1 Temperatur","platform":"knx","supported_features":0,"translation_key":null,"unique_id":"3/2/5","previous_unique_id":null,"unit_of_measurement":"°C"}

Probably the file is only written every now and then, so it doesn’t re-appear immediately. Either way it is somehow added back to the entity registry without me understand how and why.

Are there any other code paths in which a group address is mapped to an entity / sensor? Do you have any other suggestion on where to look and what to do?

Re-organizing group addresses is not really a good idea with regards to the HA knx integration :grimacing: good luck!

I know, but I still need to do this.

I’m happy to delete and re-add (and have already done) the KNX integration.

I’m happy to fiddle around within .storage.

Neither of which seemed to have helped in this case.

Also I don’t quite like the way the knx integration generates its unique_id, but it is what it is.

No idea where this comes from. I’d try this:

  • remove the entry from your knx sensor config
  • restart core (maybe twice), then the entity should still be there, but orphaned and you can delete it from the user interface
  • restart again
  • add the entry back to knx sensor config
  • restart again

Me neither, but I wouldn’t know any other way for yaml created entities. UI created ones use a different system.

So I’ll try again in the hope someone finds a solution!

I have an KNX installation which works perfectly.

Mainly for the dashboard and some mobile device interections I installed Homeassistant and configured the KNX integration. Everything is configured via YAML.
Everything worked like a charm!

Now, when changing groop addresses in KNX (which I do regularly), I did the following steps to “update” entities: (as does @kbabioch)

  • entirely comment out KNX in configuration
  • restart of entire Homeassistant
  • remove all KNX-related entities from Home Assistant (config/entities)
  • comment KNX back in
  • restart of entire Homeassistant

If I don’t change names, all entities come back as before (even with statistics), but are now connected to the correct groop addresses again.
When I also (or only) changed names, I had to also delete the corresponding statistics and rename the corresponding entry in the dashboard.

This worked all the time now for some years.

But: Now, it doesn’t work anymore!

An example:

knx:
  binary_sensor:
    - name: "OG Licht aus?"
      state_address: "2/0/0"
    - name: "EG Licht aus?"
      state_address: "2/0/1"
    - name: "UG Licht aus?"
      state_address: "2/0/2"

But the entities are as follows:


You can see: The names written in the YAML are not reflected into entity-names AND even worse, they intermix randomly.
Super weird: There is and has never been any binary_sensor named “Bad”.

So, what is going on here?
I could only assume that there’s some problem with new features that do not use the YAML anymore and create entities differently.

Anyone any idea? Thanks!

I’d recommend to stop doing that regularly :upside_down_face: it’s just an address, there is hardly any need for those to be changed once created.
In HA Knx yaml entities are identified by GA, so if you change it, a new entity will be created. The old entity may be left as orphan, not really sure how this snd the cleanup exactly works.

Once a Knx yaml entity is created, “name” is ignored. You can change it to whatever you like. If you want to rename it for HA, do it via UI.

For yaml KNX entities nothing was changed.

I’d recommend to use UI entities instead - you can change GA and names without any issues there.

Finding different solutions for automations and corresponding relations often leads to new and obsolet GAs. But, I have a sorting scheme which makes it a lot easier to maintain. Thus, GAs change.

That’s the reason for the previously mentioned steps of removing and adding back in the whole knx-setup with every GA change.

That has never been necessary, since by removing and adding back in the KNX config, all unchanged names remain working - although the GA in the background is different.

As far as I know KNX is mainly only addable and editable via YAML config file.
So, you say KNX entities are addable und editable without direct YAML-editing?

I still don’t understand why deleted entities are mysteriously coming back. After commenting out KNX, restarting HA and deleting all entities, e.g. “bad” can’t be found:

But when adding a totally different GA-name-combination, it is suddenly there:

For me this seems to be a database (SQL?) problem. Maybe deleted entities in the UI are not deleted in the database - but that’s just guessing.


Anyway: I found the solution!

So, the updated steps to change KNX GAs within Homeassistant are as follows:

  • entirely comment out KNX in configuration
  • restart of entire Homeassistant
  • remove all KNX-related entities from Home Assistant (config/entities)
  • comment KNX back in
  • restart of entire Homeassistant
  • select all KNX entities and “recreate entity ID of selected” → this needs to be done several times until all duplicates are gone

Hope this helps others with the same problem :raising_hand_man:

Yes, some platforms at least. You can find this in the Knx config panel (/knx/entities).

Thanks for the tip!
When all platforms are availlable (analog sensors, scenes, climate, …), it might make sense to readd my 191 entities :wink: