Device Alias

I’m struggling with entity naming when configuring an OpenEVSE device.

If I name the device OpenEVSE-CP, the alias openevse_cp is automatically created.

An unamed entity of that device is then assigned ‘openevse_cp SomeFunc’ and since the beginning of that does not match the device name, in the UI that entity is displayed in full as ‘openevse_cp SomeFunc’.

If I then rename the Device to openevse_cp, the match is successful and so the entity is displayed simply as ‘SomeFunc’ which is what I want. However I would rather the device name was mixed case for clarity.

So if I have to use lowercase for the Device’s Name, I thought I’d use mixed case for the Alias, but that is impossible as the Alias is automatically converted to lower case, with exactly the same result if no Alias name is entered, it gets created in lowercase.

So the only way to have entity names ‘trimmed’ to remove the device name is to use lowercase for the device name (and Alias which will be created that way if not entered) and leave the entity name blank, or use a more desirable mixed case Device name and have to manually create ALL the Entity names, each starting with that Device name.

Am I missing something here? Are Aliases not intended to be the ‘friendly name’ that can be mixed case and include spaces etc? What’s the point of only allowing lower case and how can I arrange correct matching of mixed case Device name so to display ‘trimmed’ Entity name, without having to type the whole name in every Entity?

Can you show some screenshots of what’s happening?

Ok, in the list of Entities, some show with and some without the (lower case) device name:-

The second one above has NO Entity name entered and the auto generated (default) one does not match the Device name, so that is included.

The first one is actually named ‘OpenEVSE-CP Divert Active’ and as it matches the Device name, that is not included in the Entity name. The third is the same.

If I instead name the Device as ‘openevse_cp’, that situation is reversed and it is the second one that is displayed correctly, without the device name. IOW, the automatically generated Entity name matches the Device name which is therefore not displayed.

The first and third Entities now do not match and so the entire entered name is displayed.

In this case, I could delete all Entity names so the default would be used, match the Device name and so the Entity name would be just the function, as I want, but I also want to use mixed case for the Device name, but as in the first case, I can only do that by entering a specific, matching name for ALL Entities which is not only a faff but cannot then follow any changes I may want to make in the future to the Device name. That would involve editing the name of ALL Entities again.

So why is the default Entitiy name created with a lower case version (and ‘-’ swapped for ‘_’) of the Device name?

I figured that was actually created from the Device’s Alias. So this should work:-

However that is automatically converted to:-

and I CANNOT prevent that.

This seems wrong as the Alias is the ‘friendly’ name and is supposed to allow the use of mixed case. If I could do that, maybe the auto generated Entity names would match, or if that still did not work, at least I could have a better (mixed case) friendly name for the Device, even if its actual Name was the simplified lower case version.

It all seems very mixed up. I should be able to use any Device name, have that match the auto generated Entity names so Entities are named just by their function (no Device name included) and also use any name I desire (with any case) for the Alias. However this is not possible, unless I am misunderstanding how to achieve that.

Are you running an up-to-date HA core?

I’m a bit confused. The device’s name looks correct, but where is that lowercase “openevse_cp” coming from in the image below left column?

Are you saying that’s being added to the entity? If you open that entity for editing does it show that prefix in the Name field? e.g. like in this page:

Spitballing here, but once the integration has set up the names I would think it would follow general rules for entity names. Look at that and see if it’s following those rules.

I wonder if it is somehow related to has_entity_name.

I have device in the light domain and it looks like this:

This is a z-wave switch that runs a light and the device is named “Swan Light”. It’s following the rules – that last entry (light.swan_light) doesn’t have a name assigned so it uses the device’s name for the entity’s name. The other do have a name assigned so those names are shown in that left column. And their entity_id’s have the device name prefixed.

I don’t know if this is helpful or not, but maybe look at the files in storage (note they lag being updated if you change anything)

Below, for the main entity light.swan_light, you can see its name field is null. That means it uses the device’s name (as you can see above):

➜  .storage jq '.data.entities[]|select(.entity_id == "light.swan_light")|{name,original_name,has_entity_name,device_id}' core.entity_registry

{
  "name": null,
  "original_name": "",
  "has_entity_name": true,
  "device_id": "876be6cbc8ea1814afae810856b4a44d"
}

But another entity associated with the same device button.swan_light_identify has an original name, so that is what is used:

➜  .storage jq '.data.entities[]|select(.entity_id == "button.swan_light_identify")|{name,original_name,has_entity_name,device_id}' core.entity_registry

