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:
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
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.
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
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
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”}
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
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
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
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:
Install the MQTT Binding
via Paper UI -> Add-ons -> Bindings -> MQTT Binding (binding-mqtt - 2.5.2)
Add a MQTT Broker
via Configuration -> Things -> Add -> MQTT Binding -> MQTT Broker
Add a Generic MQTT Thing
via Configuration -> Things -> Add -> MQTT Binding -> Generic MQTT Thing
Add in the Generic MQTT Thing a channel for every Tasmota plug: