HomeTaskerCreating a near-perfect AutoNotification push in Tasker

Creating a near-perfect AutoNotification push in Tasker

maxresdefault.jpg

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.

Edit: 09/12/2017
Thanks to Joao’s feedback I have modified the tutorial to show how to integrate all AutoApps commands available through his apps. This is why there are small discrepancies in the AR messages sent in the showcase video.

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() = %arcomm1PC, %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() = %aacomm1PC, %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

TASK: AR Notification
AR Notification
	A1: Variable Set [ Name:%count To:%aapar(#) 
		Recurse Variables:Off Do Maths:Off Append:Off ] 
	A2: For [ Variable:%temp Items:%aapar() ] 
	A3: Variable Search Replace [ Variable:%temp Search:\. 
		Ignore Case:Off Multi-Line:Off One Match Only:Off 
		Store Matches In: Replace Matches:On Replace With:  ] 
	A4: Array Push [ Variable Array:%aanpar 
		Position:%count Value:%temp 
		Fill Spaces:Off ] 
	A5: Variable Add [ Name:%count Value:1 Wrap Around:0 ] 
	A6: End For  

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:

PROFILE: Perfect AutoNotification
Profile: NearPerfect Autonotification 
	Event: AutoRemote [ Configuration:NOTIFICATION ]
Enter: AR Notification 
	A1: AutoNotification [ Configuration:Title: %aacomm1
		Text: %aacomm2
		Icon: /storage/icons/%aacomm7.png
		Status Bar Icon Manual: /storage/icons/%aacomm6.png
		Status Bar Text Size: 16
		Background Color: %aacomm4
		Colorize Background: true
		Id: %aacomm3
		Title Expanded: %aacomm1
		Text Expanded: %aacomm2
		Button 1: %aacomm9
		Label 1: %aacomm8
		Button 2: %aacomm11
		Label 2: %aacomm10 Timeout (Seconds):20 ] 
		
		If [ %aapar2 ~ silent ]
	A2: AutoNotification [ Configuration:Title: %aacomm1
		Text: %aacomm2
		Icon: /storage/icons/%aacomm7.png
		Status Bar Icon Manual: /storage/icons/%aacomm6.png
		Status Bar Text Size: 16
		Background Color: %aacomm4
		Colorize Background: true
		Id: %aacomm3
		Title Expanded: %aacomm1
		Text Expanded: %aacomm2
		Button 1: %aacomm9
		Label 1: %aacomm8
		Button 2: %aacomm11
		Label 2: %aacomm10 Timeout (Seconds):20 ] 
		
		If [ %aapar2 ~ loud ]
	A3: AutoNotification [ Configuration:Title: %aacomm1
		Text: %aacomm2
		Icon: /storage/icons/%aacomm7.png
		Status Bar Icon Manual: /storage/icons/%aacomm6.png
		Status Bar Text Size: 16
		Background Color: %aacomm4
		Colorize Background: true
		Id: %aacomm3
		Title Expanded: %aacomm1
		Text Expanded: %aacomm2
		Button 1: %aacomm9
		Label 1: %aacomm8
		Button 2: %aacomm11
		Label 2: %aacomm10 Timeout (Seconds):20 ] 
		
		If [ %aapar2 ~ vibrate ]

Button and AutoApps commands

TASKER TASK: AR Notification
AR Notification 
	A1: Variable Set [ Name:%count To:1 Recurse Variables:Off Do Maths:Off Append:Off ] 
	A2: For [ Variable:%temp Items:%aacomm() ] 
	A3: Variable Convert [ Name:%temp Function:To Lower Case 
		Store Result In:%aacomm(%count) ] If [ %count > 7 ]
	A4: Variable Add [ Name:%count Value:1 Wrap Around:0 ] 
	A5: End For 
	A6: AutoNotification [ Configuration:Title: %aacomm1
		Text: %aacomm2
		Icon: /storage/emulated/0/Tasker/icons/notification icons/%aacomm7.png
		Status Bar Icon Manual: /storage/emulated/0/Tasker/icons/notification icons/%aacomm6.png
		Status Bar Text Size: 16
		Background Color: %aacomm4
		Colorize Background: true
		Id: %aacomm3
		Title Expanded: %aacomm1
		Text Expanded: %aacomm2
		Button 1: %aacomm9
		Label 1: %aacomm8
		Button 2: %aacomm11
		Label 2: %aacomm10
		Button 3: %aacomm13
		Label 3: %aacomm12 Timeout (Seconds):20 ] 

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.

PayPal

Nothing says "Thank you" better than keeping my coffee jar topped up!

Patreon

Support me on Patreon and get an early access to tutorial files and videos.

image/svg+xml

Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

New to Tasker?

Tasker Quick Start – Getting started with Tasker

0
From newb to not so newbie in 10 min

Best Tasker Projects

How to use Raspberry PI as WOL (wake on lan) server

0
While you could wake up your PC from a mobile directly, having a dedicated server capable of doing so is the best solution. The reason is simple. You can hook up as many devices as you wish with a single endpoint. This is why Raspberry Pi is perfect for this.

How to wake on LAN computers and put it to sleep with Power Menu,...

0
How to Wake on LAN properly via Android, Alexa, Google Assistant and Web

7 awesome Bluetooth keyboard shortcuts for Android

0
7 unique Android shortcuts that you can add to any Bluetooth keyboard.

Smart overnight charging with Tasker

0
Still keeping your phone plugged in overnight? Try smarter overnight charging with this profile

One thing that Join app can’t do and how to fix it with Tasker

0
It's not possible to share the clipboard automatically between join accounts registered to 2 different emails. But you can fix this with tasker.

Essential Guides

Tasker: Seconds into DD:HH:MM:SS (dynamic)

0
It's time to.... ok it's a pun, but I will show you how to master time and convert seconds to DD:HH:MM:SS dynamically

4 ways to organise Tasker projects

0
Keep your Tasker tidy!

A better way to store Tasker credentials

0
The more clever way of managing credentials

Annoyed with dozens of AutoApps populating your app drawer? Here is a fix!

0
Clear your app drawer from the clutter in seconds

Putting AutoTools pie chart to a good use – SSID logger

0
Who wants a piece of the pie (chart)?