Working with todoist API in Webcore


#1

So I have yet to create the piston, but that should be the easy part… the hard part is todoist and I prefer not go down that particular road without understanding whether I should do this directly through webcore or through webcore and IFTTT. Anyway here goes the simple piston.

If battery < 25%
Then
Add Todoist reminder replace {device_name} battery tonight at 7pm on #home list.

Obviously to add the todoist reminder, I must send data using the todoist web api WHICH I HAVE NEVER DONE BEFORE but seems like a fun challenge.

An example of the code needed to create a task is here:

curl https://todoist.com/api/v7/sync
-d token=0123456789abcdef0123456789abcdef01234567
-d sync_token=“VRyFHr0Qo3Hr–pzINyT6nax4vW7X2YG5RQlw3lB-6eYOPbSZVJepa62EVhO”
-d resource_types=’[“projects”, “items”]’
-d commands=’[
{ “type”: “item_add”,
“temp_id”: “fdef5d16-a40a-475e-bd4a-0ccbd6fd8c3f”,
“uuid”: “a3aa2f44-23b4-4986-b513-ef7663bbb752”,
“args”: { “project_id”: “24a193a7-46f7-4314-b984-27b707bd2331”, “content”: “Task1” } },
{ “type”: “item_add”,
“temp_id”: “6f5e0b50-af7a-4133-bfc0-e8c041b819d2”,
“uuid”: “d16ad84a-e10b-4894-af7d-93ba6adf7a1e”,
“args”: { “project_id”: 176637191, “content”: “Task2” } },

So again my question, is webcore capable of passing this through directly or should I use a web hook?


#2

You’re out of luck for now :sob:


#3

Why? In layperson terms


#4

I’m sure @ipatersoncan do a better job at explaining this…


#5

Forgive the fact that I do not know how to change this from Piston: Design Help to Example. But here is a piston that ultimately accomplished what I wanted.

This piston monitors the battery of my devices. If the battery level drops beneath certain threshold, I get a push alert AND a reminder is sent to Todoist to remind me to change the battery over the weekend.

One question: I find that I now get duplicate reminders because I am getting the same alert multiple times. How can I prevent this. In other words, I get an alert on Tuesday saying the closet motion sensor battery is at 10% please change on Saturday. I get the same alert wednesday which means this item is added twice to my todoist list. Given the fact that the piston only triggers upon a DROP in battery percentage, I am unsure as to why I am receiving the alert.

1/24/2018, 7:09:42 AM +534ms
+1ms	╔Received event [Master Bathroom Shower Motion Sensor].battery = 11 with a delay of 156ms
+415ms	║Runtime (54884 bytes) successfully initialized in 59ms (v0.2.102.20180116) (413ms)
+417ms	║╔Execution stage started
+582ms	║╚Execution stage complete. (166ms)
+584ms	╚Event processed successfully (584ms)
1/23/2018, 11:40:31 PM +295ms
+2ms	╔Received event [Master Bathroom Shower Motion Sensor].battery = 1 with a delay of 206ms
+184ms	║Runtime (54854 bytes) successfully initialized in 48ms (v0.2.102.20180116) (182ms)
+185ms	║╔Execution stage started
+1065ms	║║Executed virtual command sendEmail (677ms)
+1070ms	║║Executed virtual command setVariable (1ms)
+1099ms	║║Executed virtual command sendPushNotification (9ms)
+1116ms	║║Executed virtual command setState (0ms)
+1134ms	║╚Execution stage complete. (949ms)
+1135ms	╚Event processed successfully (1135ms)