Many times before, I found myself creating yet another AutoNotificaiton action in my Tasker project. Anyone using this plugin knows how versatile it can be and at the same time, how annoying it can be to fill in all these fields to make the notification look half decent. I touched on streamlining the AutoNotification messages before when using NodeRED, but the same principle can be applied to any project.
Near-perfect Autonotification
The set up created by me supports most useful fields. It can be expanded to virtually all fields available. Don’t worry, I’m not going to do all of it, but feel free to expand it out according to your needs. I’m going to show you how to use a single profile to integrate the AutoRemote and AutoApps commands in a single task.
Sending data with AutoRemote or AutoApps commands
First of all, if you want to know more about how AutoRemote works – read this. I’m only going to cover a small fraction of that plugin for the purpose of the tutorial. When I started with AutoRemote, my messages between devices would look something like this:
silent notification PC wake up
While this would work, after a while my notifications had to be organised. This is where the structure of the message comes into play.
silent notification=:=PC=:=wake up
In the example above AuroRemote will split the message accordingly:
- %arcomm() = %arcomm1 = PC, %arcomm2 = wake up
- %armessage = silent notification=:=PC=:=wake up
- %arpar() = %arpar1 = silent, %arpar2 = notification
In advanced settings AutoRemote allows you to change the name of the variables: %arpar and %arcomm. To have a single task that links the commands issued by AutoRemote and AutoApps I’m going to rename the variables to: %aapar and %aacomm respectively. This way regardless of where the command has originated, the AutoNotification will process it in the same way.
- %aacomm() = %aacomm1 = PC, %aacomm2 = wake up
- %aamessage = silent notification=:=PC=:=wake up
- %aapar() = %aapar1 = silent, %aapar2 = notification
The AutoNotification
As you can see in the previous chapter the array %aapar() allows you to pass different values to the AutoNotification. For short notifications, you could use something as simple as:
notification=:=title=:=text
Each word to the right of =:= would get assigned as %aacom. Here is the list of values which are substituted by the variables:
- title (expanded as well)
- text (expanded as well)
- message ID
- priority
- launcher icon
- notification icon
- colour
- multiple buttons and actions
The proposed message format starts with the most often used values and ends with buttons. I will use the notification below as an example.
NOTIFICATION silent=:=This is the title=:=This is the text of the message that will have over 37 characters to illustrate the point=:=messageID=:=#5481D4FA=:=2=:=notification=:=notificationbig=:=button1=:=button1action=:=button2=:=button2action
Here is the layout of my notification:
In addition to the %aacomm() array, we also get a %aapar() array which contains each word to the left of =:=. You could use this neat trick to pass multiple words into a single variable.
make this silent NOTIFICATION=:=PC=:=wake up
a string like this, which reads as %aapar() = make,this,silent,NOTIFICATION could be used as:
make.this.silent NOTIFICATION=:=PC=:=wake up
and transformed into something more useful using the task below %aapar() = make this silent, NOTIFICATION
Back to our initial formatting, there are things to take note of: icon paths are backed into the notification, therefore all I have to pass is the icon name which is the file name itself. Make sure to create the correct folder structure. (all my icons have an icon folder inside the Tasker folder)
I’m usually using the %aapar data as my AutoRemote event filter to trigger the task. If you use the upper case filter for AutoRemote event it makes even easier to capture a specific event and use further elements of the %aapar() array to run separate actions:
Button and AutoApps commands
I recently run into an issue where I had to issue 3 commands. I usually handle these by creating a ‘universal’ AutoApp command profile which intercepts a common phrase and tasks are executed based on the rest of the command. A command:
GoogleHome pause/stopall/enableall
The GoogleHome is the trigger for this profile and two IF statement would handle the stop/stopall/enableall actions. There is a problem with this setup. The notification AutoApp command contains the same trigger words, that would trigger the command profile.
Fortunately, I figured out the solution without breaking anything. The notification string is issued with the button commands with uppercase letters (I keep it all caps, but at least one is needed). This way notification is created by the Near Perfect AutoNotificaiton profile but it doesn’t trigger anything else. All it’s left is to convert the string into the lower case letters – and I can use the case-sensitive AutoApp command to intercept button presses.
Trigger Word: GoogleHome IF ~R pause IF ~R stopall IF ~R enableall
I have updated the download files to reflect the changes. You can also offset the number of formatted %aacomm by adding an IF statement to variable convert. Here is how the task would look like.
Conclusion
As you can see, this could save you a lot of time. It’s especially useful if you (like me) use AutoRemote a lot. You can create push notifications with different colours, icons texts and titles just by passing a string of characters. It will save you time and will also decrease the number of actions in your Tasker projects.
Project Download
Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.