Your manually configured MQTT sensor(s) needs attention

I see this but what exactly am I looking for?
image
Is this considered old and needs to be fixed?

sensor:
- platform: mqtt
    name: "OpenEVSE Manual Override"
    state_topic: !secret OPENEVSE_T_OVERRIDE
    value_template: >-
      {% if value == '1' %}
        On
      {% else %} 
        Off
      {% endif %}

If yes then to what?

Click on “see the documentation, for more information” in the screen you included in the post and you will see the new requested format…

1 Like

The only change I can see is that “platform:mqtt” is deleted and the sensor now comes under “mqtt:”
Am I right?

Example from my own converted mqtt sensors to the new format.

Put name on top first and add - before it:

mqtt:
  sensor:
    - name: "Ventilation Supply Temperature"
      unique_id: "ventilation/supply_temperature"
      state_topic: "ventilation/supply_temperature"
      unit_of_measurement: "°C"
      value_template: "{{ value }}"
    - name: "Ventilation Output Temperature"
      unique_id: "ventilation/output_temperature"
      state_topic: "ventilation/output_temperature"
      unit_of_measurement: "°C"
      value_template: "{{ value }}"
3 Likes

I was puzzled too, but is quite clear in hindsight
change it to:

mqtt:
     sensor:
         name: "OpenEVSE Manual Override"
         state_topic: !secret OPENEVSE_T_OVERRIDE
         value_template: >-
         {% if value == '1' %}
           On
         {% else %} 
           Off
         {% endif %}
1 Like

How can I find the entity to modify? I have hundreds of them, I have modified many of them but maybe I can’t find some, the log does not tell me which one to correct, how can I solve?

Yes it will take some time but just do a search for mqtt through all your yaml files.

I am trying to figure out how to get my (test) switch into the new format , but whatever format i try the configuration is not valid.

switch:
  - platform: template
    switches:
      wohnzimmer:
        friendly_name: "Wohnzimmer"
        turn_on:
          service: script.wohnzimmer_an
        turn_off:
          service: script.wohnzimmer_aus
  - platform: mqtt
    name: "test-lader-dummy"
    command_topic: "home/switch/653/power"
    state_topic: "home/switch/653/state"
    payload_on: "On"
    payload_off: "Off"
    qos: 1
    retain: true

mqtt:
  broker: 192.168.1.5
  port: 1883
  discovery: true

Also it complains about my external mqtt server , it seems to be deprecated

The template switch stays like that but you need to chnage your mqtt one like that :

mqtt:
  switch:
    - name: "test-lader-dummy"
      command_topic: "home/switch/653/power"
      state_topic: "home/switch/653/state"
      payload_on: "On"
      payload_off: "Off"
      qos: 1
      retain: true

It actually says that it has imported the MQTT server configuration in to Home Assistant and it can now be removed from your configuration.yaml file.

In automations does this also need to be updated or not?

trigger:
      platform: mqtt
      topic: !secret OPENEVSE_T_ISL

I literally used the notepad replace function. It may not be “ideal” but everything is working great. That said I keep my configuration segmented into separate files. That made things easy.

EDIT: I further segmented during the process by creating an MQTT folder.

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
notify: !include notify.yaml
switch: !include switch.yaml
sensor: !include sensor.yaml
mqtt:
  binary_sensor: !include mqtt/binary_sensors.yaml
  sensor: !include mqtt/sensors.yaml
  switch: !include mqtt/switches.yaml
6 Likes

If what you posted is not located in configuration.yaml (it appears to be in a separate file) then remove the first line containing mqtt: from the file.

1 Like

I had a -platform: template in there which was causing the issue, thought it was commented out :slight_smile:

1 Like

Hi,
Please help me because it is not clear for me:
i have a file !switches.yaml

- platform: mqtt
  name: "Tasmota Plug1"
  state_topic: "stat/tasmota1/RESULT"  
  value_template: "{{ value_json.POWER }}"
  command_topic: "cmnd/tasmota1/POWER"
  payload_on: "ON"
  payload_off: "OFF"

  qos: 1
  retain: false

and

!sensors.yaml

- platform: "mqtt"
  state_topic: "zigbee2mqtt/0x****"
  availability_topic: "zigbee2mqtt/bridge/state"
  value_template: "{{ value_json.temperature }}"
  unit_of_measurement: "°C"
  device_class: "temperature"

What should I change in those files?

Thank you!

OK, solve it:

  1. in configuration.yaml I added
mqtt:
  switch: !include mqtt/zswitches.yaml
  sensor: !include mqtt/zsensors.yaml
  1. I created files zswitches.yaml and zsensors.yaml in a new mqtt folder
  2. I removed all the lines that were under senors.yaml and switches.yaml (the initial one, from root), all the entries related to platform mqtt and I added to new files (starting with z, in mqtt folder).
  3. I changed each entry lihe this:
