My Sonoff RF Bridge with ESPHome

Tags: #<Tag:0x00007f7c66f94400> #<Tag:0x00007f7c620f3cb0>

I just wanted to share my ESPHome config for the RF Bridge.
It’s nothing special, but as I was asked about it, here’s the config (the RF codes have been change to protect the innocent :-D)

I have added my standard set of sensors as well.

# Setting up standard info

substitutions:
  device_name: sonoff_rfbridge_1

esphome:
  name: ${device_name}
  platform: ESP8266
  board: esp01_1m
  
  # Resetting sensors on boot
  on_boot:
    then:
      lambda: |-
        {
          id(stairsswitch_above).publish_state(false);
          id(stairsswitch_below).publish_state(false);
          id(hallswitch_kitchen).publish_state(false);
          id(hallswitch_entry).publish_state(false);
          id(bedtroomswitch).publish_state(false);
          id(bedroomwindow).publish_state(false);
          id(entrydoor).publish_state(false);
          id(gardendoor).publish_state(false);
          id(chestfreezerdoor).publish_state(false);
          id(frontdoor).publish_state(false);
        }
      
# Setting up WIFI access
wifi:
  ssid: "SSID"
  password: "PW"
  manual_ip:
    static_ip: 192.168.1.100
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    
# Enable logging
logger:

# Enable Home Assistant API
api:

# Setting up OTA
ota:
  password: "PW"
  
# Activating Webserver
web_server:
  port: 80

# Setting up the remote receiver
remote_receiver:
 pin: 4
 dump: rc_switch
 tolerance: 50
 filter: 4us
 idle: 4ms
 
# Setting up the remote transmitter
remote_transmitter:
  pin: 5
  carrier_duty_percent: 100%

# Setting up the LED
status_led:
  pin:
    number: GPIO13
    inverted: yes
  
# Setting up my default sensors about wifi and esphome
text_sensor:
  - platform: version
    name: '${device_name} ESPHome Version'
  - platform: wifi_info
    ip_address:
      name: '${device_name} ip'
    ssid:
      name: '${device_name} ssid'

# Setting up a counted for uptime in days
sensor:
  - platform: uptime
    name: '${device_name} Uptime'
    unit_of_measurement: days
    update_interval: 300s
    accuracy_decimals: 1
    filters:
      - multiply: 0.000011574

# Setting up sensors with single states
binary_sensor:
  - platform: status
    name: Sonoff RF Bridge Status
  - platform: remote_receiver
    name: stairsswitch_above
    id: stairsswitch_above
    rc_switch_raw:
      code: 'CODE'
      protocol: 1
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    name: stairsswitch_below
    id: stairsswitch_below
    rc_switch_raw:
      code: 'CODE'
      protocol: 1
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    name: hallswitch_kitchen
    id: hallswitch_kitchen
    rc_switch_raw:
      code: 'CODE'
      protocol: 1
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    name: hallswitch_entry
    id: hallswitch_entry
    rc_switch_raw:
      code: 'CODE'
      protocol: 1
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    name: bedtroomswitch
    id: bedtroomswitch
    rc_switch_raw:
      code: 'CODE'
      protocol: 1
    filters:
      delayed_off: 100ms
# Setting up sensors with dual state, first two internal sensors and then 
# a sensor that sends the resulting state to HA
  - platform: remote_receiver
    id: bedroomwindow_open
    internal: true
    rc_switch_raw:
      code: 'CODE'
      protocol: 2
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    id: bedroomwindow_close
    internal: true
    rc_switch_raw:
      code: 'CODE'
      protocol: 2
    filters:
      delayed_off: 100ms
  - platform: template
    name: bedroomwindow
    id: bedroomwindow
    device_class: window
    lambda: |-
      if (id(bedroomwindow_open).state) {
        return true;
      } else if (id(bedroomwindow_close).state) {
        return false;
      } else {
        return {};
      }
  - platform: remote_receiver
    id: entrydoor_open
    internal: true
    rc_switch_raw:
      code: 'CODE'
      protocol: 2
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    id: entrydoor_close
    internal: true
    rc_switch_raw:
      code: 'CODE'
      protocol: 2
    filters:
      delayed_off: 100ms
  - platform: template
    name: entrydoor
    id: entrydoor
    device_class: door
    lambda: |-
      if (id(entrydoor_open).state) {
        return true;
      } else if (id(entrydoor_close).state) {
        return false;
      } else {
        return {};
      }
  - platform: remote_receiver
    id: gardendoor_open
    internal: true
    rc_switch_raw:
      code: 'CODE'
      protocol: 2
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    id: gardendoor_close
    internal: true
    rc_switch_raw:
      code: 'CODE'
      protocol: 2
    filters:
      delayed_off: 100ms
  - platform: template
    name: gardendoor
    id: gardendoor
    device_class: door
    lambda: |-
      if (id(gardendoor_open).state) {
        return true;
      } else if (id(gardendoor_close).state) {
        return false;
      } else {
        return {};
      }
  - platform: remote_receiver
    id: freezerdoor_open
    internal: true
    rc_switch_raw:
      code: 'CODE'
      protocol: 2
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    id: freezerdoor_close
    internal: true
    rc_switch_raw:
      code: 'CODE'
      protocol: 2
    filters:
      delayed_off: 100ms
  - platform: template
    name: chestfreezerdoor
    id: chestfreezerdoor
    device_class: door
    lambda: |-
      if (id(freezerdoor_open).state) {
        return true;
      } else if (id(freezerdoor_close).state) {
        return false;
      } else {
        return {};
      }
  - platform: remote_receiver
    id: frontdoor_open
    internal: true
    rc_switch_raw:
      code: 'CODE'
      protocol: 2
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    id: frontdoor_close
    internal: true
    rc_switch_raw:
      code: 'CODE'
      protocol: 2
    filters:
      delayed_off: 100ms
  - platform: template
    name: frontdoor
    id: frontdoor
    device_class: door
    lambda: |-
      if (id(frontdoor_open).state) {
        return true;
      } else if (id(frontdoor_close).state) {
        return false;
      } else {
        return {};
      }
3 Likes

You can read the RF correctly?

Yes, it works quite well, and it is very fast compared to tasmota.

Did you make the hardware hack mod?

Yes I did, it was quite easy.

Then I think I broke my RF Bridge, because I cant send any code…

Didi you use resistances or a simple cable to the mod?

Now you talked about receiving, and now transmitting?
I only use the sonoff bridge for receiving, I didn’t have success with sending, not stable at least.
For that I still use Tasmota (secondary bridge)

1 Like

Dude, you make my day.
I can receive but cant transmit whit this mod.

Then I need another bridge with tasmota to transmit.

THANKS!!!

That mod works for sending, although not tested with esphome yet.

1 Like

I try this mod with ESPhome and Espurna.
With espurna I cant send or receive, with ESPHome I can receive but wont send.

I think I broke something.