MQTT Binding 2.4 System Broker "Ghost"

A little history, I’m new to openHab, migrated from Smartthings. I’ve been learning as I go with a no programming experience. (Just a little Basic commadore 64)

In three or four weeks time, I’m running openhabian on a Pi 3 B. I’ve learned Item, Rules, Maps, etc. and tried following the rule design principles

I have my first ESP8266 based sensor up and running and chopped up arduino code running on it it communicating via MQTT.
I installed the MQTT 2.4 Binding watched the videos, read the documentation and the boards but I’m really having a tough time with this. I do not have an extenal MQTT server
My first try at set-up, my Sensor couldn’t connect. I troubleshot. INCLUDING uninstalling and reinstalling the MQTT 2.4 binding.
I finally got the sensor to connect to the MQTT Broker but could get any data into any items.

I’ve been at it for two days and I’m about to give up. so I though i’d start from scratch one more time.
I uninstalled the Generic MQTT thing (including the channels)
I uninstalled the MQTT Thing (Broker)
I uninstalled the MQTT Binding 2.4
Restarted the PI and noticed my sensor lost connection as it was restarting, but re-established a connection. I have no external MQTT server, so I’m guessing there is a ghost of the broker still on my PI

This is my first question ever on the site, my apologies if this is the wrong topic or way to address this.
So the question is:

How can I delete and/or find and correct these files?

I see a complete reload in my future, but I thought I’d ask first

Sometimes you need to clean the cache after uninstalling bindings and making lots of changes.

sudo systemctl stop openhab2

sudo openhab-cli clean-cache

sudo systemctl start openhab2
or
sudo reboot

Post what you have so far and I’m sure someone will be glad to help.

Thanks for the fast reply, I did a sudo reboot, that’s when i noticed the loss of connection and the re-connect. I will try the others.

Well, I haven’t much. I have been creating the Broker with Paper UI, and then I just have linked Items. each is a test, I thought it may have been the item type that was stopped the data.

Switch Basement_Sensor   "Basement motion"   { channel="mqtt:topic:Basement:motion" }
Number Basement_Sensor_temp   "Basement Temp [ %.1f °F ]"   { channel="mqtt:topic:Basement:temperature" }
String Basement_Sensor_hum   "Basement hum [ %s ]"   { channel="mqtt:topic:Basement:humidity" }
Number Basement_sensortest "Sensortest temp" { channel="mqtt:topic:Basement:temp2" }

as for the PI I cleared the cache and rebooted, and my sensor still has a connection, even after resetting it. The MQTT “Ghost” must be one the first parts of code that gets loaded. My sensor re-establishes a connection almost immediately after the Pi starts

I haven’t moved to the new 2.x binding but I do remember that others had an issue and need to upgrade to OH 2.5 snapshot for the fix. Hope this helps.

This is a little confusing because there is a difference between the actual embedded broker and the connection to the broker. The connection to the broker is represented by a Broker Thing. So if you just deleted the Thing you just deleted the connection OH has to the embedded broker.

The broker itself you will find the configuration for under Configuration → Bindings. To remove the embedded broker, you need to uninstall the Add-On.

But, since your sensor is successfully connected I’d say leave it be, it’s working.

So since we know the emebedded broker is working you next need to create the MQTT Broker Thing. This represents the connection to the Broker. If it successfully connects to the broker it will show as Online in PaperUI.

Next you need to create your Things. It sounds like you need to create Generic MQTT Things. Create one Thing for each device. I sounds like you have one device at this time so create a single Thing.

Now create a Channel for each Thing. Now here is where I think you may have gone wrong. What makes up the message for the motion sensor topic? If it isn’t “ON” and “OFF” you need to transform the message to “ON” or “OFF” inorder for it to work. The type of the Channel also needs to be On Off switch and this Channel can ONLY be linked to a Switch Item. If you link it to any other Item type nothing will happen.

The Channel type for the temp and temp2 Channels need to be Number and the Channel type for hum needs to be Text.

@rlkoshak Thank you for the reply, I learned a ton from your design pattern posts.

I have uninstalled everything hoping for a clean start.

The add-on is un-installed: there is no MQTT under Add-ons

I think you are correct, but I was trying to start fresh so I could get the names of everything correct. ie server name, broker name, device name, topic, channel

I have a motion sensor that sends a 1
DHT22 sensor that sends a string that is a number (because MQTT only sends strings?)

I tried a switch channel for the motion sensor, I tried a text channel and a number channel for the temperature.

If I install the binding, then install the system Broker I get an error: OFFLINE (CONFIGURATION_ERROR): The system connection with the name homebroker doesnt exist anymore.

but I can create a broker thing (which goes ONLINE) and then a Generic MQTT thing with the channels. when I do, I don’t get any data. in the paper UI - control i see - for humidity and NaN for temperature.
I watch the log feed and don’t see any update, only the actual items update when i save the item file.

