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

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. How to know what MQTT topic to send data on to reach a relay?

How to know what MQTT topic to send data on to reach a relay?

Scheduled Pinned Locked Moved Troubleshooting
18 Posts 5 Posters 9.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.
  • hekH hek

    When did you last update the library code?

    Do you have this that was committed 12 days ago?
    https://github.com/mysensors/Arduino/pull/251

    S Offline
    S Offline
    Samuel235
    Hardware Contributor
    wrote on last edited by
    #6

    I got the development branch 2 days ago from your github.

    Would the child sensor id be the same on the publish topic as it is on the subscribe topic, surely yes, if so then the relay has a ID of 1. Which implies that i have my published message correct and its just not leaving the gateway. Which would then point towards what your suggesting of my gateway not being a repeater.

    I just checked what the change was on the MySensor.h file for that update you just linked and i can confirm i have it in my version of MySensor.h:

    // GATEWAY - TRANSPORT
    #if defined(MY_GATEWAY_MQTT_CLIENT)
    	#if defined(MY_RADIO_FEATURE)
    		// We assume that a gateway having a radio also should act as repeater
    		#define MY_REPEATER_FEATURE
    	#endif
    

    MySensors 2.1.1
    Controller - OpenHAB (Virtual Machine)
    Gateway - Arduino Mega MQTT Gateway W5100

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

      @samuel235 said:

      Would you say that the construction of my message looks okay and conforms with the API?

      Yes it looks ok. Very strange.

      Far fetched: Could it be something about case sensitivity on topic prefix naming? But you get "Message arrived on topic" message... Hmm..

      S 1 Reply Last reply
      0
      • hekH hek

        @samuel235 said:

        Would you say that the construction of my message looks okay and conforms with the API?

        Yes it looks ok. Very strange.

        Far fetched: Could it be something about case sensitivity on topic prefix naming? But you get "Message arrived on topic" message... Hmm..

        S Offline
        S Offline
        Samuel235
        Hardware Contributor
        wrote on last edited by
        #8

        @hek I've just been comparing the 1.5 RelayActuator sketch with the Development one.

        Is it supposed to be completely different? I'm assuming its referenced in the MySensor.h but the development sketch doesn't have any of the gw. options or anything. This is how its supposed to be? In an attempt to lower the memory needed on the node side?

        Just out of interested, could you briefly explain or point me to the page where i can decode the sending message layout "send: 4-4-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:" Makes no sense to me at all. I only know that the s=1 is something to do with the sensor attached maybe? I keep looking everywhere to decode this and i can't get any sense out of it. It probably wont have any influence on this issue but i would just like to understand the methods, if possible.

        MySensors 2.1.1
        Controller - OpenHAB (Virtual Machine)
        Gateway - Arduino Mega MQTT Gateway W5100

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Samuel235
          Hardware Contributor
          wrote on last edited by
          #9

          I've just found this in the sketch

          void receive(const MyMessage &message) {
            // We only expect one type of message from controller. But we better check anyway.
            if (message.isAck()) {
               Serial.println("This is an ack from gateway");
            }
          

          So, i changed my published message to: mosquitto_pub -t Gateway1-in/4/1/1/1/2 -m '1'.

          The relay has not printed anything out, so i think its fair to assume that the issue is for some reason or another the gateway is not pushing that message to the relay node.

          MySensors 2.1.1
          Controller - OpenHAB (Virtual Machine)
          Gateway - Arduino Mega MQTT Gateway W5100

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jpaulin
            wrote on last edited by
            #10

            I´m new on this forum, and I'm really excited about the MySensors project. I've done a lot of research on the internet and haven't found anything close to what you guys are doing.Thanks Henrik and the rest of the team involved! Excellent work, really!

            I haven't tried yet the 1.6 Development Branch; but when looking into your MQTT Client issue I don't recognize the MQTT message format being used (I could be deeply wrong about something I haven't understood about your set-up). Normally the standard MQTT format is a/b/c/d + payload. In my GW_MQTT Client pre-version I'm using to send messages to a Relay sensor I use format: "a/b/c/d/set + payload. In your case it seems to be a/b/c/d/e/f + payload. That wouldn't work in my case. Or in 'MySensors' terms it would be: 'MyMQTT/Sensor_Node_id/Child_Id/Sub_Type/set' + Payload. I use for my relay sensor Sub_Type = V_LIGHT. You're using Sub_Type=2, I guess it is incorrect.

            With mosquitto publish client command it would be: mosquitto_pub -t Gateway1-in/4/0/V_LIGHT/set -m 1 or 0. This works ok for me. I think the command '/set' for publishing to the sensor isn't used in current MySensors V1.6 GW_MQTT_Client proposal. Not sure yet how this has been arranged in V1.6 development branch. I have to look into the code.

            I have an up and running test environment with a pre-relaease to V1.6 MySensors MQTT-GW-Client, a mosquitto-brooker, ZABBIX for monitoring and a bunch of sensors (so far: Temperatue / Humidity / RFID-reader / Energy-Consumption / ON-OFF-sensors (door-open, smoke alarm, motion detector etc.)/ Action-Relays / Battery back-up voltage measurement). It's working incredibly well. I'm impressed so far! To push messages to the relay over MQTT works fine too. My expectations are to reach hopefully hundreds of environmental sensors over MQTT and MySensors to monitor our data-nodes at work via ZABBIX. If anyone is interested in my set-up and preliminary hardware prototypes pls. let me know. (sorry if it's the wrong forum-channel).

            Right now I'm looking into the new RS485 concept added to V1.6. Hopefully it'll work with MQTT? I have been struggling too much with NRF24L01+ without being fully satisfied. Interested as well in the new RFM69W radio with better range with the LowPowerLabs Moteino board, but haven't got time to test so far.

            S 1 Reply Last reply
            0
            • J jpaulin

              I´m new on this forum, and I'm really excited about the MySensors project. I've done a lot of research on the internet and haven't found anything close to what you guys are doing.Thanks Henrik and the rest of the team involved! Excellent work, really!

              I haven't tried yet the 1.6 Development Branch; but when looking into your MQTT Client issue I don't recognize the MQTT message format being used (I could be deeply wrong about something I haven't understood about your set-up). Normally the standard MQTT format is a/b/c/d + payload. In my GW_MQTT Client pre-version I'm using to send messages to a Relay sensor I use format: "a/b/c/d/set + payload. In your case it seems to be a/b/c/d/e/f + payload. That wouldn't work in my case. Or in 'MySensors' terms it would be: 'MyMQTT/Sensor_Node_id/Child_Id/Sub_Type/set' + Payload. I use for my relay sensor Sub_Type = V_LIGHT. You're using Sub_Type=2, I guess it is incorrect.

              With mosquitto publish client command it would be: mosquitto_pub -t Gateway1-in/4/0/V_LIGHT/set -m 1 or 0. This works ok for me. I think the command '/set' for publishing to the sensor isn't used in current MySensors V1.6 GW_MQTT_Client proposal. Not sure yet how this has been arranged in V1.6 development branch. I have to look into the code.

              I have an up and running test environment with a pre-relaease to V1.6 MySensors MQTT-GW-Client, a mosquitto-brooker, ZABBIX for monitoring and a bunch of sensors (so far: Temperatue / Humidity / RFID-reader / Energy-Consumption / ON-OFF-sensors (door-open, smoke alarm, motion detector etc.)/ Action-Relays / Battery back-up voltage measurement). It's working incredibly well. I'm impressed so far! To push messages to the relay over MQTT works fine too. My expectations are to reach hopefully hundreds of environmental sensors over MQTT and MySensors to monitor our data-nodes at work via ZABBIX. If anyone is interested in my set-up and preliminary hardware prototypes pls. let me know. (sorry if it's the wrong forum-channel).

              Right now I'm looking into the new RS485 concept added to V1.6. Hopefully it'll work with MQTT? I have been struggling too much with NRF24L01+ without being fully satisfied. Interested as well in the new RFM69W radio with better range with the LowPowerLabs Moteino board, but haven't got time to test so far.

              S Offline
              S Offline
              Samuel235
              Hardware Contributor
              wrote on last edited by Samuel235
              #11

              @jpaulin I'm not completely sure in what your reply objective is. However, I'm not convinced that you understand the message API properly.... gateway-subscription-prefix/node-id/child-sensor-id/message-type/ack/sub-type/payload. I'm not sure what your meaning with the "/set" at the end of your message layout? For an example, my gateway subscription prefix is "Gateway-1". So for me to set a value of 1 on my relay node i would send the payload as '1' on the route of:

              "/Gateway-1/4/1/1/0/2/[Payload-Goes-Here]" Now, i personally use 2 for the Sub_Type rather than V_Light. Not sure if that will impose any issues further down the line, but it works perfectly for me right now.

              Just to let you know, I run my controller (OpenHAB) and my MQTT Broker (Mosquitto) on a RaspberryPi, then my Gateway is using the development branch of W5100GatewayMQTT which is pretty awesome, and then my sensors at the moment are running all on Arduino Nano Pros, but I'm in the process of converting those to Arduino Pro Minis for lower power consumption and to enable me to get close to installing them in socket boxes behind light switches.

              MySensors 2.1.1
              Controller - OpenHAB (Virtual Machine)
              Gateway - Arduino Mega MQTT Gateway W5100

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jpaulin
                wrote on last edited by
                #12

                ok, I think I need to look into the new MQTTW5100 code to understand better the new API structure. Anyhow, I had a similar case as you mentioned with my MQTT pre-version, where the mesage_type has to be written in ASCII (V_LIGHT), and internally in the .cpp code it's translated to 2. Could be your case, maybe? In the MQTT-GW-Client pre-version I'm using it expects '/set' after the a/b/c/d MQTT message to allow sending forward a message to the sensor node, to avoid message loops. I guess that's been changed in the V1.6 branch.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Samuel235
                  Hardware Contributor
                  wrote on last edited by
                  #13

                  Yeah, the numbers of the type of message is set as variables in the .cpp or the .h file somewhere, i can't remember which one off the top of my head.

                  The /set might still be in but all i'm saying is that i don't need to specify it in my sketches. It may be referenced somewhere. I'm sure Hek could advise on this, not that its an issue as we both have working examples. Just out of curiosity more than anything. The new dev branch for the MQTTGateway is super smooth and functional now. Give it a shot!

                  MySensors 2.1.1
                  Controller - OpenHAB (Virtual Machine)
                  Gateway - Arduino Mega MQTT Gateway W5100

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jpaulin
                    wrote on last edited by
                    #14

                    ok. think I'll give it a try on the weekend.

                    1 Reply Last reply
                    0
                    • Y Offline
                      Y Offline
                      yancym
                      wrote on last edited by
                      #15

                      Here is a page on the message structure. It's the same as the Serial API. There is also a list of all the subtypes.

                      http://www.mysensors.org/download/serial_api_15

                      1 Reply Last reply
                      0
                      • S Samuel235

                        UPDATE:

                        If i publish a message from mosquitto out to the Gateway of:

                        mosquitto_pub -t Gateway1-in/4/1/1/0/2 -m '0'
                        

                        I get this in the Gateway serial interface:

                        0;0;3;0;9;Message arrived on topic: Gateway1-in/4/1/1/0/2
                        

                        Now, the controller isn't reporting that it sent out a message to node 4 (which is my relay node). Should i expect to see it serial print a message saying its sent that message to the node? I've had a little attempt to look through the .h files to see if it is supposed to be saying its sent a message out, i would have thought so considering that it shows when it sends out a message to the controller....

                        ahmedadelhosniA Offline
                        ahmedadelhosniA Offline
                        ahmedadelhosni
                        wrote on last edited by
                        #16

                        @samuel235 I guess you have the same problem which I faced. I managed to receive the topic on the gateway like you have did, but it wasn't sent to the sensor node.

                        There was two fixes for these to work for me. First one which is defining #MY_REAPEATER_NODE (You have already did this ) and hek has verified this solution. The other issue is related to a ( IF CONDITION ) in the code but it was not verified by hek so it was reported as a bug as no one else complained except me.

                        Please read this post that includes details explanation of the two fixes http://forum.mysensors.org/topic/2193/gatewayesp8266mqttclient-in-development-branch/10

                        This is also the main thread where I had the same problem which you complain of now. You can read it if you want also http://forum.mysensors.org/topic/2378/how-can-i-set-the-payload-for-mqtt-v1-6/5

                        Please update me. Hope that it solves your problem.

                        S 1 Reply Last reply
                        0
                        • ahmedadelhosniA ahmedadelhosni

                          @samuel235 I guess you have the same problem which I faced. I managed to receive the topic on the gateway like you have did, but it wasn't sent to the sensor node.

                          There was two fixes for these to work for me. First one which is defining #MY_REAPEATER_NODE (You have already did this ) and hek has verified this solution. The other issue is related to a ( IF CONDITION ) in the code but it was not verified by hek so it was reported as a bug as no one else complained except me.

                          Please read this post that includes details explanation of the two fixes http://forum.mysensors.org/topic/2193/gatewayesp8266mqttclient-in-development-branch/10

                          This is also the main thread where I had the same problem which you complain of now. You can read it if you want also http://forum.mysensors.org/topic/2378/how-can-i-set-the-payload-for-mqtt-v1-6/5

                          Please update me. Hope that it solves your problem.

                          S Offline
                          S Offline
                          Samuel235
                          Hardware Contributor
                          wrote on last edited by Samuel235
                          #17

                          @ahmedadelhosni I have got my gateway working perfectly with my sensors now, have a look at my topic i created for this issue.

                          http://forum.mysensors.org/topic/2469/solved-mqttgatewayw5100-not-sending-messages-to-nodes

                          MySensors 2.1.1
                          Controller - OpenHAB (Virtual Machine)
                          Gateway - Arduino Mega MQTT Gateway W5100

                          ahmedadelhosniA 1 Reply Last reply
                          0
                          • S Samuel235

                            @ahmedadelhosni I have got my gateway working perfectly with my sensors now, have a look at my topic i created for this issue.

                            http://forum.mysensors.org/topic/2469/solved-mqttgatewayw5100-not-sending-messages-to-nodes

                            ahmedadelhosniA Offline
                            ahmedadelhosniA Offline
                            ahmedadelhosni
                            wrote on last edited by
                            #18

                            @samuel235 Yes. That's the same issue which I was pointing to but with a better solution. Glad that someone guided you (Y)

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