MQTT mosquitto Setup and Sonoff Tasmota

I’m new here, so apologies if I’m doing all wrong :frowning:

I have my system running with a Xiaomi Hub, a Termometer also from Xiaomi and, as for now, some external calls with webhooks.

In order to avoid this webhook calls, that give sometimes an unreasonable delay, i’m configuring a MQTT device.

And here come my problems.

I installed mosquitto via “sudo openhabian-config” withouth password for now.

Then I went to Paperui GUI and installed “MQTT Binding” add-on

Created a mqtt.cfg file as follow:

mosquitto.url=tcp://192.168.0.52:1883
mosquitto.user=openhabian

Then I went to Configuration Things, and configured MQTT Broker
Broker Hostname: 192.168.0.52
Broker Port: 1883
Username: openhabian

MQTT Broker Thing is showed as ONLINE

Then I added a Sonoff TH10 with a Thermometer SI7021. (It was visible in my Inbox), but it shows as OFFLINE - GONE.

I have also created, as i saw on some guide, for testing purposes the following Item

Number mqtt_kitchen_gas "Gas Level [%.1f]" {mqtt="<[mosquitto:Home/Floor1/Kitchen/Gas_Sensor:state:default]"}

And added it for visualitation on my sitemap

Text item=mqtt_kitchen_gas icon="gas"

Then on a terminal I typed:
sudo mosquitto_pub -u openhabian --pw smarthomeblog -t “Home/Floor1/Kitchen/Gas_Sensor” -m 10

To update the value and test if all worked. Nothing changed.

I have the following error on my openhab.log.

2019-02-20 17:21:41.520 [ERROR] [g.discovery.AbstractDiscoveryService] - An error occurred while calling the discovery listener org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.
java.lang.NullPointerException: null
	at org.eclipse.smarthome.config.discovery.internal.DiscoveryServiceRegistryImpl.thingRemoved(DiscoveryServiceRegistryImpl.java:278) ~[?:?]
	at org.eclipse.smarthome.config.discovery.AbstractDiscoveryService.thingRemoved(AbstractDiscoveryService.java:300) ~[?:?]
	at org.eclipse.smarthome.binding.mqtt.generic.internal.discovery.HomeAssistantDiscovery.receivedMessage(HomeAssistantDiscovery.java:164) ~[?:?]
	at org.eclipse.smarthome.binding.mqtt.discovery.TopicSubscribe.processMessage(TopicSubscribe.java:52) ~[?:?]
	at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.lambda$3(ClientCallback.java:90) ~[?:?]
	at java.util.ArrayList.forEach(ArrayList.java:1257) [?:?]
	at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.messageArrived(ClientCallback.java:90) [202:org.eclipse.smarthome.io.transport.mqtt:0.10.0.oh240]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:499) [198:org.eclipse.paho.client.mqttv3:1.2.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:402) [198:org.eclipse.paho.client.mqttv3:1.2.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:206) [198:org.eclipse.paho.client.mqttv3:1.2.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

What am I missing? What can I do?

Thanks in advance.

My mosquitto server must be running as I do this procedure, and I have no errors.

                    Open the terminal and type 
                    `mosquitto_sub -h 192.168.0.52 -t topic`
                     Open another terminal and type 
                     `mosquitto_pub -h 192.168.0.52 -t topic -m "Hello"`

I have also the following error on my openhab.log

2019-02-20 18:06:34.542 [ERROR] [ansport.mqtt.internal.ClientCallback] - MQTT message received. MqttMessageSubscriber#processMessage() implementation failure
java.lang.NullPointerException: null
	at org.eclipse.smarthome.binding.mqtt.generic.internal.discovery.HomeAssistantDiscovery.receivedMessage(HomeAssistantDiscovery.java:168) ~[?:?]
	at org.eclipse.smarthome.binding.mqtt.discovery.TopicSubscribe.processMessage(TopicSubscribe.java:52) ~[?:?]
	at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.lambda$3(ClientCallback.java:90) ~[202:org.eclipse.smarthome.io.transport.mqtt:0.10.0.oh240]
	at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:?]
	at org.eclipse.smarthome.io.transport.mqtt.internal.ClientCallback.messageArrived(ClientCallback.java:90) [202:org.eclipse.smarthome.io.transport.mqtt:0.10.0.oh240]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.deliverMessage(CommsCallback.java:499) [198:org.eclipse.paho.client.mqttv3:1.2.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.handleMessage(CommsCallback.java:402) [198:org.eclipse.paho.client.mqttv3:1.2.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsCallback.run(CommsCallback.java:206) [198:org.eclipse.paho.client.mqttv3:1.2.0]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

Until this everything was good and online.
You have a MQTT broker running and you have a connection to it from openhab ( the MQTT Broker Thing which acts as a bridge).
I can’t say why the Sonof TH was in your inbox, since their setup does not follow the two setups that are automatically discovered they should not appear.
I would have created a Generic MQTT Thing for each Sonoff as described in Here.
The item you have created uses the syntax of the old MQTT version 1 binding , so this one will NOT work, hence you are not getting any feedback.

I’m the mqtt subsystem maintainer. My recommendation: don’t use oh 2.4, there are too many problems. Use at least oh 2.5m1.

Second: don’t trust openHAB guides written before OH2.4. They are talking about the old mqtt add-on. You don’t use a mqtt.cfg file anymore nowadays.

Third: tasmotas+sonoffs are in theory auto discovered. But they use an mqtt specification from our (friendly) competitor Homeassistent. Just recently we fixed all bugs in that component. That will not be available before oh 2.5m2. Until then you will see those long error messages when using the inbox.

For now you would follow one of the many forum posts to configure mqtt topics manually.

Cheers David

Thank you both.
Yes, in fact as a I add it manually, it is shown as online.
I will update my OH2 and continue learning :smiley:

It doesn’t seem so easy to add this MQTT items.

If you mastered connecting one device as thing and create an item for it, the following ones will be easy. The hard part is understanding the underlying oh2 concept of things and items which differs from oh1 where you had items only.

2 Likes

Updated to latest snapshot and I have no PaperUI and no BasicUI :frowning:

According to what I have read, I guess I have to downgrade :frowning:

Yes that’s a bad idea at the moment and probably at least until end of this month.
That’s why I mentioned OH2.5M1 (Milestone 1).

And how can i install that? I don’t see that on openhabian-config :frowning: