Event: Thing State

Post date: Dec 08, 2014 5:50:30 AM

As of version 1.07, SharpTools has a Tasker Event plugin called Thing State which can be used to trigger events in Tasker when a subscribed Thing's state changes. For example, you can choose to subscribe to the Temperature of an Aeon Multisensor and have an Event trigger if the temperature is too low or high. Or you might subscribe to the 'switch' state of a light switch and trigger an event when the light turns on or off.

You may also be interested in the following articles:

Tasker Variables

Whenever an event is triggered, the following local variables are set in Tasker:

    • %st_thing_id = The internal Thing ID of the Thing that triggered the event.

    • %st_thing_name = The user friendly name/label of the Thing that triggered the event.

    • %st_attr_name = The attribute name that triggered the event. (eg. 'switch', 'level', 'temperature')

    • %st_attr_value = The value of the attribute that triggered the event (eg. 'on', '100', '72')

Subscribe to a Thing's State

To use the Thing State plugin in Tasker, you must first subscribe to the state of a Thing.

    1. Open SharpTools

    2. Make sure you are using the default SmartApp provider

    3. Change to the 'Things' screen

    4. Long press on the desired Thing

    5. From the Subscriptions menu that pops up, select the state you would like to subscribe to

Upon successfully subscribing to a thing, you should see a confirmation message. The very first time you subscribe to any device, SharpTools will register your device with Google for push messages and will respond with a 'Device registered with GCM' message.

React to Thing State changes in Tasker

After subscribing to a Thing's state within the main SharpTools application, you can configure Tasker to react to state changes:

    1. Open Tasker

    2. On the Profiles tab, click the '+' icon to add a new Profile

  1. Select Event > Plugin: Thing State

  2. Click the pencil icon to edit the Configuration

  3. Fill in the optional filters and click Apply

Example Task:

  1. Press the back button on your mobile device to continue setting up the Tasker

    1. Select the 'New Task' option

    2. Leave the New Task Name blank and press the checkmark

    3. Click + at the bottom of the screen to add an action

    4. Choose Alert > Notify

    5. In the title field, enter %st_thing_name

    6. In the Text field enter %st_attr_name: %st_attr_value

    7. Press back to save the Action, back again to save the Task, and back again to exit Tasker

Now whenever a subscribed device's state change, a notification will appear showing the Thing Name as the title and the Attribute Name and Value as the text.

Alternate Reference: Original video demonstration

Tasker: Thing State Event Filters

The Tasker Event plugin, Thing State, has a set of filters that allow you to determine which events to react to.

  • If either field is left blank, the field is treated as a wildcard and all things or attributes are matched.

    • If both fields are left blank, the system will match all events that are triggered

    • If the Thing field is filled in and the Attribute field is left blank, the system will match all events for a particular thing name

    • If the Attribute field is filled in and the Thing field is left blank, all events for the particular Attribute will be matched.

        • For example, Attribute = "Switch" and Thing = blank would match all switch events (eg. on/off events)

  • Each field performs a partial content match.

      • For example, if the Thing field has the word hall entered, the system will match all things with hall in their name (eg. Upstairs Hall, Downstairs Hall, Shallow Light)

    • These fields also accept Tasker variables as parameters

      • Tasker variables start with a % symbol such as %myvariable or %st_attr_value

      • In the Voice Control Things example, the local variables %command and %device are parsed from AutoVoice and passed to the SharpTools Tasker plugin.