Get Status of Things in Tasker

There are a few approaches to getting the state of devices with the SharpTools Android Tasker integration:

  1. Invoke an action that asks SmartThings for the status of the attribute of a device (or multiple devices)

  2. Wait for the state to be pushed to SharpTools (based on a subscription)

1. Actively ask for the status of an attribute from SmartThings

The first approach to invoke a request for the thing state would be the use of the Thing: Get Attribute action in Tasker. This is effectively making an HTTP request to SmartThings asking for the state of a single device (or multiple devices).

As you might imagine, in order to use this approach, you need some sort of trigger to tell SharpTools to go out and ask for the state. The trigger might be something like every morning when your alarm clock goes off, check the status of your devices so you could speak a summary. Alternatively, you might setup a recurring Task which would effectively 'poll' SmartThings for status, but frequent HTTP/network calls will likely increase battery consumption.

If you only occasionally need the status of a device, actively asking for the state using Thing: Get Attribute is a good approach.

This approach is often simpler to understand and get setup, but also incurs additional latency in your task as you have to wait for the HTTP request to be made to SmartThings and a response to be received. If execution speed of the Task is important, consider setting up a subscription and saving the state to a variable for use in future tasks.

If you will be frequently requesting state using Thing: Get Attribute, there will be an impact on your battery life. If your device is not connected to a power source, you may be better off using 'Thing State' event plugin along with a subscription. See option 2 below.

2. Setup subscriptions and react to push events

The second approach is to wait for state to be pushed to the device and react to the event using the Thing State event plugin (as a profile context).

In this approach, Tasker only gets activated when the state of your desired thing+attribute combo changes and SmartThings sends the event to SharpTools. If this is an attribute that changes relatively infrequently like a lock or switch, it would minimize the number of events you are receiving and minimize battery usage (as compared to polling for the status with "Thing: Get State"). But if you are subscribed to an attribute that changes very frequently like a heartbeat status or a device handler which updates the status too frequently, then this would push a large number of events and keep SharpTools and Tasker active.

For more details, check out the following related articles:

If you want to always have the updated status of a specific attribute, the Thing State event plugin is a great way to setup state/event driven actions. The state can also be saved to global Tasker variables for use in other plugins and other profiles can conditionally determine if they run based on the status of a previous or currently received event.

If the attribute you are subscribing to changes frequently and you don't need instant status updates, then you might consider using the Thing: Get Attribute approach mentioned in the first option. Attributes which change very frequently will trigger a push event for each status change which may wake your device and consume battery when not needed.