How to configure IFTTT to trigger Particle device?

this should be

int control(String command) {

(that was an oversight on my part :blush: - corrected above)

2 Likes

Thank you very much. Code was corrected and verified.
Now, when I try the html code, get this error:

yup
after you flash the new code
you can call your function control from Particle comsole
or from Particle App. with args like , lock or unlock or start directly and you will get the return value as response so you will know if the function works correctly.

1 Like

Error 400 something wrong with HTML

try this :


function test(cmd){

     	var fnPr = particle.callFunction({ deviceId:deviceID2, name:'control', argument: cmd, auth: accessToken2});

		fnPr.then(

		  function(data) {

			console.log('Function called succesfully:', data);

         }, function(err) {

			console.log('An error occurred:', err);

		  });

           

     }


test('lock');

setTimeout(function() {

test('unlock');

}, 2000); 

setTimeout(function() {


test('start');

}, 4000); 
1 Like

I got this in return:

function test(cmd){ var fnPr = particle.callFunction({ deviceId:deviceID2, name:'control', argument: cmd, auth: accessToken2}); fnPr.then( function(data) { console.log('Function called succesfully:', data); }, function(err) { console.log('An error occurred:', err); }); } test('lock'); setTimeout(function() { test('unlock'); }, 2000); setTimeout(function() { test('unlock'); }, 4000);

I was able to call function with arg from the app.

But the applet is still not working. Here is how I have it setup: Am i missing anything:

Okay I think I got it. I had the wrong token in the applet! corrected it and now lock and unlock work but not start!

Let’s forget right now about html (any way you have to edit and copy/paste the test function and all below it also in function arguments should be { deviceId:deviceID } not
{ deviceId:deviceID2 } :man_facepalming:t3: sorry my mistake ) and focus on IFTTT
Did you try to call your function directly from console or from Particle app ? If yes what’s the return value when you call it with start args ?

I used the app to call the function and arg. I got 3 in retuen when i called conteol - start.

Which is mean that it’s working correctly. :+1:
How do you check the state change od D2 ?
The Delay is pretty small 250ms.
Could you connect some small LED with 1K rsistor to D2 and GND and extend the delay a little e.g 400ms but this is not necessary if D2 change the state you’ll be able to see fast “blink”

250ms works great for my device. I had IFTTT SETUP to trigger particle directly, whixh worked up until I chnaged it to go through webhook.

I will check boron in thr vehicle and see if all wires are still connected well. Who knows with how how it has been i dont doubt D2 wire got loose somehow. I will keep you posted.

Thank you,
Yazen

Problem solved!!

I had the valet switch on! Turning it off fixed it. Now can lock, unlock and start my vehicle from my cellphone.

Thank you all for all your help. You guys are awesome.

Yazen

2 Likes

I’m glad that it’s working! just as a side note if you a iPhone user you can achieve this functionality with Siri Shortcuts and App named Scriptable. Let me show you how.

  1. Download and install Scriptable then “+” new script:

let a =  {args:"lock"}
let accessToken = "put_your_access_token_here"
let deviceID ="put_your_devID_here"
url = "https://api.particle.io/v1/devices/" + deviceID + "/control"

req = new Request(url)
req.method = "POST"
req.headers = {"Content-Type":"application/json","authorization":"Bearer " + accessToken}

req.body = JSON.stringify(a)
json = await req.loadJSON()
QuickLook.present(json)
//Speech.speak(json)

here is just one for lock car but the rest is identical just variable a args are different
a for unlock:
{args:"unlock"}
a for start:
{args:"start"}

  1. go to Siri Shortcuts and add new then click “add action” and search for Run

  2. select scriptable Run script and chose apriobate script

  3. save and add to home screen then on Home Screen add all 3 shortcuts to one bookmark rename e.g My Car and done.


It’s pretty save because when iPhone is locked Siri will not run any shortcut as long as the action require third-party application.
I run my garage opener with this approach for a while and is working pretty well :grin:
Hope that will be useful :+1: best,
Arek

2 Likes

Oh wow thats neat! Well, I am an Android user. Is there somethjnf simillar for Android thst you know of?

Thank you,
Yazen

The scriptable app is available for Android as well but I’m not sure what can be use instead of Siri Shortcuts :thinking:

1 Like

awesome applet! do you have a wiki on how to adapt the Particle IO to your car? I’m interested

thanks and congrats!

-R

So in the car, I have installed Fortin evo all. In evo all, there was a option to enable which lets you start the car if one of the inputs on evo all gets a pulse. Then used a particle device to generate a pulse when triggered through the web. Then used ifttt to start/lock and unlock the car from the phone, or from google home. Hope this was helpful. If you need more information please let me know.

Yazen