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:
Thing → SmartThings → SmartApp (SharpTools) → Firebase → SharpTools → Widget
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:
Thing → SmartThings → SmartApp (SharpTools) → Firebase → SharpTools → Tasker*
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.
Verify Cloud Messaging ID
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.
Send Test Message
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.
Push Event Debug Notifications
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.
Test a Subscription
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.
Review SmartThings IDE Live Logs
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.