Voice Query: Is the bedroom light on?
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").
Looking for an example of how you can use dashboards or SharpTools.io rules to determine if a light is on? Check out the introduction to dashboards and rules articles:
- Tasker - automation for Android
- AutoVoice (Pro) - voice recognition for Tasker
- SharpTools - SmartThings control for Tasker
- Open Tasker
- In Profiles, click the "+" icon to add a new profile
- Select Event > Plugin > AutoVoice > Recognized
- Click the pencil icon to configure the AutoVoice plugin
- Tap the Speak Filter option and say the following when prompted:
Is the bedroom light on
- 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.
- Check the Exact Command box
- Select the checkmark at the top of the screen to save your plugin settings
- Press the back button on your phone to save the Tasker event profile
- At the prompt to select a Task, select New Task
- Leave the optional Task Name blank and click the check mark to continue
- Click the + icon at the bottom of the screen to add an action
- Choose Plugin > SharpTools> Thing: Get Attribute
- Click the pencil icon to configure the SharpTools plugin
- Select the 'Thing' you want to check the status of
Example: Bedroom Light
- Select the attribute
- Press Apply
Note: the names of the Tasker variables that will be set are displayed at this point
- Press the back button on your phone to save the SharpTools Action
- Click the + icon at the bottom of the screen to add another action
- Choose Alert > Say
- In the Text field, enter: The bedroom light is %st_attr_value
- Press the back button on your phone to save the Say Action
- 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
- Press the back button again to close out the Task Edit
- Press the back button one more time to back out of Tasker completely and ensure the profile becomes active
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.
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:
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:
- 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