This page displays the full list of examples in article format. If you are looking for a summarized list of examples, you may prefer the condensed view.
SharpTools uses push events for two main features -- the `Thing State` Tasker plugin and Widgets that display state. This article explains how push events work with Widgets and Tasker and how to troubleshoot various features.
SharpTools includes a widget called "A Thing (Widget)" which can change color to reflect the current state of a device. For example, you might create a widget for a lamp and the widget would show a lit-up yellow color when the lamp is off and a gray color when the lamp is turned off. When you first create this widget, SharpTools automatically sets up an event subscription which is used to keep the widget status up-to-date. This uses the SmartThings event subscription capabilities and then pushes the data for Firebase Cloud Messaging (FCM) by Google. FCM is Google's push event and push notification service that powers millions of Android apps that you like use today.
The process is something like the following:
It may seem like a long process, but all this happens in milliseconds when things are working properly!
In addition to the push events, SharpTools also refreshes the widget data anytime the main SharpTools app is open and the Thing data is refreshed. By default, the Thing data is automatically refreshed when you first open the app. Additionally, you can change the SharpTools Settings to periodically refresh data while the app is open or you can manually refresh the data by tapping the refresh icon in the action bar.
Widget-specific troubleshooting: The first step in troubleshooting widgets is to try deleting the widget and then setting it back up again. After deleting the widget, check to see if there are any subscriptions for the Thing/Attribute that was used for the widget by opening the Subscriptions pane from the SharpTools left navigation and tapping the refresh icon in the action bar. Remove any remaining subscriptions by long-pressing on the subscription and selecting Unsubscribe. Try setting up the widget again and verify if the push events are working as expected.
The 'Thing State' event plugin in Tasker uses many of the same principles as the SharpTools widgets -- the main difference being that you must manually subscribe to your desired attribute and setup the 'Thing State' plugin in Tasker. Check out the Event: Thing State tutorial for more information on how to set up a Tasker profile that reacts to SmartThings events.
The summarized version of setting up the profile is as follows: First, subscribe to the desired attribute by long pressing on the Thing in SharpTools and selecting the appropriate "Subscribe to..." option. A small star icon will show up in the top-right corner of the Thing card when you are subscribed to at least one attribute. Then open up Tasker and create a new 'Thing State' event profile and make sure you configure the Thing and Attribute fields to match your subscribed thing/attribute.
The process of an event being triggered is very similar to widgets -- a SmartApp running in the SmartThings cloud watches for the subscribed Thing events and then pushes the data to your device using Firebase Cloud Messaging by Google (FCM).
The process is something like the following:
Again, this may seem like a long process, but it all happens in milliseconds when things are working properly!
*Within Tasker, the 'Thing State' profile has to be configured correctly to trigger the task and the task must be configured properly to take a desired action. One way to test this is to completely clear out the 'Thing' and 'Attribute' fields in the 'Thing State' event plugin configuration -- this will cause the Tasker plugin to match ANY thing and attribute that changes. Additionally, try creating the most basic profile you can with ONLY the 'Thing State' plugin as a context and ONLY an Alert → Notify action with "TEST" as the title. If the simple profile and task are being triggered successfully, build from there adding 'Thing' and/or 'Attribute' filters to the Thing State plugin and adding additional logic and actions to the task.
SharpTools has a Subscriptions screen which displays all the currently subscribed Device/Attribute pairs for the current Android device. To access this feature, open the left navigation in SharpTools and select Subscriptions. Once the subscriptions screen is open, tap the refresh icon in the action bar to download the latest set of subscriptions from SmartThings.
Note that the subscriptions list shows two different icons -- the first icon is a square/cube which indicates that a subscription is in place and is being used for widgets. The second icon is a star icon which indicates that a subscription is in place and is being used for Tasker.
A subscription can also have both a widget and Tasker subscription -- in this case, if you long-press and try to remove the subcription, SharpTools will only remove the Tasker subscription leaving the widget subscription in tact. Similarly, if you have both a widget and tasker subscription and then remove the widget, SharpTools will remove the widget subscription but leave the Tasker subscription in tact. To completely remove the subscription, you may have to manully unsubscribe from the thing/attribute and then delete the widget from your homescreen.
Now that we have a basic understanding of how the Widgets and Tasker push event features work, let's dig into troubleshooting a bit. As of SharpTools 2.3, there is now a "Manage Push Events" feature at the bottom of the SharpTools Settings screen. This is a great place to start for troubleshooting.
At the top of the screen, you should see your Firebase Cloud Messaging ID (FCM ID). If you don't see an ID, this likely means that something went wrong when trying to register your device with Google. This registration process is all handled automatically by Google, but if you aren't seeing a FCM ID for some reason, you can try tapping the 'Force Reset FCM ID' option which will forcefully clear the local registration ID and manually ask Google for an ID.
Once you have confirmed that you have a FCM ID, another helpful feature is the Send Test Message button. This will send a push message to your device using the SharpTools.io cloud servers. This is a great diagnostic feature as it completely takes the SmartThings servers out of the loop and directly communicates with SharpTools.io which is running on Google's Cloud Platform. After pressing the 'Send Test Message' button, you should see a message indicating whether or not the message was successfully posted to SharpTools.io and the Google servers -- when successful, this message will also include a receipt ID which is helpful for diagnostics (more on this in a bit). After a successful post, the next message you should see is a receipt of the push event. If all three messages are shown (FCM ID, Post Successful, Ping Response Received), then the core push event functionality is working on your device.
If the Send Test Message feature works as expected, the next step is to troubleshoot events from SmartThings. Before we get started with that, it may be helpful to enable Push Event Debug Notifications. Once this feature is enabled, SharpTools will display a notification anytime ANY push event is received. This is particularly helpful in troubleshooting Tasker profiles where the profile might need some additional adjustments to work properly. Using the 'Send Test Message' feature will give you an idea how this works -- a notification will be displayed which when expanded displays the content of the received push event.
Note: The instructions in this section only apply to Tasker subscriptions as the `Things` view only shows a star icon for Tasker subscriptions. If you want to see all of the subscriptions for your device, open the Subscriptions pane instead. See the Subscriptions section for more details.
After Push Event Debug Notifications are enabled, check that the desired attribute is subscribed as expected. To do this, open the Things screen in SharpTools and scroll down to your desired device. You should see a star icon in the top-right corner of the Thing card indicating that at least one attribute is subscribed. Further to that, if you long press on the device, you should see a menu of items you can subscribe to and unsubscribe from. You should see an "Unsubscribe from..." option on the attribute you are trying to receive push events from. If you don't see this option, select the "Subscribe to..." option for your desired option to make sure you are subscribed to push events. Another helpful troubleshooting step is to manually unsubscribe from and then resubscribe to your desired attribute - this forces the SmartApp to clear out the subscription and then re-add it. Additionally, you can try opening the 'Subscriptions' pane from the SharpTools left navigation and then manually tap the refresh icon in the action bar to refresh the list of subscriptions. Once you've refreshed the list of subscriptions, open the Things screen again and check to see if your subscription is setup as expected.
After you have confirmed that Push Event Debug Notifications are enabled and your desired attribute is subscribed, try triggering the event. For example, if you are subscribed to the 'switch' attribute of a light, turn the light off and on a few times. If you are subscribed to the 'level' attribute, try dimming the light down and then back up again a few times. If the push events are working as expected, you should receive a push event debug notification at that top of your screen.
If you still haven't received a push event as expected, try reviewing the SmartThings IDE Live Logs. To do this, open the SmartThings IDE Live Logs, then manually trigger your event (eg. turning the light on/off). To make it easier to sort through the logs, tap the "SharpTools" option in the top filter bar. When the subscribed attribute is changed, we expect to see a message that starts with "event triggered for [attribute] on [device_id]" -- this message indicates that SmartThings internally received the event from the Thing. If you aren't receiving this event, it means that SmartThings isn't seeing the change from your device -- the first troubleshooting step would be to manually unsubscribe and resubscribe to the attribute in SharpTools. The next message you should see is "Event data successfully posted" and then "RegIDs triggered" showing the FCM ID(s) that the push event was sent to. These last two messages indicate that SmartThings has successfully handed the messages off to Firebase Cloud Messaging and it is up to Google to deliver the message now.
Note: some IP devices like the Belkin Wemo are notorious for having slow status updates on the SmartThings platform. Submit a support ticket to SmartThings to show that you want this improved on the platform! Try testing with a Zigbee or Z-wave device as these tend to have the fastest update times on the SmartThings platform.
If the push events still aren't working as expected, one option is to completely reset your environment. To do this, first open the SmartThings mobile application and remove the SharpTools SmartApp. As of writing this document, you can remove a SmartApp by opening the right-hand navigation menu, select SmartApps, scroll down and select SharpTools, then scroll down and select 'Remove'.
After the SharpTools SmartApp is removed, clear the data from the SharpTools. While many devices should not require clearing the data from the app (as an uninstall and reinstall process should clear the data), experience has shown that some device manufacturers cache app data longer than they should. To work around this, manually clear the data from the SharpTools app before removing and reinstalling it. The instructions on how to do this vary from device to device, but in general the process includes navigating to your main Android Settings screen, then selecting Applications, select "All Applications" or "Installed Applications", then scroll down and find SharpTools, then select "Clear Data". Again, the process may vary from manufacturer to manufacturer, so refer to manufacturer instructions as needed.
After the app data has been cleared, uninstall and then reinstall the SharpTools Android app. Open Google Play and search for SharpTools -- select SharpTools and then select the 'Remove' option. Once the application is removed, restart your Android device. After your device has restarted, open Google Play and search for 'SharpTools' and select Install.
After installing SharpTools, complete the Authorization of your Things from the SharpTools Settings screen and setup the subscription again. Once the subscription is setup, try the troubleshooting steps again.
In this tutorial, we will demonstrate how to use Tasker, AutoVoice, and SharpTools to run a SmartThings routine using your voice. At the end of this tutorial, you will be able to say "Okay Google, run the routine Good Morning" and have the "Good Morning!" routine/phrase run.
This tutorial uses the SmartThings Voice Control with Tasker tutorial as a baseline. If you are unfamiliar with using AutoVoice or Tasker, I would strongly recommend reviewing the SmartThings Voice Control with Tasker tutorial.
In the end, your task will have several actions like:
Note: For debugging purposes, you may want to include a simple Notify or Flash action to show the contents of the variable captured with AutoVoice. Sometimes the words captured by AutoVoice/Google are slightly different than you expected and you will want to adjust your conditional actions accordingly (eg. "good night" → "goodnight", "10" → "ten")
For additional troubleshooting steps, see the troubleshooting section of the SmartThings Voice Control with Tasker tutorial.
In this tutorial, we'll show how to react to specific mode changes. By default, when you subscribe to mode changes in SharpTools, the 'Mode Change' event plugin will be triggered anytime ANY mode change occurs. If you want to trigger mode changes only for specific modes, you will need to use a conditional action (IF).
In this example, we will explain how to setup a task that only runs if the mode is changed to `Night`.
Here's a video showing this feature in action:
This example shows how to save the state of a device for later use in Tasker. If you are subscribed to multiple devices, you might find that you want to have a Tasker profile react to the current state of many devices at once. In order to do this, you can save the device status off to a global Tasker variable, so it is available for use in other profiles and tasks.
Note: This same approach can be used with the action "Thing: Get Attribute" within a profile. Immediately after triggering the Thing: Get Attribute action, you would setup a Variable Set action to copy data into a global variable.
When the 'Thing State' event triggers in Tasker, there are four variables that are set. Using a Porch Light as an example:
In order to make this data available in other profiles, you need to copy the data from the %st_attr_value to your desired permanent variable. For example:
There are a couple of options on how to do this conditionally:
Option 1: One option is to setup several "Thing State" events each with the configuration filters set to react to each individual thing and then have each Task set the desired variable (eg. %PORCHSTATUS) to the value from %st_attr_value. At the end of running through your variable copying tasks, you could then trigger the main tasks which would evaluate all the global variables you have set.
Option 2: Another option is to have one main "Thing State" event that does not have any filters applied to the plugin so it catches everything... then use conditional actions to transfer the data from the %st_attr_value to the appropriate variable. So like in the above scenario, you would use Tasker's "Variable Set" %PORCHSTATUS to %st_attr_value but only IF the %st_thing_name matched "porch light". You would setup an action for each thing that you want to transfer the variable for (eg. IF %st_thing_name matched "hall light" then set %HALLSTATUS to %st_attr_value, then at the end of the task, you would trigger the main tasks which would evaluate all the global variables you have set.
Keep in mind that local variables are only available during the execution of a task, so you should global variables so the data will be retained. From the Tasker variable guide:
In this tutorial, we will show how to use SharpTools and Tasker to create a custom widget that displays Thing state in Android. If you are looking for a quick and easy way to control your Things without Tasker and without showing the current state, the built-in widget 'A Thing' is ready-to-go right out of the box.
You might also be interested in the following SharpTools articles:
In this article, we demonstrated how to setup a 'Task' widget to toggle a light then how to subscribe to an attribute in SharpTools and react to that change in Tasker. Putting all this together, we now have a widget that toggles a light and displays the current state of the device.
In the example, we used a somewhat boring built-in Tasker icons, but I implore everyone to get creative with your use of widgets. Perhaps you want to have an actual picture of the light showing the status of the device; Or perhaps you might use a custom graphic or icon pack; Or perhaps even use Zooper Widget to create a completely custom Widget.
In this tutorial, we will briefly demonstrate how to use Tasker and SharpTools to create an accurate and effective custom presence solution for SmartThings. The built-in presence feature of the SmartThings mobile application has been criticized for randomly indicating that a person is no longer present in their home (when they are sleeping or sitting on the couch).
At the end of the tutorial, you will have a custom presence solution using the proximity to your WiFi access point as the trigger for determining your presence. Additionally, the tutorial provides commentary on areas where you might choose to use alternative methods/customization that would better determine presence for your home.
You might also be interested in the following SharpTools articles:
If you are interested in setting up a high accuracy presence solution with AutoLocation, @destructure00 from the SmartThings Community has a fantastic write-up showing how to set nested geofences which balance high-accuracy with great battery life.
Create a Simulated Presence Device
You should now have a new 'Custom Presence' device listed in your SmartThings mobile app. Unlike normal presence devices, you can manually control this presence device setting it to 'not present' (away) or 'present' (arrived). Continue to the instructions below to see how we can use this simulated presence device along with Tasker to create an accurate and effective presence device.
In this section, we will explain how to create a Tasker context for which will trigger when you enter or leave your defined area. Note that there are many different approaches to determining location and only a few of those are noted here. So if you have other ideas on how you might be able to more effectively determine your location, feel free to use those.
In order to keep this tutorial accessible to the broadest audience, we are going to use the 'WiFi Near' condition that is built into Tasker. GPS, WiFi, and Cellular options are built-in to Tasker, but we have found that the Fused Location via AutoLocation provider provides the best accuracy both indoors and outdoors (particularly when WiFi is left on).
As noted in the Tasker: Location Without Tears article:
Following the previous section where we had just completed setting up the context of a Tasker profile and had just clicked the back button to save the context.
We used the 'Wifi Near' Tasker context in this example to as it is included with Tasker and is easy to understand. Note that the author of this article recommends the AutoLocation plugin which provides a fused location provider which can provide a more flexible geolocation solution. As you might guess, the 'Wifi Near' context is dependent on being able to detect the access point... so if for some reason there are connectivity issues with the access point, the phone will trigger the exit condition.
The fused location provider in AutoLocation helps get around this by using a geofence and location determined using Wifi+GPS+Cellular so there is a bit of fail-over built into the provider. The geofence capabilities of Autolocation also provide a visual representation your location and makes it easier to increase the size of the circle to reduce false alarms.
Resiliency and Retries: You may be interested in adding more resiliency to your profiles through the use of retries. Some users have found that the transition from Wifi to Cellular (or vice-a-versa) can cause the SharpTools commands to timeout while the network is unavailable.
Hellfire51 put together a nice example showing how to add retries to your profile:
Prompt to unlock doors: You may decide that you don't want your phone to automatically perform an action for you. For example, you may prefer the phone to display a notification or prompt asking you if you really want to perform the action.
eibyer put together an example showing how to use custom presence to trigger a prompt asking if he wants to manually unlock his doors
This is a draft stub of this article and may have formatting and grammatical errors.
For more details on how to use conditional actions with Mode changes, check out the Conditional Mode Change article which includes a video showing how to react to only specific mode change events.
In this tutorial, we will briefly demonstrate how to use Tasker, AutoVoice, and SharpTools to use voice commands to control devices in your smart home using variables. If you are looking for a more basic tutorial on controlling your devices, see here - and if you are interested in just the details of dimming a light (without voice control), see here. At the end of the tutorial, you will be able to say
Now you should be able to say Okay Google, Dim the bedroom light to [level] percent where [level] is a number between 0 and 100 and the associated light should dim to the desired percentage.
This approach can be used with other devices which have commands that accept parameters. Consider the following example for changing the cooling setpoint of your thermostat:
In this tutorial, we will briefly demonstrate how to use Tasker, AutoVoice, and SharpTools to query the status of devices in your home. At the end of the tutorial, you will be able to say
This approach can be used to answer other queries like:
The same concept applies as was used in the instructions above. Simply swap out the AutoVoice filter for your updated query and replace the thing and attribute in the Thing: Get Attribute configuration.
If you don't want to have the response spoken aloud, you might consider using the Alert > Notify or Alert > Flash action to have the result of the attribute query displayed on screen.
Many devices have several different attributes that may be of interest to you, so play around and see what's out there. For example, in addition to pulling in the
You can also use the `Thing: Get Attribute` plugin with variables to get the current status of many of your things at once or to use variables to get the status of a desired device. To do this, tap the tag icon in the top action bar to switch to variable mode.
Once you have switched the plugin into variable mode, you can either directly enter a string into the fields or you can use a Tasker variable (eg.
For example, if we wanted to setup a profile that allowed us to ask 'Is the [device] on?', we could change the voice query from above to use AutoVoice's RegEx feature to allow us to dynamically ask if a device is on using a query like:
Then in the `Thing: Get Attribute` plugin we would use the following configuration:
And finally, we could spit out the result using an action like Alert > Flash:
Important: When you are using `Thing: Get Attribute` in variable mode, the response changes from a set of single-value strings to a set of string arrays.
When you are using `Thing: Get Attribute` for a single device (Eg. with the drop-downs), you'll get the following variables:
When you use `Thing: Get Attribute` in variable mode, you'll get the following variables (which are each arrays):
For more information on variable arrays in Tasker, see the documentation linked below:
This tutorial shows how to use the SharpTools Tasker Plugins (or Widgets) to dim a light in your SmartThings automated home.
Each phone/launcher has different ways to add widgets to your homescreen. This guide assumes the reader has knowledge of how to add a widget to their homescreen.
Note: Many launchers display the list of widgets after a long press of the homescreen or within their app drawer. Several of the SharpTools widgets are actually shortcuts and some launchers, like Nova Launcher, group these separate from traditional widgets.