What is this "mqtt deprecated in configuration.yaml" message?

I am getting messages that something about mqtt in configuration.yaml will be deprecated. I am just user, not developer and I do not understand that message. I have following entries in configuration.yaml - will I need to change anything? And how? I have probably hundred of sensors:

#MQTT autodiscovery
mqtt:
  discovery: true
  #qos: 2 not allowed
sensor ACC_Z:
  - platform: mqtt
    state_topic: "AndrOBD/ACC_Z"
sensor 3:
  platform: mqtt
  unique_id: sensor.test_temperature_2
  name: "ESP8266_Temperature"
  state_topic: "sensor/temperature"
  force_update: true
  qos: 2
  unit_of_measurement: "ºC"

Here’s one of the many posts that were arround when this message started - in 2022.9 release:

You need to move your mqtt devices to a mqtt section, with sensors, switches etc under there.

Thanks. What is “mqtt section”? Is it in configuration.yaml where it starts with mqtt:? I only have discovery: true there. But the warning says "mqtt deprecated in configuration.yaml” - so where do I need to put all my manual configurations to?

Does it mean that following definition will not be valid and I have to manually rewrite hundreds of sensor definitions?

sensor 3:
  platform: mqtt
  unique_id: sensor.test_temperature_2
  name: "ESP8266_Temperature"
  state_topic: "sensor/temperature"
  force_update: true
  qos: 2
  unit_of_measurement: "ºC"

If by rewrite you mean do some copy/pasting, yes. Your sensor becomes:

mqtt:
  sensor:
    - name: "ESP8266_Temperature"
      unique_id: sensor.test_temperature_2
      state_topic: "sensor/temperature"
      force_update: true
      qos: 2
      unit_of_measurement: "ºC"

Does the order matter, or can it be like this?

mqtt:
  sensor:
    - unique_id: sensor.test_temperature_2
      name: "ESP8266_Temperature"
      state_topic: "sensor/temperature"
      force_update: true
      qos: 2
      unit_of_measurement: "ºC"

no bro

but to make YAML cleaner

I did this
in the config file

mqtt:
  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/

what this means is that you can have a folder for each section

and inside that, you can have your Yaml Files

so my MQTT lounge lights are in the file lounge.yaml into the mqtt folder which has a light folder

Thanks. I still do not get this:
with sensor: !include_dir_merge_list mqtt/sensor/ - the yaml file is in folder sensor, but how it is called?

In that sensor yaml file, can there be entries like this?

sensor 3:
  platform: mqtt
  unique_id: sensor.test_temperature_2
  name: "ESP8266_Temperature"
  state_topic: "sensor/temperature"
  force_update: true
  qos: 2
  unit_of_measurement: "ºC"

I am really unhappy about new updates not beeing backward compatible. I think I will just not use new version. I had lot of problems when Python 3 came over Python 2.7, it costs me days of my life…

1 Like

as it the MQTT Domain you dont need the Platform bit

try this

 - unique_id: sensor.test_temperature_2
   name: "ESP8266_Temperature"
   state_topic: "sensor/temperature"
   force_update: true
   qos: 2
   unit_of_measurement: "ºC"

Thanks. So let me summerize it (for others too). Instead all current definitions like this:

sensor 3:
  platform: mqtt
  unique_id: sensor.test_temperature_2
  name: "ESP8266_Temperature"
  state_topic: "sensor/temperature"
  force_update: true
  qos: 2
  unit_of_measurement: "ºC"

I will create single entry in configuration.yaml:

mqtt:
  sensor: !include_dir_merge_list mqtt/sensor/

then in config folder I will create subfolder mqtt and in it the file sensor.yaml and to this file I will copy all definitions like this:

 - unique_id: sensor.test_temperature_2
   name: "ESP8266_Temperature"
   state_topic: "sensor/temperature"
   force_update: true
   qos: 2
   unit_of_measurement: "ºC"

Is that correct? Two things not clear - name of file in mqtt subfolder and why in last example the dash is intended by one space?

1 Like