www.homeseer.com    
 

Go Back   HomeSeer Message Board > Legacy Software & Plug-ins > Legacy Software (Older Versions) > HSTouch™

HSTouch™ Discussions regarding HSTouch touchscreen software for HomeSeer

Reply
 
Thread Tools Display Modes
  #1  
Old May 8th, 2009, 03:52 PM
fungun's Avatar
fungun fungun is offline
Seer Master
 
Join Date: Apr 2004
Location: Iowa
Posts: 1,262
Kitchen timer?

Does anyone have a kitchen type timer script?
I looked at the alarm clock stuff, but it triggers on the next day, and I can't figure out how to make it trigger the same day.
One that when you push a button in HST it would increment the timer by 1 min, then push "Start" and when it's done make an announcement. ie-"Your cake is done"

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

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

“No, I’m from Iowa. I only work in outer space.” – Captain Kirk
Reply With Quote
  #2  
Old May 8th, 2009, 07:05 PM
kenm kenm is offline
Seer Deluxe
 
Join Date: Jan 2001
Location: San Jose, CA
Posts: 497
Hey fungun,

This sounds a lot like the "sleep timer" my wife has been asking me to create. What kind of parameters do I need to consider?

What's the max timer value? Could I assume less than 12 hours? Would the timing ever cross over midnight? Would you want separate hour and minute incr/decr buttons? Do you need to see the time counting down while the timer is running? If yes, would a minute-by-minute display be good enough or would you want to see the seconds displayed as well? Would you want to be able to stop/start/restart/cancel the timer?

I'll start working on the base code and I can add the other features in if needed.

Also, it's probably not going to be .NET since I don't have enough experience with that yet.

Ken
Reply With Quote
  #3  
Old May 8th, 2009, 07:29 PM
fungun's Avatar
fungun fungun is offline
Seer Master
 
Join Date: Apr 2004
Location: Iowa
Posts: 1,262
Quote:
Originally Posted by kenm View Post
Hey fungun,

This sounds a lot like the "sleep timer" my wife has been asking me to create. What kind of parameters do I need to consider?

What's the max timer value? 1 hour would be good Could I assume less than 12 hours? Would the timing ever cross over midnight?I wouldn't think so, unless your up making a midnight snack of cookies LOL Would you want separate hour and minute incr/decr buttons?I think just mins would be good enough. Do you need to see the time counting down while the timer is running?Yes If yes, would a minute-by-minute display be good enough or would you want to see the seconds displayed as well?either would be ok Would you want to be able to stop/start/restart/cancel the timer?Yes to all.

I'll start working on the base code and I can add the other features in if needed.

Also, it's probably not going to be .NET since I don't have enough experience with that yet.

Ken
Very cool thank you much.
Tim
Reply With Quote
  #4  
Old May 8th, 2009, 09:43 PM
Stuart Stuart is offline
Seer Master
 
Join Date: Mar 2002
Location: Massachusetts
Posts: 843
I created this kitchen countdown timer. kind of crude.(but it works)
You can only enter the total minutes then the enter button. NO stop at this time.
You can hit the clear and change the minutes before you hit enter.
It allows you to enter the timer in minutes and then it counts down minute by minute.
you need to create 2 virtual devices and the 2 small scripts (below) in the Hs script directory.
I used t10 and t67.
Also the timer.xml file is included.

Stuart

Timerkeystrokes.txt

Sub Main
dim digit
digit = hs.devicevalue ("t66")
digit = (digit * 10)+ hs.devicevalue ("t67")
hs.setdevicevalue "t66", digit
End Sub



Timerbutton.txt

sub main()
dim maxsecs,totalmins,delaysecs
totalmins = hs.devicevalue("T10")
maxsecs = hs.devicevalue("T10")
delaysecs= 60 * totalmins
hs.delaytrigger delaysecs,"completed message"
if totalmins = 0 then
exit sub
end if
for maxsecs = totalmins to 1 step -1
hs.setdevicevalue("T10"),maxsecs
hs.waitsecs 60
next

hs.speak "your time has completed, your time is up."
end sub
Attached Files
File Type: xml timer.xml (103.9 KB, 60 views)
Reply With Quote
  #5  
