Sonoff RF Bridge with ESPHOME?

Hi,

I have Sonoff RF-bridge running with ESP Home and Portisch firmware.

I want to monitor/persist the Open/Close state of my door/window sensors and the state of my alarm in HA to add some automation rules and intelligence to my alarm.

The sensors and rf codes are set properly and I do receive event changes in HA some of the time. But these sensors (Binary switches) goes unavailable most of the time. And I loose state changes and I am left with wrong states in HA.

Here are some examples from my esp home code:

  - platform: remote_receiver
    name: Motion Family
    id: motion_family
    device_class: motion
    rc_switch_raw:
      code: '000111101010010101011100'  #1EA55C
      protocol: 2
    filters:
      delayed_off: 400s

  - platform: remote_receiver
    name: "OpenClose5_Opened"
    id: open_close_5_opened
    rc_switch_raw:
      code: '111000001001001100001010'  #E0930A
      protocol: 2
    filters:
      - delayed_off: 5s

  - platform: remote_receiver
    name: "OpenClose5_Closed"
    id: open_close_5_closed
    rc_switch_raw:
      code: '111000001001001100001110'  #E0930E
      protocol: 2
    filters:
      - delayed_off: 5s

I have about 40 of these code blocks (sensors).

I guess I read somewhere the issue is caused by the large amount of code in the RF bridge Esp code. I reduced this to the minimum but no significant difference.

Any idea what I can do?

1 Like

I wanted to share my implementation of this hardware/firmware combo as it appears to be a novel one. Not that I take any credit as it’s a combination of two other ideas. First, I program the rf bridge to trigger HA events whenever it receives a RF code. This is the example code given on the esphome website.

esphome:
  name: rf_bridge_1
  platform: ESP8266 
  board: esp01_1m

wifi:
  ssid: XXXX
  password: XXXX
  
captive_portal:
  
web_server:
  port: 80

ota:

api:
  services:
    - service: send_rf_code
      variables:
        sync: int
        low: int
        high: int
        code: int
      then:
        - rf_bridge.send_code:
            sync: !lambda 'return sync;'
            low: !lambda 'return low;'
            high: !lambda 'return high;'
            code: !lambda 'return code;'
    - service: learn
      then:
        - rf_bridge.learn

uart:
  tx_pin: 1
  rx_pin: 3
  baud_rate: 19200

logger:
  baud_rate: 0

rf_bridge:
  on_code_received:
    then:
      - homeassistant.event:
          event: esphome.rf_code_received
          data:
            sync: !lambda 'char buffer [10];return itoa(data.sync,buffer,16);'
            low: !lambda 'char buffer [10];return itoa(data.low,buffer,16);'
            high: !lambda 'char buffer [10];return itoa(data.high,buffer,16);'
            code: !lambda 'char buffer [10];return itoa(data.code,buffer,16);'

sensor:
  - platform: wifi_signal
    name: rf_bridge_1_wifi_signal
    update_interval: 60s
    
switch:
  - platform: restart
    name: rf_bridge_1_restart
    
text_sensor:
  - platform: wifi_info
    ip_address:
      name: rf_bridge_1_ip

Then I use node-red to read these events when they trigger and determine if the code matches any of my sensors. If so, publish to a mqtt topic that HA can read. I do this with three nodes:

  • Home-assistant:events:all - configured to watch for esphome.rf_code_received events
  • Function:python function - configured as per the following code
  • Network:mqtt out - no special configuration; just connected to my broker

The python code does most of the work and is easily updated:

codes = {
    '000X0X':['backdoor','ON'],
    '000X0X':['backdoor','OFF'],
    '0X000X':['garagedoor','ON'],
    '0X000X':['garagedoor','OFF'],
    '00000X':['garagemotion01','ON'],
}

data = msg['payload']['event']['code']

if data in codes.keys():
    msg = {}
    msg['topic'] = 'home/{}/status'.format(codes[data][0])
    msg['payload'] = codes[data][1]
    return msg

Then I configure sensors in home-assistant to listen to the appropriate mqtt topics (ex. home/garagedoor/status)

  - platform: mqtt
    state_topic: "home/backdoor/status"
    name: "Back Door"
    payload_on: 'ON'
    payload_off: 'OFF'
    device_class: door

  - platform: mqtt
    state_topic: "home/garagedoor/status"
    name: "Garage Door"
    payload_on: 'ON'
    payload_off: 'OFF'
    device_class: door

  - platform: mqtt
    state_topic: "home/garagemotion01/status"
    name: "Motion Sensor Garage Indoor"
    payload_on: 'ON'
    payload_off: 'OFF'
    device_class: motion
    off_delay: 2

