Sonoff + tasmota firmware + http binding

here is an easier way of connecting your Sonoff tasmota flashed devices to openhab2 (havent tried it with orginal firmware)

install the http binding

Switch Sonoff       "Sonoff"        { http=">[ON:POST:] >[OFF:POST:]" }                                    

the actual http command is
i had to add an extra % for it to work cause the % calls for an action and %% to ignore
took me some time to figure this out

Switch item=Sonoff		mappings=[ON="ON", OFF="OFF"]

havent played around with the JSON command to read the state yet


@alokin79 Thank you, it actually took me finding your post to figure out how to escape the spaces. Have you been able to integrate active status polling from the switch? I can display it OK but my openHab interface doesn’t update accordingly, only on manual refresh.


Thank you, @alokin79,

the hint with two "%% " has helped me finally getting the sonof tasmotas to work!

Welcome to the openHAB Forum!

Why don’t you try to connect the sonoff using the MQTT protocol? That is more commonly used.

String SonoffGardenaGV     "Sonoff GetValue"    { http="<[*?\\{\"POWER\":\"(.*?)\"\\}.*)]"}
Text item=SonoffGardenaGV 		icon="auto"			label="Status [%s]"

im on OpenHAB 2.2

I actually got it to work like this in the end (requires JSONPATH)

Switch rfplug2 "Office Light [%s]" { http=">[ON:GET:] >[OFF:GET:] <[$.POWER)]" }

In the sitemap I simply include the Switch with no further formating.

@opus Every new binding requires hours of research. At the moment I’m struggling to get homegear/homematic binding to work so I prefer to keep the rest as simple as possible. From my understanding MQTT would require a separate server to connect?

Yes, a MQTT server is needed. I have one running besides openHAB on my raspi3.

Please how should be inserted %% or @@ characters on Sonoff POW2 switch (espurna firmware)?
On bash command executes OK.
How should be propperly substitued with %% or @@ characters in rules ?

Terminal window:
curl -X PUT -H “Accept: application/json” http://localip/api/relay/0 --data “apikey=xxxxxxxxxxx&value=1”

Also working on restfull api off:
curl -X GET "http://localip/api/relay/0?apikey=xxxxxxxxxxxxxxx&value=1

executeCommandLine("curl -X PUT -H “Accept: application/json” http://localip/api/relay/0 --data “apikey=xxxxxxxxxxx&value=1"”)