Announcement

Collapse
No announcement yet.

wait in script for 30 minutes

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

    wait in script for 30 minutes

    Ok, next one, hopefully real simple this time.

    I want a script to simply:

    - do something
    - wait 30 minutes
    - do something else
    - end

    Some reading has lead me to WaitEvents, but it looks like the idea behind that is to wait for a specific event to happen, rather than just sit tight for a specified amount of time and let other things run.

    Suggestions?

    #2
    Hi Paul,

    There's the hs.WaitSecs function that'll do what you need. Another option is to have the script create a delayed event that'll run 30 minutes later. If you need to pass variables, you can use devices (values or strings) or an INI file to do so. What are you trying to accomplish?

    Cheers
    Al
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      Just writing a script that checks the current setpoint of a thermostat, bumps it up a bit for 30 minutes, then bumps it back down again. If hs.WaitSecs will do it without causing grief then cool - I had just read that having scripts run long without using something like WaitEvents would cause other things not to run due to holding the thread. Perhaps it's no longer an issue?

      Comment


        #4
        Hi Paul,

        You can likely do what you need with events. There are triggers and actions for the z-wave thermostats that I think will do what you need. I personally don't like scripts that "hang-around" that long. One of the actions in the event can be to create a delayed event that changes the setpoint back.

        For reference, the hs.waitsecs command does the following:
        This function waits a number of seconds. This will also allow other operations to take place in HomeSeer by giving up the CPU. It will also keep a script from timing out. The function will not return until the number of seconds have elapsed.
        Cheers
        Al
        HS 4.2.8.0: 2134 Devices 1252 Events
        Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

        Comment


          #5
          Yeah, I know what you mean. I would happily do it with events if I knew it would do what I need. I do have an event to do this - the problem is the determining of the current temp. It's easy with an event to say:

          - set temperature to xx
          - wait 30 min
          - set temperature to yy

          But What I really want is:

          - set temperature to (current temp + 2)
          - wait 30 min
          - set temperature to (previous current temp)

          It's the logic of bumping the current temp from whatever it currently is that I couldn't do from within events. OR.... if I can I didn't figure that out then I'm willing to be corrected...

          Comment


            #6
            Gotcha. How do you intend to trigger the running of the script? Will it be based on pressing a button on a remote or something like that? If I were to setup something similar for my system, I think this is how I would do it:

            Have an event that's triggered by the remote press. The event would do the following:
            - run a script that would get the current set-point, increase it by 2 degrees
            - create a delayed event that would run a different script that would get the current setpoint and decrease it by 2 degrees

            You could actually use the same script for both options by passing one or more values to it. That way you can use the same script for multiple scenarios. The event action would look something like this:

            Main Event:
            Code:
            Run script: temp.txt("2")
            Delayed Event:
            Code:
            Run script: temp.txt("-2")
            Cheers
            Al
            HS 4.2.8.0: 2134 Devices 1252 Events
            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

            Comment


              #7
              When HomeSeer runs your script, it halts almost everything it is doing and transfers control to your script. If your script hangs out for an extended period (more than a second or two) then the performance and responsiveness of HS will be adversely effected. This was a serious problem in the early days of HS when a script would accidentally enter an endless loop (or some other erroneous condition) and cause HS to lockup completely, and why protections were implemented in HS to keep scripts from running longer than 30 seconds.

              Both hs.WaitSecs() and hs.WaitEvents() will allow HomeSeer to handle its urgent tasks while keeping your script alive. However, while it is possible to hang out in a script for longer than what is required to get the job done, it is not a recommended practice.

              In this particular case, you can easily create a single HS event to accomplish what you want to do, as long as you are using a 'stat that is supported in HS. If not you can try the method outlined in the following post:
              Attached Files
              Last edited by mfisher; November 24, 2012, 11:29 AM.
              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


                #8
                Here is how you might combine the use of events, delayed events and a script.

                Create the script with subroutines to handle increasing and decreasing the setpoint:
                Code:
                Main()
                  ' HS requires a Main sub, whether you use it or not.
                End Sub
                
                Sub Increase_SP(Params)
                  'commands to increase the thermostat setpoint by value in Params  
                End Sub
                
                Sub Decrease_SP(Params)
                  'commands to decrease the thermostat setpoint by value in Params  
                End Sub
                Note that the value passed in Params is a string.

                Create an event like this to trigger the appropriate subroutines within your script:
                Attached Files
                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


                  #9
                  Sparkman and mfisher, indeed you're right - even if I use a script to increase and decrease the setpoint, I could totally do the way you suggest - trigger the script to change the setpoint, but use the event to cause the 30 min delay. I think you're right, that's the way to go.

                  mfisher, my thermostat is a z-wave 2 Gig CT-30. From within the event I see options to set the setpoint to a specific value, but not to increase/decrease. Is it possible I'm missing something? I'm assuming that I just need to create the script for changing the setpoint (I like the plan to pass the change variable to the script)...

                  Comment


                    #10
                    I personally do not like to set waits that long. I prefer to schedule events.

                    Takes a bit to get the structure laid out, but once it's there, the events just take care of themselves.

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

                    Working...
                    X