Indentation error in configuration.yaml

Hello,

I am getting bad indentation errors (bad indentation of a mapping entry on Line 19,

  • platform: maytag_dryer). I keep trying to adjust but to no avail. Can someone see where the line needs to be moved to? Thank you
homeassistant:
    packages: !include_dir_named packages

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

  - platform: maytag_dryer
    user: "[email protected]"
    password: "mypwd"
    dryersaids:
      - "yourdryerSAID" 
    washersaids:
      - "MVW6230RHW1"

You’re missing the sensor beforehand

sensor:
  - platform
    ...

It creates a sensor so put it under the sensor: key.

On the other hand, if you already have this somewhere in the file:

sensor: !include sensors.yaml

then it should go into the sensors.yaml file.

1 Like

@123 the configuration.yaml file I posted is complete and fairly small. so there is no reference to sensor: !include sensors.yaml in configuration.yaml file. @jchh I tried adding sensor: right before the 2nd - platform line and it does not compile clean. I am using File Editor. Is there something else that is better for dealing with these nit picky yaml files? Also, I did not have any issues until I added the maytag section. Thanks to both for offering assistance.

What’s the error message?

BTW, you can only have one instance of sensor: in the file so make sure the one you added isn’t duplicating an existing one.

YAML employs indentation to structure data (instead of parentheses, brackets, braces, etc). Therefore, the data’s meaning is altered, often corrupted, if its indentation isn’t correct.

Because what you added has no context. It’s a configuration for something but what exactly isn’t clear (to Home Assistant) because it’s not part of any key like
sensor:
binary_sensor:
switch:
light:
etc

Can you post the updated configuration.yaml?

Thanks @123 and @jchh for help thus far.

Updated configuration.yaml

homeassistant:
    packages: !include_dir_named packages

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml

Newly added sensors.yaml

Sensor:

- platform: maytag_dryer
    user: "[email protected]"
    password: "mypwd"
    dryersaids:
      - "yourdryerSAID" 
    washersaids:
      - "MVW6230RHW1"

Error from sensors.yaml
image

well the error says it all, use the correct indentation:

- platform: maytag_dryer
  user: "[email protected]"
  password: "mypwd"
  dryersaids:
    - "yourdryerSAID" 
  washersaids:
    - "MVW6230RHW1"

and check the known thread on this community: see Maytag Smart Washer/Dryer Integration - #78 by MKME_Lab

this seems the way to go though: Maytag Smart Washer/Dryer Integration - #106 by jaaem

also, sensor is in lower case

1 Like

I appreciate the help, but yaml is super fussy with how it wants stuff indented. I been wrestling around with it thanks to the help of the other two. Maybe Notepad++ or SlickEdit is needed to avoid wrestling how fussy this language is

no it’s not fussy, its all rather well documented, you might need to get accustomed to it though. If in doubt, find the documentation, that always helps. Well, the odd bad doc aside ofc…

2 Likes

Probably because the indentation was wrong in my github documentation jdeath/maytag_dryer_homeassistant (github.com). I think I fixed it.

1 Like

Well we can’t comment on that as you haven’t pointed to the github.

You’re finding creative ways of not doing what has been suggested. :slightly_smiling_face:

Your first post shows the sensor’s configuration perfectly indented but it simply lacked the sensor: key word. It was suggested to add it.

Your most recent example removed the indentation from the first line and added Sensor: with a capital S instead of the recommended sensor:

Can you suggest in what other way we can explain it so you don’t make more mistakes like this?

Screenshot_20230325-194528~2

2 Likes

Not a scripter\coder and still a new HA enthusiast. Thanks again to all who responded. Point taken @123. Need to be more observant.

Maybe this will help.

YAML and JSON are two common formats employed to present structured data. There are online tools, like jsonformatter, that can convert from one format to the other.

Here’s a screenshot showing some random data I created on the left in YAML and, on the right, how the same information is presented in JSON. YAML is concise and uses indentation as a means of structuring the data whereas JSON is verbose and uses braces, brackets, double-quotes, etc. Unlike YAML, JSON doesn’t rely on indentation to convey any special meaning. However, in lieu of indentation, it has its own rules about how all of that “punctuation” should be used.

  • colors is a list containing three items. Each item in this example is a string.

  • months is a dictionary containing three keys and three associated values (i.e. three key-value pairs). All values in this example are integers.

  • animals is a list containing three items. Each item is a dictionary containing two key-value pairs. All values in this example are strings

So if I wanted to create a shopping list and structure it as a YAML list, it would look something like this:

my_shopping_list:
  - apples
  - bananas
  - oranges
  - eggs

If I wanted to include more information such as quantity, I could choose to structure it as a dictionary:

my_shopping_list:
  apples: 12
  bananas: 8
  oranges: 6
  eggs: 12

If I wanted to get a bit fancier, and add more information for each thing I want to buy, I could structure it like this:

my_shopping_list:
  - name: apples
    qty: 12
    store: ABC
  - name: bananas
    qty: 8
    store: XYZ
  - name: oranges
    qty: 6
    store: ABC
  - name: eggs
    qty: 12
    store: MNO

If I wanted to offer a choice of stores for buying each item, I can replace the existing string value with a list.

my_shopping_list:
  - name: apples
    qty: 12
    store:
      - ABC
      - XYZ
  - name: bananas
    qty: 8
    store:
      - ABC
      - XYZ
  - name: oranges
    qty: 6
    store:
      - ABC
      - QRS
  - name: eggs
    qty: 12
    store: 
      - MNO
      - TUV

I hope this helps, just a little bit, to demystify YAML’s use of indentation and hyphens to structure data.

1 Like

thats a very useful primer indeed.
also, you can read here: Thomas Lovén - YAML for Non-programmers

it’s an often referred to post by Thomas, and builds on what Taras mentions above. Targeted at people that say:

1 Like