Displaying state of GPIO14 of Sonoff SV in OH2


i want to display the current state of the GPIO14 Pin of my Sonoff SV with Tasmota Firmware in OH2.

Therefore i set the Contact of GPIO14 to another relay as described here.

But i’m struggeling to display the value in OH2 via mqtt. This is what my things-file looks:

Thing topic SchalterTestSchalter “Testschalter” {
Type switch : SchalterTestPower [ stateTopic=“stat/SchalterTest/POWER”, commandTopic=“cmnd/SchalterTest/POWER” ]
Type contact : SchalterTestPower2 [ stateTopic=“stat/SchalterTest/POWER”, on=“ON”, off=“OFF” ]
Type contact : SchalterTestPower3 [ stateTopic=“stat/SchalterTest/POWER2”, on=“ON”, off=“OFF” ]

and my item-file:

Switch SchalterTestSchalter “SchalterTest” { channel=“mqtt:topic:ikarus:SchalterTestSchalter:SchalterTestPower”, expire=“5s,command=OFF” }
Contact SchalterTestState2 “Schalter Status 2” { channel=“mqtt:topic:ikarus:SchalterTestSchalter:SchalterTestPower2”}
Contact SchalterTestState3 “Schalter Status 3” { channel=“mqtt:topic:ikarus:SchalterTestSchalter:SchalterTestPower3”}

And this is the result:

The contact state of switch 2 is working, but why won’t switch3 not?

Thanks for your help!

This line looks wrong.

Test Power 3 but in state topic you have POWER2?

I only named this different during trial and error.

POWER2 is the Sonoff Tasmota label for GPIO14. This is log of the Sonoff:

19:42:20 MQT: cmnd/SchalterTest/POWER2 = OFF
19:42:20 MQT: stat/SchalterTest/RESULT = {“Command”:“Unknown”}
19:42:25 MQT: cmnd/SchalterTest/POWER2 = ON
19:42:26 MQT: stat/SchalterTest/RESULT = {“Command”:“Unknown”}

Is this from the tasmota console?

Yes, this is the output of the tasmota console when connect GPIO14 to GND.

Something with the tasmota setup may not be correct…saying that b/c it mentions “Command Unknown”.

Have you used GPIO14 before?

No, not yet…

Somewhere in this link https://github.com/arendst/Tasmota/wiki/Commands#mqtt look to verify that you have the option for using GPIO14 set up correctly. I like tasmota but sometimes think Esp_Easy is much easier.

I think this page will be what your looking for. https://github.com/arendst/Tasmota/wiki/Buttons-and-Switches

The naming of the state-and commandTopics look suspicious to me.
If more then one PowerSwitch can be handled they are normally all named Power1, Power2 …
You are using “POWER” for the first and second channel and you see them both working. My guess there is only one Power switch on this device.
Did you even set a module type that has more then one Power switch?

No. i didn’t this before.

I’ve only done this for testing purpose. Finally i only want do display the state of the GPIO-Pin OH2…

Sorry, can you give me hint, where i have to read at this site? I know this page already, but in the past it didn’t helped me much…

Without setting the correct module type your sonoff device will be handled as a sonoff basic. This one has only one Power switch named “POWER”.

I know this and i set the type to sonoff sv and gpio14 to switch1. A little bit confusing is disconnecting the new switch from the main relay. Maybe there is my fault?

According to the blog you took your config from the topic should be:cmnd/sonoff/POWER2
Not stat...
And that makes sense due to his switch topic config
Just monitor mqtt When You open and close Gpio14

in tasmota a virtual relay is needed
Gpio14 switch2
Gpio4 relay2 (virtual relay)


Ok, i found the problem.

The problem was, there was something wrong with my virtual relay. I didn’t have defined a second relay and this was the problem.

If i setup the sonoff to according picture:
Everything works fine!

Now i can view the state of GPIO14 via OH2. This is what my things-file looks:

Type contact : SchalterTestPower2 [ stateTopic=“stat/SchalterTest/POWER2”, on=“ON”, off=“OFF” ]

Thanks a lot to you all for helping!

Now that you have it all working can you post your final configuration files here to help a noobie starting with OpenHAB garage door opener/monitor using Tasmotised Sonoff SV?



this is my working setup:

    Thing topic SonoffSVGaragentor  "Sonoff SV Garagentor" {
            Type switch : GaragentorPower           [ stateTopic="stat/SonoffSVGaragentor/POWER1", commandTopic="cmnd/SonoffSVGaragentor/POWER1", autoupdate="true" ]
            Type contact : GaragentorStatus         [ stateTopic="stat/SonoffSVGaragentor/POWER2", on="ON", off="OFF" ]


Switch GaragentorSchalter “Garagentor” { channel=“mqtt:topic:ikarus:SonoffSVGaragentor:GaragentorPower” }
Contact GaragentorStatus “Status Garagentor” { channel=“mqtt:topic:ikarus:SonoffSVGaragentor:GaragentorStatus” }


    Frame           label="Garage" {
            Switch          item=GaragentorSchalter icon="garagedoorclosed" mappings=[ON="offen"] visibility=[GaragentorStatus == OPEN]
            Switch          item=GaragentorSchalter icon="garagedooropen" mappings=[ON="geschlossen"] visibility=[GaragentorStatus == CLOSED]
            Switch          item=GaragentorSchalter icon="garagedooropen" mappings=[ON="geschlossen"] visibility=[GaragentorStatus == NULL]

The configuration of the tasmota firmware is displayed above.

BW Maximilian

Thank you for these files.
They were a big help.