Hello,
i have problems to get my mqtt binding working proberbly.
MQTT binding is installed, nothing else.
In config i tried all you can find in www, now it has only “mosquitto.url=tcp://192.168.178.95:8888” and the connection is established.
Mosquito broker is working under this address and the openhab2 log gives me no error
2018-07-14 22:59:04.115 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
LOG
--------------------------
2018-07-14 22:59:04.117 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'
==> /var/log/openhab2/events.log <==
2018-07-14 22:59:48.553 [ome.event.ItemCommandEvent] - Item 'MQTT_Switch_Command' received command ON
2018-07-14 22:59:48.616 [vent.ItemStateChangedEvent] - MQTT_Switch_Command changed from NULL to ON
-----------------------------
Here you can see, that Openhab recognize if i triggered the switch, but didnt send anything through mqtt.
The MQTT broker (Mosquitto) is tested with an esp8266 and worked. I tested it with MQTT.fx
I’ve been trying to get that working for the past 3 days, but I definitely need help !!
Sorry for my bad english!
best regards,
Marc
update
Mosquito log =>
1531601944: New connection from 192.168.178.95 on port 8888.
1531601944: New client connected from 192.168.178.95 as paho89601675222578 (c1, k60).
installed:
clean install with the openhab2 image for raspi ==> I used a raspi 3 b +
installed mosquitto => config anonymous connection allowed => on port 8888
install mqtt binding in openhab (nothing else)
in services/mqtt.conf added the following line “mosquitto.url=tcp://192.168.178.95:8888”
create item and sitemap i listed below
tested the mosquitto mqtt broker with esp8266 and all worked fine (but openhab2 did nothing over mqtt => tested with mqtt.fx => subscribed # to see all postings, also esp/station001 )
Here is my mqtt.cfg
it has only the .url
but i tried all … rly all other things
If active…MQTT Event Bus Binding works perfect!
#
# 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
#<broker>.url=tcp://<host>:1883
# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
#<broker>.clientId=<clientId>
# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false
mosquitto.url=tcp://192.168.178.95:8888
# Optional. User id to authenticate with the broker.
#<broker>.user=<user>
# Optional. Password to authenticate with the broker.
#<broker>.pwd=<password>
# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>
# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>
# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>
# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>```
Yes, i use MQTT.fy and subscribed # to get all messages and i also subscribed “esp/station001”
The broker was tested with an esp8266 on esp/station001 and worked.
If i activate the mqtt event bus, i got those mqtt messages from openhab.
I added the space at the begining and end, but mqtt still wont work, sry.
mybe important, all i write in config and items/sitemaps, i type in nano in/over ssh on raspi 3b+
If i restart mosquitto, then i have the following log entry in Openhab.The reconnect did fine.
2018-07-15 00:25:48.763 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'mosquitto' was lost: Connection lost : ReasonCode 32109 : Cause : null
2018-07-15 00:25:48.767 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'mosquitto'
2018-07-15 00:25:58.776 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'
Dim i tried this after reading 2 days ago but still no mqtt messages (openhab cache and temp cleared after changes).
I set the pid in the first line in mqtt.cfg
Thedannymullen:
All other ports are default, i changed only the mosquitto broker to 8888 and set it right in the mqtt.conf. Do you know, it has to be changed in other places too?
Thanks for your reply.
Openhab still connects to the broker, you can see in first reply/message i will update this with all i try to get mqtt working. The mosquitto get connection from openhab2. If i restart mosquitto then openhab reconnects by itself.
I have no log from this but i had no errors, still broker connection but no mqtt messages from item.
Mqtt eventbus works perfect, but i need the item messages.
But yes, mqtt action wasnt installed.
This is strange… the MQTT-EventBUS is working but not the Item lines… I have never seen this before
This points to the direction of a syntax error in the Item config (although I don’t see any errors in your stuff)
Here is the eventbus.cfg, i only copied the example from Doc, when i changed my item-Switch i got the mqtt messages for command and state, also i can change the switch state with mqtt.fx, when publishing the right message.
Make another simple test.items file and enter this Item alone in there…
Try to increase the log levels for the MQTT Binding also to see if more useful info come up
@iMarc92 yes if you change in one place you will need everything to be on port 8888.
Here is a simple example the best way I know to explain. Openhab2 runs its web service on port 8080. If you go to a browser an try to communicate on port 5020 you will get a blank screen. This is because you have to have two components to see the openhab2 website the IP address and the port. Mosquito works much the same way. You need the broker and openhab2 to be talking to the same port and ip combination or else you will get nothing.
I would also ask one question in the end. Is there a reason you changed the port? Why not just leave it the same, it will make things a little less error prone.
I know how it works and i know how to configure tcp/ip websoc etc, i developed some other programs in the past, but this here I just can not get it to work. And you can see in this thread, that the connection is not the problem. MQTT broker and openhab can communicate (the mqtt eventbus work well) only the item did nothing.
I changed the port, because i have learned that you shouldn`t use standard ports (security ).
But thank you for your reply.
I found the problem, i thought.
It was an syntax error… maybe the linending in nano editor or something else. If i created the test.items in editor on windows and copy them over to the PI, it works !! …
I created my items again and it works too…