{
  "name": null,
  "original_name": "Identify",
  "has_entity_name": true,
  "device_id": "876be6cbc8ea1814afae810856b4a44d"
}

I included the device_id so you can then look at its name:

➜  .storage jq '.data.devices[]|select(.id == "876be6cbc8ea1814afae810856b4a44d")|{name,name_by_user}' core.device_registry
{
  "name": "Swan Light",
  "name_by_user": null
}

So, now you can change things and see what happens. For example, if I change the device’s name the device now shows:

➜  .storage jq '.data.devices[]|select(.id == "876be6cbc8ea1814afae810856b4a44d")|{name,name_by_user}' core.device_registry
{
  "name": "Swan Light",
  "name_by_user": "my_new_light_name"
}

and then everything changes as expected:

Maybe inspecting those files will help show what’s going on.

Yes, so does your detailed description :slight_smile: , try to set as Default , as above where you use Mixed cases in Device name, Then as i understand you get 1 “entity” with lowercase and full name … Click on this “Entity” and show what this pop-up shows and where you change this nqme of that particular entitys “friendlly” name
But also Show Where Did you changed the Device Name
You are just showing the result of your changes in the “Entities-View”
It Would be easier to understand if you show pics, of where/how you named your DeVice, and where/ you tried to change the name of the entity

Edit: Click fist at your Integration, then the specific Device ( In this pop-up, is Where you write the Name of Your Device , in mixed letters) “Pensil in top right corner”
Then you go to the “entities” of this device, or simply click on each entities, in the Device-page and there change the name of the Entity

Yes, as of the last few days, but an update has just become available which I’ll do tomorrow.

That’s a good question. I’ve got no idea, hence posting here.

It’s not the exact Device name, but a ‘simplified’ one and is exactly what appears as the Device Alias (see screenshot from my previous post). I try to enter the full ‘OpenEVSE-CP’ as the Alias, but it is automatically converted to the ‘simplified’ version ‘openevse_cp’ which I cannot seem to prevent.

This rather suggests to to me that the auto generated Entity name is based on the Device Alias, which I am unable to change. It always reverts to the ‘simplified’ version ‘openevse_cp’ and the only way to then have the Entities named as just the function (as recommended), I have to manually edit them all or name the Device as the simplified ‘openevse_cp’.

I don’t know what a “device alias” is. You can rename devices and you can rename entities.

Are you able to run those jq queries and see what the data shows?

In the main Integration page there is this:-

If I select the upper 3dot menu and select 'Reconfigure", I get this:-

In which you can enter what I can only think of as the Device Alias and it automatically ‘simplifies’ anything I enter, converting to lowercase only and swapping ‘-’ for ‘_’ as shown in the screenshot above. This seems to be what is used to automatically generate the Entity Name as shown below (Name is empty until I click in it and it shows the auto generated Name which is then used).

However an automatically generated Entity name always uses that ‘simplified’ version, (i.e. same as the Alias which is what I suspect it is using for this). So the only way to get this to match is to use the same simplified version for the Device Name and in which case why are there 2 naming options if they both have to be the same.

Or

Enter an Entity Name for every one and if prepended by whatever has been used as the Entity Name, that will be removed when displayed in the list.

Either way, in order to be able to use a decent Device Name (e.g. with mixed case and perhaps ‘-’), it requires manually entering hundreds of Entity Names. This would not be necessary if an automatically generated Entity Name was prepended by the actual Device Name, rather than use this ‘simplified’ version which I believe is actually the Alias, that automatically ‘simplifies’ anything you enter.

Basically it’s got you both ways. Either you have to put up with a simplified (i.e. lowercase etc) Entity Name, or manually type the required Name in every single Entity.

Either I’m not understanding how to achieve what I want (decent Device Name AND not having to manually enter very single Entity Name) or something has gone wrong with HA.

Another quick check and I can confirm that an auto generated Entity Name starts with that Alias, followed by the function.

Somewhat unclear but that Alias seems to be for that Integration configuration, rather than specifically the device. Be that as it may, it is what is being used to create the Entity Name.

Since that Alias can only exist as a ‘simplified’ name, no auto generated Entity Name can start with a proper (mixed case etc) Device Name and no matching will occur. Unless…

The Device Name is exactly the same (simplified) as the Alias OR every Entity Name has to be manually entered.

This makes no sense to me so seems unlikely anyone intended it to be this way which makes me suspect an actual error (bug?) somewhere.

I am beginning to think this is an OpenEVSE Integration issue.

