Announcement

Collapse
No announcement yet.

Sleep function in Script

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

    Sleep function in Script

    I have a script I am working on and I need to issue a sleep command. I need to script to wait 100 milliseconds for a command to process before it continues (it is a loop of information I am sending to a com port, GC-100 to be exact). I have seen the hs.waitsecs function but it only seams to want to wait for whole seconds and I need the script to wait less than that. wscript shell has a sleep command but I can't seam to get homeseer to use the reference. I have not been scripting very long with HS so I may be missing something basic here. Any Help would be appreciated.

    Thanks,
    Scott

    #2
    Is it a .net script if so, system.threading.thread.sleep(millseconds)
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment


      #3
      From the HS help file under scripting:
      WaitMS

      Purpose
      This function waits the number of specified milliseconds. The application still processes events, but will sleep so the script does not use all the CPU.
      Parameters
      Parameter: Millisecs
      Type: Integer
      Description: The number of milliseconds to wait.
      Returns
      None.
      Examples
      ' wait 2 seconds
      hsp.WaitMS 2000
      Best regards,
      -Mark-

      If you're not out on the edge, you're taking up too much room!
      Interested in 3D maps? Check out my company site: Solid Terrain Modeling

      Comment


        #4
        Thanks. Thats what I needed.

        Comment


          #5
          I think you have to use system.threading.thread.sleep(millseconds), as the hsp wait only works if you have hs phone.

          I went down this route, and ended up needing to use system.threading.thread.sleep(millseconds) ... but now I've changed my scripts to not need those, they are all event driven now...

          --Dan
          Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

          Comment


            #6
            You can also use decimals within the hs.waitsecs scripting command i.e.

            hs.waitsecs 0.1

            This would provide 100mS delay.
            Jon

            Comment


              #7
              Jon,

              I wish I had tried that ages ago..that's smart!

              I just figured it would only take in INTs...being a C and ASM guy...I didn't remember VB is kind of non-denominational regarding variables...

              --Dan
              Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

              Comment


                #8
                Originally posted by drozwood90 View Post
                Jon,

                I wish I had tried that ages ago..that's smart!

                I just figured it would only take in INTs...being a C and ASM guy...I didn't remember VB is kind of non-denominational regarding variables...

                --Dan
                It used to be Integer only but was changed in the 2.1 development days.
                Jon

                Comment


                  #9
                  hs.waitsecs 0.1 worked great. Thanks

                  Comment

                  Working...
                  X