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. Development
  3. Help Understanding MySensors Coding Syntax

Help Understanding MySensors Coding Syntax

Scheduled Pinned Locked Moved Development
13 Posts 3 Posters 4.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • rvendrameR Offline
      rvendrameR Offline
      rvendrame
      Hero Member
      wrote on last edited by
      #2

      Maybe this may help somehow.

      http://www.mysensors.org/download/sensor_api_15

      Home Assistant / Vera Plus UI7
      ESP8266 GW + mySensors 2.3.2
      Alexa / Google Home

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0
        • rvendrameR Offline
          rvendrameR Offline
          rvendrame
          Hero Member
          wrote on last edited by
          #4

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

          Home Assistant / Vera Plus UI7
          ESP8266 GW + mySensors 2.3.2
          Alexa / Google Home

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            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!

            1 Reply Last reply
            0
            • rvendrameR Offline
              rvendrameR Offline
              rvendrame
              Hero Member
              wrote on last edited by
              #6

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

              Home Assistant / Vera Plus UI7
              ESP8266 GW + mySensors 2.3.2
              Alexa / Google Home

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • rvendrameR Offline
                  rvendrameR Offline
                  rvendrame
                  Hero Member
                  wrote on last edited by
                  #8

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

                  Home Assistant / Vera Plus UI7
                  ESP8266 GW + mySensors 2.3.2
                  Alexa / Google Home

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    Ok, I will do that!

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

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #10

                      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.

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

                        @BenGor said:

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

                        Yes

                        1 Reply Last reply
                        0
                        • ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #12

                          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!

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

                            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".

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


                            25

                            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