Rf bridge/tasmota MQTT button not working as binary sensor

HI all,
This is going to be a mouthful.
I have an SOS button connected to a sonoff RF bridge connected to mqtt/home assistant.

When I use config the UI automation, I can get it to work, though when I try to make it a binary sensor, there are no errors, but doesnt work and nothing comes up in for logs, and have tried many different variations of config though it does display as a binary sensor. I need it as a binary sensor to I can embed it in the the double click blueprint.

binary_sensor:
  - platform: mqtt
    name: "sosbutton"
    state_topic: "tele/sonoff_rf/RESULT"
    payload_on: "048058"

Whether single click or double click, if is not showing in my mqtt logs but does show in the tasmota console.

09:54:24.282 MQT: tele/sonoff_rf/RESULT = {"Time":"2021-06-15T09:54:24","RfReceived":{"Sync":9760,"Low":370,"High":960,"Data":"048058","RfKey":"None"}}

I have been racking my brain for over 2 weeks… PLEASE HELP :slight_smile:

You’re asking it to look for “048058”, but that’s not what’s sent: a JSON dictionary is sent instead. You need to add a value_template that processes the incoming JSON to provide the string you’re looking for (docs). Like this:

binary_sensor:
  - platform: mqtt
    name: "sosbutton"
    state_topic: "tele/sonoff_rf/RESULT"
    value_template: "{{ value_json['RfReceived']['Data'] }}"
    payload_on: "048058"

Of course, this will only ever turn on without a payload_off

If there is no off message use the off_delay configuration option. https://www.home-assistant.io/integrations/binary_sensor.mqtt/#off_delay