Yaml giving me an error, not sure what it means! Please help!

Hi, I am new to mqtt. I created a YAML file for it and included it in the configuration.yaml. Here is the error I get when running check:

Configuration invalid!

Invalid config for [mqtt]: [mqtt] is an invalid option for [mqtt]. Check: mqtt->mqtt->0->mqtt. (See /config/configuration.yaml, line 15).

This is my configuration.yaml:

# 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
mqtt: !include mqtt.yaml

and my mqtt.yaml:

mqtt:
    - name: "Office LED Clock"
      unique_id: Pool_LED_Clock
      availability:
        - topic: "ESP32_Clock/Pool/Status"
      payload_available: "Online"
      payload_not_available: "Offline"
      value_template: "{{ value_json.device_status }}"
      state_topic: "ESP32_Clock/Pool/Light/Power"
      command_topic: "ESP32_Clock/Pool/Light/Power/Set"
      brightness_state_topic: "ESP32_Clock/Pool/Light/Brightness"
      brightness_command_topic: "ESP32_Clock/Pool/Light/Brightness/Set"
      rgb_state_topic: "ESP32_Clock/Pool/Light/Color"
      rgb_command_topic: "ESP32_Clock/Pool/Light/Color/Set"
      qos: 1
      payload_on: "ON"
      payload_off: "OFF"
      optimistic: true
      retain: true

Any help would be greatly appreciated! Thank you.

-David

Since you are referencing mqtt: in the config.yaml, you don’t use it in the mqtt.yaml file. Simply remove (or # out) that line and then remove the excess indentation.

@sparkydave - thank you for the help. I removed the mqtt from the mqtt.yaml and removed the excess indentation, but still getting the error:

Invalid config for [mqtt]: [name] is an invalid option for [mqtt]. Check: mqtt->mqtt->0->name. (See /config/configuration.yaml, line 15).

- name: Office LED Clock
  unique_id: Pool_LED_Clock
  availability:
    - topic: ESP32_Clock/Pool/Status
  payload_available: Online
  payload_not_available: Offline
  value_template: "{{ value_json.device_status }}"
  state_topic: ESP32_Clock/Pool/Light/Power
  command_topic: ESP32_Clock/Pool/Light/Power/Set
  brightness_state_topic: ESP32_Clock/Pool/Light/Brightness
  brightness_command_topic: ESP32_Clock/Pool/Light/Brightness/Set
  rgb_state_topic: ESP32_Clock/Pool/Light/Color
  rgb_command_topic: ESP32_Clock/Pool/Light/Color/Set
  qos: 1
  payload_on: ON
  payload_off: OFF
  optimistic: true
  retain: true

Thanks for the help!

-David

  light:
    - name: "Office LED Clock"
      unique_id: Pool_LED_Clock
      availability:
        - topic: "ESP32_Clock/Pool/Status"
      payload_available: "Online"
      payload_not_available: "Offline"
      value_template: "{{ value_json.device_status }}"
      state_topic: "ESP32_Clock/Pool/Light/Power"
      command_topic: "ESP32_Clock/Pool/Light/Power/Set"
      brightness_state_topic: "ESP32_Clock/Pool/Light/Brightness"
      brightness_command_topic: "ESP32_Clock/Pool/Light/Brightness/Set"
      rgb_state_topic: "ESP32_Clock/Pool/Light/Color"
      rgb_command_topic: "ESP32_Clock/Pool/Light/Color/Set"
      qos: 1
      payload_on: "ON"
      payload_off: "OFF"
      optimistic: true
      retain: true

You beat me to it!

Still getting the same error with the suggested change.

The examples in the documentation look like this:

  - light:
      name: "Office LED Clock"
      unique_id: Pool_LED_Clock
      availability:
        - topic: "ESP32_Clock/Pool/Status"
      payload_available: "Online"
      payload_not_available: "Offline"
      value_template: "{{ value_json.device_status }}"
      state_topic: "ESP32_Clock/Pool/Light/Power"
      command_topic: "ESP32_Clock/Pool/Light/Power/Set"
      brightness_state_topic: "ESP32_Clock/Pool/Light/Brightness"
      brightness_command_topic: "ESP32_Clock/Pool/Light/Brightness/Set"
      rgb_state_topic: "ESP32_Clock/Pool/Light/Color"
      rgb_command_topic: "ESP32_Clock/Pool/Light/Color/Set"
      qos: 1
      payload_on: "ON"
      payload_off: "OFF"
      optimistic: true
      retain: true

So if that fails to work then something else is wrong.

Just tried that, still getting this error:

Configuration invalid!
Invalid config for [mqtt]: [value_template] is an invalid option for [mqtt]. Check: mqtt->mqtt->0->light->0->value_template. (See /config/configuration.yaml, line 15).

It’s referencing the mqtt line in the config.yaml - am I doing something wrong in that file?


# 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
mqtt: !include mqtt.yaml

value_template: "{{ value_json.device_status }}"

Should be

state_value_template: "{{ value_json.device_status }}"

Not necessarily. Long ago, everything was in configuration.yaml and mine at one time was over a hundred lines. A couple of years ago we got !include which greatly decluttered the configuration.yaml file. But it leaves the problem of counting lines because to the interpreter reading configuration.yaml, the line numbers keep incrementing within each !include file. So in your configuration.yaml file, the first line in automations.yaml is line 13 in configuration.yaml.

It’s confusing.

The !include file sequence doesn’t make any difference (that I am aware of), move the mqtt: !include mqtt.yaml line up to be the first !include line. This way it is easier to count lines in configuration.yaml.

Thank you so much, everyone. Turns out @tom_l was right - it was the state_value_template that did it. No more errors!

I really appreciate you all helping out here. I am still new with YAML, so it helps to get different perspectives.

Last question - this is an LED clock - should I leave the - light: at the top of the file?

Yes, it will error if you remove it. That refers to the domain being used.