[SOLVED] Receiving 433mhz and send to sonoff switch

Create Items bound it looked to the 433 binding. You will have other items bound to Matt for the Sonoff switches (assuming you flash Tasmota on the switches).

Then create rules that trigger when the 433 Items receive a command from the remote and issues the appropriate command to the Sonoff.

If the 433Mhz Binding does not work for you. There is an additional way to do it.

Maybe this helps.

  1. Sett up OpenHAB to be able to recieve 433MHz data
  2. Make a Rule and send Something to your SONOFF.

jsut some additional info if you want to use your RPI to send to 433MHz devices.

Thank you both for your answers.

To send the On/Off command from openhab to the sonoff/tasmota,
Is it possible to use the web command instead of the MQTT stack ?

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

Web

Commands can be executed via HTTP requests, for example:

http://sonoff/cm?cmnd=Power%20TOGGLE
http://sonoff/cm?cmnd=Power%20On
http://sonoff/cm?cmnd=Power%20off
http://sonoff/cm?user=admin&password=joker&cmnd=Power%20Toggle

@aymeric106 maybe with the http binding?

https://docs.openhab.org/addons/bindings/http1/readme.html

Maybe this helps. My setup with a sonoff bridge used for receiving and switching 433 devices:

Items

Number RfBridge_RSSI "RfBridge: RSSI [%d %%]" (gRSSI)
    { mqtt="<[broker:tele/sonoff-8E8329/STATE:state:JSONPATH($.Wifi.RSSI)]" }
String RfBridge_Up "RfBridge: Uptime [%s]" (gUptime)
    { mqtt="<[broker:tele/sonoff-8E8329/STATE:state:JSONPATH($.Uptime)]" }
String RfBridge_RfReceive "RfReceive [%s]"
    { mqtt="<[broker:tele/sonoff-8E8329/RESULT:state:JSONPATH($.RfReceived.Data)]" }    

           

