MQTT breaking changes RC 2022.6

mqtt:
  - switch:
      - name: "steve_Heat"
        command_topic: "cmnd/steve_heat/power"
        state_topic: "stat/steve_heat/POWER"
        qos: 1
        payload_on: "ON"
        payload_off: "OFF"
        retain: false

I didn’t notice that my earlier question was munged by the forum software, so I’ll ask again in code tags.

Also your suggested fix produced this error:

The system cannot restart because the configuration is not valid: Error loading /config/configuration.yaml: while parsing a block mapping in "/config/configuration.yaml", line 262, column 7 expected <block end>, but found '<block mapping start>' in "/config/configuration.yaml", line 263, column 8

Is there a codex or universal translator to help understand, just what is a <block end> and a '<block mapping start>' ?

Try this way. I have a similar switch setup in a package.

mqtt:
  switch:
    - name: "steve_Heat"
      command_topic: "cmnd/steve_heat/power"
      state_topic: "stat/steve_heat/POWER"
      qos: 1
      payload_on: "ON"
      payload_off: "OFF"
      retain: false
mqtt:
  switch:
  - name: "steve_Heat"

Thanks guys. I knew it had to be in the indenting. FWIW, the formatting in the “breaking-changes” is also indented wrong.

Works now.

But, for future errors, and I will absolutely have more.

Should I be looking for a YAML 101 guide on the web?

The indentation and formatting in breaking-changes is correct. The indentation in your original question was fine, your issue was the dash not having a space between your field.

Yaml only cares about relative indentation. These yaml examples are functionally the same:

mqtt:
 sensor:
 - name: ...
mqtt:
  sensor:
                            - name: ...
mqtt:
                         sensor:
                         - name: ...

This is what you did wrong:

1 Like

Thanks. That explains a lot.

Thanks for this @petro Got all 98 of mine switched over with this process.

Hi there,

Please could someone assist me with my mqtt re-configuration. I have my mqtt files saved in one folder like this:

/config/packages/systems/ustou/ustou_lights.yaml

My old configuration was like this:

# Devices
light:
  - platform: mqtt
    name: "Entrance Hall Light"   
    command_topic: "cmnd/halllight/POWER"
    state_topic: "stat/halllight/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
    unique_id: entrance hall light
    
  - platform: mqtt
    name: "Dining Floor Light"
    command_topic: "cmnd/floorlamp/POWER"
    state_topic: "stat/floorlamp/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
    unique_id: dining floor light
    
  - platform: mqtt
    name: "Telephone Table Lamp"
    command_topic: "cmnd/table3/POWER"
    state_topic: "stat/table3/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
    unique_id: telephone table lamp

I have 3 .yaml files; one for sensors, one for lights and one for switches

Now after changing to RC 2022.6 I changed the above to this:

# Devices
mqtt:
  light:
    - name: "Entrance Hall Light"    
      command_topic: "cmnd/halllight/POWER"
      state_topic: "stat/halllight/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      retain: true
      unique_id: entrance hall light
    
    - name: "Dining Floor Light"
      command_topic: "cmnd/floorlamp/POWER"
      state_topic: "stat/floorlamp/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      retain: true
      unique_id: dining floor light
    
    - name: "Telephone Table Lamp"
      command_topic: "cmnd/table3/POWER"
      state_topic: "stat/table3/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      retain: true
      unique_id: telephone table lamp
    

Now after restart all lights are “unavailable” but switches and climate sensors are working…?

I changed my switches from this:

# Power Outlets
switch:
  - platform: mqtt
    name: "Mums Blanket"
    command_topic: "cmnd/mumblanket/POWER"
    state_topic: "stat/mumblanket/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
    
  - platform: mqtt
    name: "Dads Blanket"
    command_topic: "cmnd/dadblanket/POWER"
    state_topic: "stat/dadblanket/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
       
  - platform: mqtt
    name: "Lili Blanket"
    command_topic: "cmnd/liliblanket/POWER"
    state_topic: "stat/liliblanket/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

