MQTT auto discovery - friendly_name?

Hello all,
I’m having fun using my ESP8266 board registering to Home-Assistant via MQTT. I’m trying to present the board to let HASS discover the new device. Until here all ok.
The presentation (subscribe to MQTT) is as follow, for one switch:

XefilHome/switch/Studio_Switch01/config {"name":"Studio Switch01","command_topic":"XefilHome/switch/Studio_Switch01/set"}
XefilHome/switch/Studio_Switch01/state OFF

The configuration in HASS is:

mqtt:
  broker: 127.0.0.1
  port: 1883
  client_id: home-assistant-1
  keepalive: 120
  discovery: true
  discovery_prefix: XefilHome

Now, the above ‘config’ is presenting the switch which is then recognized as switch.studio_switch01 with friendly_name: "Studio Switch01".
If I would like to add a second switch with a different name, I’ve noticed that the name field in the config JSON is used to create the friendly name as well as the device name. I.e.:

XefilHome/switch/Studio_Switch02/config {"name":"Not Used","command_topic":"XefilHome/switch/Studio_Switch02/set"}

It creates switch.not_used with friendly_name: "Not Used".
I would expect something like switch.studio_switch02 with friendly_name: "Not Used".
Is this behaviour expected or I’m doing something wrong?
I would like to have the switch name related to the <object_id> and the friendly_name related to the name.

Thanks for suggestions!

Simon

UP, no suggestions?
Some MQTT guru? :slight_smile:

If you’re using discovery just add the integration and get rid of all the MQTT config from config… HA will use the defined name in the device. Then in the device just make sure discovery is enabled and it has a unique name.

Hello,
Thanks for the answer but that’s not exactly what I was looking for.
I know I could correct the friendly_name using customizations, but was wondering if, during the presentation, I can submit both a name AND a friendly_name, different each other, so that HASS can then use both informations automatically :slight_smile:
Thanks, Simon

Any luck with this? Kinda annoying to have to manually rename all the friendly_names after discovery using the UI.

1 Like

Actually not, btw I’m moved to ESPHome.

Cheers, Simon

Bumb.
How can I send the friendly name over mqtt?

You can send the name, but not the friendly name. Choose the name well, so you don’t need a friendly name.

'{"name": "garagedoor", "device_class": "garage_door", "state_topic": "sensor/garagedoor", "unique_id": "garagedoor", "off_delay": 30, "device": {"identifiers": ["rfbridge_564886"],"name": "garagedoor", "model": "Digoo door sensor", "manufacturer": "Digoo"}}'

Running into the same issue.
Setting the ‘name’ to the wanted friendly_name seems to work.
Then ‘unique_id’ can be used to determine the entity_id (I think).

I’m working on adding auto-discovery to a Netatmo-Mqtt-bridge and this config seems to create the entity like the Netatmo integration also creates it:

{
	"device": {
		"identifiers": "Mqtt Netatmo Station",
		"manufacturer": "Netatmo",
		"model": "WeatherStation",
		"name": "Station",
		"via_device": "netatmo-mqtt-bridge"
	},
	"device_class": "temperature",
	"unique_id": "mqtt_netatmo_station_temperature",
	"name": "MQTT Netatmo Station Temperature",
	"state_topic": "/netatmo/station-name/station/temperature",
	"unit_of_measurement": "°C"
}