Openhab configuration for Sonoff switches

Hi,
I have flashed my sonoff 4ch pro with tasmota firmware and using mqtt.fx i can flawlessly control my sonoff switches but i am having trouble with configuring in openhab2 items and sitemaps as the switches wont work though they are displaying in the sitemap. Any help is appreciated

1 Like

What mqtt binding are you using, 1.x or 2.x? If using 2.x are you trying to configure the Things, Items via files or PaperUI?

I am using mqtt 2.4 binding and i am using the files to configure not the paper UI

We got the same issue like thats although we already install 1.x and 2.x, hope any help😂

@Karunya_Atluri
Please show the related contents of your files (.things, .items and .sitemap)
Did you read This?

My items file :
//My Switch

Switch Pwr_B_1 “Master Bedroom Light” (LR,gLight) { mqtt=">[mqtth2:cmnd/msterbd/POWER1:command:*:default],<[mqtth2:stat/masterbd/POWER1:state:default]" }

Switch Pwr_B_2 “Master Bedroom Fan” (LR,gLight) { mqtt=">[mqtth2:cmnd/masterbd/POWER2:command:*:default],<[mqtth2:stat/masterbd/POWER2:state:default]" }

Switch Pwr_B_3 “Master Bedroom CFL Light” (LR,gLight) { mqtt=">[mqtth2:cmnd/masterbd/POWER3:command:*:default],<[mqtth2:stat/masterbd/POWER3:state:default]" }

Switch Pwr_B_4 “Master Bedroom Ceiling Light” (LR,gLight) { mqtt=">[mqtth2:cmnd/masterbd/POWER4:command:*:default],<[mqtth2:stat/masterbd/POWER4:state:default]" }

My sitemap:
sitemap home label=“Atluri SmartHouse”
{
Frame
{
Group item=gFF label=“Master Bedroom”
{
Switch item=Pwr_B_1 icon=“light”
Switch item=Pwr_B_2 icon=“Fan”
Switch item=Pwr_B_3 icon=“light”
Switch item=Pwr_B_4 icon=“light”
}
}
}

My things file:
Bridge mqtt:broker:myUnsecureBroker [ host=“192.168.1.81”, secure=false ]
{
Thing topic mything {
Channels:
Type switch : Light “Master Bedroom Light” [ stateTopic=“sonoff/masterbd/state/POWER1”, commandTopic=“sonoff/masterbd/command/POWER1”, on=“i-am-on”, off=“i-am-off” ]
Type switch : Fan “Master Bedroom Fan” [ stateTopic=“sonoff/masterbd/state/POWER2”, commandTopic=“sonoff/masterbd/command/POWER2”, on=“i-am-on”, off=“i-am-off” ]

}

}

The items file is using the MQTT1 syntax! Look into the documentation linked above!
On your thing setup, the use of the custom on and off strings looks suspicious.

@opus I am new to this and started learning it if you can guide me that would be very helpful. I will look into the documentation and please tell me what do i need to change for the things file. I hope you do the needful

after looking at the documentation which you have provided there are 2 demo.things files I am confused which format to use can you tell me which is comfortable. I guess the one which i posted previously was similar to the demo1.things format in the documentation

In your things file I would ddelete only this : " on=“i-am-on”, off=“i-am-off”" part.
Have you changed the items file?

Working with the documentation