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. Library 1.6 devel - How query the parent node?

Library 1.6 devel - How query the parent node?

Scheduled Pinned Locked Moved Troubleshooting
6 Posts 2 Posters 1.3k Views 2 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.
  • X Offline
    X Offline
    xefil
    wrote on last edited by
    #1

    Hello,

    I'm using succesfully the new development library.
    If I set the parent to AUTO and enable the debug mode, I can see which parent was choosen.
    I would like to save this output to a variable.
    Can I query (maybe during presentation) the parent I get during the discovery? How?
    Thanks'

    Simon

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

      You should be able to query query parent id through:

      _nc.parentNodeId
      

      Hmm. we should probably add a new method getParentId() or something to make it a bit more publicly accessible .

      1 Reply Last reply
      1
      • X Offline
        X Offline
        xefil
        wrote on last edited by
        #3

        Ok, thank you!
        Should be enough something like that?

        int parntNode = _nc.parentNodeId;
        

        L'll give it a try.

        Thank's!

        Simon
        PS: I've seen I could query as well 'distance' :)

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xefil
          wrote on last edited by
          #4

          Hello @hek
          I was able to query the parentnode. I would like to send this information to the Gateway and then save/display it into my controller.
          How i s the best way to send these informations? They are not really related to a sensor, are more custom.

          I could define it something like that:

          // parent
          MyMessage msgNodeVar1(CHILD_ID_NODE, V_VAR1)
          // distance
          MyMessage msgNodeVar1(CHILD_ID_NODE, V_VAR2)
          

          but under which sub-type present it?

          present(CHILD_ID_NODE, S_<WHICHONE???>);
          

          Then into loop() with a time I could then send these informations:

          parentNode = _nc.parentNodeId;
          send(msgNodeVar1.set(parentNode, 1));
          
          distance = _nc.distance;
          send(msgNodeVar2.set(distance, 1));
          

          So, to be clean, which subtype should I use for the presentation?

          Thanks!

          Simon

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

            The parent node-id is sent automatically during node presentation (and can be retrieved from a running node by sending an I_PRESENTATION to the node).

            https://github.com/mysensors/MySensors/blob/dc99e8a8d4b024d69af3b67d3b9f1190700a5200/core/MySensorsCore.cpp#L216

            But to answer your question, The VAR_X can be used with any device type.

            X 1 Reply Last reply
            0
            • hekH hek

              The parent node-id is sent automatically during node presentation (and can be retrieved from a running node by sending an I_PRESENTATION to the node).

              https://github.com/mysensors/MySensors/blob/dc99e8a8d4b024d69af3b67d3b9f1190700a5200/core/MySensorsCore.cpp#L216

              But to answer your question, The VAR_X can be used with any device type.

              X Offline
              X Offline
              xefil
              wrote on last edited by
              #6

              @hek
              I can retrive the parent node by requesting it, that's ok. I have no idea how to do that (if you can point me to an example...)
              BTW, if I would like to inform the Controller (OpenHAB) on which parent is used by a node (I'm using MQTTClient as GW) I need to present and register this information as written by me before or there is another way as well?

              Thanks!
              simon

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


              28

              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