Sonoff RF BRIDGE with Tasmota - correct config with OH2

openhab2
mqtt
beginners
Tags: #<Tag:0x00007fe063523d20> #<Tag:0x00007fe063523bb8> #<Tag:0x00007fe063523a78>

(Jack) #1
  • Platform information:
    • Hardware: CPUArchitecture/RAM/storage
    • OS: what OS is used and which version
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version:
  • Issue of the topic: please be detailed explaining your issue
  • Please post configurations (if applicable):
    • Items configuration related to the issue
    • Sitemap configuration related to the issue
    • Rules code related to the issue
    • Services configuration related to the issue
  • If logs where generated please post these here using code fences:

(CM6.5 H102) #2

You didn’t provide much info.

See this topic.


(Jack) #3

I apologize for the previous post … its correct content disappeared somewhere :slight_smile:

Hello

I’m new here, I’m learning all the time and I need your help.

I have several touch switches with the option of RF 433MHZ control. I would like to control them by OH2.
I have Sonoff RF bridge with TASMOTA software with configured MQTT.

I have read many forum threads, Tasmota documentations… but I’m stuck all the time.

I found some similar threads on the forum, for example this one is very similar
https://community.openhab.org/t/sonoff-tasmota-rf-bridge-to-item-file/51076/18

How should the ITEMS RULEs configuration look like … if I know that a given switch is controlled by a paired remote control which sends code (read in the TASMOTA console) - button A

16:33:27 MQT: tele/sonoffbr/RESULT = {"RfReceived":{"Sync":12960,"Low":420,"High":1260,"Data":"4DD503","RfKey":"None"}}


(CM6.5 H102) #4

Will you be using the 1.x or 2.x mqtt binding? If planning to use the 1.x then make sure to turn on legacy bindings in PaperUI so the option to install is available.


(Jack) #5

I allready have instaled MQTT binding (binding-mqtt1 - 1.12.0)
because I use the MQTT protocol for communication with nodeMCU and sonoff Basic


(CM6.5 H102) #6

Looking at the link you posted above you have an example of the item.

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

For the rule change the name and use the correct number e.g. 4DD503

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

Change the name, Sonoff_Button, to suit your needs and test if it works. Check the logs for info on what may be the issue.

For your regular sonoff switch you will need to use something like this.

Switch Test_Sonoff "Test sonoff2" <light> (gSonoff) ["Lighting"] //swapped with CouchLight 11/19/18
	{ mqtt=">[pibroker:cmnd/sonoff4/POWER:command:*:default],
	<[pibroker:stat/sonoff4/POWER:state:default]" }

(Jack) #7

THX for another solution for regular sonoff switch - Sonoff Basic. I’II check it
This item code work great for me

Switch socket "Night Lamp" {mqtt="<[broker:/sonoff/nlamp/switch/cmd:command:ON:on] <[broker:/sonoff/nlamp/switch/cmd:command:OFF:off],<[broker:/sonoff/nlamp/switch/state:state:ON:on],<[broker:/sonoff/nlamp/switch/state:state:OFF:off]"}


(CM6.5 H102) #8

With the sonoff you shouldn’t need or use the leading slashes after the broker: like below. Also the first part should be cmnd or stat? But you have it working so who knows.:laughing:

Switch socket "Night Lamp" {mqtt="<[broker:sonoff/nlamp/switch/cmd:command:ON:on] <[broker:sonoff/nlamp/switch/cmd:command:OFF:off],<[broker:sonoff/nlamp/switch/state:state:ON:on],<[broker:sonoff/nlamp/switch/state:state:OFF:off]"}

(Jack) #9

back to the topic : )

in the code from the example

“S4CH04” is an element of “Item”
My guess is that it is channel # 4 from the 4-channel SONOFF switch

https://www.google.pl/search?client=opera&q=sonoff+4ch&sourceid=opera&ie=UTF-8&oe=UTF-8

How to define channels for such a switch in my case


(Jack) #10

or otherwise

how to force RF BRIDGE to send the code “4DD503” after switching the button in OH2 ???


(CM6.5 H102) #11

That is the item’s name. For using the rule above just replace the name with your item name e.g. socket.sendCommand(ON)


(CM6.5 H102) #12

With a rule and the RF code.

Example

rule "Code"
when
    Item Your_Button received update
then
    Your_Code_Item.sendCommand("4DD503")
end

(Jack) #13

OK I’ve got another solution. I would like use predefined codes of buttons 1-16 in tasmota
how code of item SWITCH … should like if in tasmota console I get this ?

19:46:38 MQT: stat/sonoffbr/RESULT = {"RfKey1":"Default sent"}

Something like this doesn’t work
Switch RF1 "TEST" {mqtt=">[broker:/cmnd/sonoffbr/RfKey1:command:ON:1], >[broker:/cmnd/sonoffbr/RfKey1:command:OFF:0]"}