Skip to content
Max Prokhorov edited this page Nov 12, 2019 · 11 revisions

RFBRIDGE

RFBRIDGE module (rfbridge.ino), originally created for the Itead Sonoff RF Bridge.

Since version 1.14.0, combined with RF module and now allows to use standalone ESP8266 board with an external RF receiver / transmitter

MQTT

rfin and rfout topics are used to receive and send messages. rfraw topic allows to send raw binary messages to the EFM8 chip (2)

State topic Example payload Notes
{root topic}/rfin 26C0013603CA511451 received code
Command topic Example payload Notes
{root topic}/rflearn/0/set 1 see note 1 below
{root topic}/rfout/set 26C0013603CA511451 send code
{root topic}/rfout/set 26C0013603CA511451,3 send code N times
{root topic}/rfraw/set see note 2 below

Terminal

Command description
learn <id> Learn RF code for relay ID
forget <id> Forget previously learned RF code

Settings

Key Description Possible values Default value
rfbOFF# Code to turn OFF the n-th device A string
rfbON# Code to turn ON the n-th device A string
rfbRX (DIRECT) RX GPIO 0-15 -
rfbTX (DIRECT) TX GPIO 0-15 -

RF / RFBRIDGE-DIRECT

The RF codes produced by the firmware for the "direct" modified board are different from the ones produced by the "vanilla" bridge for same remote. This was a design choice, due to the different kind of information passed by the EFM8 hardware and the software library.

For example, running mosquitto_sub -v -t "+/rfin":

rfbridge-vanilla/rfin 2F260186046ACE9778
rfbridge-direct/rfin C00101841800CE9778

Thanks to @pelson, here is an example of how to port basic Arduino sketch code that uses RCSwitch to send messages using MQTT 3:

mySwitch.setProtocol(4);
mySwitch.send(2175276, 24);

Equivalent message for the rfout would be:

mosquitto_pub -t "rfbridge-direct/rfout/set" -m "C0040000180021312C"
  • C0: The initial byte (always the same)
  • 04: Protocol 4.
  • 0000: 2 timing bytes (16 bit int?) - I wanted the timing to be defined by the protocol, not overridden.
  • 18: Bit length (24 in decimal)
  • 0021312C: The code to send (2175276 in decimal). This code is limited to 4 bytes.

Home Assistant

To configure RFBridge as a sensor.espurna_123456_rfin sensor entity:

- platform: mqtt
  name: "ESPURNA 123456 RFIN"
  state_topic: "ESPURNA-123456/rfin"
  availability_topic: "ESPURNA-123456/status"
  payload_available: "1"
  payload_not_available: "0"
  force_update: true
  expire_after: 1

Most of the time we are only interested in the last 3 bytes. It is possible to modify the incoming data right in the sensor configuration by using value_template attribute: https://www.home-assistant.io/components/template/ https://jinja.palletsprojects.com/en/master/templates/

  value_template: >
       {% if not value %}
           "No data"
       {% endif %}
       {{ value[-6:] }}

Or, with mqttUseJson => "1", state_topic should be /data and value_template should be:

  value_template: {{ value_json["rfin"] }}

Notes

(1) Triggers a learn action. The index after the "learn" magnitude indicates the relay the code will be linked to. The payload of the message indicates the action (0 for off, 1 for on).

(2) Raw codes requires a special firmware in the EFM8BB1. See Portisch/RF-Bridge-EFM8BB1 and issue #386 for more information. Full list of commands: https://github.com/Portisch/RF-Bridge-EFM8BB1/wiki/Commands

(3) https://gitter.im/tinkerman-cat/espurna?at=5d39a15be16c666d8967d6c9

Home
Change log

Getting started

Supported hardware and options

Configuration

Integrations

Network

Developers

More around ESPurna

Clone this wiki locally