Integrating RF devices with sonoff rf bridge on Tasmota Firmware

Yes, you are right, both get job done. My approach is to simulate standard behavior of switch (On / Off) in case any other control system (not only HA) will require visibility of switch status.

It is good example of HA flexibility…number of ways how you can achieve same results :wink:

Yes, lots of ways to skin the cat.

I just received from Banggood a 433MHz learning remote keyfob device, with 4 buttons. It doesn’t seem to have anything useful programmed into it, so I think I’ll need to poke at the sonoff rf bridge to get it to transmit some random codes for the keyfob to learn.

Then, I’ll have another small device to do… well, I’m not sure what at this point! For $8.00, it seemed like something interesting to try.

I had bought a couple of Z-Wave 4-button remotes that have been handy, but they were cheap at the time, I think, because they were very old inventory with LiPo batteries that didn’t hold a charge real well. It wasn’t hard to desolder the old batteries and replace them with some small batteries I found on ebay, but it’s not really a reproducible solution.

I’m hoping that the little 433MHz keyfob will have enough range to work from the car as its sitting outside the house… That might be a fun application for a more immediate action before the WiFi presence thing sniffs that my phone has come home.

this is exactly my user case. Big house many places with little recepotion, and some non critical switches (I don’t care if somebody sniffs my 433 signal)

Just received my sonoff rf bridge and I flashed it with Tasmota. Tried with a PIR sensor and worked at first try!

Now I am trying to fix the transmitting part. I can program the Bridge for up to 16 433 signals correct? Didn’t find a way to put it in learn mode yet, will investigate.

Just to make sure I understood correctly, a way to integrate it with HASS is the following

For receiving signals (PIR, door sensors and so on)

binary_sensor:
  - platform: mqtt
    name: "Motion sensor"
    payload_on: "FFFFF"   # the code that you see in the Tasmota log when the sensor is activated
    payload_off: "FFFFFoff"
    device_class: motion
    state_topic: "tele/sonoff_bridge/RESULT"
    value_template: '{{ value_json.RfReceived.Data }}'  # Data here?

While for the SENDING part, I am a bit more confused. Did I understand correctly the following:
I can use, for example, a 433 Key, put the Bridge in learn mode and associate the number 1 (for example) to that code. So now if I click the number 1 in tasmota interface or click the switch switch.rf_bridge_key_1_pressed
it will send the 433 signal learned. But that signal is also received? I mean if I want to press the 433 remote key 1, the Bridge will RECEIVE that signal (like it does with a PIR sensor activated), correct?

binary_sensor:
  - platform: mqtt
    name: "RF bridge key 1 pressed"
    payload_on: "1"
    payload_off: "key1_off"
    device_class: switch #?
    state_topic: "tele/sonoff_bridge/RESULT"
    value_template: '{{ value_json.RfReceived.RfKey }}'  # Rfkey here?

Correct?

Or is the other way around: the RF Bridge HAS already the 16 codes, and you put to learn the RF remote with the code from the Sonoff Bridge?

For Pir this is what i have working:

- platform: mqtt
  name: "pir8_mastertoilet"
  state_topic: 'tele/sonoff/rfbridge/RESULT'
  value_template: '{{ value_json["RfReceived"].Data if value_json else "825888OFF" }}' 
  payload_on: "825888"
  payload_off: "825888OFF"
  device_class: motion
  scan_interval: 5
  retain: true 

For sending using the memories what you need to do is bring the device you want to control close to the gateway, put that device in learning mode and then press 1 in the sonoff rfbridge. Test it. if it works go to the console and get the code for your switch

I think I got it.

You can use the default codes by just pressing the number on the Tasmota webui, if you put the remote key on learning mode it will learn that code.
Or you can make the RF Bridge in learn mode and then press a remote key (that is already programmed) next to the RF Bridge (in this case the default code will be lost)

You put the Sonoff RF Bridge in learn mode writing in console
RFkeyx 2 (x can vary from 1 to 16)

Pretty powerful little device

1 Like

If I understand correctly your problem, maybe the issue is that the Bridge does not listen to itself when he is the one sending the RF code

Hello,

For me this is all a kind of new.
I achieved already a lot.
The switches at home are working good but now i am testing with the sonoff bridge with tasmota on it.
What i now want to do os to turn on and off the light what is already working and can be switched on and off by the handy.
I don’t believe i have to create a new switch or not?
Is it a line what needs to be added to this switch so it listen also to the commands from the bridge with the correct data what belongs to the bridge?

This solution is much cleaner than spoofing mqtt messages:

 - platform: mqtt
    name: "Lounge Window"
    payload_on: "5D4533"
    device_class: window
    state_topic: "rf_bridge/tele/RESULT"
    value_template: "{{ value_json.RfReceived.Data }}"
    off_delay: 180

rather than what most people propose in this thread:

