Mqtt.py log warning "No matching payload found for entity"

I offer another solution to prevent the “No matching payload” message from appearing.

For an MQTT Binary sensor, the default for payload_on is ON and for payload_off it’s OFF (i.e. uppercase). On the other hand, the state of a binary_sensor can either be on or off (i.e. lowercase). Keeping this important distinction in mind, we can use it to construct a value_template that ensures the payload always matches something and never nothing.

This example assumes Data=2C8D0A indicates the door is open and Data=2C8D0E indicates the door is closed. Here’s the important part, if the payload contains neither 2C8D0A or 2C8D0E, it reports the binary_sensor’s current state. In other words, no matter what it receives in the payload, the value_template always reports a valid state.

- platform: mqtt
  name: 'Bathroom Door'
  state_topic: 'tele/RF_Bridge/RESULT'
  value_template: >-
    {% if value_json.RfReceived.Data == '2C8D0A' %}
      {{'ON'}}
    {% elif value_json.RfReceived.Data == '2C8D0E' %}
      {{'OFF'}}
    {% else %}
      {{states('binary_sensor.bathroom_door') | upper}}
    {% endif %}
  device_class: Door

If you have a sensor that does not report an off state then you can compensate by using the off_delay option.

In this example, Data=E5D30E indicates the motion sensor is on but there’s no command available to indicate when the sensor is off. I have set off_delay: 15 so the motion sensor will automatically set itself to off after 15 seconds.

- platform: mqtt
  name: 'Hallway Motion'
  state_topic: 'tele/RF_Bridge/RESULT'
  value_template: >-
    {% if value_json.RfReceived.Data == 'E5D30E' %}
      {{'ON'}}
    {% else %}
      {{states('binary_sensor.hallway_motion') | upper}}
    {% endif %}
  off_delay: 15
  device_class: motion
8 Likes