Reminders Attachment Script

Posted on
Tue Apr 07, 2009 1:56 pm
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Reminders Attachment Script

I wrote this attachment last year before coming to work with Matt, and have been just too busy to get it prepped and up on the filelib. [EDIT]It's there now. Anyway, I hope someone else finds it useful! This is not an "official" Perceptive Automation release, so use at your own risk (although I've been using it for about a year now)... :D

Check the bottom of the script file for some examples of how to call the handlers.

Reminders Attachment Script (requires Indigo Pro 3.x or later)

This attachment script provides handlers to create Reminders and Pesters (periodic mini-reminders). The thinking here is that sometimes you want to create a reminder at some future time. That you want that reminder to execute some actions, and that you want frequent periodic mini reminders (called pesters) so that you don't forget.

For instance, let's say you're washing machine is in the basement and you can't hear when it's finished washing a load of clothes. And you, like me, have the memory of a goldfish and will completely forget and leave the clothes in the washer for days. This is an attempt to help out with that problem. Using this attachment, you can create a reminder, hook it up to a button on a keypadlinc in the basement, and have an announcement made when the laundry is done after, say, 30 minutes. It can also create a pester so that it repeats the message every 5 minutes until you cancel it or it runs out.

Pesters can be created outside of a timer as well if you like, so, for instance, you can use pesters in other situations.

Installation

To install this attachment script, drag the Reminders.scpt file to the following location:

/Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Attachments/

Select "Reload Attachments" from the "Scripts" menu in the Mac client to have the attachment loaded.

Usage

The script and it's handlers are described in detail inside the script, but for completeness, here is a list of handlers in this script (the type in parenthesis before the handler is the return type):

-- (boolean) createReminder(theName, actionList, reminderValueInMinutes, pesterCount, pesterFrequencyInSeconds, pesterActions,finalPesterAction)
-- (boolean) cancelReminder(theName)
-- (boolean) createPester(theName, pesterCount, pesterFrequencyInSeconds, actionList,finalAction)
-- handlePester(theName, shouldCancel, pesterFrequencyInSeconds)
-- cancelAllPesters()
-- (string) makeStringListIntoString(theStringList)

Here is a definition of the parameters for each handler:

