It show device name and wifi hostname like this “mono-8d5128” but mqtt only show “mono”
Topic Prefix: ‘mono’
State Topic: ‘mono/switch/mono_relay1/state’
State Topic: ‘mono/switch/mono_relay2/state’
Is there a way for me to change it to
Topic Prefix: ‘mono-8d5128’
State Topic: ‘mono-8d5128/switch/mono_relay1/state’
State Topic: ‘mono-8d5128/switch/mono_relay2/state’
Sorry, I’m not good at English. I hope you can read and understand.
discovery_unique_id_generator (Optional, string): The unique_id generator to use. Can be one of legacy or mac. Defaults to legacy, which generates unique_id in format ESP<component_type><default_object_id>. mac generator uses format <mac_address>-<component_type>-<fnv1_hash(friendly_name)>.
Maybe put in a feature request to make MQTT topic_prefix templatable?
In the meantime, you could retrieve the MAC address using the WiFi Info sensor then manually publish your sensors using the mqtt.publish action, which is templatable…
I found a solution !
I installed esphome on windows then I can edit the code as I want on vscode.
But the downside is that I have to stay in this version of esphome forever.
But I can add components myself. So there’s not much problem.
Hi There, I know its after a long time but problem is exactly like yours. What is the solution?
I want the topic name to be (devicename+MAC address) - I dont want that to be hardcoded, how do I get that in my TOPIC ?
Thanks for your idea. It works! Almost))
The thing is that the topic that displays the connection status by default still has topic_prefix = node name, without MAC address…
I feel that somewhere else I need to add MAC address reception, but I don’t understand where exactly…
In this repo, I created a .H file to write my own HA discovery MQTT topics, a button.yaml to post sensors just the way i wanted and a mqtt.yaml to subscribe and receive commands.
s_unique_name receives the unique name of the sensor using de mac on boot: