[SOLVED] OHv2 Help with MQTT v1 please

I have migrated from OHv1 to v2… now it comes to MQTT

I’d like to use v1 of the MQTT binding, because it means I would not have to change any of the items.

My addon.cfg has these entries:

binding = expire1,fritzboxtr0641,http1,mqtt1,networkhealth1,weather1,astro,exec,ntp,systeminfo
# removed mqtt action based on https://community.openhab.org/t/solved-mqtt-binding-stopped-working-after-todays-snapshot-update/19447/13
#action = mail,mqtt
action = mail

When I had the mqtt action enabled, I got an error:

2018-12-28 10:57:29.095 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mymosquitto'
2018-12-28 10:57:29.195 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttException: MqttException
        at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38) ~[?:?]
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664) ~[?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.net.UnknownHostException: 192.1681.66
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) ~[?:?]
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]
        at java.net.Socket.connect(Socket.java:589) ~[?:?]
        at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:70) ~[?:?]
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) ~[?:?]
        ... 1 more
2018-12-28 10:57:29.230 [ERROR] [org.apache.felix.configadmin        ] - Cannot use configuration org.openhab.mqtt for [org.openhab.core.scriptengine.action.ActionService, org.osgi.service.cm.ManagedService, id=390, bundle=222/mvn:org.openhab.action/org.openhab.action.mqtt/1.13.0]: No visibility to configuration bound to mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.13.0

The mqtt.cfg looks like this:

# 181228-0940 MaxG added as per https://community.openhab.org/t/need-help-to-setup-mqtt-binding-on-oh2/45677/5
pid:org.openhab.mqtt
# results in error

mymosquitto.url=tcp://192.168.1.66:1883
mymosquitto.clientId=openhab

What puzzles me is, where do I tell openHAB that the clientID is ‘openhab’?

mosquitto is working, as I can see data coming with:

mosquitto_sub -v -t ArgyleCourt/#
ArgyleCourt/Shed/Tower/BMS/BatteryCapacity 20.0
ArgyleCourt/Shed/Tower/BMS/BatteryPower -11.0
ArgyleCourt/Shed/Tower/BMS/BatteryTemperature 30.437
ArgyleCourt/Shed/GroundFloor/LivingRoom/AmbientLight/Lux 18.07
ArgyleCourt/Shed/GroundFloor/LivingRoom/AmbientLight/Visible 3270
ArgyleCourt/Shed/GroundFloor/LivingRoom/AmbientLight/IR 1780
ArgyleCourt/House/TriSensor/South/Barometer1 995.58
ArgyleCourt/House/TriSensor/South/Humidity1 50.05
ArgyleCourt/House/TriSensor/South/Temperature1 26.55

Any hints appreciated…

Well, my mistake… did not change the IP address in mqtt.cfg :frowning:
Also, the mqtt action entry is required for mqtt v1 to work; it is needed to 'publish".

However, seeing this:

2018-12-28 11:34:50.161 [WARN ] [g.dispatch.internal.ConfigDispatcher] - The file /etc/openhab2/services/mqtt.cfg subsequently defines the exclusive PID 'org.openhab.mqtt'. Overriding existing configuration now.

Is this pid entry in mqtt.cfg required or not?

It is required exactly once in the file. Actually it is not really required but a feature and good habit. If you remove the file, the config manager will remove all entries from the cache for you.