It is used to simulate sunrise ( slowly fading up lights ) along with a seperateiTunes Fade-up script for an "alarm clock" in the morning.
- Code: Select all
tell application "IndigoServer"
set deviceName to "Master Bedroom Keypad - B"
set maximumLightPercentage to 60
set minutesToSunrise to 30
-- This math is importaint as it sets the number of repeats below
set raiseLightsBy to round (maximumLightPercentage / minutesToSunrise / 2)
log "Starting to raise the lights by " & raiseLightsBy & "% every 30 seconds over the next " & minutesToSunrise & " minutes to achive a final brightness of " & maximumLightPercentage
repeat minutesToSunrise * 2 times
-- Turn up the brightness of the device one increment
brighten deviceName by raiseLightsBy
-- Set a variable with the current brightness of our device so we can log it below
set currentBrightness to brightness of device deviceName as integer
log "Sunrise Simulator raised " & deviceName & " to " & currentBrightness & "%"
-- Since the parameter minutesToSunrise is in minutes, delay one minute
-- but loop every 30 seconds to give it a more even increase in
-- brightening. Note the "minutesToSunrise / 2" and "repeat minutesToSunrise * 2 times"
-- above to account for the half minute increment.
delay 30
end repeat
-- In case there is a rounding error above, set it to the target percentage
brighten deviceName to maximumLightPercentage
end tell
Thanks!