
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