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. Node-RED
  4. Extract sensor values in Node-red

Extract sensor values in Node-red

Scheduled Pinned Locked Moved Node-RED
23 Posts 5 Posters 10.3k Views 8 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.
  • gohanG gohan

    I don't remember how to use the mysensors nodes, but knowing how mqtt works, just take advantage of it: the sensor is publishing a value to a topic, so just read that.

    lozzer65L Offline
    lozzer65L Offline
    lozzer65
    wrote on last edited by
    #11

    @gohan I am just thinking about the implications of moving to mqqt. This will break my home assistant setup. I also have over 30 sensors I would have to change the setup of.

    If you see this as an example, "67;0;1;0;0;62.5↵" which is my data from a sensor showing in node-red debug. The 67 is the nodeId, the next 0 is the childSensor Id and the 62.5 is the temperature.

    This the code I am using in a function of node-red to try and extract the temp value.
    if (msg.payload.nodeId == 67 && msg.payload.childSensorId === 0) {
    var msg;
    msg.payload = msg.payload.value;
    msg.topic = "Temperature";
    return msg;
    }

    Can anyone spot any reason why this may not work ?

    G 1 Reply Last reply
    0
    • gohanG Offline
      gohanG Offline
      gohan
      Mod
      wrote on last edited by
      #12

      You don't need to change the sensors. Did you check if HA doesn't support mqtt gateway?

      1 Reply Last reply
      0
      • lozzer65L Offline
        lozzer65L Offline
        lozzer65
        wrote on last edited by
        #13

        I have built an Mqtt gateway as you suggested. from the arduino serial monitor I can see it working, as below.
        0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
        0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.5
        0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
        0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.0
        0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
        0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.5
        0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
        0;255;3;0;9;TSF:MSG:READ,67-67-0,s=3,c=1,t=0,pt=7,l=5,sg=0:11.0
        0;255;3;0;9;Sending message on topic: mygateway1-out/67/3/1/0/0
        0;255;3;0;9;TSF:MSG:READ,67-67-0,s=5,c=1,t=0,ptto=7,l=5,sg=0:16.5
        0;255;3;0;9;Sending message on topic: mygateway1-out/67/5/1/0/0

        I have mosquitto broker running on my pi 3. Node-red shows connected to the mqqt broker, yet no data is shown passing.

        any ideas how best to fault find this issue

        1 Reply Last reply
        0
        • gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #14

          If you use a mqtt client and subscribe to the topic mygateway1-out/67/5/1/0/0 do you actually see messages? Or subscribe to mygateway1-out/# and see all mqtt messages. If you see correct messages your setup is correct

          1 Reply Last reply
          1
          • lozzer65L Offline
            lozzer65L Offline
            lozzer65
            wrote on last edited by
            #15

            Gohan

            Thanks very much for that pointer. You have been very helpful. All working now.

            1 Reply Last reply
            1
            • gohanG Offline
              gohanG Offline
              gohan
              Mod
              wrote on last edited by
              #16

              Do you think it is easier with mqtt or with serial?

              1 Reply Last reply
              0
              • tbowmoT Offline
                tbowmoT Offline
                tbowmo
                Admin
                wrote on last edited by
                #17

                If you use the node-red-contrib-mysensors nodes, then you can split the sensor string into the different parts.

                Then you are able to use for example the switch node, to filter the data..

                0_1509910711235_flow-mysensors.png

                S 1 Reply Last reply
                1
                • lozzer65L lozzer65

                  @gohan I am just thinking about the implications of moving to mqqt. This will break my home assistant setup. I also have over 30 sensors I would have to change the setup of.

                  If you see this as an example, "67;0;1;0;0;62.5↵" which is my data from a sensor showing in node-red debug. The 67 is the nodeId, the next 0 is the childSensor Id and the 62.5 is the temperature.

                  This the code I am using in a function of node-red to try and extract the temp value.
                  if (msg.payload.nodeId == 67 && msg.payload.childSensorId === 0) {
                  var msg;
                  msg.payload = msg.payload.value;
                  msg.topic = "Temperature";
                  return msg;
                  }

                  Can anyone spot any reason why this may not work ?

                  G Offline
                  G Offline
                  Geoff
                  wrote on last edited by
                  #18

                  @lozzer65 I'm playing with node red and a mock TCP gateway at the moment and looking at your code I think the problem is that rather than msg.payload.nodeId it should be msg.nodeId and msg.payload.childSensorId should be msg.childSensorId. I realise you've moved on to MQTT but thought I'd mention it in case others come looking.

                  1 Reply Last reply
                  1
                  • tbowmoT tbowmo

                    If you use the node-red-contrib-mysensors nodes, then you can split the sensor string into the different parts.

                    Then you are able to use for example the switch node, to filter the data..

                    0_1509910711235_flow-mysensors.png

                    S Offline
                    S Offline
                    scottdube
                    wrote on last edited by
                    #19

                    @tbowmo Hi there I have your nodes installed but having a little trouble getting started. Is there any documentation I could follow? I want to build a flow just like the one you have in this post. Thank for your help and your work on this!

                    1 Reply Last reply
                    0
                    • tbowmoT Offline
                      tbowmoT Offline
                      tbowmo
                      Admin
                      wrote on last edited by
                      #20

                      @scottdube

                      Sorry I don't have more documentation at hand, than what is in the mysensors npm module already. But basically I use the switch node to route messages, on subtype, then on nodeId, and last on childId.

                      I'm currently remodeling my node-red setup.. Moving everything to MQTT for internal message distribution between all parts (both within node-red and to external systems).

                      S 1 Reply Last reply
                      1
                      • tbowmoT tbowmo

                        @scottdube

                        Sorry I don't have more documentation at hand, than what is in the mysensors npm module already. But basically I use the switch node to route messages, on subtype, then on nodeId, and last on childId.

                        I'm currently remodeling my node-red setup.. Moving everything to MQTT for internal message distribution between all parts (both within node-red and to external systems).

                        S Offline
                        S Offline
                        scottdube
                        wrote on last edited by
                        #21

                        @tbowmo Thank you, would it be possible to get that flow? I have not been successful building it myself.

                        Thanks for your work on this!

                        1 Reply Last reply
                        0
                        • tbowmoT Offline
                          tbowmoT Offline
                          tbowmo
                          Admin
                          wrote on last edited by
                          #22

                          @scottdube

                          I have put my nodered flows on github as a project, where you can clone from, find it at https://github.com/tbowmo/nodered-mysensors-flow

                          Please note that this is taylored specifically to my usage, but could be used as an inspiration..

                          (In nodered 0.18.x they have added possibility to have multiple projects, including git and github integration)

                          S 1 Reply Last reply
                          0
                          • tbowmoT tbowmo

                            @scottdube

                            I have put my nodered flows on github as a project, where you can clone from, find it at https://github.com/tbowmo/nodered-mysensors-flow

                            Please note that this is taylored specifically to my usage, but could be used as an inspiration..

                            (In nodered 0.18.x they have added possibility to have multiple projects, including git and github integration)

                            S Offline
                            S Offline
                            scottdube
                            wrote on last edited by
                            #23

                            @tbowmo Thank you! I am needing the inspiration! :)

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


                            29

                            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