Doorbell button state from RF Bridge Tasmota

Hello, I am struggling with making a config code in HA.
I would like to make a sensor which state changes when the doorbell is pressed.
I have a Sonoff RF Bridge flashed with Tasmota and Portisch.
I am able to receive the codes in the Tasmota console
after enetring rfraw177
when doorbell button is pressed:

20:48:29.894 CMD: rfraw 177
20:48:29.901 MQT: stat/RF_bridge/RESULT = {"RfRaw":"ON"}
20:48:29.929 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-10T20:48:29","RfRaw":{"Data":"AAA055"}}
20:48:31.273 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-10T20:48:31","RfRaw":{"Data":"AA B1 03 0140 0352 11DA 28190908190819081818181818181819090909 55"}}
20:48:32.115 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-10T20:48:32","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
20:48:32.956 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-10T20:48:32","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
20:48:33.799 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-10T20:48:33","RfRaw":{"Data":"AA B1 03 0154 033E 125C 28190908190819081818181818181819090909 55"}}
20:48:34.642 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-10T20:48:34","RfRaw":{"Data":"AA B1 03 0154 033E 1248 28190908190819081818181818181819090909 55"}}

How to build the configuration code that will make a sensor that show changes a state when button is pressed and then change the state to off.?

I see instead of a constant payload, there are a number of different payloads like AA B1 03 0140 0352 11DA 28190908190819081818181818181819090909 55, AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55etc beings transmitted for the bell but if these codes are consistently sent every time. You can build a mqtt binary sensor like this.

binary_sensor:
  - platform: mqtt
    name: "Door Bell"
    payload_on: "AA B1 03 0140 0352 11DA 28190908190819081818181818181819090909 55"
    off_delay: 5
    state_topic: "tele/RF_bridge/RESULT"
    value_template: '{{ value_json.RfRaw.Data }}'

Thank you for quick response.
Unfortunately only some part of the code is constant.
This part is this:

xx xx xx xxxx xxxx xxxx 28190908190819081818181818181819090909 55

Can the code be more universal to this type of random code?

I think this would work for you. Please try and let me know

binary_sensor:
  - platform: mqtt
    name: "Door Bell"
    payload_on: "true"
    off_delay: 5
    state_topic: "tele/RF_bridge/RESULT"
    value_template: '{{ '28190908190819081818181818181819090909 55' in  value_json.RfRaw.Data }}'

I don’t think that long number is not constant either. Are you sure?
I think only the first 6 or 8 digits and the last digits are constant but not in between.

This makes it hard to know the state. I’m struggling myself with that problem too.

Unfortunately your code does not work.
To test it I had to change:

value_template: '{{ '28190908190819081818181818181819090909 55' in  value_json.RfRaw.Data }}'

to

value_template: "{{ '28190908190819081818181818181819090909 55' in  value_json.RfRaw.Data }}"

Otherwise the config test fails.
I also tried:

value_template: "{{ '28190908190819081818181818181819090909' in  value_json.RfRaw.Data }}"

