Help needed with MQTT 2022.6 breaking change

You only need the first -sensor: . Remove the others.
Like:

  sensor:
    - name: "Teckin01 Energia Hoy"
      state_topic: "tele/teckin01/SENSOR"
      value_template: '{{ value_json["ENERGY"]["Today"] }}'
      unit_of_measurement: "kWh"
    - name: "Teckin01 Energia Ayer"
      state_topic: "tele/teckin01/SENSOR"
      value_template: '{{ value_json["ENERGY"]["Yesterday"] }}'
      unit_of_measurement: "kWh"
    - name: "Teckin01 Energia Total"
      state_topic: "tele/teckin01/SENSOR"
      value_template: '{{ value_json["ENERGY"]["Total"] }}'
      unit_of_measurement: "kWh"
1 Like

Thank You.

EDIT: I was so close, butā€¦ :slight_smile:

OK, another one with problems converting to the new syntax.

My manual config is split across a number of ā€œthemeā€-based yaml files in packages
Two of them have mqtt configured sensors. I am seeing the same problem in both. One will serve as an example.

mqtt:
  sensor:
    # Temperatures
    - name: "Shed Temperature"
      state_topic: "emon/emonth4/temperature"
      unit_of_measurement: "Ā°C"
      device_class: temperature
      value_template: "{{ value | float | round(1) }}"
      expire_after: 300

    - name: "Bedroom1 Temperature"
      state_topic: "emon/emonth5/temperature"
      unit_of_measurement: "Ā°C"
      device_class: temperature
      value_template: "{{ value | float | round(1) }}"
      expire_after: 300

I get no errors when I run ha core check, but when HA restarts I see errors of the form:

The version platform for the sensor integration does not support platform setup. Please remove it from your config.
17:05:59 ā€“ (ERROR) Sensor - message first occurred at 17:05:59 and shows up 2 times
Unable to prepare setup for platform mqtt.switch: Unable to set up component.
17:05:57 ā€“ (ERROR) setup.py
Setup failed for mqtt: Invalid config.
17:05:57 ā€“ (ERROR) setup.py
Invalid config for [mqtt]: [sensor] is an invalid option for [mqtt]. Check: mqtt->mqtt->sensor. (See ?, line ?). Please check the docs at https://www.home-assistant.io/integrations/mqtt
17:05:57 ā€“ (ERROR) config.py

and

2022-06-02 17:05:57 ERROR (MainThread) [homeassistant.config] Invalid config for [mqtt]: [sensor] is an invalid option for [mqtt]. Check: mqtt->mqtt->sensor. (See ?, line ?). Please check the docs at https://www.home-assistant.io/integrations/mqtt
2022-06-02 17:05:57 ERROR (MainThread) [homeassistant.setup] Setup failed for mqtt: Invalid config.

Looks like you have it setup as

mqtt:
  mqtt:
    sensor:

Thanks. I saw that, but I canā€™t see where that first mqtt: is.
The Mosquitto integration is configured through the GUI - thereā€™s no reference to it in configuration.yaml. All the real config takes in places in packages. The relevant one starts:

# Batteries.yaml
# Stuff to report battery state and raise an elert of a battery state gets low.
#
# Customisations to facilitate selecting the filtered battery levels
homeassistant:
  customize:
    sensor.filtered_shed_battery:
      type: "filtered"
    sensor.filtered_bedroom1_battery:
      type: "filtered"
    sensor.filtered_bedroom2_battery:
      type: "filtered"
    sensor.filtered_livingroom_battery:
      type: "filtered"
    sensor.filtered_shack_battery:
      type: "filtered"

# emonCMS battery sensors
mqtt:
  sensor:
    - name: "Shed Battery"
      state_topic: "emon/emonth4/battery"
      unit_of_measurement: "V"
      device_class: battery
      value_template: "{{ value | float | round(1) }}"
      expire_after: 300

I see no place where an extra level got added in. However, I do see that VSC (Iā€™m using the VSC editor addon) does put a blue hash highlight on that whole section.

OK, panic over. I wasnā€™t running 2022.6.0 as I thought. Could have sworn Iā€™d upgraded before I started tidying up.

Not sure about the terminology, but it looks like itā€™s not possible to have multiple instances of the mqtt: configuration key, each with a unique secondary identifier, the way you can with platform keys like binary_sensor, sensor, etc. This would be helpful (to me at least) to keep the YAML more manageable.

For exampleā€¦

# this validates but has been deprecated

binary_sensor basement:
  - platform: mqtt
    name: Basement Motion 1
  - platform: mqtt
    name: Basement Motion 2

binary_sensor bedrooms:
  - platform: mqtt
    name: Hall Motion

# but this doesn't validate

mqtt basement:
  binary_sensor:
    - name: Basement Motion 1
    - name: Basement Motion 2

mqtt bedrooms:
  binary_sensor:
    - name: Hall Motion

# and neither does this

mqtt:
  binary_sensor basement:
    - name: Basement Motion 1
    - name: Basement Motion 2
  binary_sensor bedrooms:
    - name: Hall Motion

Hi,

I have hundreds of sensors and switches with MQTT. Is there a tool available which is changing the config in Bulk to the new concep?

Br,
Johannes

2 Likes

I have rewritten syntax in accordance to recent changes, but now when I check config before rebooting HA I get:

Invalid config for [mqtt]: [entity_id] is an invalid option for [mqtt]. Check: mqtt->mqtt->sensor->44->entity_id. (See /config/configuration.yaml, line 81).

Hereā€™s the look of My config.yaml, line 81 corresponds to MQTT:

mqtt:
  broker: 192.168.0.3
  port: 1883
  discovery: true
  keepalive: 60
  username: user
  password: pass
  sensor:
    - name: "VoltageV1"
      state_topic: "1728053740.V1"
      unit_of_measurement: "Š’"
      value_template: "{{ value | round(0) }}"
    - name: "VoltageV2"
      state_topic: "1728053740.V2"
      unit_of_measurement: "Š’"
      value_template: "{{ value | round(0) }}"

What is wrong?

Did you ever figure this out?

Iā€™m running into the same issueā€¦

If youā€™re still experiencing this issue, take a look at this solution:
https://community.home-assistant.io/t/problem-with-new-mqtt-format/428745/19?u=ha_noobie
Which says to format the MQTT section of the ā€œconfiguration.yamlā€ like so:

sensor:
  - name: "Outside Temperature"  
    state_topic: "building/dhjm/eobs/external/wx"
    unit_of_measurement: 'Ā°C'
    value_template: "{{ value_json['obs']['temperature'] }}"`

It resolved my issue.