First time setup of MQTT [solved]

Hi,

I happily got QO2.4 running on my PI3+ with openhabian. Next step ist to connect my Tasmota Sonoff devices using MQTT. I know there is a MQTT binding, but the documentation is confusing me. Whenever I google I get outdated (not 2.4) or contradicting info. Let me fire some questions. A simple RTFM answer is totally acceptable if it contains a link :slight_smile:

How to I start MQTT on my Openhabian? I want to control a MQTT device, not get controlled. Its supposed to run locally, so far no Internet MQTT is intended. The PaperUI is not self-explaining.

In general: Some tutorials explain PaperUI, others are telling that all changes there are lost after reboot and I need to edit config files manually. Which is the truth?

Next I’d like to add a 433MHz device. I used this tutorial OpenHAB Exec Binding explained in detail on 433MHz radio transmitter example and got quite far: I can switch a device with the send command on the ssh console. Now I need to add it as a thing? item? to openhab. I don’t trust the mentioned page because it may be for an older OH version. There seems to be a binding for RF devices but that again does not appear in PaperUI. Any hints?

Thanks a lot, Archi

You will find two parties, the hardcore text file users and the UI-open-minded people. It doesn’t matter actually, depends on your taste. The UI is not perfect yet, fast copy/paste is for example not very feasible. But auto discovering and configuring Things is very well possible with the UI.

MQTT requires a broker (server). Start the embedded one or use Mosquitto. Depends on your taste again. openHAB will only be a client to that broker, as every other device.

1 Like

Thanks David.

So from your answer I conclude that also config changes using the Ui are permanent.

Just one hint is missing: How do I start the built-in MQTT server? Is there any place in the config (either file or UI) to do it? The PaperUI jusz says: “you need a MQTT server running” but it does not suggest any starting point how ton do it.

Thanks anyway, I have another starting point for my research :smiley: now

Use the openhabian tool.

sudo openhabian-config

Look through the options and find where you can add the mqtt broker.

EDIT: Its located in Optional components then select Mosquitto

Cool, installed!
Next I went into PaperUI config. First question: What shall I add in the field “location”?
Then, which IP is working? Assumption: 127.0.0.1, because its running locally. I also added my passwd in the extended settings. Result: “your server is offline”. Do I have to reboot?
Now I googled and found some hints how to set up the mqtt.con in services, Its not there. I expected the PaperUI to create one. Wheres my mistake this time?

You can manually configure the broker at etc/openhab2/services/mqtt.cfg

I haven’t moved from mqtt 1.x to the new 2.4 binding so I’m not sure of the options for configuring the broker from PaperUI.

Have you installed the mqtt binding?

I believe yes. At least in the page Configuration chevron_right Bindings chevron_right MQTT Thing Binding in the UI I see
MQTT Thing Binding
Link MQTT topics to things
Author: David Graeff

However I did this before I started mosquitto.

Here’s a tutorial that may help with your setup. It’s for migrating from 1.x to 2.4 but should help either way.

The link is good. However I am stuck at the beginning of it. Although I installed mosquitto using the config tool, I don’t have any mqtt.cfg This seems to be wrong.

Edit: mosquitto IS running:
mosquit+ 1968 0.0 0.4 6356 4016 ? S 15:57 0:00 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

FYI, You can restart OH and watch the logs (front tail logs, found on the webUI) to see if the broker gets started.

No I cannot :frowning: I have no clue how to restart OH2. I can restart the PI, but I would loose most output before I can see in in the gui or SSH. But anyhow, I know that mosquitto is running.

I believe my issue is that most users are coming from some older OH version, thats why they have a mqtt.cfg and I don’t. This seems to be the tested and documented path.

Under Things I see:
Generic MQTT Thing Status: OFFLINE - BRIDGE_OFFLINE
Local MQTT Broker Status: OFFLINE - COMMUNICATION_ERROR MqttException
MQTT Boker Status: OFFLINE - COMMUNICATION_ERROR MqttException

In the Broker settings (both) I added user name, passwd, and port 1883
It is a little bit frustrating…

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