Hey. I did everything according to your instructions. I can accept codes from the remote control. but it doesn’t work. can you help?

esphome:
   name: rf_bridge
   platform: ESP8266
   board: esp01_1m

wifi:
  ssid: "pass"
  password: "pass"
  use_address: 192.168.0.237
  manual_ip:
    static_ip: 192.168.0.237
    gateway: 192.168.0.1
    subnet: 255.255.255.0 

# Enable logging
logger:

web_server:
  port: 80

# Enable Home Assistant API
api:
  password: "apipassword"

ota:
  password: "otapassword"

remote_receiver:
   pin:
     number: 4
   dump:
   - rc_switch
   filter: 50us
   idle: 2ms

remote_transmitter:
  pin: GPIO5
  carrier_duty_percent: 50%


switch:
  - platform: template
    name: RF Power Button
    turn_on_action:
      - remote_transmitter.transmit_rc_switch_raw:
          code: '111111110101111101110001'
          protocol: 1  
  

Same here. Receiver works but not the transmitter.

I have rf bridge hacked.
Finally I managed to transmit protocol 1 rf code.
My settings:

switch:
  - platform: template
    name: "gtstat_01"
    id: "gtstat_01"
    optimistic: true
    assumed_state: true
    turn_on_action:
      remote_transmitter.transmit_rc_switch_raw:
        code: '100010001010101000000001'
        protocol: 
          pulse_length: 320
        repeat:
          times: 10
          wait_time: 0s

Please try it and check if it works.

1 Like

Interesting. I think @andreaslindner 's config work around (Here)
which has been solid for me broke with updating Esphome to 1.16.0, potentially relating to this issue:

Replacing with your settings have fixed it for me.

Thanks!

Been trying to get my sonoff rf bridge to receive and send codes from Zemismart blind remote AC123-06.

Began with Tasmota and portisch but with no success. I could se the binary but did not succeed in keeping the setup, and after reboot of the RF bridge, the “raw.mode” reverted to “standard”

Progressed to ESPhome with this setup:

esphome:
  name: sonoff_rf_bridge
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# Enable logging
logger:
  baud_rate: 0

uart:
  tx_pin: GPIO01
  rx_pin: GPIO03
  baud_rate: 19200

# Enable Home Assistant API
api:
  password: !secret api_password
  services:
    - service: send_rf_code
      variables:
        sync: int
        low: int
        high: int
        code: int
      then:
        - rf_bridge.send_code:
            sync: !lambda 'return sync;'
            low: !lambda 'return low;'
            high: !lambda 'return high;'
            code: !lambda 'return code;'
    - service: learn
      then:
        - rf_bridge.learn

rf_bridge:
  on_code_received:
    then:
      - homeassistant.event:
          event: esphome.rf_code_received
          data:
            sync: !lambda 'char buffer [10];return itoa(data.sync,buffer,16);'
            low: !lambda 'char buffer [10];return itoa(data.low,buffer,16);'
            high: !lambda 'char buffer [10];return itoa(data.high,buffer,16);'
            code: !lambda 'char buffer [10];return itoa(data.code,buffer,16);'

ota:
  password: !secret ota_password

web_server:
  port: 80

sensor:
  - platform: wifi_signal
    name: Sonoff RF Bridge Wifi Signal
    update_interval: 10s
  - platform: uptime
    name: Sonoff RF Bridge Uptime

binary_sensor:
  - platform: status
    name: Sonoff RF Bridge Status

 
remote_receiver:
  pin: 4
  dump: rc_switch
  tolerance: 50
  filter: 4us
  idle: 4ms

remote_transmitter:
  pin: 5
  carrier_duty_percent: 100%

status_led:
  pin:
    number: GPIO13
    inverted: yes

Have done all the hardware mods, it still receives al the old known signals but now in biniry and not the hex codes so far so good.

But my Zemismart remote omly reads as “00000000”
No matter which button I press I get the same result in the logs:
[remote.rc_switch:256]: Received RCSwitch Raw: protocol=1 data=‘00000000’

Any solution to get the RF bridge to read the Zemismart?

I can’t recall where/when I saw it, but I recall the Sonoff can’t do all rf codecs even with the hardware hack. I ended getting and using a broadlink to learn/send codes for my blinds. I had similar symptoms of “incomplete looking” codes being logged/received. Sonoff RF Bridge with ESPHOME?

Perfect! Thanx a lot
my old settings :

- platform: template
    name: Remote Front Gate Control
    turn_on_action:
      remote_transmitter.transmit_rc_switch_raw:
        code: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
        protocol: 1
        repeat:
          times: 10
          wait_time: 10ms 

Hi guys,

Sorry if it’s a nood question, I’m pretty new to rf433.

i’ve got a sonoff rf bridge modified (cut on the lines, etc …)
I’ve flashed esphome and dumping rf_switch.

Then I’m testing my brand new RM433 remote.
My issue is that the top left button and second line right button give me exactly the same code :

#Press on top-left button
[21:22:51][D][remote.rc_switch:256]: Received RCSwitch Raw: protocol=1 data='011110000100000001001000'
[21:22:51][D][remote.rc_switch:256]: Received RCSwitch Raw: protocol=1 data='011110000100000001001000'

#press on second-right button. 
[21:22:53][D][remote.rc_switch:256]: Received RCSwitch Raw: protocol=1 data='011110000100000001001000'
[21:22:53][D][remote.rc_switch:256]: Received RCSwitch Raw: protocol=1 data='011110000100000001001000'

then I don’t know how to distinguish them on config.
All other buttons have differents codes.

Do you know id I did something wrong ?

Have you tried dumping “all” or “raw” just to make sure ?

As a side node: I don’t understand why by default people assume you have to do the hardware “hack” on the RF Bridge for ESPHome… I use it with Portisch firmware, but I don’t know if I even had to flash that, 'cause all my devices seem to work out of the box.
My recommendation with the RF Bridge would be:

  1. Try it with ESPHome without any modifications
  2. If you have devices that don’t work: try using Portisch firmware for the second chip
  3. If all else fails, do the hardware “hack”, but know you essentially now have an ESP8285 with a generic receiver/transmitter duo.
1 Like

The hardware hack is a bit of an abomination

I’m just getting into this pretty late I guess.

I purchased 11 RF 433 MHz door sensors, and 3 water leak sensors. I put Tasmota on my RF Bridge. Water leak sensors work great, but the door sensors often don’t see when the door goes from open to close (probably once ever 5 times on some doors). I would love for the to work 100% of the time. I often get alerts a door is left open when it is in fact close.

it seems if I put ESPHome on my bridge it would work better, but I kept reading how you have to solder two connections and cut three lines. Not the end of the world, but I would love to test ESPhome first. If I can test it out without doing a hardware hack that would be great.

Could you point me to where I put ESPhome on the RF Bridge without a hack? Thanks.

I don’t think ESPHome will make your RF Bridge work better than with Tasmota.
The reason your door sensors don’t work all the time is probably because if you have 11 a lot of them are probably on the edge of the reach of the RF Bridge. My advice would be to either get 1 or 2 extra RF Bridges or maybe build a custom RF solution with better chips and/or antenna’s…

If you still want to try ESPHome just to try it:

Just make the .bin file and upload it through Tasmota, it supports writing ESPHome firmware directly.

Don’t cut anything on your bridge. There is absolutely no need to. It’s a horrible hack job. Search for the guide i posted on it.

I tried to create a binary sensor inside esphome - this option seemed to me the most convenient. I tried to do it in two ways. In each of these two ways, I ran into the same error:
In the esphome web interface, only a part of the sensors becomes active, active sensors become visible in the homeassistant, the rest are not. When I start using the devices, everything is correct in the logs, each window activates the desired sensor, but in the web interface “window 1” activates “window 1”, but “window 2” also activates “window 1”, although in the logs I see a trigger sensor “window 2” and no activity “window 1”. Help organize the binary sensors correctly.

esphome:
  name: sonoff_rfbridge
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "xxx"
  password: "xxx"
  
api:
  password: "xxx"
  services:
    - service: send_rf_code
      variables:
        sync: int
        low: int
        high: int
        code: int
      then:
        - rf_bridge.send_code:
            sync: !lambda 'return sync;'
            low: !lambda 'return low;'
            high: !lambda 'return high;'
            code: !lambda 'return code;'
    - service: learn
      then:
        - rf_bridge.learn

uart:
  tx_pin: 1
  rx_pin: 3
  baud_rate: 19200

logger:
  baud_rate: 0

rf_bridge:
  on_code_received:
    then:
      - text_sensor.template.publish:
          id: rf_code
          state: !lambda 'char buffer [10];return itoa(data.code,buffer,16);'
      - homeassistant.event:
          event: esphome.rf_code_received
          data:
            sync: !lambda 'char buffer [10];return itoa(data.sync,buffer,16);'
            low: !lambda 'char buffer [10];return itoa(data.low,buffer,16);'
            high: !lambda 'char buffer [10];return itoa(data.high,buffer,16);'
            code: !lambda 'char buffer [10];return itoa(data.code,buffer,16);'

ota:
  password: "xxx"

web_server:
  port: 80

sensor:
        
#  WiFi Signal Sensor
#  Датчик отображающий уровень сигнала Wifi
  - platform: wifi_signal
    name: "Sonoff Rfbridge WiFi Signal"
    update_interval: 60s
    
#  Uptime Sensor

#  Датчик отображающий время работы
  - platform: uptime
    name: "Sonoff Rfbridge Uptime"
    id: sonoff_rfbridge_uptime
    update_interval: 60s
    on_raw_value:
      then:
        - text_sensor.template.publish:
            id: uptime_human_rfbridge
            state: !lambda |-
              int seconds = round(id(sonoff_rfbridge_uptime).raw_state);
              int days = seconds / (24 * 3600);
              seconds = seconds % (24 * 3600);
              int hours = seconds / 3600;
              seconds = seconds % 3600;
              int minutes = seconds /  60;
              seconds = seconds % 60;
              return (
                (days ? String(days) + "d " : "") +
                (hours ? String(hours) + "h " : "") +
                (minutes ? String(minutes) + "m " : "") +
                (String(seconds) + "s")
              ).c_str();

binary_sensor:


  - platform: template
    name: "Дверь входная"
    id: dver_vhodnaya

  - platform: template
    name: "Окно гостиная 1"
    id: okno_gostinaya_1

  - platform: template
    name: "Окно гостиная 2"
    id: okno_gostinaya_2

  - platform: template
    name: "Окно родители"
    id: okno_roditeli

  - platform: template
    name: "Окно кухня"
    id: okno_kuhnya

  - platform: template
    name: "Окно санузел 1 этаж"
    id: okno_sanuzel_1_etaz

  - platform: template
    name: "Окно прихожая"
    id: okno_prihozaya

  - platform: template
    name: "Окно крыльцо"
    id: okno_krilco

  - platform: template
    name: "Окно санузел 2 этаж"
    id: okno_sanuzel_2_etaz

  - platform: template
    name: "Окно спальня 1"
    id: okno_spalnya_1

  - platform: template
    name: "Окно спальня 2"
    id: okno_spalnya_2

  - platform: template
    name: "Окно детская"
    id: okno_detskaya


light:
  - platform: binary
    name: "Sonoff Rfbridge WiFi LED"
    id: wifi_led
    output: output_wifi_led
    internal: True

output:
  - platform: gpio
    pin:
      number: GPIO13
      inverted: True
    id: output_wifi_led

switch:
  - platform: restart
    name: "Sonoff Rfbridge Restart"


text_sensor:
  - platform: template
    name: "Latest Code"
    id: rf_code
    on_value:
      then:
    # Дверь входная
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'd72f2e'
            then:
              - lambda: |-
                  id(dver_vhodnaya).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'd72f27'
            then:
              - lambda: |-
                  id(dver_vhodnaya).publish_state(false);

    # Окно гостиная 1
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '713b2e'
            then:
              - lambda: |-
                  id(okno_gostinaya_1).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '713b27'
            then:
              - lambda: |-
                  id(okno_gostinaya_1).publish_state(false);

    # Окно гостиная 2
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '8cdb2e'
            then:
              - lambda: |-
                  id(okno_gostinaya_2).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '8cdb27'
            then:
              - lambda: |-
                  id(okno_gostinaya_2).publish_state(false);

    # Окно родители
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '84eb2e'
            then:
              - lambda: |-
                  id(okno_roditeli).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '84eb27'
            then:
              - lambda: |-
                  id(okno_roditeli).publish_state(false);

    # Окно кухня
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '351b2e'
            then:
              - lambda: |-
                  id(okno_kuhnya).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '351b27'
            then:
              - lambda: |-
                  id(okno_kuhnya).publish_state(false);

    # Окно санузел 1 этаж
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'bb20ae'
            then:
              - lambda: |-
                  id(okno_sanuzel_1_etaz).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'bb20a7'
            then:
              - lambda: |-
                  id(okno_sanuzel_1_etaz).publish_state(false);

    # Окно прихожая
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'bfab2e'
            then:
              - lambda: |-
                  id(okno_prihozaya).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'bfab27'
            then:
              - lambda: |-
                  id(okno_prihozaya).publish_state(false);

    # Окно крыльцо
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'dc5b2e'
            then:
              - lambda: |-
                  id(okno_krilco).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'dc5b27'
            then:
              - lambda: |-
                  id(okno_krilco).publish_state(false);	  

    # Окно санузел 2 этаж
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'be8b2e'
            then:
              - lambda: |-
                  id(okno_sanuzel_2_etaz).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'be8b27'
            then:
              - lambda: |-
                  id(okno_sanuzel_2_etaz).publish_state(false);	  

    # Окно спальня 1
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '50b2e'
            then:
              - lambda: |-
                  id(okno_spalnya_1).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '50b27'
            then:
              - lambda: |-
                  id(okno_spalnya_1).publish_state(false);	

    # Окно спальня 2
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'a7732e'
            then:
              - lambda: |-
                  id(okno_spalnya_2).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: 'a77327'
            then:
              - lambda: |-
                  id(okno_spalnya_2).publish_state(false);	

    # Окно детская
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '10d72e'
            then:
              - lambda: |-
                  id(okno_detskaya).publish_state(true);
         - if:
            condition:
              - text_sensor.state:
                  id: rf_code
                  state: '10d727'
            then:
              - lambda: |-
                  id(okno_detskaya).publish_state(false);		 

  - platform: version
    name: "Sonoff Rfbridge ESPHome Version"
    
  - platform: template
    name: Uptime Human Rfbridge
    id: uptime_human_rfbridge
    icon: mdi:clock-start

here is my second config:

esphome:
  name: sonoff_rfbridge
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "xxx"
  password: "xxx"
  
api:
  password: "xxx"
  services:
    - service: send_rf_code
      variables:
        sync: int
        low: int
        high: int
        code: int
      then:
        - rf_bridge.send_code:
            sync: !lambda 'return sync;'
            low: !lambda 'return low;'
            high: !lambda 'return high;'
            code: !lambda 'return code;'
    - service: learn
      then:
        - rf_bridge.learn

uart:
  tx_pin: 1
  rx_pin: 3
  baud_rate: 19200

logger:
  baud_rate: 0

rf_bridge:
  on_code_received:
    then:
      - text_sensor.template.publish:
          id: rf_code
          state: !lambda 'char buffer [10];return itoa(data.code,buffer,16);'
      - homeassistant.event:
          event: esphome.rf_code_received
          data:
            sync: !lambda 'char buffer [10];return itoa(data.sync,buffer,16);'
            low: !lambda 'char buffer [10];return itoa(data.low,buffer,16);'
            high: !lambda 'char buffer [10];return itoa(data.high,buffer,16);'
            code: !lambda 'char buffer [10];return itoa(data.code,buffer,16);'

ota:
  password: "xxx"

web_server:
  port: 80

sensor:
        
#  WiFi Signal Sensor
#  Датчик отображающий уровень сигнала Wifi
  - platform: wifi_signal
    name: "Sonoff Rfbridge WiFi Signal"
    update_interval: 60s
    
#  Uptime Sensor

#  Датчик отображающий время работы
  - platform: uptime
    name: "Sonoff Rfbridge Uptime"
    id: sonoff_rfbridge_uptime
    update_interval: 60s
    on_raw_value:
      then:
        - text_sensor.template.publish:
            id: uptime_human_rfbridge
            state: !lambda |-
              int seconds = round(id(sonoff_rfbridge_uptime).raw_state);
              int days = seconds / (24 * 3600);
              seconds = seconds % (24 * 3600);
              int hours = seconds / 3600;
              seconds = seconds % 3600;
              int minutes = seconds /  60;
              seconds = seconds % 60;
              return (
                (days ? String(days) + "d " : "") +
                (hours ? String(hours) + "h " : "") +
                (minutes ? String(minutes) + "m " : "") +
                (String(seconds) + "s")
              ).c_str();

