OH3 Send Command using MQTT

I would like to send the command below using MQTT, I’m guessing the correct route would be using a rule, do I require a special binding.

Cant seem to find and help or info, any help appreciated.

cmnd/sonoffRFBridge/Backlog RfRaw AAB0210314016703F924180101011001100110010101100110011001010110010101100255; RfRaw 0

I use javascript and it looks like this:
events.sendCommand(“Fanceiling_Fanceiling”, ‘RfRaw AAB0150303014702872C920010101010110101010100110255; RfRaw 0’);

DSL rules:
sendCommand(FanCeiling2_FanCeiling2,“RfRaw AAB0150303014702872C920010101010110101010100110255; RfRaw 0”)

I forgot to say also that yes you need to set up mqtt binding and also set up your thing mqtt channel command topic like this:

Good luck

I will have a play and do some more reading.

This is a game changer!
I appreciate your help.

Hi Greg

I have to honest I am struggling!

I have setup a channel with to topic cmnd/RFBridge1//Backlog
am I barking up the right tree?

I then have a item set up as false switch

I then have a rule when false switch is on
run events.sendCommand(“RFBridge1”, RfRaw AAB0150303014702872C920010101010110101010100110255; RfRaw 0)

this brings up an error in logs
Script execution of rule with UID ‘Test’ failed: events.sendCommand( ___ “ ___ RFBridge1”, RfRaw AAB0150303014702872C920010101010110101010100110255; RfRaw 0 ___ )

Thanks for any help, I’m a bit green to all this, and docs are limited.

It’s important to put quotemarks around strings

Hi rossko57

I used your example and got following error

2021-03-15 23:15:49.330 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘Test’ failed: :1:19 Expected an operand but found error

events.sendCommand(“Fanceiling_Fanceiling”, ‘RfRaw AAB0150303014702872C920010101010110101010100110255; RfRaw 0’);

               ^ in <eval> at line number 1 at column number 19

Not my example. What rule language are you writing in?

Are you using javascript rule?

This is my fan thing:

The item is just a string item.

I just created a javascript rule and this was the only thing I put in it:

 events.sendCommand("Fanceiling_Fanceiling", 'RfRaw AAB01503030143028B2C920010101010110101010101001255; RfRaw 0');

Then I pressed the run now button down the bottom left and it worked.

You can do the same but change the FanCeiling_fanCeiling to the name of your item.
and also put your AAB etc code in and see what happens.

Hi, I’m still struggling, sorry I must be really thick ;), despite your patience with me.

yes I’m using javascript

Are you adding a channel to RFBridge or Adding a completely new thing and the adding channel,

I have the rule working ish no errors now.
I just cant seem to get my head around the flow.

Thanks again,

I am assuming you have the thing and item already set up.
So you just copy and paste the line of code that I sent into a brand new rule.
Change the item name in the rule to your item name and if you want put your rf code in there as well and then press the run button and see what happens.

Finally got my head around it, thanks for your help, I near gave up :wink:

My Garage now goes up,down and stops.


Can you put how you did it up on the forum in case someone wants to do the same thing? Also I would like to know how you did it as well.

Of course, will put something together this week, I will also try to put a YouTube video up, I’m not a programmer and there doesn’t seem to be much info about.

I am not a programmer either.

Here is a YouTube I did that uses OH and sonoff and small display.

This YouTube is the one that is similar you what you are doing and uses the rfraw etc: