KNX: Define enitity_id, icon and area via YAML

Dear KNX Team,

first of all thank you very much for your great work. The knx integration is really awesome. I have one feature request that would improve the user experience even further.

Problem Statement:

Currently, only the name for the entity can be set via the configuration files. The entity ID is generated based on the name. However, if the name and the entity ID should differ, there is currently only the possibility to write the entity ID into the name attribute and then adjust the name again via the UI. (which is very inconvenient with 1000+ entities) e.g:

ID:
Name:

ff_br_light
First Floor Bedroom Light

Proposed solution

In addition to the name attribute, there should also be a configuration parameter for the entity_id, icon and area. This would allow to manage all entity-relevant data in one configuration file. To ensure backward compatibility, entity ID, icon & area field should be optional. If the id parameter is not defined, the entity ID should be generated automatically (like today). e.g.:

knx:
  light:
    - entity_id: ff_br_light
      icon: mdi:lightbulb-group
      area_id: bedroom
      name: First Floor Bedroom Light
      address: 2/3/10
      state_address: 2/3/11

If the entity ID is specified, this solution would also have the positive side effect of avoiding duplicates when the configuration is changed.

Please let me know what you think of the idea and if you need any further input.

Hi :wave:!

Thank you for your suggestions!
Unfortunately I don’t think any of these can be done for a core integration.

As you may have already noticed, not even the name attribute is required, and once the entity is instantiated it has no further meaning (even if you changed it later it wouldn’t be reflected). This is due to how HAs entity registry works. The idea is to have the name and also the entity_id changeable from HAs UI - without ever writing to your configuration.yaml.

Currently there is no way to create duplicate entity_ids and changing configuration doesn’t change any entity_ids - as long as you don’t change a “significant GA”. See KNX - Duplicate Entities

You may however programmatically change the entity registry entries, if you really feel a need for entity_ids differing form the names. But that’s at your own risk - remember to do a backup before!

Thanks for your feedback. I got your point. Even if it were only considered for initial registration, it would be helpful for the scenario described. But I understand the concerns. New users would expect that changes in configuration layer are reflected in the registry.

You are right. By duplicates I mean entities that are re-registered after subsequent changes to the config file. Those “duplicates” are getting the same name with a number at the end:

org: ff_light
duplicate: ff_light2

Thanks for your support and suggestions!

Those “duplicates” are getting the same name with a number at the end

Right, but that only happens if you change one ofvthe significant GAs without deleting the entity before. That’s the compromise we have to take since the Knx system - especially when configured by users via yaml - can not provide any unique identifier.
Same would occur when the entity_id was user configurable and a user configured the same twice by mistake.

users would expect that changes in configuration layer are reflected

Exactly. This is already confusing for name.

That said, we are currently working on a different configuration system based on UI and knxproj files. But at this time we are just at the beginning and probably months away from even a working prototype. Help is always welcome :technologist::wink: