Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. OpenHAB and MQTT Gateway: moving to GatewayClient - Issue

OpenHAB and MQTT Gateway: moving to GatewayClient - Issue

Scheduled Pinned Locked Moved Troubleshooting
5 Posts 3 Posters 1.8k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xefil
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by hek
      #2

      I cannot see the incoming traffic in your log.

      Could it be the node sends an ack message back (even though you're not asking for it)?

      (but it shouldn't send an off command in that case... weird)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        drock1985
        wrote on last edited by
        #3

        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.

        My Projects
        2 Door Chime Sensor
        Washing Machine Monitor

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xefil
          wrote on last edited by xefil
          #4

          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

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xefil
            wrote on last edited by
            #5

            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:

            1. ">[mysensor:mygateway1-in/20/2/1/0/2:command:ON:1]"
            2. ">[mysensor:mygateway1-in/20/2/1/0/2:command:OFF:0]"
            3. "<[mysensor:mygateway1-in/20/2/1/0/2:command:MAP(1on0off.map)]" "

            I think it means:

            1. outbount to turn ON
            2. outbount to turn OFF
            3. 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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            20

            Online

            11.7k

            Users

            11.2k

            Topics

            113.1k

            Posts


            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular