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.
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.
The script adjusts variables in my home automation app, Indigo, which knows of the variables.
For example ws_Temp_HotTub holds the hot tub temperature, ClockTimeAmPm holds the current time in a standard format. ( 8:46 pm), and HotTubReadyTime holds the time the same way.
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
The above script returns the error “Can’t get date”.
Try keeping the date stuff outside application ‘tell’ statements.
tell application "IndigoServer"
set theTemp to (value of variable "wsTemp_HotTub" as integer)
set timeNow to (value of variable "ClockTimeAmPm")
end tell
set theTime to ((100 - theTemp) / 10) * hours
set readyTime to time string of ((date timeNow) + theTime)
tell application "IndigoServer" to set the value of variable "HotTubReadyTime" to readyTime
Also, since you’ve now made 89 posts to MacScripter, try using its [applescript][/applescript] tags when posting code. There’s a button which inserts them around selected text in the posting window on the posting page or you can write them in yourself.
Thanks kel1. I should have explained that. Written date specifiers (‘date’ + text or text variable) often don’t work in application ‘tell’ statements because they conflict with a similar keyword or token belonging to the applications themselves.