I have some custom code that publishes some MQTT sensors to HA using MQTT Discovery. I have set up a custom dashboard that arranges all of these custom entities and groups them appropriately.
Unfortunately, the change to make device names prepended to entity names by default throws out all of my layouts. I don’t need the device name in my entity names, because the groupings done by the dashboard already make it obvious which device a given entity is for. And the extra text means the dashboard is way more dense and difficult to read. Is there anything I can change in the MQTT Discovery message to get Home Assistant to not prepend the device name in the entity/entities cards?
Also, because this system adds and removes sensors dynamically, I can’t manually fix the problem by explicitly setting the names on the buttons/entities through the UI. (Because any new ones wouldn’t have that customization.)
I have tried setting the friendly_name in addition to the name field on the discovery message, but that doesn’t seem to have any effect.
There’s a load of information on HASS MQTT Discovery (including updated mosquitto_pub examples to experiment with) in this thread, but I changed my code rather than attempt to change the new behaviour and marked the hour needed down to paying technical debt:
The key is to understand the difference between the nested "name": fields in MQTT Discovery JSON. You might also add a few more fields to make the discovery more complete:
The MQTT discovery docs don’t seem to discuss any ability to opt out of the device name prepending behavior. They discuss some of the implications, and generally it being the default makes a lot of sense to me. It does strike me as odd that it wouldn’t be possible to control the text that will be displayed on the entity card in the same place that I’m defining the sensor/button/etc (esp since the user can do what I’m looking to do from the UI), but I could see the project weighing that up against consistency and deciding consistency is the bigger benefit.
I don’t think I’m missing any info that could be provided by additional name fields. Which “nested” fields are you referring to?
I can rework my solution to not provide devices at all, seems to be the main way I could avoid this problem. I don’t have a userbase of people trying to understand this - it’s for just me and my home and is dependent on various other things that don’t make sense for others to use. I’m effectively using the HA dashboard as a frontend for interacting with an application that I wrote and at some point, it would make more sense to have that application serve up its own web page and embed that inside a dashboard. HA’s live-updating and customizable UI were a much easier place to start.
I’m also both the software eng, and consumer, but after quite a bit of testing MQTT discovery completely configured my custom device without any changes in HASS itself.
The key is using mosquitto_pub to test JSON values interactively - GUI changes are immediate after the topic changes. That made testing a lot faster and meant my Python Just Worked™ !
My example documents: Note the difference between the DEVICE name and the moisture ENTITY
ISTR "sa":"Conservatory" or suggested_location was formalised in a later dev blog post.