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. MQTT Broker gateway

MQTT Broker gateway

Scheduled Pinned Locked Moved Controllers
132 Posts 34 Posters 115.6k Views 7 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.
  • YveauxY Yveaux

    @Damme Hey man, thanks for the extensive documentation!
    Would you mind if I split this post into its own topic? I think your MQTT broker deserves its own topic; let's reserve this thread for OpenHAB+MQTT related stuff.

    Update Split done!

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

    @Yveaux sure

    1 Reply Last reply
    0
    • HomerH Offline
      HomerH Offline
      Homer
      wrote on last edited by
      #4

      So have I got this right.....?

      This will mean that I can build an arduino with an ethernet port and a radio, and this will then plug in to an ethernet port and be what my other ardiuno sensors will connect to, and it will send everything to my Vera?

      DammeD 1 Reply Last reply
      0
      • HomerH Homer

        So have I got this right.....?

        This will mean that I can build an arduino with an ethernet port and a radio, and this will then plug in to an ethernet port and be what my other ardiuno sensors will connect to, and it will send everything to my Vera?

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

        @Homer For Vera you should build http://mysensors.org/build/ethernet_gateway

        MQTTGateway is a MQTT broker (server), used for mqttclient like openhab for example.

        HomerH 1 Reply Last reply
        0
        • DammeD Damme

          @Homer For Vera you should build http://mysensors.org/build/ethernet_gateway

          MQTTGateway is a MQTT broker (server), used for mqttclient like openhab for example.

          HomerH Offline
          HomerH Offline
          Homer
          wrote on last edited by
          #6

          @Damme said:

          @Homer For Vera you should build http://mysensors.org/build/ethernet_gateway

          MQTTGateway is a MQTT broker (server), used for mqttclient like openhab for example.

          Ok. I was hoping that this device would enable me to have some of my sensors connected to ethernet so I can power them as well. Rather than sending information over wireless, they would do so via ethernet.

          There isn't a way to do as I have described above, right?

          DammeD 1 Reply Last reply
          0
          • HomerH Homer

            @Damme said:

            @Homer For Vera you should build http://mysensors.org/build/ethernet_gateway

            MQTTGateway is a MQTT broker (server), used for mqttclient like openhab for example.

            Ok. I was hoping that this device would enable me to have some of my sensors connected to ethernet so I can power them as well. Rather than sending information over wireless, they would do so via ethernet.

            There isn't a way to do as I have described above, right?

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

            @Homer I'm sorry but I don't think I really understand your question.
            read http://mysensors.org/build/network
            Each node (with sensors) talk wireless to A gateway, which then talks to a controller (in your case Vera) this can be via RS232 OR ethernet.

            If you have something that talks MQTT (like openhab) as a controller, then your choice could be sensors <-> MQTTgateway <-> openhab instead.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              ToSa
              Code Contributor
              wrote on last edited by
              #8

              I can confirm it's working with UIPEthernet.h and the ENC28J60 module as well. You need to turn off debugging in MyConfig.h to make the code fit.

              DammeD T 3 Replies Last reply
              0
              • T ToSa

                I can confirm it's working with UIPEthernet.h and the ENC28J60 module as well. You need to turn off debugging in MyConfig.h to make the code fit.

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

                @ToSa Thanks! I havn't had time to get and test that module.

                1 Reply Last reply
                0
                • T ToSa

                  I can confirm it's working with UIPEthernet.h and the ENC28J60 module as well. You need to turn off debugging in MyConfig.h to make the code fit.

                  T Offline
                  T Offline
                  ToSa
                  Code Contributor
                  wrote on last edited by
                  #10

                  @ToSa said:

                  I can confirm it's working with UIPEthernet.h and the ENC28J60 module as well. You need to turn off debugging in MyConfig.h to make the code fit.

                  Maybe that was a little too fast - it starts up and starting OpenHAB finds the gateway and connects. When I reset a node it appears that the gateway crashes (OpenHAB reports disconnect) and only a reset of the gateway helps to get it to work again. Problem is it's hard to debug without debugging enabled due to code size :(

                  DammeD 1 Reply Last reply
                  0
                  • T ToSa

                    @ToSa said:

                    I can confirm it's working with UIPEthernet.h and the ENC28J60 module as well. You need to turn off debugging in MyConfig.h to make the code fit.

                    Maybe that was a little too fast - it starts up and starting OpenHAB finds the gateway and connects. When I reset a node it appears that the gateway crashes (OpenHAB reports disconnect) and only a reset of the gateway helps to get it to work again. Problem is it's hard to debug without debugging enabled due to code size :(

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

                    @ToSa if possible you could make a tcpdump over the mqqt port and I'll look at it. Also a serial dump from the node would be great

                    T 1 Reply Last reply
                    0
                    • DammeD Damme

                      @ToSa if possible you could make a tcpdump over the mqqt port and I'll look at it. Also a serial dump from the node would be great

                      T Offline
                      T Offline
                      ToSa
                      Code Contributor
                      wrote on last edited by
                      #12

                      @Damme said:

                      @ToSa if possible you could make a tcpdump over the mqqt port and I'll look at it. Also a serial dump from the node would be great

                      After changing the include from Ethernet.h to UIPEthernet.h the sketch fits into the m328 only with DEBUG (and TCPDUMP) turned off:

                      DEBUG / TCPDUMP turned off:
                      Sketch uses 30,626 bytes (99%) of program storage space. Maximum is 30,720 bytes.
                      Global variables use 1,330 bytes (64%) of dynamic memory, leaving 718 bytes for local variables. Maximum is 2,048 bytes.

                      DEBUG / TCPDUMP turned on:
                      Sketch uses 32,354 bytes (105%) of program storage space. Maximum is 30,720 bytes.
                      Global variables use 1,393 bytes (68%) of dynamic memory, leaving 655 bytes for local variables. Maximum is 2,048 bytes.
                      processing.app.debug.RunnerException: Sketch too big;

                      The only thing I have right now to look at is the OpenHAB output (appears that it's not happening when I reset a node but rather random):

                      pi@openhab ~/runtime $ ./start.sh
                      Launching the openHAB runtime...
                      osgi> 19:54:19.384 INFO o.o.c.internal.CoreActivator[:61] - openHAB runtime has been started (v1.6.0).
                      19:54:39.316 INFO o.o.i.t.mqtt.MqttService[:106] - MQTT Service initialization completed.
                      19:54:39.322 INFO o.o.i.t.m.i.MqttBrokerConnection[:112] - Starting MQTT broker connection 'mysensor'
                      19:54:42.838 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'logging.persist'
                      19:54:46.082 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'exec.persist'
                      19:54:46.261 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'rrd4j.persist'
                      19:54:46.494 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'db4o.persist'
                      19:54:47.009 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'test.items'
                      19:55:01.187 INFO o.o.i.s.i.DiscoveryServiceImpl[:72] - mDNS service has been started
                      19:55:10.219 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'test.sitemap'
                      19:55:19.042 INFO o.o.io.rest.RESTApplication[:143] - Started REST API at /rest
                      19:55:24.936 INFO o.o.u.w.i.s.WebAppServlet[:79] - Started Classic UI at /openhab.app
                      19:55:35.271 ERROR o.o.i.t.m.i.MqttBrokerConnection[:478] - Error starting consumer
                      org.eclipse.paho.client.mqttv3.MqttException: Connection lost
                      at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138)
                      Caused by: java.net.SocketException: Connection reset
                      at java.net.SocketInputStream.read(SocketInputStream.java:196)
                      19:55:35.298 ERROR o.o.i.t.m.i.MqttBrokerConnection[:532] - MQTT connection to broker was lost
                      org.eclipse.paho.client.mqttv3.MqttException: Connection lost
                      at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138)
                      Caused by: java.net.SocketException: Connection reset
                      at java.net.SocketInputStream.read(SocketInputStream.java:196)
                      19:55:35.305 ERROR o.o.i.t.m.i.MqttBrokerConnection[:536] - MQTT connection to 'mysensor' was lost: Connection lost : ReasonCode 32109 : Cause : Connection reset
                      19:55:35.310 INFO o.o.i.t.m.i.MqttBrokerConnection[:543] - Starting connection helper to periodically try restore connection to broker 'mysensor'
                      19:55:45.317 INFO o.o.i.t.m.i.MqttBrokerConnection[:112] - Starting MQTT broker connection 'mysensor'

                      DammeD 1 Reply Last reply
                      0
                      • T ToSa

                        @Damme said:

                        @ToSa if possible you could make a tcpdump over the mqqt port and I'll look at it. Also a serial dump from the node would be great

                        After changing the include from Ethernet.h to UIPEthernet.h the sketch fits into the m328 only with DEBUG (and TCPDUMP) turned off:

                        DEBUG / TCPDUMP turned off:
                        Sketch uses 30,626 bytes (99%) of program storage space. Maximum is 30,720 bytes.
                        Global variables use 1,330 bytes (64%) of dynamic memory, leaving 718 bytes for local variables. Maximum is 2,048 bytes.

                        DEBUG / TCPDUMP turned on:
                        Sketch uses 32,354 bytes (105%) of program storage space. Maximum is 30,720 bytes.
                        Global variables use 1,393 bytes (68%) of dynamic memory, leaving 655 bytes for local variables. Maximum is 2,048 bytes.
                        processing.app.debug.RunnerException: Sketch too big;

                        The only thing I have right now to look at is the OpenHAB output (appears that it's not happening when I reset a node but rather random):

                        pi@openhab ~/runtime $ ./start.sh
                        Launching the openHAB runtime...
                        osgi> 19:54:19.384 INFO o.o.c.internal.CoreActivator[:61] - openHAB runtime has been started (v1.6.0).
                        19:54:39.316 INFO o.o.i.t.mqtt.MqttService[:106] - MQTT Service initialization completed.
                        19:54:39.322 INFO o.o.i.t.m.i.MqttBrokerConnection[:112] - Starting MQTT broker connection 'mysensor'
                        19:54:42.838 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'logging.persist'
                        19:54:46.082 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'exec.persist'
                        19:54:46.261 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'rrd4j.persist'
                        19:54:46.494 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'db4o.persist'
                        19:54:47.009 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'test.items'
                        19:55:01.187 INFO o.o.i.s.i.DiscoveryServiceImpl[:72] - mDNS service has been started
                        19:55:10.219 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'test.sitemap'
                        19:55:19.042 INFO o.o.io.rest.RESTApplication[:143] - Started REST API at /rest
                        19:55:24.936 INFO o.o.u.w.i.s.WebAppServlet[:79] - Started Classic UI at /openhab.app
                        19:55:35.271 ERROR o.o.i.t.m.i.MqttBrokerConnection[:478] - Error starting consumer
                        org.eclipse.paho.client.mqttv3.MqttException: Connection lost
                        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138)
                        Caused by: java.net.SocketException: Connection reset
                        at java.net.SocketInputStream.read(SocketInputStream.java:196)
                        19:55:35.298 ERROR o.o.i.t.m.i.MqttBrokerConnection[:532] - MQTT connection to broker was lost
                        org.eclipse.paho.client.mqttv3.MqttException: Connection lost
                        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138)
                        Caused by: java.net.SocketException: Connection reset
                        at java.net.SocketInputStream.read(SocketInputStream.java:196)
                        19:55:35.305 ERROR o.o.i.t.m.i.MqttBrokerConnection[:536] - MQTT connection to 'mysensor' was lost: Connection lost : ReasonCode 32109 : Cause : Connection reset
                        19:55:35.310 INFO o.o.i.t.m.i.MqttBrokerConnection[:543] - Starting connection helper to periodically try restore connection to broker 'mysensor'
                        19:55:45.317 INFO o.o.i.t.m.i.MqttBrokerConnection[:112] - Starting MQTT broker connection 'mysensor'

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

                        @ToSa wireshark dump https://www.wireshark.org/ or tcpdump http://www.tcpdump.org/

                        T 1 Reply Last reply
                        0
                        • DammeD Damme

                          @ToSa wireshark dump https://www.wireshark.org/ or tcpdump http://www.tcpdump.org/

                          T Offline
                          T Offline
                          ToSa
                          Code Contributor
                          wrote on last edited by
                          #14

                          @Damme said:

                          @ToSa wireshark dump https://www.wireshark.org/ or tcpdump http://www.tcpdump.org/

                          Thought you were referring to the "#define TCPDUMP" in MyMQTT.h :)

                          I did "sudo tcpdump host 10.0.1.99 -i eth0 -w dump.pcap" on the RPi that is running the OpenHAB runtime (10.0.1.6 is the IP of the RPi with OpenHAB / 10.0.1.99 is the IP of the MQTT gateway) and then did the following:

                          • power-on MQTT gateway
                          • start OpenHAB and wait until startup finished
                          • power-on node with DallasTemperature

                          The pcap file is attached (not knowing a lot about the protocol it looks like a series of keep-alive messages only and suddenly a connection reset): dump2.pcap

                          I do not see any messages arriving at OpenHAB... looking at the debug output from the node it appears that the "find parent" message is correctly handled by the gateway but the "node ID request" is not.

                          ** OpenHAB output: **

                          pi@openhab ~/runtime $ ./start.sh
                          Launching the openHAB runtime...
                          osgi> 21:55:31.305 INFO o.o.c.internal.CoreActivator[:61] - openHAB runtime has been started (v1.6.0).
                          21:55:50.955 INFO o.o.i.t.mqtt.MqttService[:106] - MQTT Service initialization completed.
                          21:55:50.974 INFO o.o.i.t.m.i.MqttBrokerConnection[:112] - Starting MQTT broker connection 'mysensor'
                          21:55:57.178 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'logging.persist'
                          21:55:59.989 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'exec.persist'
                          21:56:00.137 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'rrd4j.persist'
                          21:56:00.303 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'db4o.persist'
                          21:56:01.162 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'test.items'
                          21:56:13.732 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'test.sitemap'
                          21:56:16.231 INFO o.o.i.s.i.DiscoveryServiceImpl[:72] - mDNS service has been started
                          21:56:31.603 INFO o.o.io.rest.RESTApplication[:143] - Started REST API at /rest
                          21:56:37.387 INFO o.o.u.w.i.s.WebAppServlet[:79] - Started Classic UI at /openhab.app
                          21:59:50.613 ERROR o.o.i.t.m.i.MqttBrokerConnection[:532] - MQTT connection to broker was lost
                          org.eclipse.paho.client.mqttv3.MqttException: Connection lost
                          at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138)
                          Caused by: java.net.SocketException: Connection reset
                          at java.net.SocketInputStream.read(SocketInputStream.java:196)
                          21:59:50.621 ERROR o.o.i.t.m.i.MqttBrokerConnection[:536] - MQTT connection to 'mysensor' was lost: Connection lost : ReasonCode 32109 : Cause : Connection reset
                          21:59:50.625 INFO o.o.i.t.m.i.MqttBrokerConnection[:543] - Starting connection helper to periodically try restore connection to broker 'mysensor'
                          22:00:00.633 INFO o.o.i.t.m.i.MqttBrokerConnection[:112] - Starting MQTT broker connection 'mysensor'

                          ** The serial debug output of the node shows (more than that but always repeating as I did several resets of the node): **

                          sensor started, id 255
                          req node id
                          send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                          req node id
                          send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                          req node id
                          send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                          req node id
                          send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                          req node id
                          send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                          req node id
                          send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                          send: 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
                          req node id
                          send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                          req node id
                          send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:

                          DammeD 1 Reply Last reply
                          0
                          • T ToSa

                            @Damme said:

                            @ToSa wireshark dump https://www.wireshark.org/ or tcpdump http://www.tcpdump.org/

                            Thought you were referring to the "#define TCPDUMP" in MyMQTT.h :)

                            I did "sudo tcpdump host 10.0.1.99 -i eth0 -w dump.pcap" on the RPi that is running the OpenHAB runtime (10.0.1.6 is the IP of the RPi with OpenHAB / 10.0.1.99 is the IP of the MQTT gateway) and then did the following:

                            • power-on MQTT gateway
                            • start OpenHAB and wait until startup finished
                            • power-on node with DallasTemperature

                            The pcap file is attached (not knowing a lot about the protocol it looks like a series of keep-alive messages only and suddenly a connection reset): dump2.pcap

                            I do not see any messages arriving at OpenHAB... looking at the debug output from the node it appears that the "find parent" message is correctly handled by the gateway but the "node ID request" is not.

                            ** OpenHAB output: **

                            pi@openhab ~/runtime $ ./start.sh
                            Launching the openHAB runtime...
                            osgi> 21:55:31.305 INFO o.o.c.internal.CoreActivator[:61] - openHAB runtime has been started (v1.6.0).
                            21:55:50.955 INFO o.o.i.t.mqtt.MqttService[:106] - MQTT Service initialization completed.
                            21:55:50.974 INFO o.o.i.t.m.i.MqttBrokerConnection[:112] - Starting MQTT broker connection 'mysensor'
                            21:55:57.178 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'logging.persist'
                            21:55:59.989 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'exec.persist'
                            21:56:00.137 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'rrd4j.persist'
                            21:56:00.303 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'db4o.persist'
                            21:56:01.162 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'test.items'
                            21:56:13.732 INFO o.o.m.c.i.ModelRepositoryImpl[:79] - Loading model 'test.sitemap'
                            21:56:16.231 INFO o.o.i.s.i.DiscoveryServiceImpl[:72] - mDNS service has been started
                            21:56:31.603 INFO o.o.io.rest.RESTApplication[:143] - Started REST API at /rest
                            21:56:37.387 INFO o.o.u.w.i.s.WebAppServlet[:79] - Started Classic UI at /openhab.app
                            21:59:50.613 ERROR o.o.i.t.m.i.MqttBrokerConnection[:532] - MQTT connection to broker was lost
                            org.eclipse.paho.client.mqttv3.MqttException: Connection lost
                            at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:138)
                            Caused by: java.net.SocketException: Connection reset
                            at java.net.SocketInputStream.read(SocketInputStream.java:196)
                            21:59:50.621 ERROR o.o.i.t.m.i.MqttBrokerConnection[:536] - MQTT connection to 'mysensor' was lost: Connection lost : ReasonCode 32109 : Cause : Connection reset
                            21:59:50.625 INFO o.o.i.t.m.i.MqttBrokerConnection[:543] - Starting connection helper to periodically try restore connection to broker 'mysensor'
                            22:00:00.633 INFO o.o.i.t.m.i.MqttBrokerConnection[:112] - Starting MQTT broker connection 'mysensor'

                            ** The serial debug output of the node shows (more than that but always repeating as I did several resets of the node): **

                            sensor started, id 255
                            req node id
                            send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                            req node id
                            send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                            req node id
                            send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                            req node id
                            send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                            req node id
                            send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                            req node id
                            send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                            send: 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,st=fail:
                            req node id
                            send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:
                            req node id
                            send: 255-255-0-0 s=255,c=3,t=3,pt=0,l=0,st=fail:

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

                            @ToSa Thats odd. Everything looks good...(almost, there are some excess of trailing 0x00 but shouldn't matter, but I'll look at that anyways..)
                            Can you compile with myconfig debug enabled, but define tcpdump disabled? or is it too big that way too?

                            1 Reply Last reply
                            0
                            • JohnJ Offline
                              JohnJ Offline
                              John
                              Plugin Developer
                              wrote on last edited by John
                              #16

                              @Damme

                              I'm currently busy implementing an mqtt client plugin, and i'm going to use mysensors for it's first predefined implementation so i have a couple of questions

                              I took a look at the api page and saw this in the mqtt documentation:

                              [MQTT_BROKER_PREFIX]/[NodeID]/[SensorID]/V_[SensorType]
                              

                              Does this means as example:

                              MyMQTT/[0-255]/[0-255]/[STRING]/[VALUE]
                              

                              OR this?

                              MyMQTT/[0-255]/[0-255]/[0-endvarindex]/[VALUE]
                              
                              • Are variable types defined by their index used or by name?
                              • Also it states it keeps track of node id's how are these reported by the broker, should the controller still hand out free id's?

                              [EDIT]
                              I currently do not have the hardware present to at least set it up to test and look at what exactly is happening.
                              [/EDIT]

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

                              DammeD 1 Reply Last reply
                              0
                              • JohnJ John

                                @Damme

                                I'm currently busy implementing an mqtt client plugin, and i'm going to use mysensors for it's first predefined implementation so i have a couple of questions

                                I took a look at the api page and saw this in the mqtt documentation:

                                [MQTT_BROKER_PREFIX]/[NodeID]/[SensorID]/V_[SensorType]
                                

                                Does this means as example:

                                MyMQTT/[0-255]/[0-255]/[STRING]/[VALUE]
                                

                                OR this?

                                MyMQTT/[0-255]/[0-255]/[0-endvarindex]/[VALUE]
                                
                                • Are variable types defined by their index used or by name?
                                • Also it states it keeps track of node id's how are these reported by the broker, should the controller still hand out free id's?

                                [EDIT]
                                I currently do not have the hardware present to at least set it up to test and look at what exactly is happening.
                                [/EDIT]

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

                                @John MyMQTT/[0-255]/[0-255]/[STRING]/[VALUE]

                                MQTT.cpp :

                                sprintf(&buffer[buffsize],"/%i/%i/V_%s", msg.sender, msg.sensor, getType(convBuf, &vType[msg.type]));
                                

                                note V_%s -> MyMQTT/[0-255]/[0-255]/V_[STRING]/[VALUE]
                                also note there is no trailing / before payload, as http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/mqtt-v3r1.html
                                http://mqtt.org/wiki/doku.php/topic_format
                                I choose not to have trailing slash, but if needed its easy to make it configurable.

                                and get type translates from this list

                                  char V_0[] PROGMEM = "TEMP";		//V_TEMP
                                  char V_1[] PROGMEM = "HUM";		//V_HUM
                                  char V_2[] PROGMEM = "LIGHT";		//V_LIGHT
                                  char V_3[] PROGMEM = "DIMMER";		//V_DIMMER
                                  char V_4[] PROGMEM = "PRESSURE";	//V_PRESSURE
                                  char V_5[] PROGMEM = "FORECAST";	//V_FORECAST
                                  char V_6[] PROGMEM = "RAIN";		//V_RAIN
                                  char V_7[] PROGMEM = "RAINRATE";	//V_RAINRATE
                                  char V_8[] PROGMEM = "WIND";		//V_WIND
                                  char V_9[] PROGMEM = "GUST";		//V_GUST
                                  char V_10[] PROGMEM = "DIRECTON";	//V_DIRECTON
                                  char V_11[] PROGMEM = "UV";		//V_UV
                                  char V_12[] PROGMEM = "WEIGHT";		//V_WEIGHT
                                  char V_13[] PROGMEM = "DISTANCE";	//V_DISTANCE
                                  char V_14[] PROGMEM = "IMPEDANCE";	//V_IMPEDANCE
                                  char V_15[] PROGMEM = "ARMED";		//V_ARMED
                                  char V_16[] PROGMEM = "TRIPPED";	//V_TRIPPED
                                  char V_17[] PROGMEM = "WATT";		//V_WATT
                                  char V_18[] PROGMEM = "KWH";		//V_KWH
                                  char V_19[] PROGMEM = "SCENE_ON";	//V_SCENE_ON
                                  char V_20[] PROGMEM = "SCENE_OFF";	//V_SCENE_OFF
                                  char V_21[] PROGMEM = "HEATER";		//V_HEATER
                                  char V_22[] PROGMEM = "HEATER_SW";	//V_HEATER_SW
                                  char V_23[] PROGMEM = "LIGHT_LEVEL";	//V_LIGHT_LEVEL
                                  char V_24[] PROGMEM = "VAR1";		//V_VAR1
                                  char V_25[] PROGMEM = "VAR2";		//V_VAR2
                                  char V_26[] PROGMEM = "VAR3";		//V_VAR3
                                  char V_27[] PROGMEM = "VAR4";		//V_VAR4
                                  char V_28[] PROGMEM = "VAR5";		//V_VAR5
                                  char V_29[] PROGMEM = "UP";		//V_UP
                                  char V_30[] PROGMEM = "DOWN";		//V_DOWN
                                  char V_31[] PROGMEM = "STOP";		//V_STOP
                                  char V_32[] PROGMEM = "IR_SEND";	//V_IR_SEND
                                  char V_33[] PROGMEM = "IR_RECEIVE";	//V_IR_RECEIVE
                                  char V_34[] PROGMEM = "FLOW";		//V_FLOW
                                  char V_35[] PROGMEM = "VOLUME";		//V_VOLUME
                                  char V_36[] PROGMEM = "LOCK_STATUS";	//V_LOCK_STATUS
                                  char V_37[] PROGMEM = "DUST_LEVEL";	//V_DUST_LEVEL
                                  char V_38[] PROGMEM = "VOLTAGE";	//V_VOLTAGE
                                  char V_39[] PROGMEM = "CURRENT";	//V_CURRENT
                                  char V_40[] PROGMEM = "";		//
                                  char V_41[] PROGMEM = "";		//
                                  char V_42[] PROGMEM = "";		//
                                  char V_43[] PROGMEM = "";		//
                                  char V_44[] PROGMEM = "";		//
                                  char V_45[] PROGMEM = "";		//
                                  char V_46[] PROGMEM = "";		//
                                  char V_47[] PROGMEM = "";		//
                                  char V_48[] PROGMEM = "";		//
                                  char V_49[] PROGMEM = "";		//
                                  char V_50[] PROGMEM = "";		//
                                  char V_51[] PROGMEM = "";		//
                                  char V_52[] PROGMEM = "";		//
                                  char V_53[] PROGMEM = "";		//
                                  char V_54[] PROGMEM = "";		//
                                  char V_55[] PROGMEM = "";		//
                                  char V_56[] PROGMEM = "";		//
                                  char V_57[] PROGMEM = "";		//
                                  char V_58[] PROGMEM = "";		//
                                  char V_59[] PROGMEM = "";		//
                                  char V_60[] PROGMEM = "Started!\n";	//Custom for MQTTGateway
                                  char V_61[] PROGMEM = "SKETCH_NAME";	//Custom for MQTTGateway
                                  char V_62[] PROGMEM = "SKETCH_VERSION"; //Custom for MQTTGateway
                                  char V_63[] PROGMEM = "UNKNOWN"; 	//Custom for MQTTGateway
                                  char V_64[] PROGMEM = "FW_CREQ"; 	//Custom for MQTTGateway
                                  char V_65[] PROGMEM = "FW_CRES"; 	//Custom for MQTTGateway
                                  char V_66[] PROGMEM = "FW_REQ"; 	//Custom for MQTTGateway
                                  char V_67[] PROGMEM = "FW_RES"; 	//Custom for MQTTGateway
                                

                                The MQTTgateway hands out ID's; configured in MQTT.h:

                                  #define MQTT_FIRST_SENSORID	20  		// If you want manually configured nodes below this value. 255 = Disable
                                  #define MQTT_LAST_SENSORID	254 		// 254 is max! 255 reserved.
                                  #define MQTT_BROKER_PREFIX	"MyMQTT"	// First prefix in MQTT tree, keep short!
                                  #define MQTT_SEND_SUBSCRIPTION 1		// Send empty payload (request) to node upon MQTT client subscribe request.
                                  // NOTE above : Beware to check if there is any length on payload in your incommingMessage code:
                                  // Example: if (msg.type==V_LIGHT && strlen(msg.getString())>0) otherwise the code might do strange things.
                                
                                1 Reply Last reply
                                0
                                • JohnJ Offline
                                  JohnJ Offline
                                  John
                                  Plugin Developer
                                  wrote on last edited by
                                  #18

                                  @Damme
                                  Clear!

                                  And how about the internal messages? Are these somewhat compatible with the Serial API? Like this one now has a "I_GATEWAY_READY" internal var, this one complies then with the "Started!\n" message?

                                  Also about the presentation (if the node does it), are these also passed through?

                                  I know it's a bit question banging... But i just want to do it right.

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

                                  DammeD 1 Reply Last reply
                                  0
                                  • JohnJ John

                                    @Damme
                                    Clear!

                                    And how about the internal messages? Are these somewhat compatible with the Serial API? Like this one now has a "I_GATEWAY_READY" internal var, this one complies then with the "Started!\n" message?

                                    Also about the presentation (if the node does it), are these also passed through?

                                    I know it's a bit question banging... But i just want to do it right.

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

                                    @John No worries! :)
                                    Presentation is On Todo.. Or Rather To think About list is presentation . I dont do anything with that as it is (Just ignores it). I havn't had any good idea for that yet.

                                    Internal is nothing more or less, it connects and set a variable that it is connected. :) But sure, there could be transport for internal messages also.
                                    I do have an experimental version there I can send internal messages to reboot node, reboot gateway and set clear read eeprom values. (over mqtt-protocol) but this s not finnished yet.. Ideas are welcome!

                                    DammeD 1 Reply Last reply
                                    0
                                    • DammeD Damme

                                      @John No worries! :)
                                      Presentation is On Todo.. Or Rather To think About list is presentation . I dont do anything with that as it is (Just ignores it). I havn't had any good idea for that yet.

                                      Internal is nothing more or less, it connects and set a variable that it is connected. :) But sure, there could be transport for internal messages also.
                                      I do have an experimental version there I can send internal messages to reboot node, reboot gateway and set clear read eeprom values. (over mqtt-protocol) but this s not finnished yet.. Ideas are welcome!

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

                                      @John About Presentation ; My idea was that next version of the variable system I will either store some bytes in the MQTT gateway about what S_types to V_types, or hopefully the next protocol contains both those so the GW doesnt have to remember. And then add an extra directory to the MQTT path ( MyMQTT/[0-255]/[0-255]/S_[STRING]/V_[STRING]/[VALUE]

                                      1 Reply Last reply
                                      0
                                      • JohnJ Offline
                                        JohnJ Offline
                                        John
                                        Plugin Developer
                                        wrote on last edited by John
                                        #21

                                        I think maybe it depends on the next protocol implementation. Personally i wouldn't mind if the full path mapping was /[0-255]/[0-255]/etc.. to keep (prog)mem print smaller (use the V_ and S_ array index values). It could leave space for more specific things or some extra gateway specific functions.

                                        it would be nice if the mqtt gateway output was "cloned" to the serial output. Controllers should/could be able to map the S_ and V_ types internally. I'm not aware of the openhab config if that would allow this, or that such a setup would require a lot of coding at openhab side.

                                        [EDIT]
                                        It would be more difficult to read though if a path would only exist of numbers. But could also introduce easier maintainability in your library because you wouldn't have to keep track on type namings.
                                        [/EDIT].

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

                                        DammeD 1 Reply Last reply
                                        0
                                        • JohnJ John

                                          I think maybe it depends on the next protocol implementation. Personally i wouldn't mind if the full path mapping was /[0-255]/[0-255]/etc.. to keep (prog)mem print smaller (use the V_ and S_ array index values). It could leave space for more specific things or some extra gateway specific functions.

                                          it would be nice if the mqtt gateway output was "cloned" to the serial output. Controllers should/could be able to map the S_ and V_ types internally. I'm not aware of the openhab config if that would allow this, or that such a setup would require a lot of coding at openhab side.

                                          [EDIT]
                                          It would be more difficult to read though if a path would only exist of numbers. But could also introduce easier maintainability in your library because you wouldn't have to keep track on type namings.
                                          [/EDIT].

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

                                          @John That was my first aproach, and I might set a define configuration to choose if the MQTT gateway should translate or not. As you say, the footprint would be much smaller.
                                          Might be next version of the MQTT, slectable address layout :)

                                          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.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