I have been wondering if it possible for the home assistant to have multiple discovery prefixes. This is to ensure that I can develop several devices with appropriate naming for the prefix. Just to have better readability. However, I wonder if there is a possibility to do so in the configuration.yaml.
The current idea that I have in my is to have a node-red function to modify the published discovery message from my device lineup, then re-publish them with the topic that home assistant does the discovery.
I am all ears to have an input on this matter. Thanks in advance.
@anuradhawick - I have been researching this exact issue today as well. The documentation for HA MQTT only references a single discovery prefix (https://www.home-assistant.io/docs/mqtt/discovery/) and throughout forums I have found no evidence of alternatives.
In my case, I have both zwave2mqtt and zigbee2mqtt feeding Mosquitto. What was not clear to me is the HA discovery integration for each of the 2mqtt’s give’s impression that each can essentially publish to prefix [zwave2mqtt | zigbee2mqtt] and by nature of HA discovery intergrations also [homeassistant]. Kind of fuzzy and I am unable to see that work or find documentation which spells out how.
So, it seems its a single prefix for the HA intance (e.g. homeassistant, or whatever single prefix you specify in discovery_prefix: within mqtt: configuration.yaml)
The root of the discovery topic can be changed (the default is homeassistant) but you can only have one discovery topic.
As mentioned, you can use a ‘middleman’ to receive via a custom discovery topic and re-publish it to Home Assistant’s discovery topic. This can be done using an automation or Node-Red (whatever you prefer).
If you’re interested, it can also be done with an automation. I would need to see a sample of your custom discovery topic to provide a suitable automation example.
Thanks for the offer. My mqtt discovery prefixes are like wickmesh-light, wickmesh-sensor, etc. I am publishing these topics from a bridge device that I made. I am not familiar with automation. I’ll be much obliged if you could show me how to do one for say a lighting device, so I could follow the rest up.
On the other hand, if you are unable to change the format of the discovery topic, then the automation is slightly more complicated. It will require multiple triggers, one for each type of topic. The template will have to perform more string manipulation in order to extract the needed information before reformatting it
So here’s what I have finally got setup and working. It does not speak directly to OP question, but may proove useful for the concepts. Here’s how I set up my mqtt connections:
Zigbee2MQTT service configuration file (abstracted to relevent settings):
HA MQTT integration is using default settings connecting to Mosquitto. MQTT Explorer (or similar) shows a clean structure with Zigbee2MQTT, Zwave2MQTT and homeassistant as root topics. HA is looking for topics under device classes such as light, sensor, switch, binary_sensor, fan etc…
As an added bonus, I created friendly names in both Zigbee2MQTT and Zwave2MQTT using / which creates a nice structured topology. So ultimately, HA is limited to a single discovery topic, but each MQTT client / publisher can isolate their content from others so long as it provides for HA discovery as both of these do.
I’ve come across numerous articles / threads where folks were guided towards setting all topics to homeassist, effectively co-mingling all of the topics together. This is not so good from a performance perspective (IMHO) as all clients / pubs will be reading all messages from all other clients / pubs causing unncessary overhead reading and rejecting out of scope messages.