Is my Openhab to MQTT connection broken?

I’m very new to openHAB, more at the looking at it and testing proof of concept.

I’m having issues that I thought was me not knowing enough getting data (temps etc) to show up in openHAB. I was happily making sense of everything until I started wondering.

I have a win 10 SFF PC (don’t hate me :slight_smile: ) on 192.168.1.162 (static IP) with Mosquitto and Openhab working on it. A tasmota device is talking to the MQTT server, and I can see that data using MQTT-SPY on my PC and on the ‘server’. Tasmota’s console is showing data going to the MQTT server.

I assumed it was down to a mis-configuration and I’ve been working my way thru it, with a view to understanding it better… I thought I’d look at the (openHAB) logs to see if there was anything obvious.

I got ; "

> 22:14:26.337 [INFO ] [o.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.1.162' with clientid fffbe576-441a-4ef7-93d2-04e58993d0c6
> 22:15:26.354 [INFO ] [t.reconnect.PeriodicReconnectStrategy] - Try to restore connection to '192.168.1.162'. Next attempt in 60000ms
> 22:15:26.354 [INFO ] [o.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.1.162' with clientid fffbe576-441a-4ef7-93d2-04e58993d0c6

"

Does this denote an openHAB to MQTT connection issue? Resulting in my not getting any data to openHAB?

I ask this before I start posting the broker connection and things to this chat.

Thanks in advance,

Yes that looks like openhab can’t connect to mosquitto

Welcome!

Yep, this sounds like an issue communicating with Mosquitto. In general, it’s better to just post any config/settings that you suspect to be a problem in your first post. If you’re on the right track, you’ll get a faster response (and others don’t have to ask for them).

You should have gotten this template when you started your message. You answered most of it, but following the layout really does help us to help you (even if you just answer “I don’t know” to some things). In particular, I don’t know which version of OH you’re on, and don’t want to assume it’s OH3.

  • Platform information:
    • Hardware: CPUArchitecture/RAM/storage
    • OS: what OS is used and which version
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version:
  • Issue of the topic: please be detailed explaining your issue
  • Please post configurations (if applicable):
    • Items configuration related to the issue
    • Sitemap configuration related to the issue
    • Rules code related to the issue
    • Services configuration related to the issue
  • If logs where generated please post these here using code fences:

OH, now greater minds then me think it’s a comms issue;

  • Platform information:

    • Hardware: CPUArchitecture/RAM/storage Intel I5 something/8gb/256ssd
    • OS: what OS is used and which version Win 10 1903
    • Java Runtime Environment: which java platform is used and what version [Azul Zulu] as per openHAB pre-requsites.
    • openHAB version: Version 3. As downloaded 1 week ago.
  • Please post configurations (if applicable): Please correct me if I’ve missed anything, but since it’s initally a openHAB to MQTT issue, I’m just post that broker if that’s ok? Seem’s better the flooding you with pages and pages.

      UID: mqtt:broker:LocalMQTT
      label: MQTT Broker
      thingTypeUID: mqtt:broker
      configuration:
    lwtQos: 0
    publickeypin: true
    keepAlive: 60
    clientid: 941fdc6b-470e-4106-803e-5a800fdcc69a
    qos: 0
    reconnectTime: 60000
    host: 192.168.1.162
    secure: false
    certificatepin: true
    lwtRetain: true
    enableDiscovery: true
    
    
     UID: mqtt:topic:LocalMQTT:Tasmota1
    label: Generic MQTT Thing
    thingTypeUID: mqtt:topic
    configuration: {}
    bridgeUID: mqtt:broker:LocalMQTT
    channels:
      - id: Temperature
        channelTypeUID: mqtt:number
        label: Air Temperature
        description: ""
        configuration:
          stateTopic: tele/Tasmota_06X/SENSOR
    

I don’t know if anything else is relavent. I understand the need for comprehensive information to assist me, but I don’t fully know what is needed, and I’m doing this all from the UID. Hope it’s good?

It may be something to do with your PIN for a test can you set publickeypin:false and certificatepin:false

Hi,

I did wonder about that, as I choose defaults. I’ve changed them.

UID: mqtt:broker:LocalMQTT
label: MQTT Broker
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: false
  keepAlive: 60
  clientid: 8893fa46-9de7-45ca-a0fd-ae3f7dfedea5
  qos: 0
  reconnectTime: 60000
  host: 192.168.1.162
  secure: false
  certificatepin: false
  lwtRetain: true
  enableDiscovery: true

and now get ;

   openhab> log:clear
   openhab> log:display

   openhab> log:display
   00:07:27.579 [INFO ] [t.reconnect.PeriodicReconnectStrategy] - Try to restore co   nnection to '192.168.1.162'. Next attempt in 60000ms
  00:07:27.579 [INFO ] [o.transport.mqtt.MqttBrokerConnection] - Starting MQTT bro   ker connection to '192.168.1.162' with clientid fffbe576-441a-4ef7-93d2-04e58993   d0c6
   00:08:27.584 [INFO ] [t.reconnect.PeriodicReconnectStrategy] - Try to restore co   nnection to '192.168.1.162'. Next attempt in 60000ms
   00:08:27.584 [INFO ] [o.transport.mqtt.MqttBrokerConnection] - Starting MQTT bro   ker connection to '192.168.1.162' with clientid fffbe576-441a-4ef7-93d2-04e58993   d0c6

   openhab>

It’s worth noting, possibly, I set this up so far using the tutorial’s on openHAB. everything was default apart from names and IP’s. There is no security at the moment.

I think the thing that’s caused confusion is that the web page says the broker is on-line. I guess that means the connection is turned on, not communicating.

For sure. As you say, the tricky part is that you don’t know what’s needed. But when you provide something/anything, it shows us that you’re willing and able to meet us halfway. And as I said before, sometimes the solution is almost immediate (though that doesn’t seem like it’ll be the case here).

Which tutorials? I was just going to ask if you set up username/password in your Mosquitto broker.

For reference, here’s what my broker connection looks like (with user/pass omitted):

UID: mqtt:broker:mosquitto
label: Mosquitto MQTT Broker
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: true
  clientID: OpenHAB
  keepAlive: 60
  secure: false
  certificatepin: true
  password: ****
  qos: 0
  reconnectTime: 60000
  port: 1883
  host: openhab
  lwtRetain: true
  username: ****
  enableDiscovery: true

Tutorials as per here. Getting Started - Introduction | openHAB

I’ll address the username and password tomorrow. I assume it’s in a conf or ini file somwhere. I’ll report back.

Thanks for the help.

Update after an hour of changes (remember to remove the # from mosquitto.conf!!)

I’ve setup a username and password as suggested. and set the line allow_anonymous false (was true) to disallow anonymous entrys

I’m now getting

2021-01-26T17:39:51: New client connected from 192.168.1.162:55600 as openHAB (p2, c1, k60, u'mosquitto_admin')..

from $SYS$/# topic.

This looks good. After some struggle I seem to have the Tasmota client talking to Mosquitto and the openHAB talking to mosquitto as well. An openHAB is now showing Data! Yea!

1 Like