Time Adjustment Calculation

Posted on
Mon May 27, 2013 10:09 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Time Adjustment Calculation

Hey,

I thought this may be simple but with my limited knowledge of AS it has me stumped.

What I'm after is to calculate the time our hot tub will arrive at 100 degrees
based on it's current temperature. It heats at a rate of 10 degrees an hour...slow I know.

Code: Select all
tell application "IndigoServer"
   
   set theTemp to (value of variable "wsTemp_HotTub" as integer)
   set theTime to (100 - theTemp)
   set theTime to (theTime * 6)
   set the value of variable "HotTubReadyTime" to time string of ((date (value of variable "ClockTimeAmPm")) + (theTime * minutes))
   
end tell


So basically, I think, I just need to subtract the hot tub temperature from 100, then multiply by 6 and add that as minutes
to the current time and set the HotTubReadyTime variable to that.

Any help greatly appreciated!

Thanks,

Carl

Posted on
Tue May 28, 2013 9:20 am
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Time Adjustment Calculation

The script works for me when I substitute:

Code: Select all
date (value of variable "ClockTimeAmPm")


with:

Code: Select all
current date


Are you sure that whatever you have ClockTimeAmPm set to is being coerced correctly into a date? And is there any reason you're using a time stored in a variable rather than just using current date?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue May 28, 2013 11:45 am
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Time Adjustment Calculation

Could use current date in place of ClockTimeAmPm but I still can't
get it to run with the substitution you suggested.

Error: Can't make "11:45 am" into type number.

No doubt it's just a syntax error on my part.

Thanks,

Carl

Posted on
Tue May 28, 2013 12:04 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Time Adjustment Calculation

That indicates that you didn't get the change in and it's still trying to make "11:45 am" from somewhere (the variable?) into a date. Paste in your script.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue May 28, 2013 2:20 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Time Adjustment Calculation

Here it is.

Code: Select all
tell application "IndigoServer"
   
   set theTemp to (value of variable "wsTemp_HotTub" as integer)
   set theTime to (100 - theTemp)
   set theTime to (theTime * 6)
   set the value of variable "HotTubReadyTime" to (time string of (current date)) + (theTime * minutes)
   
end tell



Thanks for looking into it.

Carl

Posted on
Tue May 28, 2013 5:05 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Time Adjustment Calculation

Parenthesis problem - you're converting current date into a string before adding the minutes. You should do that after:

Code: Select all
tell application "IndigoServer"
   
   set theTemp to (value of variable "wsTemp_HotTub" as integer)
   set theTime to (100 - theTemp)
   set theTime to (theTime * 6)
   set the value of variable "HotTubReadyTime" to time string of (current date + (theTime * minutes))
   
end tell

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue May 28, 2013 6:48 pm
ckeyes888 offline
Posts: 2425
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Time Adjustment Calculation

Excellent...thanks a bunch. Really need to find the time to learn Python.

Carl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 29 guests