MQTT doesn’t work like that.
the
topic
sends the code
Topics never send anything. Payloads are published to topics. Even if a payload consists of an empty string (NULL value) it can still be published to a topic.
In addition, your code is literally contradicting the statement “You do not need any payload
”
action:
- service: mqtt.publish
data:
topic: cmnd/RFBridge_Home/RfKey4
payload: " " # <---- publishing a payload
If you have any other RF sensors that will report their state, the configuration for the binary_sensor will also receive their payloads and cause Home Assistant to produce warning messages (“No matching payload for entity …”).
The reason is because the binary_sensor’s configuration only looks for two matches: 33810A
and 33810E
. If it receives any other payload, it can’t match it to anything and you’ll get a warning message.
Here’s how to prevent it. In this version, the value_template
always report a valid state even if it has no match for the received payload.
- platform: mqtt
name: 'Front Door'
state_topic: 'tele/RF_Bridge/RESULT'
value_template: >-
{% if value_json.RfReceived.Data == '33810A' %}
{{'ON'}}
{% elif value_json.RfReceived.Data == '33810E' %}
{{'OFF'}}
{% else %}
{{states('binary_sensor.front_door') | upper}}
{% endif %}
device_class: door
qos: 1
For more information:
Sonoff RF Bridge. Strategies for receiving data