Update entity friendly name based on state

Just wondering if it is possible to change an entity’s friendly name based on what the value of the entity is?

I’d like to take an entity exposed via my solar monitoring system and based on its state show importing or exporting so I can show it on a card.

The reason I want to do this is the entities exposed for input via Solar Panels, import/export to/from Grid, charge/discharge to/from batteries are inconsistent across integrations, so the average person looking at the dashboard is not going to have any idea what the negative denotes.

Not as far as I know, two options come to mind here:

1: make a template sensor and show this in the front end.

2: use a markdown card with a template.

It is possible!
Using amazing Home Assistant Entities Script.

Example:

service: python_script.hass_entities
data:
  action: set_attributes
  entity_id: input_boolean.test_toggle
  attributes:
    - friendly_name: "{{ now().strftime('%H.%M') }}"

In fact, it is possible to set any attribute and state.
Attributes are useful because they, unlike state, are not limited to 255 charcters.

Best regards!

1 Like