- platform: mqtt
    name: "Lounge Window"
    payload_on: "5D4533"
    payload_off: "5D4533off"
    device_class: window
    state_topic: "rf_bridge/tele/RESULT"
    value_template: "{{ value_json.RfReceived.Data }}"

  - alias: Reset Lounge Window
    hide_entity: true
    trigger:
      platform: state
      entity_id: binary_sensor.lounge_window
      to: 'on'
      for:
        seconds: 300
    action:
      service: mqtt.publish
      data:
        topic: "rf_bridge/tele/RESULT"
        payload: ' {“RfReceived”:{“Data”:"5D4533off"}} '
        retain: 'true'
4 Likes

Instead of the reset automation you can also do this:

off_delay: 5

This resets it after 5 seconds. No need for another automation.

- platform: mqtt
  state_topic: "tele/rfbridge/RESULT"
  name: 'Kitchen Leak'
  value_template: '{{value_json.RfReceived.Data}}'
  payload_on: '578B11'
  off_delay: 5
  device_class: moisture
  optimistic: false
  qos: 1
  retain: false

Thanks for the tips, got it to work!

5 Likes

Thanks for that code snippet @eh50 I have been looking for a clean way to turn of a binary_sensor that I have setup for an RF Motion Sensor.

Glad to help, I had a whole yaml file full of reset automations, got rid of it with just that code.

This save’d me from a lot of work

I’m trying to use ur code and it doesn’t work, can you please show in more details?

I have an RF plug, that have ‘on’ and ‘off’ codes controlled by remote control, I know both codes, I also have ‘Key 1’ and ‘key 2’ on the ‘rf bridge’ learn the codes and they can turn it on and off. However, when i’m trying to make a ‘switch’ in HA, no response.
Did you make a binary_sensor? Can you show the ymal? All that is related to the rf in ur settings?
Really appriciated if you could help.

i’ve set it up as an automation, with an input boolean. I have an RF plug hooked up to my 12 inch fan inside my electric cabin (where gas and electricity comes in the house) and there’s a hole in the door where a PI with a 3.5 inch TFT is sticking out. (overclocked so there’s a huge fan behin it.

You could change the trigger to the input boolean you create for the switch.

automations.yaml:

- alias: "[RPI] Turn on FAN above 48 degree"
  trigger:
  - platform: numeric_state
    entity_id: sensor.pitft_temperature
    above: '48'
  condition:
    - condition: state
      entity_id: input_boolean.rpi_fan
      state: 'off'
  action:
    - service: mqtt.publish
      data:
        topic: "cmnd/rfbridge/RfKey3"
        payload: ""
        qos: 2
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.rpi_fan

- alias: "[RPI] Turn off FAN below 50 degree"
  trigger:
  - platform: numeric_state
    entity_id: sensor.pitft_temperature
    below: '42'
  condition:
    - condition: state
      entity_id: input_boolean.rpi_fan
      state: 'on'
  action:
    - service: mqtt.publish
      data:
        topic: "cmnd/rfbridge/RfKey4"
        payload: ""
        qos: 2
    - service: input_boolean.turn_off
      data:
        entity_id: input_boolean.rpi_fan

configuration.yaml:

input_boolean:
  rpi_fan:
    name: RaspberryPi 3 Fan
    initial: off
    icon: mdi:fan

Hi, my Sonoff RF Breidsge works fine and well integrated in HASS, for RECEIVING signals.

Noiw I am trying to SEND signal: I have an RF Siren 433, which I want to trigger when the alarm goes ON.
The siren comes with an RF sender, that when you press (send signal) the siren goes ON. Reading the code in Tasmota consolle is

14:31:10 MQT: tele/rf-bridge/RESULT = {"RfReceived":{"Sync":10270,"Low":310,"High":930,"Data":"980000","RfKey":"None"}}

So I know the code is 980000

Now I want to trigger the siren from HASS SENDING (not receiving) the code to the RF Bridge which then should send the RF signal, but which is the configuration??

script:
###########################################
####  TRIGGER SIREN THREE (RF SEND)
###########################################  
  rf_bridge_turn_on_siren_three:
    alias: 'Turn on siren three'
    sequence:
    - service: mqtt.publish
      data_template:
        topic: 'cmnd/send'  #  WHAT HERE?            
        payload: '980000'

I know I can use Sonoff RF Bridge to LEARN the signal, and then use the Keys for SENDing the signal (also this I do not know how to integrate in HASS with mqtt.publish), but I do not need to use one of the 16 signal keys

I ended up using this code for RF:

  • platform: mqtt
    name: “Switch”
    command_topic: “cmnd/Bridge/RfCode”
    payload_on: “2372244”
    payload_off: “2372250”
    state_topic: “stat/Bridge/RESULT”
    value_template: ‘{{ value_json.RfCode }}’
    state_on: “2372244”
    state_off: “2372250”
    retain: false
    qos: 1

Payload_on/off values you will get them from the “Data”:“980000” part in your example.

On Rf 433 SonOff Bridge (Tasmota 6.4.1) use
SetOption28 ON
rule1 on
rule on RfReceived#data do publish stat/Bridge/RESULT {“RfCode”:“%value%”} endon

Now, no matter if you press the 433 remote control of the device or the mqtt switch on HA
the feedback value is stated on HA.

Thanks will try this