OpenHAB and MQTT Gateway: moving to GatewayClient - Issue
-
Hello to all!
I've used OpenHAB with MQTT Gateway for a while without issues.
Now I would like to use local MQTT (mosquitto) and use the MQTTClientGateway to publish/subscribe to mosquitto the messages.
Manually works all well. I can publish manually commands and and the relays on the remote node starts or stops.
BUT, when I configure OpenHAB, changing the publish address, it creates a loop ON/OFF as soon I try to turn a light on. Seems disco :dancer:This is the old binding using MQTT Gateway (not client):
Switch node20_sw2 "Relay02" (all,node20) { mqtt=">[mysensor:MyMQTT/20/2/V_LIGHT:command:ON:1],>[mysensor:MyMQTT/20/2/V_LIGHT:command:OFF:0],<[mysensor:MyMQTT/20/2/V_LIGHT:command:MAP(1on0off.map)]" }This has worked very well.
Now I'm using this:
Switch node20_sw2 "Luce Stufa" (all,node20) { mqtt=">[mysensor:mygateway1-in/20/2/1/0/2:command:ON:1],>[mysensor:mygateway1-in/20/2/1/0/2:command:OFF:0],<[mysensor:mysensor:mygateway1-in/20/2/1/0/2:command:MAP(1on0off.map)]" }It happens that OpenHAB sends out the message, and I got a reply message back which is replied i immediatly with an OFF:
21:22:30.396 [DEBUG] [.mqtt.internal.MqttItemBinding:44 ] - Publishing command ON to mygateway1-in/20/2/1/0/2 21:22:30.398 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:437 ] - Publishing message 2680 to topic 'mygateway1-in/20/2/1/0/2' 21:22:30.401 [DEBUG] [.mqtt.internal.MqttItemBinding:44 ] - Publishing command ON to mygateway1-in/20/2/1/0/2 21:22:30.402 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:437 ] - Publishing message 2681 to topic 'mygateway1-in/20/2/1/0/2' 21:22:30.405 [DEBUG] [.mqtt.internal.MqttItemBinding:44 ] - Publishing command ON to mygateway1-in/20/2/1/0/2 21:22:30.407 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:437 ] - Publishing message 2682 to topic 'mygateway1-in/20/2/1/0/2' 21:22:30.422 [DEBUG] [.mqtt.internal.MqttItemBinding:44 ] - Publishing command OFF to mygateway1-in/20/2/1/0/2 21:22:30.424 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:437 ] - Publishing message 2683 to topic 'mygateway1-in/20/2/1/0/2' 21:22:30.427 [DEBUG] [.mqtt.internal.MqttItemBinding:44 ] - Publishing command OFF to mygateway1-in/20/2/1/0/2 21:22:30.429 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:437 ] - Publishing message 2684 to topic 'mygateway1-in/20/2/1/0/2' 21:22:30.432 [DEBUG] [.mqtt.internal.MqttItemBinding:44 ] - Publishing command OFF to mygateway1-in/20/2/1/0/2 21:22:30.434 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:437 ] - Publishing message 2685 to topic 'mygateway1-in/20/2/1/0/2' 21:22:30.450 [DEBUG] [.mqtt.internal.MqttItemBinding:44 ] - Publishing command ON to mygateway1-in/20/2/1/0/2 21:22:30.452 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:437 ] - Publishing message 2686 to topic 'mygateway1-in/20/2/1/0/2' 21:22:30.455 [DEBUG] [.mqtt.internal.MqttItemBinding:44 ] - Publishing command ON to mygateway1-in/20/2/1/0/2 21:22:30.457 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:437 ] - Publishing message 2687 to topic 'mygateway1-in/20/2/1/0/2' 21:22:30.459 [DEBUG] [.mqtt.internal.MqttItemBinding:44 ] - Publishing command ON to mygateway1-in/20/2/1/0/2 21:22:30.461 [DEBUG] [o.i.t.m.i.MqttBrokerConnection:437 ] - Publishing message 2688 to topic 'mygateway1-in/20/2/1/0/2'What's going on?
Thanks!
Simon
-
I'm not an expert on MQTT, but I think you have a small config problem with where you are publishing and retrieving your data. There should also be a mygateway1-out in your string as well. The out is used for MySensors to communicate with the home-controller.
-
Hello!
I've converted the entry from:
Switch node20_sw2 "Luce Stufa" (all,node20) { mqtt=">[mysensor:mygateway1-in/20/2/1/0/2:command:ON:1],>[mysensor:mygateway1-in/20/2/1/0/2:command:OFF:0],<[mysensor:mysensor:mygateway1-in/20/2/1/0/2:command:MAP(1on0off.map)]" }to:
Switch node20_sw2 "Luce Stufa" (all,node20) { mqtt=">[mysensor:mygateway1-in/20/2/1/0/2:command:ON:1],>[mysensor:mygateway1-in/20/2/1/0/2:command:OFF:0]" }And now works.
BTW I need to understood better why, removing the last part, it works. Does this query the status? In this case, then the solution could be right as written by you @drock1985 . Maybe in that case I should ask with mygateway1-out.Simon
-
Oh, maybe that's exactly the case:
https://github.com/openhab/openhab/wiki/MQTT-Binding#item-binding-configuration-for-inbound-messages
It writes:
direction: This is always "<" for inbound messages.
So, having those 3 arguments in the original version:
- ">[mysensor:mygateway1-in/20/2/1/0/2:command:ON:1]"
- ">[mysensor:mygateway1-in/20/2/1/0/2:command:OFF:0]"
- "<[mysensor:mygateway1-in/20/2/1/0/2:command:MAP(1on0off.map)]" "
I think it means:
- outbount to turn ON
- outbount to turn OFF
- INBOUND to check
So, I need to change 'mygateway1-in' to 'mygateway1-out'. This would explain why I was going in loop.
I THINK AT LEAST.
I'll give a try this evening.
Simon