It’s 10pm, do you know where your Automower™ is?
Google Assistant Actions are pretty interesting and it would be pretty cool to be able to create an Action that would tell you the location of your Husqvarna Automower relative to your property along with additional information such as when it was last seen, and the battery charge.
As would be expected — this doesn’t exist as it would require gluing together several separate pieces:
- An unsupported Husqvarna API.
- Relative locations that you refer to on your property (“front yard”, “side yard”, “back of the house”, et cetera).
- Custom Google Actions / Webhooks.
So, let’s build it.
Get That Data
The data we require is in the response from the unsupported Husqvarna API. I wrote about this previously here.
Assuming that you are running the same collection server locally based-on husmow, you would be able to also run a service that defines your areas in your yard and how you want them represented.
Script / Service to collect (and write) the data:
This shouldn’t require too much customization but the main part that needs to be catered for you is the areas you would like to define. You can use any map coordinate software that you would like to define the boundary box for each area and then the language that you would like to define that area if your mower is found within it.
SAVE_API until the next section where we write this data to be then read by a Google Action.
Writing the Data
To be able to have the data available to a Google Action, it needs to be readable from a conversational webhook.
For this, we can have a simple Google Cloud Function that allows reading the status and writing the status. One note: This is entirely public so if you have any concern for privacy of your mower / mower data — you should consider other options.
Your function can be as simple as follows:
This writes a message to Google Cloud Datastore and reads that same key (
message) out. The key is deployed in-line which is not secure.
Once deployed, you can simply request the current status with:
curl https://<YOUR FUNCTION URL> cloudfunctions.net/automower
Now you may update the previous service / script with your Cloud Function URL.
Creation of the Google Action
The Google Action(s) interface and setup process is absolutely terrible. It might be one of the most confusing onboarding / quick start processes I have seen with a product lately — but it does rival the confusion of Google Cloud Datastore in Native or Datastore mode (or is it Google Cloud Datastore Firestore in Native Mode Wednesday Afternoon Australia Day?).
- Create or use an existing GCP Project on https://console.actions.google.com.
- Try to follow the Wizard (which will error) and set the Display Name to “Where is <Name of your Mower>”
- Set it to call a webhook, name it
defaultor something that doesn’t have any spaces, or dashes (which you don’t learn about until later in the process).
- Head down to the Webhook and let them manage / deploy the function. It can be very simple with the following:
This will look like this, in the console:
- Deploy and head over to Test.
- Assuming that you resolve any issues w/Testing, it should be fully functional. You likely would want to write an initial value to Datastore.
- Set yourself up as an Alpha tester by heading over to Deploy > Manage Alpha Testers. Add your Google Account that you use with Google Assistant and open the URL on your mobile device.
If you made it through all of the complexities of build / deployment, setting up of a Google Action, creating an Alpha release, et cetera then you will enjoy the outcome-
- It’d be nice to get the Action out of Alpha mode to be able to customize some of the settings a bit more. To do this doesn’t really seem possible with Google’s ToS (attempted and denied multiple times).
- Removing the “Talk to” prefix in the invocation. Not quite sure what is necessary to do that.
This was not meant to be a thorough or step-by-step tutorial. That would likely be a much more involved and potential unreadable document. The complexity with setup, build, and deploy have just gotten to a point when connecting this many pieces that it is quite difficult and time consuming to document for others which is unfortunate.