433MHz door sensors: how to configure binary_sensor mqtt?

Hi, I am trying to configure in HASS some 433Mhz door sensors. They do send two diferent codes for ON and OFF, I do not know how to configure it, like below is wrong

binary_sensor:
    - platform: mqtt
      name:  door sensor
      payload_on: "2885386"
      payload_off: "2885390"
      state_topic: "stat/rf-bridge/RESULT"
      value_template: '{{ value_json.RfCode }}'
      qos: 1

this is what I receive when open and close. Do not uindertstand why I have
stat/Bridge/RESULT
tele/rf-bridge/RESULT
in my Sonoff RF Bridge the topic is rf-bridge

16:13:28 RUL: RFRECEIVED#DATA performs "publish stat/Bridge/RESULT {“RfCode”:"2885390"}"
16:13:28 MQT: stat/Bridge/RESULT = {“RfCode”:"2885390"}
16:13:33 MQT: tele/rf-bridge/RESULT = {"RfReceived":{"Sync":14030,"Low":470,"High":1340,"Data":2885390,"RfKey":"None"}}
16:13:33 RUL: RFRECEIVED#DATA performs "publish stat/Bridge/RESULT {“RfCode”:"2885390"}"
16:13:33 MQT: stat/Bridge/RESULT = {“RfCode”:"2885390"}

Take this with a grain of salt - I am VERY new to Home Assistant… but I think I see the problem.

In your sensor setup you have:

But in your MQTT message, the topic is:

So I believe you need to change your state_topic and replace “rf-bridge” with “Bridge”.
So it should should like this:

Now, whether you should be using the stat or tele topic, I don’t know yet - still learning all this.
Okay, found the Tasmota MQTT explanation - stat is correct for state change… tele is telemetry info - message sent at periodic interval.

I hope this helps!
… and that I am not completely wrong :slight_smile:

  • DeadEnd
1 Like

thanks for taking the time to check … I still do not understand what “Bridge” is, since in my Tasmota configuration its “rf-bridge”.

Anyway I have a PIR sensor which works great and the state-topic is tele/rf-bridge

- platform: mqtt
  state_topic: "tele/rf-bridge/RESULT"
  name: 'PIR Garden East 2'
  value_template: '{{value_json.RfReceived.Data}}'
  payload_on: '15160782'   #Kerui
  off_delay: 5
  device_class: motion
  qos: 1



17:46:14 MQT: tele/rf-bridge/RESULT = {"RfReceived":{"Sync":12530,"Low":430,"High":1210,"Data":15160782,"RfKey":"None"}}
17:46:14 RUL: RFRECEIVED#DATA performs "publish stat/Bridge/RESULT {“RfCode”:"15160782"}"
17:46:14 MQT: stat/Bridge/RESULT = {“RfCode”:"15160782"}
17:46:34 MQT: tele/rf-bridge/RESULT = {"RfReceived":{"Sync":12520,"Low":420,"High":1220,"Data":15160782,"RfKey":"None"}}
17:46:34 RUL: RFRECEIVED#DATA performs "publish stat/Bridge/RESULT {“RfCode”:"15160782"}"
17:46:34 MQT: stat/Bridge/RESULT = {“RfCode”:"15160782"}
17:46:43 MQT: tele/rf-bridge/RESULT = {"RfReceived":{"Sync":12520,"Low":420,"High":1220,"Data":15160782,"RfKey":"None"}}
17:46:43 RUL: RFRECEIVED#DATA performs "publish stat/Bridge/RESULT {“RfCode”:"15160782"}"
17:46:43 MQT: stat/Bridge/RESULT = {“RfCode”:"15160782"}
17:46:52 MQT: tele/rf-bridge/RESULT = {"RfReceived":{"Sync":12520,"Low":420,"High":1220,"Data":15160782,"RfKey":"None"}}
17:46:52 RUL: RFRECEIVED#DATA performs "publish stat/Bridge/RESULT {“RfCode”:"15160782"}"
17:46:52 MQT: stat/Bridge/RESULT = {“RfCode”:"15160782"}
17:46:58 MQT: tele/rf-bridge/RESULT = {"RfReceived":{"Sync":12520,"Low":430,"High":1210,"Data":15160782,"RfKey":"None"}}
17:46:58 RUL: RFRECEIVED#DATA performs "publish stat/Bridge/RESULT {“RfCode”:"15160782"}"
17:46:58 MQT: stat/Bridge/RESULT = {“RfCode”:"15160782"}
17:4

other issue I see that in binary_sensor mqtt the field retain gives error (I have to take it out)

I have a question: Why is RfCode delimited by fancy double-quotes (“ ”) in the JSON message?

16:13:28 RUL: RFRECEIVED#DATA performs "publish stat/Bridge/RESULT {“RfCode”:"2885390"}"

mmhhh when I copIED/pasteD from a website it did it that way (it happened in the past too), but I did change in configuration with proper " (after using it though before correcting the error).

I changed my code as below, but still is not working (binary_sensor.14a_door_sensor does not change state in HASS)

- platform: mqtt
  name: 14a door sensor
  payload_on: "2885386"
  payload_off: "2885390"
  state_topic: "tele/rf-bridge/RESULT"
  value_template: '{{ value_json.RfCode }}'
  device_class: Door
  qos: 1

Try this:

- platform: mqtt
  name: 14a door sensor
  payload_on: "2885386"
  payload_off: "2885390"
  state_topic: "tele/rf-bridge/RESULT"
  value_template: '{{value_json.RfReceived.Data}}'
  device_class: Door
  qos: 1

Also check the small and capital letters in state_topic

For this the state topic is

state_topic: "stat/Bridge/RESULT"

The rest of your configuration looks correct.