Old May 8th, 2009, 10:27 PM
fungun's Avatar
fungun fungun is offline
Seer Master
 
Join Date: Apr 2004
Location: Iowa
Posts: 1,262
Quote:
hs.setdevicevalue("T10"),maxsecs
hs.waitsecs 60
next
Does the waitsecs 60 bog things down any?
I was under the assumtion you shopuldn't go longer than 30.
Thanks,
Tim
Reply With Quote
  #6  
Old May 8th, 2009, 11:54 PM
kenm kenm is offline
Seer Deluxe
 
Join Date: Jan 2001
Location: San Jose, CA
Posts: 497
Stuart,

Do you run that code regularly? I would think it would be hard for your system to get much done while it was running. With an "hs.waitsecs 60" in a "for" loop the only time your system would be able to get anything done would be while it was decrementing the loop counter and updating t10.

My approach is to setup a recurring event that fires off once a minute, checks the status of the timer, and reacts if the timer has reached zero. I would then enable or disable the recurring timer check event depending on whether or not the timer was running. I'm going to steal some code from my sprinkler control script so I should have something to post sometime tomorrow afternoon unless the weather is really nice...

Ken
Reply With Quote
  #7  
Old May 9th, 2009, 08:59 AM
Krumpy's Avatar
Krumpy Krumpy is offline
Seer Master
 
Join Date: Apr 2001
Location: Minneapolis, MN
Posts: 1,209
I would recommend the following logic:

1.) Create a drop down element with predefined the options (see the "Values" area in the editor - lower right).

2.) The script takes the requested time and creates a new event based on the desired new time.

3.) The event will trigger and execute the requested step.

This architecture is sound without extra delay and processing.
Reply With Quote
  #8  
Old May 9th, 2009, 10:36 AM
Stuart Stuart is offline
Seer Master
 
Join Date: Mar 2002
Location: Massachusetts
Posts: 843
The wait didnt seem to impact system performance. I guess I've been hoping that Hs had a countdown timer built in. It would make it a lot easier to display this then to come up with some round about way to make it work. If anyone makes anything better, please post it as I would be interested in it.
Stuart
Reply With Quote
  #9  
Old May 9th, 2009, 11:27 AM
Krumpy's Avatar
Krumpy Krumpy is offline
Seer Master
 
Join Date: Apr 2001
Location: Minneapolis, MN
Posts: 1,209
My recommendation is not round about. It's architecturally sound and does not need extra processing as a wait loop would. Ugly.
Reply With Quote
  #10  
Old May 9th, 2009, 11:48 AM
mfisher's Avatar
mfisher mfisher is offline
Seer Master
 
Join Date: Jan 2001
Location: Ventura County, CA, USA
Posts: 1,280
Quote:
Originally Posted by fungun View Post
Does the waitsecs 60 bog things down any?
I was under the assumtion you shopuldn't go longer than 30.
Thanks,
Tim
His system will run just fine using hs.WaitSecs - this is exactly what hs.WaitSecs was provided for!
From the scripting help:
Quote:
WaitSecs
Purpose
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.
If you need to actually do something in a loop while waiting then use hs.WaitEvents so that HS doesn't get blocked by your script.

Sometimes I use the event architecture that Krumpy outlined for timer-based things and other times I just use hs.WaitSecs. Both methods work fine.
__________________
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
Reply With Quote
  #11  
Old May 9th, 2009, 11:58 AM
Stuart Stuart is offline
Seer Master
 
Join Date: Mar 2002
Location: Massachusetts
Posts: 843
Krumpy,
I'm not referring to your approach as round about. I was referring to mine. Usually when I can figure out something and code it, I'm happy. But I'm always willing to learn.
Stuart
Reply With Quote
  #12  
Old May 9th, 2009, 12:14 PM
kenm kenm is offline
Seer Deluxe
 
Join Date: Jan 2001
Location: San Jose, CA
Posts: 497
Quote:
Originally Posted by Krumpy View Post
I would recommend the following logic:

1.) Create a drop down element with predefined the options (see the "Values" area in the editor - lower right).

2.) The script takes the requested time and creates a new event based on the desired new time.

