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. Openhab MQTT Example

Openhab MQTT Example

Scheduled Pinned Locked Moved OpenHAB
openhab mqtt ex
49 Posts 8 Posters 68.9k Views 1 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.
  • M Marcus

    @Crazy Do u need Mosquitto?

    C Offline
    C Offline
    C.r.a.z.y.
    wrote on last edited by
    #30

    @Marcus serial is working fine with piDome, openHab and Vera. No need for mosquito which i never installed and used before.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Marcus
      wrote on last edited by Marcus
      #31

      Thank u for your answers.

      I love the look of openhab. So i will try the it with mosquitto.

      If it will not work then i will try pidome and serial gateway.

      If i have new infos i will post them here!

      JohnJ 1 Reply Last reply
      0
      • M Offline
        M Offline
        Marcus
        wrote on last edited by
        #32

        Good morning community.

        Here is what i did now for installing mosquitto on my raspberry pi.

        This infos are from here (http://jpmens.net/2013/09/01/installing-mosquitto-on-a-raspberry-pi/).

          curl -O http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
        
          sudo apt-key add mosquitto-repo.gpg.key
        
          rm mosquitto-repo.gpg.key
        
          cd /etc/apt/sources.list.d/
        
          sudo curl -O http://repo.mosquitto.org/debian/mosquitto-repo.list
        
          sudo apt-get update
        
          sudo apt-get install mosquitto mosquitto-clients python-mosquitto
        

        Now mosquitto is running.

        With:

        sudo /etc/init.d/mosquitto stop
        

        I can stop it.

        With

        sudo /etc/init.d/mosquitto start
        

        I can start it.

        But what to do now???
        How do i connect mosquitto to my MQTT-Ethernet-Gateway?
        How do i connect mosquitto to Openhab?

        Please help!

        1 Reply Last reply
        0
        • b0rmannB Offline
          b0rmannB Offline
          b0rmann
          wrote on last edited by
          #33

          MQTT-Ethernet-Gateway is mqtt brocker, not client :(

          to connect mosquitto try use MQTTClientGateway http://forum.mysensors.org/topic/524/mqtt-client-gateway

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Marcus
            wrote on last edited by Marcus
            #34

            @b0rmann Please read the whole thread and tell me what to do now!!! I only want openhab and mysensors work together. But i want to use my mqtt-ethernet-gateway. Not the serial way.

            b0rmannB 1 Reply Last reply
            0
            • M Marcus

              Thank u for your answers.

              I love the look of openhab. So i will try the it with mosquitto.

              If it will not work then i will try pidome and serial gateway.

              If i have new infos i will post them here!

              JohnJ Offline
              JohnJ Offline
              John
              Plugin Developer
              wrote on last edited by
              #35

              @Marcus PiDome also supports the mqtt gateway next to the serial gateway, so no need to switch. As far as i know, but i'm not an openhab expert, it should work fine as a mqtt client to connect to the mysensors mqtt gateway.

              See this thread for some examples: http://forum.mysensors.org/topic/303/mqtt-broker-gateway

              The developer of the MQTT gateway has posted some examples in the above thread on how you should be able to use it.

              Cheers!

              My Domotica project: http://www.pidome.org

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Marcus
                wrote on last edited by
                #36

                @John Thank u very much. I think i will stop with Openhab and give PiDome a try. it seems to be better described what to do to get it run.

                In the thread u mentioned i looked for some examples but didnt get them to work and no one could help.

                JohnJ 1 Reply Last reply
                0
                • M Marcus

                  @b0rmann Please read the whole thread and tell me what to do now!!! I only want openhab and mysensors work together. But i want to use my mqtt-ethernet-gateway. Not the serial way.

                  b0rmannB Offline
                  b0rmannB Offline
                  b0rmann
                  wrote on last edited by
                  #37

                  @Marcus mqtt client gateway is not serial way :)

                  i have mqtt-client-gateway + raspi (mosquitto + openhab + nodered)

                  1 Reply Last reply
                  0
                  • M Marcus

                    @John Thank u very much. I think i will stop with Openhab and give PiDome a try. it seems to be better described what to do to get it run.

                    In the thread u mentioned i looked for some examples but didnt get them to work and no one could help.

                    JohnJ Offline
                    JohnJ Offline
                    John
                    Plugin Developer
                    wrote on last edited by
                    #38

                    @Marcus Wish i could help, too bad it doesn't work. Others are using it successfully as far as i know. Maybe different openhab version install. Well, let me know if there are any issues or help needed with PiDome.

                    My Domotica project: http://www.pidome.org

                    1 Reply Last reply
                    1
                    • T Offline
                      T Offline
                      tboha
                      wrote on last edited by
                      #39

                      @Marcus: Sorry I'm in a hurry so...
                      But what to do now??? -> is your broker really ok?

                      1. open two terminal windows on your Raspberry.

                      2. one window:

                        mosquitto_sub -t /test -v

                      3. second window:

                        mosquitto_pub -t /test -m "test message"

                      If it's all fine, the test message should show up in the first window.

                      How do i connect mosquitto to Openhab?
                      OpenHab -> mosquitto
                      If your still got the OpenHab sitemap from above, the swtiches 1+3 should be functional like desribed, switch 2 will result in an errormessage in the log (as "intended").

                      Reverse direction (mosquitto -> Openhab).
                      You may populate your broker with some messages for the given topic.
                      e.g. mosquitto_pub -t MyMQTT/20/255/V_SKETCH_NAME -m "fake sketch name"

                      How do i connect mosquitto to Openhab?
                      I use the serial Gateway connected via USB to my Raspberry and a little Node.js script.
                      If you are interested - let me know.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        Marcus
                        wrote on last edited by
                        #40

                        Thank u anyway for your help @tboha . I think this is too much complicated. I tried ur last idea, but i got connection refused error. Really frustrating.... I want to see results. I hope pidome gave me faster results than openhab.

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          tboha
                          wrote on last edited by
                          #41

                          Connection refused means (in 99%) your broker is not up or you got the wrong address.
                          I supposed you to run mosquitto_sub/pub on the same machine your broker runs on.
                          On a different machine you have to add the host address like:

                          mosquitto_sub -h 192.168.1.10 -t /topic -m "message".
                          

                          No - at last its not really complicated, but I think you had just a bad start. MySensors and OpenHab tend to start right out of the box - but you need the right box......

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            Marcus
                            wrote on last edited by Marcus
                            #42

                            Please stop helping me now. Now i have pidome and the first sensor is running after 30 minutes with my ethernet mqtt gateway ;-)

                            That is what i want. Maybe one day there are nice tutorials for Openhab. Thank u very much for trying to help. If i now start with mosquitto to get openhab run is the same as when i make a patch for a patch....

                            It seems that pidome has wait for me it is really nice and not much complicated.

                            This thread can be closed here.Unbenannt.JPG

                            C 1 Reply Last reply
                            0
                            • M Marcus

                              Please stop helping me now. Now i have pidome and the first sensor is running after 30 minutes with my ethernet mqtt gateway ;-)

                              That is what i want. Maybe one day there are nice tutorials for Openhab. Thank u very much for trying to help. If i now start with mosquitto to get openhab run is the same as when i make a patch for a patch....

                              It seems that pidome has wait for me it is really nice and not much complicated.

                              This thread can be closed here.Unbenannt.JPG

                              C Offline
                              C Offline
                              C.r.a.z.y.
                              wrote on last edited by
                              #43

                              @Marcus Try Tim's files and JAR file for serial openHab http://forum.mysensors.org/topic/655/serial-gateway-connection-to-openhab/2
                              I added a motion sensor and its fine.

                              JohnJ 1 Reply Last reply
                              0
                              • C C.r.a.z.y.

                                @Marcus Try Tim's files and JAR file for serial openHab http://forum.mysensors.org/topic/655/serial-gateway-connection-to-openhab/2
                                I added a motion sensor and its fine.

                                JohnJ Offline
                                JohnJ Offline
                                John
                                Plugin Developer
                                wrote on last edited by John
                                #44

                                @Marcus Good to see you have it working! The MySensors MQTT plugin and serial drivers are quite stable. Some parts of the server can behave a little strange, cause still in heavy development.

                                My Domotica project: http://www.pidome.org

                                C 1 Reply Last reply
                                0
                                • JohnJ John

                                  @Marcus Good to see you have it working! The MySensors MQTT plugin and serial drivers are quite stable. Some parts of the server can behave a little strange, cause still in heavy development.

                                  C Offline
                                  C Offline
                                  C.r.a.z.y.
                                  wrote on last edited by
                                  #45

                                  @John There was a problem with serial....1.6.1.jar it doesnt show this correctly;

                                  ArduinoUpdate -> 0;0;3;0;9;read: 14-14-0 s=1,c=1,t=16,pt=0,l=1:0
                                  14;1;1;0;16;0

                                  i think its related with baud rate for jar file because i saw  these kind of things in terminal ����BO�"U��²e��B&��i�

                                  JohnJ 1 Reply Last reply
                                  0
                                  • C C.r.a.z.y.

                                    @John There was a problem with serial....1.6.1.jar it doesnt show this correctly;

                                    ArduinoUpdate -> 0;0;3;0;9;read: 14-14-0 s=1,c=1,t=16,pt=0,l=1:0
                                    14;1;1;0;16;0

                                    i think its related with baud rate for jar file because i saw  these kind of things in terminal ����BO�"U��²e��B&��i�

                                    JohnJ Offline
                                    JohnJ Offline
                                    John
                                    Plugin Developer
                                    wrote on last edited by
                                    #46

                                    @C.r.a.z.y. That's highly possible, or there was a wrong choice of encoding at the wrong moment.

                                    My Domotica project: http://www.pidome.org

                                    1 Reply Last reply
                                    0
                                    • H Offline
                                      H Offline
                                      Hacker007
                                      wrote on last edited by
                                      #47

                                      Hi.
                                      I have OpenHAB, MQTT and battery powered units (http://iot-playground.com/2-uncategorised/10-low-power-door-window-sensor). I cannot receive battery status in Openhab (other things from the same unit are transmitted OK). What is wrong?

                                      1. I send: gw.sendBatteryLevel(batLevel);
                                      2. Number node4_bat "Bat [%.1f %%]" <temperature> (node4, GBattery) {mqtt="<[mysensor:MyMQTT/4/255/50:state:default]"}

                                      I have seen somewhere that battery state is transmitted via '50'?!?

                                      1 Reply Last reply
                                      0
                                      • H Offline
                                        H Offline
                                        Hacker007
                                        wrote on last edited by Hacker007
                                        #48

                                        Hi. I have figured it out. It is presented as "mysensor:MyMQTT/4/255/V_:state:default". No number in current version from mysensors!!!
                                        The next step was to edit MyMQTT.cpp: char V_50[] PROGMEM = ""; into char V_50[] PROGMEM = "50";. Now I get battery status via "mysensor:MyMQTT/4/255/V_50:state:default".

                                        So in conclusion I have answered my own questions and have solved them...

                                        1 Reply Last reply
                                        1
                                        • F Offline
                                          F Offline
                                          francis
                                          wrote on last edited by
                                          #49

                                          coming back to the initial issue, is there anyone that can post items and maps configuration to test the binary switch example of mysensors? my configuration is arduino uno+w5100 and mqtt gateway, opnhab on windows pc on the same network

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


                                          15

                                          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