Why is my yaml coding essentially upside down?

Why does my coding differ from 90% of the example codes?

for instance with the type of card at the top this works, however after i come back to it later, the type will be moved to the bottom:

type: horizontal-stack
cards:
  - entities:
      - entity: switch.side_door_light
    type: entities
  - entities:
      - entity: light.front_door_light
    type: entities

after a restart:

cards:
  - entities:
      - entity: switch.side_door_light
    type: entities
  - entities:
      - entity: light.front_door_light
    type: entities
type: horizontal-stack

They both work, but is it doing this?

another example straight from the github page for this custom card example code:

- type: custom:mini-graph-card
  entities:
    - sensor.sensor_temperature
  show:
    labels: true
  color_thresholds:
    - value: 20
      color: "#f39c12"
    - value: 21
      color: "#d35400"
    - value: 21.5
      color: "#c0392b"

When I paste this, I get: No card type found
If i remove the - and fix the indention it works, however after a reboot the Type is back at the bottom. Also the - will be moved to the Color: instead of the Value: like every example.

color_thresholds:
    value: 20
  - color: "#f39c12"
  

Basically every time i copy someones examples, they Never work. I always have to modify it usually its just removing the - and fixing the indention., but it gets repetitive and tiring.

one last example: Raw editer / ui-lovelace.yaml:

every example I see for this has the - on the URL. mine will NOT load if i do it that way:
examples:

resources:
  - url: /local/custom-card.js
    type: js

Mine:

resources:
  - type: js
    url: /local/custom-card.js

Whats the deal here?

If you are using Lovelace UI edit mode (not yaml edit) then the UI sorts the keys alphabetically. It’s an absolute PITA.

As for “-” and indentation, when pasting the code into a UI edit card window it is config for a single card. Not a list of cards in a view, as is the case for yaml mode.

There is some good reading in this topic:

1 Like

Other types of bread are available :stuck_out_tongue_winking_eye:

2 Likes

@fiftys - I highly recommend Visual Code Studio, with the Home Assistant plugin. It handles all of the formatting, offers suggestions on code, and populates all of the entites as you code. It makes life SO much easier.

ahhh, ok i will read through that. its a bit frustrating for sure. thanks for the info.

i have been using Kate and Atom lately,…ill check out Visual studio. Home assistant plugin?! got a link for that?

If you use VSCode from the add-on store it’s already installed. If not, you can get it from here:

https://marketplace.visualstudio.com/items?itemName=keesschollaart.vscode-home-assistant

1 Like

Order doesn’t matter to the machine in YAML as much as it does to us mere mortals who have to read it!

1 Like

Only for lists. It matters for dictionaries. Oops, that’s back to front. Lists are ordered, dictionaries aren’t.

1 Like

Just remember this add-on won’t work on RPi’s.

That’s interesting as the majority on new users (and I’m guessing this is a case in point) are probably running on Pi’s.
I just use notepad++ but do you happen to know why not a Pi ???
I’m not blaming you (unless you wrote it :rofl:)
I then assume they’d have to run it on their desktop and access the files via Samba ???
(I learn a new wrinkle every day)

Because the build is not compatible with ARM systems such as the Pi, it’s only for x86 systems.

You are right that a lot of new users are running it on a Pi, and I forgot about that. After the 3rd or 4th SD card failure in 2 months I just switched to a NUC a year or so ago I’ve forgotten some of those issues with the Pi.

As for how to run it if you do have a Pi, I’d just run VS code in windows (or your OS of choice) and access the files via a samba share.

From the addon’s “Known issues and limitations” -

This add-on currently only supports AMD64 machines, although we hope we are able to support ARM devices in the future, it is most likely that most devices will lack the resources to run this add-on (e.g., Raspberry Pi).

Checked out VS code. Only thing bugging me now is how long it takes this extension to load the remote files.

Anyone using Remote work space extension ? Whats the fastest way to get it to load, im using sftp but it also only loads to user folder… i need it to go right into .homeassistant. hmm

click on .homeassistant.

1 Like

I use Samba, with a gigabit ethernet, my files load faster than from the local file system (they are pretty small files)

1 Like

got it figured out, just had to add the directory to the login. working good so far.

looking like im gonna be swiutching my main editing to VS code.

started with notepad ++ which i really liked… then i moved all my local computers to ubuntu, so i started using Kate. then moved over to atom… now im here… dont think i want to learn another one after this… the auto complete and snippets is just to good.

thanks.