pairing nodes with each other



  • Hi,

    Ive been playing around with MySensors for a while now and I have become quite fond of having things which I can automate and control from my bed.

    Since I am retro fitting conventional ceiling lamps and heaters, I have to bypass the wall switches and keep them in always ON mode (to provide mains power). The actual ON/OFF mechanism is controlled by the sensor nodes, which are placed near-by the bulb holder or end of the wire for other items. In this way, I have no physical switch with which I can control the actual bulb. I do prefer the good old and trusty wall switch and it’s a good to have when you have guests, whom do not have access to the controller.

    Some of the “commercial” home automation products come with a separate remote control device which acts as a physical (but wireless) button which can be paired to the actual device.

    I was wondering if there was a way that I can create a paring mechanism whereby I can join two senor nodes together (wireless), and not have the need to go through a GW. So basically, a sensor node which can be controlled by a controller software(HA/OpenHab) and multiple button nodes.

    For example, consider the setup below:
    0_1496948474740_hw_setup.png

    Setup

    • Controller - Some controller which can be accessed by phone (Web based) eg HomeAssistant, OpenHab.
    • Serial GW - Connected to controller and manages the MySensors network.
    • Control Node - Connected with the GW (as normal) and is always on. This node has sensors and actuators which we want to control eg Relays
    • btnNode1 - This is a node with just a button. It is connected to Node1 (paired node), acting as a wireless button to control the main node.
    • btnNode2 - Same as btnNode1, but placed in different part of room.

    What I want to Do

    1. Setup a node which is connected to the the GW and has a node-id. This is the node we want to control. Call this Control Node
    2. Setup another node which will act as a Button Node and can connect to:
    • The GW, to get node-id and for pairing session.
    • The Control Node, to toggle the relay, switch, etc.

    Button Node

    • Normal Operation
    1. When a button is pressed, the node wakes up.
    2. Send a toggle command to the Control node with the secret-key.
    • Pairing Operation
    1. When the button is pushed for more than 3 secs, the node goes switches into paring mode.
    2. Connects to the GW and obtains a node-id (if it is a brand new node)
    3. Obtains a secret-key/network key from the GW (Security mechanism, something like a two-factor thing)
    4. Puts itself into receive mode.
    5. When it receives a pairing request it responds back to the pairing node with its node-id and the secret-key/network id.
    6. On confirmation, it stores the network-id and pairing nodes’s node-id to EEPROM.

    Control Node

    • Pairing Operation
    1. When a button is pressed for 3 secs, the node changes its state to pairing mode
    2. Sends a network wide request to locate the Button Node
    3. When the button node
    4. When it receives a request for pairing, it stores the Control node's Id into EEPROM

    Has anyone done anything like this? What options do I have in creating functionality for this using mySensors.

    Any help and advice will be greatly appreciated.


  • Mod

    I think you can replace the wall switches with push buttons and use low voltage cables and add a digital pin handling in code that toggles the lights. Mysensors in addition has node to node communication but it still needs the gateway to route the messages



  • @gohan said in pairing nodes with each other:

    I think you can replace the wall switches with push buttons and use low voltage cables and add a digital pin handling in code that toggles the lights. Mysensors in addition has node to node communication but it still needs the gateway to route the messages

    this is how I did it in my new apartment and I believe this is the right thing to do, it is much more reliable, do not require replacing batteries. But it maybe not doable if there is not enough cables in walls. If you have enoguh cables or you will rip the wall anyway I would recommend to do what @gohan said. Still the idea of direct connection and pairing is very interesting.


  • Hardware Contributor

    @gohan said in pairing nodes with each other:

    but it still needs the gateway to route the messages

    I'm not so sure about that ...
    As the receiver in the ceiling (controlling the light) will be always on, it can be set in repeater mode.
    So you can set node ID in "Control node" on the schema above, which is set as reapeater.
    Then in the button nodes, you set the id of the node, and also the parent which is set to the node id of the "control node".
    That way the "control node" will receive & process the messages from the button nodes.

    So let's imagine in control node :

    #define MY_REPEATER_FEATURE
    #define MY_NODE_ID 10
    

    And in button nodes :

    #define MY_PARENT_NODE_IS_STATIC
    #define MY_PARENT_NODE_ID 10  // id of "control node"
    #define MY_NODE_ID 11
    

    And of course when sending message to the "control node" from "button node" don't forget to use setDestination.


  • Hardware Contributor

    I realize after checking the configuration that in repeater mode you will always have a "sanity check" at regular interval checking connexion to the gateway, you can set a very long interval so it nearly never happens but the sanity check will eventually happen and I don't know what the "control node"/repeater behavior will be in that case. Meaning you still need a gateway.
    But you don't need to connect it to a controller if you hard code the ids in your nodes with MY_NODE_ID



  • Thanks Nca78.👍
    I used the MY_PARENT_NODE_ID but didnt use the MY_PARENT_NODE_IS_STATIC option and it works!

    The button node will be in sleep mode until it a button is pressed. So in that case, will it ever need to communicate to the GW?



  • You could do this dynamically, on the light nodes have a little button that sends out a message which is valid for say 60s, any other button/door node that would send a message within that time could become paired



  • @rfm69 actually, I did quite the same. If someone needs code exampe: https://forum.mysensors.org/topic/8716/direct-pairing-of-two-nodes-implementation/1



  • @monte Great, just looking now, looks good. Thanks for sharing that.


  • Hardware Contributor


Log in to reply
 

Suggested Topics

  • 4
  • 9
  • 9
  • 8
  • 20
  • 15

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts