How do I figure out which code goes where?

I’m trying to learn how to use HA. I’m getting stuck on understanding which code goes in configuration.yaml and which code goes in groups, automations, etc. I’ve been watching a series on setting up holiday lights and have gotten my esp8266 to talk to my broker, but can’t seem to grasp the yaml files and my controls are not showing up on the overview tab. The only error I can see is a notification that says "
Invalid config

The following components and platforms could not be set up:

  • [group]
  • [script]
  • [light]
  • [automation]
  • [default-config]

Please check your config."

Does this mean there is an error in my configuration.yaml or am I missing something elsewhere?

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
http:
   base_url: mydomain.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
##This version of the holiday lights code does not require the node red portion
##The "W" slider under the main "holiday LED" light modifies each effect
##The "W" slider under "Glitter" light modifies the frequency of glitter, the RGB selection changes the color of the glitter
##The "W" slider under "Lightning" switch modifies the frequency of lightning.
##You must replace the [MQTT_CLIENT_ID] with the USER_MQTT_CLIENT_NAME you specified in the arduino USER CONFIGURATION section
sensor:
  - platform: mqtt
    name: "Current LED"
    state_topic: "LightMCU/locator"

light:
  - platform: mqtt
    name: "Holiday Lights"
    command_topic: "LightMCU/power"
    state_topic: "LightMCU/powerState"
    brightness_command_topic: "LightMCU/brightness"
    brightness_state_topic: "LightMCU/brightnessState"
    brightness_scale: 255
    white_value_command_topic: "LightMCU/modifier"
    white_value_state_topic: "LightMCU/modifierState"
    white_value_scale: 500
    effect_command_topic: "LightMCU/effect"
    effect_state_topic: "LightMCU/effectState"
    effect_list:
      - Color_Chase
      - Color_Glitter
      - Single_Race
      - Double_Crash
      - Rainbow
      - Blocked_Colors
      - BPM
      - Twinkle
      - Fire
      - Fill_Solid
      - Spooky_Eyes
      - LED_Locator
    retain: true
  - platform: mqtt
    name: "Color 1"
    command_topic: "LightMCU/ColorPower"
    state_topic: "LightMCU/powerState"
    rgb_command_topic: "LightMCU/color1"
    rgb_state_topic: "LightMCU/color1State"
    retain: true
  - platform: mqtt
    name: "Color 2"
    command_topic: "LightMCU/ColorPower"
    state_topic: "LightMCU/powerState"
    rgb_command_topic: "LightMCU/color2"
    rgb_state_topic: "LightMCU/color2State"
    retain: true
  - platform: mqtt
    name: "Color 3"
    command_topic: "LightMCU/ColorPower"
    state_topic: "LightMCU/powerState"
    rgb_command_topic: "LightMCU/color3"
    rgb_state_topic: "LightMCU/color3State"
    retain: true
  - platform: mqtt
    name: "Glitter"
    state_topic: "LightMCU/glitter/state"
    command_topic: "LightMCU/addEffects"
    payload_on: "Glitter On"
    payload_off: "Glitter Off"
    rgb_command_topic: "LightMCU/glitterColor"
    rgb_state_topic: "LightMCU/glitterColorState"
    white_value_command_topic: "[LightMCU/glitterChance"
    white_value_state_topic: "LightMCU/glitterChanceState"
    white_value_scale: 255
    retain: true
  - platform: mqtt
    name: "Lightning"
    state_topic: "LightMCU/lightning/state"
    command_topic: "LightMCU/addEffects"
    payload_on: "Lightning On"
    payload_off: "Lightning Off"
    white_value_command_topic: "LightMCU/lightningChance"
    white_value_state_topic: "LightMCU/lightningChanceState"
    white_value_scale: 500
    retain: true
  


Look in Developer Tools then select Logs for more information on what is wrong.

Thank you.

Invalid config for [group]: [houseLights] is an invalid option for [group]. Check: group->group->group->houseLights. (See /config/configuration.yaml, line 12).

Do blank spaces matter in the configuration.yaml? Line 12 is blank

Spaces matter greatly, blank lines do not :crazy_face:

YAML
Yaml Ain’t a Mark-up Language
But it is hierarchical
You have light:
Then you are defining an MQTT platform, with a name: then loads of other things under the same platform. Then you list another MQTT platform etc. Why.?
You only define the platform once under lights, maybe once again under switches

Don’t use capital letters in group names.

Also there should be no group: line in your groups.yaml file.

If that is all correct post your (correctly formatted) groups file contents for us to check.

Because he’s defining multiple mqtt lights.

Okay,
I have no experience of MQTT but thought it would be like when you specify (say) sensors, you define the platform and then define all the elements of that platform under the sensors heading. Then you specify another platform, etc.

What you’re describing is exactly what he’s done. He’s defined the light integration, and under it he’s defined 6 lights, each one controlled by MQTT.

Yes but for sensors (say) you only define the template platform once

Template sensors (and binary sensors and switches) are an internal homeassistant thing so they work differently.

If you look at every other type of sensor, type of switch, notification etc they’re all done like that. Even other homeassistant internal constructed entities (light group for example).

group:
  houseLights:
    name: Holiday Lights
    control: hidden
    entities:    
      - light.holiday_lights
      - light.color_1
      - light.color_2
      - light.color_3
      - light.glitter
      - light.lightning
      - sensor.current_led
      

You need to delete the line group: from your groups.yaml file and move the block of config underneath two spaces to the left (so that houselights: is against the margin), maintain the indentation you have though.

To explain further, you have already specified group: in your configuration.yaml file, this:

group: !include groups.yaml

takes the contents of the file groups.yaml and places it under group:

So at the moment when the !include is parsed you have:

group:
  group:
    houseLights:
      name: Holiday Lights
      control: hidden
      entities:    
        - light.holiday_lights
        - light.color_1
        - light.color_2
        - light.color_3
        - light.glitter
        - light.lightning
        - sensor.current_led

This ain’t right. It needs to be:

group:
  houseLights:
    name: Holiday Lights
    control: hidden
    entities:    
      - light.holiday_lights
      - light.color_1
      - light.color_2
      - light.color_3
      - light.glitter
      - light.lightning
      - sensor.current_led

Which you will accomplish by deleting the line group: from your groups.yaml file.

Also as noted in my post above, you cant use capital letters in entity_ids. So houseLights: needs to be changed to houselights:

1 Like

Thank you so much for the explanation! I’ll give it a try

Thanks again everyone. I got it working!

1 Like