Problem with MQTT2 and Sonoff T1/Teepao switch with Tasmota forked

Tags: #<Tag:0x00007f7454888978>

I found this item from @Elch2000 with a temporary solution for using a Sonof T1 as rollershutter. Problems MQTT2 Sonoff T1 with Tasmota Fork
I try to use his solution but i am not able to get it working.
I created a new openhabian install on a RPi2 with Mosquitto and tested this with one of my Sonoff S20 devices and this is working OK.
(I know the current MQTT Binding has a bug with the STOP command. We are all waiting for the solution for that.) But there seems to be a solution using a Dimmer item for this…
I have 2 Teepao and 2 Sonoff TX (T1) 2-gang switches for my screens.
The Teepao switches i flashed with Stefan Bodes fork of Tasmota. The Sonoff TX switches still have to be flashed.
From the Tasmota Console as well as from the command prompt on the RPi i am able to switch the switches UP, Down and STOP.

$ mosquitto_pub -d -h 192.168.178.241 -t cmnd/Screen_2/POWER1 -u openhab -P ******* -m ON
$ mosquitto_pub -d -h 192.168.178.241 -t cmnd/Screen_2/POWER1 -u openhab -P ******* -m STOP
$ mosquitto_pub -d -h 192.168.178.241 -t cmnd/Screen_2/POWER1 -u openhab -P ******* -m OFF
$ mosquitto_pub -d -h 192.168.178.241 -t cmnd/Screen_2/POWER1 -u openhab -P ******* -m STOP
$ mosquitto_pub -d -h 192.168.178.241 -t cmnd/Screen_2/POWER2 -u openhab -P ******* -m ON
$ mosquitto_pub -d -h 192.168.178.241 -t cmnd/Screen_2/POWER2 -u openhab -P ******* -m OFF
$ mosquitto_pub -d -h 192.168.178.241 -t cmnd/Screen_2/POWER2 -u openhab -P ******* -m STOP

This works perfectly.

But I am having problems translating these commands to the correct Things and Item files. (I am using text-file configuration for openHAB, not the PaperUI.)

my mqtt-broker.things

// MQTT Broker Bridge en things definitions
//
Bridge mqtt:broker:mosquitto    "Mosquitto MQTT Broker" @ "MQTT" [ 
    host="192.168.178.241", 
    secure=false, 
    port=1883, 
    qos=0, 
    retain=false, 
    clientID="openHAB2", 
    //certificate="",
    //certificatepin=false,
    //publickey="",
    //publickeypin=false,
    keep_alive_time=30000, 
    reconnect_time=60000, 
    //lastwill_message="",
    //lastwill_qos=1,
    //lastwill_topic="",   
    username="openhab", 
    password="********"
]
{
//
    Thing topic Sonoff_4S20         "Sonoff 4S20" (mqtt:broker:mosquitto) @ "Sonoff Tasmota"  {
        Channels:
        Type switch : switch        "Sonoff_4S20 WCD" [ stateTopic="Sonoff_4S20/POWER", commandTopic="cmnd/Sonoff_4S20/POWER", on="ON", off="OFF" ]
        Type number : rssi          "WiFi Signal Strength" [ stateTopic="tele/Sonoff_4S20/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI"]
        //
        Type string : state01       "Sonoff_4S20 State" [ stateTopic="tele/Sonoff_4S20/STATE", transformationPattern="JSONPATH:$.POWER", on="ON", off="OFF" ]
        //
        Type string : devicestate   "Device State" [ stateTopic="Sonoff_4S20/LWT" ]
    }
//    MQTT Binding heeft een fout voor de Rollershutter. Een work-around is gebruit een dimmer item:
//    https://community.openhab.org/t/solved-problem-with-mqtt2-and-sonoff-t1-tasmota-forked/68984/3

    // Teepao Testschakelaar 2 met Stefan Bode Fork
    Thing topic Teepao-Screen_2 "Teepao Screen Switch 2" {
        Type rollershutter : blinds "Screen_2" [ stateTopic="stat/Screen_2/SHUTTER1", commandTopic="cmnd/Screen_2/shutterposition" ]
    }
}

My mqtt-screens.items file:

//Rollershutter Screen_2 "Teepao Screen 2" { channel="mqtt:topic:broker:Teepao-Screen_2:blinds" }
Dimmer Screen_2     "Teepao Screen 2"           { channel="mqtt:topic:broker:Screen_2:blinds" }
Switch Screen_2_UP  "Teepao Screen 2 Omhoog"    { channel="mqtt:topic:mosquitto:Screen_2:state", 
                                                  channel="mqtt:topic:mosquitto:Screen_2:switch" }

