Openhab and Sonoff Switch

hi
i have a sonoff and i want to command it from openhab by rasberry pi.
This is the configuration of the sonoff:

mqtt.cfg:

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
 localbroker.url=tcp:the ip of the raspberry:1883
 # Optional. User id to authenticate with the broker.
 localbroker.user=openhabian
 # Optional. Password to authenticate with the broker.
 localbroker.pwd=the password

sonoff.items

Switch LivingRoom_Light "Interruttore WiFi Sonoff" <light> (LR,gLight)
 { mqtt=">[localbroker:cmnd/sonoffSERCAM/POWER:command:*:default],
 <[localbroker:stat/SONOFFsercam/POWER:state:default]" } 

sonoff.sitemap

sitemap sonoff label="Sonoff" {
 Frame label="Sonoff" {
 Switch item=LivingRoom_Light
 }
 }

I have the following add on:
MQTT Action
MQTT Binding 2,4
MQTT Persistence
JSONPath Transformation

The problem is that from openhab i am not able to control the sonoff.

Can you hlep me ?

Please read in Here.
You are doing the same mistake by using the syntax of the MQTT 1 binding while having the MQTT 2.4 binding installed.

ok
i followed the topic and i changed the sonoff.item so:

Switch LivingRoom_Light "Interruttore WiFi Sonoff" <light> (LR,gLight)
 {channel="mqtt:topic:b7bb37dc:Power1"} 

but i continue to have problem to command by the bottom of openhab the sonoff.

I report the images of my openhan





Now by MQTT.fx i am able to se the message that the switch of openhab send but the sonoff don’t change the status

If using files try changing the item channel to:

Switch LivingRoom_Light "Interruttore WiFi Sonoff" <light> (LR,gLight)
 {channel="mqtt:topic:localbroker:b7bb37dc:power1"} 

You may need to post your Things file if the above doesn’t work.

Thanks Now it work.
I want to command a sonoff dual but in this way i command only 1 exit.
Can you help me?

You have created a channel for Power1, do the same for Power2.

I did bur it doesn’t work

These are the configs of my two switches of the Sonoff dual

this is the result


when i push one also the other turn on but i setted the interlock.
I command the same

this is my sonoff.items

Switch LivingRoom_Light "Interruttore WiFi Sonoff" <light> (LR,gLight)
 {channel="mqtt:topic:b7bb37dc:Power1"}

But i must create another file for the second switch?

The other problem is i can only turn off but not turn on

can you show me your configuration please?

Sorry, but I do not understand. When pushing Power1 to On the second light switches to On also? What do you try to say by:" but i setted the interlock"?
You need another item for Power2, it can be setup in the same file as the other item(s).

Does the switch not toggle to OFF or does the sitemap icon stay in the ON position?

I did my item config by files, but the screencopy of PaperUI shows the result.
My items config for Power1 is basically the same as yours, I have a second one for Power2

BTW: You do not need the MQTT action and persistence binding.

The cases are:
1)sonoff has the 1 switch to on. If i push on the switch in openhab it works (the switch go to off)

2)sonoff has the 1 switch to off. if i push on the switch in openhab the switch go first to on and then to off.

Could you post the log entries you are getting in the case 2.)

now the sonoff.items:

Switch LivingRoom_Light "Interruttore WiFi Sonoff" <light> (LR,gLight)
 {channel="mqtt:topic:b7bb37dc:Power1"}


Switch LivingRoom_Light "Interruttore 2 WiFi Sonoff" <light> (LR,gLight)
 {channel="mqtt:topic:b7bb37dc:Power2"}

and in openhab






before to switch from openhab to on the log viewer is

after i switch to on the 1 and the 2 go to on

You have both items with the SAME name!
You have to have each item with an unique name!
Can’t say if that solves all the problems.

Please, when showing logs copy and paste only the needed lines!