Can't connect my tasmota flahed tuya devices via MQTT and Mosquitto

I succesfully flahed my Tuya plug device called Avatar AWP08L Plug.

It is now running Tasmota 8.2.0.

I successfully connected to my Mosquitto Server running on my Synology NAS DS716+ with this plug and I was I able to send turn the plug on and off via mqtt-spy.
I can turn the plug on with:
Topic: cmnd/tasmotaplug01/POWER
Data: ON
I can read the status of the plug with a subscription to:
Topic: stat/tasmotaplug01/POWER

But I can’t get the plug connect with my openHAB2 2.5.2 also running on my Synology NAS DS716+.
I have done the following:

  1. Installed the MQTT Binding
    via Paper UI → Add-ons → Bindings → MQTT Binding (binding-mqtt - 2.5.2)
    I can see it now here: Configuration → Bindings
  2. Added a MQTT Broker
    via Configuration → Things → Add → MQTT Binding → MQTT Broker
    Configuration of the broker:
    Broker Hostname/IP: 192.168.0.2 (IP of my Synology NAS DS716+)
    Broker Port: 1883
    Username: mqtt
    Password: ******
    The Broker got the following ID mqtt:broker:db13a14f and is shown as ONLINE.
  3. The openhab.log looks like:

2020-03-30 18:54:00.666 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘192.168.0.2’. Next attempt in 60000ms
2020-03-30 18:54:00.673 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.0.2’ with clientid openHAB helipus
2020-03-30 18:55:00.677 [INFO ] [.reconnect.PeriodicReconnectStrategy] - Try to restore connection to ‘192.168.0.2’. Next attempt in 60000ms
2020-03-30 18:55:00.681 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.0.2’ with clientid openHAB helipus

  1. Channel for my plug
    Under the MQTT Broker I added a channel with
    id: mqtt:broker:db13a14f:tasmotaplug01
    MQTT Topic: stat/tasmotaplug01/POWER
    Payload Condition:
    Separator Character

  2. plug.items
    Switch plug01 “Steckdose Avatar” { mqtt=“<[mqtt:broker:db13a14f:stat/tasmotaplug01/POWER], >[[mqtt:broker:db13a14f:cmnd/tasmotaplug01/POWER:command:*:default]” }
    I also tried:
    Switch plug01 “Steckdose Avatar” {channel=“mqtt:broker:db13a14f:tasmotaplug01”}

  3. default.sitemap
    Default item=plug01

I get the following in openhab.log:

[INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘default.sitemap’
[INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘plugs.items’
[WARN ] [.transport.mqtt.MqttBrokerConnection] - Failed subscribing to topic stat/tasmotaplug01/POWER
java.util.concurrent.CompletionException: com.hivemq.client.mqtt.exceptions.MqttSessionExpiredException: Session expired as connection was closed.

What am I doing wrong? What do I miss?

  • Platform information:
    • Hardware: Synology NAS DS716+ with Paketinstallation for OpenHAB and Mosquitto
    • Java Runtime Environment: Java 8 1.8.0_241
    • openHAB version: 2.5.2

You’d normally add a generic Thing under the broker Thing, and add your channels to that.

Looks to me that you have an OH to broker problem though.

Thank you for your time!
I can only add channels here under my Thing.and no generic Thing.


I must have done something wrong in the steps before.

Do I have to use this?
image

Do you already have a broker installed?
If not, yes you would need a broker. I’m not sure which one is better. The built in (from your screenshot) or mosquitto. I’m using mosquitto and I’m quite happy with it
But anyhow, you need a broker :slight_smile:

Yes I have the Broker Mosquitto installed on my Synology NAS. But I seem to have it not connected correctly in openHAB. How is the correct way today? I never discovered a thing in my Inbox.

Yes reading your first post again i see now that you already have the broker installed. Sorry for asking :wink:

Since your broker thing is online, credentials seem to be ok. I’ve just tried to use wrong credentials and the thing immediately goes offline.
Are you using a secure connection?

If yes, try disabling it.
And also: Since the broker is running on the same machine, try “localhost” as the hostname/IP instead of the external IP of your NAS

You don’t want anything to do with the “system broker” stuff, when you are already using an independent broker (Mosquitto).

There are a couple of hundred posts about MQTT, I’m sure some of them cover establishing a broker connection with PaperUI. Do you really want to give IP, or should you be using localhost?

A large proportion of those posts also cover configuring for Tasmota.
This is mostly using xxx.things files, but the process is the same when using PaperUI

Okay here is the solution. I needed to restart my openhab and all the errors have been gone. But I also was not using the right order and elements. The correct way is:

  1. Install the MQTT Binding
    via Paper UI -> Add-ons -> Bindings -> MQTT Binding (binding-mqtt - 2.5.2)
  2. Add a MQTT Broker
    via Configuration -> Things -> Add -> MQTT Binding -> MQTT Broker
  3. Add a Generic MQTT Thing
    via Configuration -> Things -> Add -> MQTT Binding -> Generic MQTT Thing
  4. Add in the Generic MQTT Thing a channel for every Tasmota plug:
  5. default.items
    Switch tasmotaplug01 “Steckdose Waschmaschine” {channel=“mqtt:topic:plugs:tasmotaplug01”}
  6. default.sitemap
    Default item=tasmotaplug01

Thats it. Sadly this took me a full day… To many different documentations on this which are not fitting well.

Tell us about the documentation you found lacking?