Search code examples
aws-lambdaiotalexa-skills-kitiftttamazon-echo

Create a toggle between two actions in IFTTT


I have a simple device (Nordic Thingy 52) with a push button which can trigger the Maker Webhooks service in order to pass an event (button_press), which I am currently using to then trigger the Smart Life service's "Turn Off" or "Turn On" action.

The problem is that, since I can only pass the one event (button_press), I have to choose whether that event triggers either "Turn Off" or "Turn On". But what I want is to add some logic to say, "If the previous request was to turn off the Smart Life device, make the next one turn on the smart life device."

Wasn't sure how to do this. An AWS Lambda function? Chaining some other preexisting service? A filter that utilizes local storage or somehow handles state logic?

Any pointers for where to start searching would be appreciated.

enter image description here


Solution

  • I figured out a way to do this with a service called apilio.

    Process:

    Head to apilio.io and register for an account.

    • Enter your IFTTT token in your user profile page.
    • Go to Boolean Variables and enter a variable called bln_light_on. Set its default value to false
    • Go to Conditons > New Condition for Boolean. Call it cnd_light_on.
    • Under variable select bln_light_on with a required state of True.
    • Under name create a name of lgc_light_on with conditon cnd_light_on, with Condition Linking set to Simple AND
    • Under Action Chains > Actions for Positive Result enter button_on
    • Under Action Chains > Actions for Negative Result enter button_off
    • Under Execution Mode select Immediate. Under Advanced Options > Automatic Evaluation select Evaluate this logicblock when any connected variable changes. Now, in IFTTT, create a New Applet > Web Hooks > If maker Event "button_press", then > Web Hooks > make a web request In the URL field you’ll enter the Toggle URL from the bln_light_on Boolean Variable you set up in Apilio. You can see this by clicking Boolean Variables > bln_light_on > show from the menu. Lastly, in the Nordic Thingy Web App, send the event button_press