MQTT Help in docker openhab install

  • Platform information:
    • Hardware: AMD64
    • OS: ubuntu 20 running docker
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version:2.5.5
  • Issue of the topic: I’m having trouble making my openhab running in docker pickup the MQTT

This is the GPS.things file I created

Bridge mqtt:broker:GPS “MQTT Broker”
[
host=“10.1.40.9”,
port=1883,
secure=false,
clientid=“openhab”
]

Thing mqtt:topic:GPS:chris “Chris GPS” (mqtt:broker:GPS) @ “GPS”
{
Channels:
Type string : Place "Location: " [ stateTopic=“location” ]
Type number : Battery "Battery: " [ stateTopic=“batt” ]
Type number : Latitude "Lat Coordinates: " [ stateTopic=“lat” ]
Type number : Longitude "Lon Coordinates: " [ stateTopic=“lon” ]
Type number : Accuracy "Accuracy: " [stateTopic=“acc” ]
}

This is my GPS.items file I created

String Chris_Location “Chris Location: [%s]” (GPS) {mqtt="<[mqtt:broker:GPS/chris:state:JSONPATH($.locname):.*]"}

Number Chris_Batt “Chris Battery: [%]” (GPS, Battery) {mqtt="<[mqtt:broker:GPS/chris:state:JSONPATH($.batt):.*]"}

Location Chris_Loc “Chris Location [%s]” (GPS) { mqtt="<[mqtt:broker:GPS/chris:state:JS(owntracks-coordinates.js)]" }

This is the owntracks-coordinates.js file I created
var location = JSON.parse(input);
result = lat + “,” + lon;

I’ve connected to the MQTT server and I can verify that information is being received and that openhab is connecting to it

Output from the MQTT server

chris = {“acc”:50,“lon”:-00.163479,“lat”:00.0984925,“batt”: 18,“location”: Home}
*I manually changed the coordinates for my security when posting.

for the life of me I cannot figure out what I’m doing wrong that none of my items are being populated in openhab everything is coming back blank or not

Control Output in PaperUI

Chris Location: -
Chris Battery: -

For a little back story I was running this in openhabian on a raspberry pi but my SD card corrupted so I decided to move it over to a desktop running docker. Everything else is running great just having issues with this. I didn’t have issues with the script before which generates this MQTT information and obviously the MQTT is working as I can see if on the server. I’m at my wits end here. would love any insight you can give.

Chris

But, can openHAB connect to it? What does your openhab.log have to say about this?

These are MQTT binding version 1 configurations, and wil never work with the Things and channels of version 2.

Don’t think this will work. What are variables lat and lon?

Openhab is connecting to the mqtt server. The bridge I created shows it is connected as well as it’s showing as a connected client and the log file concurs. I’ve installed the mqtt 2 binding on openhab

Every article showing how to create mqtt connections shows me the same way what am I doing wrong?

Lon and Lat area longitude and latitude variables that are being passed to the mqtt server but that’s a secondary issue honestly because I’m not getting any of the data let alone those variables.

Regards

Chris

Don’t know what you are looking at.
Older postings will invariably be about MQTT binding version 1. But of course they won’t say that, since there was only a version 1 at the time.
{mqtt="blah"}
is version 1 notation and simply will never work with v2 binding

{channel="blah"}
is version 2 notation for use with any binding
You use that when you have configured Things and channels.

Here are the version 2 docs

I wasn’t able to make heads or tails out of it. I reverted back to mqqt 1.x bindings and resolved my own issue.