Question regarding references to device names for readable config files

Hello,

I’m just starting out with HA and in the very early configuration stages and I’m worried about unfriendly references with my 60+ Z-wave devices.

Configuring things like this seems hard to maintain:

light.level_4 #Family Room Recessed Lights
light.level_3 #Family Room Fireplace Recessed Lights
light.level_11 #Family Room Landing Recessed Lights
light.level_10 #Family Room Sconce

So I started thinking about using the secrets file to store device names so I can reference them like so:

!secret zFR_RecessedLights
!secret zFR_FireplaceRecessedLights
!secret zFR_LandingRecessedLights
!secret zFR_Sconce

My secrets file has an entry that looks like:

#Family Room
zFR_RecessedLights: light.level_4 #Recessed Lights
zFR_FireplaceRecessedLights: light.level_3 #Fireplace Recessed Lights
zFR_LandingRecessedLights: light.level_11 #Landing Recessed Lights
zFR_Sconce: light.level_10 #Sconce

My groups file looks like this:

family_room:
  name: Family Room
  entities:
    - !secret zFR_RecessedLights
    - !secret zFR_FireplaceRecessedLights
    - !secret zFR_LandingRecessedLights
    - !secret zFR_Sconce

Assuming there are no issues, I’m thinking this would be a lifesaver if devices ever die or are replaced because I’m only updating the entity in one location.

I would really appreciate some feedback on this solution before I move forward and go crazy with it. I haven’t configured anything besides initial groups so I’m not sure if these references would work in automations or other configurations.

Thanks for the help,
Will

1 Like

can’t you use the entity registry to do what you want? I thought that was the point of it. (I don’t have any devices that can use the entity registry, so I don’t really know)

1 Like

HAHA. I am still trying to figure out what the entity registry actually does or how to use it…

I just did a test and it seems to work.

I renamed light.level_24 to a test name, light.zSampleName, and was able to reference it with the test name in my groupings. I then swapped up the unique_id in light.zSampleName with a different device and restarted and the reference was updated as expected.

I’m glad I asked the question before going with my more clunky solution - apparently this is a brand new feature in HA.

Thanks for the help!

Tried it and it seems to be working correctly. For me it is a GREAT improvement, every time i had to make a script, automation, scene I had a hard time remembering what is sonoff_1 or sonoff4_2…

Friendly names, welcome!!! :+1:

Must correct myself… I can’t find a way to use it consistently. @will can you post an example of working configuration?

Here is an excerpt from my entity_registry.yaml

# Dining Room
light.dining_room_recessed_lights:
  platform: zwave
  unique_id: 18-72057594344734721
  name: Dining Room Recessed Lights
light.dining_room_chandelier:
  platform: zwave
  unique_id: 19-72057594361511937
  name: Dining Room Chandelier
light.dining_room_sconces:
  platform: zwave
  unique_id: 20-72057594378289153
  name: Dining Room Sconces

The name change only takes effect on a restart and you have to list everything in the entity registry that you upload. For example, when I added in a new Sonos speaker, HA updated my entity_registry.yaml file but the names didn’t persist. I had to update a local copy with the new Sonos speaker information and reupload - everything worked fine after that.

I’m also still running an older version of HA. 63.3, I plan to update to 65.x shorly.