From 'old' mqtt config to new config

Hi,
Yesterday I upgraded to 2022.9.0 and after the restart, I got 3 warninigs that mqtt config (for my mqtt switches, sensors and binary sensors) would no longer work after … (around end of the year I think).
That old config looked like this eg (switch)
configuartion.yaml
switch: !include_dir_merge_list switches/
in switches/ I have a file eg alarm.yaml with content like this

  - platform: mqtt
    unique_id: alarm_state
    name: "Alarm State"
    state_topic: "engrie111/alarmtrigger/data/alarm"
    command_topic: "engrie111/alarmtrigger/command"
    payload_on: "Alarm=ON"
    payload_off: "Alarm=OFF"
    state_on: "ON"
    state_off: "OFF"
    qos: 1
    retain: false

So, based on what I found I reconfiged like this
configuration.yaml
mqtt: !include_dir_merge_list mqtt/

in mqtt/ I have a file alarm.yaml with content

  switch:    
    - name: "Alarm State"
      unique_id: alarm_state
      state_topic: "engrie111/alarmtrigger/data/alarm"
      command_topic: "engrie111/alarmtrigger/command"
      payload_on: "Alarm=ON"
      payload_off: "Alarm=OFF"
      state_on: "ON"
      state_off: "OFF"
      qos: 1
      retain: false

Note that I removed the alarm.yaml from the siwtches dir.
Running ‘check configuration’ gives me a valid config. But after restart, the entity in no longer available.
Checking/listening to the topic using the MQTT integration GUI also works fine.

In the list of entities, the entity switch.alarm_state sits under integration mqtt but, as said, no longer available while hoovering over the “red counter-clock rotation + exclamation mark”- symbol, "Restored’ is shown.

Note: beside the alarm.yaml, I have several other yaml files in mqtt/ that contain sensor and/or switch and/or binary_sensor mqtt settings. Is that a problem?

What am I missing or overseeing to get the entity active again?

Regards
Marc

This is a list:

- something
- something else
- another thing

This is not a list:

  switch:    
    - name: "Alarm State"
      unique_id: alarm_state etc...

Try merge_named https://www.home-assistant.io/docs/configuration/splitting_configuration/#example-include_dir_merge_named

1 Like

Or -

mqtt:
  sensor: !include_dir_merge_list cfg/_component/mqtt/sensor/
  binary_sensor: !include_dir_merge_list cfg/_component/mqtt/binary_sensor/
  switch: !include_dir_merge_list cfg/_component/mqtt/switch/

is the way I do it, because I have multiple files for each

2 Likes

Thx. I see where I missed it. But I shoose for the way andrw Jones did it as that matches the way I have set-up my HA. Lesson learned :wink:

Thx. Indeed, that solved the problem. It was an easy fix.

1 Like