Hello! I have some difficulties with my project. I am new to Openhab to i wanted to do something simple to just learn how it works. I want to just turn on and off LED connected to esp8266. I configured Openhab and espeasy however something is not working. I got this kind of error in log
2018-08-31 20:59:00.456 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'komar'
2018-08-31 20:59:02.330 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttSecurityException: Not authorized to connect
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:28) [202:org.openhab.io.transport.mqtt:1.12.0]
at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:990) [202:org.openhab.io.transport.mqtt:1.12.0]
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:118) [202:org.openhab.io.transport.mqtt:1.12.0]
at java.lang.Thread.run(Thread.java:748) [?:?]
And I have tested if mosquitto is working using mqttfx. So I quess there must be some mistake in openhabian configuration or in esp easy, but I have no idea where.
This is ma mqtt.cfg, rest of it is unchanged.
#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#
# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
komar.url=tcp://192.168.8.114:1883
# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
komar.clientId=openhab2
If the Unit Name in Config tab is esp8266 and your using the GPIO pin 0 it looks ok. I would try capitalizing the gpio and there is some who will say that the leading / is not needed but I have used with and without and no issue.
@vzorglub made a good point about the user name and password. Looking at the doc’s and how the mqtt cfg file has it as optional is a bit confusing. That being said, if you are not using a user name and password you should add it (both in OH and Esp Easy). ClientId is optional and for now comment it out.
sooo… I added user and password both in OH and ESP, capitalized gpio, commented out clientid and still getting same error. Any other ideas? Maybe something with Controller Subscribe and Publish in ESP Easy? What should I put there?
Do you have the MQTT Action installed?
If yes, remove it
Also add:
pid:org.openhab.mqtt
At the very top (first line) of the mqqt.cfg file. That will force OH to ignore any previous config that may remain in the cache config
Remove the pid:org.openhab.mqtt from mqtt.cfg, make sure the user name and password looks like: komar.user=your user name and komar.pwd=your password. Then from terminal type the following, all on one line, even the grey part.
This should clear out any previous configs your no longer using.
In the Esp Easy UI, controller tab, verify your using the same user name and password thats in the mqtt.cfg file. See below for example I have user as openhabian.
ok so quick update. I started everything from scratch. Reinstalled software on pi and esp and everything works now. I have no idea what was wrong previously. Anyway thank you for your help. And btw everything works fine without putting user and password in mqtt.conf.