Split config with mqtt: instead of platform: mqtt

Old world:

In configuration.yaml: “sensor: !include_dir_merge_list sensors”

In sensors/classic.yaml:

- platform: mqtt
  name: Foo
  state_topic: Bar

Works fine.

New world:

In configuration.yaml: “mqtt: !include_dir_merge_list mqtt”

in mqtt/classic.yaml (only one file in the subdir for testing purposes):

- sensor:
  - name: Foo
  state_topic: Bar

Error: “Invalid config for [mqtt]: expected dictionary for dictionary value @ data[‘mqtt’]. Got [OrderedDict([…”

I know I am doing something silly wrong, have tried all combinations of indent and dash or no dash.

If I add the line “mqtt:” to the top of the subfile, then the error goes away, but the entities do not populate.


looks like your spacing is out a bit

this is mine want them in difference folders and also if I make the logic beater I code have differance files inside said folder.

  sensor: !include_dir_merge_list mqtt/sensor/
  climate: !include_dir_merge_list mqtt/climate/
  binary_sensor: !include_dir_merge_list mqtt/binary_sensor/
  switch: !include_dir_merge_list mqtt/switch/
  light: !include_dir_merge_list mqtt/light/

and the folders look like

in side the Light folder


inside the lights.yaml

the yaml stuff

  - name: "Hallway"
    state_topic: "stat/SONOFF10/POWER"
    command_topic: "cmnd/SONOFF10/POWER1"
    payload_on: "ON"
    payload_off: "OFF"
    qos: 0

  - name: "Hallway slave"
    state_topic: "stat/SONOFF6/POWER"
    command_topic: "cmnd/SONOFF6/POWER1"
    payload_on: "ON"
    payload_off: "OFF"
    qos: 0
1 Like

Thanks much for the thoughts Stephan.

The issue is that I want multiple files separated by source device (since I have several devices talking MQTT to a single broker), and each one has some sensors, some binary sensors, etc.

So where you have a single folder for all of your sensors, I want several files that all have sensors in them.

In the old world, I could have multiple lines of the form:

  platform: mqtt
  name: foo

  platform: mqtt
  name: bar

This was even documented in Adding devices to Home Assistant - Home Assistant

But in the new world, it seems like I only can have one file for


Even if the mqtt: integration tag is in my main config file and then !includes other files

Turns out that Platforms is the way to deal with this…

Could you expand a little bit as to how you did it with platforms?
I have a device.yaml set up like this:

  - platform: mqtt
    name: "BSB-LAN outside tempt"
    state_topic: "BSB-LAN/8700"
    unique_id: "BSB_outside_temp"
    unit_of_measurement: °C
    device_class: temperature
    force_update: true

    - platform: mqtt
      unique_id: "BSB-LAN_opmode"
      name: "BSB-LAN operating mode"
      command_topic: "BSB_LAN"
        - "0 - Protection"
        - "1 - Auto"
        - "2 - Reduced Temp"
        - "3 - Comfort"
      command_template: S700={{ value[:1] }}
      state_topic: "BSB-LAN/700"

And if in my configuration.yaml I write:

bsblan: !include mqtt/device.yaml

I get an error that bsblan is unknown integration. Can you give me some pointers as to how to proceed? I have multiple furnace controllers I would like to handle them in files separated by device not device function.