Interactive Android Notifications (CoRE + Tasker)

I recently spent some time putting together a method to allow interactive Android notifications using CoRE and Tasker. This post describes the CoRE piston and Tasker task used for my implementation. Hopefully someone else will find this useful!

Background
The primary use case was to allow disabling a virtual presence sensor directly from an Android notification. I use a virtual presence sensor named “Guest Mode” to prevent automatically turning off lights, locking doors, etc. when we have guests. This works well, but sometimes we forget to turn it off after our guests leave. I previously used CoRE to send myself a reminder notification at 8AM if “Guest Mode” was enabled. While this worked, I still needed to open the SmartThings app in order to disable the presence sensor. My desire was to add a “Disable” link directly to the notification.

Design
I modified my CoRE piston to send an SMS message to my phone rather than a notification. (This prevents the notification from showing up on my wife’s phone, and I found it was easier to prevent a notification on my phone for the SMS message.) The SMS message contains the following delimited list of values:

@CN|Guest Mode Reminder|Guest mode is enabled.|Disable|disableGuestMode

Here is a description of each value:

  1. @CN - Key indicating that the message is destined for my CoRE Notifier task
  2. Guest Mode Reminder - Title of the notification
  3. Guest mode is enabled. - Text of the notification (keep it short, does not word-wrap)
  4. Disable - Action 1 label
  5. disableGuestMode - Action 1 CoRE IFTTT endpoint

This example only includes one action, but the Tasker task supports up to 3 actions.Each action is essentially a callback to CoRE using an IFTTT endpoint. Note that this does not require setting up an IFTTT channel with CoRE, it simply uses that interface for the action callbacks. A screenshot of the CoRE piston is included at the end of the post for reference.

I created a Tasker profile to run anytime I receive an SMS from the SmartThings number. The contents of the SMS message (%SMSRB) is passed to my CoRE Notifier task through Parameter 1 using an anonymous task. This provides an easy way to change the message source in case SMS is not desirable.

The CoRE Notifier task parses the value list and displays the appropriate notification. When a notification action is selected, the CoRE Notifier task is called again with the action endpoint specified in Parameter 2. An HTTP Get is performed using the CoRE IFTTT URL (stored in the %CN_URL variable) and the callback endpoint. On success, the notification is cleared and “Success” is displayed, otherwise “HTTP Error” is displayed.

Setup
Here are the basic steps to set this up on your Android device:

  1. Obtain CoRE URL
    a. Open CoRE SmartApp
    b. Click on CoRE Dashboard
    c. Copy the URL to the clipboard
  2. Setup Tasker
    a. Import the CoRE Notifier task into Tasker.
    b. Import the SmartThings SMS profile into Tasker
    c. Run the CoRE Notifier task, which will prompt for Dashboard URL
    d. Paste URL obtained in step 1
    e. Submit
  3. Hide SMS notifications (Optional)
    a. Once you receive an SMS from SmartThings, disable SMS notifications from that number (device dependent)

That’s it! At this point, you should be able to send yourself SMS from CoRE using the format below and have it processed by the Tasker task

@CN|Title|Text|Label1|Callback1|Label2|Callback2|Label3|Callback3

To handle a callback in CoRE, simply create a piston that executes when IFTTT event Callback# is executed (replacing Callback# with whatever callback name you specified in the message).

CoRE Piston

Tasker:CoRE Notifier Task

Tasker:SmartThings SMS Profile

5 Likes

This is great. I’ve been wanting something just like this. Thanks for sharing.

I know this is an old post, but I’ve been wanting interactive notifications and this helped me a ton. I made some tweaks to get it working with webcore.

  1. Changed the HTTP call from a get to a post, using the %par2 in the payload.
  2. pointed the http call to a webcore piston.
  3. Configured the piston as a Tasker handler piston. to utilize the value passed in %par2