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!
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.
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:
@CN- Key indicating that the message is destined for my CoRE Notifier task
Guest Mode Reminder- Title of the notification
Guest mode is enabled.- Text of the notification (keep it short, does not word-wrap)
Disable- Action 1 label
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.
Here are the basic steps to set this up on your Android device:
- Obtain CoRE URL
a. Open CoRE SmartApp
b. Click on CoRE Dashboard
c. Copy the URL to the clipboard
- 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
- 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
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).
Tasker:CoRE Notifier Task
Tasker:SmartThings SMS Profile