• header.categories
    • header.recent
    • header.tags
    • header.popular
    • register
    • login

    Programmatically reboot a node

    scheduled pinned locked moved Developers Zone
    15 posts 4 posters 2.2k views 1 watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • skywatchS offline
      skywatch @Daniele
      global:last-edited-by, skywatch

      @Daniele That is the opposite of what I have - here my GW is 'up' in mycontroller but node 0 is 'down' and yet it is working perfectly with myc and all nodes!

      If this is a random thing I would suggest triple checking all connections individually to ensure they are tight and no movement at all can happen. I took out a DC barrel connector and replaced it and things got a lot better from just that one change.

      I also put the arduino watchdog on the GW node as another way to recover from any 'hangs'.

      I added the previously posted operations as another way to tackle problems with the gw, but not sure how to tell if it is working as expected!

      Finally I upgraded the pi from stretch to buster and fully updated everything.

      Since then I have had 7-8 weeks without any issues (previously 1-2 weeks was about all I could hope for).

      I still have a ups on my to do list. That will happen soon I hope.

      jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
      • jkandasaJ offline
        jkandasa @skywatch
        global:last-edited-by,

        @Daniele some example to send the payload.
        Note: I didn't test this in practice. Please let me know if you face an issue.

        var myImports = new JavaImporter(java.lang, java.util, org.mycontroller.standalone.utils.McUtils);
        
        with(myImports) {
          // get your node/sensor/variable via uuid
          var mySensorVariable = mcApi.uidTag().getByUid("abc").getResource();
          
          // set new value
          mySensorVariable.value  = 2
          
          // send paylaod
          mcApi.sensor().sendPayload(mySensorVariable);
        }
        
        one-reply-to-this-post last-reply-time reply quote 0
        • D offline
          Daniele
          global:last-edited-by,

          @jkandasa thank you for the example, but how can I leverage it to reboot a node?
          I mean, as far as I understand the reboot payload is not a regular sensor that I can map through a uid.

          jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
          • jkandasaJ offline
            jkandasa @Daniele
            global:last-edited-by,

            @Daniele I have modified the script and here is your request,

            var myImports = new JavaImporter(java.lang, java.util, org.mycontroller.standalone.utils.McUtils, org.mycontroller.standalone.message.IMessage);
            
            with(myImports) {
              // get your gateway via uuid
              var myGateway = mcApi.uidTag().getByUid("my-test-gateway").getResource();
              
              // Import message type
              var Message = Java.type("org.mycontroller.standalone.message.IMessage")
              
              // create message object
              var message = Message.getInstance()
              
              // update gateway id.
              message.setGatewayId(myGateway.id)
              
              // update message type
              message.setType("Internal")
              
              // update message sub type
              message.setSubType("Reboot")
              
              // set sensor id as 255 for node message
              message.setSensorId("255")
              
              // set acknowledgement status
              message.setAck(0)
              
              // set empty payload, but json conversion throws excepton for empty, so set it as "0"
              message.setPayload("0")
              
              // update your node EUI
              message.setNodeEui(21)
              
              // send Raw Message
              mcApi.sensor().sendRawMessage(message);
            }
            
            
            one-reply-to-this-post last-reply-time reply quote 0
            • D offline
              Daniele
              global:last-edited-by,

              Amazing, thank you!

              one-reply-to-this-post last-reply-time reply quote 0
              • R offline
                Radi-M
                global:last-edited-by, Radi-M

                Hi all,

                I have a similar problem with Raspberry PI and MySensors Serial Node with NRF radio.
                After a random time the node service on RPI stops working:

                c1398a70-e1c5-4de6-8652-bff918bba715-image.png

                To restart the service I need to run 'sudo systemctl restart mysgw.service'.
                Currently, I have scheduled a script to do that, which decrease problem frequency, however, it still happens.

                Q: Is there a way to run this console command from the MyController script when the selected node is down?

                jkandasa it would be great if you can provide an example.

                Many Thanks.

                jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
                • jkandasaJ offline
                  jkandasa @Radi-M
                  global:last-edited-by, jkandasa

                  @Radi-M can you try this and let me know,

                  var myImports = new JavaImporter(java.lang, java.util);
                  
                  with(myImports) {
                    // your command to execute
                    var command = "sudo systemctl restart mysgw.service";
                    
                    // execute your command
                    mcApi.osCommandExecuter().executeLinuxCommand(command);
                  }
                  
                  one-reply-to-this-post last-reply-time reply quote 0
                  • R offline
                    Radi-M
                    global:last-edited-by,

                    Hi,

                    It works.

                    Many thanks.
                    Radi-M

                    one-reply-to-this-post last-reply-time reply quote 1
                    • skywatchS offline
                      skywatch
                      global:last-edited-by,

                      Probably a stupid question, but will this reboot all mys GW attached to the pi?

                      jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
                      • jkandasaJ offline
                        jkandasa @skywatch
                        global:last-edited-by,

                        Probably a stupid question, but will this reboot all mys GW attached to the pi?

                        @skywatch Yes, it will. if your mys GW powered by RPI

                        one-reply-to-this-post last-reply-time reply quote 0
                        • first-post
                          last-post

                        0

                        online

                        644

                        users

                        532

                        topics

                        3.4k

                        posts
                        Copyright © 2015-2025 MyController.org | Contributors | Localization