I’d like to use IDE to edit complex HA configurations, but it’s difficult do it w/o instant schema validation / code completion. This leads to a tedious cycle of editing in an IDE, testing in Home Assistant, and fixing errors.
This is where a dedicated endpoint providing the YAML schema for the configuration?
Picture an endpoint like /homeassistant/openapi.json
that returns a JSON schema representing the entire configuration structure. Popular IDEs like PyCharm could then leverage this schema to offer:
- Real-time validation: Highlight errors and issues as you type, preventing them from reaching Home Assistant.
- Code completion: Access detailed information about each option and get suggestions for valid values and nested structures.
- Improved maintainability: Catch errors early.
AFAIK Home Assistant uses Pydantic to build data structures. Pydantic conveniently offers built-in mechanisms to generate JSON schemas from its data models. Moreover, similar functionality exists in frameworks like FastAPI, where /openapi.json
provides complete JSON schma of data structures.
The question is: Does such an endpoint currently exist for Home Assistant? Has anyone explored building or requesting it? The benefits for YAML editing users, who uses IDEs, would be immense!
1. I’m not asking for complete YAML validation as HA may do , but at least keywords, structure, types can be checked via JSON schema.
2. Projects like this will tend to fall-behind, be incomplete and incorrect vs specific version, because of the need to follow-up all changes in the product and differences between different versions of HA. Only the instance of HA can say, which config it accepts .
Related to this.