------------------------------------------------------
-- (boolean) createReminder(theName, actionList, reminderValueInMinutes, pesterCount, pesterFrequencyInSeconds, pesterActions,finalPesterAction)
(*
This function creates a reminder named [theName - string] that will perform [actionList - list of action group
names (strings)] actions when [reminderValueInMinutes] is up. It will also optionally create a pester when the
reminder goes off using the other parameters (see createPester next). If no [pesterActions] are passed in (again, a list of action names),
[actionList] will be passed to createPester instead.

NOTE: Once the complete cycle (reminder going off, pester finishing, pester cancelled) all items will be deleted
including the reminder itself.

NOTE: to cancel a pester, call the handlePester(theName, shouldCancel, pesterFrequencyInSeconds) function with the name passed
in to createReminder and true for shouldCancel (whatever is passed in pesterFrequencyInSeconds is ignored if shouldCancel is true
*)
------------------------------------------------------
-- (boolean) cancelReminder(theName)
(*
This function cancels a previously scheduled reminder if it hasn't gone off yet. If it's into the pester cycles, it will cancel the pester.
*)
------------------------------------------------------
-- (boolean) createPester(theName, pesterCount, pesterFrequencyInSeconds, actionList,finalAction)
(*
This function creates a pester time/date action named [theName] that will perform [actionList - list of
action group names] [pesterCount] times every [pesterFrequencyInSeconds] seconds. [finalAction] is
optional; if the name of an action group is included in this parameter, it will be executed on the last
pass through the pester. This is useful for coordinating buttons, status, etc. If the pester is already
running, the function will return false.

NOTE: the parameter theName is going to be used in an Indigo Variable Name, so it CAN'T contain spaces

NOTE: if you call the createPester function from a time/date action, and you pass the name of that
action into createPester in [theName] parameter, that action will be deleted at the end of the pester
cycle. If you want to reuse your time/date action, just pass a different name to createPester.

NOTE: to cancel a pester, call the handlePester(theName, shouldCancel, pesterFrequencyInSeconds) function with the name
passed in to createPester and true for shouldCancel (frequency is ignored if shouldCancel is true)
*)
------------------------------------------------------
-- handlePester(theName, shouldCancel, pesterFrequencyInSeconds)
(*
This function is called every time the pester is fired; it's the one that manages the counter,
and when the last pester executes, it cleans up all the automatically generated items. If
shouldCancel (a boolean) is true, it will cancel the pester regardless of the pester count
remaining. PesterFrequencyInSeconds is passed in to set the next pester cycle -
it's ignored if shouldCancel is true.
*)
------------------------------------------------------
-- cancelAllPesters()
(*
This function will cancel all pesters created with this library by looking for variables
that begin with thePrefix (defined at the top). Useful if you don't really care what
any given pester(s) are running so it can be used as a generic cancel mechanism.
*)
------------------------------------------------------
-- (string) makeStringListIntoString(theStringList)
(*
This function is useful if you're programmatically constructing AppleScript - it takes a
list of strings such as {"one","two","three"} and creates a string representation of
exactly that so you can insert it into a string that is an AppleScript. It only works for
lists of strings as the name implies. If I have a need, I'll make another function that
will deal with multiple data types.
*)

Known Issues

The example at the bottom of the script should read createReminder, not createTimer.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue May 17, 2011 11:16 pm
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Reminders Attachment Script

I got the installation and usage, but how do I implement it?

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Wed May 18, 2011 8:54 am
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Reminders Attachment Script

Execute the handlers in an embedded AppleScript action (that's one way anyhow).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed May 18, 2011 9:28 am
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Reminders Attachment Script

I figured that much, but had a few problems:

-It wouldn't accept action group names with spaces in them, even when quoted.
-It would create the time/date action but it would be disabled, and have no action selected.

An example of what I executed would be:

createReminder("Reminder", "SpeakAnnouncement", 2, 6, 10, "SpeakAnnouncement","SpeakAnnouncement")

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Wed May 18, 2011 9:58 am
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Reminders Attachment Script

The actionList and pesterActions parameters are lists (I've updated the description of pesterActions above to clarify but it already says that when describing actionList) so your call is incorrect - it should look like this:

Code: Select all
createReminder("Reminder", {"SpeakAnnouncement"}, 2, 6, 10, {"SpeakAnnouncement"},"SpeakAnnouncement")


There are examples at the bottom of the script but I notice that the last two are misnamed - they should be createReminder, not createTimer.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed May 18, 2011 10:09 am
Brandt offline
User avatar
Posts: 414
Joined: Dec 24, 2008
Location: Mission Viejo, CA

Re: Reminders Attachment Script

Thank you Jay, examples always help me out. I'll try this when I get home from work.

-Brandt

Indigo 7 w/ Dual-Band 2413U PLM
macOS High Sierra 10.13.x
2011 iMac 3.4 GHz Intel Core i7

Posted on
Wed May 18, 2011 10:14 am
jay (support) offline
Site Admin
User avatar
Posts: 18225
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Reminders Attachment Script

Here's some examples from my production database:

Code: Select all
createReminder("15MinuteTimer", {"Utility - Execute 15 Minute Timer"}, 15, 3, 60, {"Utility - Execute 15 Minute Timer Pester"}, "Notice - Clear 15 Minute Timer LEDs")
cancelReminder("15MinuteTimer")

createPester("trashPester", 10, 180, {"Trash Pester Message"}, "Turn off Reminder Button")
handlePester("trashPester", true, 0)

cancelAllPesters()

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 19 guests