SOLVED! Sonoff Rf Bridge Sensor Setup Help!

Im at my witts end with trying to fingure this out. copied a solution and altered to suit my situation but still not working. rf code is received by Sonoff bridge and is sending an mqtt message which appears on my iOS mqtttool app but nothing happens in openHAB. Not a single log input shows regarding the items.please advise!!!

things file,

Type contact : FrontDoor   "Front Door"          [ stateTopic="tele/Sonoff_Bridge/RESULT", transformationPattern="JS:FrontDoor.js"]
Type contact : RearDoor "Rear Door"        [ stateTopic="tele/Sonoff_Bridge/RESULT", transformationPattern="JS:RearDoor.js"]
}```

items file,

Contact Sonoff_Bridge_Front_Door  "Front Door: [%s]"            <frontdoor>           { channel="mqtt:topic:Sonoff_Bridge:FrontDoor" }
Contact Sonoff_Bridge_Rear_Door  "Rear Door: [%s]"            <door>           { channel="mqtt:topic:Sonoff_Bridge:RearDoor" }

sitemap,

Frame label="Security"   {
               Text item=Sonoff_Bridge_Front_Door
               Text item=Sonoff_Bridge_Rear_Door
         }

transform file

(function(jsonString) {
    var data = JSON.parse(jsonString);
    var door = data.RfReceived.Data;
    if (door === null) door = UNDEF;
    if (door == '2BC00A') door = 'OPEN';
    if (door == '2BC00E') door = 'CLOSED';
    return door;
})(input

anybody?

You did not post your full .things file, or if you did it is improperly formed.

Do you have a Bridge defined? Does the Bridge show as online in PaperUI?

Why don’t you delete that things file and create your thing with the paperUI?

That is the first 2 lines in the things file all that is missing is the { at the start and no I don’t have the bridge defined as a thing?

When I’ve tried to a the bridge as a thing via Paper UI it asks me to choose a binding and the only binding available to choose is the WiFiled binding

You must have a Broker Thing defined. This will act as the Bridge and represents OH’s connection to the MQTT broker.

Then you do not have the MQTT binding installed. You can’t do MQTT without the MQTT binding.

I strongly agree with Vincent, you would be better off working through PaperUI. And in the future, if you don’t see something in PaperUI you expect, like there was no ability to create MQTT Things, you should stop there and look for why, because that indicates that there is a problem.

I am already using mqtt to control other Sonoff devices succefully with the version 1 binding. Does this mean I will need to install version 2? Also include legacy 1.x binding is checked

Then you either need to configure your Item using the MQTT 1.x syntax (no Things) or you need to install the 2.4 version and configure it appropriately. The two can live side by side. See the MQTT 2.4 docs and search the forum for many examples and tutorials.

Ok so I’ve installed the 2.0 binding and have set up the bridge as a thing in the Paper UI linked it to the broker and added 2 channels Front_Door_Sensor and Rear_Door_Sensor they both have the mqtt topic incoming set to tele/Sonoff_Bridge/RESULT. Would you be able to point me in the right direction as to how I need to update my items sitemap and transform files?

Since your Items are in .items files, I recommend the Text File Linking section.

Ok I’ve changed my items to have the channel Id of the relevant sensor. But how do I link the .js file to the channel? Can I just put /etc/openhab2/transform/FrontDoor.js in the incoming value transformation field?

These are my new items
Contact Sonoff_Bridge_Front_Door "Front Door [%s]" <frontdoor> { channel="mqtt:topic:bc732646:1" } Contact Sonoff_Bridge_Rear_Door "Rear Door: [%s]"<door>{ channel="mqtt:topic:bc732646:2" }

Is this a transform on the data coming in or going out.

If you want to transform the data coming from the topic, you put the transform on the Channel config.

You will have to click on “Show more” to see the field in PaperUI.

I don’t think the binding supports outgoing transforms at this time.

It’s a transform for the data coming in. I have 2 transform files FrontDoor.js and RearDoor.js so in the incoming value transformation field I’ve put JS:FrontDoor.js not to see if it works!

Any chance you can share your final configuration. I just reprogrammed the Sonoff RF Bridge and I would like to leverage the sensors in Openhab. I tried using MQTT 2.4 but it goes offline after some time and I need to reboot Openhab. I’m thinking of falling back on MQTT 1.x since it works reliably.

I recommend trying the OH 2.5 M1 version before going back to the 1.x version of the binding. There are a ton of fixes that were added in that short month between the release and that first milestone.

Give me a couple of hours and I will post what I have done for you when I return from work :grinning: