Announcement

Collapse
No announcement yet.

Kitchen timer?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by fungun View Post
    I tried Stuart's approach and had to constantly run to the HS pc and click the script control box to continue or end the script. Hung everything up. Also the countdown always shows 0. Unless I am not setting it up right

    Thanks,
    Tim
    Tim,

    I think you have to go into Setup->Other Settings and set "Scripts cannot timeout" to "Yes" because the default is for a script to timeout in 30 seconds. I'm not sure about the countdown as I didn't look at the code that closely.


    Ken

    PS. I've got the basic timer functions written I just have to test them out and then I can post the code.
    "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

    Comment


      #17
      Originally posted by fungun View Post
      Isn't this a contadiction??
      By what you wrote, we should be using hs.WaitEvents instead of hs.WaitSecs. True?

      Tim
      hs.WaitSecs stops your script for the specified number of seconds while allowing HS to process events. Use this to delay for a timed duration.

      hs.WaitEvents stops your script briefly (not seconds) in order to process events. Use this to allow HS to process events while you're waiting in your script for something to happen - like waiting for voice a command.

      From the help:
      Code:
      [B][COLOR="Blue"]WaitEvents[/COLOR][/B]
      [COLOR="DarkRed"]Purpose[/COLOR]
      This function will suspend operation of the script and allow the HomeSeer
      application to run.  This is useful if you are waiting for a voice command 
      or some other action that HomeSeer needs to recognize.  If this function 
      is not called, a script will time out in 30 seconds and prompt the user to
      either wait longer or kill the script.  If this function is called within the 30 
      seconds, the script will not time out.
      While this makes it sound like your code is suspended for an extended period of time, it's actually very short and just long enough for HS to process it's events.

      This code demonstrates the difference:
      Code:
      ' Demo.vb
      ' hs.WaitSecs and hs.WaitEvents example
      ' 10May2009 mfisher
      
      Sub Main(parm as Object)
      	Dim Start1, Start2 as DateTime
      	Dim End1, End2 as Date
      	Dim Elapsed1, Elapsed2 as TimeSpan
      	Dim i as Integer
      
      	Start1 = Now()
      	hs.WaitSecs(2)
      	End1 = Now()
      
      	Start2 = Now()
      	For i = 1 to 10000
      		hs.WaitEvents
      	Next
      	End2 = Now()
      
      	Elapsed1 = End1 - Start1
      	Elapsed2 = End2 - Start2
      
      	MsgBox("hs.WaitSecs = " & Elapsed1.ToString & vbCrLf & "hs.WaitEvents = " & Elapsed2.ToString,,"Testing...")
      End Sub
      The results of this test on my system:
      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


        #18
        Tim,

        Here is the code and HSTouch screen I used to test the code.

        Setup:

        1. Create a device to hold the timer value. (I used t99 and called it "Kitchen Timer")

        2. Create a recurring event (1 minute) and have it run &hs.RunEx "timer.txt","DecrTimer","" (I called mine "Kitchen Timer Check") and leave it disabled by default.

        3. Create a manual event to be triggered when the timer is done. (I called mine "Kitchen Timer End") and have it do whatever you want to do when the timer is done.

        4. Put "timer.txt" in your scripts directory.

        5. Put "timer.xml" in your HSTouch directory and load up the screen with an HSTouch client.

        6. "+/-/Start/Stop/Clear" buttons all call subroutines in "timer.txt".

        7. The only thing that's a little kludgy is the handling of the timer value when you press "Start". Because "Start" enables the timer_check_event it causes it to run immediately and thus causes the timer count to decrement by one almost immediately after starting. My quick fix "kludge" for this is to add a minute to the timer value just before starting the timer which will immediately get decremented. The side effect of this is that the timer display may briefly flash the incremented value and then show the correct value.


        Play with this a bit and let me know what you think and if you want any added features.

        Ken

        PS. In addition to creating a "sleep" timer I'm looking at re-writing my sprinkler control code to use some of this code.
        Attached Files
        "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

        Comment


          #19
          I tried this out and I have to admit it's pretty slick and works perfectly. Thank you for uploading it. It's nice to see the old sharing spirit is still alive and well. Excellent job!

          A couple of comments if you don't mind in the spirit of making it better.

          I notice that it only goes to 60 minutes

          My wife asked if she has to push the button 60 times to get the hour.

          It would be great if it were able to go over 1 hour and also have some sort of button that increments more than one minute at a time as well. say a 15 minute button or some such thing.

          Either way again well done!
          Marty
          ------
          XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
          Playing with HS3 a bit but it's just play at this point.

          Comment


            #20
            Hi Marty,

            Glad you found it useful. Your wife and mine must be related. The first thing mine asked was why it could only go to 60 minutes. This one is easy to change. If you look at the top of the script there's a Constant called "max_timer_value" that is currently 60. Change it to whatever you want it to be. You may have to adjust the HSTouch display to make it a bit wider if you go to three digits.

            The second one isn't hard to add so I'll add "+15" and "-15" routines into timer.txt that can be called from buttons. My wife actually wants the buttons to be "+15" and "-1" so she would set 40 minutes by doing "+15", "+15", "+15", "-1", "-1", "-1", "-1", "-1". The script will have "+1", "-1", "+15", and "-15" routines so you can call them as you wish.

            Also, I just downloaded the tenscripting package so hopefully I'll be able to start learning to code in vb.net.

            Ken
            "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

            Comment


              #21
              Excellent news and a .net script would be just icing on the cake. Now I'll start adding the timer module into my normal HST screens. I'm not sure yet weather to just add it in the kitchen stuff or make it a pop-up over any screen for easy access in more than just the kitchen.

              Very excellent work!
              Marty
              ------
              XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
              Playing with HS3 a bit but it's just play at this point.

              Comment


                #22
                Hi Marty,

                Here's an updated script. After looking at the increment/decrement routines I decided that the easiest way to do it was to allow a parameter to be passed to IncrTimerValue and DecrTimerValue which is the amount you want to increment or decrement the timer value. If you don't pass a parameter or if you pass an invalid parameter (like a letter or symbol) then the default incr/decr amount will be "1". If you pass a parameter that puts the timer value out-of-range (< min_timer_value or > max_timer_value) then the timer value won't be changed.

                Some examples:

                &hs.RunEx "timer.txt","IncrTimerValue","" would increment by "1"
                &hs.RunEx "timer.txt","IncrTimerValue","A" would increment by "1"

                &hs.RunEx "timer.txt","IncrTimerValue","1" would increment by "1"
                &hs.RunEx "timer.txt","IncrTimerValue","2" would increment by "2"
                &hs.RunEx "timer.txt","IncrTimerValue","5" would increment by "5"
                &hs.RunEx "timer.txt","IncrTimerValue","15" would increment by "15"

                The same goes for the DecrTimerValue.

                Now you can add as many incr/decr buttons as you want to fit your application.

                Enjoy,
                Ken

                PS. I'll be converting this script to .NET as a part of my learning process so I'll post an update when I have that done and tested.
                Attached Files
                "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

                Comment


                  #23
                  Thank you very much, I'll play with it some. I figure if it meets your wife's requirements it'll meet mine too!
                  Marty
                  ------
                  XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                  Playing with HS3 a bit but it's just play at this point.

                  Comment


                    #24
                    Oops, something happened to version 2 of the script, It increments and decrements just fine but when you start the timer it adds one minute to the display that and does nothing else. It also gives this error in the log.

                    Running script, script run or compile error in file: timer.txt0: in line 0 More info: Exception from HRESULT: 0x800A01C2

                    The new available buttons work well too, the wife likes that much better, well except for that part about it not running. Progress is always so painful.
                    Marty
                    ------
                    XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                    Playing with HS3 a bit but it's just play at this point.

                    Comment


                      #25
                      Grrrr! I probably messed up the datatype when I added the parameter. I'll have a look and post an update in a little while.

                      Ken
                      "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

                      Comment


                        #26
                        no rush, she's not timing anything but me now anyway.
                        Marty
                        ------
                        XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                        Playing with HS3 a bit but it's just play at this point.

                        Comment


                          #27
                          I was playing with a screen and decided that a pop-up would work better than having to go to a specific screen. This she can pop up over any screen, set it and then close and forget it.
                          Attached Files
                          Marty
                          ------
                          XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                          Playing with HS3 a bit but it's just play at this point.

                          Comment


                            #28
                            OK Marty, Hopefully this code will work a bit better.

                            It appears that HS is trying pass data to the DecrTimer subroutine that's called to check and decrement the counter. I just added a parm called "data" to each subroutine (even if I don't use the data) and the error went away. I'll investigate further but for now this should get you going.

                            Ken
                            Attached Files
                            "if I have seen further [than others], it is by standing on the shoulders of giants." --Sir Isaac Newton (1675)

                            Comment


                              #29
                              Ah, that seems to be working, thanks for the quick fix!
                              Marty
                              ------
                              XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                              Playing with HS3 a bit but it's just play at this point.

                              Comment


                                #30
                                Perfect
                                Thank you very much!

                                Tim
                                FB Page - https://www.facebook.com/pages/Capt-Tim/209398425902188

                                HSTouch Layouts - https://www.facebook.com/media/set/?...5902188&type=3

                                Comment

                                Working...
                                X