Sonoff RF Bridge + OpenHAB

I assume that you have the Sonoff RF Bridge 433MHz flashed with Tasmota firmware and initially configured to handle MQTT. Optional requirement would be configuring pre-defined RFKeyX’s. Full tutorial is written i previous post. this guideline covers OpenHAB configuration only.

I went through OpenHAB community forum to get the best approach in configuring Sonoff RF Bridge. There are different solutions and configs. I tried to get the best and put them together here. Solution is quite simplified as I do not use any rules yet. They will be required when you use virtual buttons or devices that send data and we have to act upon that.

Generally there are 2 approaches how to control remote devices like wireless switch using Sonoff RF Bridge.

  • You capture signal and configure RFKeyX in Sonoff RF Bridge. Then configure OpenHAB to send MQTT requests to switch RFKey1, RFKey2…RfKey16
  • You do not need configure RFKey at all. You use full 433MHz code that is captured by Sonoff RF Bridge and re-use it directly in MQTT requests. Bridge works as WiFi-to-433MHz gateway.

In both cases receiving MQTT messages and binding them to the Items is the same. To be more specific I mean getting input from devices which only send data one-way (PIR, weather station, temperature sensor, reed switch etc.)

I focus only on OpenHAB2 and MQTT plugin v2.x.

Scenario 1 – Separate RfKeyX

Let’s say that you were able to learn codes to Sonoff RF Bridge. There are 16 codes that can be programmed. In order to execute any of them we have to pass command RfKeyX where X is the value from 1-16. If key has code learned then it is executed.

Positive

MQTT act fast as RfKeyX has already saved in Sonoff RF Bridge Flash

Negative

You have to learn code in Sonoff RF Bridge first

.things

.items

.sitemaps

Scenario 2 – RfKeyX mapped to the button

In previous scenario in Sitemap file we have to use 2 separate buttons to handle one wireless switch. RfKey1 sent separate signal to ON and RfKey2 sent separate signal to OFF. If you use remote switch only in Rules then it doesn’t matter but if you want to have more human readable interface it is better to use traditional 1 switch button to handle 1 socket/relay.

I changed thing definition, separate for ON and OFF action. I use also different MQTT command: Backlog

Positive

MQTT act fast as RfKeyX has already saved in Sonoff RF Bridge Flash

Negative

You have to learn code in Sonoff RF Bridge first

In example below I skip common parts for Sonoff Bridge states, just focus on relevant changes.

.things

.items

.sitemaps

Scenario 3 – Sonoff Bridge as a Gateway

Sonoff Bridge may act as MQTT<WIFI>433MHz Gateway. We may manually define what 433MHz message should look like and send over the air. At the beginning it is good to learn codes and then view and re-use them in custom MQTT queries. To show details of learned code assigned to RFKey1 you may type in console:

RfKey1 6

Positive

MQTT act fast as RfKeyX has already saved in Sonoff RF Bridge Flash

Negative

You have to learn code in Sonoff RF Bridge first

.things

.items

.sitemaps

MQTT Debug

Sometimes we need to check what is happening inside Sonoff RF Bridge. For MQTT testing it is good to install Chrome plugin MQTTLens. Add broker and may either subscribe to topics or publish MQTT messages.

In other end, on the server side in order to get live logs you have to subscribe to all topics “#”. In case of mosquitto you may run the following:

Links

https://github.com/arendst/Sonoff-Tasmota/wiki/Commands

Promo

Now Sonoff smart devices are cheaper: SONOFF -15% OFF

You may also like...

4 Responses

  1. Edward says:

    Cześć
    Czy możesz pokazać jakie tematy masz wpisane w BridgeRF? Fajnie to widać w zakładce Information w Tasmocie. Niestety ale nie mogę ogarnąć tych tematów…
    Pozdrawiam.

  2. Bob B says:

    Thank you for this. Very helpful in pointing me in the right direction. I was able to trigger a Sonoff basic via a Key Fob. It took a while, but I was successful in my proof of concept to under OpenHab 2.5 and Tasmota 8.2.0. I am using the bridge as a gateway.

    Thank you. Besafe!

    Bob

  1. February 22, 2020

    […] signal in console. In my case “Data” values were static. I wrote down to use it in my existing OpenHAB thing […]

Leave a Reply

Your email address will not be published. Required fields are marked *