First time setup of MQTT [solved]

To start and stop OH from the command line use this:

sudo systemctl stop openhab2

sudo systemctl start openhab2

Maybe try using the IP address of your OH server instead of 127.0.0.1

1 Like

ahh, this is the output (with 127.0.0.1)

2018-12-22 16:53:22.453 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Stopped Paper UI

2018-12-22 16:53:22.490 [INFO ] [panel.internal.HABPanelDashboardTile] - Stopped HABPanel

2018-12-22 16:53:22.500 [INFO ] [ebuilder.internal.HomeBuilderServlet] - Stopped Home Builder

2018-12-22 16:53:22.530 [INFO ] [.dashboard.internal.DashboardService] - Stopped Dashboard

2018-12-22 16:53:34.676 [WARN ] [.MqttBrokerConnectionServiceInstance] - MqttBroker connection configuration faulty: host : You need to provide a hostname/IP!

2018-12-22 16:53:36.065 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel

2018-12-22 16:53:36.392 [INFO ] [ebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder

2018-12-22 16:53:36.411 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to ‘Europe/Berlin’.

2018-12-22 16:53:36.418 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to ‘de_DE’.

2018-12-22 16:53:46.141 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007

==> /var/log/openhab2/events.log <==

2018-12-22 16:53:47.581 [hingStatusInfoChangedEvent] - ‘mqtt:topic:b091eb34’ changed from UNINITIALIZED to UNINITIALIZED (BRIDGE_UNINITIALIZED)

==> /var/log/openhab2/openhab.log <==

2018-12-22 16:53:48.188 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.1.61:8080

2018-12-22 16:53:48.192 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.1.61:8443

2018-12-22 16:53:48.646 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui

==> /var/log/openhab2/events.log <==

2018-12-22 16:53:48.868 [hingStatusInfoChangedEvent] - ‘mqtt:broker:a01955b2’ changed from UNINITIALIZED to INITIALIZING

2018-12-22 16:53:49.005 [hingStatusInfoChangedEvent] - ‘mqtt:broker:a01955b2’ changed from INITIALIZING to OFFLINE

==> /var/log/openhab2/openhab.log <==

2018-12-22 16:53:49.098 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘127.0.0.1’ with clientid paho4927382951316 and file store ‘/var/lib/openhab2/mqtt/127.0.0.1’

==> /var/log/openhab2/events.log <==

2018-12-22 16:53:49.141 [hingStatusInfoChangedEvent] - ‘mqtt:broker:e8ebb485’ changed from UNINITIALIZED to INITIALIZING

2018-12-22 16:53:49.148 [hingStatusInfoChangedEvent] - ‘mqtt:broker:e8ebb485’ changed from INITIALIZING to OFFLINE

==> /var/log/openhab2/openhab.log <==

2018-12-22 16:53:49.163 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘127.0.0.1’ with clientid paho4927556946079 and file store ‘/var/lib/openhab2/mqtt/127.0.0.1’

==> /var/log/openhab2/events.log <==

2018-12-22 16:53:49.215 [hingStatusInfoChangedEvent] - ‘mqtt:broker:a01955b2’ changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Timeout

2018-12-22 16:53:49.223 [hingStatusInfoChangedEvent] - ‘mqtt:topic:b091eb34’ changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING

2018-12-22 16:53:49.243 [hingStatusInfoChangedEvent] - ‘mqtt:broker:a01955b2’ changed from OFFLINE (COMMUNICATION_ERROR): Timeout to OFFLINE (COMMUNICATION_ERROR): MqttException

2018-12-22 16:53:49.247 [hingStatusInfoChangedEvent] - ‘mqtt:broker:e8ebb485’ changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Timeout

2018-12-22 16:53:49.253 [hingStatusInfoChangedEvent] - ‘mqtt:broker:e8ebb485’ changed from OFFLINE (COMMUNICATION_ERROR): Timeout to OFFLINE (COMMUNICATION_ERROR): MqttException

2018-12-22 16:53:49.255 [hingStatusInfoChangedEvent] - ‘mqtt:topic:b091eb34’ changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE)


Something is wrong with the IP. I still believe the UI did not create a mqtt.cfg at the right location. Can I get a plain cfg from somewhere and place it manually (including the password config lines)?

Edit: I see in mosquitto.log
1545494550: New connection from 127.0.0.1 on port 1883.
1545494550: Socket error on client , disconnecting.

Use the server IP address, replace 127.0.0.1 with 192.168.1.61

Do you have a mqtt.cfg at etc/openhab2/services?
Use this command to check:
ls /etc/openhab2/services

Does not help, mosquitto.log

1545494862: New connection from 192.168.1.61 on port 1883.
1545494862: Socket error on client , disconnecting.
1545494862: New connection from 192.168.1.61 on port 1883.
1545494862: Socket error on client , disconnecting.
1545494872: New connection from 192.168.1.61 on port 1883.

edit: here is the log output
2018-12-22 17:10:42.789 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.1.61’ with clientid paho5941079571809 and file store ‘/var/lib/openhab2/mqtt/192.168.1.61’

==> /var/log/openhab2/events.log <==

2018-12-22 17:10:42.840 [hingStatusInfoChangedEvent] - ‘mqtt:broker:e8ebb485’ changed from UNINITIALIZED to INITIALIZING

2018-12-22 17:10:42.851 [hingStatusInfoChangedEvent] - ‘mqtt:broker:e8ebb485’ changed from INITIALIZING to OFFLINE

==> /var/log/openhab2/openhab.log <==

2018-12-22 17:10:42.861 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to ‘192.168.1.61’ with clientid paho5941254556477 and file store ‘/var/lib/openhab2/mqtt/192.168.1.61’

==> /var/log/openhab2/events.log <==

2018-12-22 17:10:42.876 [hingStatusInfoChangedEvent] - ‘mqtt:broker:a01955b2’ changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Timeout

2018-12-22 17:10:42.907 [hingStatusInfoChangedEvent] - ‘mqtt:broker:a01955b2’ changed from OFFLINE (COMMUNICATION_ERROR): Timeout to OFFLINE (COMMUNICATION_ERROR): MqttException

2018-12-22 17:10:42.924 [hingStatusInfoChangedEvent] - ‘mqtt:broker:e8ebb485’ changed from OFFLINE to OFFLINE (COMMUNICATION_ERROR): Timeout

2018-12-22 17:10:42.928 [hingStatusInfoChangedEvent] - ‘mqtt:broker:e8ebb485’ changed from OFFLINE (COMMUNICATION_ERROR): Timeout to OFFLINE (COMMUNICATION_ERROR): MqttException

Try uninstalling the mqtt binding via PaperUI. Then use the following commands to clean the cache and tmp files.

sudo systemctl stop openhab2

sudo openhab-cli clean-cache

sudo systemctl start openhab2

After OH is back up and running reinstall the mqtt binding.

1 Like

Much better! MQTT is online now. Thanks!

If anyone is reading the thread:

  • First start mosquitto MQTT broker with sudo openhabian-config Its located in Optional components then select Mosquitto
  • Remember user password (user is openhabian)
  • In the openhab GUI install in addons mqtt
  • Then follow Migrating MQTT1 items to MQTT2.4 items
  • you will need to add your user / password combination. I disabled secure connection (TLS)
  • if anything goes wrong, uninstall on PaperUI and clean the cache:
    sudo systemctl stop openhab2
    sudo openhab-cli clean-cache
Summary

sudo systemctl start openhab2

  • redo the steps above.

Next step for me: Bring my sonoff into the GUI

Glad you have it working.:+1:

Please mark the topic solved by clicking the square box (lower right corner) on the post that provided the solution and edit the title to start with [Solved].

Thanks

In the openhab GUI install in addons mqtt

Which addon do you install!?! “MQTT Binding” or " Embedded MQTT Broker"? I’ve already installed the mqtt broker by config. Does the embedded MQTT broker conflict?

It was so simple and pretty running up to OH1.8. Whith OH2 is started the confusion… every new version the complexity increase. Openhab are getting too difficult to be managed, because there isn’ t an official tutorial fully updated, that lead you step by step. To find information I have to search in the forum, spendig a big amount of time because, for a problem there isn’t only one solution and too many things are given for known. I’m getting crazy to bring my sonoff in OH2.4. I loved OH but now with the 2.4 version, if I have to learn again also ho to make the connection with the MQTT broker, then I’m seriously thinking to pass to Home Assistant. I’m very sorry, because I belived in the project OpenHab, but It becames a mess.

6 Likes

sorry for the outburst, I feel a bit 'frustrated because even if I do everything I find written, and while being connected the Sonoff with the mqtt server installed on raspberry, and using the same items and sitemap of the previous version, I can not view in basic ui the sonoff values

Just install mqtt1 again and everything is back :slight_smile:
And yes OH2 is a different product compared to OH1. It required more steps if you do it by text. The idea is that you just don’t to it by textual configuration anymore. HomeAssistant is not easier in this regard, they have “components” and “entities” which is like our Things and (auto linked) Items.

Hi David,
thanks for your suggestion but what do you mean for mqtt1? I mean that I do not choose the version when I install mqtt by the config tool. As you understand, I’m a beginner.

I expected you are a long time user, because you mentioned OH1.8 (which is quite dusty). Since OH2.4 there is a new MQTT binding. If you have used mqtt before, you were using mqtt1. That required a config file, the new approach don’t. mqtt1 was automatically uninstalled with OH2.4.

Please also understand that this forum is about openHAB itself mostly. It is expected that you read up on MQTT yourself and to understand what a broker does, what an mqtt topic is and so on.

Hello, I’m not a GUI-open-minded guy, and I like text based configuration. Once you understand the scripts, it is easier and faster to edit than click, click & more clicks. So my question is: in future OH versions do we still have the text configuration option?

I recommend reading Directions for openHAB 3. And I mean the entire 80 min read time thread. Everything, every argument is covered in there.

1 Like

Hello David,
I am following your tutorial. I have installed the MQTT embedded Broker and then the MQTT binding. As you could see attached I have MQTT broker online but when I create a channel it appears under systemBroker. Is that normal?

Hey!

You did everything correct so far, except the last step with adding channels. The broker thing is really only to configure the broker (and for trigger channels, but that might confuse you atm). You will need to add a “Generic MQTT Thing” and add channels there.

Cheers, David

Thanks for your quick reply. I want to use MQTT between openhab and my “the Home Remote” (http://thehomeremote.com/) UI design so that I could extend features on both side.

As a first step to better understand how mqtt works I am trying to create a virtual mqtt “switch” and a virtual mqtt “lamp” in openHab. I thought that the MQTT Binding was meant for that?

If not should I just create by hand these two MQTT in a .thing file or is there a way to create them in Paper UI?

That’s an interesting project of yours.

Regarding MQTT: It’s for the other way round actually. You have mqtt topics on your broker and the binding allows you bind those topics to Things->Channels->Items.

If you are looking for exporting Things and Channels to MQTT: That’s what an IO Service is for in openHAB. Unfortunately I haven’t written that part. I revamped the Hue Emulation IO service instead recentenly.

Is there a step by step tutorial of Video you could refer me to to understand better how to use MQTT in openhab?

I don’t use .thing and .item files. I think it’s a pest tbh and there are long community arguments topics and posts about technical aspects, the syntax and all that jazz and a little civil war even that I accidentally started here when I proposed to remove those files completely.

That’s why I can’t help you in this regard, and it is dead simple with Paper UI, I guess you do not need any help on that. And if so, my blog post (openHAB Blog Website) about that topic might help :slight_smile:

1 Like