[SOLVED] Sonoff RfBridge Button setup

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

Hello again,

I have done the last things you mentioned but they sonoff isn’t seeing any messages published. If I subscribe to the topic in my MQTT viewer the messages also aren’t coming through.

Here’s my configuration files:

Projector.items -

Switch TVScreen
String TVScreenCommand { channel="mqtt:topic:mosquitto:genericthing:tvscreen" }

mqtt.things

 mqtt:broker:mosquitto [ host="127.0.0.1",secure=false, username="openhab", password="habopen" ]

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/rfraw" ]
    }
}

projector.rules

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

default.sitemap

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

The only thing I can think I had to input into your example config was the channel name. The channel name was the generic mqtt string thing from paper ui: mqtt:topic:mosquitto:genericthing:tvscreen

Any ideas why this might not be working?

the logs show the following

14:19:51.984 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TVScreen' received command ON
14:19:51.997 [INFO ] [smarthome.event.ItemStateChangedEvent] - TVScreen changed from OFF to ON
14:19:52.032 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TVScreenCommand' received command AAB03C04081374027600DC13BA381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A192A19292A192A19292955
14:19:52.038 [INFO ] [arthome.event.ItemStatePredictedEvent] - TVScreenCommand predicted to become AAB03C04081374027600DC13BA381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A192A19292A192A19292955
14:19:52.055 [INFO ] [smarthome.event.ItemStateChangedEvent] - TVScreenCommand changed from AAB03C0408137E026C00DC13A6381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A1A1A19292A192A192A1955 to AAB03C04081374027600DC13BA381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A192A19292A192A19292955
14:20:15.788 [INFO ] [smarthome.event.ItemStateChangedEvent] - Michael_iPhone changed from OFF to ON
14:20:15.801 [INFO ] [smarthome.event.ItemStateChangedEvent] - Michael_Response_Time changed from UNDEF to 22.0
14:21:20.843 [INFO ] [smarthome.event.ItemStateChangedEvent] - Michael_iPhone changed from ON to OFF
14:21:20.853 [INFO ] [smarthome.event.ItemStateChangedEvent] - Michael_Response_Time changed from 22.0 to UNDEF
14:21:26.327 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TVScreen' received command OFF
14:21:26.357 [INFO ] [smarthome.event.ItemStateChangedEvent] - TVScreen changed from ON to OFF
14:21:26.365 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TVScreenCommand' received command AAB03C0408136A027600DC13C4381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A192929292929292A1A19292A19292A1A1955
14:21:26.375 [INFO ] [arthome.event.ItemStatePredictedEvent] - TVScreenCommand predicted to become AAB03C0408136A027600DC13C4381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A192929292929292A1A19292A19292A1A1955
14:21:26.383 [INFO ] [smarthome.event.ItemStateChangedEvent] - TVScreenCommand changed from AAB03C04081374027600DC13BA381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A192A19292A192A19292955 to AAB03C0408136A027600DC13C4381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A192929292929292A1A19292A19292A1A1955
14:21:31.376 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'TVScreenCommand' received command AAB03C0408137E026C00DC13A6381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A1A1A19292A192A192A1955
14:21:31.385 [INFO ] [arthome.event.ItemStatePredictedEvent] - TVScreenCommand predicted to become AAB03C0408137E026C00DC13A6381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A1A1A19292A192A192A1955
14:21:31.395 [INFO ] [smarthome.event.ItemStateChangedEvent] - TVScreenCommand changed from AAB03C0408136A027600DC13C4381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A192929292929292A1A19292A19292A1A1955 to AAB03C0408137E026C00DC13A6381929292929292929292929292929292929292A192A1A1A1A192A1A1929292A1A1929292929292A1A1A19292A192A192A1955

If you are on 2.4 you need to restart openHAB after modifying the things file.

Aha the good old restart! Works as expected! Thank you very much for your help!

please tick the solution, thanks

Hello,

i hope you can help me, i will do the same, but with the cmnd/Sonoff-RF-Bridge/Backlog command.

this is my last thing i have to change to the mqtt 2.4 version.

i have a intertechno cmr 1000 with 433mhz that i will use.

this was my working mqtt v1 config:

Rollershutter Rollershutter_GF_Living_1    					"Wohnzimmer Links"  							<rollershutter>	(GF_Living, Shutterswz) 					{ mqtt=">[mosquitto:cmnd/Sonoff-RF-Bridge/Backlog:command:up:RfSync 11310; RfLow 360; RfHigh 1050; RfCode #000015],>[mosquitto:cmnd/Sonoff-RF-Bridge/Backlog:command:down:RfSync 11310; RfLow 360; RfHigh 1060; RfCode #000014]" }

what i have tried with the mqtt v2.4 binding:

Type switch : switchrfA "Wohnzimmer Links"   	   [ stateTopic="stat/Sonoff-RF-Bridge/RESULT", commandTopic="cmnd/Sonoff-RF-Bridge/Backlog", UP="RfSync 11310; RfLow 360; RfHigh 1050; RfCode #000015", DOWN="RfSync 11310; RfLow 360; RfHigh 1060; RfCode #000014"]
Rollershutter Rollershutter_GF_Living_1    					"Wohnzimmer Links"  							<rollershutter>	(GF_Living, Shutterswz) 					{channel="mqtt:topic:mosquitto:Sonoff_RF_GF_Living:switchrfA", autoupdate="false"}

on that i got no error, in the logs i see the item is changing to UP and DOWN, but no rf command is sending…

and secound try:

Type string : switchrfA "Wohnzimmer Links"   	   [ stateTopic="stat/Sonoff-RF-Bridge/RESULT", commandTopic="cmnd/Sonoff-RF-Bridge/Backlog", on="RfSync 11310; RfLow 360; RfHigh 1050; RfCode #000015", off="RfSync 11310; RfLow 360; RfHigh 1060; RfCode #000014", on="UP", off="DOWN" ]
String Rollershutter_GF_Living_1    					    "Wohnzimmer Links"  							<rollershutter>	(GF_Living, Shutterswz) 					{channel="mqtt:topic:mosquitto:Sonoff_RF_GF_Living:switchrfA", autoupdate="false"}
Switch item=Rollershutter_GF_Living_1 mappings=[ON="UP", OFF="DOWN"] label="Rollo Links"

here the same.

the ,on=“UP”, off=“DOWN” in the thing file i have only on one, on a secound i have it without this, is also not woking!
i dont know how do i need to write this that its working :neutral_face:

i can receive rf data with the mqtt 2.4 binding

Did you check what is actually being published to the MQTT broker?
Use MQTT Explorer