home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
4.13k stars 2.81k forks source link

YAML dump appears not consistent to core #21860

Open akloeckner opened 3 months ago

akloeckner commented 3 months ago

Checklist

Describe the issue you are experiencing

I acknowledge that YAML will most likely never match entirely between UI and configuration files. However, simple harmonizations could be done. Consider this script example:

In UI:

alias: Test Unicode
sequence:
  - variables:
      abort: "{{ \"\\uE12C\" }}"
mode: single

In scripts.yaml:

test_unicode:
  alias: Test Unicode
  sequence:
  - variables:
      abort: '{{ "\uE12C" }}'
  mode: single

The difference in quotes seems to be a choice.

For the UI double quotes are set: https://github.com/home-assistant/frontend/blob/a09f44dcd2b887b3a40116caa4705045dae005ab/src/components/ha-yaml-editor.ts#L62

While core seems to default to single quotes: https://github.com/home-assistant/core/blob/671aaa7e957ffd9603d0c5beb39b10d00d223da6/homeassistant/util/yaml/dumper.py#L21

Probably more options could be harmonized: https://github.com/nodeca/js-yaml/tree/master?tab=readme-ov-file#dump-object---options-

Describe the behavior you expected

YAML in UI and in configuration files should be more alike.

Steps to reproduce the issue

  1. Copy above script into the code editor
  2. Save and compare scripts.yaml

What version of Home Assistant Core has the issue?

2024-8-3

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

No response

Which operating system are you using to run this browser?

No response

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

github-actions[bot] commented 11 hours ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.