Summary
You can get Homey to ask you a question by voice via Alexa, then run different flows depending on the answer you speak back to your Alexa device.
My use case
Sometimes there are situations where I want my Homey to check with me before it does something. One such situation is when we’re leaving the house. I have a a ‘going out button’ (in my case on an iPad dashboard near the door) which triggers a flow to check whether all the doors and windows are locked. If they are, it marks everyone as out (which then triggers flows to switch all the lights off and set the alarm). But what to do if the house is not secure?
I used to have Homey just announce a warning via an Echo dot near the door and then stop (so you had to go and close the offending window and try again). But sometimes we’re in a hurry and want everything switched off regardless. I needed a simple way to enable the user to override the security check when that happened.
Homey has a built-in ‘AND’ card that you can find in the ‘Push notifications’ section which sends a yes/no question to a Homey user via a push message to their mobile. You can then have cards linked to the ‘yes’ or ‘no’ outputs of this card so you can run different ‘branches’ of the flow depending on the answer. This is great, but it’s annoying when you’re leaving the house to have to fumble for your phone to tap a response (especially when in a hurry). The Apple watch integration helps but even then if your hands are full it’s annoying. What if I could make it work by voice instead? Well, it turns out that’s actually pretty easy.
You will need
- One or more Alexa devices
- If you don’t have these already, you can use any model and some of the older Echo dots are available second hand for less than £10 in the UK
- An Amazon account (needed for Alexa)
- An account with Voicemonkey.io (you can log in using your Amazon account)
Overview
We’re going to set up a flow that, in its simplest form, looks something like this:
When the flow is triggered (I actually have my going out button trigger this but have shown a start button here for simplicity), I check whether the house is secure (I have another flow maintaining this variable). If yes, all good - mark me as away (again in practice I have more going on here, but have simplified this example). If the house is not secure, I make a GET request to trigger a flow that I’ve already set up on voicemonkey.io (see below). The final piece of the puzzle is the webhook WHEN card in the top left. This is how the voicemonkey flow effectively sends the answer to the question back to Homey. My voicemonkey flow makes a GET request to this webhook if the user responds “yes” to a question.
The question I have my voicemonkey flow ask me is, “Warning: the house is not secure. Do you want to switch everything off and set the alarm anyway?”. If the user says “Yes”, the voicemonkey flow picks that up and makes a GET request to that Homey webhook in the flow above, and again I am marked as away.
So how is the voicemonkey flow doing this magic, and how do we get it all set up?
How to
Once you have your voicemonkey account set up, you’ll need to head to the console dashboard (console.voicemonkey.io) which looks a bit like this:
Add an Alexa device to Voicemonkey
There’s a bit more one-time set up to do if this is your first time using voicemonkey. You need to create a ‘device’ in Voicemonkey for each Alexa device you want to use with it. Simply hit ‘Manage Devices’ in the top left box, hit the ‘+ Add a speaker’ button and then follow the instructions. Give it a name, then at step 2 you’re going to use the Alexa app on your mobile device to set up a new Alexa routine to use with the device (hit the ‘Tell me how’ button for detailed instructions). Finally, at step 3 an announcement from the device you set up confirms success.
If at step 3 when adding a device to voicemonkey you hear ‘There’s someone at the [device name]’ announced from other Alexa devices in your home, you may need to find the device you just added in the devices section of the Alexa app on your mobile and tap on it to make sure that ‘Doorbell announcements’ are switched off. (This is how voicemonkey is doing its magic under the hood - it’s creating a new smart home device that is pretending to be a doorbell, which it then ‘presses’ via the API and that’s what the routine you created reacts to and launches the voicemonkey skill to do the rest.)
Create a flow in Voicemonkey
Now go back to the voicemonkey dashboard and hit ‘Manage Flows’. Hit the ‘New flow’ button and give the flow a name. You’re then given a menu of options for actions to add to your voicemonkey flow. In the box labelled “Question Prompt”, hit the ‘Add Action’ button. Select the speaker to use the action with (the menu contains all devices you have already set up in voicemonkey using the previous step). Now type the question you want to ask the user in the Question box and finally select the Answer Type as ‘Yes / No’. You can leave the Additional settings on their defaults. Hit the ‘Add Action’ button.
You now see an overview of the flow which should look something like this:
Next, we need to add some actions to the ‘Answer Yes’ and ‘Answer No’ branches of this flow. Hit the plus button next to ‘Answer No’. Scroll about half way down the list of options and add a ‘Speech’ action. Select your speaker from the drop-down menu and enter some text to speak in the ‘Speech’ box. This is what Alexa will say if you answer no to overriding. So something like “OK, alarm not set. Please check the house is secure then try again.”. Again, leave the Advanced settings default and hit ‘Add Action’.
If the user answers yes, we want this to trigger our Homey webhook to override and mark me as away. So next we need to build that Homey flow. Before we do, though, we’re going to need the voicemonkey URL to call to trigger this voicemonkey flow from Homey. On the right hand side of the flow screen in voicemonkey, hit the ‘Visit playground’ button under ‘Trigger using the API’. On the right hand side of the resulting screen is a box labelled ‘API URL’. Copy the text in the box to the clipboard for now.
Create the Homey flow
Next, create an advanced flow based on the example one shown further up this post. For the GET request card, bottom right, select the THEN card that looks like this in the Logic section:
Select ‘GET’ in the Method field and paste the URL you just copied from voicemonkey into the URL field. You can leave Headers and Body blank.
When you’ve got the flow set up, save it, then hover over the little ‘i’ icon on the top left corner of the webhook WHEN card to find the URL for this webhook. Select the URL part of this message and copy it to the clipboard.
Finish the voicemonkey flow
Now we just need to get the voicemonkey flow to trigger our Homey webhook if the user responds Yes. Go back to the voicemonkey flow and hit the ‘+’ button next to ‘Answer Yes’ in your flow. This time, scroll down to the bottom of the list and add a ‘Web request’ action. Paste the webhook URL you just copied into the URL box. Make sure you delete ‘my_event?tag=my_tag’ at the end of the URL and replace with the event name you gave your event in the webhook card in Homey. Leave the method set to its default of GET, everything else on its defaults and hit the ‘Add Action’ button.
Finally, you probably want to give the user an audible confirmation that you’re setting the alarm. So hit the ‘+’ button next to the action you just added in the ‘Answer Yes’ branch and add another Speech action with some suitable message. Remember to set the speaker to the one you’re using for this flow.
Test
That’s it! Now you can test your flow by triggering the Homey flow and try answering different ways each time you test to see what happens.
Other use cases
Once I had this kind of flow working, I found versions of it useful for all sorts of different use cases. One other example was switching off lights in a room once there’s no longer any movement detected there. This kind of setup is notorious for switching off when you’ve just been relatively still in a room for a while, e.g. eating at a kitchen table. With this kind of flow, you can have Homey ask “is anyone still here?” In the room. My kids occasionally try to be clever by answering “No!”, at which point they get what they were literally asking for and all the lights switch off.
I’d be really interested if anyone else is using flows like this or whether you have other use cases or alternative approaches.