Library 1.6 devel - How query the parent node?



  • 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


  • Admin

    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 .



  • 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' 🙂



  • 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


  • Admin

    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.



  • @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


Log in to reply
 

Suggested Topics

13
Online

11.2k
Users

11.1k
Topics

112.5k
Posts