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. The best way to connect to OpenHAB

The best way to connect to OpenHAB

Scheduled Pinned Locked Moved OpenHAB
24 Posts 6 Posters 33.4k 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.
  • K Offline
    K Offline
    kolaf
    Hero Member
    wrote on last edited by
    #1

    In parallel with trying to get the radio library to work with my hardware, I started trying to connect this up to my openHAB installation. I will be connecting the Arduino gateway unit directly to a computer through USB, so a solution has to be able to talk to it through the serial port. As far as I can see there are two options for me:

    1. Use one of the MQTT gateway libraries available (which one?).
    2. Use the place and gateway Web server implementation created for openHAB implementation posted by someone a few months ago.

    Are there any other options I have missed and should be looking at?

    I already have a mqtt broker running on my server, so there is no overhead there. However, it seems a bit like overkill to put a mqtt client, a broker, and the mqtt binding between the serial gateway and openhab. Also, I'm not quite sure what kind of management functionality this offers as far as assigning IDs and so on.

    What do you guys suggest I do?

    DammeD YveauxY 2 Replies Last reply
    0
    • K kolaf

      In parallel with trying to get the radio library to work with my hardware, I started trying to connect this up to my openHAB installation. I will be connecting the Arduino gateway unit directly to a computer through USB, so a solution has to be able to talk to it through the serial port. As far as I can see there are two options for me:

      1. Use one of the MQTT gateway libraries available (which one?).
      2. Use the place and gateway Web server implementation created for openHAB implementation posted by someone a few months ago.

      Are there any other options I have missed and should be looking at?

      I already have a mqtt broker running on my server, so there is no overhead there. However, it seems a bit like overkill to put a mqtt client, a broker, and the mqtt binding between the serial gateway and openhab. Also, I'm not quite sure what kind of management functionality this offers as far as assigning IDs and so on.

      What do you guys suggest I do?

      DammeD Offline
      DammeD Offline
      Damme
      Code Contributor
      wrote on last edited by Damme
      #2

      @kolaf Imo : mqttgateway (arduino + nrf24 + ethernet) (runs as a broker) and openhab mqtt client on a server :)

      K 1 Reply Last reply
      0
      • DammeD Damme

        @kolaf Imo : mqttgateway (arduino + nrf24 + ethernet) (runs as a broker) and openhab mqtt client on a server :)

        K Offline
        K Offline
        kolaf
        Hero Member
        wrote on last edited by kolaf
        #3

        @Damme Thanks, but hardly surprising from you, I believe ;)

        The problem is that I really don't want to hassle with connecting an ethernet shield when I can just plug the thing into my USB port. I'm more of a software guy than a hardware guy, so the less soldering, the better.

        YveauxY 1 Reply Last reply
        0
        • K kolaf

          @Damme Thanks, but hardly surprising from you, I believe ;)

          The problem is that I really don't want to hassle with connecting an ethernet shield when I can just plug the thing into my USB port. I'm more of a software guy than a hardware guy, so the less soldering, the better.

          YveauxY Offline
          YveauxY Offline
          Yveaux
          Mod
          wrote on last edited by Yveaux
          #4

          @kolaf said:

          hassle with connecting an ethernet shield

          Take the Arduino UNO in one hand, the Ethernet shield in the other and plug them together. Done!

          1.jpg

          It's really that hard ;-)
          Even a software guy (like me) can do it!

          http://yveaux.blogspot.nl

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kolaf
            Hero Member
            wrote on last edited by
            #5

            Hehe, but what about the radio? You need to connect that, too.

            YveauxY 1 Reply Last reply
            0
            • K kolaf

              Hehe, but what about the radio? You need to connect that, too.

              YveauxY Offline
              YveauxY Offline
              Yveaux
              Mod
              wrote on last edited by Yveaux
              #6

              @kolaf you need to connect the radio anyway, right ;-)

              http://yveaux.blogspot.nl

              K 1 Reply Last reply
              0
              • YveauxY Yveaux

                This topic was split off http://forum.mysensors.org/topic/301/the-best-way-to-connect-to-openhab to discuss tips and hints specific to using MySensors together with MQTT middleware and OpenHAB.
                If you made something nice using this combination or have some questions/issues please post them in here!


                @kolaf I just started experimenting with openhab and find it quite hard to get started. There's some documentation ( far from complete, especially when you're just starting) but the general impression is that it's very powerful, mainly due to all the programming options. I'm quite sure you could directly talk to a mysensors gateway using the serial protocol, using e.g. rules, if you want.
                I doubt however if you want to write your own protocol handler...
                Anyway, I'm currently using an Ethernet gateway which tasks to a Perl script I wrote (https://github.com/Yveaux/MySensors_MQTTGateway) that does the conversion to and from MQTT. This script is a MQTT client that runs on the same server I run openhab and the mosquitto broker on. This is the only difference compared to @Damme solution who runs a broker on the gateway.
                I like the flexibility of storing & accessing all data through an MQTT broker which makes up for the apparent overkill going through MQTT just to connect mysensors to openhab.
                As long as your server has enough resources to run it all its not really worth the effort to directly talk to my sensors or create an openhab binding for it.

                K Offline
                K Offline
                kolaf
                Hero Member
                wrote on last edited by
                #7

                @Yveaux I saw that earlier and it is one of the options I have been considering. But why do you use an ethernet gateway instead of a serial?

                YveauxY 1 Reply Last reply
                0
                • YveauxY Yveaux

                  @kolaf you need to connect the radio anyway, right ;-)

                  K Offline
                  K Offline
                  kolaf
                  Hero Member
                  wrote on last edited by
                  #8

                  @Yveaux said:

                  @kolaf you need to connect the radio anyway, right ;-)

                  Not if you're lazy like me and buy moteinos or anarduinos where everything comes in one nice, compact package :-)

                  YveauxY 1 Reply Last reply
                  0
                  • K kolaf

                    @Yveaux I saw that earlier and it is one of the options I have been considering. But why do you use an ethernet gateway instead of a serial?

                    YveauxY Offline
                    YveauxY Offline
                    Yveaux
                    Mod
                    wrote on last edited by
                    #9

                    @kolaf my gateway is located downstairs an my server is in the attic. They're only connected using Ethernet, so for me it is the most logic solution.

                    http://yveaux.blogspot.nl

                    K 1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kolaf
                      Hero Member
                      wrote on last edited by
                      #10

                      The anarduino with RF 69HW combined as up to only $15 which seems to me to be a reasonable price. Of course you need some headers as well, and an antenna, but still...

                      1 Reply Last reply
                      0
                      • K kolaf

                        @Yveaux said:

                        @kolaf you need to connect the radio anyway, right ;-)

                        Not if you're lazy like me and buy moteinos or anarduinos where everything comes in one nice, compact package :-)

                        YveauxY Offline
                        YveauxY Offline
                        Yveaux
                        Mod
                        wrote on last edited by
                        #11

                        @kolaf touché

                        http://yveaux.blogspot.nl

                        1 Reply Last reply
                        0
                        • YveauxY Yveaux

                          @kolaf my gateway is located downstairs an my server is in the attic. They're only connected using Ethernet, so for me it is the most logic solution.

                          K Offline
                          K Offline
                          kolaf
                          Hero Member
                          wrote on last edited by
                          #12

                          @Yveaux makes sense. Can your gateway speak the serial protocol?

                          YveauxY 1 Reply Last reply
                          0
                          • K kolaf

                            @Yveaux makes sense. Can your gateway speak the serial protocol?

                            YveauxY Offline
                            YveauxY Offline
                            Yveaux
                            Mod
                            wrote on last edited by
                            #13

                            @kolaf said:

                            @Yveaux makes sense. Can your gateway speak the serial protocol?

                            It currently connects using sockets, but the protocol is identical, so it shouldn't be hard to use a serial connection.

                            http://yveaux.blogspot.nl

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

                              For testing basic functions there exists another (rather crude) way - the serial binding offerd by OpenHAB. Adding :

                                 String Arduino   "Arduino [%s]"    {serial="COM6"}
                              

                              to an "items" file will do the trick. Accordingly a "rules" file should be expanded by something like :

                                 rule SplitMessage
                                 when 
                              Item Arduino changed
                                then
                               <do some relevant processing>
                              

                              Using MySensors 1.4b (proMini, Uno, Mega.Leonardo) and OpenHab 1.5 (Windows 7 Notebook) produced very reliable results with SerialGateway connected via USB.

                              You have to compile the sketches with Baudrate set to 9600 because OpenHAB deals only with this Baudrate (mentioned somewhere in the OpenHAB Documentation).

                              So in Mysensors.h replace :

                              #define BAUD_RATE 115200
                              with
                              #define BAUD_RATE 9600
                              

                              Because OpenHAB is not prepared to distribute NODE_IDs, you should hardcode this NODE-IDs. This decreases flexibility, but it is acceptable to some degree.

                              This approach works well for reading sensordata as for writing to actuators. Currently I am using eigth Nodes (including Repeater) with serveral children (e.g. multiple DS18B20, multiple Door contacts, Motionsensor, DHT22 etc). Until now I haven´t enconterd serious problems.

                              K 1 Reply Last reply
                              1
                              • T tboha

                                For testing basic functions there exists another (rather crude) way - the serial binding offerd by OpenHAB. Adding :

                                   String Arduino   "Arduino [%s]"    {serial="COM6"}
                                

                                to an "items" file will do the trick. Accordingly a "rules" file should be expanded by something like :

                                   rule SplitMessage
                                   when 
                                Item Arduino changed
                                  then
                                 <do some relevant processing>
                                

                                Using MySensors 1.4b (proMini, Uno, Mega.Leonardo) and OpenHab 1.5 (Windows 7 Notebook) produced very reliable results with SerialGateway connected via USB.

                                You have to compile the sketches with Baudrate set to 9600 because OpenHAB deals only with this Baudrate (mentioned somewhere in the OpenHAB Documentation).

                                So in Mysensors.h replace :

                                #define BAUD_RATE 115200
                                with
                                #define BAUD_RATE 9600
                                

                                Because OpenHAB is not prepared to distribute NODE_IDs, you should hardcode this NODE-IDs. This decreases flexibility, but it is acceptable to some degree.

                                This approach works well for reading sensordata as for writing to actuators. Currently I am using eigth Nodes (including Repeater) with serveral children (e.g. multiple DS18B20, multiple Door contacts, Motionsensor, DHT22 etc). Until now I haven´t enconterd serious problems.

                                K Offline
                                K Offline
                                kolaf
                                Hero Member
                                wrote on last edited by kolaf
                                #15

                                @tboha Thanks, that was very helpful. Do you have some more details for the mystical "do some processing"?

                                @Yveaux how do you use the mqtt binding to talk to the sensors? I have looked into it, and must admit I have no idea on how to achieve this. It's apparent that you need some kind of transformation, but my understanding ends there. Specifically, I would like to implement a toggle switch, a switch that toggles a light every time it is activated instead of having a specific on and off state.

                                YveauxY 1 Reply Last reply
                                0
                                • YveauxY Offline
                                  YveauxY Offline
                                  Yveaux
                                  Mod
                                  wrote on last edited by
                                  #16

                                  @hek or @marceltrapman can you please split this topic starting at the openhab/mqtt examples into something like "OpenHAB & MQTT examples" please?
                                  Thanks!

                                  http://yveaux.blogspot.nl

                                  marceltrapmanM 1 Reply Last reply
                                  0
                                  • YveauxY Yveaux

                                    @hek or @marceltrapman can you please split this topic starting at the openhab/mqtt examples into something like "OpenHAB & MQTT examples" please?
                                    Thanks!

                                    marceltrapmanM Offline
                                    marceltrapmanM Offline
                                    marceltrapman
                                    Mod
                                    wrote on last edited by
                                    #17

                                    @Yveaux said:

                                    @marceltrapman can you please split this topic starting at the openhab/mqtt examples into something like "OpenHAB & MQTT examples" please?
                                    Starting from which post do you suggest the split?

                                    Fulltime Servoy Developer
                                    Parttime Moderator MySensors board

                                    I use Domoticz as controller for Z-Wave and MySensors (previously Indigo and OpenHAB).
                                    I have a FABtotum to print cases.

                                    YveauxY 1 Reply Last reply
                                    0
                                    • marceltrapmanM marceltrapman

                                      @Yveaux said:

                                      @marceltrapman can you please split this topic starting at the openhab/mqtt examples into something like "OpenHAB & MQTT examples" please?
                                      Starting from which post do you suggest the split?

                                      YveauxY Offline
                                      YveauxY Offline
                                      Yveaux
                                      Mod
                                      wrote on last edited by
                                      #18

                                      @marceltrapman said:

                                      @Yveaux said:

                                      @marceltrapman can you please split this topic starting at the openhab/mqtt examples into something like "OpenHAB & MQTT examples" please?
                                      Starting from which post do you suggest the split?

                                      Can you also join to an existing topic? In that case I'll create one -- that will make a clearer topic than just start in the middle of a discussion.

                                      http://yveaux.blogspot.nl

                                      1 Reply Last reply
                                      0
                                      • K Offline
                                        K Offline
                                        kolaf
                                        Hero Member
                                        wrote on last edited by kolaf
                                        #19

                                        For the record there is also this initiative where a smart guy has created a Python Web application to interface between the serial connection and openhab. He has even built in the functionality for handling node IDs.

                                        https://github.com/wbcode/ham

                                        It seems like there are three quite usable options for interfacing with openhab:

                                        1. The MQTT gateway
                                        2. Using the serial binding in openhab
                                        3. Using the python openhab gateway.

                                        The serial binding seems the best option for quick prototyping with its low implementation cost (no additional software) and high flexibility. One of the two other options seems to be a better long-term choice since they will be easier to manage on the configuration size as the network grows, I think. I like the concept behind the python gateway, but using the httpbinding to communicate with it seems a bit cumbersome. Ideally I would like to see this incorporated as an openhab binding, but I do not think it is possible to do the node ID assignment this way since the binding should be stateless.

                                        This leaves the MQTT solution which leverages technology that seems to grow in popularity. An additional benefit is that the author of the software is still around the forums as opposed to the case with the python gateway. The downside is that the item configurations seems a bit complex (at least to me), it is much easier to understand the serial binding or HTTP binding usage.

                                        It is a tough choice.

                                        1 Reply Last reply
                                        1
                                        • YveauxY Offline
                                          YveauxY Offline
                                          Yveaux
                                          Mod
                                          wrote on last edited by
                                          #20

                                          @hek made me a forum moderator, so now I did the split myself ;-)
                                          Moved the topics regarding specific MQTT & Openhab usage to http://forum.mysensors.org/topic/302/openhab-mqtt-tips-hints
                                          There we can post some OpenHAB code and stuff, and this thread continues to discuss different ways to connect to OpenHAB.
                                          Still have to clean up the new thread a little, though...

                                          http://yveaux.blogspot.nl

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


                                          16

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 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