#Comments in Dashboard Code

1 messages · Page 1 of 1 (latest)

thorny hemlock
#

What is the technical reason for comments not being persisted in the yaml code of dashboards? The yaml for dashboards can become very long very quickly, thus having comments in there would be helpful.

snow bison
#

You could try Jinja2 comments ( {# ... #} ). I haven't tested it with dashboard configs yet.

thorny hemlock
#

Does the entire yaml end up getting parsed as a template? I thought that only applies to property values.

vivid harbor
#

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.

thorny hemlock
vivid harbor
#

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.