[SOLVED] Sonoff RfBridge Button setup

I’m using a sonoff RF bridge to control my projector screen. I have the following RF codes that control the screen

up
rfraw AAB03C04081374027600DC13BA381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A192A19292A192A19292955

stop
rfraw AAB03C0408137E026C00DC13A6381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A1A1A19292A192A192A1955

down
rfraw AAB03C0408136A027600DC13C4381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A192929292929292A1A19292A19292A1A1955

What I want is two buttons in my UI: Projector down and Projector Up.

When the Projector down is pressed I would like to send the down code, sleep for X seconds, then send the stop code. The Projector up code just needs to send the up code.

Could someone point me in the right direction as I am struggling with this.

Thanks.

1 Like

That involves quite a lot actually.

You need to install the MQTT binding to work with the sonoff.
Is that done?

I had a feeling that was the case.

Yep I have mosquitto all up and running and the mqtt binding installed and configured. I can publish and subscribe to a test topic from an external machine.

Ok, go through this:

And then: MQTT - Bindings | openHAB and MQTT Things and Channels - Bindings | openHAB for more details on how to set-up mqtt with OH

Also, this might help:

and:

When you get to the stage of sending RF commands to the tasmota from OH then we’ll go though the rule that you need for the delay that you mentioned in your first post

Ok thanks. Will give it a go when I get home from work. Thanks.

Give it a go.
Best way to learn.
If you get stuck, post what you tried and we’ll try to get you there.

Ok I’ve followed both of those pages and now have a MQTT Broker thing defined and connected to my MQTT broker.

Am I ready for the next part?

Yes, create a MQTT generic thing and then create a string channel to send a value on the topic the sonoff RF listens to

is this right?

Bridge mqtt:broker:mosquitto [ host="localhost", secure=false, username="openhab", 
password="habopen" ]
{
    Thing topic genericthing {
    Channels:
        Type string : tvscreen "TV Screen" [ stateTopic="tasmota/cmnd/sonoff-rfbridge/" ]
    }
}

Probably not.
What topic do you need to publish to for the sonoff to send the RF command?

Then it would be: commandTopic=the/topic

Without \ at the end

the bridge is setup to listen to the tasmota/cmnd/sonoff-bridge/ topic,

so my setup should be:

Bridge mqtt:broker:mosquitto [ host="localhost", secure=false, username="openhab", password="habopen" ]
{
    Thing topic genericthing {
    Channels:
        Type string : tvscreen "TV Screen" [ commandTopic="tasmota/cmnd/sonoff-rfbridge" ]
    }
}

my sonoff mqtt config is the following:

MQTT Host 192.168.1.xxx
MQTT Port 1883
MQTT User openhab
MQTT Client sonoff-rfbridge
MQTT Topic sonoff-rfbridge
MQTT Group Topic sonoffs
MQTT Full Topic tasmota/cmnd/sonoff-rfbridge/
MQTT Fallback Topic cmnd/sonoff-rfbridge_fb/

Ok, looks ok.

What happens when you send a command AAB03C04081374027600DC13BA381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A192A19292A192A19292955 to the topic?

Use an MQTT utility like MQTTfx, MQTTspy or even MQTT explorer (New kid on the block and brilliant)

Ok if I publish the following

tasmota/cmnd/sonoff-rfbridge/command:ON:rfraw AAB03C04081374027600DC13BA381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A192A19292A192A19292955

I see this in the sonoff console:

22:06:49 MQT: tasmota/stat/sonoff-rfbridge/RESULT = {"Command":"Unknown"}

Ok, you need to find out what is a valid command. This will be in the tasmota wiki or here in the forum if someone has used the sonoff rf before

Ok figured it out.

If I publish to the topic

tasmota/cmnd/sonoff-rfbridge/rfraw

with payload

AAB03C04081374027600DC13BA381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A192A19292A192A19292955

The screen operates as I expect.

1 Like

Excellent!! Well done
Change the thing as follow:

        Type string : tvscreen "TV Screen" [ commandTopic="tasmota/cmnd/sonoff-rfbridge/rfraw" ]

So next step, create a file called sonoffrf.map in the tranform folder with the following content:

up=AAB03C04081374027600DC13BA381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A192A19292A192A19292955
stop=AAB03C0408137E026C00DC13A6381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A1A1A19292A192A192A1955
down=AAB03C0408136A027600DC13C4381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A192929292929292A1A19292A19292A1A1955

Which UI are you using?

1 Like

Ok, done both of those things.

I use the basic ui currently. Config files rather than paper ui for config.

Ok, so you need two elements on your sitemap and one switch item:
You also need to link the sonoff channel to an item
item first
in an items file:

Switch TVScreen
String TVScreenCommand { channel="xxxxxxxxx" } // Copy the channel from the paperUI

In the sitemap:

Switch item=TVScreen label="TV Screen UP" mappings=[ON="UP"]
Switch item=TVScreen label="TV Screen DOWN" mappings=[OFF="DOWN"]

And then 2 rules in a rules file:

rule "TV Screen UP"
when
    Item TVScreen received command ON
then
    TVScreenCommand.sendCommand(transform("MAP", "sonoffrf.map", "up"))
end

rule "TV Screen DOWN"
when
    Item TVScreen received command OFF
then
    TVScreenCommand.sendCommand(transform("MAP", "sonoffrf.map", "down"))
    createTimer(now.plusSeconds(5), [ |
        TVScreenCommand.sendCommand(transform("MAP", "sonoffrf.map", "stop"))
    ])
end
1 Like

Sound simple enough. Signing off for the night so will give it a try in the morning and let you know! Thanks for your help!

A pleasure to help some eager to learn and find out stuff by themselves