binary_sensor:

  - platform: template
    name: "Дверь входная"
    device_class: door
    lambda: !lambda |-
      if (id(rf_code).state == "d72f2e") {
        return true;
      } else if (id(rf_code).state == "d72f27") {
        return false;
      }

  - platform: template
    name: "Окно гостиная 1"
    device_class: door
    lambda: !lambda |-
      if (id(rf_code).state == "713b2e") {
        return true;
      } else if (id(rf_code).state == "713b27") {
        return false;
      }

  - platform: template
    name: "Окно гостиная 2"
    device_class: window
    lambda: !lambda |-
      if (id(rf_code).state == "8cdb2e") {
        return true;
      } else if (id(rf_code).state == "8cdb27") {
        return false;
      }

  - platform: template
    name: "Окно родители"
    device_class: window
    lambda: !lambda |-
      if (id(rf_code).state == "84eb2e") {
        return true;
      } else if (id(rf_code).state == "84eb27") {
        return false;
      }

  - platform: template
    name: "Окно кухня"
    device_class: window
    lambda: !lambda |-
      if (id(rf_code).state == "351b2e") {
        return true;
      } else if (id(rf_code).state == "351b27") {
        return false;
      }

  - platform: template
    name: "Окно санузел 1 этаж"
    device_class: window
    lambda: !lambda |-
      if (id(rf_code).state == "bb20ae") {
        return true;
      } else if (id(rf_code).state == "bb20a7") {
        return false;
      }

  - platform: template
    name: "Окно прихожая"
    device_class: window
    lambda: !lambda |-
      if (id(rf_code).state == "bfab2e") {
        return true;
      } else if (id(rf_code).state == "bfab27") {
        return false;
      }

  - platform: template
    name: "Окно крыльцо"
    device_class: window
    lambda: !lambda |-
      if (id(rf_code).state == "dc5b2e") {
        return true;
      } else if (id(rf_code).state == "dc5b27") {
        return false;
      }

  - platform: template
    name: "Окно санузел 2 этаж"
    device_class: window
    lambda: !lambda |-
      if (id(rf_code).state == "be8b2e") {
        return true;
      } else if (id(rf_code).state == "be8b27") {
        return false;
      }

  - platform: template
    name: "Окно спальня 1"
    device_class: window
    lambda: !lambda |-
      if (id(rf_code).state == "50b2e") {
        return true;
      } else if (id(rf_code).state == "50b27") {
        return false;
      }
  - platform: template
    name: "Окно спальня 2"
    device_class: window
    lambda: !lambda |-
      if (id(rf_code).state == "a7732e") {
        return true;
      } else if (id(rf_code).state == "a77327") {
        return false;
      }

  - platform: template
    name: "Окно детская"
    device_class: window
    lambda: !lambda |-
      if (id(rf_code).state == "10d72e") {
        return true;
      } else if (id(rf_code).state == "10d727") {
        return false;
      }
    

text_sensor:
  - platform: template
    name: "Latest Code"
    id: rf_code

  - platform: version
    name: "Sonoff Rfbridge ESPHome Version"
    
  - platform: template
    name: Uptime Human Rfbridge
    id: uptime_human_rfbridge
    icon: mdi:clock-start

Maybe the problem is not in the code, but in the esphome version?

Some sensors that don’t work (it is mainly my front and back door, which are less than 10 feet away) are the ones that often fail, and always on close.

Thanks for the link on how to go with ESPHome. If I do this, is it also just as quick to go back if I want to?

@tman75: Only 2 options for your sensors really. Either the RF Bridge has trouble receiving or your sensors have trouble sending. I suggest you do some debugging. Could be interference, could be batteries, could be something I can’t think of right know…
I don’t know if flashing back to Tasmota is as easy as flashing ESPHome (from Tasmota). I already told you that your problem probably isn’t Tasmota. If you try ESPHome though, I also don’t see a reason to go back to Tasmota as the RF Bridge will probably work more or less the same with either firmware…

(ESPHome has the benefit of being well integrated into HA, both in communication as through the add-on. With ESPHome you can also handle sending/receiving of codes directly inside the firmware if you want. The firmware itself is also more optimized compared to Tasmota, which is like a big Swiss army knife)

You created template sensors with no template. So until you set their state, they don’t have one.

Did you somehow modify the Sonoff board? did you cut the tracks?