View unanswered posts | View active topics It is currently Fri May 24, 2013 1:11 pm



Reply to topic  [ 3 posts ] 
 Get current hour, set a variable accordingly 
Author Message

Joined: May 11, 2011
Posts: 12
Post Get current hour, set a variable accordingly
Man, I hate AppleScript! It's like almost programming, but note quite ;)

I put the following together to check the current hour ever few minutes, then set a variable called "rampLightsPartially" based on the result of some operations.

Why? I have my bedroom lighting starting brightness set to 25%, based on the above variable I can increase the brightness using a trigger to 100%. This is so I don't blind myself between 1:00 and 4:00



Code: Select all
property hour : ""

set hour to (do shell script "date +%H") as integer

tell application "IndigoServer"
   -- set the current hour
   if not (variable "currentHour" exists) then
      make new variable with properties {name:"currentHour", value:""}
   end if
   set the value of variable "currentHour" to hour as integer
   
   
   -- set "rampLightsPartially"
   if not (variable "rampLightsPartially" exists) then
      make new variable with properties {name:"rampLightsPartially", value:false}
   end if
   
   if (hour > 1 and hour < 4) then
      set the value of variable "rampLightsPartially" to true
   else
      set the value of variable "rampLightsPartially" to false
   end if
end tell


Wed May 11, 2011 7:50 pm
Profile
Site Admin
User avatar

Joined: Jan 27, 2003
Posts: 11698
Location: Texas
Post Re: Get current hour, set a variable accordingly
You could do this without AppleScript by creating 2 Time/Date Actions that execute Modify Variable Value actions.

_________________
Image


Thu May 12, 2011 7:53 am
Profile WWW
Site Admin
User avatar

Joined: Mar 19, 2008
Posts: 6665
Location: Austin, Texas
Post Re: Get current hour, set a variable accordingly
Or, you could just have an AppleScript condition on the trigger that brightens from 25% to 100% that looks something like this:

Code: Select all
set theHour to hours of (current date)
if (theHour > 4) then
   return true
else
   return false
end if


Then you wouldn't need a variable or any other things.

_________________
Jay (Indigo Support)
Image


Thu May 12, 2011 9:39 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.   Template designed by STSoftware.