Adding Conditional Logic To Amazon Alexa Routines

Posted on
Mon Jul 24, 2023 1:25 pm
mgolden50 offline
User avatar
Posts: 261
Joined: Jan 29, 2007
Location: Chandler, AZ

Adding Conditional Logic To Amazon Alexa Routines

I had become frustrated (after years of waiting), that Amazon has yet to add variables and/or any kind conditional logic capability to its “routines” functionality. Perhaps they believe these basic concepts would be too confusing to the typical consumer.

I have attempted to resolved this missing capability using a somewhat cumbersome, but still very reliable combination of the Indigo Alexa plugin, the Alexa IFTTT Trigger skill, and the Indigo Trigger’s conditional logic capability.

As an example of an Alexa routine for which I desired to use conditional logic to is the conditional control of an electric window shade. I use an electronically controlled Moen shower that is turned on and off using voice requests with an Alexa routine and a Moen-Alexa skill. When the shower is asked to turn on, the routine also opens only the top half of the bathroom shade (for privacy). When a voice request is made to turn off the shower, a routine is invoked that turns off the shower then waits for 10 minutes. After the wait is over, I wanted the shade to fully open if it’s daylight and two fully close if it’s dark outside.

The solution for making the above work was to create a sequence of exchanges between Alexa routines and Indigo that take advantage of Indigo’s conditional execution abilities. It works like this:

As the last step of the Alexa “shower off” routine, the routine turns on a published Indigo Virtual Device named “bathroom_shade”. (Note: I use underscores to replace spaces for virtual device names to distinguish them from physical devices when they appear in Alexa’s device list.)

I then create two conditional Indigo triggers. Both are triggered by any state change in the device “bathroom_shade” when and “on” or “off” command is sent by Alexa to Indigo. For the first Indigo trigger, if the condition is “Isdark” it sends to Alexa the IFTTT trigger “CloseShade”. For the second Indigo trigger, if the condition is “isdaylight”, that trigger sends Alexa the IFTTT trigger “OpenShade”.

When one of the two IFTTT triggers is received by Alexa she executes the appropriate routine to either actually open or close the shade.

Please see my earlier posts further explanation on using IFTTT triggers to control Alexa routines.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests