Announcement

Collapse

Contacting HomeSeer This Week

HomeSeer is open and operational this week. All orders are being processed and shipped as usual. However, some staff are working from home. If you need to contact HomeSeer for support or customer service, please use our Email or Chat options. https://homeseer.com/contact-us/
See more
See less

Terminating a Script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Terminating a Script

    Forgive me if this is standard knowledge, but is there a way to cancel a running script without rebooting HS?

    I started a script last night that was expecting a voice command and wouldn't time out until it saw one. Unfortunately, I didn't have a microphone attached to my server that was running the script so the script was running indefinately. Looked through script help and didnt see a method.

    Any easy solutions?

  • #2
    Nope - the only way is to set the configuration option to timeout scripts after xx minutes (I think it is 2 minutes by default) and then when you have scripts that run longer, just make sure there is an hs.WaitEvents call in there to reset the timer.

    HS 2 will give us full control and we'll be able to allow the termination of scripts.
    Regards,

    Rick Tinker (a.k.a. "Tink")

    Comment


    • #3
      Launch your script using mcsMovement then you have full control of run status and ability to abort it if desired.

      Comment


      • #4
        Thanx guys.
        I will look into mcsMovement to see if I can figure that out.

        Looking forward to HS2.0!

        Comment


        • #5
          How do I cancel a script in 2.1?

          I want to be able to terminate a script mid-stream, upon the occurence of an event (subject to certain conditions). Could someone point me to some sample code that does this? Thanks.

          Comment


          • #6
            Here's a prototype

            sub main()

            While your process is working

            if process is complete
            exit sub
            end if
            loop
            -Rupp
            sigpic

            Comment


            • #7
              I'm sorry

              I need to be clearer. Supposed an event has triggered a script, and it is now running. Let's say it normally takes about a half hour to run. (Specifically, I'm envisioning a dawn simulation routine.)

              Now, after 10 minutes or so, another event occurs, and I want that event to kill the execution of that script. How would I do that?

              Thanks again.

              Comment


              • #8
                You can't kill one script from another if HomeSeer launched the scripts. You would need to use Michael's suggestion. This would make a good feature request though.
                -Rupp
                sigpic

                Comment


                • #9
                  Thanks - one other thought

                  Is it possible to change the value of a "global" variable (flag), so that if the script is running in a loop, it can test on the flag and break out of the loop if the flag changes?

                  That would allow me to do what I need to do. Could a virtual X-10 device be used as a flag, for example?

                  Comment


                  • #10
                    Sure that should work just fine.
                    -Rupp
                    sigpic

                    Comment


                    • #11
                      I thought you could kill a script in 2.x. For example I have a demo script that sometimes I run to show guests what my system can do and many times I just want to kill it at some point cause we've "Heard and seen enough".

                      Comment


                      • #12
                        I'm using a flag - works okay

                        For now, I've used a virtual X-10 device as the flag, and within a loop in the script, I'm using hs.IsOn() on that device to test whether to continue the script or to terminate it (exit sub). Seems to work pretty well.

                        Comment

                        Working...
                        X