Making web request to IFTTT


#1

1) Give a description of the problem
I have an IFTTT applet that I want my piston to run. I took a shot, but don’t know how to do this. In piston, I did a ‘POST’ web request of JSON type, and for the ‘value’, I pasted the IFTTT URL from my webcore Settings page.

2) What is the expected behavior?
Piston sends a web request to IFTTT, which initiates a phone call to me and plays a message.

3) What is happening/not happening?
Errors show in trace. IFTTT applet doesn’t run.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach any logs (From ST IDE and by turning logging level to Full)
+1112ms ║Error executing external web request: groovyx.net.http.HttpResponseException: Not Found
12/5/2017, 10:47:17 AM +68ms
+386ms ║Piston waited at a semaphore for 260ms


#2

There is a task called Send an IFTTT Maker event, use that to send your message in value 1 as a variable or as a fixed value.


#3

Hmmm, ok so I changed the task and used the IFTTT applet name as the ‘value’ in piston. It worked (after maybe a 2 minute delay from IFTTT) and called me. But then it ran lines 42 thru 45 again… I guess it will keep doing it until the door closes(?). IFTTT called me multiple times as well.


#4

If you integrate it into your nag SMS/Notification then yes, it will do the same for the ifttt webcall.


#5

I see- thanks for your help! I’d like to make sure the second notification set (text mssg and IFTTT webcall) only happen once. Probably makes the most sense to control it exactly as the first set of notifications is controlled (evaluating the variable “firstNotice”) by creation of a new variable called ‘secondNotice’… but where exactly (what line number?) would I put the new IF statement? And where would I flip the new variable to ‘TRUE’? I defined the new variable already.


#6

If you don’t want to keep getting phone calls and texts then I would suggest not using a while loop.


#7

Thanks @c1arkbar, that makes sense. I couldnt figure out how to replace the WHILE so I created a new piston with IF… but now something is really messed up - It seems to skip the first condition and perform some of the second, but not the phone call. What did I mess up & how??


#8

Are you setting the variable back to false? I see at the end it looks like you are making it blank.


#9

It will work well with a while, nothing wrong with nagging reminders lol, you just need to get creative.

This will speak repeated messages every two minutes (change push notification to 'speak text, I didn’t have any audio devices to test with). The message includes a running timer for how long the door has been open. The first message will be without “Contacting Merrick” and subsequent messages will say that extra bit.

A singe text message is sent at the 4 minute mark.

“Attention, Attention. The refrigerator door has been left open for " formatDuration(Age([ device name : contact]), true, “s”, false) “.” IF(age([Device Name : Contact]) > 210000 , " I’m Contacting Merrick” , “”)


#10

@Robin, THANK YOU so much! Sounds like it should be great- I can’t get to a computer this evening but I’ll try in the morning.


#11

Robin, I replaced the PUSH NOTIFICATION statement with a WITH statement for the speakers, and used SPEAK TEXT (the other options were SPEAK TEXT AND RESTORE and SPEAK TEXT AND RESUME). I put this as the VALUE…

When I tested, at 2 minutes I heard the announcement but she verbalized all the coding (format duration age device…). At 4 minutes I heard similar (maybe same?) announcement and did not receive SMS. Did I do something incorrectly or should I do something different with the quotation marks maybe? Thank you!


#12

Instead of typing it in as a value, you need to type it in an expression window. Look at the dropdown list to the left of the text entry window, and change that to expression.


#13

Got it… getting close- I changed the “device name: contact” to the correct device and it evaluated as it should. On testing, speaker announced same for 2 and 4 minutes:
“Attention, the refrigerator door has been open for 0 seconds dot java dot exception…”. I did not receive SMS at 4 minutes.


#14

You need “contact” after the colons.

Currently you have

age([refrigerator:])

Needs to be

age([refrigerator:contact])


#15

WOW… you guys are amazing! Tested… “Attention: The refrigerator door has been left open for 1 minute 59 seconds” and “… 2 minutes 59 seconds”. I think I found the problem with SMS and will test again.

With the understanding that battery issues or other things can affect contact sensors- I think maybe this will be better as
2 mins: “Attention: It appears that the refrigerator door has been open for xxxx. Please check on it”.
4 mins: “Attention: It appears that the refrigerator door is still open after xxxx. I’m contacting Merrick”.


#16

If you don’t want the granularity of seconds then change the “s” to “m” and it will just say minutes


#17

I considered putting that in my example but I wasn’t sure how the rounding works and was too lazy to test lol

I believe 1 minute 59 seconds would round down to 1 minute?

Unfortunately, most schedules seem to run a few seconds early, hence the 59 seconds.


#18

I changed the ‘s’ to ‘m’ for less granularity, but it appears to be rounding down instead of up (at 2 minutes it verbalized 1 minute and at 4 minutes it said 3). How can I get it to round up instead?

SMS: I thought I had it but it still didn’t send…
.


#19

Ha! Didn’t see your message as I was composing message telling you same.


#20

By the way- I gave up on sending the web request to IFTTT to initiate a phone call to me because I tested and found a ONE HOUR delay in the call from IFTTT.