- platform: mqtt
 name: "Tasmota Plug1"
 state_topic: "stat/tasmota1/RESULT"  
 value_template: "{{ value_json.POWER }}"
 command_topic: "cmnd/tasmota1/POWER"
 payload_on: "ON"
 payload_off: "OFF"

to


- name: "Tasmota Plug1"
  state_topic: "stat/tasmota1/RESULT"  
  value_template: "{{ value_json.POWER }}"
  command_topic: "cmnd/tasmota1/POWER"
  payload_on: "ON"
  payload_off: "OFF"

I hope that this will help someone!

5 Likes

I moved all my mqtt-related sensors and binary_sensors to the new mqtt.yaml.

However, I still have Date & Time related sensors in my sensor.yaml. Will this cause problems when devices looking for a sensor and get confused by where to find the sensor?

Could anyone be so kind as to help me modify these two to work with the new format? It’s been a horrendous day and I’d like to get this off my ‘todo’ list!

  • platform: mqtt
    name: ‘Toilet Motion’
    state_topic: ‘tele/tasmota_8266F7/RESULT’
    value_template: >-
    {% if value_json.RfReceived.Data == ‘D49B1E’ %}
    {{‘ON’}}
    {% else %}
    {{states(‘binary_sensor.toilet_motion’) | upper}}
    {% endif %}
    off_delay: 15
    device_class: motion

  • platform: mqtt
    state_topic: “tele/tasmota_8266F7/RESULT”
    value_template: ‘{{value_json.RfReceived.Data}}’
    payload_on: ‘8CA0B1’
    payload_off: ‘8CA0B1’
    name: “R1_Button_A”
    off_delay: 1

mqtt:
  binary_sensor:
    - name: 'Toilet Motion'
      state_topic: 'tele/tasmota_8266F7/RESULT'
      value_template: >-
        {% if value_json.RfReceived.Data == 'D49B1E' %}
          {{'ON'}}
        {% else %}
          {{states('binary_sensor.toilet_motion') | upper}}
        {% endif %}
      off_delay: 15
      device_class: motion
      unique_id: mqtt-a979e8dadc7a49f295604f6342ad50b9

    - name: "R1_Button_A"
      state_topic: "tele/tasmota_8266F7/RESULT"
      value_template: '{{value_json.RfReceived.Data}}'
      payload_on: '8CA0B1'
      payload_off: '8CA0B1'
      off_delay: 1
      unique_id: mqtt-176ae5ad468747aaa24665c3dc530083

That’s the best I can do because you didn’t use the code button in your post.
I’m not entirely sure about that second sensor - because the payload for on and off are the same, I think you might want to remove payload_off: because that’s what off_delay: is doing.

1 Like

Hey Andrew,

Thanks so much for helping me out. When I read through this thread I figured this was the way forward but wasn’t sure if it would work for me due to mine looking slightly different to anyone else’s.

So, to save a long post I didn’t list all of the sensors as they are all similar. I have a remote control with 4 buttons on, two are on’s and two are off’s (for the kids to turn some lights on and off, I was finding that if they use the same button for both on&off it was getting confusing so one is only on, the other is only off).

This code is in /config/includes/binarysensor.yaml - will it be fine for me to use the heading mqtt: in this (if it could exist in other yaml files which will probably cause a conflict, right?)

The less headachey way of doing it - is to have all your MQTT stuff in it’s own files - then stick this in your configuration.yaml:

mqtt:
  sensor: !include includes/mqttsensor.yaml
  binary_sensor: !include includes/mqttbinarysensor.yaml
  switch: !include includes/mqttswitch.yaml

Inside includes/mqttbinarysensor.yaml - your file will look like this:

    - name: 'Toilet Motion'
      state_topic: 'tele/tasmota_8266F7/RESULT'
      value_template: >-
        {% if value_json.RfReceived.Data == 'D49B1E' %}
          {{'ON'}}
        {% else %}
          {{states('binary_sensor.toilet_motion') | upper}}
        {% endif %}
      off_delay: 15
      device_class: motion
      unique_id: mqtt-a979e8dadc7a49f295604f6342ad50b9

    - name: "R1_Button_A"
      state_topic: "tele/tasmota_8266F7/RESULT"
      value_template: '{{value_json.RfReceived.Data}}'
      payload_on: '8CA0B1'
      payload_off: '8CA0B1'
      off_delay: 1
      unique_id: mqtt-176ae5ad468747aaa24665c3dc530083

basically exactly as I posted, but just with the mqtt: and binary_sensor: lines removed.