#Comments in Dashboard Code
1 messages · Page 1 of 1 (latest)
You could try Jinja2 comments ( {# ... #} ). I haven't tested it with dashboard configs yet.
Does the entire yaml end up getting parsed as a template? I thought that only applies to property values.
What is the technical reason for comments not being persisted in the yaml code of dashboards?
IIRC it is because UI-created dashboards are not saved as YAML. They're actually saved in JSON which does not support comments. YAML is easier for people to read while HA reads JSON.
Dashboards running in YAML Mode do retain comments since their files are explicitly saved. But, YAML Mode dashboards cannot be edited with the UI and have to be edited with a text/code editor.
Interesting. But that does sound like a minor historical limitation right? If the UI editor can deal with JSON, it should have no trouble using yaml either. They are 100% convertible after all.
Yes and no. It's not a matter of the UI handling JSON. The underlying operations for HA is stored in JSON. (I picked three random files in the hidden .storage folder and they were all JSON files.) The UI (a subsystem of HA) parses the JSON into YAML as a "convenience" to the user. Like I mentioned earlier, YAML is easier for the user to read. When you go to save, the UI parses the YAML and saves it as JSON. And, as you've noticed, comments are stripped away because they not compatible with the JSON file format. It all just goes back to the fact that HA doesn't (really) use YAML.