Newbie question - what am I doing wrong in my configuration?

Hi all,
I’m quite experienced with home assistant and I have two instances in two houses running.
I feel ashamed to ask for help to understand what am I doing wrong with this configuration in terms of yaml? I get the folllowing error:


Logger: homeassistant.components.websocket_api.http.connection
Source: components/homeassistant/__init__.py:170
Integration: Home Assistant WebSocket API
First occurred: 10:53:15 AM (5 occurrences)
Last logged: 11:14:34 AM

    [1827832784] The system cannot restart because the configuration is not valid: Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block collection in "/home/homeassistant/.homeassistant/configuration.yaml", line 31, column 3 expected <block end>, but found '<block sequence start>' in "/home/homeassistant/.homeassistant/configuration.yaml", line 56, column 4
    [1826324544] The system cannot restart because the configuration is not valid: Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block collection in "/home/homeassistant/.homeassistant/configuration.yaml", line 31, column 3 expected <block end>, but found '?' in "/home/homeassistant/.homeassistant/configuration.yaml", line 32, column 3
    [1826681832] The system cannot restart because the configuration is not valid: Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block mapping in "/home/homeassistant/.homeassistant/configuration.yaml", line 1, column 1 expected <block end>, but found '<block sequence start>' in "/home/homeassistant/.homeassistant/configuration.yaml", line 41, column 3

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/service.py", line 733, in admin_handler
    await result
  File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/homeassistant/__init__.py", line 170, in async_handle_core_service
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: The system cannot restart because the configuration is not valid: Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block collection
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 31, column 3
expected <block end>, but found '<block sequence start>'
  in "/home/homeassistant/.homeassistant/configuration.yaml", line 56, column 4

This is line 31 (starting from - platform)

switch:

### SHELLY 1 EM ###
   - platform: mqtt
     name: "Output"
     state_topic: "shellies/shellyem-0620F/relay/0"
     command_topic: "shellies/shellyem-0620F/relay/0/command"
     qos: 1
     payload_on: "on"
     payload_off: "off"
     retain: false

hi

switch:
### SHELLY 1 EM ###
  - platform: mqtt
    name: "Output"
    state_topic: "shellies/shellyem-0620F/relay/0"
    command_topic: "shellies/shellyem-0620F/relay/0/command"
    qos: 1
    payload_on: "on"
    payload_off: "off"
    retain: false

??? (2 spaces) ???

Could you elaborate a bit?

switch:
‘space1’ 'space2"- platform
2 spaces not 4

I see two spaces before - platform
Ah no it was three! My bad

I still get the same error:

 Logger: homeassistant.util.yaml.loader
Source: util/yaml/loader.py:127
First occurred: 10:53:15 AM (10 occurrences)
Last logged: 12:38:42 PM

    while parsing a block collection in "/home/homeassistant/.homeassistant/configuration.yaml", line 31, column 3 expected <block end>, but found '<block sequence start>' in "/home/homeassistant/.homeassistant/configuration.yaml", line 56, column 4
    while parsing a block collection in "/home/homeassistant/.homeassistant/configuration.yaml", line 31, column 3 expected <block end>, but found '?' in "/home/homeassistant/.homeassistant/configuration.yaml", line 32, column 3
    while parsing a block mapping in "/home/homeassistant/.homeassistant/configuration.yaml", line 1, column 1 expected <block end>, but found '<block sequence start>' in "/home/homeassistant/.homeassistant/configuration.yaml", line 41, column 3
    while parsing a block collection in "/home/homeassistant/.homeassistant/configuration.yaml", line 31, column 2 expected <block end>, but found '<block sequence start>' in "/home/homeassistant/.homeassistant/configuration.yaml", line 41, column 3
    while parsing a block collection in "/home/homeassistant/.homeassistant/configuration.yaml", line 26, column 3 expected <block end>, but found '<block sequence start>' in "/home/homeassistant/.homeassistant/configuration.yaml", line 51, column 4

Line 26:

switch:
### SHELLY 1 EM ###
  - platform: mqtt
    name: "Output"
    state_topic: "shellies/shellyem-0620F1/relay/0"
    command_topic: "shellies/shellyem-0620F1/relay/0/command"
    qos: 1
    payload_on: "on"
    payload_off: "off"
    retain: false

Should it look like this?

switch:
### SHELLY 1 EM ###
- platform: mqtt
  name: "Output"
  state_topic: "shellies/shellyem-0620F1/relay/0"
  command_topic: "shellies/shellyem-0620F1/relay/0/command"
  qos: 1
  payload_on: "on"
  payload_off: "off"
  retain: false

try to paste your full yaml here:
http://yaml-online-parser.appspot.com/
because the code you send seems good

there is a problem with space somewhere
could you try to write Output output , thx you

write it where? With the yaml parser i get the same error but if I count the spaces they are correct!

there is no error on the code you send
name: “Output” —>
name: “output”

Then why home assistant gives me an error? Could it be a type of space UNIX vs windows Idk

it can. but the little code of your yaml do not show error. the error should be before

this is what I have from line 1:


default_config:

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

homeassistant:
  customize: !include customize.yaml
  packages: !include_dir_named packages

system_health:

updater:

history:

sun:

recorder:


switch:

### SHELLY 1 EM ###
  - platform: mqtt
    name: "Output"
    state_topic: "shellies/shellyem-0620F1/relay/0"
    command_topic: "shellies/shellyem-0620F1/relay/0/command"
    qos: 1
    payload_on: "on"
    payload_off: "off"
    retain: false

i m using sublime text on windows i have to switch to views/line_ending/unix instead of windows

I’m using Gedit on Ubuntu… I’ll try something different

try mine

no error with this (copy from your paste)

default_config:

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

homeassistant:
  customize: !include customize.yaml
  packages: !include_dir_named packages

system_health:

updater:

history:

sun:

recorder:
switch:

### SHELLY 1 EM ###
  - platform: mqtt
    name: "Output"
    state_topic: "shellies/shellyem-0620F1/relay/0"
    command_topic: "shellies/shellyem-0620F1/relay/0/command"
    qos: 1
    payload_on: "on"
    payload_off: "off"
    retain: false

its the same code but you shoud have tab or blank somewhere try to remove all blank line and space at each end of line and try sublimetext

or:

Ok I did some find & replace with the spaces, saved with Sublime, put a little bit of cinnamon and it worked.
Thank you so much for the support @tomdudu38

1 Like