Tasker+AutoWear+openHAB Android App - Controlling OH from your watch

I got a new Android Wear watch for Father’s Day which has three physical buttons, two of which I can configure to run an app of my choice. I figured now would be a good time to revisit AutoWear to see if I can add the ability to control a few switches that I commonly need to do manually (e.g. opening garage doors).

Since the last time I visited this topic the Android openHAB app has implemented Tasker plug-ins which make this super easy to implement without needing to set up REST API calls.

So why would you want to do this instead of using Google Assistant? I find that I’m occasionally in places where speaking a command isn’t possible or convenient. Also, I find that Google Assistant command to openHAB are not 100% reliable or timely. Having another convenient way to issue the command can help with these problems. Other users may not want to set up Google Assistant at all but still use Android Wear devices and this can work for them too.

Prerequisites

  • openHAB installed and configured with Items that you want to command from your watch
  • openHAB Android App installed and configured to connect to your openHAB instance.

openHAB Config

In my case I have four Switchs that I want to be able to toggle from my watch:

Item Purpose
aGarageDoor1 Any ON command causes the garage door opener to trigger with standard garage door behavior (when closed triggering cause it to start opening, when in motion it causes the door to stop, etc.)
aGarageDoor2 Any ON command causes the garage door opener to trigger with standard garage door behavior
aMBR_Lights ON command turns on the master bedroom lights, OFF command turns them off
gLights_ALL ON command turns ON all the automated lights in the house, OFF command turns them off

These are all Switches and the specific configuration of these Items is beyond the scope of this tutorial. I assume that you already have openHAB configured and you are simply expanding the ways you can control it.

Other types of Items can be supportable, in particular Number Items. I’ve not fully explored all the available options yet to find limitations but right now I don’t see any limitations. Please post a reply if you encounter one.

openHAB Android App

Open Settings and scroll down. Turn on "Tasker integration "

Tasker

Tasker is very complicated to figure out how to use. It’s probably every bit as complicated as openHAB itself, and it’s just as rewarding once you do. At a high level it shares a lot of commonality with openHAB and, unsurprisingly there are a number of tutorials here on this forum showing various ways to use Tasker and openHAB together. It’s purpose is to automate pretty much anything that can be done on your phone. There is very little you cannot automation with Tasker. For example, I have a Task that:

  • when connected to the BT speaker in the car
    • start Android Auto
    • if I’m at HOME (determined by my WiFi SSID being near by)
      • open a dialog to open the garage (issues the command through the Android app to openHAB)
    • save the screen’s current brightness settings
    • turn off auto brightness on the screen
    • if it’s not NIGHT set the brightness to about 75%
    • if it is NIGHT set the brightness to about 90%
    • change the display timeout to 4 hours
    • bring up a dialog asking what audio playback app to start (it remembers the last app chosen and will automatically start that one if one isn’t chosen in time)
    • if it is LATE_AFTERNOON and my location is WORK (determined by GPS)
      • open Waze and navigate to home
    • if it is MORNING on a WEEKDAY and my location is HOME
      • open Waze and navigate to work
    • else
      • just open Waze
    • open the dialog to close the garage door

This isn’t going to be a full tutorial for Tasker, it’d be too long. There are tons of examples and tutorials out there. But there is one thing that might help users who know openHAB, Tasker is both event driven and state driven.

Install Tasker

You can find Tasker on the Google Play Store at https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm. It does cost and IMHO the cost is well worth it. There is a trial that you can use to evaluate whether this is something you want to pursue.

Once installed open it and it might ask for all sorts of permissions. In order to access the information and do the things it needs to automate your device, it needs a lot of permissions. If you know you don’t plan on ever using certain features (e.g. location based automations) you can refuse those permissions. You can always enable them later.

Watch for notifications and toasts. Those will indicate errors and provide some additional information.

Create tasks to send commands to openHAB Items

We need to create a Task to send commands to your openHAB Items. NOTE: the screenshots you will see shows all sorts of stuff I already have installed and running in Tasker. I’ll try to highlight the elements of interest.

Open Tasker and click the “TASKS” tab. Then select the + icon at the bottom right.

Give the task a meaningful name (you will need this name later).

Tap the check mark.

Now we need to add stuff to do in this task. These tasks will be very easy, all they do is send a command to an openHAB Item. Tap the + icon at bottom left. You will be presented with a lengthy list of categories each with a bunch of stuff you can do in that category. Scroll the list a little until you see the “Plugin” category and tap it.

Choose openHAB from the list (I’m running the beta version of the app).

This will open the configuration screen. Tap the pencil icon next to “Configuration”.

Make sure that “Command” is selected at the top and scroll down to the Item you want to control. Tap it and select the command you want to send. I this case I selected aGarageOpener1 and chose “ON” as the command.

Set a reasonable timeout and check the box next to “Continue Task After Error”. Also take note of the little note that was added under Configuration. The HTTP return code will be saved to a variable called %httpcode. We will use that to generate an error message if the command failed.

Tap the arrow at the top to save the changes.

There will be a play icon at the bottom. Tap that to test that the task works.

You should see that the command was issued to that Item in openHAB’s logs (at a minimum).

Optionally, you can set an icon for the task by tapping the grid of squares icon at the bottom center and browsing through the various icons.

Once you have everything set up the way you want it, you can clone the task by long pressing the task you want to clone to highlight it. Then tap the three dots menu at the top right and select “Clone” from the menu. Change the name and then change the stuff inside the task as appropriate (e.g. select a different Item to end the command to or select a different command to send. This is particularly useful if you add more to the task than just issuing the command to the openHAB Item (e.g. alerting with a Flash or error handling. In my case, I created the following four Tasks:

Task Name Item Command
Open Garage Direct 1 aGarageDoor1 ON
Open Garage Direct 2 aGarageDoor2 ON
Toggle MBR Lights aMBR_Lights Toggle
Toggle All Lights aLights_ALL Toggle

Now that you have tasks successfully commanding OH Items, you can do all sorts of stuff. You can put a 1x1 widget on your desktop to trigger the task. You can add the task as a tile in your quick settings area in the pull down. You can call tasks from tasks so, for example, you could turn off all the lights when you put your phone face down on the desk after dark.

AutoWear

AutoWear is one of the suite of Auto Tasker plug-ins which greatly increase and enhance the capabilities of Tasker. In this case, AutoWear extends Tasker to your AndroidWear watch. You can create apps, screens, complications, etc. which can come up based on events on your watch (e.g. wrist shake) or your phone.

Unfortunately, AutoWear is really challenging to figure out. Hopefully this section will provide just enough information to get started.

Installation

Install the AutoWear app on your phone. As with Tasker, this plug-in does cost. https://play.google.com/store/apps/details?id=com.joaomgcd.autowear

Before running the newly installed app, open the Play store on your watch and search for and install the AutoWear app there as well. You need it installed in both places. Run the AutoWear app on your watch and accept the permissions it requests. Now return to your phone and run the AutoWear app and accept the permissions it requests as well.

There will be a tutorial that will come up with a bunch of videos you can watch for how to set up various things. I encourage you to go through the tutorials but you can skip them for now. Eventually you will end up at a screen that looks like:

  • Screens are custom UIs that can be displayed on the watch. We will be creating a display with a list of entries that can be interacted with to trigger Tasker tasks.
  • Floating Icons can add an always present (or you can control when it becomes present) icon on your watch face that can be tapped to cause stuff to happen (e.g. open a Screen)
  • Complications are icons that can be added to existing watch faces that support complications. They can show information and/or launch stuff (e.g. open a Screen)
  • Notifications allow you to add a notification to the watch.

The rest are things that will need to be explored on your own. For this tutorial we will only be using Screens but you might be interested in the others as ways to launch tasks.

How we will use it

AutoWear is very complicated and very powerful. The following is merely one way to use it to accomplish commanding openHAB Items.

  1. We will create a Screen with a list of Items that can be commanded
  2. We will link that Screen to a Launcher App. Launcher Apps are a set of predefined app stubs whose purpose is to add an entry to your list of apps. When opened an event is generated and tasks can be done in response. In our case we will show the Screen from 1. This Launcher App can be called manually and, if supported, called by pressing one of your physical buttons.
  3. The Screen will have four entries in the list, one for each Item discussed above. These Items will be configured so that when they are tapped, they will issue a command to Tasker with a special format.
  4. Tasker will have a profile and task created to receive those commands from AutoWear and then call the four Tasks we created above.

Let’s start with 4 and set up Tasker.

Tasker Configuration

In the “Profiles” tab in Tasker click the + icon and name it “Autowear Command” and tap the checkmark. Tap “Event” from the list and then select “Plugin” and finally select “AutoWear”.

Tap the pencil icon and under “Command Filter” enter task=:=. This will match any command from AutoWear that starts with task=:=. We will configure AutoWear to issue commands of the format task=:=Task Name, for example task=:=Open Garage Direct 1. Tap the checkmark icon to accept. Then tap the arrow to accept the profile trigger.

A list of tasks to select will appear. Scroll up to see “New Task +” at the very top.

Name it “AutoWear Task Command”.

Tap the + icon and select Task and then Perform Task. Under “Name” tap the variables icon and select %awcomm from the list of variables. This variable is set by AutoWear and it includes everything after the =:=. So if we use the task name in the AutoWear commands, this little task will receive those commands and run that task by name.

NOTE: If you do not exit Tasker after making changes, in order to enable any changes you’ve made tap the checkmark icon at the top right.

Enable a Launcher App

On your watch open AutoWear Settings. Scroll down to “Launcher Apps” and open it. You will see a list of a bunch of random seeming workds. These are the names that will be used as the application name. I chose “Automation” from the list and toggled it on.

screen

You will now see a new application in your list of apps called “Automation”.
screen(1)

This is the app that we will use to launch the screen with the list of Items to tap.

Create the Screen

On your phone, open the AutoWear app and tap “Screens”. Tap the + icon at the top right.

You should experiment to come up with the best screen type to use given the way you want to interact with your openHAB Items from the watch. I originally chose “Buttons Screen” but there is no text and I didn’t want to have to come up with different buttons to represent the two garage door openers and the two lights. So I chose “List Screen” instead.

Unfortunately, I find this screen both confusing and awkward to use.

Setting Purpose Notes Value
Screen Name A unique identifier for the screen, used by AutoWear, not shown anywhere Home Automation
Command to Show Select the event that causes this Screen to be shown Select “yes” to see pre-defined Events “App Opened Automation”
Header Text Text at the top of the Screen You will need to experiment with some basic HTML formatting to get the color and position right. It does not follow the Text Color setting (see below). <br/><br/>Home Automation
Labels The list of labels to show. One for each entry you want in the list. GD 1, GD 2, MBR Light, All Lights
Icons The icons to show to the right of the list entries. Select “YES” to get help selecting a file. Select icons for each entry in the list. Order matters. I selected all from Ipack Icons.
Commands The list of commands to send for each entry when it’s tapped. Put the list of the Task names as they appear in Tasker (see above). Open Garage Direct 1,Open Garage Direct 2,Toggle MBR Lights,Toggle All Lights
Long Tap Commands List of commands to send for each entry when it’s long tapped. Not used
Double Tap Commands List of commands to send for each entry when it’s double tapped. Not used
Command Prefix Text prepended to each command (i.e. the stuff before =:=). task
Trigger Events Check to enable sending the commands to Tasker checked
Text Color Color of the text in the list. Does not change the Header. white
Text Size Size of the text in the list. Does not change the Header. default
Background Color Chose something close to openHAB orange.

There are more entries you can play with if desired. Tap the checkmark icon at the top.

Usually, when a new screen is created or edited, it will open on your watch automatically. If it didn’t open automatically, open the “Automation” app from the list.
screen(2)

Test it out. Tapping an entry should trigger the assocaited Tasker Task which should in turn send the appropriate command to the openHAB Item.

Not bad for about 20 minutes of effort. :slight_smile:

Physical Button

Many of the more recent Android Wear watches come with three buttons. Two of those three buttons can often be customized to open the app of your choice. Open settings on the watch and scroll down to “Personalization” and then to “Customize hardware buttons”. Choose which button you want to launch your AutoWear screen and choose the “Automation” app from the list.

screen(3)

Conclusion

AutoWear is really powerful. You can do almost anything you can think of using it. Hopefully the above will give you enough to get started. I look forward to seeing what you do with this. Post a reply with your questions, comments, and successes.

6 Likes

I’ll second these statements. Tasker is great, but there’s a lot of trial and error just to figure out if the thing you want to do is possible, or to determine which AutoApp you need to install. I appreciate the developer’s efforts; he just doesn’t have a strong interest in documentation (and neither did the previous owner). :wink: