MindFreeze / ha-sankey-chart

A Home Assistant lovelace card to display a sankey chart. For example for power consumption
MIT License
387 stars 20 forks source link

[Bug] When using UI editor, the yaml code gets altered #223

Open AleXSR700 opened 1 month ago

AleXSR700 commented 1 month ago

Checklist:

Release with the issue: 3.2.4 Last working release (if known):

Browser and Operating System: Chrome, Windows 11

Description of problem:

When creating a card using yaml editor, the card seems to work fine. But if after doing all the manual work, you change a setting (or just play with a setting in the UI) a whole bunch of code is added to the yaml code that is partially incorrect.

E.g., things like the fake CO2 sensor are force added:

convert_units_to: ''
co2_intensity_entity: sensor.co2_signal_co2_intensity
gas_co2_intensity: 2351.6459999999997
min_box_size: 3
min_box_distance: 5

and all the entities of the final child are converted from a nice list to a bunch of entities with no children: from

          - sensor.fixed_value_consumers_energy_today
          - sensor.siemens_sx758x06te_42_energy_today
          - sensor.naim_audio_nsub_energy_today
          - sensor.light_dining_room_ambient_energy_today_0
          - sensor.light_dining_room_ambient_energy_today_1
          - sensor.office_energy_today

to

      - type: entity
        children: []
        entity_id: sensor.fixed_value_consumers_energy_today
      - type: entity
        children: []
        entity_id: sensor.siemens_sx758x06te_42_energy_today
      - type: entity
        children: []
        entity_id: sensor.naim_audio_nsub_energy_today
      - type: entity
        children: []
        entity_id: sensor.light_dining_room_ambient_energy_today_0

These changes are partially incorrect (adding fake sensor) and in part simply mess up the cleanliness of the code by adding lots of redundant lines. :(

Would it be possible to disable these adjustments and instead only write the specific lines of codes of the options that are adjusted? E.g. when changing the height, only that line is needed. The rest of the code does not need to be touched :)

Thank you for your consideration (and cool card, of course!)

Alex

Javascript errors shown in the web inspector (if applicable):

Additional information:

MindFreeze commented 1 month ago

There is nothing incorrect here. It just adds the default values and expands entities into the long form format. It would be nice to keep the format but that's a lot of work tbh, so I don't know if I'll get around to it

AleXSR700 commented 1 month ago

Thank you for taking the time to respond :)

Why does it add the default code even though it is not needed? I am not aware of any other card doing this. After all, the defaults do not need to be added because they are, well, default. Hence they carry no information and just crowd the code.

In addition, the placement is a bit strange 😄 Some default code is added at the top, some at the bottom.

And the long format is... long 😄 and makes it much more difficult to read and adjust.

It would be a cool enhancement especially for people new to the card. I think being able to play with settings via the UI makes it easier to test them. But since it changes the code the user has written, it kind of makes it less attractive to use the UI.

Of course just my opinion :-)

AleXSR700 commented 1 month ago

I noticed that the indentation is not correct when parts are added automatically. The indentation seems to be 4 spaces instead of 2. Also, would it be possible to keep the entity_id at the top? Right now it is usually found below the children, which makes larger sections more difficult to keep organized.