Split config in packages

Hello,
I am new and need a little help …
I want to split my config in packages but get crazy … maybe i am to stupid.
Config check say everyting is fine but nothing from the package get loaded :frowning:
When i copy it back to the main config everything is fine.

Main Config:

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

# Text to speech
  tts:
  - platform: google_translate

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

licht.yaml:

###################### Schalter ######################

# Bad
switch LBA1:
  - platform: mqtt
    unique_id: LBA1
    name: "Bad"
    state_topic: "stat/LBA1/POWER"
    command_topic: "stat/LBA1/cmnd/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true
    
# WC
switch LWC1:
  - platform: mqtt
    unique_id: LWC1
    name: "WC"
    state_topic: "stat/LWC1/POWER"
    command_topic: "stat/LWC1/cmnd/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true
    
# Bücherzimmer
switch LBZ1:
  - platform: mqtt
    unique_id: LBZ1
    name: "Zwischenzimmer"
    state_topic: "stat/LBZ1/POWER"
    command_topic: "stat/LBZ1/cmnd/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true
    
###################### Gruppen ######################

group:
  ws1:
    entities:
      - switch.wc
      - switch.bad
      
###################### Automation ######################

# Wechselschalter Test Bad / WC
automation:
- id: '1617896516551'
  alias: WSA1
  trigger:
    - platform: state
      entity_id:
        - switch.wc
        - switch.bad
  action:
    entity_id: group.ws1
    service: homeassistant.turn_{{ trigger.to_state.state }}

Thank you very much for helping !

Your configuration looks fine in general, but if it doesn’t work the first thing I’d try is removing the integration specifiers, e.g. switch LBA1:switch: and then list all switches under there.

That’s at least how I understand the note in the doco:

Components inside packages can only specify platform entries using configuration style 1, where all the platforms are grouped under the integration name.

Thank you exxamalte.

I have changed the switches now the editor shows up:
duplicated mapping key at line 19, column -292: switch:

Configuration check ist Ok !

But also nothing get loaded :frowning:

I have also changed it to “packages: !include_dir_named packages” and put the file in the folder.
Same behavior nothing from the File get loaded.

Its a litte bit strange …

I have found a (the) solution after some hours testing and a completly fresh installation.

I have to paste the “homeassistant:” after the default config comes with home assistant and then my package config.

Put the “homeassistant:” at the top of the config as shown in the docs will not work maybe they have changed here something …

Here the configuration.yaml (only added the “homeassistant:” and after):


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

# Text to speech
tts:
  - platform: google_translate

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

homeassistant:
  packages: !include_dir_named packages

Also name the switches like “switch LBA1:” should be the correct way otherwise i get the “duplicated mapping key” error in the editor.

Here the file in the package folder:

###################### Schalter ######################

# Bad
switch LBA1:
  - platform: mqtt
    unique_id: LBA1
    name: "Bad"
    state_topic: "stat/LBA1/POWER"
    command_topic: "stat/LBA1/cmnd/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true
    
# WC
switch LWC1:
  - platform: mqtt
    unique_id: LWC1
    name: "WC"
    state_topic: "stat/LWC1/POWER"
    command_topic: "stat/LWC1/cmnd/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true
    
# Bücherzimmer
switch LBZ1:
  - platform: mqtt
    unique_id: LBZ1
    name: "Zwischenzimmer"
    state_topic: "stat/LBZ1/POWER"
    command_topic: "stat/LBZ1/cmnd/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"
    optimistic: false
    qos: 0
    retain: true
    
###################### Gruppen ######################

group:
  ws1:
    entities:
      - switch.wc
      - switch.bad
      
###################### Automation ######################

# Wechselschalter Test Bad / WC
automation:
- id: '1617896516551'
  alias: WSA1
  trigger:
    - platform: state
      entity_id:
        - switch.wc
        - switch.bad
  action:
    entity_id: group.ws1
    service: homeassistant.turn_{{ trigger.to_state.state }}

Now it works without any problems :slight_smile:

Maybe this should be added to the documentation for other new users so they dont spend hours to find out that now “homeassistent:” should not be pasted on the top of the file like described now !

Thanks to all !

Most likely this happens because you need to group all switch definitions under a single switch: heading. So, it should look like:

switch:
  - platform: mqtt
    unique_id: LBA1
    name: "Bad"
    ...
  - platform: mqtt
    unique_id: LWC1
    name: "WC"
    ...

Sorry, I didn’t notice before, but the configuration in your first post is wrong. packages is a sub-item of homeassistant. But default_config, group, automation, etc. are all on the same level (indentation) as homeassistant.
In other words, the two following lines can go anywhere in your configuration file, as long as their indentation stays as it is now:

homeassistant:
  packages: !include_dir_named packages

With the above in mind, the homeassistant section can indeed be located at the top of the file.