Prepending the device name is an architectural decision made a long time ago but wasn’t implemented in the MQTT integration, specifically the MQTT Discovery feature, until version 2023.8.0.
If you don’t want the device name prepended to entity’s friendly_name
, you’ll need to do what you have already mentioned (manually rename its friendly_name
).
I have several dozen of such entities so I used Manual Customization to modify entity names in bulk.
Copy-paste the following template into the Template Editor.
{% for id in integration_entities('mqtt')
| map('device_id') | unique | reject ('eq', None) | sort %}
{% set name = device_attr(id, "name_by_user") or device_attr(id, "name") %}
# {{ name }}
{%- for e in device_entities(id) | sort %}
{{ e }}:
friendly_name: {{ state_attr(e, 'friendly_name') | replace(name, '') | trim }}
{%- endfor -%}
{%- endfor -%}
The Template Editor’s results window should now contain a neatly formatted YAML listing of your MQTT-based entities, grouped by device, showing each one’s entity_id
and its friendly_name
stripped of its device name.
Example of what the template generated
Each entity’s desired friendly_name
has been stripped of its device name (HAI Omnistat2) .
# HAI Omnistat2
binary_sensor.hvac_fan_status:
friendly_name: Furnace Fan
climate.thermostat:
friendly_name: Thermostat
sensor.indoor_humidity:
friendly_name: Indoor Humidity
sensor.indoor_temperature:
friendly_name: Indoor Temperature
Copy-paste the generated listing into the customize
section of your configuration.yaml
file. In my case, I have that section in a separate customize.yaml
file.
Make any required corrections, like proper YAML indentation, then save the file and restart Home Assistant.