I have OH2 installed, the MQTT 1.9 binding installed, and OH1.x compatibilty = true.
Now, to configure/use the binding… Nothing showing under ‘Things’ in Paper UI.
Is it necessary to configure using a text file?
Do I configure this as an Item or a Thing, or both?
MQTT is running, and I can mosquitto_sub to the topics being published OK
The physical object is an ESP8266 with a DS18B20 temperature sensor, and a photocell on the analog input.
The intent is to read outside temperature and light levels, and to act on them ~ I’m in a wooded valley, and using (astro:sunset) to define “it’s getting dark” is proving too variable.
> Instead of the global configurations/openhab.cfg file, there is now an individual file per add-on in conf/services. The <key>: prepended to each configuration property is removed in the new <key>.cfg files.
I’ve configured my mqtt.cfg file to be as follows:
# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a default one is generated.
But in my mosquitto.log I see this:
1477129863: Client OpenHAB2 already connected, closing old connection.
1477129863: Client OpenHAB2 disconnected.
1477129863: New client connected from 192.168.5.3 as OpenHAB2 (c1, k60).
1477129873: New connection from 127.0.0.1 on port 1883.
Where is it getting the client ID of OpenHAB2 from? I’ve just uninstalled, deleted the mqtt*.cfg files and reinstalled the mqtt binding through PaperUI with the same output. I’m using OH2 Beta4 on the Pi
It’s happening while running, every ten seconds in fact!
2016-10-25 08:21:39.904 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection '<broker>'
2016-10-25 08:21:39.924 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
Connection lost (32109) - java.io.EOFException
Caused by: java.io.EOFException
... 1 more
2016-10-25 08:21:39.929 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'broker' was lost: Connection lost : ReasonCode 32109 : Cause : null
2016-10-25 08:21:39.931 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'broker'
1477383800: New connection from 192.168.5.3 on port 1883.
1477383800: Client OpenHAB2 already connected, closing old connection.
1477383800: Client OpenHAB2 disconnected.
1477383800: New client connected from 192.168.5.3 as OpenHAB2 (c1, k60).
1477383810: New connection from 127.0.0.1 on port 1883.
1477383810: Client OpenHAB2 already connected, closing old connection.
1477383810: Client OpenHAB2 disconnected.
1477383810: New client connected from 127.0.0.1 as OpenHAB2 (c1, k60).
1477383820: New connection from 192.168.5.3 on port 1883.
1477383820: Client OpenHAB2 already connected, closing old connection.
1477383820: Client OpenHAB2 disconnected.
1477383820: New client connected from 192.168.5.3 as OpenHAB2 (c1, k60).
I have an idea that the configuration for 1.x bindings that’s possible from the Paper UI is not coexisting properly with the contents of the <service>.cfg file. Any chance you have more MQTT configuration via the UI or other .cfg files?
@Rob_Pope I had a similar problem in the past… It was due to OpenHab 2 loading up the default mqtt.cfg config file (with the sample <broker> name)… it was my mistake since I removed the comments from the lines without adjusting the broker name… After I fixed the mistake, the <broker> info still remained (as a second broker) in OH2 “internal database” (I don’t know how to call it :)) and was causing errors because all other parameters for <broker> were null.
Try to check with the Karaf Console (ssh openhab@localhost -p 8101 with password: habopen) what has been already stored in the OH2 “internal database” by using:
config:edit org.openhab.mqtt config:property-list
Also, you can use: config:list to show you all bindings configs stored.
You can start clean by configuring your mqtt.cfg and mqtt-eventbus.cfg and clearing out whatever is stored already by: config:delete org.openhab.mqtt and then restarting OH2 to reload the .cfg files
@Dim, would you be willing to write this posting up as a quick tutorial as a top level thread under Tutorials and Examples? I think this really important and not well known and it actually answers a lot of questions I had. Eventually I can see this migrating to the official docs.
Absolutely. I will give it a try and write some examples on how to “manage” configurations that are already stored within the OpenHab 2 OSGi cache. I am not an expert in Apache Karaf, so I will need help to “iron-out” any errors
Please Help, I spent the day trying to debug.
I have run out of ides…
The best I can tell when I press the switch It triggers a event
2017-01-20 17:00:24.129 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection ''
2017-01-20 17:02:56.931 [DEBUG] [inding.mqtt.internal.MqttItemBinding] - Publishing command ON to control/SW010101/command
But the broker does not see any <> messages from OH2:
1484950320: Sending CONNACK to paho-263225371366065 (0, 0)
1484950321: Received PUBLISH from paho-263225371366065 (d0, q0, r0, m0, ‘control/SW010101/command’, … (2 bytes))
1484950322: Received PUBLISH from WallSwitch001 (d0, q0, r0, m0, ‘control/SW010101/SW1/state’, … (1 bytes))
1484950330: Received PINGREQ from Openhab2
1484950330: Sending PINGRESP to Openhab2
the broker does see Openhab:
1484950210: Sending CONNACK to Openhab2 (0, 0)
1484950217: Received PINGREQ from WallSwitch001