Switch WohnFluter       "Wohnz. Fluter"         <light> (LR,gLight)     [ "Lighting" ] 
		{ mqtt=">[broker:cmnd/sonoff-8E8329/Backlog:command:ON:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #150551],
                >[broker:cmnd/sonoff-8E8329/Backlog:command:OFF:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #150554]" }

Switch SchrankLicht     "Schrankwand Licht"     <light> (LR,gLight)     [ "Lighting" ] 
		{ mqtt=">[broker:cmnd/sonoff-8E8329/Backlog:command:ON:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #151151],
                >[broker:cmnd/sonoff-8E8329/Backlog:command:OFF:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #151154]" }

Switch SchrankTechni    "Schrankwand Technik"  (LR,gLight)              [ "Lighting" ] 
		{ mqtt=">[broker:cmnd/sonoff-8E8329/Backlog:command:ON:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #151451],
                >[broker:cmnd/sonoff-8E8329/Backlog:command:OFF:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #151454]" }

Switch Glaskugel        "Glaskugel"             <light> (LR,gLight)     [ "Lighting" ] 
		{ mqtt=">[broker:cmnd/sonoff-8E8329/Backlog:command:ON:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #151511],
                >[broker:cmnd/sonoff-8E8329/Backlog:command:OFF:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #151514]" }

Switch Leselampe        "Leselampe"             <light> (LR,gLight)     [ "Lighting" ] 
		{ mqtt=">[broker:cmnd/sonoff-8E8329/Backlog:command:ON:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #151541],
                >[broker:cmnd/sonoff-8E8329/Backlog:command:OFF:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #151544]" }

Switch SideRechts       "Sideboard rechts"      (LR,gLight)             [ "Lighting" ] 
		{ mqtt=">[broker:cmnd/sonoff-8E8329/Backlog:command:ON:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #150151],
                >[broker:cmnd/sonoff-8E8329/Backlog:command:OFF:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #150154]" }

Switch Salzlampe        "Salzlampe"             <light> (LR,gLight)     [ "Lighting" ] 
		{ mqtt=">[broker:cmnd/sonoff-8E8329/Backlog:command:ON:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #151051],
                >[broker:cmnd/sonoff-8E8329/Backlog:command:OFF:RfSync 11320; RfLow 360; RfHigh 1090; RfCode #151054]" }

Switch Schlafzimmer     "Schlafzimmer"          <light> (LR,gLight)     [ "Lighting" ]
		{ mqtt=">[broker:cmnd/sonoff-8E8329/Backlog:command:ON:RfSync 12880; RfLow 420; RfHigh 1270; RfCode #3575C0],
                >[broker:cmnd/sonoff-8E8329/Backlog:command:OFF:RfSync 12880; RfLow 420; RfHigh 1270; RfCode #35750C]" }

Rules (Rf Remote Switches Sonoffs)


rule "RF433 switch sonoff"
when
    Item RfBridge_RfReceive changed
then
if (RfBridge_RfReceive.state == NULL)
    {
    logInfo("RfBridge.rules", "Item is null, cancelling...")
    return;
    } 
    var rfData = RfBridge_RfReceive.state.toString
    logInfo("rfbridge.rules", "Received IT Codes: " + rfData)
        switch (rfData) {         
            case "A00A1F":
               {
                publish("broker", "cmnd/sonoff-13D92F/POWER", "ON")
                }
            case "A00A17":
                {
                publish("broker", "cmnd/sonoff-13D92F/POWER", "OFF")
                }
            case "A00A1B":
               {
                publish("broker", "cmnd/sonoff-065CA6/POWER", "ON")
                }
            case "A00A13":
                {
                publish("broker", "cmnd/sonoff-065CA6/POWER", "OFF")
                }
            case "A00A1D":
               {
                publish("broker", "cmnd/sonoff-101AEE/POWER", "ON")
                }
            case "A00A15":
                {
                publish("broker", "cmnd/sonoff-101AEE/POWER", "OFF")
                }                
            case "A00A1E":
               {
                publish("broker", "cmnd/sonoff-5DE6D5/POWER", "ON")
                }
            case "A00A16":
                {
                publish("broker", "cmnd/sonoff-5DE6D5/POWER", "OFF")
                }               
    }
 RfBridge_RfReceive.postUpdate(rfData)
end
2 Likes

Yes thanks, found it here …

Aymeric

Thanks for the script, I didn’t know the rfbridge was also tasmota flashable, This may help the range issue I have with the cheap 433Mhz receiver I bought.

Comment to post Sonoff + tasmota firmware + http binding

Maybe it looks at the first step easier. But if you want to know the state off the switch than this way is complicated, perhaps interesting things are not possible.
OpenHab with mqtt gives you a professional tool in your hands. Working with that is at the beginning harder but worth the effort…

The RF Bridge works very nice with tasmota. It is a perfect WLAN driven RF433 Basis and Repeater. The Transmitter is very strong. Better than a CUL or a cheap RF 433 Modul…

With the tag [ “Lighting” ] you make your 433 Poweroutlets voice switchable via ALEXA.
Just install Alex Bindig and after a search for new devices the will apear :slight_smile:

At banggood it costs only about 10 Euro…

Thanks again for your scripts, very useful :slight_smile:
I’ve got to questions for you:

Why did you add

RfBridge_RfReceive.postUpdate(rfData)

at the end of the rule ? What should it do ?

Other question : if i understand correctly, you’ve got two buttons for each light, one ON and one OFF.

In my case I’ve got on transmitter to toggle ON and OFF
Your rule kicks in when

when
Item RfBridge_RfReceive changed

But in my case it only changes once, because next time you push the button, it’s still the same button that is triggered (same frequency) . How would you reset the state of the RfBridge_RfReceive item after the light have been turn On or Off ?

Thank you
Aymeric

Your questions later is the answer what RfBridge_RfReceive.postUpdate(rfData) does. With that i dont fire the rule a second time if i press the same button of the remote again. The item status is the same and rule cancels here working:
Item RfBridge_RfReceive changed
For your case change the postUpdate to a dummy value. Check for this dummy value in the cancelling part
So every key press triggers the rule because item RfBridge_RfReceive has changed on every key press

You have a rf remote with just one button?
With that you want to switch something on / off?
Than my rule isnt the solution for you.
You have to set a flag in the which stores the state off the lamp and check this.

Here are my final configurations files.
Basically, 1 sonoff switch (tasmota firmware), 1 sonoff bridge (tasmota firmware), 1 remote control with 1 button. Each time the button is pushed, the Sonoff switch toggles between On and Off.

Thank you everybody for your help :wink:

maison.sitemap

sitemap maison label="MAISON" {

	Switch item=SONOFF_LAMPE_TABLE icon="light"
	Text item=SONOFF_BRIDGE_RfReceive label="Last incoming RF code"  icon="remotecontrol"
}

sonoff.items


String SONOFF_BRIDGE_RfReceive "Bridge SONOFF RfReceive [%s]"
    { mqtt="<[broker:SONOFF/tele/SONOFF_BRIDGE/RESULT:state:JSONPATH($.RfReceived.Data)]" } 

//Sonoff Basic 
Switch SONOFF_LAMPE_TABLE "Lampe Table" <light> (LR,gLight)
    { mqtt=">[broker:SONOFF/cmnd/SONOFF_LAMPE_TABLE/power:command:*:default],
            <[broker:SONOFF/stat/SONOFF_LAMPE_TABLE/POWER:state:default]" }

sonoff_bridge.rules

rule "SONOFF BRIDGE"
when
    Item SONOFF_BRIDGE_RfReceive changed 
then
if (SONOFF_BRIDGE_RfReceive.state == NULL)
    {
    logInfo("rule SONOFF BRIDGE", "Item is null, cancelling...")
    return;
    } 
    var rfData = SONOFF_BRIDGE_RfReceive.state.toString
    logInfo("rule SONOFF BRIDGE", "Incoming RF code: " + rfData)
        switch (rfData) {         
            case "066661":
               {
		if (SONOFF_LAMPE_TABLE.state == ON)
			{
			logInfo("rule SONOFF BRIDGE", "-> SONOFF_LAMPE_TABLE.sendCommand(OFF)")
			SONOFF_LAMPE_TABLE.sendCommand(OFF)
			}
        	else
			{
			logInfo("rule SONOFF BRIDGE", "-> SONOFF_LAMPE_TABLE.sendCommand(ON)")	
			SONOFF_LAMPE_TABLE.sendCommand(ON)
			}

		// Reset Last Received Code
		rfData=""
		SONOFF_BRIDGE_RfReceive.postUpdate(rfData)
		}
                       
    	}
  

end
3 Likes

Clear and simple (=always good) rule. Nice done!

Interesting thread.

Do you think it would be possible to get the info from the RF devices of this weather station?

I dont think it is possible with the Sonoff RF Bridge. The used (unknow?!) protocol of the weather station isnt supported by the bridge. The bridge can only decode some protocols…
May you have more luck using a self build nanoCUL433 Mhz. There is a OpenHab binding.
The German Project FHEM has decoded many protocols. If you speak german take a look at the FHEM site.

ok, so the idea is to install a 433 receiver in the RP and try to decode…

I speak a little German, no so much, but I will have a look.
Thanks.

Blockquote
I dont think it is possible with the Sonoff RF Bridge. The used (unknow?!) protocol of the weather station isnt supported by the bridge. The bridge can only decode some protocols…
Blockquote

You may try to flash Portisch to get more supported protocols or different project called Rflink

I went through different topics on this forum and decided to put all together. I wrote a post here if somebody needs tutorial step by step how to configure Sonoff Bridge with OpenHAB with no rules.

1 Like

Also another idea. For controlling a switch through one RF key, you can use the tasmota “TOGGLE” command on the switch.
Watch out. Openhab switch items only support the ON, OFF or UNDEF states.
So, i use the MQTT Action to send the TOGGLE MQTT payload.

or UNDEF.

1 Like