Trying to send RF Codes, how do I do that with the Sonoff RFBridge?

Hi All

I have a light that is operated via RF, I have a SONOF RFBridge that is tazmotized.
I’ve used the RFBridge only for receiving codes so far, so I’m a little lost here.

I can see the code the remote sends to the light directly in the console.
So it seems to be able to do this.

But how do I:

  1. Enter a command directly in the RF Bridge console to send the RF code (for testing)
  2. Create an MQTT command that will send this code through the RF Bridge.

I’ve tried searching for this, but I can’t seem to find a ‘simple and modern’ recipe for this.
Am I limited to somehow store these codes in the 16 fields in the RF Bridge, because the light remote has 24 buttons :open_mouth: ?

This is how I do it on my RF Bridge, but it is flashed with OpenMQTTGateway

  action:
  - data:
      payload: '1213858'
      topic: home/OpenMQTTGateway/commands/MQTTtoSRFB
    service: mqtt.publish

For Tasmota it is similar, but you have to change the topic.

And you can send an unlimited amount of codes, you just have to know them :slight_smile:

For testing, just use the mqtt command in developer tools.

Got it working, I couldn’t find the last part of the topic for it, but finally did.
So for me it’s a topic like
cmnd/rfbridge/RfCode
with a payload of the RF code, and the light reacts on it.

Now I have to figure out how to create this best, as it doesn’t have a ‘toggle’ RF command, just an off and an on (and of course a lot of colours).
My idea at the moment is to have a boolean input that holds the state, and then create two automations based on whether the boolean input says it’s on or not.
Anybody that has a better idea?

And that works. I’ve created two automations that reacts on the RF wallswitches, and then one for turning the light on, and setting the input boolean to on, and one for turning it off, and setting the input boolean to off.
I’m currently letting the automation toggle the input boolean, I could change it so that the RF code does this, as this would allow the remote control to be used as well, but I doubt that I will ever use the remote for turning the light on and off, but maybe for some of the effects.

Can you show your config?

Hej @Brian_Blak_Guldager

What do you want to know exactly?
I’m running two RF Bridges, one for transmission (Tasmota) and one for receiving (ESPHome).
The codes for my RF light are stored in the Tasmota firmware with the 16 storage places there.
The RF Bridge that receives codes are an ESPHome, and that has all the wall switches defined locally.
The card I’ve built for controlling my RF led star light look like this:

cards:
  - card:
      cards:
        - color-type: icon
          entity: light.trappe
          icon: 'mdi:plus'
          show_name: false
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey14
          type: 'custom:button-card'
        - color-type: icon
          entity: light.trappe
          icon: 'mdi:minus'
          show_name: false
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey15
          type: 'custom:button-card'
        - color-type: icon
          entity: light.trappe
          icon: 'mdi:lightbulb-off-outline'
          show_name: false
          tap_action:
            action: call-service
            service: light.turn_off
            service_data:
              entity_id: light.trappe
          type: 'custom:button-card'
        - color-type: icon
          entity: light.trappe
          icon: 'mdi:lightbulb-outline'
          show_name: false
          state:
            - icon: 'mdi:lightbulb-on'
              value: 'on'
          tap_action:
            action: call-service
            service: light.turn_on
            service_data:
              entity_id: light.trappe
          type: 'custom:button-card'
      type: horizontal-stack
    conditions:
      - entity: light.trappe
        state: 'on'
    type: conditional
  - card:
      cards:
        - color-type: blank-card
          style: |
            ha-card{background:transparent;box-shadow: none;}
          type: 'custom:button-card'
        - color-type: blank-card
          style: |
            ha-card{background:transparent;box-shadow: none;}
          type: 'custom:button-card'
        - color-type: blank-card
          style: |
            ha-card{background:transparent;box-shadow: none;}
          type: 'custom:button-card'
        - color: 'rgb(255,255,255)'
          color-type: icon
          entity: light.trappe
          icon: 'mdi:lightbulb-outline'
          show_name: false
          state:
            - color: 'rgb(255,255,0)'
              icon: 'mdi:lightbulb-on'
              value: 'on'
          tap_action:
            action: call-service
            service: light.turn_on
            service_data:
              entity_id: light.trappe
          type: 'custom:button-card'
      type: horizontal-stack
    conditions:
      - entity: light.trappe
        state: 'off'
    type: conditional
  - card:
      cards:
        - color: 'rgb(255,0,0)'
          color-type: icon
          icon: 'mdi:lightbulb-on'
          show_name: false
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey4
          type: 'custom:button-card'
        - color: 'rgb(0,255,0)'
          color-type: icon
          icon: 'mdi:lightbulb-on'
          show_name: false
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey5
          type: 'custom:button-card'
        - color: 'rgb(0,0,255)'
          color-type: icon
          icon: 'mdi:lightbulb-on'
          show_name: false
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey6
          type: 'custom:button-card'
        - color-type: icon
          icon: 'mdi:lightbulb-on-outline'
          show_name: false
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey3
          type: 'custom:button-card'
      type: horizontal-stack
    conditions:
      - entity: light.trappe
        state: 'on'
    type: conditional
  - card:
      cards:
        - color: 'rgb(255,255,0)'
          color-type: icon
          icon: 'mdi:lightbulb-on'
          show_name: false
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey7
          type: 'custom:button-card'
        - color: 'rgb(0,255,255)'
          color-type: icon
          icon: 'mdi:lightbulb-on'
          show_name: false
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey8
          type: 'custom:button-card'
        - color: 'rgb(255,0,255)'
          color-type: icon
          icon: 'mdi:lightbulb-on'
          show_name: false
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey9
          type: 'custom:button-card'
        - color-type: blank-card
          style: |
            ha-card{background:transparent;box-shadow: none;}
          type: 'custom:button-card'
      type: horizontal-stack
    conditions:
      - entity: light.trappe
        state: 'on'
    type: conditional
  - card:
      cards:
        - color-type: icon
          icon: 'mdi:traffic-light'
          name: Jump3
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey10
          type: 'custom:button-card'
        - color-type: icon
          icon: 'mdi:traffic-light'
          name: Jump7
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey11
          type: 'custom:button-card'
        - color-type: icon
          icon: 'mdi:traffic-light'
          name: Fade3
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey12
          type: 'custom:button-card'
        - color-type: icon
          icon: 'mdi:traffic-light'
          name: Fade7
          tap_action:
            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey13
          type: 'custom:button-card'
      type: horizontal-stack
    conditions:
      - entity: light.trappe
        state: 'on'
    type: conditional
type: vertical-stack

My ESPHome config for receiving my RF wall switches looks like this:


# 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(bedroomswitch).publish_state(false);
        }
      
# Setting up WIFI access
wifi:
  ssid: "SSID"
  password: "PW"
  manual_ip:
    static_ip: 1.2.3.4
    gateway: 1.2.3.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: '000000000000000000000000'
      protocol: 1
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    name: stairsswitch_above2
    id: stairsswitch_above2
    rc_switch_raw:
      code: '000000000000000000000000'
      protocol: 1
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    name: stairsswitch_below
    id: stairsswitch_below
    rc_switch_raw:
      code: '000000000000000000000000'
      protocol: 1
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    name: hallswitch_kitchen
    id: hallswitch_kitchen
    rc_switch_raw:
      code: '000000000000000000000000'
      protocol: 1
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    name: hallswitch_entry
    id: hallswitch_entry
    rc_switch_raw:
      code: '000000000000000000000000'
      protocol: 1
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    name: bedroomswitch
    id: bedroomswitch
    rc_switch_raw:
      code: '000000000000000000000000'
      protocol: 1
    filters:
      delayed_off: 100ms
  - platform: remote_receiver
    name: bedroomnightswitch
    id: bedroomnightswitch
    rc_switch_raw:
      code: '000000000000000000000000'
      protocol: 1
    filters:
      delayed_off: 100ms

Just curious, what’s the reason behind using two RF bridges with different firmwares?
Does that mean the ESPHome firmware does not allow for sending RF codes?
I’m on OMG but recently noticed that people are using ESPHome for their RF gateways so I’ve started collecting information for a potential move… :wink:

Well it is an intermediate solution, as I haven’t yet found a working setup for ESPHome and transmission of codes. It does support it, but I’ve had less success with controlling the RF light without storing the codes inside the bridge.

1 Like

Im trying to find out how to set up send rf codes via hassio but it seems i cant get it to work.
i have tasmota with Portisch.

I see, well I’ve store the codes internally in Tasmota, and just call them by reference.

The action I’ve set up looks like this:

            action: call-service
            service: mqtt.publish
            service_data:
              payload: ''
              qos: 1
              topic: cmnd/rfbridge/rfkey14

So the topic is set inside tasmota, and it of course subscribes to the MQTT (Mosquitto) that I have installed on the Hass.io

My problem is that i want to use more codes than the 16 buttons in tasmota, i need to find a way to send it from within homeassistant configurations.yaml so dont know if its possible.
and my codes seems different “AA B0 29 03 08 0596 021C 1B9E 011001101001100101011010011001010110011010101010011010011010100112 55”

Just to add to your post, to store new codes you run the command “RFKeyX 2” without the quotes at the command line of the RFBridge, where “X” is the slot number you want to store the new code, it will enter learning mode. Then press the RF remote button you want to clone, hold it for about 1-2 seconds and the RFBridge will make a beep and will exit learning mode. That’s it, the new code is learned in the slot number you set in the command. I searched for this for a few hours on the forums and could not find it explained well, people suggested other more difficult ways to do it, but if you don’t need to send more than 16 codes, this is the easiest way. Hope that helps someone.

Hi @chri5tian
Yes, that’s what I had it set up to before I reset it, moved it to a NOT vlan, and is hoping I can get a more advanced set up. But as it is now, I’m going to relearn the codes to the hub, and wait for somebody to help me solve this :slight_smile:

Hi all, I’m trying to send a command using a known key; so if in the developper tools I send

topic: cmnd/RF_Bridge/RfCode
payload: '529CB4'

In the RF Bridge console I only see the first 3 digits of the code

08:49:16 MQT: stat/RF_Bridge/RESULT = {"RfCode":529}

as if the code was truncated

I assume you are running Tasmota on the bridge? If so this is how I send RF data:

  - platform: mqtt
    name: "Siren"
    command_topic: "cmnd/bridge/rfcode"
    payload_on: "#08AC88"
    payload_off: "#08AC82"

It’s been a while since I wrote the YAML so I can’t remember the references I read to come up with this, but it works. I suspect the leading hash symbol will make a difference?

topic: cmnd/RF_Bridge/RfCode
payload: '#529CB4'

Definetely use # in front of the code there.

ah, or I found that converting the hexadecimal to decimal works

I’m just trying to trigger my wireless doorbell; publishing the RfCode only doesn’t work; is it possibile I also need to publish Sync/Low/High data? (not sure what all of that is)

I think from memory I set the values for those on the console of the bridge, making them the defaults. The alarm is the only thing I send codes for.

I’ve had to create a script for sending these values to my RF units.
I send out:

cmnd/rfbridge/RfSync
cmnd/rfbridge/RfLow
cmnd/rfbridge/RfHigh
cmnd/rfbridge/RfCode

For each RF Command