3.) The event will trigger and execute the requested step.

This architecture is sound without extra delay and processing.
Hi Krumpy,

As it turns out that's exactly the approach I took with my sprinkler control script. I hadn't looked at that script for a couple of years and when I went back to it to grab the code for the kitchen timer I realized I was setting events in the future and having them trigger.

This approach would work fine from a functional standpoint but one of the goals is to provide a countdown display of the timer. If there was a "Time until Trigger" function that allowed you to get the time between current time and the trigger of a timed event that would work but the only other way I can figure out how to do it is to run a recurring event and decrement the timer value and use that as the data displayed on the HST screen.

Please let me know if you can think of a way to display the "time remaining" using the timed event approach.

Ken
Reply With Quote
  #13  
Old May 9th, 2009, 12:38 PM
kenm kenm is offline
Seer Deluxe
 
Join Date: Jan 2001
Location: San Jose, CA
Posts: 497
Quote:
Originally Posted by mfisher View Post
His system will run just fine using hs.WaitSecs - this is exactly what hs.WaitSecs was provided for!
From the scripting help:
If you need to actually do something in a loop while waiting then use hs.WaitEvents so that HS doesn't get blocked by your script.

Sometimes I use the event architecture that Krumpy outlined for timer-based things and other times I just use hs.WaitSecs. Both methods work fine.
Hi Mark,

Thanks for pointing this out. I'll have to go back and investigate these functions further when I get a few minutes. In the past (1.x days) scripts and HS ran in the same thread and it was my understanding that nothing else happened while a script was in an hs.Waitsecs. I know that the architecture of HS has changed with 2.x but I still thought that scripts not written in vb.net ran in a single thread which meant that an hs.Waitsecs would block any non-vb.net script from running while it was waiting.

Thanks again for the clarification,
Ken
Reply With Quote
  #14  
Old May 9th, 2009, 02:00 PM
fungun's Avatar
fungun fungun is offline
Seer Master
 
Join Date: Apr 2004
Location: Iowa
Posts: 1,262
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
Reply With Quote
  #15  
Old May 9th, 2009, 02:03 PM
fungun's Avatar
fungun fungun is offline
Seer Master
 
Join Date: Apr 2004
Location: Iowa
Posts: 1,262
Quote:
Originally Posted by mfisher
His system will run just fine using hs.WaitSecs - this is exactly what hs.WaitSecs was provided for!
From the scripting help:
If you need to actually do something in a loop while waiting then use hs.WaitEvents so that HS doesn't get blocked by your script.

Sometimes I use the event architecture that Krumpy outlined for timer-based things and other times I just use hs.WaitSecs. Both methods work fine.
Isn't this a contadiction??
By what you wrote, we should be using hs.WaitEvents instead of hs.WaitSecs. True?

Tim
Reply With Quote
  #16  
Old May 9th, 2009, 03:45 PM
kenm kenm is offline
Seer Deluxe
 
Join Date: Jan 2001
Location: San Jose, CA
Posts: 497
Quote:
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.
Reply With Quote
  #17  
Old May 10th, 2009, 01:30 PM
mfisher's Avatar
mfisher mfisher is offline
Seer Master
 
Join Date: Jan 2001
Location: Ventura County, CA, USA
Posts: 1,280
Quote:
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:
WaitEvents
Purpose
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 Images
 
Reply With Quote
  #18  
Old May 10th, 2009, 04:14 PM
kenm kenm is offline
Seer Deluxe
 
Join Date: Jan 2001
Location: San Jose, CA
Posts: 497
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
File Type: txt timer.txt (3.4 KB, 98 views)
File Type: xml timer.xml (24.1 KB, 65 views)
Reply With Quote
  #19  
Old May 11th, 2009, 10:57 AM
nightwalker nightwalker is offline
OverSeer
 
Join Date: Dec 2004
Location: Thorndale, PA.
Posts: 3,873
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.
Reply With Quote
  #20  
Old May 11th, 2009, 01:12 PM
kenm kenm is offline
Seer Deluxe
 
Join Date: Jan 2001
Location: San Jose, CA
Posts: 497
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
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 11:49 PM.


Copyright HomeSeer Technologies, LLC