I've made a number of improvements to my "DND Profile" lately and re-wrote a lot of it so I figured I'd post the new recipes. Here's a brief rundown of some of the new features:
- Responds to texts as well as calls
- Only sends a message to each person once, no matter how many times they call/text
- Modified so that it's easier to have different outgoing messages
- Added an orientation-based trigger for easy enabling
The changes required me to break out the script into multiple tasks and profiles, so I'll start with the "responder" profiles and work my way backwards.
event - phone ringing
1 If %DNDTOG =1
2 End Call
3 Send SMS (number %CNUM, Message below, Store In Messaging App, If %INC_RA !~ *%CNAME*)
4 Variable Set (%INC_RA to %CNAME, Append, If %INC_RA !~ *%CNAME*)
5 End If
In order to make sure each caller/texter only gets on response message, I have a variable called INC_RA, which is an array (get it?) of incoming callers. When a new call comes in, you check to see if %CNAME (the address book name of the caller) is already in the array. If it isn't, then you send them the SMS and add their name to the array. If they are in the array, nothing happens.
event - received sms
1 If %DNDTOG =1
2 Send SMS (number %SMSRF, Message below, Store In Messaging App, If %INC_RA !~ *%SMSRN*)
3 Variable Set (%INC_RA to %SMSRN, Append, If %INC_RA !~ *%SMSRN*)
4 End If
The message has also been tweaked to make it easier to have different custom messages by way of two variables. My message is set up as thus: "Sorry I missed your call, but %DND_WHY and unable to pick up. I'll call you back %DND_WHEN. Thanks."
This bit is fairly easy to decipher. My trigger widget now has two new variables to set, which I use in the outgoing message. This way, I can have several trigger widgets on my desktop for various things ("I'm in a meeting" or "I'm asleep" etc)
So now that we have our responders set, it's time to set up the task that will turn DND Mode on and off. This one isn't very different from the original one, except for the addition of a line or two.
This is a basic toggle if/then. If the toggle is on, turn it off. If it's off, turn it on. When turning it on, I set a Notify LED to let you know. I find this is better than the popup message I used to have, because so long as you don't clear the notification, you'll have a constant reminder that you're in DND mode. And if you pull down the notification bar, you'll have a reminder of what specific DND type you're set to.
1 If %DNDTOG = 0
2 Notify LED (Title DND On, Text DND - %DND_WHY, Color & Icon whatever you want)
3 Silent Mode (Vibrate)
4 Variable Clear (%INC_RA)
5 Variable Set (%DNDTOG to 1)
6 Goto Action (10)
7 End If
8 Variable Set (%DNDTOG to 0)
9 Notify Cancel
10 Silent Mode (Off)
NOTE: The LED doesn't work on all phones because some will only turn on the LED notify if the screen is off. I still keep it here for the few phones that allow LEDs on displays that are awake.
Now it's time for the widget that'll call the toggle. Go to your desktop and add a Task widget. Once you get to the screen, click "New" and name your task. This is important because the task name is how the widget will be labeled on your desktop. If you leave it blank, the widget will have a blank name.
The "One Time" checkbox lets you write the task without saving it to Tasker. On the plus side, this keeps your list of tasks relatively clean -- handy if you plan on having a number of different widgets. The down side, however, is that once you save your task, there's no way to come back later and edit it. The choice is yours to make. Me, I have them all as One Time tasks, since they're pretty basic and I don't wanna clutter up my task list.
And that's it. All you're really doing is setting your message variables and then calling the toggle task (by name, so make sure it's the same as how you named your toggle task), which is why I don't bother saving the task. Don't forget to give it a descriptive icon, since you can't change it after the fact.
1 Variable Set (%DND_WHY to "I'm in a meeting")
2 Variable Set (%DND_WHEN to "as soon as I'm able")
3 Perform Task ("dnd toggle," Stop off)
Finally, my "Sleepytime" profile. I came up with this last night because it seemed a much more elegant solution than pressing a desktop widget. When I turn in for the night, I simply turn my EVO face-down and the profile triggers. When I wake up in the morning, I turn it face up and it turns off. This one actually has three trigger events, though, not just the orientation flip.
And that's it! The reason for the three triggers is because I want to make sure this only turns on when I'm actually going to sleep. Since I always charge my phone as I sleep, having a "Power (Any)" event is a good safeguard. By having the Time event, I ensure that DND mode turns off at 9:00, thus preventing me from accidentally missing important calls in the morning. And the orientation event is there so that if I for some reason want to still receive calls, I can just leave my phone face-up. Otherwise it'd turn on any time I plugged in my phone between midnight and 9am.
time - from 00:00 to 09:00; power - any; orientation - face down
1 Notify Vibrate (Title DND On, Text DND - %DND_WHY, Pattern 250,250,250,250,250)
2 Silent Mode (Vibrate)
3 Variable Set (%DNDTOG to 1)
4 Variable Clear (%INC_RA)
5 Variable Set (%DND_WHY to "I'm asleep")
6 Variable Set (%DND_WHEN to "when I wake up")
Unlike the toggle widgets, though, there's no button to press to turn this off. Instead, we set an Exit Task
1 Notify Cancel
2 Variable Set (%DNDTOG to 0)
3 Silent Mode (Off)
The Notify Vibrate is a handy way to verify that DND mode has turned on. Since you can't really check the LCD (since it's face-down), it gives three quick buzzes to let you know it's on. Meanwhile the Notify title is still there so when you pick up the phone in the morning, you can see it disappear (thus confirming that it's off). Easy peasy.
So that's that. A slightly involved profile, I suppose, but operatively simple. I might at a future date add a little task that pops up a message reading "You received calls/texts from %INC_RA while you were DND." but it's hardly critical, especially as the outgoing messages are saved in my SMS reader anyway, so I can always just check there.