I’m new to HA and am confused about entity naming.
I have a Hive system, and when I configure it, I get an entity (amongst others) called climate.heating. That’s fine if there is only one platform that creates a climate.heating entity, but if there are two or more, then whenever I restart the system, I get new climate.heating entities created as climate.heating_2, climate.heating_3 etc and the previous ones get orphaned and are inactive. This means I can never refer to any entity as it will be renamed come the next restart.
So what I thought was that if I named the entity in the configuration.yaml, this would solve the problem, like so:
hive:
username: myusername
password: mypassword
climate myzone:
platform: hive
name: My friendly name for my zone
But this doesn’t seem to work, I still get the entity created as climate.heating, not climate.myzone as I expected.
What am I doing wrong, and/or where is the documentation on how entity names work?
Thanks. More generally, what is the approach to namespacing in HA? If two devices both generate the same name for the same platform (climate.heating is very generic), and I have two integrations (say Hive and Nest or whatever), and both create a climate.heating entity, how do I make sure that climate.heating comes from Hive and climate.heating_2 comes from Nest? It seems that upon restart, these entity names can and do get re-assigned, so at that point everything downstream (views, rules etc) will break down. Am I missing something?
I suppose a workaround is to override the integrations and force them to generate unique entity names. If the names are unique, there is no need for renaming with the _2, _3 trick, and hence everything stays stable and appears to work, but relying on all independently created integrations to all generate globally unique but readable names seems wrong to me. What am I missing here?
That’s where the entity registry comes in. You should never have that problem.
For many things you can define a name in the YAML when you configure it, for things set up in the UI usually you’ll be able to change the entity_id to something sensible.
Home Assistant (and the integrations) will generate unique IDs, it’s up to you to decide whether to leave them, or make them meaningful. Personally, I change anything generic to something relevant.
To add to the other replies: there are some things that may not currently be possible to adjust, but hopefully those get address over time. While the core part of HA is quite solid, in one respect you have to look at it as beta software given some of the rough edges and the large volume of changes that are made each release. It’s come a long ways in the past 6 months, even more over the past year, and huge amounts over the past couple years.
It’s getting more polished by the release (on average).
So I have almost sorted myself out.
I have multiple Hive systems, and the current Hive component only supports one. So what I did was I copied the Hive integration, changed its domain from hive to hive2 in the __init__ file and the manifest, and put that in the custom_components folder.
That didn’t work, because although the Hive component creates a unique id when there is only one of it, if you have two, then it is no longer unique. So I had to go into all of the unique_id methods and add a “2” to the end of whatever they produce, to make the outputs of the hive2 component unique.
I also had to make a local copy of the api module that retrieves the info from the Hive cloud, as that was also only expecting to be called by one component, not two.
So after all that, I now have info coming from two Hive systems, but I can’t control the second one, as I am told that I am missing the services.yaml file. I am not missing this file. I have put it in my hive2 folder, and out of desperation, I have also put it in the root custom_components folder, but it is still claiming it can’t find it. Anyone know the trick to persuade it to find that file?
Yes. I’ve since noticed that even though it whinges about the lack of services.yaml file even though it is there, I can actually control the devices, so I’m wondering what it is actually complaining about? Is it perhaps a false warning?