My mqtt-sonoff-s20.items file for the working Sonoff S20:

// Sonoff devices items file voor MQTT versie 2; 2019-04-22.
//
/*
    <Functie WCD>.     Sonoff_4S20 (Tasmota fw)
*/
Switch Sonoff_4S20_Switch "Sonoff_4S20 WCD" (SonoffPowerSwitches_S20, ChristmasNightLights) { channel="mqtt:topic:mosquitto:Sonoff_4S20:switch" }
String Sonoff_4S20_State "Sonoff_4S20 State" (SonoffPowerSwitches_S20) { channel="mqtt:topic:mosquitto:Sonoff_4S20:state01", 
                                                                         channel="mqtt:topic:mosquitto:Sonoff_4S20:state02", 
                                                                         channel="mqtt:topic:mosquitto:Sonoff_4S20:state03", 
                                                                         channel="mqtt:topic:mosquitto:Sonoff_4S20:switch" }
Number Sonoff_4S20_RSSI     "WiFi Signal Strength [%d %%]"      <wifi>   (Sonoff_S20) { channel="mqtt:topic:mosquitto:Sonoff_4S20:rssi" }
//*                                                                  

My test sitemap file:

sitemap testhome label="Mijn OH testomgeving"
{
	Frame label="Test Sonoff en Teepao switches" {
		Text item=CurrentDate
                Switch  item=Sonoff_4S20_Switch     label="Sonoff 4 S20 WCD aan/uit"    icon="light"
                    //Switch item=Sonoff_4S20       labelcolor=[S20_1_Reachable == "ON" = "green",S20_1_Reachable == "OFF" = "red"]
                    //
                    //Text item=Sonoff_4Uptime      label="Sonoff 4 Uptime"         icon="clock"
                    Text    item=Sonoff_4S20_RSSI       label="Wifi Signaal sterkte"
	}
    Frame label="Test met Teepao Switch" {
		Switch item=Screen_2
        Switch item=Screen_2_UP
	}
}

Hopefully someone can help me to solve my issue…
Kind regards, Bert

Wouldn’t you want two switch channels, each on/off? And a “dummy” roller Item that can accept commands up/down/stop? And a rule listening for those commands and converting to on/off commands for the two real switches?

Hi @rossko57, thank you for your reaction. I read and understand that David Greaff is working a solution for the STOP function with the Rollershutter Channel. I like to wait till that is fixed in the MQTT binding.
But i would like to know how i can make the config, with text-files, working for UP and Down movement of my screens (without the STOP). That would do it for the time being.
But i don’t know how i could make a rule witch assists in this…
I am sorry, but i am not a programmer…

That’s alright, there are lots of examples of simple rules to follow.

How about the other things you would need to do, setting up Things and Items?

Well, i managed to setup about 10 other Sonoff devices with mqtt2 like Basic, and S20 as illustrated in my post for S20. And they all work perfectly even with Rules and also node-RED.
But with these switches, i do not know how to do this. Hopefully you can help me with this?

Well, if you clarify what you need to achieve it may help clarify the path to it.

Looking at the mosquitto log in your first post, you send commands to two different topics to do whatever it is you want done.

It seems logical then, to set up two channels to do something similar from openHAB.

Two channels means two Items, if you want to command them from rules or UI.
Switches, I would guess.

At this stage you could temporarily put your Items into your sitemap to see if you can do what you want. You might have to be careful not to turn on both at once! I don’t know how your end device works.

But I assume what you really want is one thing on your UI that looks like a Rollershutter. So you would create a Rollershutter Item for that, not linked to any channels.

Now you can create a rule that listens for commands to that Rollershutter from the UI (or from other rules, come to that). The rule would need to find out what the command was, and send appropriate commands to the two Items linked to the channels.
Example lets say, command STOP would send OFF to both switches.

Yes, i need one item, a Rollershutter item, in my UI which can do shutter-UP and -DOWN commands (and later when it is fixed in the Binding also -STOP).
I found this example (see my first post): Rollershutter but i seem not able to translate it to my situation…
Luckily the Tasmota Fork fw from Stefan Bode prevents it to energize both relais at the same time, so that problem is covered.
I was hoping that @Elch2000, who has a sililar situation could help me with his example files for Things, Items and sidemap… He writes in his posts he solve dit using a Dimmer item. But sorry, it is not clear to me

Edit. I just asked him about this in a pm.

That’s a step by step roadmap for you to follow. The advice is free, and of course you are free not to follow it.