Help Understanding MySensors Coding Syntax



  • Hey everyone,

    I was hoping to get some help understanding how to write sketches to implement MySensors around my home. I am in no way a coding person, but I love the MySensors network. I was hoping to learn quite a bit from looking through the sketches available on the website, but it seems that it has only confused me more. For example, it seems that some sketches use the gw.process command or different gw.begin commands, while some don't.

    Is there anywhere that explains each MySensors handle and syntax? Or how to understand different message or command types and how to code with them?

    Any help would be appreciated! Thank you!


  • Hero Member



  • Thank you for your response, but I have already read through the library API. It seems that there are even more commands being used within some sketches that aren't mentioned in there. For example, in the Relay Actuator sketch, Hek uses

    gw.begin(incomingMessage, AUTO, true);
    

    when the library API only mentions gw.begin().

    I want to learn more about the commands that can be used, like gw.___ or message.___

    Hope this makes sense. Thank you!


  • Hero Member

    If you scroll down on that page , at section 'Starting up the Library' there is a detailed description of gw.begin.



  • So, if I have a relay that I want to control via a button and my vera and I change the state with the button, how would I typically write that change to my Vera. Also, if I changed the state on my Vera, how would I read that change?

    Thank you for all your help!


  • Hero Member

    Did you check the http://www.mysensors.org/build/relay#relaywithbuttonactuator-example ? It works out-of-the-box exactly like you want...



  • Yes, I've looked at that, and for that example, it would work great. But I guess I am just trying to understand the coding side as much as I can, in case I want to improve/add features for other sensors.

    One of my projects that I am trying to do is monitor my garage. I will have a limit switch that is pressed by the door carriage when the garage door is open and another limit switch that will be pressed when the garage door is closed So, based on which button is HIGH or LOW, I can determine if the garage door is open or closed. Then I can trigger a relay connected to the button to open or close the garage door.

    Let me know if I am getting in way over my head or not as someone who has very little coding experience.


  • Hero Member

    My suggestion is to read carefully that page, from the 'Ok! So, what is happening here?' down ;-)



  • Ok, I will do that!

    But, don't be surprised if I'm back here on the forum later! :)



  • I guess one more nooby questions would be, what exactly is a child sensor? I understand that each sensor node is considered a sensor, but is each sensor or relay or whatever connected to that node a child sensor?

    So, a node that has 2 buttons and a relay has 3 child sensors?

    Thank you.


  • Admin

    @BenGor said:

    So, a node that has 2 buttons and a relay has 3 child sensors?

    Yes



  • What is the difference between a child sensor and an actuator? I have heard both used, but I am not sure if they mean the same thing or not.

    Thanks!


  • Admin

    An actuator is generally some that you control like relay/light/lock etc.
    Sensors usually take measurement of the environment.

    Both types are "child sensors".


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.