I’m working a project that I would like to integrate into Home Assistant via MQTT, but am currently grinding my wheels a bit getting autodiscovery working.
While the core concepts and discovery payloads are well documented in the docs themselves, these only go so far and don’t allow workflows like imports into TypeScript for sanity checking.
Is there a place to get JSON schemas for the MQTT discovery message and all appropriate component entries?
Hi,
I’ve not seen a full list in JSON beyond the source or the topic list in the MQTT discovery docs, but search is your friend - I’ve posted several examples over the years including mosquitto_pub example tests and tooling:
I did manage to find mqtt2ha and node-ha-mqtt-discoverable for type references, which provide some of the documentation, but apparently still use the “legacy” style of per-component discovery (which, according to the docs is deprecated?). Helpful, but still not a full schema.
It does seem odd that there isn’t published schema information for this, though. As far as I can tell, all of the schemas are defined via voluptuous, and HA has their own library for serializing these rules into schemas. I can combine all of these things myself, but this really feels like something that should be handled at the project level versus requiring independent devs to completely redefine these object types.
Point taken about iterating by just trying things until they work, I was mostly trying to avoid that by having as clear of a definition set as possible.