Loops by send state from MQTT

Hi there,

I am new in OH2. I have an simple configuaration for access from Java using Paho.
The goal is to receive a notification to my Java-App when I press the switch in OH.

I use a simple Swich

Switch java_text "Text von Java" <text> (gWRaumEG) { mqtt=">[localbroker:/IoTDemo/openHAB/java_text/command:command:OFF:0],>[localbroker:/IoTDemo/openHAB/java_text/command:command:ON:1],<[localbroker:/IoTDemo/openHAB/java_text/state:state:default]"}

Generally it works when I use this in my openhab.cfg:

mqtt-eventbus:commandSubscribeTopic=/IoTDemo/openHAB/#
mqtt-eventbus:stateSubscribeTopic=/IoTDemo/openHAB/#

but when I use this and press the switch (or send command from Java by MQTT), my mosquitto wents go into loop for Sending PUBLISH and Received PUBACK repeatly:

mqtt-eventbus:commandSubscribeTopic=/IoTDemo/openHAB/+/command
mqtt-eventbus:stateSubscribeTopic=/IoTDemo/openHAB/+/state

(… when I change back, it still comes into the loop…:open_mouth:)

What could be the problem. Thank you for any idea.

I don’t see the need for the MQTT Event Bus binding in your goal. Do you have other goals?

Im not sure i understand you correctly, I am german speeker…

My goal ist to write an management system and also measuring station written in Java. So my communication goes to mosquitto - server by using mqtt.
An also to embed openHAB.

curiously… when I change

<[localbroker:/IoTDemo/openHAB/java_text/ state:state:default]

to

<[localbroker:/IoTDemo/openHAB/java_text/ command:state:default]

and use

mqtt-eventbus:stateSubscribeTopic=/IoTDemo/openHAB/#
mqtt-eventbus:commandSubscribeTopic=/IoTDemo/openHAB/#

in openhab.cfg, it works as expected.

My completly openhab.cfg:

mqtt:localbroker.url=tcp://localhost:1883
mqtt:localbroker.clientId=openHABservice
mqtt:localbroker.qos=1
  
mqtt-eventbus:broker=localbroker
mqtt-eventbus:commandPublishTopic=/IoTDemo/openHAB/${item}/command
mqtt-eventbus:statePublishTopic=/IoTDemo/openHAB/${item}/state
mqtt-eventbus:stateSubscribeTopic=/IoTDemo/openHAB/#
mqtt-eventbus:commandSubscribeTopic=/IoTDemo/openHAB/#

Any idea what the problem is?

I don’t have a solution but the same issue. As soon as I configure the

mqtt-eventbus:statePublishTopic

in the mqtt-eventbus.cfg I’m getting a loop and evey item I switch on/off after mosquitto has been started loops until i stop mosquitto. Mosquitto itself seems to work fine because I’m using it with owntracks.

You also can restart openHab daemon to stop loops.

As @watou alluded to, you shouldn’t need to mess with the MQTT event bus for what it sounds like you’re doing (sending a payload to an MQTT topic based on a switch state).

Ok, but its not only to send some switch state, I also wants to reseive any event from MQTT to update item state.