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.
Same here. I am trying to implement a super simple monitoring tool in C#, and it should be discoverable. I was kind of expecting to find a Json schema or something similar to be able to generate classes for Json serialization.
I’m in the same position, and just filed an issue in the voluptuous-serialize repository because it doesn’t even work with the MQTT device discovery payload schema.
I find the documentation lacking, even if it is verbose it is really hard to understand (even if you want to use the device discovery payload, you have to read the deprecated component discovery payload section and figure out what still applies).
having a JSON Schema would be a nice added value, at least among the developers here