Create a toggle between two actions in IFTTT

1,840 views
Skip to first unread message

mhea...@gmail.com

unread,
Mar 28, 2018, 6:52:22 PM3/28/18
to Apilio
Hi - Just found this service, and I think it will do what I need it to, but I couldn't quite figure out the format for everything.

I have a simple device (Nordic Thingy 52) with a push button which can trigger the Maker Webhooksservice 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."


So I set up a boolean `button_press` - default false

Then I set up a condition: button_on - which requires a button_press value of of true

Now I am trying to set up a logic block `button_on_true`  - and in the action chains section, under Add IFTTT actions, I see IFTTT Maker Channel Event name field. What do I enter here?

I want this to trigger the smart things app on or off modes. 

In my IFTTT account, I actually have two maker event applets - if maker event button_on > Turn On Smart Plug, and if maker event button_off > Turn Off smart plug. Does that mean I just put `button_on` and `button_off` in the Action chains section for positive and negative results / respectively?


Chillihead

unread,
Mar 28, 2018, 7:57:27 PM3/28/18
to Apilio
On face value, that sure sounds like you have things how you need them. Did you try that already? Did it work?

mhea...@gmail.com

unread,
Mar 28, 2018, 8:43:22 PM3/28/18
to Apilio
It isn't, but maybe I'm not integrating it properly via IFTTT.

Right now, I essentially have three applets:

my original two, which work to turn off and on the lights if they are set explicitly: 

IF webhooks > event > button_on THEN smart life > turn on device
IF webhooks > event > button_off THEN smart life > turn off device

and one new one, which is:

IF webhooks > event > button_press THEN > webhooks > web_request

where, for "make a web reques" URL field, I've pasted the link to my toggle:


Are there more applets that I need to set up? Or should I be pasting the URL to my logic block evaluation trigger?


Chillihead

unread,
Mar 28, 2018, 8:46:33 PM3/28/18
to Apilio
I replied the email that I recieved, so not sure if you have seen that. Just in case, this is what I wrote:

If I was doing this, I’d probably do it like this:

 

Create a Boolean variable something like “bln_light_on” and set it to false.

Create a Boolean condition called something like “cnd_light_on” with the required state being “true”.

Create a logicblock called something like “lgc_light_on”, and choose the “cnd_light_on” condition to test. In the positive result, I’d put “light_on” and in the negative result I’d put “light_off”.  Put a check in the automatic evaluation of the logicblock when the value changes (at the bottom) to get it to fire.

 

From the “bln_light_on” Boolean value’s save screen copy the Toggle URL and use this from your button to do the toggling of the state.

 

I’d then set up two applets within IFTTT to receive a WebHook from the logicblock above. For the light on applet, use the “light_on” action and of course, for the negative action I’d use “light_off”. Then for the THAT part use whatever it takes to turn your light on / off.

 

I haven’t tested this and can’t hand on heart say that it works, but it sounds solid in theory…

mhea...@gmail.com

unread,
Mar 28, 2018, 10:39:22 PM3/28/18
to Apilio
Thanks - this has been really helpful. I think the only thing that is stumping me is what you put as the URL for the two webhooks in IFTTT. 

Chillihead

unread,
Mar 28, 2018, 10:44:21 PM3/28/18
to Apilio
If you are setting up applets to turn your lights on / off then you don't need the URL

Your IF filter is the Webhooks / Recieve A Web Request. In the Event Name box, put the name of the positive / negative action from the LogicBlock.

Your THAT filter is of course the filter to de/activate your light.

Chillihead

unread,
Mar 28, 2018, 11:10:36 PM3/28/18
to Apilio
I have taken a few minutes to put my theory into practice and rather than toggle my lights I set it up to receive IFTTT notifications. It worked, so I'm confident that this will do what you are after.

One thing I didn't say is that for your first webhooks request to do the toggle, you need to set the "type" to text/plain.

mhea...@gmail.com

unread,
Mar 28, 2018, 11:17:24 PM3/28/18
to Apilio
Ah - I figured out the missing piece in my brain. The button - the Nordic Thingy - it sends an event. The event it needs to send (using your example) is `bln_light_on`. Then you need to set up a third event in IFTTT, which is:

if > webhooks > maker event > bln_light_on:
then > webhooks > make a web request > [URL TO TOGGLE OF bln_light_on].

It's working now. Thanks!

Chillihead

unread,
Mar 28, 2018, 11:23:47 PM3/28/18
to Apilio
Glad to hear it's working, although it sounds like you've done it slightly differently to my example. But that's by the by.

You are welcome :-)

mhea...@gmail.com

unread,
Mar 28, 2018, 11:29:41 PM3/28/18
to Apilio
Wait - how is it different. Because my current implementation seems very buggy. But as mentioned in the original post - I can only send one event from the Nordic Thingy. And your example lists two different IFTTT applets.

pebneter

unread,
Mar 29, 2018, 12:23:59 AM3/29/18
to Apilio
Hi! Great discussion!

Are you aware of the „toggle“ function that boolean variables offer?

I would toggle of the boolean variable with every button press (because your button can send only one state).
Then have a logicblock which either puts your target service on or off (depending of the state of the boolean variable).
-> the only change to your discussed solution being to use „toggle“ instead of set_true/set_false.

On your initial post you asked what to put into the „event name“ field: The part must match the identifier of your IFTTT webhook applet. That way IFTTT knows whoch one of your webhook applet it should activate.

Cheers
Philipp

mhea...@gmail.com

unread,
Mar 29, 2018, 12:47:14 AM3/29/18
to Apilio
Hmmmm...as far as I can tell, I am doing exactly what both of you are recommending, and things still aren't working properly. I am including a step-by-step screenshot of my entire configuration. To note, if, within apilio, I explicitly hit the URL for the lights_on or lights_off variable, things work just fine, but the URL listed for the toggle is not working. Likewise, within the Nordic Thingy app, if I explicitly send lights_on or lights_off, it works - but not if I send the boolean event

BOOLEAN:


CONDITION:



LOGIC



IFTTT: button_press hits the Apilio toggle:



ALL IFTT EVENTS (light_off and light_on work fine, button_press does not)



Nordic Thingy Web App Event trigger (if I type light_off or light_on it works, but button_press toggle does not):






Chillihead

unread,
Mar 29, 2018, 2:46:46 AM3/29/18
to Apilio
Your button press IFTTT should be MAKING a web request (using the TOGGLE URL) not receiving a web request. If you get that swapped over it might work....

Chillihead

unread,
Mar 29, 2018, 2:53:32 AM3/29/18
to Apilio
To be more precise the IF should be the button press and the THAT should be the call to the URL.

pebneter

unread,
Mar 29, 2018, 10:48:16 AM3/29/18
to Apilio
The screenshots look good to me (except that you should switch the actions for negative/positive result, but that’s just for the perfectionist).
Does it work when you call the toggle URL from the browser?

Philipp

P.S.: you should obscure the keys in your screenshots.

mhea...@gmail.com

unread,
Mar 29, 2018, 11:26:16 AM3/29/18
to Apilio
Thanks for all your help, both of you. It's working now! I think I just had to restart everything - might've been making too many requests or something just got mixed up with bluetooth or wifi. Your help was really invaluable. 

Chillihead

unread,
Mar 29, 2018, 1:36:41 PM3/29/18
to Apilio
Brilliant! Glad to hear it:-) You are very welcome.
Reply all
Reply to author
Forward
0 new messages