To this and they are still present and working in my dashboard:

# Power Outlets
mqtt:
  switch:
   -  name: "Mums Blanket"
      command_topic: "cmnd/mumblanket/POWER"
      state_topic: "stat/mumblanket/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      retain: true
    
   -  name: "Dads Blanket"
      command_topic: "cmnd/dadblanket/POWER"
      state_topic: "stat/dadblanket/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      retain: true
       
   -  name: "Lili Blanket"
      command_topic: "cmnd/liliblanket/POWER"
      state_topic: "stat/liliblanket/POWER"
      payload_on: "ON"
      payload_off: "OFF"
      retain: true
        

I made the same changes made to my sensors and switches, as I did to my lights. So I’m confused as to why the lights no longer work.

Any advice would be greatfully received.

I’m also having issues with the new changes. I’m getting the error “missing property platform” in sensor.yaml when I use a separate mqtt sensor file. How did you solve this?

Configuration.yaml

mqtt:
  broker: #hidden
  port: 1883
  username: #hidden
  password: #hidden
  sensor: !include sensor.yaml

sensor.yaml

mqtt:
  sensor:
  - name: "mqtt_temp"
    state_topic: "l/t_1/sensor/t_1/state"
    unit_of_measurement: '°C'
    payload_available: "online"
    payload_not_available: "offline"
    availability_topic : 'l/tyl_1'
    state_class: measurement

It looks like it should work for light as long as you are using packages. If you aren’t using packages and you have a single configuration, then both light and switch need to be in 1 mqtt section.

It does not go in sensor.yaml or the sensor section. It goes in a new MQTT section. There are multiple ways to specify this, and it’s covered earlier in the thread.

Thanks. I’ve looked at those and structured my code accordingly. For some reason, the error actually went away. However, the sensor doesn’t show up as an entity when I search for it.

Based on your previous response, it seems like you still have the sensor in the wrong section. Post your configuration.

Hi. I found the problem. I was including “mqtt” and “sensor” below, which is redundant because it’s already specified in configuration.yaml:

mqtt:
  sensor:
  - name

The solution was to just write:

  - name: "mqtt_temp"

I have the following sensor and I’m getting errors and trying to figure out how to use the Icon_template, as it’s not allowed in the mqtt.yaml.

- platform: mqtt
  state_topic: "bbq/iGrill/probe1"
  name: "Probe 1"
  qos: 0
  unit_of_measurement: "°"
  icon: mdi:thermometer
- platform: template
  sensors:
    probe1:
      friendly_name: "iGrill Probe 1"
      unit_of_measurement: '°'
      icon_template: >-
        {% if states.sensor.probe_1.state == 'unknown' %}
          mdi:cancel
        {% else %}
          mdi:thermometer
        {% endif %}
      #value_template: "{{ states('sensor.probe_1')|round }}"
      value_template: "{% if is_state('sensor.probe_1', 'unknown') -%}
     {{ 'off' }}
   {%- else -%}
     {{ states('sensor.probe_1')|round }}
   {%- endif %}"

Any suggestions?

What’s your configuration.yaml? We cant help you because we don’t know how or if this random mqtt.yaml file is included in your actual config.

No, he’ll have to switch to the new template style for that.

Keep platform: template and below in sensor.yaml. Only move the single mqtt sensor.

Example for those who have a separate yaml file …

configuration.yaml entry
mqtt:
discovery: true
broker: 192.168.1.6
binary_sensor: !include mqtt_binary_sensor.yaml
climate: !include mqtt_climate.yaml
switch: !include mqtt_switch.yaml
sensor: !include mqtt_sensor.yaml

Example in mqtt_binary_sensor.yaml …

  - name: "Carport Motion"
    device_class: motion
    state_topic: "mqtt/cp/master"
    payload_on: "Mo_1"
    payload_off: "Mo_0"
    off_delay: 10
    qos: 0