Aliases/pointers for entities

I’m wondering if there’s been any thought about adding some sort of alias or pointer mechanic to HA, allowing aliases to be associated with entity names and used in the place of said entity name (not the same thing as user-friendly names). To use a real example of what I mean:

I had a ZWave smart plug that controlled a humidifier. The entity name was something like switch.aeotec_zw096_smart_switch_6_switch_3. I had an automation written to turn it on and off, set up several customization entries, passed it to HomeKit, assigned it to a specific Lovelace card, etc.

Then I decided to switch to a sonoff/Tasmota smart plug. Which means I had to find every place that listed switch.aeotec_zw096_smart_switch_6_switch_3 and change it to switch.sonoffs31_2. Sure, I could do a global search-and-replace, but that doesn’t help with Lovelace (if it’s managed through the editor) or Homekit.

What I’d like is for there to be a way to define something like switch.alias_humidifier1, which can then be set to point to an actual entity. Automations, front-end stuff, etc. would all be passed the aliased name, not the actual entity name. That way, if I change the hardware, I just need to reassign the pointer, all else remains the same.

If anyone’s used the pfSense software router, it uses a very similar mechanic where you can define aliases for IPs and ports (or port groups). That way, if you have port forwarding or firewall rules set up, and need to point them to a different machine, you just change the alias definitions, without needing to actually touch the rules.

9 Likes

For devices that support it, many people just rename the entity_id to whatever suits them. If they replace the device with something else to have the same functionality, just rename the old device to something else, install the new device, and give it the same entity_id you did the first time.

Of course this fails if you’re replacing a switch.* with a light.* or a fan.* (because you got a more capable device), but, works for the most part.

I agree, though. I’d like to see aliases used in PLACE of entity_id renaming. I’d like to see all devices have an unchangable ID related to it’s underlying driver/component. Then manage all devices using aliases. I think this would make all of the various components easier to understand and would allow anything to be given a specific ID even if it doesn’t support it directly now.

3 Likes

Yeah, unfortunately in my case, that doesn’t seem to work with all the changes I’ve made.

I think I know of a fairly easy way of changing within a domain (from one switch to another) by writing a custom component. Might try my hand at coding for HA to do that, if there seems to be support for the idea.

Changing from a switch to a light, etc. seems much more complicated. No clue how to do that with just components, I think it’d take changes to the HA core, which is definitely over my head atm.

I had been looking for this feature too, in 2022 and this is one of the few posts I found with this question so I’ll answer in here:

I added Group helpers with single entity items and referenced other groups or entities directly.

Not sure how elegant this solution is, but it works.

I did this for items that might have more frequent replacement with identical hardware, such as lights, and smart switches.

3 Likes

Anyone knows if there’s been any updates since a year back that would allow for aliases/pointers like this? My use case would be to not have to update a lot of scripts and automations whenever I change my mobile phone.

@wizta The group with single entity idea is really good, I’ll try it out! :raised_hands:

1 Like

Since I was using the notify service I couldn’t easily use groups for this, instead I solved my problem using an input text helper. From the UI I added the helper with a name of Notify Service My Mobile and set its value to notify.mobile_app_google_pixel_phone

After that I replaced all occurences of

  - service: notify.mobile_app_google_pixel_phone
    data:
       ...

with

  - service: "{{ states('input_text.notify_service_my_mobile') }}"
    data:
       ...

Thus, whenever I change out my mobile phone, I only have to update the helper value in the UI to keep all mobile notifications working :slight_smile: Hope this might help anyone else!

2 Likes

I’ve also come looking for this – use case is that I have generic_thermostat entities for heating and cooling, and a binary variable for “Heating Mode” vs “Cooling Mode”.

I’d like to set up a single variable called “Thermostat”, which points to the relevant generic_thermostat entity depending on the season, such that calling a service on Thermostat results in the call being applied to whichever entity Thermostat points to at the time.

1 Like