but still no changes on doorbell status ;-(

I am sure that the long part of the code is constant.
Look at the result from tasmota console after pressing the doorbell several times:

13:27:29.253 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:27:29","RfRaw":{"Data":"AA B1 03 014A 0352 122A 28190908190819081818181818181819090909 55"}}
13:27:30.096 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:27:30","RfRaw":{"Data":"AA B1 03 0154 0352 125C 28190908190819081818181818181819090909 55"}}
13:27:30.938 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:27:30","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
13:27:31.781 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:27:31","RfRaw":{"Data":"AA B1 03 014A 0352 1252 28190908190819081818181818181819090909 55"}}
13:27:32.624 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:27:32","RfRaw":{"Data":"AA B1 03 014A 0352 1252 28190908190819081818181818181819090909 55"}}
13:27:37.255 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:27:37","RfRaw":{"Data":"AA B1 03 015E 0352 122A 28190908190819081818181818181819090909 55"}}
13:27:38.098 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:27:38","RfRaw":{"Data":"AA B1 03 0140 0348 1252 28190908190819081818181818181819090909 55"}}
13:27:38.941 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:27:38","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
13:27:39.783 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:27:39","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
13:27:40.627 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:27:40","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
13:28:00.537 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:00","RfRaw":{"Data":"AA B1 03 0122 037A 1252 28190908190819081818181818181819090909 55"}}
13:28:01.380 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:01","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
13:28:02.303 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:02","RfRaw":{"Data":"AA B1 03 014A 0352 1252 28190908190819081818181818181819090909 55"}}
13:28:03.066 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:03","RfRaw":{"Data":"AA B1 03 0154 0348 125C 28190908190819081818181818181819090909 55"}}
13:28:03.908 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:03","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
13:28:09.077 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:09","RfRaw":{"Data":"AA B1 03 0122 037A 1252 28190908190819081818181818181819090909 55"}}
13:28:09.924 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:09","RfRaw":{"Data":"AA B1 04 014A 0348 00F0 1252 38190908190819081818181818181819290909 55"}}
13:28:10.000 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:09","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
13:28:10.842 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:10","RfRaw":{"Data":"AA B1 03 0140 0352 1252 28190908190819081818181818181819090909 55"}}
13:28:11.691 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:11","RfRaw":{"Data":"AA B1 03 0140 0352 125C 28190908190819081818181818181819090909 55"}}
13:28:12.370 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:12","RfRaw":{"Data":"AA B1 04 014A 0348 00E6 1252 38192908190819081818181818181819090909 55"}}
13:28:12.447 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:12","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
13:28:17.523 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:17","RfRaw":{"Data":"AA B1 03 0118 037A 1252 28190908190819081818181818181819090909 55"}}
13:28:18.122 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:18","RfRaw":{"Data":"AA B1 04 0168 032A 00FA 1252 38192928192819081818181818181819290909 55"}}
13:28:18.200 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:18","RfRaw":{"Data":"AA B1 03 014A 0348 1252 28190908190819081818181818181819090909 55"}}
13:28:19.046 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:19","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
13:28:19.889 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:19","RfRaw":{"Data":"AA B1 03 014A 033E 125C 28190908190819081818181818181819090909 55"}}
13:28:20.823 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T13:28:20","RfRaw":{"Data":"AA B1 03 014A 0352 1252 28190908190819081818181818181819090909 55"}}

Had some syntax issues but this should work. Please try it.

  - platform: mqtt
    name: "Door Bell"
    payload_on: true
    off_delay: 5
    state_topic: "tele/RF_bridge/RESULT"
    value_template: '{{ "28190908190819081818181818181819090909 55" in  value_json.RfRaw.Data }}'

Sorry my friend, it does not work.

It worked when I tested it with my system but there might be something else. What is the error you are getting or is it that the binary sensor is not triggering ?

Please copy and paste the tasmota logs between ``` so that it appears as a code.

The binary sensor state does not change.

Here is the newest log from tasmota console:

14:17:37.713 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:17:37","RfRaw":{"Data":"AA B1 03 0140 0348 122A 28190908190819081818181818181819090909 55"}}
14:17:38.365 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:17:38","RfRaw":{"Data":"AA B1 03 0154 0348 1252 28190908190819081818181818181819090909 55"}}
14:17:39.207 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:17:39","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
14:17:40.050 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:17:40","RfRaw":{"Data":"AA B1 03 0140 035C 1252 28190908190819081818181818181819090909 55"}}
14:17:40.893 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:17:40","RfRaw":{"Data":"AA B1 03 0154 0348 125C 28190908190819081818181818181819090909 55"}}
14:17:47.176 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:17:47","RfRaw":{"Data":"AA B1 03 0140 0352 125C 28190908190819081818181818181819090909 55"}}
14:17:47.782 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:17:47","RfRaw":{"Data":"AA B1 03 015E 033E 1252 28190908190819081818181818181819090909 55"}}
14:17:48.624 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:17:48","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
14:17:49.468 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:17:49","RfRaw":{"Data":"AA B1 03 0140 0352 1252 28190908190819081818181818181819090909 55"}}
14:17:50.310 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:17:50","RfRaw":{"Data":"AA B1 03 0154 0348 125C 28190908190819081818181818181819090909 55"}}
14:18:06.741 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:18:06","RfRaw":{"Data":"AA B1 03 0118 037A 12C0 28190908190819081818181818181819090909 55"}}
14:18:07.000 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:18:06","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
14:18:07.845 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:18:07","RfRaw":{"Data":"AA B1 04 015E 0348 00FA 125C 38190908190819081818181818181819092909 55"}}
14:18:07.929 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:18:07","RfRaw":{"Data":"AA B1 03 014A 0348 1252 28190908190819081818181818181819090909 55"}}
14:18:08.772 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:18:08","RfRaw":{"Data":"AA B1 03 0140 0352 125C 28190908190819081818181818181819090909 55"}}
14:18:09.617 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:18:09","RfRaw":{"Data":"AA B1 03 014A 0352 1252 28190908190819081818181818181819090909 55"}}

Any idea why the one at 14:18:07.845 is different?

14:18:07.000 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:18:06","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
14:18:07.845 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:18:07","RfRaw":{"Data":"AA B1 04 015E 0348 00FA 125C 38190908190819081818181818181819092909 55"}}
14:18:07.929 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:18:07","RfRaw":{"Data":"AA B1 03 014A 0348 1252 28190908190819081818181818181819090909 55"}}

Its RfRaw.Data is not the same as the others. Do you know what happened at that moment?

AA B1 04 015E 0348 00FA 125C 38190908190819081818181818181819092909 55
\____________  ____________/ ^
             \/              |
          More data.         |
                             |
             This is a 3 as opposed to a 2.

I have no idea why there is a difference in the code. I did the test now and the signal is constant:

14:35:47.897 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:47","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
14:35:48.743 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:48","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
14:35:49.585 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:49","RfRaw":{"Data":"AA B1 03 014A 0352 1252 28190908190819081818181818181819090909 55"}}
14:35:50.429 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:50","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
14:35:54.635 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:54","RfRaw":{"Data":"AA B1 03 014A 0352 1266 28190908190819081818181818181819090909 55"}}
14:35:55.478 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:55","RfRaw":{"Data":"AA B1 03 0154 0348 125C 28190908190819081818181818181819090909 55"}}
14:35:56.321 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:56","RfRaw":{"Data":"AA B1 03 014A 0352 1252 28190908190819081818181818181819090909 55"}}
14:35:57.163 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:57","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
14:35:58.007 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:58","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
14:35:58.841 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:58","RfRaw":{"Data":"AA B1 03 0140 0348 1252 28190908190819081818181818181819090909 55"}}
14:35:59.684 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:35:59","RfRaw":{"Data":"AA B1 03 014A 0352 1252 28190908190819081818181818181819090909 55"}}
14:36:00.526 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:00","RfRaw":{"Data":"AA B1 03 0154 0348 1252 28190908190819081818181818181819090909 55"}}
14:36:01.369 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:01","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
14:36:02.247 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:02","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
14:36:05.920 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:05","RfRaw":{"Data":"AA B1 03 0136 0366 1252 28190908190819081818181818181819090909 55"}}
14:36:06.761 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:06","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
14:36:07.605 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:07","RfRaw":{"Data":"AA B1 03 0154 0348 1252 28190908190819081818181818181819090909 55"}}
14:36:08.448 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:08","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
14:36:09.290 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:09","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
14:36:13.615 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:13","RfRaw":{"Data":"AA B1 03 014A 035C 1252 28190908190819081818181818181819090909 55"}}
14:36:14.458 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:14","RfRaw":{"Data":"AA B1 03 014A 0348 125C 28190908190819081818181818181819090909 55"}}
14:36:15.380 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:15","RfRaw":{"Data":"AA B1 03 0154 0348 1252 28190908190819081818181818181819090909 55"}}
14:36:16.143 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:16","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}
14:36:16.986 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:16","RfRaw":{"Data":"AA B1 03 014A 0352 1248 28190908190819081818181818181819090909 55"}}
14:36:20.968 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:20","RfRaw":{"Data":"AA B1 03 0136 035C 1252 28190908190819081818181818181819090909 55"}}
14:36:21.811 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:21","RfRaw":{"Data":"AA B1 03 0154 0352 1252 28190908190819081818181818181819090909 55"}}
14:36:22.748 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:22","RfRaw":{"Data":"AA B1 03 0140 0352 1252 28190908190819081818181818181819090909 55"}}
14:36:23.497 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:23","RfRaw":{"Data":"AA B1 03 0154 0352 1252 28190908190819081818181818181819090909 55"}}
14:36:24.340 MQT: tele/RF_bridge/RESULT = {"Time":"2021-04-11T14:36:24","RfRaw":{"Data":"AA B1 03 014A 0352 125C 28190908190819081818181818181819090909 55"}}

When you say “test” do you mean you pushed the doorbell button but the payload (specifically RfRaw.Data) in tele/RF_bridge/RESULT never changed?

yes I pressed the doorbell several times

If a button press isn’t being automatically reported in tele/RF_bridge/RESULT then you may need to use a Tasmota Rule to do it. :man_shrugging:

  - platform: mqtt
    name: "Door Bell"
    off_delay: 5
    state_topic: "tele/RF_bridge/RESULT"
    value_template: '{{ value_json.RfRaw.Data.split(" ") [6]}}'
    payload_on: "28190908190819081818181818181819090909"

Does this work for you maybe?

You need to make sure it’s in rfraw 177 mode. You can do it with a rule to make that permanently.

it works!!!
can I change off_delay to 1s ???

Good.
Yes you can change to 1s if you like.

FWIW, for an MQTT Binary Sensor, the default payloads representing on/off states are ON and OFF. Therefore the template only needs to match a few relevant characters and then report the appropriate ON/OFF values.

  - platform: mqtt
    name: Door Bell
    state_topic: tele/RF_bridge/RESULT
    value_template: "{{ 'ON' if ' 281909' in value_json.RfRaw.Data else 'OFF' }}"
    off_delay: 2
1 Like