Syntax of YAML/homeassistant

Hey all,

Could someone please explain to me or at least point me in the direction of somewhere which explains how my YAML files should be structured.

  • When should “type” have a - in front of it and when it shouldn’t
  • How you configure horizontal stacks, what if you dont want it on the top row, maybe the second?
  • What does “-” actually mean? Does it mean its a parent and any cards which follow are “children”
  • How many spaces should there be and when there shouldn’t be any spaces/

I’ve been trying to work on this for the last 6 hours and various problems have cropped up throughout the night, this seems to be my last hurdle. Below is my ui-lovelace.yaml file which doesn’t display anything other than an error:

Error: “mapping values are not allowed here in “/config/ui-lovelace.yaml”, line 15, column 16”

YAML:

views:
    # View tab title.
  - title: Example
    cards:
        # The markdown card will render markdown text.
      - type: markdown
        title: Lovelace
        content: >
          Welcome to your **Lovelace UI**.
      - type: entity-button
        entity: switch.utility_light
        action: toggle
        
           type: horizontal-stack
           cards:
             - type: entity-button
               entity: switch.utility_light
             - type: entity-button
               entity: switch.utility_light
        

I’ve formated my code, can anyone help me out correct this please?

All indented lines are exactly 2 spaces from the previous one. Tabs are not permitted.
If you want configuration help, please format your posting properly.

HomeAss_CodeMarking_From%40finity

1 Like

Give this a read

2 Likes

Updated formatting of my YAML, any help would be appreciated.

Something strange happened with some of your formatting. Look around the boxed region. There can be onlu one cards: entry.

image

1 Like

Your horizontal stack type isn’t aligned with the rest of the types.

views:
    # View tab title.
  - title: Example
    cards:
        # The markdown card will render markdown text.
      - type: markdown
        title: Lovelace
        content: >
          Welcome to your **Lovelace UI**.
      - type: entity-button
        entity: switch.utility_light
        action: toggle
        
      - type: horizontal-stack
        cards:
          - type: entity-button
            entity: switch.utility_light
          - type: entity-button
            entity: switch.utility

Try it this way it will probably work.
The ‘-‘ is meant to distinguish the different cards, so it is not necessary to put it in front of “type”. As long as the first line of the card has that ‘-‘ (without the quotes).

  - name: test card
    type: entity-button

This would work too!

1 Like

Thanks for that, this summed it up and now I have 5 views and figured out the basics. You guys are awesome!