Here is the error log when I delete the System MQTT Broker. (time: 18:04)
Then created a Broker Thing (time: 18:07)

2019-01-18 18:04:25.628 [hingStatusInfoChangedEvent] - 'mqtt:systemBroker:90bd732b' changed from OFFLINE (CONFIGURATION_ERROR): The system connection with the name SBroker doesnt exist anymore. to REMOVING

2019-01-18 18:04:25.636 [hingStatusInfoChangedEvent] - 'mqtt:systemBroker:90bd732b' changed from REMOVING to REMOVED

2019-01-18 18:04:25.643 [hingStatusInfoChangedEvent] - 'mqtt:systemBroker:90bd732b' changed from REMOVED to UNINITIALIZED

2019-01-18 18:04:25.642 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.dispose()' on 'org.eclipse.smarthome.binding.mqtt.handler.SystemBrokerHandler@13f45c5': null

	at org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler.dispose(AbstractBrokerHandler.java:141) ~[?:?]

	at org.eclipse.smarthome.binding.mqtt.handler.SystemBrokerHandler.dispose(SystemBrokerHandler.java:133) ~[?:?]

2019-01-18 18:04:25.671 [ERROR] [core.thing.internal.ThingManagerImpl] - Exception occurred while disposing handler of thing 'mqtt:systemBroker:90bd732b': null

	at org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler.dispose(AbstractBrokerHandler.java:141) ~[?:?]

	at org.eclipse.smarthome.binding.mqtt.handler.SystemBrokerHandler.dispose(SystemBrokerHandler.java:133) ~[?:?]

2019-01-18 18:04:25.719 [hingStatusInfoChangedEvent] - 'mqtt:systemBroker:90bd732b' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

2019-01-18 18:07:29.895 [hingStatusInfoChangedEvent] - 'mqtt:broker:0661030d' changed from UNINITIALIZED to INITIALIZING

2019-01-18 18:07:30.013 [hingStatusInfoChangedEvent] - 'mqtt:broker:0661030d' changed from INITIALIZING to OFFLINE

2019-01-18 18:07:30.110 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '192.168.1.232' with clientid paho19030931491603 and file store '/var/lib/openhab2/mqtt/192.168.1.232'

2019-01-18 18:07:30.176 [hingStatusInfoChangedEvent] - 'mqtt:broker:0661030d' changed from OFFLINE to ONLINE

2019-01-18 18:07:30.285 [me.event.ThingUpdatedEvent] - Thing 'mqtt:broker:0661030d' has been updated.

It looks like the Broker thing (0661030d) is connecting to clientid paho19030931491603 but there is no System MQTT running… it’s my “ghost”
How do I fully delete it? is it located at: ‘/var/lib/openhab2/mqtt/192.168.1.232’?

I’m all out of options. I followed all the steps.

Here is my Things file:

Bridge mqtt:broker:0661030d [ host="192.168.1.232", secure=false ]
{
    Thing topic Basement {
    Channels:
        Type switch : motion "Motion Sensor" [ stateTopic="motion/state" on="1", off="0" ]
        Type number : temperature "Temperature Sensor" [stateTopic="temperature"]
        Type number : temperature "Humidity Sensor" [stateTopic="humidity"]
        
        
    }
}

Here are my Items

Switch Basement_Sensor   "Basement motion"   { channel="mqtt:topic:0661030d:Basement:motion" }
Number Basement_Sensor_Temp   "Basement Temp [ %.1f °F ]"   { channel="mqtt:topic:0661030d:Basement:temperature" }
Number Basement_Sensor_Humid   "Basement Humidity [ %d %% ]"   { channel="mqtt:topic:0661030d:Basement:humidity" }

and here are my sitemap entries:

Text item=Basement_Sensor_Humid label="Humidity" icon="humidity"  
        Text item=Basement_Sensor_Temp label="Temperature" icon="temperature"  
        Switch item=Basement_Sensor label="Motion" icon="motion" 

No Joy. :frowning:

Try netstat -tulpen | grep 1883 and see if there is any application running that provides a service on that port. There’s maybe a running mosquitto mqtt broker or so? Please find out and report back.

Here are the results:

tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN 0 12338 413/mosquitto
tcp6 0 0 :::1883 :::* LISTEN 0 12339 413/mosquitto

I don’t know what it means though.

It means you have the Mosquito broker installed and running. You either need to use it or you need to uninstall it to use the embedded broker.

Since you have your devices already successfully talking to Mosquito I would keep using that broker.

1 Like

Turns out, I installed the MQTT option when I installed openhabian. there wasn’t a “ghost” that was left over, it was there before the 2.4 release… still can’t figure this MQTT out…but I’m still trying.