Sonoff (tasmota) RF Bridge to item file

Now it is working… the full code is:

rule "Button Pressed"
when
    Item Sonoff_Button received update // Need received update if Data has not changed but button still pressed
then
    Thread::sleep(100) // Need the sleep to allow for the state to change
    if (Sonoff_Button.state == "6A8CD2") {
        if (S4CH04.state == ON || S4CH04.state == NULL) { S4CH04.sendCommand(OFF) }
        else { S4CH04.sendCommand(ON) }
    }
end

And Item:

//RF Bridge
String Sonoff_Button { mqtt="<[broker:tele/sonoff_rf/RESULT:state:JSONPATH($.RfReceived.Data)]" }

now the next question… I have one more switch in my rf button, that sends another code… what is best practise then?? make another file rule, similar to this one, and with other data, or can I continue in this rule, with another RF code…?

Maybe this code snipplet i use helps you.
I control with a Rf Remote (which sends a different code for every button on it) sonoff device (s):


rule "RF433 switch sonoff and Update RF Switch (Bridge 1)"
when
    Item RfBridge_RfReceive changed
then
if (RfBridge_RfReceive.state == NULL)
    {
    logInfo("RfBridge1.rules", "Item is null, cancelling...")
    return;
    } 
    var rfData = RfBridge_RfReceive.state.toString
    logInfo("rfbridge1.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")
                }
        	case "85D5CC":
        	    {
			    Pir433.sendCommand(ON)
			    }                   
            case "150551":
               {
				postUpdate(WohnFluter, ON)
                }
            case "150554":
                {
				postUpdate(WohnFluter, OFF)
                }   
            case "151151":
               {
				postUpdate(SchrankLicht, ON)
                }
            case "151154":
                {
				postUpdate(SchrankLicht, OFF)
                }   
            case "151451":
               {
				postUpdate(SchrankTechni, ON)
                }
            case "151454":
                {
				postUpdate(SchrankTechni, OFF)
                }   
            case "151511":
               {
				postUpdate(Glaskugel, ON)
                }
            case "151514":
                {
				postUpdate(Glaskugel, OFF)
                }   
            case "151541":
               {
				postUpdate(Leselampe, ON)
                }
            case "151544":
                {
				postUpdate(Leselampe, OFF)
                }   
            case "150151":
               {
				postUpdate(SideRechts, ON)
                }
            case "150154":
                {
				postUpdate(SideRechts, OFF)
                }   
            case "151051":
               {
				postUpdate(Salzlampe, ON)
                }
            case "151054":
                {
				postUpdate(Salzlampe, OFF)
                }   
            case "3575C0":
               {
				postUpdate(Schlafzimmer, ON)
                }
            case "35750C":
                {
				postUpdate(Schlafzimmer, OFF)
                }   
    }
 rfData=""
 RfBridge_RfReceive.postUpdate(rfData)
end

Yep!
If you have just another one of two buttons then if then will be enough
More than that it will get confusing and use the case switch

rule "Button Pressed"
when
    Item Sonoff_Button received update // Need received update if Data has not changed but button still pressed
then
    if (Sonoff_Button.state == NULL) return; //Do nothing if NULL
    Thread::sleep(100) // Need the sleep to allow for the state to change
    if (Sonoff_Button.state == "6A8CD2") {
        if (S4CH04.state == ON || S4CH04.state == NULL) { S4CH04.sendCommand(OFF) }
        else { S4CH04.sendCommand(ON) }
    }
    if (Sonoff_Button.state == "6A8CD8") {
        if (otherSwitch.state == ON || otherSwitch.state == NULL) { otherSwitch.sendCommand(OFF) }
        else { otherSwitch.sendCommand(ON) }
    }
end

Hi did you manager to get this to work with MQTT 2.5

Regards

Will this string item work for the MQTT 2?

Not sure what you mean but the binding version should not make a difference

I’m asking because of this thread:

so at the “new MQTT” the items originally should be changed to something that refers to channels as you see at the Sonoff_RF examples.

Paulo