Moving to MQTT 2.x

After a lot of reading, and a lot of trying and trying, I have come to the conclusion that I need some help.

For years I have been using the old MQTT addon, but moving to a new installation on a new server, I have decided to also update it all to work on the newest addons.

I started by reading this, https://www.openhab.org/blog/2018-12-16-mqtt-arrives-in-the-modern-openhab-2-x-architecture.html and thought I also did what it said, but I couldn’t get it to work. Then I started searching on the forum, and also found some topics there, but still no luck getting it to work, so clearly there is something I am not understanding properly.

I am trying to do the configuration via text files, instead of Paper UI.

Here is what I did

broker.thing

mqtt:broker:selina_mqtt [ host="192.168.1.30", secure=false ]

mqtt.thing

Bridge mqtt:broker:selina_mqtt [ host="192.168.1.30", secure=false ]
{
    Thing mqtt:topic:aircondition {
    Channels:
        Type number : water_level "AC water level" [ stateTopic="/AC/water_level"]
    }
}

airconditon.items

Number ac_water_level	"Condensation water [%.0f %%]"		<sewerage>	(sensors)	{channel="mqtt:topic:aircondition:water_level"}

Log files

==> openhab.log <==
2019-05-19 09:09:39.924 [INFO ] [ebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder
2019-05-19 09:09:39.944 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2019-05-19 09:09:40.012 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Time zone set to 'Europe/Copenhagen'.
2019-05-19 09:09:40.017 [INFO ] [.core.internal.i18n.I18nProviderImpl] - Locale set to 'da_DK'.
2019-05-19 09:09:41.782 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'aircondition.items'
2019-05-19 09:09:42.538 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2019-05-19 09:09:42.650 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'nygade.sitemap'
2019-05-19 09:09:42.902 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.1.35:8080
2019-05-19 09:09:42.903 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.1.35:8443
2019-05-19 09:09:42.976 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui

==> events.log <==
2019-05-19 09:09:42.728 [.ItemChannelLinkAddedEvent] - Link 'ac_water_level-mqtt:topic:aircondition:water_level' has been added.
2019-05-19 09:09:42.732 [.ItemChannelLinkAddedEvent] - Link 'ac_water_level-mqtt:topic:6e94fcaf:ac_water_level' has been added.

So I am not getting any errors, but it isn’t working either. And there are two links being added, and I am not sure why the second one is there.This text will be hidden

Okay… I know why…

Renaming them to “.things” made it read the files, and then it started to work instantly.

I just spend a few hours trying to figure out what I did wrong… :neutral_face: And what I did wrong, was to follow what the instructions said.

If you have found instructions that are incorrect please file an issue or even better a PR. See How to file an Issue

One problem I have left, is

Link 'ac_water_level-mqtt:topic:6e94fcaf:ac_water_level' has been added.

still getting added, where could that be coming from?

The blog post is from me and contains invalid, wrong syntax for thing and item files.
The reason is: I don’t use those files, but I had to give those examples for the blog post to be approved.

How about updating the article then? Or deleting it?

Yes updating seems like a valid approach. So far nobody made a PR to fix the wrong syntax.

We can also delete it, but we do not have any documentation at the moment for mqtt thing and item syntax. I rather go with an update.