MQTT switch and sensor dont work after 2022.9 upgrade

After I upgraded to 2022.9, I saw notification to change mqtt switch and sensor config.
I followed up documentation examples, but after upgrade MQTT sensor and
switches have stopped working
After I’ve changed back to “OLD” configuration, switches and sensors came back.
Still using 2022.9
Here is example of old config:

  • platform: mqtt
    unique_id: lr_ac
    name: “Lisa_Room_AC”
    command_topic: “broker/ac4”
    payload_on: “Y1”
    payload_off: “OFF”
    state_on: “ON”
    state_off: “OFF”

Here is example of “NEW” config:
- command_topic: “broker/ac4”
unique_id: lr_ac
name: “Lisa_Room_AC”
payload_on: “Y1”
payload_off: “OFF”
state_on: “ON”
state_off: “OFF”

I have found that when I use “NEW” config - MQTT messages just are not transmitted.
With “OLD” config I see messages go out with no issues.
I am running HA in Docker Containers

Any suggestions?
Thank you,

Very hard to tell when you don’t format your code. Please read How to help us help you - or How to ask a good question

I have this same issue. After 2022.9 upgrade, MQTT broker integrations are broken. I had many mqtt sensors that just stopped showing up now.

Example of one of my broken sensors.

`#MQTT Weewx monitor

- platform: mqtt

  name: "wx-Barometer"

  state_topic: "weather/barometer_inHg"

  unit_of_measurement: "Hg"

Looks like the old style of mqtt config.

Please switch to the new style, as we have been warned about since 2022.6


    - name: "wx-Barometer"
      state_topic: "weather/barometer_inHg"
      unit_of_measurement: "inHg"
      unique_id: wx0ec2f07076f0414e9124659bf8ca4f31 #since you might as well add unique id's while you are moving to the proper format
      device_class: pressure
      state_class: measurement
    - name: next sensor etc

Hi , all,
I think I had some sort of formatting issue. I have re-formatted mqtt sensor config as in example above and all sensors came back online!
Thank you.

1 Like

I also was running into a formatting issue. Thanks! fixed now.

Also not able to setup the configuration.ymal to the new format. Missing example of how to use both MQTT switch and sensor in the configuration.ymal.
I got a error at the sensor



  name: "stue XX"

  command_topic: "mytopic/stue_XX"

  payload_on: 1

  payload_off: 0


- name: "sensor_1"   (her i got the error " expected <block end>, but found '?'")

  state_topic: "mytopic/sensor_1"

  unit_of_measurement: "°C"
     - name: WHR_intake
       state_topic: "testxcvb/WHR"
       value_template: "{{ value_json.intake }}"
       device_class: temperature
       unit_of_measurement: °C

     - name: next_sensor
       etc etc

      - name: if_you_have_switch

I ran into problem when changing my platform: mqtt over to new format, that even tho all idents and stuff was correct, my switch did not appear and also gave no errors and development tools checked yaml and was happy with everything.

Turned out, that i had mqtt defined lower for other things before (sensors) and making new mqtt: to root, did not produce any errors but just got ignored.
Moved my switched to previously defined mqtt root sector and all worked again.