Integrating RF devices with sonoff rf bridge on Tasmota Firmware

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

Trying to upgrade to 6.4.1 (from Version 6.3.0-2_3_0) but it does not.

Nevertheless, your code seems to work (see log below) also with firmware 6.3.0, but the software switch does not trigger …

10:14:38 CMD: SetOption28 ON
10:14:38 MQT: stat/rf-bridge/RESULT = {"SetOption28":"ON"}
10:14:44 CMD: rule1 on
10:14:44 MQT: stat/rf-bridge/RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":432,"Rules":"on RfReceived#data do publish stat/Bridge/RESULT {“RfCode”:"%value%"} endon"}
10:14:52 CMD: rule on RfReceived#data do publish stat/Bridge/RESULT {“RfCode”:"%value%"} endon
10:14:52 MQT: stat/rf-bridge/RESULT = {"Rule1":"ON","Once":"OFF","StopOnError":"OFF","Free":432,"Rules":"on RfReceived#data do publish stat/Bridge/RESULT {“RfCode”:"%value%"} endon"}

this when I press the switch manually, so its all ok I think

10:16:29 RUL: RFRECEIVED#DATA performs "publish stat/Bridge/RESULT {“RfCode”:"9987858"}"
10:16:29 MQT: stat/Bridge/RESULT = {“RfCode”:"9987858"}

You named your sonoff bridge rf-bridge so where I say Bridge in my code replace that with rf-bridge that you named yours. You need to do that in command topic, state topic and rule.

To upgrade a Sonoff device firmware, log in to its local ip choose Firmware Upgrade => Choose file => Start upgrade. First you choose the sonoff-minimal.bin firmware. Flash it restart the device and then flash it again with sonoff.bin. Restart again the device and you are ready.

  1. Yep, that was, plus the code changed since yesterday I reset the siren (I forgot)

  2. Ahh got it, thanks.
    EDIT: ggrrrr I did the sonoff-minimal, now the website does not load …

EDIT it came back, but it does not upgrade. Anyway I am not interested in upgrading, also because the commands seems to work fine

The issue I have is that the switch works well first time (from off to on and the siren triggers), but then the switch does not go back to off (of course I do slide it to off, but it does not go from on to off, it stays on)

Maybe I have to change payload_off or state_off???