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.7k 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
    • H Offline
      H 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
          • H Offline
            H 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
            • H 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

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              21

              Online

              12.0k

              Users

              11.2k

              Topics

              113.4k

              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