#**How to Rename an Entity from an Action?**

1 messages · Page 1 of 1 (latest)

flint rune
#

I'm looking for a proper way to rename an entity's friendly name programmatically within an automation in Home Assistant.

Here's the issue I'm encountering:

  • Currently, friendly names appear as attributes of the entity’s state, rather than as properties you can directly manipulate via automation actions.
  • Oddly, it's possible to manually update an entity's friendly name via Developer Tools → States, by editing the entity’s state and specifying the friendly_name attribute in the YAML field. However, I don't see an equivalent method exposed for automations.

Questions:

  1. Is there an officially supported or recommended method to rename entities (specifically their friendly names) from an automation script?
  2. If not, is my only solution to call the state API directly (replicating the Developer Tools behavior)?
  3. What's the rationale behind treating friendly names as part of an entity’s state/attributes? It feels unintuitive.
#

How to Rename an Entity from an Action?

minor sundial
#

I think we've been moving away from storing static entity properties (like name) as attributes, but it's probably mostly there for legacy purposes and existing custom cards.
Similarly Icon used to be an attribute but that was removed.

#

However whatever we move to isn't going to support changing the name by automation either, so I don't think that will be satisfying for you.

#

Oddly, it's possible to manually update an entity's friendly name via Developer Tools → States,

This is just a hack for debugging and it won't persist, as soon as the entity updates it will revert back to the original name.

#

Best you can probably do is duplicate an entity via a template, and in that template you can have a custom/dynamic friendly name.

gritty nexus
flint rune
# gritty nexus Why do you actually want to change the friendly name?

whenever a new device connects to my Wi-Fi, a device_tracker is automatically created based on its MAC address. I use integrations like Zeroconf, Nmap, and hostnames to help identify which device belongs to whom, but that’s not always enough. if I forget to rename it, it gets tricky later to figure out who it actually was.

so to solve this, I now send myself a notification as soon as a new, unseen device connects to my wifi. the notification has a "Rename" button that prompts me to enter a name. I input the person's name and it renames the device tracker friendly_name to reflect that, making it much easier to track who's home and for how long