No other Integrations that I’ve checked offer that ‘Reconfigure’ option, so no such Alias available for them.

For some, an auto generated Entity Name starts with the actual complex (i.e. not simplified) Device Name and matching works well leading to just the Entity’s function being displayed in the list (and possibly elsewhere). Then other Integrations auto generate the Entity Name as just the function, i.e. NOT prepending the function with the Entity Name and no matching required.

So this process appears to be Integration specific and looks like it’s the OpenEVSE integration that is at fault and explains why I’ve not come across this problem in HA before.

I need to take it up with them.

EDIT the Name There, and you can also EDIT the entity Name there

You have full control over the naming. Ignore the “Reconfigure” and the “Device Alias”.

That “Alias” is simply the device name. The author just decided to call the name “Alias” in the UI:

"name": "Alias",

Then it uses that name when creating the device:

  name=config_entry.data[CONF_NAME],

And then when creating entities the author decided to add (prefix) that name (Alias) to the name of the entity. For example:

self._attr_name = f"{self._config.data[CONF_NAME]} {self._name}"

self._config.data[CONF_NAME] is that Alias you entered.

I think in general integrations don’t ask for a name when configuring becaus there’s already a way to change the name to whatever you want.

But that’s all besides the point. If you don’t like the device’s name then click on the pencil and change it. And likewise for the entities; just rename them. Just like @boheme61 said.

I know what I am able to edit, but I am trying to have a ‘complex’ (mixed case etc) name for the Device and have all its Entities displayed just by their function. Yes I can edit each Entity to obtain what I need, but that means manually editing HUNDREDS of Entities which as I’ve said, I am very keen to avoid doing. :slightly_smiling_face:

The author of this Integration has indeed decided to call the Device name an Alias, and when you enter the apparent Name you are actually creating the ‘name_by_user’.

The problem is an Entity’s auto generated Name is created from the UI Alias (the actual ‘name’ parameter which is ‘simplified’ by force), but matching (to remove the Device part and only display the Entity by its function) is done to the UI Name (I.e. actual name_by_user).

So the only way to achieve matching is to enter the same ‘simplified’ version for the UI Name (name_by_user) as is forced for the UI Alias (name) or to manually edit the Name for the hundreds of Entities, which is what I am trying to avoid.

Oddly, when creating a new entry for this Integration, it actually will create a complex UI Alias (name), but if you try to edit it (because it’s not very good), it will simplify it on saving. If it didn’t do that, there would be no problem so as far as I’m concerned this is an error on the part of the OpenEVSE custom Integration’s author. It will happily create a complex, mixed case Alias (name) but then not allow the user to do the same. So you have to either accept the not very good one it created, or you’re stuck with having a lower case only, simplified name.

Unless I manually edit the core.device_registry file and set the Device’s name (UI Alias) to the complex version I want.

I know it seems petty, all this hooha just about getting the naming I want, but as all HA users know, naming is actually very important to ensure the consistent and continued smooth running of Home Assistant.

Last try, go to Devices/Services , click on entities, Make Sure you don’t have any Filters on (to the left), then search for " Ethernet " or what ever name it is you have issues with, … Your long stories are not helpful, facts is (meaning show a pic of the result for the name you search for) If you already have a device/entity named “Ethernet” then you have to change the i.e sensor-name “sensor.no_same_name_here”
“Ethernet” should show all entities you have with that in
IF You want you can also search “openevse_cp” OR OpenEVSE-CP ( Try with OpenEVSE CP ) no DASH (Sometimes a Dash is not accepted in names, or just with “space” In the name(not on entity-level, neither DASH nor Space is accepted on entity_level)

And Btw i doubt you have HUNDREDS of entities from this Integration which you have issues with

Yeah, that’s how it works.

I cannot follow what you are saying. Do you know what you are asking for at this point? Doesn’t really seem like it. Are you saying you just don’t want to bother editing a lot of entities?

You are clear that names are not entity_ids, correct?

I rename things often. Even in bullk. It’s just not that hard.

OK, I won’t bore anyone further by repeating myself again and I’ll keep this short and simple.

Thanks for trying to think about this problem, but I have come to realise it is an OpenEVSE Integration issue so will continue my search there for a possible solution.

I edited this Integration’s code to prevent it from slugifying the UI Alias and it now works as expected and is consistent with other Integrations so one can now use a decent/complex Device name and have it match the auto generated Entity Names so that Entities are displayed just as their function.

That is the solution I have been trying to achieve, so very happy about that.

Could you provide the details, for this brave solution ?