Examples‎ > ‎

Voice Query: Is the bedroom light on?

posted Jan 1, 2015, 1:35 PM by Joshua Lyon   [ updated Nov 14, 2015, 7:24 PM ]

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 Okay Google, is the bedroom light on? and your phone will check the status of the light and say the status as a voice response (eg. "The bedroom light is on" or "The bedroom light is off").

Requirements:

Instructions

  1. Open Tasker
  2. In Profiles, click the "+" icon to add a new profile
  3. Select Event > Plugin > AutoVoice > Recognized
  4. Click the pencil icon to configure the AutoVoice plugin
  5. Tap the Speak Filter option and say the following when prompted:
    Is the bedroom light on
  6. Select the option that matches your query from the list that is presented to you.
    Note: AutoVoice will attempt convert your voice command into text and will display the list of options with the most likely option in the first position.
  7. Check the Exact Command box
  8. Select the checkmark at the top of the screen to save your plugin settings
  9. Press the back button on your phone to save the Tasker event profile
  10. At the prompt to select a Task, select New Task
  11. Leave the optional Task Name blank and click the check mark to continue
  12. Click the + icon at the bottom of the screen to add an action
  13. Choose Plugin > SharpTools> Thing: Get Attribute
  14. Click the pencil icon to configure the SharpTools plugin
  15. Select the 'Thing' you want to check the status of
    Example: Bedroom Light
  16. Select the attribute
    Example: switch
  17. Press Apply
    Note: the names of the Tasker variables that will be set are displayed at this point
  18. Press the back button on your phone to save the SharpTools Action
  19. Click the + icon at the bottom of the screen to add another action
  20. Choose Alert > Say
  21. In the Text field, enter: The bedroom light is %st_attr_value
  22. Press the back button on your phone to save the Say Action
  23. At the bottom of the screen, press the play icon to test the Task
    Note: With Tasker 4.6+ you will see a play icon next to each Action in the task as it is executed
  24. Press the back button again to close out the Task Edit
  25. Press the back button one more time to back out of Tasker completely and ensure the profile becomes active

Other Thoughts:

This approach can be used to answer other queries like:
  • What temperature is the AC set to?
    • AutoVoice filter: What temperature is the AC set to
    • Thing: Downstairs AC
    • Attribute: thermostatSetpoint
  • Is the front door locked?
    • AutoVoice filter: Is the front door locked
    • Thing: Front Door
    • Attribute: lock
  • Did I leave the garage open?
    • AutoVoice filter: Did I leave the garage open
    • Thing: Garage
    • Attribute: contact or door or switch (depends on device type)
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 thermostatSetpoint, you might also be interested in pulling in the thermostatMode to see if it is set to heat or cool.

Dynamic Queries

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. %device)

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:
  • AutoVoice Filter: (?<q>Is|Are) the (?<device>.+?) (?<onoff>on|off|on or off|off or on)
Note: Make sure the "Use RegEx" box is checked in AutoVoice when using this approach -- this will convert the funky groups in parenthesis to variables that get captured.

Then in the `Thing: Get Attribute` plugin we would use the following configuration:
  • Thing: %device
  • Attribute: switch
And finally, we could spit out the result using an action like Alert > Flash:
  • Text: The %device is %st_attr_values(1)


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:
  • %st_attr_name
  • %st_attr_value
  • %st_thing_id
  • %st_thing_name
When you use `Thing: Get Attribute` in variable mode, you'll get the following variables (which are each arrays):
  • %st_attr_names()
  • %st_attr_values()
  • %st_thing_ids()
  • %st_thing_names()
For more information on variable arrays in Tasker, see the documentation linked below:

Troubleshooting:

  • Make sure you can manually toggle the desired device from the main SharpTools interface
  • Check the AutoVoice logs
  • Make sure the %st_attr_value variable is spelled correctly as it must be exact
Comments