MQTT breaking changes RC 2022.6

Hello All,

please can someone advise how will this translate to new format?

  • platform: mqtt
    name: “Garage Motion”
    device_class: motion
    state_topic: “blueiris/garagehd”
    payload_on: “on”
    off_delay: 30

a precision, configuration check is green, but sensor is shown unavailable/Unknown in the dashboards

Just because your configuration is free from (so to speak) grammatical errors the check for validity does not say your code will be working. (Like you could be waiting for a state “on” but the entity returns “true” instead - that would never be covered by the config-check. It’s just a syntax check, not more.

You aren’t showing enough of the working YAML, and you aren’t using code tags.
I have never used a cover device, and this is just a guess that isn’t likely to work. And I am assuming that it’s a switch (the missing part of your YAML).

mqtt:  
  switch:
    - name: "Garage Motion"
      state_topic: "blueiris/garagehd"
      qos: 1
      payload_on: "on"
      off_delay: 30
1 Like

It’s likely a binary_sensor being a motion sensor.

mqtt:  
  binary_sensor:
    - name: "Garage Motion"
      state_topic: "blueiris/garagehd"
      qos: 1
      payload_on: "on"
      off_delay: 30
1 Like

I already had everything split out and really didn’t want to combine it again, so I did this…

configuration.yaml
---
mqtt:
  binary_sensor: !include_dir_merge_list mqtt/binary_sensor/
  button: !include_dir_merge_list mqtt/button/
  cover: !include_dir_merge_list mqtt/cover/
  fan: !include_dir_merge_list mqtt/fan/
  light: !include_dir_merge_list mqtt/light/
  lock: !include_dir_merge_list mqtt/lock/
  sensor: !include_dir_merge_list mqtt/sensor/
  switch: !include_dir_merge_list mqtt/switch/

Then tweaked the top of the files to remove platform, dropped the files into their folders where they fit from the prior integrations, and done.

I probably will adjust things with friendly names now that I can and make it all look the same, clean it up, but it’s working again and no broken entities or required name changes.

File Structure…

4 Likes

Do any of you know what is working equivalent of:

light: !include_dir_merge_list cfg/lights/

with contents:

- platform: mqtt
  name: "Kinkiet Hall"
  command_topic: milight/0x8164/rgb_cct/3
  state_topic: milight/states/0x8164/rgb_cct/3
  schema: json
  color_temp: true
  rgb: true
  brightness: true

with RGB colors, color brightness and white color temp?
I really can’t make it working under new format :frowning:

Look at the post directly above yours. You have to move that file to a new driectory and remove - platform mqtt, but keep the -, so put it on the next line.

1 Like

yes, check MQTT Light - Home Assistant which clearly states the hierarchy.

# Example configuration.yaml entry
mqtt:
  light:
    - command_topic: "office/rgb1/light/switch"

first 2 lines of these are already in your configuration.yaml with the include, so do as Petro states and start with the 3d line

No, I did it with all switches, sensors and so on and it works.
With lights it’s deferent, as now it refuses to accept combination of color_temp, rgb, brightness.

thats probably because you dont use the correct keys (configuration variables). check the section below what I posted, and see there’s a _topic behind most of these

edit
see MQTT Light - Home Assistant for the docs on what Petro says below…

change

to

  supported_color_modes:
  - rgb

Thanks for sharing this, I learned something: I didn’t know about !include_dir_merge_list.

I ended up using a separate file for each list of binary_sensor, sensor, etc. Then I created a single mqtt.yaml file that includes those files. I include that mqtt.yaml in configuration.yaml. So: more layers, maybe too much – will see the next time I have to add more MQTT devices. My mqtt.yaml looks this…

binary_sensor: !include mqtt_binary_sensor.yaml 
sensor: !include mqtt_sensor.yaml
device_tracker: !include mqtt_device_tracker.yaml
1 Like

You’re literally describing packages. A package is a way of grouping a bunch of different things that come together to make something else (a “unit” as you call it). Just use those.

2 Likes

Does anyone know if the format has also changed for MQTT triggers? I’ve tried looking all over the place and the documentation shows the method I am still using. I’m currently using this in my templates.yaml for some Plex automations:

- trigger:
    - platform: mqtt
      topic: "plex/update"
  sensor:
    - name: "Webhook Plex State"
      state: >
        {% if (trigger.payload_json.event == 'media.play') %}
          playing
        {% elif (trigger.payload_json.event == 'media.pause') %}
          paused
        {% elif (trigger.payload_json.event == 'media.resume') %}
          resumed
        {% elif (trigger.payload_json.event == 'media.stop') %}
          stopped
        {% elif (trigger.payload_json.event == 'media.rate') %}
          rated
        {% elif (trigger.payload_json.event == 'media.scrobble') %}
          90% viewed
        {% endif %}

    - name: "Webhook Plex Player"
      state: "{{ trigger.payload_json.Player.title }}"

    - name: "Webhook Plex Media Type"
      state: "{{ trigger.payload_json.Metadata.type }}"

    - name: "Webhook Plex Media Title"
      state: "{{ trigger.payload_json.Metadata.title }}"

    - name: "Webhook Plex Media Length"
      state: "{{ ((trigger.payload_json.Metadata.duration|float)/60000) }}"

In the documentation those first 3 lines are the same format. I was wondering if this would also change to:

- mqtt:
    - trigger:
      topic: "plex/update"

or something similar.

That’s the template integration, not mqtt. So no changes.

Thanks for the information. This has been bugging me for quite some time and was getting nowhere finding the answer.

I’m a simple user that have a very small knowledge about yaml files, coding etc. - I’m expanding my HA setup following the “more configuration from the UI” trend.
I got this error from the check configuration addon, but only when trying to install 2022.07 - no errors before:
WARNING:homeassistant.components.mqtt.mixins:Manually configured MQTT sensor(s) found under platform key 'sensor', please move to the mqtt integration key, see https://www.home-assistant.io/integrations/sensor.mqtt/#new_format

I haven’t any “platform: mqtt” in my configuration.yaml and I don’t know if I also have to look elsewhere.

Should I have to look in hacs custom component? In packages dir? I have only a few packages (smart irrigation and zigbee2mqtt), should I check and if needed, modify them?

No

I was going to say yes but then you called zigbee2mqtt a package. Do you actually mean packages or do you really mean addons? If you mean addons then no, those have nothing to do with this. If you actually mean packages then yes you should look at the config of those packages.

What you’re looking for is this:

  1. Somewhere in your configuration.yaml file it should have sensor:
  2. Under that should be something with platform: mqtt.
    • Note this may be in a different file if you have something like sensor: !include sensors.yaml in your configuration.yaml. Then look in that file instead
  3. This is the deprecated format. Follow the documentation and the guidance in this thread to move those entries out from being under sensor: and to being under mqtt: in your configuration.yaml

If you actually did mean packages above then similar logic applies there. Look in each of your packages and find platform: mqtt under sensor: and refactor in the same way. Or ask the package author for an update if you copied it from the forum or something.

1 Like

Thank you for your reply.
I just waited, and with 2022.07.3, the error is gone so I am not sure if actually there were a platform:mqtt somewhere.