in different packages.
2. Note that these entities have same entity_id.
3. Reload “input_select” entities.
4. Check that one “input_select.test_abc” entity is created with MERGED lists:
I believed that HA does not allow me to create entities with same entity_id.
This happened in fact - one entity is created, by WTH it gets a merged list?
Thanks for a reply.
Thinking about registering an issue in core.
Also, I am thinking about possible positive outcomes of this “possibly bug”.
One use-case comes to my mind:
Imagine a package-based config.
Assume these packages represent “root areas” of some house hold - we have packages like “garden”, “house”, “workshop”, “garage”.
Each package has “input_select.areas” (i.e. with same entity_id) - each declaration contains own list of areas like “kitchen”, “bedroom”, or “garage”, or “garden grill”, “hotbeds” etc.
The resulting “input_select.areas” contains a full list of areas (collected from packages).
Based on experience (errors I made) during my early days with Home Assistant, if you create a duplicate entity configuration in the configuration file, it will get flagged as an error.
I agree with tom_l that what you have observed seems like a bug; instead of reporting the duplication as an error, it attempted to mitigate it (creating a single merged entity).
Makes me wonder if this behavior is limited to Input Select or it attempts to do the same thing with other duplicated helpers, etc.
Tested with these packages:
same_entity_ids_1.yaml
input_boolean:
test_same_flag:
icon: mdi:account
same_entity_ids_2.yaml:
input_boolean:
test_same_flag:
icon: mdi:car
Got an error:
2024-01-10 07:53:09.633 ERROR (MainThread) [homeassistant.config] Setup of package ‘same_entity_ids_2’ at conf/test/same_entity_ids/same_entity_ids_2.yaml, line 1 failed: integration ‘input_boolean’ has duplicate key ‘icon’
The entity was created from the 1st package:
Surprising results. Also, undesirable results because I doubt anyone wants what should be separate entities combined into one. If this is not considered to be a bug then I would be interested to hear the justification for this behavior.
I’m not hindered by actual knowledge about the code base, but maybe this behavior is what customize relies on? But outside that integration I agree it would be more useful to throw an exception as it is likely a problem.
It would require more entities and might not be as “clean looking”, but something similar to your example could be accomplished by merging options using a Template Select.
Thank you, could you post a draft snippet how to do it?
I think I get the idea of defining “options” dynamically - but how this can be done in a simple “a new package added”, “some package is removed” scenario?
In my possible usecase these options may be added/removed automatically.
Like in your example, a package gets an area Input Select that follows a specific ID convention. Unlike your example, they don’t use the same ID, but they can still contain a single option:
input_select:
area_kitchen:
options:
- kitchen
or multiple options:
input_select:
area_basement:
options:
- utility_room
- basement_bedroom
- den
Then the Template select merges the options using the convention as selection criteria:
This method may be used in cases when similar entities are initially defined in different packages.
Ofc, if they are defined in the same package - yaml-anchors are sufficient.