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. Controllers
  3. OpenHAB
  4. Relay connection with MQTT?

Relay connection with MQTT?

Scheduled Pinned Locked Moved OpenHAB
13 Posts 5 Posters 5.6k Views 5 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.
  • G Offline
    G Offline
    George Whitehouse
    wrote on last edited by
    #3

    Greg,

    I have loaded the current 1.5 Latest Release sketch and just added a static Node ID.

    Regards
    George

    1 Reply Last reply
    0
    • G Offline
      G Offline
      George Whitehouse
      wrote on last edited by
      #4

      Gday,

      I hope someone can help, I am trying to get a relay node working.

      Gateway: MQTT Broker Gateway
      Relay Node sketch is: 0_1456304097597_RelayActuator.ino

      The only thing I changed was a fixed Node ID of 52.

      Could someone let me know what is the correct MQTT message is to send to turn it on and off?

      Regards,
      George

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

        If I interpret your images correctly, the command should be:

        mygateway1-in/52/1/1/0/2

        with payload 0/1

        G 1 Reply Last reply
        0
        • hekH hek

          If I interpret your images correctly, the command should be:

          mygateway1-in/52/1/1/0/2

          with payload 0/1

          G Offline
          G Offline
          George Whitehouse
          wrote on last edited by
          #6

          @hek
          Thanks for that.
          I switched back to the MQTT Broker Gateway as the client gateway seemed to lock up every no and then.

          Could you let me know the command for the broker gateway?

          Thanks again

          Regards
          George

          1 Reply Last reply
          0
          • G Offline
            G Offline
            George Whitehouse
            wrote on last edited by George Whitehouse
            #7

            Gday,

            Does anyone have a relay node connected to openHab via the MQTT Broker gateway?

            Could you point me in the right direction with the code to send to turn it on/off.

            • My MQTT broker gateway is working, I have a couple of PIRs & a Distance node working.
            • openHab is working
            • Node ID is 52
            • Sketch is the current latest 1.5 versions for both relay node and gateway

            But I can't seem to understand what to send to turn the relay node on or off.

            I have this but it is not working,

            Switch TestGD				"Test GD"			{mqtt=">[mysensors:MyMQTT/52/1/V_LIGHT:command:ON:1],>[mysensors:MyMQTT/52/1/V_LIGHT:command:OFF:0]"}
            

            This is from the serial monitor,
            send: 52-52-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
            send: 52-52-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=ok:1.5.4
            send: 52-52-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
            read: 0-0-52 s=255,c=3,t=6,pt=0,l=1,sg=0:M
            repeater started, id=52, parent=0, distance=1
            send: 52-52-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
            send: 52-52-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.4
            send: 52-52-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
            read: 0-0-52 s=255,c=3,t=6,pt=0,l=1,sg=0:M
            sensor started, id=52, parent=0, distance=1
            send: 52-52-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
            send: 52-52-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
            send: 52-52-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:

            Regards,
            George

            M 1 Reply Last reply
            0
            • G George Whitehouse

              Gday,

              Does anyone have a relay node connected to openHab via the MQTT Broker gateway?

              Could you point me in the right direction with the code to send to turn it on/off.

              • My MQTT broker gateway is working, I have a couple of PIRs & a Distance node working.
              • openHab is working
              • Node ID is 52
              • Sketch is the current latest 1.5 versions for both relay node and gateway

              But I can't seem to understand what to send to turn the relay node on or off.

              I have this but it is not working,

              Switch TestGD				"Test GD"			{mqtt=">[mysensors:MyMQTT/52/1/V_LIGHT:command:ON:1],>[mysensors:MyMQTT/52/1/V_LIGHT:command:OFF:0]"}
              

              This is from the serial monitor,
              send: 52-52-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
              send: 52-52-0-0 s=255,c=0,t=18,pt=0,l=5,sg=0,st=ok:1.5.4
              send: 52-52-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
              read: 0-0-52 s=255,c=3,t=6,pt=0,l=1,sg=0:M
              repeater started, id=52, parent=0, distance=1
              send: 52-52-0-0 s=255,c=3,t=15,pt=2,l=2,sg=0,st=ok:0
              send: 52-52-0-0 s=255,c=0,t=17,pt=0,l=5,sg=0,st=ok:1.5.4
              send: 52-52-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
              read: 0-0-52 s=255,c=3,t=6,pt=0,l=1,sg=0:M
              sensor started, id=52, parent=0, distance=1
              send: 52-52-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
              send: 52-52-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
              send: 52-52-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:

              Regards,
              George

              M Offline
              M Offline
              mbj
              wrote on last edited by
              #8

              @George-Whitehouse What do you see in your Openhab event.log. If your TestGD switch is defined OK in your sitemap you should find any changes to the switch logged as events for the TestGD item in the event.log (maybe a stupid question but since you apparently have no incoming messages logged in the serial monitor the question is "what have you sent"/"have you sent anything at all").

              1 Reply Last reply
              0
              • G Offline
                G Offline
                George Whitehouse
                wrote on last edited by
                #9

                Thanks, I reloaded the nano with the sketch and it is working ok.

                Regards
                George

                M 1 Reply Last reply
                0
                • G George Whitehouse

                  Thanks, I reloaded the nano with the sketch and it is working ok.

                  Regards
                  George

                  M Offline
                  M Offline
                  mbj
                  wrote on last edited by
                  #10

                  @George-Whitehouse Good you have it working. Seemed that your sketch was working OK as the messages in the serial monitor were all marked ok.

                  I have seen that even if sending of messages work receiving them may fail. In such a case the serial monitor of the gateway ought to show a "fail" in the log so when having problems it is always a good idea to monitor the gateway traffic as well.

                  I am using the new MQTT client and then it is easy to monitor the MQTT messages as well (as you showed in the first post). This has simplified looking for errors a lot, at least for me.

                  G 1 Reply Last reply
                  0
                  • Matt PittsM Offline
                    Matt PittsM Offline
                    Matt Pitts
                    wrote on last edited by
                    #11

                    @George-Whitehouse I've just seen your post about getting the correct message from openhab, I'm also having the same problem getting the relay to switch from within openhab.

                    Could you share the openhab item you actually got working? Thanks very much

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      George Whitehouse
                      wrote on last edited by George Whitehouse
                      #12

                      Matt,

                      No worries, this is what I am using. It plugs into a rule that energises the relay for 3 seconds and then turns off to open/close the garage door.

                      Currently I am using the MQTT Broker sketch from main branch along with the standard relay sketch.

                      Config file,

                      mqtt:mysensors.url=tcp://192.168.0.50:1883
                      mqtt:mysensors.clientId=openHAB
                      

                      Items file,

                      Switch GD					"Garage Door"	{mqtt=">[mysensors:MyMQTT/23/1/V_LIGHT:command:ON:0],>[mysensors:MyMQTT/23/1/V_LIGHT:command:OFF:1]"}
                      
                      

                      I will give the MQTT Client sketch a go again soon however last time I tried it, it locked up on me every day or so and I had to restart it. Reliability is important and for the last few weeks my set up has been working perfectly.

                      Cheers,
                      George

                      1 Reply Last reply
                      0
                      • M mbj

                        @George-Whitehouse Good you have it working. Seemed that your sketch was working OK as the messages in the serial monitor were all marked ok.

                        I have seen that even if sending of messages work receiving them may fail. In such a case the serial monitor of the gateway ought to show a "fail" in the log so when having problems it is always a good idea to monitor the gateway traffic as well.

                        I am using the new MQTT client and then it is easy to monitor the MQTT messages as well (as you showed in the first post). This has simplified looking for errors a lot, at least for me.

                        G Offline
                        G Offline
                        George Whitehouse
                        wrote on last edited by
                        #13

                        @mbj Thanks, I will give the MQTT Client sketch a go soon.

                        Cheers,

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


                        9

                        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