Suspend Event

This verb suspends or delays the execution of a scheduled event. It is also very useful for motion actions and other things that need to manipulate timed events.

Usage:

suspend event (name of event, or unit or script)

Optional Parameters

for (integer, resets the action time of the named event to this interval from now)
until (date, resets the action time of the named event to this date)

Examples:

suspend event "morning coffee" for 2 * hours

Notes:

This verb can be used to manipulate named events in 2 ways. Named events are events you created manually and gave a name to either via the create event verb or the new event setup window. If you do not supply a for or until parameter the event will not change it's time, but will become inactive. It will remain in the list and continue to run and reschedule itself (if it's a repeating event) but it will not perform any action while it's suspended in this way. It will show as greyed out in the Scheduled Event window. You can undo this via the unsuspend event verb or the controls on the window.

If you supply a time frame or a date the time at which the event is run is reset to either the in value added to the time now or the specific date value passed in the until parameter.

The verb can also be used against automatically created events by passing the name of the unit or script that they are attached to. For instance, when you execute a command like turnoff “my unit” in 10 * minutes a scheduled event is created named for the unit that will execute 10 minutes from now. You can adjust the timing of this unnamed, but automatically created event with the suspend event verb by passing the name of the unit. This is especially helpful when creating motion controlled lights that automatically turn off after motion has stopped in an area.

If there is no event by the name specified or no automatically created events for the script or unit name passed the verb will return an error which is trappable by AppleScript's Try/OnError blocks.

This makes it possible to make a motion controlled light with the following simple script. In this example the script shown woudl go in the ON script of a motion sensor in the room you wish to monitor.

try
  suspend event "Kitchen Overhead" for 10 * minutes
on error
  turnon "Kitchen Overhead" for 10 * minutes
end try

So this script would run every time the motion sensor in the kitchen is activated. The first thing that happens is that it tries to delay the automatically created OFF event by another 10 minutes. In the case that the light is already off there would be no off event so this would return an error. The error would fall to the command that turns on the kitchen lights when you walk in. The “for 10 * minutes” part creates the event that turns the lights back off again in 10 minutes. As you move around the kitchen now the suspend event command will run and keep pushing back the event to turn them off. When motion stops long enough for the off event to run the lights will go out.

dictionary/events/suspend.txt · Last modified: 2009/09/27 16:03 by James Sentman
CC Attribution-No Derivative Works 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0